diff --git a/.changeset/early-dodos-know.md b/.changeset/early-dodos-know.md
new file mode 100644
index 0000000..3bd8d11
--- /dev/null
+++ b/.changeset/early-dodos-know.md
@@ -0,0 +1,5 @@
+---
+"roo-cline": patch
+---
+
+Add a setting to control the number of terminal output lines to pass to the model when executing commands
diff --git a/README.md b/README.md
index bcf8ff2..5d1cd7b 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,7 @@ A fork of Cline, an autonomous coding agent, with some additional experimental f
- Per-tool MCP auto-approval
- Enable/disable MCP servers
- Configurable delay after auto-writes to allow diagnostics to detect potential problems
+- Control the number of terminal output lines to pass to the model when executing commands
- Runs alongside the original Cline
## Disclaimer
diff --git a/src/core/Cline.ts b/src/core/Cline.ts
index 218c0e8..91b57d9 100644
--- a/src/core/Cline.ts
+++ b/src/core/Cline.ts
@@ -721,9 +721,9 @@ export class Cline {
}
}
- let result = ""
+ let lines: string[] = []
process.on("line", (line) => {
- result += line + "\n"
+ lines.push(line)
if (!didContinue) {
sendCommandOutput(line)
} else {
@@ -731,6 +731,22 @@ export class Cline {
}
})
+ const getFormattedOutput = async () => {
+ const { terminalOutputLineLimit } = await this.providerRef.deref()?.getState() ?? {}
+ const limit = terminalOutputLineLimit ?? 0
+
+ if (limit > 0 && lines.length > limit) {
+ const beforeLimit = Math.floor(limit * 0.2) // 20% of lines before
+ const afterLimit = limit - beforeLimit // remaining 80% after
+ return [
+ ...lines.slice(0, beforeLimit),
+ `\n[...${lines.length - limit} lines omitted...]\n`,
+ ...lines.slice(-afterLimit)
+ ].join('\n')
+ }
+ return lines.join('\n')
+ }
+
let completed = false
process.once("completed", () => {
completed = true
@@ -749,7 +765,8 @@ export class Cline {
// grouping command_output messages despite any gaps anyways)
await delay(50)
- result = result.trim()
+ const output = await getFormattedOutput()
+ const result = output.trim()
if (userFeedback) {
await this.say("user_feedback", userFeedback.text, userFeedback.images)
diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts
index 2d584eb..6289a3b 100644
--- a/src/core/webview/ClineProvider.ts
+++ b/src/core/webview/ClineProvider.ts
@@ -76,6 +76,7 @@ type GlobalStateKey =
| "fuzzyMatchThreshold"
| "preferredLanguage" // Language setting for Cline's communication
| "writeDelayMs"
+ | "terminalOutputLineLimit"
export const GlobalFileNames = {
apiConversationHistory: "api_conversation_history.json",
@@ -642,6 +643,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
await this.updateGlobalState("writeDelayMs", message.value)
await this.postStateToWebview()
break
+ case "terminalOutputLineLimit":
+ await this.updateGlobalState("terminalOutputLineLimit", message.value)
+ await this.postStateToWebview()
+ break
case "deleteMessage": {
const answer = await vscode.window.showInformationMessage(
"Are you sure you want to delete this message and all subsequent messages?",
@@ -1046,6 +1051,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
screenshotQuality,
preferredLanguage,
writeDelayMs,
+ terminalOutputLineLimit,
} = await this.getState()
const allowedCommands = vscode.workspace
@@ -1075,6 +1081,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
screenshotQuality: screenshotQuality ?? 75,
preferredLanguage: preferredLanguage ?? 'English',
writeDelayMs: writeDelayMs ?? 1000,
+ terminalOutputLineLimit: terminalOutputLineLimit ?? 500,
}
}
@@ -1174,6 +1181,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
preferredLanguage,
writeDelayMs,
screenshotQuality,
+ terminalOutputLineLimit,
] = await Promise.all([
this.getGlobalState("apiProvider") as Promise
+ Maximum number of lines to include in terminal output when executing commands. When exceeded lines will be removed from the middle, saving tokens. +
+