The open source coding agent.
TypeScript
feat(core): add worktree to plugin tool context
adamelmore1f9313847f61
diff --git a/packages/opencode/src/tool/registry.ts b/packages/opencode/src/tool/registry.tsindex 2c862dfd886..7b3a4588972 100644--- a/packages/opencode/src/tool/registry.ts+++ b/packages/opencode/src/tool/registry.ts@@ -67,7 +67,11 @@ export namespace ToolRegistry {parameters: z.object(def.args),description: def.description,execute: async (args, ctx) => {- const pluginCtx = { ...ctx, directory: Instance.directory } as unknown as PluginToolContext+ const pluginCtx = {+ ...ctx,+ directory: Instance.directory,+ worktree: Instance.worktree,+ } as unknown as PluginToolContextconst result = await def.execute(args as any, pluginCtx)const out = await Truncate.output(result, {}, initCtx?.agent)return {diff --git a/packages/plugin/src/tool.ts b/packages/plugin/src/tool.tsindex 6b4f7f1d1ef..23aa512d9a4 100644--- a/packages/plugin/src/tool.ts+++ b/packages/plugin/src/tool.ts@@ -9,6 +9,11 @@ export type ToolContext = {* Prefer this over process.cwd() when resolving relative paths.*/directory: string+ /**+ * Project worktree root for this session.+ * Useful for generating stable relative paths (e.g. path.relative(worktree, absPath)).+ */+ worktree: stringabort: AbortSignalmetadata(input: { title?: string; metadata?: { [key: string]: any } }): voidask(input: AskInput): Promise<void>