Merge pull request #2202 from ualtinok/fix/glob-grep-relative-path
fix(tools): resolve relative paths in glob/grep against project directory
This commit is contained in:
commit
29d606241b
@ -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<string, ToolDefinition
|
||||
"simply omit it for the default behavior. Must be a valid directory path if provided."
|
||||
),
|
||||
},
|
||||
execute: async (args) => {
|
||||
execute: async (args, context) => {
|
||||
try {
|
||||
const cli = await resolveGrepCliWithAutoInstall()
|
||||
const searchPath = args.path ?? ctx.directory
|
||||
const runtimeCtx = context as Record<string, unknown>
|
||||
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(
|
||||
|
||||
@ -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<string, ToolDefinition
|
||||
.optional()
|
||||
.describe("Limit output to first N entries. 0 or omitted means no limit."),
|
||||
},
|
||||
execute: async (args) => {
|
||||
execute: async (args, context) => {
|
||||
try {
|
||||
const globs = args.include ? [args.include] : undefined
|
||||
const searchPath = args.path ?? ctx.directory
|
||||
const runtimeCtx = context as Record<string, unknown>
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user