diff --git a/packages/core/src/worktree.ts b/packages/core/src/worktree.ts index 62f3a7bc627..043e6c15bf7 100644 --- a/packages/core/src/worktree.ts +++ b/packages/core/src/worktree.ts @@ -254,8 +254,6 @@ const layer = Layer.effect( }) .pipe(Effect.mapError((error) => operationError(selected.id, "create", error))) const result = { directory: yield* canonical(fs, created.directory) } - if (result.directory !== (yield* canonical(fs, worktreeDirectory))) - return yield* new InvalidDirectoryError({ directory: result.directory }) yield* changed( yield* ops.create({ directory: result.directory, diff --git a/packages/plugin/src/worktree.ts b/packages/plugin/src/worktree.ts index eaf09413c49..b99a63a7cf9 100644 --- a/packages/plugin/src/worktree.ts +++ b/packages/plugin/src/worktree.ts @@ -1,5 +1,6 @@ export interface WorktreeCreateInput { readonly sourceDirectory: string + /** Suggested destination after naming and collision handling. Strategies may return a different directory. */ readonly directory: string /** Starting ref, not the name of a new branch. Reject unsupported refs rather than ignoring them. */ readonly branch?: string @@ -11,6 +12,7 @@ export interface WorktreeRemoveInput { } export interface WorktreeResult { + /** Actual directory created by the strategy, used for inventory and startup commands. */ readonly directory: string } diff --git a/services/www/src/docs/content/build/plugins/index.mdx b/services/www/src/docs/content/build/plugins/index.mdx index f7b0b7a4d93..773b172b4f1 100644 --- a/services/www/src/docs/content/build/plugins/index.mdx +++ b/services/www/src/docs/content/build/plugins/index.mdx @@ -1025,8 +1025,12 @@ force confirmation without depending on Core or Git errors. #### Reference -Implementations receive the final destination after naming and collision handling. Return that directory from `create`; -`list` must report only directories the strategy owns, plus any repository roots. Core owns inventory and startup commands. +Implementations receive a suggested destination after naming and collision handling. Return the actual directory from +`create`; it may differ when a backend requires its own layout. OpenCode resolves the returned path and uses it for +inventory, startup commands, and the API result. The returned directory must exist. + +Strategies choosing another destination handle naming collisions there. OpenCode still creates the suggested parent +directory before calling the strategy. `list` must report only directories the strategy owns, plus any repository roots. ```ts interface WorktreeDefinition {