From 9a93344aa1c925e09a357d42834c2ec31af3fd1e Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Wed, 11 Feb 2026 23:52:27 -0600 Subject: [PATCH 1/4] tweak: glob & grep output wording to be more clear about limits --- packages/opencode/src/tool/glob.ts | 2 +- packages/opencode/src/tool/grep.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/tool/glob.ts b/packages/opencode/src/tool/glob.ts index 6943795f8837..59694af364e1 100644 --- a/packages/opencode/src/tool/glob.ts +++ b/packages/opencode/src/tool/glob.ts @@ -62,7 +62,7 @@ export const GlobTool = Tool.define("glob", { output.push(...files.map((f) => f.path)) if (truncated) { output.push("") - output.push("(Results are truncated. Consider using a more specific path or pattern.)") + output.push(`(Results are truncated to top ${limit} results. Consider using a more specific path or pattern.)`) } } diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts index c10b4dfb88a6..a77e8a8e2669 100644 --- a/packages/opencode/src/tool/grep.ts +++ b/packages/opencode/src/tool/grep.ts @@ -109,7 +109,8 @@ export const GrepTool = Tool.define("grep", { } } - const outputLines = [`Found ${finalMatches.length} matches`] + const totalMatches = matches.length + const outputLines = [`Found ${totalMatches} matches${truncated ? ` (showing first ${limit})` : ""}`] let currentFile = "" for (const match of finalMatches) { @@ -127,7 +128,9 @@ export const GrepTool = Tool.define("grep", { if (truncated) { outputLines.push("") - outputLines.push("(Results are truncated. Consider using a more specific path or pattern.)") + outputLines.push( + `(Results truncated: showing ${limit} of ${totalMatches} matches (${totalMatches - limit} hidden). Consider using a more specific path or pattern.)`, + ) } if (hasErrors) { From 74182d02532cc6bf6fe7094f80e15c88344a42ea Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Wed, 11 Feb 2026 23:54:46 -0600 Subject: [PATCH 2/4] tweak: glob output --- packages/opencode/src/tool/glob.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/glob.ts b/packages/opencode/src/tool/glob.ts index 59694af364e1..9df1eedca449 100644 --- a/packages/opencode/src/tool/glob.ts +++ b/packages/opencode/src/tool/glob.ts @@ -62,7 +62,9 @@ export const GlobTool = Tool.define("glob", { output.push(...files.map((f) => f.path)) if (truncated) { output.push("") - output.push(`(Results are truncated to top ${limit} results. Consider using a more specific path or pattern.)`) + output.push( + `(Results are truncated: showing first ${limit} results. Consider using a more specific path or pattern.)`, + ) } } From d050dbb4705bdffd3ef7036485fbc497f9840e13 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Thu, 12 Feb 2026 00:05:28 -0600 Subject: [PATCH 3/4] tweak edit tool msgs --- packages/opencode/src/tool/edit.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/opencode/src/tool/edit.ts b/packages/opencode/src/tool/edit.ts index 0bf1d6792bc2..d84f6ec3499f 100644 --- a/packages/opencode/src/tool/edit.ts +++ b/packages/opencode/src/tool/edit.ts @@ -38,7 +38,7 @@ export const EditTool = Tool.define("edit", { } if (params.oldString === params.newString) { - throw new Error("oldString and newString must be different") + throw new Error("No changes to apply: oldString and newString are identical.") } const filePath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath) @@ -617,7 +617,7 @@ export function trimDiff(diff: string): string { export function replace(content: string, oldString: string, newString: string, replaceAll = false): string { if (oldString === newString) { - throw new Error("oldString and newString must be different") + throw new Error("No changes to apply: oldString and newString are identical.") } let notFound = true @@ -647,9 +647,9 @@ export function replace(content: string, oldString: string, newString: string, r } if (notFound) { - throw new Error("oldString not found in content") + throw new Error( + "Could not find oldString in the file. It must match exactly, including whitespace, indentation, and line endings.", + ) } - throw new Error( - "Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match.", - ) + throw new Error("Found multiple matches for oldString. Provide more surrounding context to make the match unique.") } From 52f961bb0eb0ab0ec8b5f4ce02aaa22bfdcb499d Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Thu, 12 Feb 2026 00:26:05 -0600 Subject: [PATCH 4/4] tweak: metadata --- packages/opencode/src/tool/grep.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts index a77e8a8e2669..41ed494de923 100644 --- a/packages/opencode/src/tool/grep.ts +++ b/packages/opencode/src/tool/grep.ts @@ -141,7 +141,7 @@ export const GrepTool = Tool.define("grep", { return { title: params.pattern, metadata: { - matches: finalMatches.length, + matches: totalMatches, truncated, }, output: outputLines.join("\n"),