diff --git a/src/tools/glob/tools.ts b/src/tools/glob/tools.ts index 361d43cd..d808377b 100644 --- a/src/tools/glob/tools.ts +++ b/src/tools/glob/tools.ts @@ -1,3 +1,4 @@ +import { resolve } from "node:path" import type { PluginInput } from "@opencode-ai/plugin" import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import { runRgFiles } from "./cli" @@ -22,10 +23,12 @@ export function createGlobTools(ctx: PluginInput): Record { + execute: async (args, context) => { try { const cli = await resolveGrepCliWithAutoInstall() - const searchPath = args.path ?? ctx.directory + const runtimeCtx = context as Record + const dir = typeof runtimeCtx.directory === "string" ? runtimeCtx.directory : ctx.directory + const searchPath = args.path ? resolve(dir, args.path) : dir const paths = [searchPath] const result = await runRgFiles( diff --git a/src/tools/grep/tools.ts b/src/tools/grep/tools.ts index e4d0e0e4..b00c4754 100644 --- a/src/tools/grep/tools.ts +++ b/src/tools/grep/tools.ts @@ -1,3 +1,4 @@ +import { resolve } from "node:path" import type { PluginInput } from "@opencode-ai/plugin" import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import { runRg, runRgCount } from "./cli" @@ -32,10 +33,12 @@ export function createGrepTools(ctx: PluginInput): Record { + execute: async (args, context) => { try { const globs = args.include ? [args.include] : undefined - const searchPath = args.path ?? ctx.directory + const runtimeCtx = context as Record + const dir = typeof runtimeCtx.directory === "string" ? runtimeCtx.directory : ctx.directory + const searchPath = args.path ? resolve(dir, args.path) : dir const paths = [searchPath] const outputMode = args.output_mode ?? "files_with_matches" const headLimit = args.head_limit ?? 0