diff options
| author | Kalle Ahlström <[email protected]> | 2025-06-28 17:41:25 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-28 14:41:25 +0000 |
| commit | 9665928860eda07a9645c0c7a985f78ae888f6ee (patch) | |
| tree | c41dff05bf5fe990b92a9cc29ce93ffcdb21dca4 /packages/core/src/tools/grep.ts | |
| parent | 25cdf9b762a13aa7bbfab363dc1c85bdf2c3fae1 (diff) | |
chore: add proper pluralization handling for match in grep tool (#2344)
Co-authored-by: Allen Hutchison <[email protected]>
Diffstat (limited to 'packages/core/src/tools/grep.ts')
| -rw-r--r-- | packages/core/src/tools/grep.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/core/src/tools/grep.ts b/packages/core/src/tools/grep.ts index f7de190b..612291d5 100644 --- a/packages/core/src/tools/grep.ts +++ b/packages/core/src/tools/grep.ts @@ -213,7 +213,10 @@ export class GrepTool extends BaseTool<GrepToolParams, ToolResult> { {} as Record<string, GrepMatch[]>, ); - let llmContent = `Found ${matches.length} match(es) for pattern "${params.pattern}" in path "${searchDirDisplay}"${params.include ? ` (filter: "${params.include}")` : ''}:\n---\n`; + const matchCount = matches.length; + const matchTerm = matchCount === 1 ? 'match' : 'matches'; + + let llmContent = `Found ${matchCount} ${matchTerm} for pattern "${params.pattern}" in path "${searchDirDisplay}"${params.include ? ` (filter: "${params.include}")` : ''}:\n---\n`; for (const filePath in matchesByFile) { llmContent += `File: ${filePath}\n`; @@ -226,7 +229,7 @@ export class GrepTool extends BaseTool<GrepToolParams, ToolResult> { return { llmContent: llmContent.trim(), - returnDisplay: `Found ${matches.length} matche(s)`, + returnDisplay: `Found ${matchCount} ${matchTerm}`, }; } catch (error) { console.error(`Error during GrepLogic execution: ${error}`); |
