fix(tools): address PR review feedback from cubic

- Use tool.schema.enum() for output_mode instead of generic string()
- Remove unsafe type assertion for output_mode
- Fix files_with_matches mode returning empty results by adding
  filesOnly flag to parseOutput for --files-with-matches rg output
This commit is contained in:
JiHongKim98
2026-02-21 03:17:48 +09:00
parent dafdca217b
commit 02017a1b70
2 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ export function createGrepTools(ctx: PluginInput): Record<string, ToolDefinition
.optional()
.describe("The directory to search in. Defaults to the current working directory."),
output_mode: tool.schema
.string()
.enum(["content", "files_with_matches", "count"])
.optional()
.describe(
"Output mode: \"content\" shows matching lines, \"files_with_matches\" shows only file paths (default), \"count\" shows match counts per file."
@@ -37,7 +37,7 @@ export function createGrepTools(ctx: PluginInput): Record<string, ToolDefinition
const globs = args.include ? [args.include] : undefined
const searchPath = args.path ?? ctx.directory
const paths = [searchPath]
const outputMode = (args.output_mode as "content" | "files_with_matches" | "count") ?? "files_with_matches"
const outputMode = args.output_mode ?? "files_with_matches"
const headLimit = args.head_limit ?? 0
if (outputMode === "count") {