feat(ocm-move): plan worktree mirror targets and stream move progress (#345)

* feat(ocm-move): plan worktree mirror targets and stream move progress

- Plan/ensure mirror targets per branch via new internal endpoints, creating a worktree repo when the target branch is not checked out in the source repo
- Skip branches checked out in other worktrees during bundle import and reset/clean before checkout on both server and CLI
- Rewrite workspace paths in message.updated events when replaying moved sessions
- Stream live move progress (bundle, upload, import, patch, replay) in the TUI
- Prefer branch-matched repos when moving sessions and share push-divergence descriptions

* chore(ocm-cli): bump version to 0.2.7

* fix(ocm): harden worktree mirror synchronization

* fix(ocm): protect active branch during branchless pull
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-01 22:14:48 -04:00
1 parent 4ed3460759
commit 68d586f183
23 files changed
+2026 -158

No files matched your search

+64
View File
@@ -1,4 +1,5 @@
import { getRepoRoot } from './local-repo.js'
import type { RemoteRepoSummary } from './mirror.js'
export interface TargetRepo {
repoId: number
@@ -6,6 +7,69 @@ export interface TargetRepo {
branch: string | null
directory: string
projectId?: string | null
isWorktree?: boolean
}
export interface RepoIdentity {
repoId: number
name: string
branch: string | null
isWorktree?: boolean
directory?: string
}
export function formatRepoIdentity(repo: RepoIdentity): string {
const parts = [`id=${repo.repoId}`, repo.isWorktree ? 'worktree' : 'repo', `branch=${repo.branch ?? 'n/a'}`]
if (repo.directory) parts.push(`path=${repo.directory}`)
return `${repo.name} (${parts.join(', ')})`
}
export function formatRepoIdentities(repos: readonly RepoIdentity[]): string {
return repos.map(formatRepoIdentity).join(', ')
}
export interface RepoIdParseResult {
repoId: number | null
error?: string
}
export function parseRepoIdPositional(args: readonly string[], knownFlags: readonly string[]): RepoIdParseResult {
let repoId: number | null = null
for (const arg of args) {
if (knownFlags.includes(arg)) continue
if (arg.startsWith('-')) {
return { repoId: null, error: `unknown option: ${arg}` }
}
const id = Number(arg)
if (!/^\d+$/.test(arg) || !Number.isSafeInteger(id) || id <= 0) {
return { repoId: null, error: `invalid repo id: ${arg}; expected a positive integer` }
}
if (repoId !== null) {
return { repoId: null, error: `multiple repo ids given: ${repoId} and ${arg}` }
}
repoId = id
}
return { repoId }
}
export interface MatchRestriction {
matches: RemoteRepoSummary[]
error?: string
}
export function restrictMatchesToRequestedRepo(matches: readonly RemoteRepoSummary[], requestedRepoId: number | null, localProjectId: string): MatchRestriction {
if (requestedRepoId === null) return { matches: [...matches] }
const selected = matches.filter((m) => m.repoId === requestedRepoId)
if (selected.length === 0) {
const available = formatRepoIdentities(matches)
return {
matches: [],
error: available
? `repo ${requestedRepoId} does not match project ${localProjectId}; matching repos: ${available}`
: `repo ${requestedRepoId} does not match project ${localProjectId}; no Manager repo matches this project`,
}
}
return { matches: selected }
}
export type ResolveResult =