mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(ocm): move sessions into OpenCode worktrees instead of replacing the Manager checkout
/ocm-move previously failed when the Manager checkout was dirty, behind, or on another branch. Choose the destination instead: replace in place only when the checkout is on the local branch, clean, and has nothing the local branch lacks; otherwise reuse an existing OpenCode worktree on that branch when it is equally safe; otherwise create a new OpenCode worktree through the same service the UI and multi-runs use, so it appears in the repo's worktree lists. The new worktree's branch is the local branch when free, else <branch>-ocm, -ocm-2 and so on. Server work is never discarded, the confirmation states the destination and why the main checkout was skipped, and a detached HEAD is refused. The mirror push endpoints (bundle upload and patch) accept a worktree directory, rejected unless it belongs to the repo, and a new endpoint creates the worktree. The old <repo>-<branch> path that registered a plain git worktree as a separate Manager repo is removed.
This commit is contained in:
1 parent
ae0dff6e84
commit
bd7c3e3fef
13 files changed
+895
-585
No files matched your search
+18
-19
@@ -147,27 +147,26 @@ export const MirrorTargetBranchRequestSchema = z.object({
|
||||
|
||||
export type MirrorTargetBranchRequest = z.infer<typeof MirrorTargetBranchRequestSchema>
|
||||
|
||||
const MirrorTargetPlanBaseSchema = z.object({
|
||||
fullPath: z.string().min(1),
|
||||
localPath: z.string().min(1),
|
||||
branch: z.string().min(1),
|
||||
currentBranch: z.string().min(1).nullable(),
|
||||
export const MirrorCheckoutStateSchema = z.object({
|
||||
directory: z.string().min(1),
|
||||
branch: z.string().min(1).nullable(),
|
||||
head: z.string().min(1).nullable(),
|
||||
dirty: z.boolean(),
|
||||
})
|
||||
|
||||
export const MirrorTargetPlanResponseSchema = z.discriminatedUnion('kind', [
|
||||
MirrorTargetPlanBaseSchema.extend({ kind: z.literal('new'), repoId: z.literal(null) }),
|
||||
MirrorTargetPlanBaseSchema.extend({ kind: z.literal('in-place'), repoId: z.number().int().positive() }),
|
||||
MirrorTargetPlanBaseSchema.extend({ kind: z.literal('existing'), repoId: z.number().int().positive() }),
|
||||
])
|
||||
export type MirrorCheckoutState = z.infer<typeof MirrorCheckoutStateSchema>
|
||||
|
||||
export type MirrorTargetPlanResponse = z.infer<typeof MirrorTargetPlanResponseSchema>
|
||||
|
||||
export const MirrorTargetEnsureResponseSchema = z.object({
|
||||
repoId: z.number().int().positive(),
|
||||
fullPath: z.string().min(1),
|
||||
localPath: z.string().min(1),
|
||||
branch: z.string().min(1),
|
||||
created: z.boolean(),
|
||||
export const MirrorMoveTargetResponseSchema = z.object({
|
||||
main: MirrorCheckoutStateSchema,
|
||||
branchWorktree: MirrorCheckoutStateSchema.nullable(),
|
||||
newWorktreeBranch: z.string().min(1),
|
||||
})
|
||||
|
||||
export type MirrorTargetEnsureResponse = z.infer<typeof MirrorTargetEnsureResponseSchema>
|
||||
export type MirrorMoveTargetResponse = z.infer<typeof MirrorMoveTargetResponseSchema>
|
||||
|
||||
export const MirrorWorktreeCreateResponseSchema = z.object({
|
||||
directory: z.string().min(1),
|
||||
branch: z.string().min(1),
|
||||
})
|
||||
|
||||
export type MirrorWorktreeCreateResponse = z.infer<typeof MirrorWorktreeCreateResponseSchema>
|
||||
Reference in new issue
Block a user