summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-12-01 13:52:42 -0500
committerDax Raad <[email protected]>2025-12-01 16:35:07 -0500
commit95c3a8b80505fcb3140989daf6fece3377aa3b95 (patch)
treea61e5f5799114f8d4c843662b7c8f3e891b06663
parentf1bb5870ce7a3f0aacab9091cbc30fc7046dd471 (diff)
downloadopencode-95c3a8b80505fcb3140989daf6fece3377aa3b95.tar.gz
opencode-95c3a8b80505fcb3140989daf6fece3377aa3b95.zip
limit grep line length to 2000
-rw-r--r--packages/opencode/src/tool/grep.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts
index 5390be21a..99af448ba 100644
--- a/packages/opencode/src/tool/grep.ts
+++ b/packages/opencode/src/tool/grep.ts
@@ -5,6 +5,8 @@ import { Ripgrep } from "../file/ripgrep"
import DESCRIPTION from "./grep.txt"
import { Instance } from "../project/instance"
+const MAX_LINE_LENGTH = 2000
+
export const GrepTool = Tool.define("grep", {
description: DESCRIPTION,
parameters: z.object({
@@ -96,7 +98,9 @@ export const GrepTool = Tool.define("grep", {
currentFile = match.path
outputLines.push(`${match.path}:`)
}
- outputLines.push(` Line ${match.lineNum}: ${match.lineText}`)
+ const truncatedLineText =
+ match.lineText.length > MAX_LINE_LENGTH ? match.lineText.substring(0, MAX_LINE_LENGTH) + "..." : match.lineText
+ outputLines.push(` Line ${match.lineNum}: ${truncatedLineText}`)
}
if (truncated) {