feat(core): add worktree to plugin tool context
This commit is contained in:
@@ -67,7 +67,11 @@ export namespace ToolRegistry {
|
|||||||
parameters: z.object(def.args),
|
parameters: z.object(def.args),
|
||||||
description: def.description,
|
description: def.description,
|
||||||
execute: async (args, ctx) => {
|
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 PluginToolContext
|
||||||
const result = await def.execute(args as any, pluginCtx)
|
const result = await def.execute(args as any, pluginCtx)
|
||||||
const out = await Truncate.output(result, {}, initCtx?.agent)
|
const out = await Truncate.output(result, {}, initCtx?.agent)
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ export type ToolContext = {
|
|||||||
* Prefer this over process.cwd() when resolving relative paths.
|
* Prefer this over process.cwd() when resolving relative paths.
|
||||||
*/
|
*/
|
||||||
directory: string
|
directory: string
|
||||||
|
/**
|
||||||
|
* Project worktree root for this session.
|
||||||
|
* Useful for generating stable relative paths (e.g. path.relative(worktree, absPath)).
|
||||||
|
*/
|
||||||
|
worktree: string
|
||||||
abort: AbortSignal
|
abort: AbortSignal
|
||||||
metadata(input: { title?: string; metadata?: { [key: string]: any } }): void
|
metadata(input: { title?: string; metadata?: { [key: string]: any } }): void
|
||||||
ask(input: AskInput): Promise<void>
|
ask(input: AskInput): Promise<void>
|
||||||
|
|||||||
Reference in New Issue
Block a user