diff --git a/src/tools/glob/tools.ts b/src/tools/glob/tools.ts index 919193fcf..f70687c1a 100644 --- a/src/tools/glob/tools.ts +++ b/src/tools/glob/tools.ts @@ -1,6 +1,6 @@ import { resolve } from "node:path" import type { PluginInput } from "@opencode-ai/plugin" -import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition, type ToolContext } from "@opencode-ai/plugin/tool" import { runRgFiles } from "./cli" import { resolveGrepCliWithAutoInstall } from "./constants" import { formatGlobResult } from "./result-formatter" @@ -23,15 +23,28 @@ export function createGlobTools(ctx: PluginInput): Record { +||||||| parent of a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) + execute: async (args) => { +======= + execute: async (args, context: ToolContext) => { +>>>>>>> a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) try { const cli = await resolveGrepCliWithAutoInstall() +<<<<<<< HEAD <<<<<<< HEAD const runtimeCtx = context as Record const dir = typeof runtimeCtx.directory === "string" ? runtimeCtx.directory : ctx.directory const searchPath = args.path ? resolve(dir, args.path) : dir ||||||| parent of 804d517f (fix(tools): resolve relative paths in glob/grep against project directory) const searchPath = args.path ?? ctx.directory +||||||| parent of a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) + const searchPath = args.path ?? ctx.directory +======= + const dir = context?.directory ?? ctx.directory + const searchPath = args.path ? resolve(dir, args.path) : dir +>>>>>>> a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) const paths = [searchPath] ======= const searchPath = args.path ? resolve(ctx.directory, args.path) : ctx.directory diff --git a/src/tools/grep/tools.ts b/src/tools/grep/tools.ts index 7b4502bef..d885dfb33 100644 --- a/src/tools/grep/tools.ts +++ b/src/tools/grep/tools.ts @@ -1,6 +1,6 @@ import { resolve } from "node:path" import type { PluginInput } from "@opencode-ai/plugin" -import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition, type ToolContext } from "@opencode-ai/plugin/tool" import { runRg, runRgCount } from "./cli" import { resolveGrepCliWithAutoInstall } from "./constants" import { formatGrepResult, formatCountResult } from "./result-formatter" @@ -34,9 +34,16 @@ export function createGrepTools(ctx: PluginInput): Record { +||||||| parent of a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) + execute: async (args) => { +======= + execute: async (args, context: ToolContext) => { +>>>>>>> a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) try { const globs = args.include ? [args.include] : undefined +<<<<<<< HEAD <<<<<<< HEAD const runtimeCtx = context as Record const dir = typeof runtimeCtx.directory === "string" ? runtimeCtx.directory : ctx.directory @@ -46,6 +53,12 @@ export function createGrepTools(ctx: PluginInput): Record>>>>>> 804d517f (fix(tools): resolve relative paths in glob/grep against project directory) +||||||| parent of a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) + const searchPath = args.path ?? ctx.directory +======= + const dir = context?.directory ?? ctx.directory + const searchPath = args.path ? resolve(dir, args.path) : dir +>>>>>>> a9d2407d (fix(tools): resolve relative paths in glob/grep against project directory) const paths = [searchPath] const outputMode = args.output_mode ?? "files_with_matches" const headLimit = args.head_limit ?? 0