mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
limit grep line length to 2000
This commit is contained in:
parent
f1bb5870ce
commit
95c3a8b805
1 changed files with 5 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue