diff --git a/packages/types/src/cloud.ts b/packages/types/src/cloud.ts index fe62990899d..f14f14370b9 100644 --- a/packages/types/src/cloud.ts +++ b/packages/types/src/cloud.ts @@ -99,8 +99,6 @@ export const organizationDefaultSettingsSchema = globalSettingsSchema maxWorkspaceFiles: true, showRooIgnoredFiles: true, terminalCommandDelay: true, - terminalCompressProgressBar: true, - terminalOutputLineLimit: true, terminalShellIntegrationDisabled: true, terminalShellIntegrationTimeout: true, terminalZshClearEolMark: true, @@ -112,7 +110,6 @@ export const organizationDefaultSettingsSchema = globalSettingsSchema maxReadFileLine: z.number().int().gte(-1).optional(), maxWorkspaceFiles: z.number().int().nonnegative().optional(), terminalCommandDelay: z.number().int().nonnegative().optional(), - terminalOutputLineLimit: z.number().int().nonnegative().optional(), terminalShellIntegrationTimeout: z.number().int().nonnegative().optional(), }), ) diff --git a/packages/types/src/global-settings.ts b/packages/types/src/global-settings.ts index 0f75e1d6107..d57ec616ff4 100644 --- a/packages/types/src/global-settings.ts +++ b/packages/types/src/global-settings.ts @@ -23,11 +23,40 @@ import { languagesSchema } from "./vscode.js" export const DEFAULT_WRITE_DELAY_MS = 1000 /** - * Default terminal output character limit constant. - * This provides a reasonable default that aligns with typical terminal usage - * while preventing context window explosions from extremely long lines. + * Terminal output preview size options for persisted command output. + * + * Controls how much command output is kept in memory as a "preview" before + * the LLM decides to retrieve more via `read_command_output`. Larger previews + * mean more immediate context but consume more of the context window. + * + * - `small`: 5KB preview - Best for long-running commands with verbose output + * - `medium`: 10KB preview - Balanced default for most use cases + * - `large`: 20KB preview - Best when commands produce critical info early + * + * @see OutputInterceptor - Uses this setting to determine when to spill to disk + * @see PersistedCommandOutput - Contains the resulting preview and artifact reference */ -export const DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT = 50_000 +export type TerminalOutputPreviewSize = "small" | "medium" | "large" + +/** + * Byte limits for each terminal output preview size. + * + * Maps preview size names to their corresponding byte thresholds. + * When command output exceeds these thresholds, the excess is persisted + * to disk and made available via the `read_command_output` tool. + */ +export const TERMINAL_PREVIEW_BYTES: Record = { + small: 5 * 1024, // 5KB + medium: 10 * 1024, // 10KB + large: 20 * 1024, // 20KB +} + +/** + * Default terminal output preview size. + * The "medium" (10KB) setting provides a good balance between immediate + * visibility and context window conservation for most use cases. + */ +export const DEFAULT_TERMINAL_OUTPUT_PREVIEW_SIZE: TerminalOutputPreviewSize = "medium" /** * Minimum checkpoint timeout in seconds. @@ -147,8 +176,7 @@ export const globalSettingsSchema = z.object({ maxImageFileSize: z.number().optional(), maxTotalImageSize: z.number().optional(), - terminalOutputLineLimit: z.number().optional(), - terminalOutputCharacterLimit: z.number().optional(), + terminalOutputPreviewSize: z.enum(["small", "medium", "large"]).optional(), terminalShellIntegrationTimeout: z.number().optional(), terminalShellIntegrationDisabled: z.boolean().optional(), terminalCommandDelay: z.number().optional(), @@ -157,7 +185,6 @@ export const globalSettingsSchema = z.object({ terminalZshOhMy: z.boolean().optional(), terminalZshP10k: z.boolean().optional(), terminalZdotdir: z.boolean().optional(), - terminalCompressProgressBar: z.boolean().optional(), diagnosticsEnabled: z.boolean().optional(), @@ -338,8 +365,6 @@ export const EVALS_SETTINGS: RooCodeSettings = { soundEnabled: false, soundVolume: 0.5, - terminalOutputLineLimit: 500, - terminalOutputCharacterLimit: DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, terminalShellIntegrationTimeout: 30000, terminalCommandDelay: 0, terminalPowershellCounter: false, @@ -347,7 +372,6 @@ export const EVALS_SETTINGS: RooCodeSettings = { terminalZshClearEolMark: true, terminalZshP10k: false, terminalZdotdir: true, - terminalCompressProgressBar: true, terminalShellIntegrationDisabled: true, diagnosticsEnabled: true, diff --git a/packages/types/src/message.ts b/packages/types/src/message.ts index d6dd46099ad..a725cb094d0 100644 --- a/packages/types/src/message.ts +++ b/packages/types/src/message.ts @@ -182,6 +182,7 @@ export const clineSays = [ "codebase_search_result", "user_edit_todos", "too_many_tools_warning", + "tool", ] as const export const clineSaySchema = z.enum(clineSays) diff --git a/packages/types/src/terminal.ts b/packages/types/src/terminal.ts index ffa1ffe7811..34f7a74e244 100644 --- a/packages/types/src/terminal.ts +++ b/packages/types/src/terminal.ts @@ -32,3 +32,69 @@ export const commandExecutionStatusSchema = z.discriminatedUnion("status", [ ]) export type CommandExecutionStatus = z.infer + +/** + * PersistedCommandOutput + * + * Represents the result of a terminal command execution that may have been + * truncated and persisted to disk. + * + * When command output exceeds the configured preview threshold, the full + * output is saved to a disk artifact file. The LLM receives this structure + * which contains: + * - A preview of the output (for immediate display in context) + * - Metadata about the full output (size, truncation status) + * - A path to the artifact file for later retrieval via `read_command_output` + * + * ## Usage in execute_command Response + * + * The response format depends on whether truncation occurred: + * + * **Not truncated** (output fits in preview): + * ```json + * { + * "preview": "full output here...", + * "totalBytes": 1234, + * "artifactPath": null, + * "truncated": false + * } + * ``` + * + * **Truncated** (output exceeded threshold): + * ```json + * { + * "preview": "first 4KB of output...", + * "totalBytes": 1048576, + * "artifactPath": "/path/to/tasks/123/command-output/cmd-1706119234567.txt", + * "truncated": true + * } + * ``` + * + * @see OutputInterceptor - Creates these results during command execution + * @see ReadCommandOutputTool - Retrieves full content from artifact files + */ +export interface PersistedCommandOutput { + /** + * Preview of the command output, truncated to the preview threshold. + * Always contains the beginning of the output, even if truncated. + */ + preview: string + + /** + * Total size of the command output in bytes. + * Useful for determining if additional reads are needed. + */ + totalBytes: number + + /** + * Absolute path to the artifact file containing full output. + * `null` if output wasn't truncated (no artifact was created). + */ + artifactPath: string | null + + /** + * Whether the output was truncated (exceeded preview threshold). + * When `true`, use `read_command_output` to retrieve full content. + */ + truncated: boolean +} diff --git a/packages/types/src/tool.ts b/packages/types/src/tool.ts index 147eb24b6cc..f90ef42ede4 100644 --- a/packages/types/src/tool.ts +++ b/packages/types/src/tool.ts @@ -17,6 +17,7 @@ export type ToolGroup = z.infer export const toolNames = [ "execute_command", "read_file", + "read_command_output", "write_to_file", "apply_diff", "search_and_replace", diff --git a/packages/types/src/vscode-extension-host.ts b/packages/types/src/vscode-extension-host.ts index 49f9687f009..7ae89e8777d 100644 --- a/packages/types/src/vscode-extension-host.ts +++ b/packages/types/src/vscode-extension-host.ts @@ -302,8 +302,7 @@ export type ExtensionState = Pick< | "soundEnabled" | "soundVolume" | "maxConcurrentFileReads" - | "terminalOutputLineLimit" - | "terminalOutputCharacterLimit" + | "terminalOutputPreviewSize" | "terminalShellIntegrationTimeout" | "terminalShellIntegrationDisabled" | "terminalCommandDelay" @@ -312,7 +311,6 @@ export type ExtensionState = Pick< | "terminalZshOhMy" | "terminalZshP10k" | "terminalZdotdir" - | "terminalCompressProgressBar" | "diagnosticsEnabled" | "language" | "modeApiConfigs" @@ -780,6 +778,7 @@ export interface ClineSayTool { | "newFileCreated" | "codebaseSearch" | "readFile" + | "readCommandOutput" | "fetchInstructions" | "listFilesTopLevel" | "listFilesRecursive" @@ -792,6 +791,12 @@ export interface ClineSayTool { | "runSlashCommand" | "updateTodoList" path?: string + // For readCommandOutput + readStart?: number + readEnd?: number + totalBytes?: number + searchPattern?: string + matchCount?: number diff?: string content?: string // Unified diff statistics computed by the extension diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 944c4918897..60bff02c0b6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1013,6 +1013,9 @@ importers: '@types/glob': specifier: ^8.1.0 version: 8.1.0 + '@types/json-stream-stringify': + specifier: ^2.0.4 + version: 2.0.4 '@types/lodash.debounce': specifier: ^4.0.9 version: 4.0.9 @@ -4265,6 +4268,10 @@ packages: '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + '@types/json-stream-stringify@2.0.4': + resolution: {integrity: sha512-xSFsVnoQ8Y/7BiVF3/fEIwRx9RoGzssDKVwhy1g23wkA4GAmA3v8lsl6CxsmUD6vf4EiRd+J0ULLkMbAWRSsgQ==} + deprecated: This is a stub types definition. json-stream-stringify provides its own type definitions, so you do not need this installed. + '@types/katex@0.16.7': resolution: {integrity: sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==} @@ -14241,6 +14248,10 @@ snapshots: '@types/json-schema@7.0.15': {} + '@types/json-stream-stringify@2.0.4': + dependencies: + json-stream-stringify: 3.1.6 + '@types/katex@0.16.7': {} '@types/lodash.debounce@4.0.9': diff --git a/src/core/assistant-message/NativeToolCallParser.ts b/src/core/assistant-message/NativeToolCallParser.ts index c13f28f517f..8aa369f74da 100644 --- a/src/core/assistant-message/NativeToolCallParser.ts +++ b/src/core/assistant-message/NativeToolCallParser.ts @@ -790,6 +790,17 @@ export class NativeToolCallParser { } break + case "read_command_output": + if (args.artifact_id !== undefined) { + nativeArgs = { + artifact_id: args.artifact_id, + search: args.search, + offset: args.offset, + limit: args.limit, + } as NativeArgsFor + } + break + case "write_to_file": if (args.path !== undefined && args.content !== undefined) { nativeArgs = { diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index b0b330d9907..db17bb97046 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -17,6 +17,7 @@ import { Task } from "../task/Task" import { fetchInstructionsTool } from "../tools/FetchInstructionsTool" import { listFilesTool } from "../tools/ListFilesTool" import { readFileTool } from "../tools/ReadFileTool" +import { readCommandOutputTool } from "../tools/ReadCommandOutputTool" import { writeToFileTool } from "../tools/WriteToFileTool" import { searchAndReplaceTool } from "../tools/SearchAndReplaceTool" import { searchReplaceTool } from "../tools/SearchReplaceTool" @@ -402,8 +403,10 @@ export async function presentAssistantMessage(cline: Task) { return `[${block.name}]` case "switch_mode": return `[${block.name} to '${block.params.mode_slug}'${block.params.reason ? ` because: ${block.params.reason}` : ""}]` - case "codebase_search": // Add case for the new tool + case "codebase_search": return `[${block.name} for '${block.params.query}']` + case "read_command_output": + return `[${block.name} for '${block.params.artifact_id}']` case "update_todo_list": return `[${block.name}]` case "new_task": { @@ -846,6 +849,13 @@ export async function presentAssistantMessage(cline: Task) { pushToolResult, }) break + case "read_command_output": + await readCommandOutputTool.handle(cline, block as ToolUse<"read_command_output">, { + askApproval, + handleError, + pushToolResult, + }) + break case "use_mcp_tool": await useMcpToolTool.handle(cline, block as ToolUse<"use_mcp_tool">, { askApproval, @@ -1088,6 +1098,7 @@ function containsXmlToolMarkup(text: string): boolean { "generate_image", "list_files", "new_task", + "read_command_output", "read_file", "search_and_replace", "search_files", diff --git a/src/core/environment/getEnvironmentDetails.ts b/src/core/environment/getEnvironmentDetails.ts index 39deb3f495a..db5a0cd088c 100644 --- a/src/core/environment/getEnvironmentDetails.ts +++ b/src/core/environment/getEnvironmentDetails.ts @@ -6,7 +6,6 @@ import pWaitFor from "p-wait-for" import delay from "delay" import type { ExperimentId } from "@roo-code/types" -import { DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT } from "@roo-code/types" import { formatLanguage } from "../../shared/language" import { defaultModeSlug, getFullModeDetails } from "../../shared/modes" @@ -26,11 +25,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo const clineProvider = cline.providerRef.deref() const state = await clineProvider?.getState() - const { - terminalOutputLineLimit = 500, - terminalOutputCharacterLimit = DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, - maxWorkspaceFiles = 200, - } = state ?? {} + const { maxWorkspaceFiles = 200 } = state ?? {} // It could be useful for cline to know if the user went from one or no // file to another between messages, so we always include this context. @@ -112,11 +107,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo let newOutput = TerminalRegistry.getUnretrievedOutput(busyTerminal.id) if (newOutput) { - newOutput = Terminal.compressTerminalOutput( - newOutput, - terminalOutputLineLimit, - terminalOutputCharacterLimit, - ) + newOutput = Terminal.compressTerminalOutput(newOutput) terminalDetails += `\n### New Output\n${newOutput}` } } @@ -144,11 +135,7 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo let output = process.getUnretrievedOutput() if (output) { - output = Terminal.compressTerminalOutput( - output, - terminalOutputLineLimit, - terminalOutputCharacterLimit, - ) + output = Terminal.compressTerminalOutput(output) terminalOutputs.push(`Command: \`${process.command}\`\n${output}`) } } diff --git a/src/core/message-manager/index.ts b/src/core/message-manager/index.ts index e35f290c398..4b68be0825c 100644 --- a/src/core/message-manager/index.ts +++ b/src/core/message-manager/index.ts @@ -1,7 +1,10 @@ +import * as path from "path" import { Task } from "../task/Task" import { ClineMessage } from "@roo-code/types" import { ApiMessage } from "../task-persistence/apiMessages" import { cleanupAfterTruncation } from "../condense" +import { OutputInterceptor } from "../../integrations/terminal/OutputInterceptor" +import { getTaskDirectoryPath } from "../../utils/storage" export interface RewindOptions { /** Whether to include the target message in deletion (edit=true, delete=false) */ @@ -207,6 +210,32 @@ export class MessageManager { apiHistory = cleanupAfterTruncation(apiHistory) } + // Step 6: Cleanup orphaned command output artifacts + // Collect timestamps from remaining messages to identify valid artifact IDs + // Artifacts whose IDs don't match any remaining message timestamp will be removed + if (!skipCleanup) { + const validIds = new Set() + + // Collect timestamps from remaining clineMessages + for (const msg of this.task.clineMessages) { + if (msg.ts) { + validIds.add(String(msg.ts)) + } + } + + // Collect timestamps from remaining apiHistory + for (const msg of apiHistory) { + if (msg.ts) { + validIds.add(String(msg.ts)) + } + } + + // Cleanup artifacts asynchronously (fire-and-forget with error handling) + this.cleanupOrphanedArtifacts(validIds).catch((error) => { + console.error("[MessageManager] Error cleaning up orphaned command output artifacts:", error) + }) + } + // Only write if the history actually changed const historyChanged = apiHistory.length !== originalHistory.length || apiHistory.some((msg, i) => msg !== originalHistory[i]) @@ -215,4 +244,28 @@ export class MessageManager { await this.task.overwriteApiConversationHistory(apiHistory) } } + + /** + * Cleanup orphaned command output artifacts. + * Removes artifact files whose execution IDs don't match any remaining message timestamps. + */ + private async cleanupOrphanedArtifacts(validIds: Set): Promise { + try { + // Access globalStoragePath and taskId through the task reference + const task = this.task as any // Access private member + const globalStoragePath = task.globalStoragePath + const taskId = task.taskId + + if (!globalStoragePath || !taskId) { + return + } + + const taskDir = await getTaskDirectoryPath(globalStoragePath, taskId) + const outputDir = path.join(taskDir, "command-output") + await OutputInterceptor.cleanupByIds(outputDir, validIds) + } catch (error) { + // Silently fail - cleanup is best-effort + console.debug("[MessageManager] Artifact cleanup skipped:", error) + } + } } diff --git a/src/core/prompts/tools/native-tools/index.ts b/src/core/prompts/tools/native-tools/index.ts index 4f78729cdc8..b6af18fa154 100644 --- a/src/core/prompts/tools/native-tools/index.ts +++ b/src/core/prompts/tools/native-tools/index.ts @@ -11,6 +11,7 @@ import fetchInstructions from "./fetch_instructions" import generateImage from "./generate_image" import listFiles from "./list_files" import newTask from "./new_task" +import readCommandOutput from "./read_command_output" import { createReadFileTool, type ReadFileToolOptions } from "./read_file" import runSlashCommand from "./run_slash_command" import searchAndReplace from "./search_and_replace" @@ -65,6 +66,7 @@ export function getNativeTools(options: NativeToolsOptions = {}): OpenAI.Chat.Ch generateImage, listFiles, newTask, + readCommandOutput, createReadFileTool(readFileOptions), runSlashCommand, searchAndReplace, diff --git a/src/core/prompts/tools/native-tools/read_command_output.ts b/src/core/prompts/tools/native-tools/read_command_output.ts new file mode 100644 index 00000000000..007915b005f --- /dev/null +++ b/src/core/prompts/tools/native-tools/read_command_output.ts @@ -0,0 +1,81 @@ +import type OpenAI from "openai" + +/** + * Native tool definition for read_command_output. + * + * This tool allows the LLM to retrieve full command output that was truncated + * during execute_command. When command output exceeds the preview threshold, + * the full output is persisted to disk and an artifact_id is provided. The + * LLM can then use this tool to read the full content or search within it. + */ + +const READ_COMMAND_OUTPUT_DESCRIPTION = `Retrieve the full output from a command that was truncated in execute_command. Use this tool when: +1. The execute_command result shows "[OUTPUT TRUNCATED - Full output saved to artifact: cmd-XXXX.txt]" +2. You need to see more of the command output beyond the preview +3. You want to search for specific content in large command output + +The tool supports two modes: +- **Read mode**: Read output starting from a byte offset with optional limit +- **Search mode**: Filter lines matching a regex or literal pattern (like grep) + +Parameters: +- artifact_id: (required) The artifact filename from the truncated output message (e.g., "cmd-1706119234567.txt") +- search: (optional) Pattern to filter lines. Supports regex or literal strings. Case-insensitive. +- offset: (optional) Byte offset to start reading from. Default: 0. Use for pagination. +- limit: (optional) Maximum bytes to return. Default: 40KB. + +Example: Reading truncated command output +{ "artifact_id": "cmd-1706119234567.txt" } + +Example: Reading with pagination (after first 40KB) +{ "artifact_id": "cmd-1706119234567.txt", "offset": 40960 } + +Example: Searching for errors in build output +{ "artifact_id": "cmd-1706119234567.txt", "search": "error|failed|Error" } + +Example: Finding specific test failures +{ "artifact_id": "cmd-1706119234567.txt", "search": "FAIL" }` + +const ARTIFACT_ID_DESCRIPTION = `The artifact filename from the truncated command output (e.g., "cmd-1706119234567.txt")` + +const SEARCH_DESCRIPTION = `Optional regex or literal pattern to filter lines (case-insensitive, like grep)` + +const OFFSET_DESCRIPTION = `Byte offset to start reading from (default: 0, for pagination)` + +const LIMIT_DESCRIPTION = `Maximum bytes to return (default: 40KB)` + +export default { + type: "function", + function: { + name: "read_command_output", + description: READ_COMMAND_OUTPUT_DESCRIPTION, + // Note: strict mode is intentionally disabled for this tool. + // With strict: true, OpenAI requires ALL properties to be in the 'required' array, + // which forces the LLM to always provide explicit values (even null) for optional params. + // This creates verbose tool calls and poor UX. By disabling strict mode, the LLM can + // omit optional parameters entirely, making the tool easier to use. + parameters: { + type: "object", + properties: { + artifact_id: { + type: "string", + description: ARTIFACT_ID_DESCRIPTION, + }, + search: { + type: "string", + description: SEARCH_DESCRIPTION, + }, + offset: { + type: "number", + description: OFFSET_DESCRIPTION, + }, + limit: { + type: "number", + description: LIMIT_DESCRIPTION, + }, + }, + required: ["artifact_id"], + additionalProperties: false, + }, + }, +} satisfies OpenAI.Chat.ChatCompletionTool diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 11eebde78fb..61ebfb12998 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -84,11 +84,13 @@ import { DiffViewProvider } from "../../integrations/editor/DiffViewProvider" import { findToolName } from "../../integrations/misc/export-markdown" import { RooTerminalProcess } from "../../integrations/terminal/types" import { TerminalRegistry } from "../../integrations/terminal/TerminalRegistry" +import { OutputInterceptor } from "../../integrations/terminal/OutputInterceptor" // utils import { calculateApiCostAnthropic, calculateApiCostOpenAI } from "../../shared/cost" import { getWorkspacePath } from "../../utils/path" import { sanitizeToolUseId } from "../../utils/tool-id" +import { getTaskDirectoryPath } from "../../utils/storage" // prompts import { formatResponse } from "../prompts/responses" @@ -2252,6 +2254,16 @@ export class Task extends EventEmitter implements TaskLike { console.error("Error releasing terminals:", error) } + // Cleanup command output artifacts + getTaskDirectoryPath(this.globalStoragePath, this.taskId) + .then((taskDir) => { + const outputDir = path.join(taskDir, "command-output") + return OutputInterceptor.cleanup(outputDir) + }) + .catch((error) => { + console.error("Error cleaning up command output artifacts:", error) + }) + try { this.urlContentFetcher.closeBrowser() } catch (error) { diff --git a/src/core/tools/ExecuteCommandTool.ts b/src/core/tools/ExecuteCommandTool.ts index d3e2bbce8df..fca3cf7a313 100644 --- a/src/core/tools/ExecuteCommandTool.ts +++ b/src/core/tools/ExecuteCommandTool.ts @@ -4,7 +4,7 @@ import * as vscode from "vscode" import delay from "delay" -import { CommandExecutionStatus, DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT } from "@roo-code/types" +import { CommandExecutionStatus, DEFAULT_TERMINAL_OUTPUT_PREVIEW_SIZE, PersistedCommandOutput } from "@roo-code/types" import { TelemetryService } from "@roo-code/telemetry" import { Task } from "../task/Task" @@ -15,8 +15,10 @@ import { unescapeHtmlEntities } from "../../utils/text-normalization" import { ExitCodeDetails, RooTerminalCallbacks, RooTerminalProcess } from "../../integrations/terminal/types" import { TerminalRegistry } from "../../integrations/terminal/TerminalRegistry" import { Terminal } from "../../integrations/terminal/Terminal" +import { OutputInterceptor } from "../../integrations/terminal/OutputInterceptor" import { Package } from "../../shared/package" import { t } from "../../i18n" +import { getTaskDirectoryPath } from "../../utils/storage" import { BaseTool, ToolCallbacks } from "./BaseTool" class ShellIntegrationError extends Error {} @@ -62,11 +64,7 @@ export class ExecuteCommandTool extends BaseTool<"execute_command"> { const provider = await task.providerRef.deref() const providerState = await provider?.getState() - const { - terminalOutputLineLimit = 500, - terminalOutputCharacterLimit = DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, - terminalShellIntegrationDisabled = true, - } = providerState ?? {} + const { terminalShellIntegrationDisabled = true } = providerState ?? {} // Get command execution timeout from VSCode configuration (in seconds) const commandExecutionTimeoutSeconds = vscode.workspace @@ -91,8 +89,6 @@ export class ExecuteCommandTool extends BaseTool<"execute_command"> { command: unescapedCommand, customCwd, terminalShellIntegrationDisabled, - terminalOutputLineLimit, - terminalOutputCharacterLimit, commandExecutionTimeout, } @@ -146,8 +142,6 @@ export type ExecuteCommandOptions = { command: string customCwd?: string terminalShellIntegrationDisabled?: boolean - terminalOutputLineLimit?: number - terminalOutputCharacterLimit?: number commandExecutionTimeout?: number } @@ -158,8 +152,6 @@ export async function executeCommandInTerminal( command, customCwd, terminalShellIntegrationDisabled = true, - terminalOutputLineLimit = 500, - terminalOutputCharacterLimit = DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, commandExecutionTimeout = 0, }: ExecuteCommandOptions, ): Promise<[boolean, ToolResponse]> { @@ -185,6 +177,7 @@ export async function executeCommandInTerminal( let runInBackground = false let completed = false let result: string = "" + let persistedResult: PersistedCommandOutput | undefined let exitDetails: ExitCodeDetails | undefined let shellIntegrationError: string | undefined let hasAskedForCommandOutput = false @@ -192,15 +185,55 @@ export async function executeCommandInTerminal( const terminalProvider = terminalShellIntegrationDisabled ? "execa" : "vscode" const provider = await task.providerRef.deref() + // Get global storage path for persisted output artifacts + const globalStoragePath = provider?.context?.globalStorageUri?.fsPath + let interceptor: OutputInterceptor | undefined + + // Create OutputInterceptor if we have storage available + if (globalStoragePath) { + const taskDir = await getTaskDirectoryPath(globalStoragePath, task.taskId) + const storageDir = path.join(taskDir, "command-output") + const providerState = await provider?.getState() + const terminalOutputPreviewSize = + providerState?.terminalOutputPreviewSize ?? DEFAULT_TERMINAL_OUTPUT_PREVIEW_SIZE + + interceptor = new OutputInterceptor({ + executionId, + taskId: task.taskId, + command, + storageDir, + previewSize: terminalOutputPreviewSize, + }) + } + let accumulatedOutput = "" + // Bound accumulated output buffer size to prevent unbounded memory growth for long-running commands. + // The interceptor preserves full output; this buffer is only for UI display (100KB limit). + const maxAccumulatedOutputSize = 100_000 + + // Track when onCompleted callback finishes to avoid race condition. + // The callback is async but Terminal/ExecaTerminal don't await it, so we track completion + // explicitly to ensure persistedResult is set before we use it. + let onCompletedPromise: Promise | undefined + let resolveOnCompleted: (() => void) | undefined + onCompletedPromise = new Promise((resolve) => { + resolveOnCompleted = resolve + }) + const callbacks: RooTerminalCallbacks = { onLine: async (lines: string, process: RooTerminalProcess) => { accumulatedOutput += lines - const compressedOutput = Terminal.compressTerminalOutput( - accumulatedOutput, - terminalOutputLineLimit, - terminalOutputCharacterLimit, - ) + + // Trim accumulated output to prevent unbounded memory growth + if (accumulatedOutput.length > maxAccumulatedOutputSize) { + accumulatedOutput = accumulatedOutput.slice(-maxAccumulatedOutputSize) + } + + // Write to interceptor for persisted output + interceptor?.write(lines) + + // Continue sending compressed output to webview for UI display (unchanged behavior) + const compressedOutput = Terminal.compressTerminalOutput(accumulatedOutput) const status: CommandExecutionStatus = { executionId, status: "output", output: compressedOutput } provider?.postMessageToWebview({ type: "commandExecutionStatus", text: JSON.stringify(status) }) @@ -223,15 +256,24 @@ export async function executeCommandInTerminal( // Silently handle ask errors (e.g., "Current ask promise was ignored") } }, - onCompleted: (output: string | undefined) => { - result = Terminal.compressTerminalOutput( - output ?? "", - terminalOutputLineLimit, - terminalOutputCharacterLimit, - ) + onCompleted: async (output: string | undefined) => { + try { + // Finalize interceptor and get persisted result. + // We await finalize() to ensure the artifact file is fully flushed + // before we advertise the artifact_id to the LLM. + if (interceptor) { + persistedResult = await interceptor.finalize() + } + + // Continue using compressed output for UI display + result = Terminal.compressTerminalOutput(output ?? "") - task.say("command_output", result) - completed = true + task.say("command_output", result) + completed = true + } finally { + // Signal that onCompleted has finished, so the main code can safely use persistedResult + resolveOnCompleted?.() + } }, onShellExecutionStarted: (pid: number | undefined) => { const status: CommandExecutionStatus = { executionId, status: "started", pid, command } @@ -321,6 +363,13 @@ export async function executeCommandInTerminal( // grouping command_output messages despite any gaps anyways). await delay(50) + // Wait for onCompleted callback to finish if shell execution completed. + // This ensures persistedResult is set before we try to use it, fixing the race + // condition where exitDetails is set (sync) before the async onCompleted finishes. + if (exitDetails && onCompletedPromise) { + await onCompletedPromise + } + if (message) { const { text, images } = message await task.say("user_feedback", text, images) @@ -337,6 +386,14 @@ export async function executeCommandInTerminal( ), ] } else if (completed || exitDetails) { + const currentWorkingDir = terminal.getCurrentWorkingDirectory().toPosix() + + // Use persisted output format when output was truncated and spilled to disk + if (persistedResult?.truncated) { + return [false, formatPersistedOutput(persistedResult, exitDetails, currentWorkingDir)] + } + + // Use inline format for small outputs (original behavior with exit status) let exitStatus: string = "" if (exitDetails !== undefined) { @@ -361,9 +418,10 @@ export async function executeCommandInTerminal( exitStatus = `Exit code: ` } - let workingDirInfo = ` within working directory '${terminal.getCurrentWorkingDirectory().toPosix()}'` - - return [false, `Command executed in terminal ${workingDirInfo}. ${exitStatus}\nOutput:\n${result}`] + return [ + false, + `Command executed in terminal within working directory '${currentWorkingDir}'. ${exitStatus}\nOutput:\n${result}`, + ] } else { return [ false, @@ -376,4 +434,69 @@ export async function executeCommandInTerminal( } } +/** + * Format exit status from ExitCodeDetails + */ +function formatExitStatus(exitDetails: ExitCodeDetails | undefined): string { + if (exitDetails === undefined) { + return "Exit code: " + } + + if (exitDetails.signalName) { + let status = `Process terminated by signal ${exitDetails.signalName}` + if (exitDetails.coreDumpPossible) { + status += " - core dump possible" + } + return status + } + + if (exitDetails.exitCode === undefined) { + return "Exit code: " + } + + let status = "" + if (exitDetails.exitCode !== 0) { + status += "Command execution was not successful, inspect the cause and adjust as needed.\n" + } + status += `Exit code: ${exitDetails.exitCode}` + return status +} + +/** + * Format persisted output result for tool response when output was truncated + */ +function formatPersistedOutput( + result: PersistedCommandOutput, + exitDetails: ExitCodeDetails | undefined, + workingDir: string, +): string { + const exitStatus = formatExitStatus(exitDetails) + const sizeStr = formatBytes(result.totalBytes) + const artifactId = result.artifactPath ? path.basename(result.artifactPath) : "" + + return [ + `Command executed in '${workingDir}'. ${exitStatus}`, + "", + `Output (${sizeStr}) persisted. Artifact ID: ${artifactId}`, + "", + "Preview:", + result.preview, + "", + "Use read_command_output tool to view full output if needed.", + ].join("\n") +} + +/** + * Format bytes to human-readable string + */ +function formatBytes(bytes: number): string { + if (bytes < 1024) { + return `${bytes}B` + } + if (bytes < 1024 * 1024) { + return `${(bytes / 1024).toFixed(1)}KB` + } + return `${(bytes / (1024 * 1024)).toFixed(1)}MB` +} + export const executeCommandTool = new ExecuteCommandTool() diff --git a/src/core/tools/ReadCommandOutputTool.ts b/src/core/tools/ReadCommandOutputTool.ts new file mode 100644 index 00000000000..9d3bbd35ddc --- /dev/null +++ b/src/core/tools/ReadCommandOutputTool.ts @@ -0,0 +1,484 @@ +import * as fs from "fs/promises" +import * as path from "path" + +import { Task } from "../task/Task" +import { getTaskDirectoryPath } from "../../utils/storage" + +import { BaseTool, ToolCallbacks } from "./BaseTool" + +/** Default byte limit for read operations (40KB) */ +const DEFAULT_LIMIT = 40 * 1024 // 40KB default limit + +/** + * Parameters accepted by the read_command_output tool. + */ +interface ReadCommandOutputParams { + /** + * The artifact file identifier (e.g., "cmd-1706119234567.txt"). + * This is provided in the execute_command output when truncation occurs. + */ + artifact_id: string + /** + * Optional search pattern (regex or literal string) to filter lines. + * When provided, only lines matching the pattern are returned. + */ + search?: string + /** + * Byte offset to start reading from (default: 0). + * Used for paginating through large outputs. + */ + offset?: number + /** + * Maximum bytes to return (default: 32KB). + * Limits the amount of data returned in a single request. + */ + limit?: number +} + +/** + * ReadCommandOutputTool allows the LLM to retrieve full command output that was truncated. + * + * When `execute_command` produces output exceeding the preview threshold, the full output + * is persisted to disk by the `OutputInterceptor`. This tool enables the LLM to: + * + * 1. **Read full output**: Retrieve the complete command output beyond the preview + * 2. **Search output**: Filter lines matching a pattern (like grep) + * 3. **Paginate**: Read large outputs in chunks using offset/limit + * + * ## Storage Location + * + * Artifacts are stored outside the workspace in the task directory: + * `globalStoragePath/tasks/{taskId}/command-output/cmd-{executionId}.txt` + * + * ## Security + * + * The tool validates artifact_id format to prevent path traversal attacks. + * Only files matching `cmd-{digits}.txt` pattern are accessible. + * + * ## Usage Flow + * + * 1. LLM calls `execute_command` which runs a command + * 2. If output is large, response includes `artifact_id` and truncation notice + * 3. LLM calls `read_command_output` with the artifact_id to get more content + * + * @example + * ```typescript + * // Basic usage - read from beginning + * await readCommandOutputTool.execute({ + * artifact_id: "cmd-1706119234567.txt" + * }, task, callbacks); + * + * // Search for specific content + * await readCommandOutputTool.execute({ + * artifact_id: "cmd-1706119234567.txt", + * search: "error|failed" + * }, task, callbacks); + * + * // Paginate through large output + * await readCommandOutputTool.execute({ + * artifact_id: "cmd-1706119234567.txt", + * offset: 32768, // Start after first 32KB + * limit: 32768 // Read next 32KB + * }, task, callbacks); + * ``` + */ +export class ReadCommandOutputTool extends BaseTool<"read_command_output"> { + readonly name = "read_command_output" as const + + /** + * Execute the read_command_output tool. + * + * Reads persisted command output from disk, supporting both full reads and + * search-based filtering. Results include line numbers for easy reference. + * + * @param params - The tool parameters including artifact_id and optional search/pagination + * @param task - The current task instance for error reporting and state management + * @param callbacks - Callbacks for pushing tool results + */ + async execute(params: ReadCommandOutputParams, task: Task, callbacks: ToolCallbacks): Promise { + const { pushToolResult } = callbacks + const { artifact_id, search, offset = 0, limit = DEFAULT_LIMIT } = params + + // Validate required parameters + if (!artifact_id) { + task.consecutiveMistakeCount++ + task.recordToolError("read_command_output") + task.didToolFailInCurrentTurn = true + const errorMsg = await task.sayAndCreateMissingParamError("read_command_output", "artifact_id") + pushToolResult(`Error: ${errorMsg}`) + return + } + + // Validate artifact_id format to prevent path traversal + if (!this.isValidArtifactId(artifact_id)) { + task.consecutiveMistakeCount++ + task.recordToolError("read_command_output") + task.didToolFailInCurrentTurn = true + const errorMsg = `Invalid artifact_id format: "${artifact_id}". Expected format: cmd-{timestamp}.txt (e.g., "cmd-1706119234567.txt")` + await task.say("error", errorMsg) + pushToolResult(`Error: ${errorMsg}`) + return + } + + try { + // Get the task directory path + const provider = await task.providerRef.deref() + const globalStoragePath = provider?.context?.globalStorageUri?.fsPath + + if (!globalStoragePath) { + const errorMsg = "Unable to access command output storage. Global storage path is not available." + await task.say("error", errorMsg) + pushToolResult(`Error: ${errorMsg}`) + return + } + + const taskDir = await getTaskDirectoryPath(globalStoragePath, task.taskId) + const artifactPath = path.join(taskDir, "command-output", artifact_id) + + // Check if artifact exists + try { + await fs.access(artifactPath) + } catch { + const errorMsg = `Artifact not found: "${artifact_id}". Please verify the artifact_id from the command output message. Available artifacts are created when command output exceeds the preview size.` + await task.say("error", errorMsg) + task.didToolFailInCurrentTurn = true + pushToolResult(`Error: ${errorMsg}`) + return + } + + // Get file stats for metadata + const stats = await fs.stat(artifactPath) + const totalSize = stats.size + + // Validate offset + if (offset < 0 || offset >= totalSize) { + const errorMsg = `Invalid offset: ${offset}. File size is ${totalSize} bytes. Offset must be between 0 and ${totalSize - 1}.` + await task.say("error", errorMsg) + pushToolResult(`Error: ${errorMsg}`) + return + } + + let result: string + let readStart = 0 + let readEnd = 0 + let matchCount: number | undefined + + if (search) { + // Search mode: filter lines matching the pattern + const searchResult = await this.searchInArtifact(artifactPath, search, totalSize, limit) + result = searchResult.content + matchCount = searchResult.matchCount + // For search, we're scanning the whole file + readStart = 0 + readEnd = totalSize + } else { + // Normal read mode with offset/limit + result = await this.readArtifact(artifactPath, offset, limit, totalSize) + // Calculate actual read range + readStart = offset + readEnd = Math.min(offset + limit, totalSize) + } + + // Report to UI that we read command output + await task.say( + "tool", + JSON.stringify({ + tool: "readCommandOutput", + readStart, + readEnd, + totalBytes: totalSize, + ...(search && { searchPattern: search, matchCount }), + }), + ) + + task.consecutiveMistakeCount = 0 + pushToolResult(result) + } catch (error) { + const errorMsg = error instanceof Error ? error.message : String(error) + await task.say("error", `Error reading command output: ${errorMsg}`) + task.didToolFailInCurrentTurn = true + pushToolResult(`Error reading command output: ${errorMsg}`) + } + } + + /** + * Validate artifact_id format to prevent path traversal attacks. + * + * Only accepts IDs matching the pattern `cmd-{digits}.txt` which are + * generated by the OutputInterceptor. This prevents malicious paths + * like `../../../etc/passwd` from being used. + * + * @param artifactId - The artifact ID to validate + * @returns `true` if the format is valid, `false` otherwise + * @private + */ + private isValidArtifactId(artifactId: string): boolean { + // Only allow alphanumeric, hyphens, underscores, and dots + // Must match pattern cmd-{digits}.txt + const validPattern = /^cmd-\d+\.txt$/ + return validPattern.test(artifactId) + } + + /** + * Read artifact content with offset and limit, adding line numbers. + * + * Performs efficient partial file reads using file handles and positional + * reads. Line numbers are calculated by counting newlines in the portion + * of the file before the offset. + * + * @param artifactPath - Absolute path to the artifact file + * @param offset - Byte offset to start reading from + * @param limit - Maximum bytes to read + * @param totalSize - Total size of the file in bytes + * @returns Formatted output with header metadata and line-numbered content + * @private + */ + private async readArtifact( + artifactPath: string, + offset: number, + limit: number, + totalSize: number, + ): Promise { + const fileHandle = await fs.open(artifactPath, "r") + + try { + const buffer = Buffer.alloc(Math.min(limit, totalSize - offset)) + const { bytesRead } = await fileHandle.read(buffer, 0, buffer.length, offset) + const content = buffer.slice(0, bytesRead).toString("utf8") + + // Calculate line numbers based on offset using chunked reading to avoid large allocations + let startLineNumber = 1 + if (offset > 0) { + startLineNumber = await this.countNewlinesBeforeOffset(fileHandle, offset) + } + + const endOffset = offset + bytesRead + const truncated = endOffset < totalSize + const artifactId = path.basename(artifactPath) + + // Add line numbers to content + const numberedContent = this.addLineNumbers(content, startLineNumber) + + const header = [ + `[Command Output: ${artifactId}]`, + `Total size: ${this.formatBytes(totalSize)} | Showing bytes ${offset}-${endOffset} | ${truncated ? "TRUNCATED" : "COMPLETE"}`, + "", + ].join("\n") + + return header + numberedContent + } finally { + await fileHandle.close() + } + } + + /** + * Search artifact content for lines matching a pattern using chunked streaming. + * + * Performs grep-like searching through the artifact file using bounded memory. + * Instead of loading the entire file into memory, this reads in fixed-size chunks + * and processes lines as they are encountered. This keeps memory usage predictable + * even for very large command outputs (e.g., 100MB+ build logs). + * + * The pattern is treated as a case-insensitive regex. If the pattern is invalid + * regex syntax, it's escaped and treated as a literal string. + * + * Results are limited by the byte limit to prevent excessive output. + * + * @param artifactPath - Absolute path to the artifact file + * @param pattern - Search pattern (regex or literal string) + * @param totalSize - Total size of the file in bytes (for display) + * @param limit - Maximum bytes of matching content to return + * @returns Formatted output with matching lines and their line numbers + * @private + */ + private async searchInArtifact( + artifactPath: string, + pattern: string, + totalSize: number, + limit: number, + ): Promise<{ content: string; matchCount: number }> { + const CHUNK_SIZE = 64 * 1024 // 64KB chunks for bounded memory + + // Create case-insensitive regex for search + let regex: RegExp + try { + regex = new RegExp(pattern, "i") + } catch { + // If invalid regex, treat as literal string + regex = new RegExp(this.escapeRegExp(pattern), "i") + } + + const fileHandle = await fs.open(artifactPath, "r") + const matches: Array<{ lineNumber: number; content: string }> = [] + let totalMatchBytes = 0 + let lineNumber = 0 + let partialLine = "" // Holds incomplete line from previous chunk + let bytesRead = 0 + let hitLimit = false + + try { + while (bytesRead < totalSize && !hitLimit) { + const chunkSize = Math.min(CHUNK_SIZE, totalSize - bytesRead) + const buffer = Buffer.alloc(chunkSize) + const result = await fileHandle.read(buffer, 0, chunkSize, bytesRead) + + if (result.bytesRead === 0) { + break + } + + const chunk = buffer.slice(0, result.bytesRead).toString("utf8") + bytesRead += result.bytesRead + + // Combine with partial line from previous chunk + const combined = partialLine + chunk + const lines = combined.split("\n") + + // Last element may be incomplete (no trailing newline), save for next iteration + partialLine = lines.pop() ?? "" + + // Process complete lines + for (const line of lines) { + lineNumber++ + + if (regex.test(line)) { + const lineBytes = Buffer.byteLength(line, "utf8") + + // Stop if we've exceeded the byte limit + if (totalMatchBytes + lineBytes > limit) { + hitLimit = true + break + } + + matches.push({ lineNumber, content: line }) + totalMatchBytes += lineBytes + } + } + } + + // Process any remaining partial line at end of file + if (!hitLimit && partialLine.length > 0) { + lineNumber++ + if (regex.test(partialLine)) { + const lineBytes = Buffer.byteLength(partialLine, "utf8") + if (totalMatchBytes + lineBytes <= limit) { + matches.push({ lineNumber, content: partialLine }) + } + } + } + } finally { + await fileHandle.close() + } + + const artifactId = path.basename(artifactPath) + + if (matches.length === 0) { + const content = [ + `[Command Output: ${artifactId}] (search: "${pattern}")`, + `Total size: ${this.formatBytes(totalSize)}`, + "", + "No matches found for the search pattern.", + ].join("\n") + return { content, matchCount: 0 } + } + + // Format matches with line numbers + const matchedLines = matches.map((m) => `${String(m.lineNumber).padStart(5)} | ${m.content}`).join("\n") + + const content = [ + `[Command Output: ${artifactId}] (search: "${pattern}")`, + `Total matches: ${matches.length} | Showing first ${matches.length}`, + "", + matchedLines, + ].join("\n") + return { content, matchCount: matches.length } + } + + /** + * Add line numbers to content for easier reference. + * + * Each line is prefixed with its line number, right-padded to align + * all line numbers in the output. + * + * @param content - The text content to add line numbers to + * @param startLine - The line number for the first line + * @returns Content with line numbers prefixed to each line + * @private + */ + private addLineNumbers(content: string, startLine: number): string { + const lines = content.split("\n") + const maxLineNum = startLine + lines.length - 1 + const padding = String(maxLineNum).length + + return lines.map((line, index) => `${String(startLine + index).padStart(padding)} | ${line}`).join("\n") + } + + /** + * Format a byte count to a human-readable string. + * + * @param bytes - The byte count to format + * @returns Human-readable string (e.g., "1.5KB", "2.3MB") + * @private + */ + private formatBytes(bytes: number): string { + if (bytes < 1024) { + return `${bytes} bytes` + } + if (bytes < 1024 * 1024) { + return `${(bytes / 1024).toFixed(1)}KB` + } + return `${(bytes / (1024 * 1024)).toFixed(1)}MB` + } + + /** + * Escape special regex characters in a string for literal matching. + * + * @param string - The string to escape + * @returns The escaped string safe for use in a RegExp constructor + * @private + */ + private escapeRegExp(string: string): string { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + } + + /** + * Count newlines before a given byte offset using fixed-size chunks. + * + * This avoids allocating a buffer of size `offset` which could be huge + * for large files. Instead, we read in 64KB chunks and count newlines. + * + * @param fileHandle - Open file handle for reading + * @param offset - The byte offset to count newlines up to + * @returns The line number at the given offset (1-indexed) + * @private + */ + private async countNewlinesBeforeOffset(fileHandle: fs.FileHandle, offset: number): Promise { + const CHUNK_SIZE = 64 * 1024 // 64KB chunks + let newlineCount = 0 + let bytesRead = 0 + + while (bytesRead < offset) { + const chunkSize = Math.min(CHUNK_SIZE, offset - bytesRead) + const buffer = Buffer.alloc(chunkSize) + const result = await fileHandle.read(buffer, 0, chunkSize, bytesRead) + + if (result.bytesRead === 0) { + break + } + + // Count newlines in this chunk + for (let i = 0; i < result.bytesRead; i++) { + if (buffer[i] === 0x0a) { + // '\n' + newlineCount++ + } + } + + bytesRead += result.bytesRead + } + + return newlineCount + 1 // Line numbers are 1-indexed + } +} + +/** Singleton instance of the ReadCommandOutputTool */ +export const readCommandOutputTool = new ReadCommandOutputTool() diff --git a/src/core/tools/__tests__/ReadCommandOutputTool.test.ts b/src/core/tools/__tests__/ReadCommandOutputTool.test.ts new file mode 100644 index 00000000000..11f85e67c08 --- /dev/null +++ b/src/core/tools/__tests__/ReadCommandOutputTool.test.ts @@ -0,0 +1,579 @@ +import * as fs from "fs/promises" +import * as path from "path" +import { vi, describe, it, expect, beforeEach, afterEach } from "vitest" + +import { ReadCommandOutputTool } from "../ReadCommandOutputTool" +import { Task } from "../../task/Task" + +// Mock filesystem operations +vi.mock("fs/promises", () => ({ + default: { + access: vi.fn(), + stat: vi.fn(), + open: vi.fn(), + readFile: vi.fn(), + }, + access: vi.fn(), + stat: vi.fn(), + open: vi.fn(), + readFile: vi.fn(), +})) + +// Mock getTaskDirectoryPath +vi.mock("../../../utils/storage", () => ({ + getTaskDirectoryPath: vi.fn((globalStoragePath: string, taskId: string) => { + return path.join(globalStoragePath, "tasks", taskId) + }), +})) + +describe("ReadCommandOutputTool", () => { + let tool: ReadCommandOutputTool + let mockTask: any + let mockCallbacks: any + let mockFileHandle: any + let globalStoragePath: string + let taskId: string + + beforeEach(() => { + vi.clearAllMocks() + + tool = new ReadCommandOutputTool() + globalStoragePath = "/mock/global/storage" + taskId = "task-123" + + // Mock task object + mockTask = { + taskId, + consecutiveMistakeCount: 0, + didToolFailInCurrentTurn: false, + say: vi.fn().mockResolvedValue(undefined), + sayAndCreateMissingParamError: vi.fn().mockResolvedValue("Missing parameter"), + recordToolError: vi.fn(), + providerRef: { + deref: vi.fn().mockResolvedValue({ + context: { + globalStorageUri: { + fsPath: globalStoragePath, + }, + }, + }), + }, + } + + // Mock callbacks + mockCallbacks = { + pushToolResult: vi.fn(), + } + + // Mock file handle + mockFileHandle = { + read: vi.fn(), + close: vi.fn().mockResolvedValue(undefined), + } + + // Default mocks + vi.mocked(fs.access).mockResolvedValue(undefined) + vi.mocked(fs.stat).mockResolvedValue({ size: 1000 } as any) + vi.mocked(fs.open).mockResolvedValue(mockFileHandle as any) + }) + + afterEach(() => { + vi.restoreAllMocks() + }) + + describe("Basic read functionality", () => { + it("should read artifact file correctly", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Line 1\nLine 2\nLine 3\n" + const buffer = Buffer.from(content) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buffer.copy(buf) + return Promise.resolve({ bytesRead: buffer.length }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + expect(fs.access).toHaveBeenCalledWith( + path.join(globalStoragePath, "tasks", taskId, "command-output", artifactId), + ) + expect(mockCallbacks.pushToolResult).toHaveBeenCalled() + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("Line 1") + expect(result).toContain("Line 2") + expect(result).toContain("Line 3") + }) + + it("should return content with line numbers", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "First line\nSecond line\nThird line\n" + const buffer = Buffer.from(content) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buffer.copy(buf) + return Promise.resolve({ bytesRead: buffer.length }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toMatch(/1 \| First line/) + expect(result).toMatch(/2 \| Second line/) + expect(result).toMatch(/3 \| Third line/) + }) + + it("should include size metadata in output", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Test output" + const fileSize = 5000 + const buffer = Buffer.from(content) + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buffer.copy(buf) + return Promise.resolve({ bytesRead: buffer.length }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain(`[Command Output: ${artifactId}]`) + expect(result).toContain("Total size:") + expect(result).toMatch(/\d+(\.\d+)?(bytes|KB|MB)/) + }) + + it("should close file handle after reading", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Test" + const buffer = Buffer.from(content) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buffer.copy(buf) + return Promise.resolve({ bytesRead: buffer.length }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + expect(mockFileHandle.close).toHaveBeenCalled() + }) + }) + + describe("Pagination (offset/limit)", () => { + it("should use default limit of 40KB", async () => { + const artifactId = "cmd-1706119234567.txt" + const largeContent = "x".repeat(50 * 1024) // 50KB + const fileSize = Buffer.byteLength(largeContent, "utf8") + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + // Mock read to return only up to default limit (40KB) + mockFileHandle.read.mockImplementation((buf: Buffer) => { + const defaultLimit = 40 * 1024 + const bytesToRead = Math.min(buf.length, defaultLimit) + buf.write(largeContent.slice(0, bytesToRead)) + return Promise.resolve({ bytesRead: bytesToRead }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("TRUNCATED") + }) + + it("should start reading from custom offset", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "0123456789ABCDEFGHIJ" + const offset = 10 + const fileSize = Buffer.byteLength(content, "utf8") + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + // Mock first read for offset calculation (returns content before offset) + // Mock second read for actual content + let readCallCount = 0 + mockFileHandle.read.mockImplementation( + (buf: Buffer, bufOffset: number, length: number, position: number | null) => { + readCallCount++ + if (position === 0) { + // First read: prefix for line number calculation + const prefixContent = content.slice(0, offset) + buf.write(prefixContent) + return Promise.resolve({ bytesRead: prefixContent.length }) + } else { + // Second read: actual content from offset + const actualContent = content.slice(offset) + buf.write(actualContent) + return Promise.resolve({ bytesRead: actualContent.length }) + } + }, + ) + + await tool.execute({ artifact_id: artifactId, offset }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain(`Showing bytes ${offset}-`) + expect(mockFileHandle.read).toHaveBeenCalled() + }) + + it("should restrict output size with custom limit", async () => { + const artifactId = "cmd-1706119234567.txt" + const largeContent = "x".repeat(10000) + const customLimit = 1000 + const fileSize = Buffer.byteLength(largeContent, "utf8") + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + const bytesToRead = Math.min(buf.length, customLimit) + buf.write(largeContent.slice(0, bytesToRead)) + return Promise.resolve({ bytesRead: bytesToRead }) + }) + + await tool.execute({ artifact_id: artifactId, limit: customLimit }, mockTask, mockCallbacks) + + expect(mockCallbacks.pushToolResult).toHaveBeenCalled() + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("TRUNCATED") + }) + + it("should show TRUNCATED when more content exists", async () => { + const artifactId = "cmd-1706119234567.txt" + const fileSize = 10000 + const limit = 5000 + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + const content = "x".repeat(limit) + buf.write(content) + return Promise.resolve({ bytesRead: limit }) + }) + + await tool.execute({ artifact_id: artifactId, limit }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("TRUNCATED") + }) + + it("should show COMPLETE when all content is returned", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Small content" + const fileSize = Buffer.byteLength(content, "utf8") + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buf.write(content) + return Promise.resolve({ bytesRead: fileSize }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("COMPLETE") + expect(result).not.toContain("TRUNCATED") + }) + }) + + describe("Search filtering", () => { + // Helper to setup file handle mock for search (which now uses streaming) + const setupSearchMock = (content: string) => { + const buffer = Buffer.from(content) + const fileSize = buffer.length + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + // Mock streaming read - return entire content in one chunk (simulates small file) + mockFileHandle.read.mockImplementation( + (buf: Buffer, bufOffset: number, length: number, position: number | null) => { + const pos = position ?? 0 + if (pos >= fileSize) { + return Promise.resolve({ bytesRead: 0 }) + } + const bytesToRead = Math.min(length, fileSize - pos) + buffer.copy(buf, 0, pos, pos + bytesToRead) + return Promise.resolve({ bytesRead: bytesToRead }) + }, + ) + } + + it("should filter lines matching pattern", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Line 1: error occurred\nLine 2: success\nLine 3: error found\nLine 4: complete\n" + + setupSearchMock(content) + + await tool.execute({ artifact_id: artifactId, search: "error" }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("error occurred") + expect(result).toContain("error found") + expect(result).not.toContain("success") + expect(result).not.toContain("complete") + }) + + it("should use case-insensitive matching", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "ERROR: Something bad\nwarning: minor issue\nERROR: Another problem\n" + + setupSearchMock(content) + + await tool.execute({ artifact_id: artifactId, search: "error" }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("ERROR: Something bad") + expect(result).toContain("ERROR: Another problem") + }) + + it("should show match count and line numbers", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Line 1\nError on line 2\nLine 3\nError on line 4\n" + + setupSearchMock(content) + + await tool.execute({ artifact_id: artifactId, search: "Error" }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("Total matches: 2") + expect(result).toMatch(/2 \|.*Error on line 2/) + expect(result).toMatch(/4 \|.*Error on line 4/) + }) + + it("should handle empty search results gracefully", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Line 1\nLine 2\nLine 3\n" + + setupSearchMock(content) + + await tool.execute({ artifact_id: artifactId, search: "NOTFOUND" }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("No matches found for the search pattern") + }) + + it("should handle regex patterns in search", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "test123\ntest456\nabc789\ntest000\n" + + setupSearchMock(content) + + await tool.execute({ artifact_id: artifactId, search: "test\\d+" }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("test123") + expect(result).toContain("test456") + expect(result).toContain("test000") + expect(result).not.toContain("abc789") + }) + + it("should handle invalid regex patterns by treating as literal", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Line with [brackets]\nLine without\n" + + setupSearchMock(content) + + // Invalid regex but valid as literal string + await tool.execute({ artifact_id: artifactId, search: "[" }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain("[brackets]") + }) + }) + + describe("Error handling", () => { + it("should return error for non-existent artifact", async () => { + const artifactId = "cmd-9999999999.txt" + + vi.mocked(fs.access).mockRejectedValue(new Error("ENOENT")) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + expect(mockTask.didToolFailInCurrentTurn).toBe(true) + expect(mockTask.say).toHaveBeenCalledWith("error", expect.stringContaining("not found")) + expect(mockCallbacks.pushToolResult).toHaveBeenCalledWith( + expect.stringContaining("Error: Artifact not found"), + ) + }) + + it("should reject invalid artifact_id with path traversal attempt", async () => { + const invalidIds = [ + "../../../etc/passwd", + "..\\..\\..\\windows\\system32\\config", + "cmd-123/../other.txt", + "cmd-.txt", + "cmd-.txt", + "invalid-format.txt", + ] + + for (const invalidId of invalidIds) { + vi.clearAllMocks() + mockTask.consecutiveMistakeCount = 0 + mockTask.didToolFailInCurrentTurn = false + + await tool.execute({ artifact_id: invalidId }, mockTask, mockCallbacks) + + expect(mockTask.consecutiveMistakeCount).toBeGreaterThan(0) + expect(mockTask.didToolFailInCurrentTurn).toBe(true) + expect(mockTask.say).toHaveBeenCalledWith( + "error", + expect.stringContaining("Invalid artifact_id format"), + ) + } + }) + + it("should accept valid artifact_id format", async () => { + const validId = "cmd-1706119234567.txt" + const content = "Test" + const buffer = Buffer.from(content) + + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buffer.copy(buf) + return Promise.resolve({ bytesRead: buffer.length }) + }) + + await tool.execute({ artifact_id: validId }, mockTask, mockCallbacks) + + expect(mockTask.consecutiveMistakeCount).toBe(0) + expect(mockTask.didToolFailInCurrentTurn).toBe(false) + }) + + it("should handle invalid offset gracefully", async () => { + const artifactId = "cmd-1706119234567.txt" + const fileSize = 1000 + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + await tool.execute( + { artifact_id: artifactId, offset: 2000 }, // Offset beyond file size + mockTask, + mockCallbacks, + ) + + expect(mockTask.say).toHaveBeenCalledWith("error", expect.stringContaining("Invalid offset")) + expect(mockCallbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("Error: Invalid offset")) + }) + + it("should handle negative offset", async () => { + const artifactId = "cmd-1706119234567.txt" + const fileSize = 1000 + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + await tool.execute({ artifact_id: artifactId, offset: -10 }, mockTask, mockCallbacks) + + expect(mockTask.say).toHaveBeenCalledWith("error", expect.stringContaining("Invalid offset")) + }) + + it("should handle missing artifact_id parameter", async () => { + await tool.execute({ artifact_id: "" }, mockTask, mockCallbacks) + + expect(mockTask.consecutiveMistakeCount).toBeGreaterThan(0) + expect(mockTask.recordToolError).toHaveBeenCalledWith("read_command_output") + expect(mockTask.didToolFailInCurrentTurn).toBe(true) + expect(mockTask.sayAndCreateMissingParamError).toHaveBeenCalledWith("read_command_output", "artifact_id") + }) + + it("should handle missing global storage path", async () => { + const artifactId = "cmd-1706119234567.txt" + + mockTask.providerRef.deref.mockResolvedValue({ + context: { + globalStorageUri: null, + }, + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + expect(mockTask.say).toHaveBeenCalledWith( + "error", + expect.stringContaining("Global storage path is not available"), + ) + expect(mockCallbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("Error")) + }) + + it("should handle file read errors", async () => { + const artifactId = "cmd-1706119234567.txt" + + mockFileHandle.read.mockRejectedValue(new Error("Read error")) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + expect(mockTask.didToolFailInCurrentTurn).toBe(true) + expect(mockTask.say).toHaveBeenCalledWith("error", expect.stringContaining("Error reading command output")) + }) + + it("should ensure file handle is closed even on error", async () => { + const artifactId = "cmd-1706119234567.txt" + + mockFileHandle.read.mockRejectedValue(new Error("Read error")) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + expect(mockFileHandle.close).toHaveBeenCalled() + }) + }) + + describe("Byte formatting", () => { + it("should format bytes correctly", async () => { + const testCases = [ + { size: 500, expected: "bytes" }, + { size: 1024, expected: "1.0KB" }, + { size: 2048, expected: "2.0KB" }, + { size: 1024 * 1024, expected: "1.0MB" }, + { size: 2.5 * 1024 * 1024, expected: "2.5MB" }, + ] + + for (const { size, expected } of testCases) { + vi.clearAllMocks() + const artifactId = "cmd-1706119234567.txt" + const content = "x" + const buffer = Buffer.from(content) + + vi.mocked(fs.stat).mockResolvedValue({ size } as any) + mockFileHandle.read.mockImplementation((buf: Buffer) => { + buffer.copy(buf) + return Promise.resolve({ bytesRead: buffer.length }) + }) + + await tool.execute({ artifact_id: artifactId }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + expect(result).toContain(expected) + } + }) + }) + + describe("Line number calculation", () => { + it("should calculate correct starting line number for offset", async () => { + const artifactId = "cmd-1706119234567.txt" + const content = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n" + const offset = 14 // After "Line 1\nLine 2\n" + const fileSize = Buffer.byteLength(content, "utf8") + + vi.mocked(fs.stat).mockResolvedValue({ size: fileSize } as any) + + let readCallCount = 0 + mockFileHandle.read.mockImplementation( + (buf: Buffer, bufOffset: number, length: number, position: number | null) => { + readCallCount++ + if (position === 0) { + // Read prefix for line counting + const prefix = content.slice(0, offset) + buf.write(prefix) + return Promise.resolve({ bytesRead: prefix.length }) + } else { + // Read actual content from offset + const actualContent = content.slice(offset) + buf.write(actualContent) + return Promise.resolve({ bytesRead: actualContent.length }) + } + }, + ) + + await tool.execute({ artifact_id: artifactId, offset }, mockTask, mockCallbacks) + + const result = mockCallbacks.pushToolResult.mock.calls[0][0] + // Should start at line 3 since we skipped 2 newlines + expect(result).toMatch(/3 \|/) + }) + }) +}) diff --git a/src/core/tools/__tests__/executeCommand.spec.ts b/src/core/tools/__tests__/executeCommand.spec.ts index f5fc258e3ae..fd85beb0f46 100644 --- a/src/core/tools/__tests__/executeCommand.spec.ts +++ b/src/core/tools/__tests__/executeCommand.spec.ts @@ -40,7 +40,6 @@ describe("executeCommand", () => { mockProvider = { postMessageToWebview: vitest.fn(), getState: vitest.fn().mockResolvedValue({ - terminalOutputLineLimit: 500, terminalShellIntegrationDisabled: false, }), } @@ -100,7 +99,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "echo test", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -141,7 +139,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "echo test", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -174,7 +171,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "echo test", terminalShellIntegrationDisabled: true, // Forces ExecaTerminal - terminalOutputLineLimit: 500, } // Execute @@ -205,7 +201,6 @@ describe("executeCommand", () => { command: "echo test", customCwd, terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -235,7 +230,6 @@ describe("executeCommand", () => { command: "echo test", customCwd: relativeCwd, terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -258,7 +252,6 @@ describe("executeCommand", () => { command: "echo test", customCwd: nonExistentCwd, terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -285,7 +278,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "echo test", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -308,7 +300,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "echo test", terminalShellIntegrationDisabled: true, - terminalOutputLineLimit: 500, } // Execute @@ -334,7 +325,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "echo success", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -360,7 +350,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "exit 1", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -394,7 +383,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "long-running-command", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute @@ -436,7 +424,6 @@ describe("executeCommand", () => { executionId: "test-123", command: "cd src && pwd", terminalShellIntegrationDisabled: false, - terminalOutputLineLimit: 500, } // Execute diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 7c7a749eca9..365717b0825 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -40,7 +40,6 @@ import { RooCodeEventName, requestyDefaultModelId, openRouterDefaultModelId, - DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, DEFAULT_WRITE_DELAY_MS, ORGANIZATION_ALLOW_ALL, DEFAULT_MODES, @@ -2016,8 +2015,6 @@ export class ClineProvider remoteBrowserEnabled, cachedChromeHostUrl, writeDelayMs, - terminalOutputLineLimit, - terminalOutputCharacterLimit, terminalShellIntegrationTimeout, terminalShellIntegrationDisabled, terminalCommandDelay, @@ -2048,7 +2045,6 @@ export class ClineProvider maxReadFileLine, maxImageFileSize, maxTotalImageSize, - terminalCompressProgressBar, historyPreviewCollapsed, reasoningBlockCollapsed, enterBehavior, @@ -2157,8 +2153,6 @@ export class ClineProvider remoteBrowserEnabled: remoteBrowserEnabled ?? false, cachedChromeHostUrl: cachedChromeHostUrl, writeDelayMs: writeDelayMs ?? DEFAULT_WRITE_DELAY_MS, - terminalOutputLineLimit: terminalOutputLineLimit ?? 500, - terminalOutputCharacterLimit: terminalOutputCharacterLimit ?? DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, terminalShellIntegrationTimeout: terminalShellIntegrationTimeout ?? Terminal.defaultShellIntegrationTimeout, terminalShellIntegrationDisabled: terminalShellIntegrationDisabled ?? true, terminalCommandDelay: terminalCommandDelay ?? 0, @@ -2196,7 +2190,6 @@ export class ClineProvider maxTotalImageSize: maxTotalImageSize ?? 20, maxConcurrentFileReads: maxConcurrentFileReads ?? 5, settingsImportedAt: this.settingsImportedAt, - terminalCompressProgressBar: terminalCompressProgressBar ?? true, hasSystemPromptOverride, historyPreviewCollapsed: historyPreviewCollapsed ?? false, reasoningBlockCollapsed: reasoningBlockCollapsed ?? true, @@ -2403,9 +2396,6 @@ export class ClineProvider remoteBrowserEnabled: stateValues.remoteBrowserEnabled ?? false, cachedChromeHostUrl: stateValues.cachedChromeHostUrl as string | undefined, writeDelayMs: stateValues.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS, - terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500, - terminalOutputCharacterLimit: - stateValues.terminalOutputCharacterLimit ?? DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT, terminalShellIntegrationTimeout: stateValues.terminalShellIntegrationTimeout ?? Terminal.defaultShellIntegrationTimeout, terminalShellIntegrationDisabled: stateValues.terminalShellIntegrationDisabled ?? true, @@ -2415,7 +2405,6 @@ export class ClineProvider terminalZshOhMy: stateValues.terminalZshOhMy ?? false, terminalZshP10k: stateValues.terminalZshP10k ?? false, terminalZdotdir: stateValues.terminalZdotdir ?? false, - terminalCompressProgressBar: stateValues.terminalCompressProgressBar ?? true, mode: stateValues.mode ?? defaultModeSlug, language: stateValues.language ?? formatLanguage(vscode.env.language), mcpEnabled: stateValues.mcpEnabled ?? true, diff --git a/src/core/webview/webviewMessageHandler.ts b/src/core/webview/webviewMessageHandler.ts index 2dc77d05027..6a0224b42f8 100644 --- a/src/core/webview/webviewMessageHandler.ts +++ b/src/core/webview/webviewMessageHandler.ts @@ -631,10 +631,6 @@ export const webviewMessageHandler = async ( if (value !== undefined) { Terminal.setTerminalZdotdir(value as boolean) } - } else if (key === "terminalCompressProgressBar") { - if (value !== undefined) { - Terminal.setCompressProgressBar(value as boolean) - } } else if (key === "mcpEnabled") { newValue = value ?? true const mcpHub = provider.getMcpHub() diff --git a/src/integrations/terminal/BaseTerminal.ts b/src/integrations/terminal/BaseTerminal.ts index 49f0746c68e..121dc343136 100644 --- a/src/integrations/terminal/BaseTerminal.ts +++ b/src/integrations/terminal/BaseTerminal.ts @@ -1,5 +1,4 @@ -import { truncateOutput, applyRunLengthEncoding, processBackspaces, processCarriageReturns } from "../misc/extract-text" -import { DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT } from "@roo-code/types" +import { truncateOutput, applyRunLengthEncoding } from "../misc/extract-text" import type { RooTerminalProvider, @@ -162,7 +161,6 @@ export abstract class BaseTerminal implements RooTerminal { private static terminalZshOhMy: boolean = false private static terminalZshP10k: boolean = false private static terminalZdotdir: boolean = false - private static compressProgressBar: boolean = true /** * Compresses terminal output by applying run-length encoding and truncating to line limit @@ -266,24 +264,19 @@ export abstract class BaseTerminal implements RooTerminal { } /** - * Compresses terminal output by applying run-length encoding and truncating to line and character limits + * Compresses terminal output by applying run-length encoding and truncating to reasonable limits. + * Uses hardcoded defaults: 500 lines, 50K characters - these are UI display limits to prevent + * memory issues, not LLM context limits (which are controlled by terminalOutputPreviewSize). * @param input The terminal output to compress - * @param lineLimit Maximum number of lines to keep - * @param characterLimit Optional maximum number of characters to keep (defaults to DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT) * @returns The compressed terminal output */ - public static compressTerminalOutput(input: string, lineLimit: number, characterLimit?: number): string { - let processedInput = input + public static compressTerminalOutput(input: string): string { + // Hardcoded UI display limits - these prevent unbounded memory growth + // in the chat display, separate from the LLM context limits + const LINE_LIMIT = 500 + const CHARACTER_LIMIT = 50_000 - if (BaseTerminal.compressProgressBar) { - processedInput = processCarriageReturns(processedInput) - processedInput = processBackspaces(processedInput) - } - - // Default character limit to prevent context window explosion - const effectiveCharLimit = characterLimit ?? DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT - - return truncateOutput(applyRunLengthEncoding(processedInput), lineLimit, effectiveCharLimit) + return truncateOutput(applyRunLengthEncoding(input), LINE_LIMIT, CHARACTER_LIMIT) } /** @@ -301,20 +294,4 @@ export abstract class BaseTerminal implements RooTerminal { public static getTerminalZdotdir(): boolean { return BaseTerminal.terminalZdotdir } - - /** - * Sets whether to compress progress bar output by processing carriage returns - * @param enabled Whether to enable progress bar compression - */ - public static setCompressProgressBar(enabled: boolean): void { - BaseTerminal.compressProgressBar = enabled - } - - /** - * Gets whether progress bar compression is enabled - * @returns Whether progress bar compression is enabled - */ - public static getCompressProgressBar(): boolean { - return BaseTerminal.compressProgressBar - } } diff --git a/src/integrations/terminal/OutputInterceptor.ts b/src/integrations/terminal/OutputInterceptor.ts new file mode 100644 index 00000000000..d1725c64269 --- /dev/null +++ b/src/integrations/terminal/OutputInterceptor.ts @@ -0,0 +1,430 @@ +import * as fs from "fs" +import * as path from "path" + +import { TerminalOutputPreviewSize, TERMINAL_PREVIEW_BYTES, PersistedCommandOutput } from "@roo-code/types" + +/** + * Configuration options for creating an OutputInterceptor instance. + */ +export interface OutputInterceptorOptions { + /** Unique identifier for this command execution (typically a timestamp) */ + executionId: string + /** ID of the task that initiated this command */ + taskId: string + /** The command string being executed */ + command: string + /** Directory path where command output artifacts will be stored */ + storageDir: string + /** Size category for the preview buffer (small/medium/large) */ + previewSize: TerminalOutputPreviewSize +} + +/** + * OutputInterceptor buffers terminal command output and spills to disk when threshold exceeded. + * + * This implements a "persisted output" pattern where large command outputs are saved to disk + * files, with only a preview shown to the LLM. The LLM can then use the `read_command_output` + * tool to retrieve full contents or search through the output. + * + * The interceptor uses a **head/tail buffer** strategy (inspired by Codex): + * - 50% of the preview budget is allocated to the "head" (beginning of output) + * - 50% of the preview budget is allocated to the "tail" (end of output) + * - Middle content is dropped when output exceeds the preview threshold + * + * This approach ensures the LLM sees both: + * - The beginning (command startup, environment info, early errors) + * - The end (final results, exit codes, error summaries) + * + * @example + * ```typescript + * const interceptor = new OutputInterceptor({ + * executionId: Date.now().toString(), + * taskId: 'task-123', + * command: 'npm test', + * storageDir: '/path/to/task/command-output', + * previewSize: 'medium', + * }); + * + * // Write output chunks as they arrive + * interceptor.write('Running tests...\n'); + * interceptor.write('Test 1 passed\n'); + * + * // Finalize and get the result + * const result = interceptor.finalize(); + * // result.preview contains head + [omitted] + tail for display + * // result.artifactPath contains path to full output if truncated + * ``` + */ +export class OutputInterceptor { + /** Buffer for the head (beginning) of output */ + private headBuffer: string = "" + /** Buffer for the tail (end) of output - rolling buffer that drops front when full */ + private tailBuffer: string = "" + /** Number of bytes currently in the head buffer */ + private headBytes: number = 0 + /** Number of bytes currently in the tail buffer */ + private tailBytes: number = 0 + /** Number of bytes omitted from the middle */ + private omittedBytes: number = 0 + + /** + * Pending chunks accumulated before spilling to disk. + * These contain ALL content (lossless) until we decide to spill. + * Once spilled, this array is cleared and subsequent writes go directly to disk. + */ + private pendingChunks: string[] = [] + + private writeStream: fs.WriteStream | null = null + private artifactPath: string + private totalBytes: number = 0 + private spilledToDisk: boolean = false + private readonly previewBytes: number + /** Budget for the head buffer (50% of total preview) */ + private readonly headBudget: number + /** Budget for the tail buffer (50% of total preview) */ + private readonly tailBudget: number + + /** + * Creates a new OutputInterceptor instance. + * + * @param options - Configuration options for the interceptor + */ + constructor(private readonly options: OutputInterceptorOptions) { + this.previewBytes = TERMINAL_PREVIEW_BYTES[options.previewSize] + this.headBudget = Math.floor(this.previewBytes / 2) + this.tailBudget = this.previewBytes - this.headBudget + this.artifactPath = path.join(options.storageDir, `cmd-${options.executionId}.txt`) + } + + /** + * Write a chunk of output to the interceptor. + * + * Output is first added to the head buffer until it's full (50% of preview budget). + * Subsequent output goes to a rolling tail buffer that keeps the most recent content. + * + * If the total output exceeds the preview threshold, the interceptor spills to disk + * for full output storage while maintaining head/tail buffers for the preview. + * + * @param chunk - The output string to write + * + * @example + * ```typescript + * interceptor.write('Building project...\n'); + * interceptor.write('Compiling 42 files\n'); + * ``` + */ + write(chunk: string): void { + const chunkBytes = Buffer.byteLength(chunk, "utf8") + this.totalBytes += chunkBytes + + // Always update the head/tail preview buffers + this.addToPreviewBuffers(chunk) + + // Handle disk spilling for full output preservation + if (!this.spilledToDisk) { + // Accumulate ALL chunks for lossless disk storage + this.pendingChunks.push(chunk) + + if (this.totalBytes > this.previewBytes) { + this.spillToDisk() + } + } else { + // Already spilling - write directly to disk + this.writeStream?.write(chunk) + } + } + + /** + * Add a chunk to the head/tail preview buffers using 50/50 split strategy. + * + * Fill head first until budget exhausted, then maintain a rolling tail buffer. + * + * @private + */ + private addToPreviewBuffers(chunk: string): void { + let remaining = chunk + let remainingBytes = Buffer.byteLength(chunk, "utf8") + + // First, fill the head buffer if there's room + if (this.headBytes < this.headBudget) { + const headRoom = this.headBudget - this.headBytes + if (remainingBytes <= headRoom) { + // Entire chunk fits in head + this.headBuffer += remaining + this.headBytes += remainingBytes + return + } + // Split: part goes to head, rest goes to tail + const headPortion = this.sliceByBytes(remaining, headRoom) + this.headBuffer += headPortion + this.headBytes += headRoom + remaining = remaining.slice(headPortion.length) + remainingBytes = Buffer.byteLength(remaining, "utf8") + } + + // Add remainder to tail buffer + this.addToTailBuffer(remaining, remainingBytes) + } + + /** + * Add content to the rolling tail buffer, dropping old content as needed. + * + * @private + */ + private addToTailBuffer(chunk: string, chunkBytes: number): void { + if (this.tailBudget === 0) { + this.omittedBytes += chunkBytes + return + } + + // If this single chunk is larger than the tail budget, keep only the last tailBudget bytes + if (chunkBytes >= this.tailBudget) { + const dropped = this.tailBytes + (chunkBytes - this.tailBudget) + this.omittedBytes += dropped + this.tailBuffer = this.sliceByBytesFromEnd(chunk, this.tailBudget) + this.tailBytes = this.tailBudget + return + } + + // Append to tail + this.tailBuffer += chunk + this.tailBytes += chunkBytes + + // Trim from front if over budget + this.trimTailToFit() + } + + /** + * Trim the tail buffer from the front to fit within the tail budget. + * + * @private + */ + private trimTailToFit(): void { + while (this.tailBytes > this.tailBudget && this.tailBuffer.length > 0) { + const excess = this.tailBytes - this.tailBudget + // Remove characters from the front until we're under budget + // We need to be careful with multi-byte characters + let removed = 0 + let removeChars = 0 + while (removed < excess && removeChars < this.tailBuffer.length) { + const charBytes = Buffer.byteLength(this.tailBuffer[removeChars], "utf8") + removed += charBytes + removeChars++ + } + this.omittedBytes += removed + this.tailBytes -= removed + this.tailBuffer = this.tailBuffer.slice(removeChars) + } + } + + /** + * Slice a string to get approximately the first N bytes (UTF-8). + * + * @private + */ + private sliceByBytes(str: string, maxBytes: number): string { + let bytes = 0 + let i = 0 + while (i < str.length && bytes < maxBytes) { + const charBytes = Buffer.byteLength(str[i], "utf8") + if (bytes + charBytes > maxBytes) { + break + } + bytes += charBytes + i++ + } + return str.slice(0, i) + } + + /** + * Slice a string to get approximately the last N bytes (UTF-8). + * + * @private + */ + private sliceByBytesFromEnd(str: string, maxBytes: number): string { + let bytes = 0 + let i = str.length - 1 + while (i >= 0 && bytes < maxBytes) { + const charBytes = Buffer.byteLength(str[i], "utf8") + if (bytes + charBytes > maxBytes) { + break + } + bytes += charBytes + i-- + } + return str.slice(i + 1) + } + + /** + * Spill buffered content to disk and switch to streaming mode. + * + * This is called automatically when the buffer exceeds the preview threshold. + * Creates the storage directory if it doesn't exist, writes the current buffer + * to the artifact file, and prepares for streaming subsequent output. + * + * @private + */ + private spillToDisk(): void { + // Ensure directory exists + const dir = path.dirname(this.artifactPath) + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }) + } + + this.writeStream = fs.createWriteStream(this.artifactPath) + + // Write ALL pending chunks to disk for lossless storage. + // This ensures no content is lost, even if the preview buffers have dropped middle content. + for (const chunk of this.pendingChunks) { + this.writeStream.write(chunk) + } + + // Clear pending chunks to free memory - subsequent writes go directly to disk + this.pendingChunks = [] + + this.spilledToDisk = true + } + + /** + * Finalize the interceptor and return the persisted output result. + * + * Closes any open file streams and waits for them to fully flush before returning. + * This ensures the artifact file is completely written and ready for reading. + * + * Returns a summary object containing: + * - A preview of the output (head + [omitted indicator] + tail) + * - The total byte count of all output + * - The path to the full output file (if truncated) + * - A flag indicating whether the output was truncated + * + * @returns The persisted command output summary + * + * @example + * ```typescript + * const result = await interceptor.finalize(); + * console.log(`Preview: ${result.preview}`); + * console.log(`Total bytes: ${result.totalBytes}`); + * if (result.truncated) { + * console.log(`Full output at: ${result.artifactPath}`); + * } + * ``` + */ + async finalize(): Promise { + // Close write stream if open and wait for it to fully flush. + // This ensures the artifact is completely written before we advertise the artifact_id. + if (this.writeStream) { + await new Promise((resolve, reject) => { + this.writeStream!.end(() => resolve()) + this.writeStream!.on("error", reject) + }) + } + + // Prepare preview: head + [omission indicator] + tail + let preview: string + if (this.omittedBytes > 0) { + const omissionIndicator = `\n[...${this.omittedBytes} bytes omitted...]\n` + preview = this.headBuffer + omissionIndicator + this.tailBuffer + } else { + // No truncation, just combine head and tail (or head alone if tail is empty) + preview = this.headBuffer + this.tailBuffer + } + + return { + preview, + totalBytes: this.totalBytes, + artifactPath: this.spilledToDisk ? this.artifactPath : null, + truncated: this.spilledToDisk, + } + } + + /** + * Get the current buffer content for UI display. + * + * Returns the combined head + tail content for real-time UI updates. + * Note: Does not include the omission indicator to avoid flickering during streaming. + * + * @returns The current buffer content as a string + */ + getBufferForUI(): string { + // For UI, return combined head + tail without omission indicator + // This provides a smoother streaming experience + return this.headBuffer + this.tailBuffer + } + + /** + * Get the artifact file path for this command execution. + * + * Returns the path where the full output would be/is stored on disk. + * The file may not exist if output hasn't exceeded the preview threshold. + * + * @returns The absolute path to the artifact file + */ + getArtifactPath(): string { + return this.artifactPath + } + + /** + * Check if the output has been spilled to disk. + * + * @returns `true` if output exceeded threshold and was written to disk + */ + hasSpilledToDisk(): boolean { + return this.spilledToDisk + } + + /** + * Remove all command output artifact files from a directory. + * + * Deletes all files matching the pattern `cmd-*.txt` in the specified directory. + * This is typically called when a task is cleaned up or reset. + * + * @param storageDir - The directory containing artifact files to clean + * + * @example + * ```typescript + * await OutputInterceptor.cleanup('/path/to/task/command-output'); + * ``` + */ + static async cleanup(storageDir: string): Promise { + try { + const files = await fs.promises.readdir(storageDir) + for (const file of files) { + if (file.startsWith("cmd-")) { + await fs.promises.unlink(path.join(storageDir, file)).catch(() => {}) + } + } + } catch { + // Directory doesn't exist, nothing to clean + } + } + + /** + * Remove artifact files that are NOT in the provided set of execution IDs. + * + * This is used for selective cleanup, preserving artifacts that are still + * referenced in the conversation history while removing orphaned files. + * + * @param storageDir - The directory containing artifact files + * @param executionIds - Set of execution IDs to preserve (files NOT in this set are deleted) + * + * @example + * ```typescript + * // Keep only artifacts for executions 123 and 456 + * const keepIds = new Set(['123', '456']); + * await OutputInterceptor.cleanupByIds('/path/to/command-output', keepIds); + * ``` + */ + static async cleanupByIds(storageDir: string, executionIds: Set): Promise { + try { + const files = await fs.promises.readdir(storageDir) + for (const file of files) { + const match = file.match(/^cmd-(\d+)\.txt$/) + if (match && !executionIds.has(match[1])) { + await fs.promises.unlink(path.join(storageDir, file)).catch(() => {}) + } + } + } catch { + // Directory doesn't exist, nothing to clean + } + } +} diff --git a/src/integrations/terminal/__tests__/ExecaTerminal.spec.ts b/src/integrations/terminal/__tests__/ExecaTerminal.spec.ts index ec5fc1e0dd3..0b202f4e048 100644 --- a/src/integrations/terminal/__tests__/ExecaTerminal.spec.ts +++ b/src/integrations/terminal/__tests__/ExecaTerminal.spec.ts @@ -15,7 +15,9 @@ describe("ExecaTerminal", () => { const callbacks: RooTerminalCallbacks = { onLine: vi.fn(), - onCompleted: (output) => (result = output), + onCompleted: (output) => { + result = output + }, onShellExecutionStarted: vi.fn(), onShellExecutionComplete: vi.fn(), } diff --git a/src/integrations/terminal/__tests__/OutputInterceptor.test.ts b/src/integrations/terminal/__tests__/OutputInterceptor.test.ts new file mode 100644 index 00000000000..ed308cff136 --- /dev/null +++ b/src/integrations/terminal/__tests__/OutputInterceptor.test.ts @@ -0,0 +1,532 @@ +import * as fs from "fs" +import * as path from "path" +import { vi, describe, it, expect, beforeEach, afterEach } from "vitest" + +import { OutputInterceptor } from "../OutputInterceptor" +import { TerminalOutputPreviewSize } from "@roo-code/types" + +// Mock filesystem operations +vi.mock("fs", () => ({ + default: { + existsSync: vi.fn(), + mkdirSync: vi.fn(), + createWriteStream: vi.fn(), + promises: { + readdir: vi.fn(), + unlink: vi.fn(), + }, + }, + existsSync: vi.fn(), + mkdirSync: vi.fn(), + createWriteStream: vi.fn(), + promises: { + readdir: vi.fn(), + unlink: vi.fn(), + }, +})) + +describe("OutputInterceptor", () => { + let mockWriteStream: any + let storageDir: string + + beforeEach(() => { + vi.clearAllMocks() + + storageDir = path.normalize("/tmp/test-storage") + + // Setup mock write stream with callback support for end() + mockWriteStream = { + write: vi.fn(), + end: vi.fn((callback?: () => void) => { + // Immediately call the callback to simulate stream flush completing + if (callback) callback() + }), + on: vi.fn(), + } + + vi.mocked(fs.existsSync).mockReturnValue(true) + vi.mocked(fs.createWriteStream).mockReturnValue(mockWriteStream as any) + }) + + afterEach(() => { + vi.restoreAllMocks() + }) + + describe("Buffering behavior", () => { + it("should keep small output in memory without spilling to disk", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "echo test", + storageDir, + previewSize: "small", // 5KB + }) + + const smallOutput = "Hello World\n" + interceptor.write(smallOutput) + + expect(interceptor.hasSpilledToDisk()).toBe(false) + expect(fs.createWriteStream).not.toHaveBeenCalled() + + const result = await interceptor.finalize() + expect(result.preview).toBe(smallOutput) + expect(result.truncated).toBe(false) + expect(result.artifactPath).toBe(null) + expect(result.totalBytes).toBe(Buffer.byteLength(smallOutput, "utf8")) + }) + + it("should spill to disk when output exceeds threshold", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "echo test", + storageDir, + previewSize: "small", // 5KB = 5120 bytes + }) + + // Write enough data to exceed 5KB threshold + const chunk = "x".repeat(2 * 1024) // 2KB chunk + interceptor.write(chunk) // 2KB - should stay in memory + expect(interceptor.hasSpilledToDisk()).toBe(false) + + interceptor.write(chunk) // 4KB - should stay in memory + expect(interceptor.hasSpilledToDisk()).toBe(false) + + interceptor.write(chunk) // 6KB - should trigger spill + expect(interceptor.hasSpilledToDisk()).toBe(true) + expect(fs.createWriteStream).toHaveBeenCalledWith(path.join(storageDir, "cmd-12345.txt")) + expect(mockWriteStream.write).toHaveBeenCalled() + }) + + it("should truncate preview after spilling to disk using head/tail split", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "echo test", + storageDir, + previewSize: "small", // 5KB + }) + + // Write data that exceeds threshold + const chunk = "x".repeat(6000) + interceptor.write(chunk) + + expect(interceptor.hasSpilledToDisk()).toBe(true) + + const result = await interceptor.finalize() + expect(result.truncated).toBe(true) + expect(result.artifactPath).toBe(path.join(storageDir, "cmd-12345.txt")) + // Preview is head (1024) + omission indicator + tail (1024) + // The omission indicator adds some extra bytes + expect(result.preview).toContain("[...") + expect(result.preview).toContain("bytes omitted...]") + }) + + it("should write subsequent chunks directly to disk after spilling", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "echo test", + storageDir, + previewSize: "small", + }) + + // Trigger spill (must exceed 5KB = 5120 bytes) + const largeChunk = "x".repeat(6000) + interceptor.write(largeChunk) + expect(interceptor.hasSpilledToDisk()).toBe(true) + + // Clear mock to track next write + mockWriteStream.write.mockClear() + + // Write another chunk - should go directly to disk + const nextChunk = "y".repeat(1000) + interceptor.write(nextChunk) + + expect(mockWriteStream.write).toHaveBeenCalledWith(nextChunk) + }) + }) + + describe("Threshold settings", () => { + it("should handle small (5KB) threshold correctly", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + // Write exactly 5KB + interceptor.write("x".repeat(5 * 1024)) + expect(interceptor.hasSpilledToDisk()).toBe(false) + + // Write more to exceed 5KB + interceptor.write("x") + expect(interceptor.hasSpilledToDisk()).toBe(true) + }) + + it("should handle medium (10KB) threshold correctly", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "medium", + }) + + // Write exactly 10KB + interceptor.write("x".repeat(10 * 1024)) + expect(interceptor.hasSpilledToDisk()).toBe(false) + + // Write more to exceed 10KB + interceptor.write("x") + expect(interceptor.hasSpilledToDisk()).toBe(true) + }) + + it("should handle large (20KB) threshold correctly", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "large", + }) + + // Write exactly 20KB + interceptor.write("x".repeat(20 * 1024)) + expect(interceptor.hasSpilledToDisk()).toBe(false) + + // Write more to exceed 20KB + interceptor.write("x") + expect(interceptor.hasSpilledToDisk()).toBe(true) + }) + }) + + describe("Artifact creation", () => { + it("should create directory if it doesn't exist", () => { + vi.mocked(fs.existsSync).mockReturnValue(false) + + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + // Trigger spill (must exceed 5KB = 5120 bytes) + interceptor.write("x".repeat(6000)) + + expect(fs.mkdirSync).toHaveBeenCalledWith(storageDir, { recursive: true }) + }) + + it("should create artifact file with correct naming pattern", () => { + const executionId = "1706119234567" + const interceptor = new OutputInterceptor({ + executionId, + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + // Trigger spill (must exceed 5KB = 5120 bytes) + interceptor.write("x".repeat(6000)) + + expect(fs.createWriteStream).toHaveBeenCalledWith(path.join(storageDir, `cmd-${executionId}.txt`)) + }) + + it("should write head and tail buffers to artifact when spilling", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB = 5120 bytes, so head=2560, tail=2560 + }) + + const fullOutput = "x".repeat(10000) + interceptor.write(fullOutput) + + // The write stream should receive the head buffer content first + // (spillToDisk writes head + tail that existed at spill time) + expect(mockWriteStream.write).toHaveBeenCalled() + // Verify that we're writing to disk + expect(interceptor.hasSpilledToDisk()).toBe(true) + }) + + it("should get artifact path from getArtifactPath() method", () => { + const executionId = "12345" + const interceptor = new OutputInterceptor({ + executionId, + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + const expectedPath = path.join(storageDir, `cmd-${executionId}.txt`) + expect(interceptor.getArtifactPath()).toBe(expectedPath) + }) + }) + + describe("finalize() method", () => { + it("should return preview output for small commands", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "echo hello", + storageDir, + previewSize: "small", + }) + + const output = "Hello World\n" + interceptor.write(output) + + const result = await interceptor.finalize() + + expect(result.preview).toBe(output) + expect(result.totalBytes).toBe(Buffer.byteLength(output, "utf8")) + expect(result.artifactPath).toBe(null) + expect(result.truncated).toBe(false) + }) + + it("should return PersistedCommandOutput for large commands with head/tail preview", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB = 5120, head=2560, tail=2560 + }) + + const largeOutput = "x".repeat(10000) + interceptor.write(largeOutput) + + const result = await interceptor.finalize() + + expect(result.truncated).toBe(true) + expect(result.artifactPath).toBe(path.join(storageDir, "cmd-12345.txt")) + expect(result.totalBytes).toBe(Buffer.byteLength(largeOutput, "utf8")) + // Preview should contain head + omission indicator + tail + expect(result.preview).toContain("[...") + expect(result.preview).toContain("bytes omitted...]") + }) + + it("should close write stream when finalizing", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + // Trigger spill (must exceed 5KB = 5120 bytes) + interceptor.write("x".repeat(6000)) + await interceptor.finalize() + + expect(mockWriteStream.end).toHaveBeenCalled() + }) + + it("should include correct metadata (artifactId, size, truncated flag)", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + // Must exceed 5KB = 5120 bytes to trigger truncation + const output = "x".repeat(6000) + interceptor.write(output) + + const result = await interceptor.finalize() + + expect(result).toHaveProperty("preview") + expect(result).toHaveProperty("totalBytes", 6000) + expect(result).toHaveProperty("artifactPath") + expect(result).toHaveProperty("truncated", true) + expect(result.artifactPath).toMatch(/cmd-12345\.txt$/) + }) + }) + + describe("Cleanup methods", () => { + it("should clean up all artifacts in directory", async () => { + const mockFiles = ["cmd-12345.txt", "cmd-67890.txt", "other-file.txt", "cmd-11111.txt"] + vi.mocked(fs.promises.readdir).mockResolvedValue(mockFiles as any) + vi.mocked(fs.promises.unlink).mockResolvedValue(undefined) + + await OutputInterceptor.cleanup(storageDir) + + expect(fs.promises.readdir).toHaveBeenCalledWith(storageDir) + expect(fs.promises.unlink).toHaveBeenCalledTimes(3) + expect(fs.promises.unlink).toHaveBeenCalledWith(path.join(storageDir, "cmd-12345.txt")) + expect(fs.promises.unlink).toHaveBeenCalledWith(path.join(storageDir, "cmd-67890.txt")) + expect(fs.promises.unlink).toHaveBeenCalledWith(path.join(storageDir, "cmd-11111.txt")) + expect(fs.promises.unlink).not.toHaveBeenCalledWith(path.join(storageDir, "other-file.txt")) + }) + + it("should handle cleanup when directory doesn't exist", async () => { + vi.mocked(fs.promises.readdir).mockRejectedValue(new Error("ENOENT")) + + // Should not throw + await expect(OutputInterceptor.cleanup(storageDir)).resolves.toBeUndefined() + }) + + it("should clean up specific artifacts by executionIds", async () => { + const mockFiles = ["cmd-12345.txt", "cmd-67890.txt", "cmd-11111.txt"] + vi.mocked(fs.promises.readdir).mockResolvedValue(mockFiles as any) + vi.mocked(fs.promises.unlink).mockResolvedValue(undefined) + + // Keep 12345 and 67890, delete 11111 + const keepIds = new Set(["12345", "67890"]) + await OutputInterceptor.cleanupByIds(storageDir, keepIds) + + expect(fs.promises.unlink).toHaveBeenCalledTimes(1) + expect(fs.promises.unlink).toHaveBeenCalledWith(path.join(storageDir, "cmd-11111.txt")) + expect(fs.promises.unlink).not.toHaveBeenCalledWith(path.join(storageDir, "cmd-12345.txt")) + expect(fs.promises.unlink).not.toHaveBeenCalledWith(path.join(storageDir, "cmd-67890.txt")) + }) + + it("should handle unlink errors gracefully", async () => { + const mockFiles = ["cmd-12345.txt", "cmd-67890.txt"] + vi.mocked(fs.promises.readdir).mockResolvedValue(mockFiles as any) + vi.mocked(fs.promises.unlink).mockRejectedValue(new Error("Permission denied")) + + // Should not throw even if unlink fails + await expect(OutputInterceptor.cleanup(storageDir)).resolves.toBeUndefined() + }) + }) + + describe("getBufferForUI() method", () => { + it("should return current buffer for UI updates", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", + }) + + const output = "Hello World" + interceptor.write(output) + + expect(interceptor.getBufferForUI()).toBe(output) + }) + + it("should return head + tail buffer after spilling to disk", () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB = 5120, head=2560, tail=2560 + }) + + // Trigger spill + const largeOutput = "x".repeat(10000) + interceptor.write(largeOutput) + + const buffer = interceptor.getBufferForUI() + // Buffer for UI is head + tail (no omission indicator for smooth streaming) + expect(Buffer.byteLength(buffer, "utf8")).toBeLessThanOrEqual(5120) + }) + }) + + describe("Head/Tail split behavior", () => { + it("should preserve first 50% and last 50% of output", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB = 5120, head=2560, tail=2560 + }) + + // Create identifiable head and tail content + const headContent = "HEAD".repeat(750) // 3000 bytes + const middleContent = "M".repeat(6000) // 6000 bytes (will be omitted) + const tailContent = "TAIL".repeat(750) // 3000 bytes + + interceptor.write(headContent) + interceptor.write(middleContent) + interceptor.write(tailContent) + + const result = await interceptor.finalize() + + // Should start with HEAD content (first 2560 bytes of head budget) + expect(result.preview.startsWith("HEAD")).toBe(true) + // Should end with TAIL content (last 2560 bytes) + expect(result.preview.endsWith("TAIL")).toBe(true) + // Should have omission indicator + expect(result.preview).toContain("[...") + expect(result.preview).toContain("bytes omitted...]") + }) + + it("should not add omission indicator when output fits in budget", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB + }) + + const smallOutput = "Hello World\n" + interceptor.write(smallOutput) + + const result = await interceptor.finalize() + + // No omission indicator for small output + expect(result.preview).toBe(smallOutput) + expect(result.preview).not.toContain("[...") + }) + + it("should handle output that exactly fills head budget", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB = 5120, head=2560 + }) + + // Write exactly 2560 bytes (head budget) + const exactHeadContent = "x".repeat(2560) + interceptor.write(exactHeadContent) + + const result = await interceptor.finalize() + + // Should fit entirely in head, no truncation + expect(result.preview).toBe(exactHeadContent) + expect(result.truncated).toBe(false) + }) + + it("should split single large chunk across head and tail", async () => { + const interceptor = new OutputInterceptor({ + executionId: "12345", + taskId: "task-1", + command: "test", + storageDir, + previewSize: "small", // 5KB = 5120, head=2560, tail=2560 + }) + + // Write a single chunk larger than preview budget + // First 2560 chars go to head, last 2560 chars go to tail + const content = "A".repeat(2560) + "B".repeat(4000) + "C".repeat(2560) + interceptor.write(content) + + const result = await interceptor.finalize() + + // Head should have A's + expect(result.preview.startsWith("A")).toBe(true) + // Tail should have C's + expect(result.preview.endsWith("C")).toBe(true) + // Should have omission indicator + expect(result.preview).toContain("[...") + }) + }) +}) diff --git a/src/integrations/terminal/types.ts b/src/integrations/terminal/types.ts index d42c7fa8a51..a0c5cde5d50 100644 --- a/src/integrations/terminal/types.ts +++ b/src/integrations/terminal/types.ts @@ -22,7 +22,7 @@ export interface RooTerminal { export interface RooTerminalCallbacks { onLine: (line: string, process: RooTerminalProcess) => void - onCompleted: (output: string | undefined, process: RooTerminalProcess) => void + onCompleted: (output: string | undefined, process: RooTerminalProcess) => void | Promise onShellExecutionStarted: (pid: number | undefined, process: RooTerminalProcess) => void onShellExecutionComplete: (details: ExitCodeDetails, process: RooTerminalProcess) => void onNoShellIntegration?: (message: string, process: RooTerminalProcess) => void diff --git a/src/package.json b/src/package.json index f059009172a..6c473cbbadc 100644 --- a/src/package.json +++ b/src/package.json @@ -540,6 +540,7 @@ "@types/diff": "^5.2.1", "@types/diff-match-patch": "^1.0.36", "@types/glob": "^8.1.0", + "@types/json-stream-stringify": "^2.0.4", "@types/lodash.debounce": "^4.0.9", "@types/mocha": "^10.0.10", "@types/node": "20.x", diff --git a/src/shared/tools.ts b/src/shared/tools.ts index 66b058fceb5..dc1615c0654 100644 --- a/src/shared/tools.ts +++ b/src/shared/tools.ts @@ -72,6 +72,10 @@ export const toolParamNames = [ "old_string", // search_replace and edit_file parameter "new_string", // search_replace and edit_file parameter "expected_replacements", // edit_file parameter for multiple occurrences + "artifact_id", // read_command_output parameter + "search", // read_command_output parameter for grep-like search + "offset", // read_command_output parameter for pagination + "limit", // read_command_output parameter for max bytes to return ] as const export type ToolParamName = (typeof toolParamNames)[number] @@ -83,6 +87,7 @@ export type ToolParamName = (typeof toolParamNames)[number] export type NativeToolArgs = { access_mcp_resource: { server_name: string; uri: string } read_file: { files: FileEntry[] } + read_command_output: { artifact_id: string; search?: string; offset?: number; limit?: number } attempt_completion: { result: string } execute_command: { command: string; cwd?: string } apply_diff: { path: string; diff: string } @@ -242,6 +247,7 @@ export type ToolGroupConfig = { export const TOOL_DISPLAY_NAMES: Record = { execute_command: "run commands", read_file: "read files", + read_command_output: "read command output", fetch_instructions: "fetch instructions", write_to_file: "write files", apply_diff: "apply changes", @@ -278,7 +284,7 @@ export const TOOL_GROUPS: Record = { tools: ["browser_action"], }, command: { - tools: ["execute_command"], + tools: ["execute_command", "read_command_output"], }, mcp: { tools: ["use_mcp_tool", "access_mcp_resource"], diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 3338f9a4bec..6a6d5c3f6df 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -1464,6 +1464,51 @@ export const ChatRowContent = ({ ) } + case "readCommandOutput": { + const formatBytes = (bytes: number) => { + if (bytes < 1024) return `${bytes} B` + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB` + return `${(bytes / (1024 * 1024)).toFixed(1)} MB` + } + + // Determine if this is a search operation + const isSearch = sayTool.searchPattern !== undefined + + let infoText = "" + if (isSearch) { + // Search mode: show pattern and match count + const matchText = + sayTool.matchCount !== undefined + ? sayTool.matchCount === 1 + ? "1 match" + : `${sayTool.matchCount} matches` + : "" + infoText = `search: "${sayTool.searchPattern}"${matchText ? ` • ${matchText}` : ""}` + } else if ( + sayTool.readStart !== undefined && + sayTool.readEnd !== undefined && + sayTool.totalBytes !== undefined + ) { + // Read mode: show byte range + infoText = `${formatBytes(sayTool.readStart)} - ${formatBytes(sayTool.readEnd)} of ${formatBytes(sayTool.totalBytes)}` + } else if (sayTool.totalBytes !== undefined) { + infoText = formatBytes(sayTool.totalBytes) + } + + return ( +
+ + {t("chat:readCommandOutput.title")} + {infoText && ( + + ({infoText}) + + )} +
+ ) + } default: return null } diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index bd58db79e6d..b84a9dd3a3c 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -179,8 +179,7 @@ const SettingsView = forwardRef(({ onDone, t ttsSpeed, soundVolume, telemetrySetting, - terminalOutputLineLimit, - terminalOutputCharacterLimit, + terminalOutputPreviewSize, terminalShellIntegrationTimeout, terminalShellIntegrationDisabled, // Added from upstream terminalCommandDelay, @@ -196,7 +195,6 @@ const SettingsView = forwardRef(({ onDone, t maxReadFileLine, maxImageFileSize, maxTotalImageSize, - terminalCompressProgressBar, maxConcurrentFileReads, customSupportPrompts, profileThresholds, @@ -391,8 +389,6 @@ const SettingsView = forwardRef(({ onDone, t remoteBrowserEnabled: remoteBrowserEnabled ?? false, writeDelayMs, screenshotQuality: screenshotQuality ?? 75, - terminalOutputLineLimit: terminalOutputLineLimit ?? 500, - terminalOutputCharacterLimit: terminalOutputCharacterLimit ?? 50_000, terminalShellIntegrationTimeout: terminalShellIntegrationTimeout ?? 30_000, terminalShellIntegrationDisabled, terminalCommandDelay, @@ -401,7 +397,7 @@ const SettingsView = forwardRef(({ onDone, t terminalZshOhMy, terminalZshP10k, terminalZdotdir, - terminalCompressProgressBar, + terminalOutputPreviewSize: terminalOutputPreviewSize ?? "medium", mcpEnabled, maxOpenTabsContext: Math.min(Math.max(0, maxOpenTabsContext ?? 20), 500), maxWorkspaceFiles: Math.min(Math.max(0, maxWorkspaceFiles ?? 200), 500), @@ -872,8 +868,7 @@ const SettingsView = forwardRef(({ onDone, t {/* Terminal Section */} {renderTab === "terminal" && ( (({ onDone, t terminalZshOhMy={terminalZshOhMy} terminalZshP10k={terminalZshP10k} terminalZdotdir={terminalZdotdir} - terminalCompressProgressBar={terminalCompressProgressBar} setCachedStateField={setCachedStateField} /> )} diff --git a/webview-ui/src/components/settings/TerminalSettings.tsx b/webview-ui/src/components/settings/TerminalSettings.tsx index a8e36bd3c10..07f062cc018 100644 --- a/webview-ui/src/components/settings/TerminalSettings.tsx +++ b/webview-ui/src/components/settings/TerminalSettings.tsx @@ -6,10 +6,10 @@ import { Trans } from "react-i18next" import { buildDocLink } from "@src/utils/docLinks" import { useEvent, useMount } from "react-use" -import { type ExtensionMessage } from "@roo-code/types" +import { type ExtensionMessage, type TerminalOutputPreviewSize } from "@roo-code/types" import { cn } from "@/lib/utils" -import { Slider } from "@/components/ui" +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider } from "@/components/ui" import { SetCachedStateField } from "./types" import { SectionHeader } from "./SectionHeader" @@ -17,8 +17,7 @@ import { Section } from "./Section" import { SearchableSetting } from "./SearchableSetting" type TerminalSettingsProps = HTMLAttributes & { - terminalOutputLineLimit?: number - terminalOutputCharacterLimit?: number + terminalOutputPreviewSize?: TerminalOutputPreviewSize terminalShellIntegrationTimeout?: number terminalShellIntegrationDisabled?: boolean terminalCommandDelay?: number @@ -27,10 +26,8 @@ type TerminalSettingsProps = HTMLAttributes & { terminalZshOhMy?: boolean terminalZshP10k?: boolean terminalZdotdir?: boolean - terminalCompressProgressBar?: boolean setCachedStateField: SetCachedStateField< - | "terminalOutputLineLimit" - | "terminalOutputCharacterLimit" + | "terminalOutputPreviewSize" | "terminalShellIntegrationTimeout" | "terminalShellIntegrationDisabled" | "terminalCommandDelay" @@ -39,13 +36,11 @@ type TerminalSettingsProps = HTMLAttributes & { | "terminalZshOhMy" | "terminalZshP10k" | "terminalZdotdir" - | "terminalCompressProgressBar" > } export const TerminalSettings = ({ - terminalOutputLineLimit, - terminalOutputCharacterLimit, + terminalOutputPreviewSize, terminalShellIntegrationTimeout, terminalShellIntegrationDisabled, terminalCommandDelay, @@ -54,7 +49,6 @@ export const TerminalSettings = ({ terminalZshOhMy, terminalZshP10k, terminalZdotdir, - terminalCompressProgressBar, setCachedStateField, className, ...props @@ -100,92 +94,34 @@ export const TerminalSettings = ({
+ label={t("settings:terminal.outputPreviewSize.label")}> -
- setCachedStateField("terminalOutputLineLimit", value)} - data-testid="terminal-output-limit-slider" - /> - {terminalOutputLineLimit ?? 500} -
-
- - - {" "} - - -
-
- - -
- - setCachedStateField("terminalOutputCharacterLimit", value) - } - data-testid="terminal-output-character-limit-slider" - /> - {terminalOutputCharacterLimit ?? 50000} -
-
- - - {" "} - - -
-
- - - setCachedStateField("terminalCompressProgressBar", e.target.checked) - } - data-testid="terminal-compress-progress-bar-checkbox"> - {t("settings:terminal.compressProgressBar.label")} - +
- - - {" "} - - + {t("settings:terminal.outputPreviewSize.description")}
diff --git a/webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx b/webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx index ddaf6a7b996..89be961625b 100644 --- a/webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx +++ b/webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx @@ -193,7 +193,6 @@ describe("SettingsView - Change Detection Fix", () => { maxReadFileLine: -1, maxImageFileSize: 5, maxTotalImageSize: 20, - terminalCompressProgressBar: false, maxConcurrentFileReads: 5, customCondensingPrompt: "", customSupportPrompts: {}, diff --git a/webview-ui/src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx b/webview-ui/src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx index 4a1733c376d..996dad86399 100644 --- a/webview-ui/src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx +++ b/webview-ui/src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx @@ -198,7 +198,6 @@ describe("SettingsView - Unsaved Changes Detection", () => { maxReadFileLine: -1, maxImageFileSize: 5, maxTotalImageSize: 20, - terminalCompressProgressBar: false, maxConcurrentFileReads: 5, customCondensingPrompt: "", customSupportPrompts: {}, diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index 26b3851c1be..d37f09bbc51 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -96,10 +96,8 @@ export interface ExtensionStateContextType extends ExtensionState { setWriteDelayMs: (value: number) => void screenshotQuality?: number setScreenshotQuality: (value: number) => void - terminalOutputLineLimit?: number - setTerminalOutputLineLimit: (value: number) => void - terminalOutputCharacterLimit?: number - setTerminalOutputCharacterLimit: (value: number) => void + terminalOutputPreviewSize?: "small" | "medium" | "large" + setTerminalOutputPreviewSize: (value: "small" | "medium" | "large") => void mcpEnabled: boolean setMcpEnabled: (value: boolean) => void enableMcpServerCreation: boolean @@ -140,8 +138,6 @@ export interface ExtensionStateContextType extends ExtensionState { pinnedApiConfigs?: Record setPinnedApiConfigs: (value: Record) => void togglePinnedApiConfig: (configName: string) => void - terminalCompressProgressBar?: boolean - setTerminalCompressProgressBar: (value: boolean) => void setHistoryPreviewCollapsed: (value: boolean) => void setReasoningBlockCollapsed: (value: boolean) => void enterBehavior?: "send" | "newline" @@ -213,8 +209,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode writeDelayMs: 1000, browserViewportSize: "900x600", screenshotQuality: 75, - terminalOutputLineLimit: 500, - terminalOutputCharacterLimit: 50000, terminalShellIntegrationTimeout: 4000, mcpEnabled: true, enableMcpServerCreation: false, @@ -247,7 +241,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode maxConcurrentFileReads: 5, // Default concurrent file reads terminalZshP10k: false, // Default Powerlevel10k integration setting terminalZdotdir: false, // Default ZDOTDIR handling setting - terminalCompressProgressBar: true, // Default to compress progress bar output historyPreviewCollapsed: false, // Initialize the new state (default to expanded) reasoningBlockCollapsed: true, // Default to collapsed enterBehavior: "send", // Default: Enter sends, Shift+Enter creates newline @@ -544,10 +537,8 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode setState((prevState) => ({ ...prevState, browserViewportSize: value })), setWriteDelayMs: (value) => setState((prevState) => ({ ...prevState, writeDelayMs: value })), setScreenshotQuality: (value) => setState((prevState) => ({ ...prevState, screenshotQuality: value })), - setTerminalOutputLineLimit: (value) => - setState((prevState) => ({ ...prevState, terminalOutputLineLimit: value })), - setTerminalOutputCharacterLimit: (value) => - setState((prevState) => ({ ...prevState, terminalOutputCharacterLimit: value })), + setTerminalOutputPreviewSize: (value) => + setState((prevState) => ({ ...prevState, terminalOutputPreviewSize: value })), setTerminalShellIntegrationTimeout: (value) => setState((prevState) => ({ ...prevState, terminalShellIntegrationTimeout: value })), setTerminalShellIntegrationDisabled: (value) => @@ -581,8 +572,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode setMaxImageFileSize: (value) => setState((prevState) => ({ ...prevState, maxImageFileSize: value })), setMaxTotalImageSize: (value) => setState((prevState) => ({ ...prevState, maxTotalImageSize: value })), setPinnedApiConfigs: (value) => setState((prevState) => ({ ...prevState, pinnedApiConfigs: value })), - setTerminalCompressProgressBar: (value) => - setState((prevState) => ({ ...prevState, terminalCompressProgressBar: value })), togglePinnedApiConfig: (configId) => setState((prevState) => { const currentPinned = prevState.pinnedApiConfigs || {} diff --git a/webview-ui/src/i18n/locales/ca/chat.json b/webview-ui/src/i18n/locales/ca/chat.json index e8ffafde5ea..078150379a5 100644 --- a/webview-ui/src/i18n/locales/ca/chat.json +++ b/webview-ui/src/i18n/locales/ca/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} servidors MCP", "messageTemplate": "Tens {{tools}} habilitades via {{servers}}. Un nombre tant alt pot confondre el model i portar a errors. Intenta mantenir-lo per sota de {{threshold}}.", "openMcpSettings": "Obrir configuració de MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/ca/settings.json b/webview-ui/src/i18n/locales/ca/settings.json index 1509137a902..dfe769e6ea1 100644 --- a/webview-ui/src/i18n/locales/ca/settings.json +++ b/webview-ui/src/i18n/locales/ca/settings.json @@ -724,6 +724,15 @@ "label": "Límit de caràcters del terminal", "description": "Anul·la el límit de línies per evitar problemes de memòria imposant un límit dur a la mida de sortida. Si se supera, manté l'inici i el final i mostra un marcador a Roo on s'ha omès el contingut. <0>Aprèn-ne més" }, + "outputPreviewSize": { + "label": "Mida de la previsualització de la sortida d'ordres", + "description": "Controla quanta sortida d'ordres veu Roo directament. La sortida completa sempre es desa i és accessible quan calgui.", + "options": { + "small": "Petita (5KB)", + "medium": "Mitjana (10KB)", + "large": "Gran (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Temps d'espera d'integració del shell del terminal", "description": "Quant de temps esperar la integració del shell de VS Code abans d'executar comandes. Augmenta si el teu shell s'inicia lentament o veus errors 'Integració del Shell No Disponible'. <0>Aprèn-ne més" @@ -736,10 +745,6 @@ "label": "Retard de comanda del terminal", "description": "Afegeix una pausa breu després de cada comanda perquè el terminal de VS Code pugui buidar tota la sortida (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Usa només si veus que falta sortida final; altrament deixa a 0. <0>Aprèn-ne més" }, - "compressProgressBar": { - "label": "Comprimeix sortida de barra de progrés", - "description": "Col·lapsa barres de progrés/spinners perquè només es mantingui l'estat final (estalvia tokens). <0>Aprèn-ne més" - }, "powershellCounter": { "label": "Activa solució de comptador de PowerShell", "description": "Activa quan falta o es duplica la sortida de PowerShell; afegeix un petit comptador a cada comanda per estabilitzar la sortida. Mantén desactivat si la sortida ja es veu correcta. <0>Aprèn-ne més" diff --git a/webview-ui/src/i18n/locales/de/chat.json b/webview-ui/src/i18n/locales/de/chat.json index cda292c3056..d123a1b236f 100644 --- a/webview-ui/src/i18n/locales/de/chat.json +++ b/webview-ui/src/i18n/locales/de/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} MCP-Server", "messageTemplate": "Du hast {{tools}} über {{servers}} aktiviert. Eine so hohe Anzahl kann das Modell verwirren und zu Fehlern führen. Versuche, es unter {{threshold}} zu halten.", "openMcpSettings": "MCP-Einstellungen öffnen" + }, + "readCommandOutput": { + "title": "Roo las Befehlsausgabe" } } diff --git a/webview-ui/src/i18n/locales/de/settings.json b/webview-ui/src/i18n/locales/de/settings.json index bc275a64e50..c49fac0f3bc 100644 --- a/webview-ui/src/i18n/locales/de/settings.json +++ b/webview-ui/src/i18n/locales/de/settings.json @@ -724,6 +724,15 @@ "label": "Terminal-Zeichenlimit", "description": "Überschreibt das Zeilenlimit, um Speicherprobleme durch eine harte Obergrenze für die Ausgabegröße zu vermeiden. Bei Überschreitung behält es Anfang und Ende und zeigt Roo einen Platzhalter, wo Inhalt übersprungen wird. <0>Mehr erfahren" }, + "outputPreviewSize": { + "label": "Befehlsausgabe-Vorschaugröße", + "description": "Steuert, wie viel Befehlsausgabe Roo direkt sieht. Die vollständige Ausgabe wird immer gespeichert und ist bei Bedarf zugänglich.", + "options": { + "small": "Klein (5KB)", + "medium": "Mittel (10KB)", + "large": "Groß (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Terminal-Shell-Integrations-Timeout", "description": "Wie lange auf VS Code Shell-Integration gewartet wird, bevor Befehle ausgeführt werden. Erhöhe den Wert, wenn deine Shell langsam startet oder du 'Shell-Integration nicht verfügbar'-Fehler siehst. <0>Mehr erfahren" @@ -736,10 +745,6 @@ "label": "Terminal-Befehlsverzögerung", "description": "Fügt nach jedem Befehl eine kurze Pause hinzu, damit das VS Code-Terminal alle Ausgaben leeren kann (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Verwende dies nur, wenn du fehlende Tail-Ausgabe siehst; sonst lass es bei 0. <0>Mehr erfahren" }, - "compressProgressBar": { - "label": "Fortschrittsbalken-Ausgabe komprimieren", - "description": "Klappt Fortschrittsbalken/Spinner zusammen, sodass nur der Endzustand erhalten bleibt (spart Token). <0>Mehr erfahren" - }, "powershellCounter": { "label": "PowerShell-Zähler-Workaround aktivieren", "description": "Schalte dies ein, wenn PowerShell-Ausgabe fehlt oder dupliziert wird; es fügt jedem Befehl einen kleinen Zähler hinzu, um die Ausgabe zu stabilisieren. Lass es ausgeschaltet, wenn die Ausgabe bereits korrekt aussieht. <0>Mehr erfahren" diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index 5bd990fb935..e8a172449b4 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -495,5 +495,8 @@ "serversPart_other": "{{count}} MCP servers", "messageTemplate": "You have {{tools}} enabled via {{servers}}. Such a high number can confuse the model and lead to errors. Try to keep it below {{threshold}}.", "openMcpSettings": "Open MCP Settings" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index 7045ef07d19..63f4056d666 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -733,6 +733,15 @@ "label": "Terminal character limit", "description": "Overrides the line limit to prevent memory issues by enforcing a hard cap on output size. If exceeded, keeps the beginning and end and shows a placeholder to Roo where content is skipped. <0>Learn more" }, + "outputPreviewSize": { + "label": "Command output preview size", + "description": "Controls how much command output Roo sees directly. Full output is always saved and accessible when needed.", + "options": { + "small": "Small (5KB)", + "medium": "Medium (10KB)", + "large": "Large (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Terminal shell integration timeout", "description": "How long to wait for VS Code shell integration before running commands. Raise if your shell starts slowly or you see 'Shell Integration Unavailable' errors. <0>Learn more" @@ -745,10 +754,6 @@ "label": "Terminal command delay", "description": "Adds a short pause after each command so the VS Code terminal can flush all output (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Use only if you see missing tail output; otherwise leave at 0. <0>Learn more" }, - "compressProgressBar": { - "label": "Compress progress bar output", - "description": "Collapses progress bars/spinners so only the final state is kept (saves tokens). <0>Learn more" - }, "powershellCounter": { "label": "Enable PowerShell counter workaround", "description": "Turn this on when PowerShell output is missing or duplicated; it appends a tiny counter to each command to stabilize output. Keep this off if output already looks correct. <0>Learn more" diff --git a/webview-ui/src/i18n/locales/es/chat.json b/webview-ui/src/i18n/locales/es/chat.json index 4c46f61231d..3813e5572e1 100644 --- a/webview-ui/src/i18n/locales/es/chat.json +++ b/webview-ui/src/i18n/locales/es/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} servidores MCP", "messageTemplate": "Tienes {{tools}} habilitadas a través de {{servers}}. Un número tan alto puede confundir al modelo y llevar a errores. Intenta mantenerlo por debajo de {{threshold}}.", "openMcpSettings": "Abrir configuración de MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/es/settings.json b/webview-ui/src/i18n/locales/es/settings.json index 36243b99be0..7115da67951 100644 --- a/webview-ui/src/i18n/locales/es/settings.json +++ b/webview-ui/src/i18n/locales/es/settings.json @@ -724,6 +724,15 @@ "label": "Límite de caracteres del terminal", "description": "Anula el límite de líneas para evitar problemas de memoria imponiendo un límite estricto al tamaño de salida. Si se excede, mantiene el inicio y el final y muestra un marcador a Roo donde se omite el contenido. <0>Más información" }, + "outputPreviewSize": { + "label": "Tamaño de vista previa de salida de comandos", + "description": "Controla cuánta salida de comandos ve Roo directamente. La salida completa siempre se guarda y es accesible cuando sea necesario.", + "options": { + "small": "Pequeño (5KB)", + "medium": "Mediano (10KB)", + "large": "Grande (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Tiempo de espera de integración del shell del terminal", "description": "Cuánto tiempo esperar la integración del shell de VS Code antes de ejecutar comandos. Aumenta si tu shell inicia lentamente o ves errores 'Integración del Shell No Disponible'. <0>Más información" @@ -736,10 +745,6 @@ "label": "Retraso de comando del terminal", "description": "Añade una pausa breve después de cada comando para que el terminal de VS Code pueda vaciar toda la salida (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Usa solo si ves salida final faltante; si no, deja en 0. <0>Más información" }, - "compressProgressBar": { - "label": "Comprimir salida de barra de progreso", - "description": "Colapsa barras de progreso/spinners para que solo se mantenga el estado final (ahorra tokens). <0>Más información" - }, "powershellCounter": { "label": "Activar solución del contador de PowerShell", "description": "Activa cuando falta o se duplica la salida de PowerShell; añade un pequeño contador a cada comando para estabilizar la salida. Mantén desactivado si la salida ya se ve correcta. <0>Más información" diff --git a/webview-ui/src/i18n/locales/fr/chat.json b/webview-ui/src/i18n/locales/fr/chat.json index 0c64efb2168..1640c4f4df1 100644 --- a/webview-ui/src/i18n/locales/fr/chat.json +++ b/webview-ui/src/i18n/locales/fr/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} serveurs MCP", "messageTemplate": "Tu as {{tools}} activés via {{servers}}. Un nombre aussi élevé peut confondre le modèle et entraîner des erreurs. Essaie de le maintenir en dessous de {{threshold}}.", "openMcpSettings": "Ouvrir les paramètres MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/fr/settings.json b/webview-ui/src/i18n/locales/fr/settings.json index 1c28b763077..8cdbc1edb4f 100644 --- a/webview-ui/src/i18n/locales/fr/settings.json +++ b/webview-ui/src/i18n/locales/fr/settings.json @@ -724,6 +724,15 @@ "label": "Limite de caractères du terminal", "description": "Remplace la limite de lignes pour éviter les problèmes de mémoire en imposant un plafond strict sur la taille de sortie. Si dépassé, conserve le début et la fin et affiche un espace réservé à Roo là où le contenu est ignoré. <0>En savoir plus" }, + "outputPreviewSize": { + "label": "Taille de l'aperçu de sortie des commandes", + "description": "Contrôle la quantité de sortie de commande que Roo voit directement. La sortie complète est toujours sauvegardée et accessible en cas de besoin.", + "options": { + "small": "Petite (5KB)", + "medium": "Moyenne (10KB)", + "large": "Grande (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Délai d'attente d'intégration du shell du terminal", "description": "Temps d'attente de l'intégration du shell de VS Code avant d'exécuter des commandes. Augmentez si votre shell démarre lentement ou si vous voyez des erreurs 'Intégration du Shell Indisponible'. <0>En savoir plus" @@ -736,10 +745,6 @@ "label": "Délai de commande du terminal", "description": "Ajoute une courte pause après chaque commande pour que le terminal VS Code puisse vider toute la sortie (bash/zsh : PROMPT_COMMAND sleep ; PowerShell : start-sleep). Utilisez uniquement si vous voyez une sortie de fin manquante ; sinon laissez à 0. <0>En savoir plus" }, - "compressProgressBar": { - "label": "Compresser la sortie de barre de progression", - "description": "Réduit les barres de progression/spinners pour ne conserver que l'état final (économise des jetons). <0>En savoir plus" - }, "powershellCounter": { "label": "Activer la solution de contournement du compteur PowerShell", "description": "Activez lorsque la sortie PowerShell est manquante ou dupliquée ; ajoute un petit compteur à chaque commande pour stabiliser la sortie. Laissez désactivé si la sortie semble déjà correcte. <0>En savoir plus" diff --git a/webview-ui/src/i18n/locales/hi/chat.json b/webview-ui/src/i18n/locales/hi/chat.json index 3f536f4f71e..37abab382bf 100644 --- a/webview-ui/src/i18n/locales/hi/chat.json +++ b/webview-ui/src/i18n/locales/hi/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} MCP सर्वर", "messageTemplate": "आपके पास {{servers}} के माध्यम से {{tools}} सक्षम हैं। इतनी अधिक संख्या मॉडल को भ्रमित कर सकती है और त्रुटियों का कारण बन सकती है। इसे {{threshold}} से नीचे रखने का प्रयास करें।", "openMcpSettings": "MCP सेटिंग्स खोलें" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/hi/settings.json b/webview-ui/src/i18n/locales/hi/settings.json index 4974ff706b4..3f7e0dfa9ab 100644 --- a/webview-ui/src/i18n/locales/hi/settings.json +++ b/webview-ui/src/i18n/locales/hi/settings.json @@ -725,6 +725,15 @@ "label": "टर्मिनल वर्ण सीमा", "description": "मेमोरी समस्याओं को रोकने के लिए आउटपुट आकार पर कठोर सीमा लगाकर लाइन सीमा को ओवरराइड करता है। यदि पार हो जाती है, तो शुरुआत और अंत रखता है और Roo को प्लेसहोल्डर दिखाता है जहां सामग्री छोड़ी गई है। <0>अधिक जानें" }, + "outputPreviewSize": { + "label": "कमांड आउटपुट पूर्वावलोकन आकार", + "description": "नियंत्रित करता है कि Roo कितना कमांड आउटपुट सीधे देखता है। पूर्ण आउटपुट हमेशा सहेजा जाता है और आवश्यकता पड़ने पर सुलभ होता है।", + "options": { + "small": "छोटा (5KB)", + "medium": "मध्यम (10KB)", + "large": "बड़ा (20KB)" + } + }, "shellIntegrationTimeout": { "label": "टर्मिनल शेल एकीकरण टाइमआउट", "description": "कमांड चलाने से पहले VS Code शेल एकीकरण की प्रतीक्षा करने का समय। यदि आपका शेल धीरे शुरू होता है या आप 'Shell Integration Unavailable' त्रुटियां देखते हैं तो बढ़ाएं। <0>अधिक जानें" @@ -737,10 +746,6 @@ "label": "टर्मिनल कमांड विलंब", "description": "प्रत्येक कमांड के बाद छोटा विराम जोड़ता है ताकि VS Code टर्मिनल सभी आउटपुट फ्लश कर सके (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep)। केवल तभी उपयोग करें जब टेल आउटपुट गायब हो; अन्यथा 0 पर छोड़ दें। <0>अधिक जानें" }, - "compressProgressBar": { - "label": "प्रगति बार आउटपुट संपीड़ित करें", - "description": "प्रगति बार/स्पिनर को संक्षिप्त करता है ताकि केवल अंतिम स्थिति रखी जाए (token बचाता है)। <0>अधिक जानें" - }, "powershellCounter": { "label": "PowerShell काउंटर समाधान सक्षम करें", "description": "जब PowerShell आउटपुट गायब हो या डुप्लिकेट हो तो इसे चालू करें; यह आउटपुट को स्थिर करने के लिए प्रत्येक कमांड में एक छोटा काउंटर जोड़ता है। यदि आउटपुट पहले से सही दिखता है तो इसे बंद रखें। <0>अधिक जानें" diff --git a/webview-ui/src/i18n/locales/id/chat.json b/webview-ui/src/i18n/locales/id/chat.json index 89c7d4369b0..72956dc6d8f 100644 --- a/webview-ui/src/i18n/locales/id/chat.json +++ b/webview-ui/src/i18n/locales/id/chat.json @@ -510,5 +510,8 @@ "serversPart_other": "{{count}} server MCP", "messageTemplate": "Anda memiliki {{tools}} diaktifkan melalui {{servers}}. Jumlah yang begitu besar dapat membingungkan model dan menyebabkan kesalahan. Cobalah untuk menjaganya di bawah {{threshold}}.", "openMcpSettings": "Buka Pengaturan MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/id/settings.json b/webview-ui/src/i18n/locales/id/settings.json index 908c975a5b8..c1505c4ba9f 100644 --- a/webview-ui/src/i18n/locales/id/settings.json +++ b/webview-ui/src/i18n/locales/id/settings.json @@ -729,6 +729,15 @@ "label": "Batas karakter terminal", "description": "Override batas baris untuk mencegah masalah memori dengan memberlakukan cap keras pada ukuran output. Jika terlampaui, simpan awal dan akhir lalu tampilkan placeholder ke Roo di mana konten dilewati. <0>Pelajari lebih lanjut" }, + "outputPreviewSize": { + "label": "Ukuran pratinjau keluaran perintah", + "description": "Mengontrol seberapa banyak keluaran perintah yang dilihat Roo secara langsung. Keluaran lengkap selalu disimpan dan dapat diakses saat diperlukan.", + "options": { + "small": "Kecil (5KB)", + "medium": "Sedang (10KB)", + "large": "Besar (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Timeout integrasi shell terminal", "description": "Waktu tunggu integrasi shell VS Code sebelum menjalankan perintah. Naikkan jika shell lambat start atau muncul error 'Shell Integration Unavailable'. <0>Pelajari lebih lanjut" @@ -741,10 +750,6 @@ "label": "Delay perintah terminal", "description": "Tambahkan jeda singkat setelah setiap perintah agar VS Code terminal bisa flush semua output (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Gunakan hanya jika output ekor hilang; jika tidak biarkan di 0. <0>Pelajari lebih lanjut" }, - "compressProgressBar": { - "label": "Kompres keluaran bilah kemajuan", - "description": "Menciutkan bilah kemajuan/spinner sehingga hanya status akhir yang disimpan (menghemat token). <0>Pelajari lebih lanjut" - }, "powershellCounter": { "label": "Aktifkan solusi penghitung PowerShell", "description": "Aktifkan saat keluaran PowerShell hilang atau digandakan; menambahkan penghitung kecil ke setiap perintah untuk menstabilkan keluaran. Biarkan nonaktif jika keluaran sudah terlihat benar. <0>Pelajari lebih lanjut" diff --git a/webview-ui/src/i18n/locales/it/chat.json b/webview-ui/src/i18n/locales/it/chat.json index dee7a4e61cc..3cfb685a4a2 100644 --- a/webview-ui/src/i18n/locales/it/chat.json +++ b/webview-ui/src/i18n/locales/it/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} server MCP", "messageTemplate": "Hai {{tools}} abilitate via {{servers}}. Un numero così alto può confondere il modello e portare a errori. Prova a mantenerlo sotto {{threshold}}.", "openMcpSettings": "Apri impostazioni MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/it/settings.json b/webview-ui/src/i18n/locales/it/settings.json index 1c3c7e494d7..139de3f16dd 100644 --- a/webview-ui/src/i18n/locales/it/settings.json +++ b/webview-ui/src/i18n/locales/it/settings.json @@ -725,6 +725,15 @@ "label": "Limite caratteri terminale", "description": "Sovrascrive il limite di righe per prevenire problemi di memoria imponendo un limite rigido alla dimensione di output. Se superato, mantiene l'inizio e la fine e mostra un segnaposto a Roo dove il contenuto viene saltato. <0>Scopri di più" }, + "outputPreviewSize": { + "label": "Dimensione anteprima output comandi", + "description": "Controlla quanto output dei comandi Roo vede direttamente. L'output completo viene sempre salvato ed è accessibile quando necessario.", + "options": { + "small": "Piccola (5KB)", + "medium": "Media (10KB)", + "large": "Grande (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Timeout integrazione shell terminale", "description": "Quanto tempo attendere l'integrazione della shell di VS Code prima di eseguire i comandi. Aumenta se la tua shell si avvia lentamente o vedi errori 'Integrazione Shell Non Disponibile'. <0>Scopri di più" @@ -737,10 +746,6 @@ "label": "Ritardo comando terminale", "description": "Aggiunge una breve pausa dopo ogni comando affinché il terminale VS Code possa svuotare tutto l'output (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Usa solo se vedi output finale mancante; altrimenti lascia a 0. <0>Scopri di più" }, - "compressProgressBar": { - "label": "Comprimi output barra di avanzamento", - "description": "Comprime barre di avanzamento/spinner in modo che venga mantenuto solo lo stato finale (risparmia token). <0>Scopri di più" - }, "powershellCounter": { "label": "Abilita workaround contatore PowerShell", "description": "Attiva quando l'output PowerShell è mancante o duplicato; aggiunge un piccolo contatore a ogni comando per stabilizzare l'output. Mantieni disattivato se l'output sembra già corretto. <0>Scopri di più" diff --git a/webview-ui/src/i18n/locales/ja/chat.json b/webview-ui/src/i18n/locales/ja/chat.json index 8e4fcb88815..95e1a51b4fe 100644 --- a/webview-ui/src/i18n/locales/ja/chat.json +++ b/webview-ui/src/i18n/locales/ja/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} MCP サーバー", "messageTemplate": "{{servers}}経由で{{tools}}が有効になっています。このような高い数は、モデルを混乱させてエラーを引き起こす可能性があります。{{threshold}}以下に保つようにしてください。", "openMcpSettings": "MCP 設定を開く" + }, + "readCommandOutput": { + "title": "Rooがコマンド出力を読み込みました" } } diff --git a/webview-ui/src/i18n/locales/ja/settings.json b/webview-ui/src/i18n/locales/ja/settings.json index b4af9d4033e..7ed64983513 100644 --- a/webview-ui/src/i18n/locales/ja/settings.json +++ b/webview-ui/src/i18n/locales/ja/settings.json @@ -725,6 +725,15 @@ "label": "ターミナル文字制限", "description": "出力サイズにハードキャップを適用してメモリ問題を防ぐため、行制限を上書きします。超過した場合、最初と最後を保持し、コンテンツがスキップされた箇所にRooにプレースホルダーを表示します。<0>詳細情報" }, + "outputPreviewSize": { + "label": "コマンド出力プレビューサイズ", + "description": "Rooが直接確認できるコマンド出力の量を制御します。完全な出力は常に保存され、必要に応じてアクセス可能です。", + "options": { + "small": "小 (5KB)", + "medium": "中 (10KB)", + "large": "大 (20KB)" + } + }, "shellIntegrationTimeout": { "label": "ターミナルシェル統合タイムアウト", "description": "コマンドを実行する前�����VS Codeシェル統合を待機する時間。シェルが遅く起動する場合や「シェル統合が利用できません」というエラーが表示される場合は、この値を増やしてください。<0>詳細" @@ -737,10 +746,6 @@ "label": "ターミナルコマンド遅延", "description": "VS Codeターミナルがすべての出力をフラッシュできるよう、各コマンド後に短い一時停止を追加します(bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep)。末尾出力が欠落している場合のみ使用;それ以外は0のままにします。<0>詳細情報" }, - "compressProgressBar": { - "label": "プログレスバー出力を圧���������", - "description": "プログレスバー/スピナーを折りたたんで、最終状態のみを保持します(トークンを節約します)。<0>詳細情報" - }, "powershellCounter": { "label": "PowerShellカウンターの回避策を有効にする", "description": "PowerShellの出力が欠落または重複している場合にこれをオンにします。出力を安定させるために各コマンドに小さなカウンターを追加します。出力がすでに正しい場合はオフのままにします。<0>詳細情報" diff --git a/webview-ui/src/i18n/locales/ko/chat.json b/webview-ui/src/i18n/locales/ko/chat.json index 93c62f6f7fb..5ee480ad782 100644 --- a/webview-ui/src/i18n/locales/ko/chat.json +++ b/webview-ui/src/i18n/locales/ko/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}}개 MCP 서버", "messageTemplate": "{{servers}}를 통해 {{tools}}가 활성화되어 있습니다. 이렇게 많은 수의 도구는 모델을 혼동시키고 오류를 유발할 수 있습니다. {{threshold}} 이하로 유지하도록 노력하세요.", "openMcpSettings": "MCP 설정 열기" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/ko/settings.json b/webview-ui/src/i18n/locales/ko/settings.json index 2888d75bb0b..20bf3858f70 100644 --- a/webview-ui/src/i18n/locales/ko/settings.json +++ b/webview-ui/src/i18n/locales/ko/settings.json @@ -725,6 +725,15 @@ "label": "터미널 문자 제한", "description": "출력 크기에 대한 엄격한 상한을 적용하여 메모리 문제를 방지하기 위해 줄 제한을 재정의합니다. 초과하면 시작과 끝을 유지하고 내용이 생략된 곳에 Roo에게 자리 표시자를 표시합니다. <0>자세히 알아보기" }, + "outputPreviewSize": { + "label": "명령 출력 미리보기 크기", + "description": "Roo가 직접 보는 명령 출력량을 제어합니다. 전체 출력은 항상 저장되며 필요할 때 액세스할 수 있습니다.", + "options": { + "small": "작게 (5KB)", + "medium": "보통 (10KB)", + "large": "크게 (20KB)" + } + }, "shellIntegrationTimeout": { "label": "터미널 셸 통합 시간 초과", "description": "명령을 실행하기 전에 VS Code 셸 통합을 기다리는 시간입니다. 셸이 느리게 시작되거나 '셸 통합을 사용할 수 없음' 오류가 표시되면 이 값을 늘리십시오. <0>자세히 알아보기" @@ -737,10 +746,6 @@ "label": "터미널 명령 지연", "description": "VS Code 터미널이 모든 출력을 플러시할 수 있도록 각 명령 후에 짧은 일시 중지를 추가합니다(bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). 누락된 꼬리 출력이 표시되는 경우에만 사용하고, 그렇지 않으면 0으로 둡니다. <0>자세히 알아보기" }, - "compressProgressBar": { - "label": "진행률 표시줄 출력 압축", - "description": "진행률 표시줄/스피너를 축소하여 최종 상태만 유지합니다(토큰 절약). <0>자세히 알아보기" - }, "powershellCounter": { "label": "PowerShell 카운터 해결 방법 활성화", "description": "PowerShell 출력이 누락되거나 중복될 때 이 기능을 켜십시오. 출력을 안정화하기 위해 각 명령에 작은 카운터를 추가합니다. 출력이 이미 올바르게 표시되면 이 기능을 끄십시오. <0>자세히 알아보기" diff --git a/webview-ui/src/i18n/locales/nl/chat.json b/webview-ui/src/i18n/locales/nl/chat.json index 331c6d9832a..e6244552458 100644 --- a/webview-ui/src/i18n/locales/nl/chat.json +++ b/webview-ui/src/i18n/locales/nl/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} MCP servers", "messageTemplate": "Je hebt {{tools}} ingeschakeld via {{servers}}. Zoveel tools kunnen het model verwarren en tot fouten leiden. Probeer dit onder {{threshold}} te houden.", "openMcpSettings": "MCP-instellingen openen" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/nl/settings.json b/webview-ui/src/i18n/locales/nl/settings.json index 83e1f4b7ab3..25b2a48f648 100644 --- a/webview-ui/src/i18n/locales/nl/settings.json +++ b/webview-ui/src/i18n/locales/nl/settings.json @@ -725,6 +725,15 @@ "label": "Terminal-tekenlimiet", "description": "Overschrijft de regellimiet om geheugenproblemen te voorkomen door een harde limiet op uitvoergrootte af te dwingen. Bij overschrijding behoudt het begin en einde en toont een placeholder aan Roo waar inhoud wordt overgeslagen. <0>Meer informatie" }, + "outputPreviewSize": { + "label": "Grootte opdrachtuitvoer voorvertoning", + "description": "Bepaalt hoeveel opdrachtuitvoer Roo direct ziet. Volledige uitvoer wordt altijd opgeslagen en is toegankelijk wanneer nodig.", + "options": { + "small": "Klein (5KB)", + "medium": "Gemiddeld (10KB)", + "large": "Groot (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Terminal-shell-integratie timeout", "description": "Hoe lang te wachten op VS Code-shell-integratie voordat commando's worden uitgevoerd. Verhoog als je shell traag opstart of je 'Shell-Integratie Niet Beschikbaar'-fouten ziet. <0>Meer informatie" @@ -737,10 +746,6 @@ "label": "Terminal-commandovertraging", "description": "Voegt korte pauze toe na elk commando zodat VS Code-terminal alle uitvoer kan flushen (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Gebruik alleen als je ontbrekende tail-uitvoer ziet; anders op 0 laten. <0>Meer informatie" }, - "compressProgressBar": { - "label": "Voortgangsbalk-uitvoer comprimeren", - "description": "Klapt voortgangsbalken/spinners in zodat alleen eindstatus behouden blijft (bespaart tokens). <0>Meer informatie" - }, "powershellCounter": { "label": "PowerShell-teller workaround inschakelen", "description": "Schakel in wanneer PowerShell-uitvoer ontbreekt of gedupliceerd wordt; voegt kleine teller toe aan elk commando om uitvoer te stabiliseren. Laat uit als uitvoer al correct lijkt. <0>Meer informatie" diff --git a/webview-ui/src/i18n/locales/pl/chat.json b/webview-ui/src/i18n/locales/pl/chat.json index b1594f87097..cb42161a74a 100644 --- a/webview-ui/src/i18n/locales/pl/chat.json +++ b/webview-ui/src/i18n/locales/pl/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} serwerów MCP", "messageTemplate": "Masz {{tools}} włączonych przez {{servers}}. Taka duża liczba może zamieszać model i prowadzić do błędów. Staraj się, aby była poniżej {{threshold}}.", "openMcpSettings": "Otwórz ustawienia MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/pl/settings.json b/webview-ui/src/i18n/locales/pl/settings.json index 7c339f96a5b..1ed4e59159c 100644 --- a/webview-ui/src/i18n/locales/pl/settings.json +++ b/webview-ui/src/i18n/locales/pl/settings.json @@ -725,6 +725,15 @@ "label": "Limit znaków terminala", "description": "Zastępuje limit linii, aby zapobiec problemom z pamięcią, narzucając twardy limit rozmiaru wyjścia. W przypadku przekroczenia zachowuje początek i koniec i pokazuje symbol zastępczy Roo tam, gdzie treść jest pomijana. <0>Dowiedz się więcej" }, + "outputPreviewSize": { + "label": "Rozmiar podglądu wyjścia polecenia", + "description": "Kontroluje, ile wyjścia polecenia Roo widzi bezpośrednio. Pełne wyjście jest zawsze zapisywane i dostępne w razie potrzeby.", + "options": { + "small": "Mały (5KB)", + "medium": "Średni (10KB)", + "large": "Duży (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Limit czasu integracji powłoki terminala", "description": "Jak długo czekać na integrację powłoki VS Code przed wykonaniem poleceń. Zwiększ, jeśli twoja powłoka wolno się uruchamia lub widzisz błędy 'Integracja Powłoki Niedostępna'. <0>Dowiedz się więcej" @@ -737,10 +746,6 @@ "label": "Opóźnienie polecenia terminala", "description": "Dodaje krótką pauzę po każdym poleceniu, aby terminal VS Code mógł opróżnić całe wyjście (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Używaj tylko gdy widzisz brakujące wyjście końcowe; w przeciwnym razie zostaw na 0. <0>Dowiedz się więcej" }, - "compressProgressBar": { - "label": "Kompresuj wyjście paska postępu", - "description": "Zwija paski postępu/spinnery, aby zachować tylko stan końcowy (oszczędza tokeny). <0>Dowiedz się więcej" - }, "powershellCounter": { "label": "Włącz obejście licznika PowerShell", "description": "Włącz gdy brakuje lub jest zduplikowane wyjście PowerShell; dodaje mały licznik do każdego polecenia, aby ustabilizować wyjście. Pozostaw wyłączone, jeśli wyjście już wygląda poprawnie. <0>Dowiedz się więcej" diff --git a/webview-ui/src/i18n/locales/pt-BR/chat.json b/webview-ui/src/i18n/locales/pt-BR/chat.json index 4153d3b5355..63ea3c56b12 100644 --- a/webview-ui/src/i18n/locales/pt-BR/chat.json +++ b/webview-ui/src/i18n/locales/pt-BR/chat.json @@ -504,5 +504,8 @@ "serversPart_other": "{{count}} servidores MCP", "messageTemplate": "Você tem {{tools}} habilitadas via {{servers}}. Um número tão alto pode confundir o modelo e levar a erros. Tente mantê-lo abaixo de {{threshold}}.", "openMcpSettings": "Abrir Configurações MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/pt-BR/settings.json b/webview-ui/src/i18n/locales/pt-BR/settings.json index 04a786ab11e..1d989db3793 100644 --- a/webview-ui/src/i18n/locales/pt-BR/settings.json +++ b/webview-ui/src/i18n/locales/pt-BR/settings.json @@ -725,6 +725,15 @@ "label": "Limite de caracteres do terminal", "description": "Substitui o limite de linhas para evitar problemas de memória, impondo um limite rígido no tamanho da saída. Se excedido, mantém o início e o fim e mostra um placeholder para o Roo onde o conteúdo é pulado. <0>Saiba mais" }, + "outputPreviewSize": { + "label": "Tamanho da visualização da saída de comandos", + "description": "Controla quanto da saída de comandos Roo vê diretamente. A saída completa é sempre salva e acessível quando necessário.", + "options": { + "small": "Pequeno (5KB)", + "medium": "Médio (10KB)", + "large": "Grande (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Tempo limite de integração do shell do terminal", "description": "Quanto tempo esperar pela integração do shell do VS Code antes de executar comandos. Aumente se o seu shell demorar para iniciar ou se você vir erros de 'Integração do Shell Indisponível'. <0>Saiba mais" @@ -737,10 +746,6 @@ "label": "Atraso de comando do terminal", "description": "Adiciona uma pequena pausa após cada comando para que o terminal do VS Code possa liberar toda a saída (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Use apenas se você vir a saída final faltando; caso contrário, deixe em 0. <0>Saiba mais" }, - "compressProgressBar": { - "label": "Comprimir saída da barra de progresso", - "description": "Recolhe barras de progresso/spinners para que apenas o estado final seja mantido (economiza tokens). <0>Saiba mais" - }, "powershellCounter": { "label": "Ativar solução alternativa do contador do PowerShell", "description": "Ative isso quando a saída do PowerShell estiver faltando ou duplicada; ele adiciona um pequeno contador a cada comando para estabilizar a saída. Mantenha desativado se a saída já parecer correta. <0>Saiba mais" diff --git a/webview-ui/src/i18n/locales/ru/chat.json b/webview-ui/src/i18n/locales/ru/chat.json index c1890f53b20..83dfd01a29a 100644 --- a/webview-ui/src/i18n/locales/ru/chat.json +++ b/webview-ui/src/i18n/locales/ru/chat.json @@ -505,5 +505,8 @@ "serversPart_other": "{{count}} серверов MCP", "messageTemplate": "У тебя включено {{tools}} через {{servers}}. Такое большое количество может сбить модель с толку и привести к ошибкам. Постарайся держать это ниже {{threshold}}.", "openMcpSettings": "Открыть настройки MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/ru/settings.json b/webview-ui/src/i18n/locales/ru/settings.json index ebdbc01b931..5a736ef1eca 100644 --- a/webview-ui/src/i18n/locales/ru/settings.json +++ b/webview-ui/src/i18n/locales/ru/settings.json @@ -725,6 +725,15 @@ "label": "Лимит символов терминала", "description": "Переопределяет лимит строк для предотвращения проблем с памятью, устанавливая жёсткое ограничение на размер вывода. При превышении сохраняет начало и конец и показывает Roo заполнитель там, где контент пропущен. <0>Подробнее" }, + "outputPreviewSize": { + "label": "Размер предпросмотра вывода команд", + "description": "Контролирует, сколько вывода команды Roo видит напрямую. Полный вывод всегда сохраняется и доступен при необходимости.", + "options": { + "small": "Маленький (5KB)", + "medium": "Средний (10KB)", + "large": "Большой (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Таймаут интеграции shell терминала", "description": "Сколько ждать интеграции shell VS Code перед выполнением команд. Увеличьте, если ваш shell запускается медленно или вы видите ошибки 'Интеграция Shell Недоступна'. <0>Подробнее" @@ -737,10 +746,6 @@ "label": "Задержка команды терминала", "description": "Добавляет короткую паузу после каждой команды, чтобы терминал VS Code мог вывести весь output (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Используйте только если видите отсутствующий tail output; иначе оставьте 0. <0>Подробнее" }, - "compressProgressBar": { - "label": "Сжимать вывод прогресс-бара", - "description": "Сворачивает прогресс-бары/спиннеры, чтобы сохранялось только финальное состояние (экономит токены). <0>Подробнее" - }, "powershellCounter": { "label": "Включить обходчик счётчика PowerShell", "description": "Включите, когда вывод PowerShell отсутствует или дублируется; добавляет маленький счётчик к каждой команде для стабилизации вывода. Оставьте выключенным, если вывод уже выглядит корректно. <0>Подробнее" diff --git a/webview-ui/src/i18n/locales/tr/chat.json b/webview-ui/src/i18n/locales/tr/chat.json index 112ac2f46ce..50303985531 100644 --- a/webview-ui/src/i18n/locales/tr/chat.json +++ b/webview-ui/src/i18n/locales/tr/chat.json @@ -505,5 +505,8 @@ "serversPart_other": "{{count}} MCP sunucusu", "messageTemplate": "{{servers}} üzerinden {{tools}} etkinleştirilmiş durumda. Bu kadar fazlası modeli kafası karışabilir ve hatalara neden olabilir. {{threshold}} altında tutmaya çalış.", "openMcpSettings": "MCP Ayarlarını Aç" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/tr/settings.json b/webview-ui/src/i18n/locales/tr/settings.json index 5a7daeec1d7..9110f27d6e5 100644 --- a/webview-ui/src/i18n/locales/tr/settings.json +++ b/webview-ui/src/i18n/locales/tr/settings.json @@ -725,6 +725,15 @@ "label": "Terminal karakter sınırı", "description": "Çıktı boyutuna katı bir üst sınır uygulayarak bellek sorunlarını önlemek için satır sınırını geçersiz kılar. Aşılırsa, başlangıcı ve sonu tutar ve içeriğin atlandığı yerde Roo'ya bir yer tutucu gösterir. <0>Daha fazla bilgi edinin" }, + "outputPreviewSize": { + "label": "Komut çıktısı önizleme boyutu", + "description": "Roo'nun doğrudan gördüğü komut çıktısı miktarını kontrol eder. Tam çıktı her zaman kaydedilir ve gerektiğinde erişilebilir.", + "options": { + "small": "Küçük (5KB)", + "medium": "Orta (10KB)", + "large": "Büyük (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Terminal shell entegrasyon timeout", "description": "Komut çalıştırmadan önce VS Code shell entegrasyonunu bekleme süresi. Shell yavaş başlıyorsa veya 'Shell Integration Unavailable' hatası görüyorsanız artırın. <0>Daha fazla bilgi edinin" @@ -737,10 +746,6 @@ "label": "Terminal komut delay", "description": "VS Code terminalin tüm outputu flush edebilmesi için her komuttan sonra kısa pause ekler (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Sadece tail output eksikse kullan; yoksa 0'da bırak. <0>Daha fazla bilgi edinin" }, - "compressProgressBar": { - "label": "İlerleme çubuğu çıktısını sıkıştır", - "description": "İlerleme çubukları/spinner'ları daraltır, sadece son durumu tutar (token tasarrufu). <0>Daha fazla bilgi edinin" - }, "powershellCounter": { "label": "PowerShell sayaç geçici çözümünü etkinleştir", "description": "PowerShell çıktısı eksik veya yineleniyorsa bunu açın; çıktıyı stabilize etmek için her komuta küçük bir sayaç ekler. Çıktı zaten doğru görünüyorsa bunu kapalı tutun. <0>Daha fazla bilgi edinin" diff --git a/webview-ui/src/i18n/locales/vi/chat.json b/webview-ui/src/i18n/locales/vi/chat.json index 65389a063bc..822e486c79e 100644 --- a/webview-ui/src/i18n/locales/vi/chat.json +++ b/webview-ui/src/i18n/locales/vi/chat.json @@ -505,5 +505,8 @@ "serversPart_other": "{{count}} máy chủ MCP", "messageTemplate": "Bạn đã bật {{tools}} qua {{servers}}. Số lượng lớn như vậy có thể khiến mô hình bối rối và dẫn đến lỗi. Cố gắng giữ nó dưới {{threshold}}.", "openMcpSettings": "Mở cài đặt MCP" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/vi/settings.json b/webview-ui/src/i18n/locales/vi/settings.json index 3e8e22d8f0c..14c8904e09f 100644 --- a/webview-ui/src/i18n/locales/vi/settings.json +++ b/webview-ui/src/i18n/locales/vi/settings.json @@ -725,6 +725,15 @@ "label": "Giới hạn ký tự terminal", "description": "Ghi đè giới hạn dòng để tránh vấn đề bộ nhớ bằng cách áp đặt giới hạn cứng cho kích thước đầu ra. Nếu vượt quá, giữ đầu và cuối, hiển thị placeholder cho Roo nơi nội dung bị bỏ qua. <0>Tìm hiểu thêm" }, + "outputPreviewSize": { + "label": "Kích thước xem trước đầu ra lệnh", + "description": "Kiểm soát lượng đầu ra lệnh mà Roo nhìn thấy trực tiếp. Đầu ra đầy đủ luôn được lưu và có thể truy cập khi cần thiết.", + "options": { + "small": "Nhỏ (5KB)", + "medium": "Trung bình (10KB)", + "large": "Lớn (20KB)" + } + }, "shellIntegrationTimeout": { "label": "Timeout tích hợp shell terminal", "description": "Thời gian đợi tích hợp shell VS Code trước khi chạy lệnh. Tăng nếu shell khởi động chậm hoặc thấy lỗi 'Shell Integration Unavailable'. <0>Tìm hiểu thêm" @@ -737,10 +746,6 @@ "label": "Delay lệnh terminal", "description": "Thêm khoảng dừng ngắn sau mỗi lệnh để VS Code terminal flush tất cả output (bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep). Chỉ dùng nếu thiếu tail output; nếu không để ở 0. <0>Tìm hiểu thêm" }, - "compressProgressBar": { - "label": "Nén đầu ra thanh tiến trình", - "description": "Thu gọn các thanh tiến trình/vòng quay để chỉ giữ lại trạng thái cuối cùng (tiết kiệm token). <0>Tìm hiểu thêm" - }, "powershellCounter": { "label": "Bật workaround bộ đếm PowerShell", "description": "Bật khi output PowerShell thiếu hoặc trùng lặp; thêm counter nhỏ vào mỗi lệnh để ổn định output. Tắt nếu output đã đúng. <0>Tìm hiểu thêm" diff --git a/webview-ui/src/i18n/locales/zh-CN/chat.json b/webview-ui/src/i18n/locales/zh-CN/chat.json index 057d4f66e77..0f4e5c95843 100644 --- a/webview-ui/src/i18n/locales/zh-CN/chat.json +++ b/webview-ui/src/i18n/locales/zh-CN/chat.json @@ -505,5 +505,8 @@ "serversPart_other": "{{count}} 个 MCP 服务", "messageTemplate": "你通过 {{servers}} 启用了 {{tools}}。这么多数量会混淆模型并导致错误。建议将其保持在 {{threshold}} 以下。", "openMcpSettings": "打开 MCP 设置" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/zh-CN/settings.json b/webview-ui/src/i18n/locales/zh-CN/settings.json index 85bc9bd431b..1b58484ceda 100644 --- a/webview-ui/src/i18n/locales/zh-CN/settings.json +++ b/webview-ui/src/i18n/locales/zh-CN/settings.json @@ -725,6 +725,15 @@ "label": "终端字符限制", "description": "通过强制限制输出大小来覆盖行限制以防止内存问题。如果超出,保留开头和结尾并向 Roo 显示内容被跳过的占位符。<0>了解更多" }, + "outputPreviewSize": { + "label": "命令输出预览大小", + "description": "控制 Roo 直接看到的命令输出量。完整输出始终会被保存,需要时可以访问。", + "options": { + "small": "小 (5KB)", + "medium": "中 (10KB)", + "large": "大 (20KB)" + } + }, "shellIntegrationTimeout": { "label": "终端 shell 集成超时", "description": "运行命令前等待 VS Code shell 集成的时间。如果 shell 启动缓慢或看到 'Shell Integration Unavailable' 错误,请提高此值。<0>了解更多" @@ -737,10 +746,6 @@ "label": "终端命令延迟", "description": "在每个命令后添加短暂暂停,以便 VS Code 终端刷新所有输出(bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep)。仅在看到缺少尾部输出时使用;否则保持为 0。<0>了解更多" }, - "compressProgressBar": { - "label": "压缩进度条输出", - "description": "折叠进度条/旋转器,仅保留最终状态(节省 token)。<0>了解更多" - }, "powershellCounter": { "label": "启用 PowerShell 计数器解决方案", "description": "当 PowerShell 输出丢失或重复时启用此选项;它会为每个命令附加一个小计数器以稳定输出。如果输出已正常,请保持关闭。<0>了解更多" diff --git a/webview-ui/src/i18n/locales/zh-TW/chat.json b/webview-ui/src/i18n/locales/zh-TW/chat.json index 1243caa76aa..31c54089cd5 100644 --- a/webview-ui/src/i18n/locales/zh-TW/chat.json +++ b/webview-ui/src/i18n/locales/zh-TW/chat.json @@ -495,5 +495,8 @@ "serversPart_other": "{{count}} 個 MCP 伺服器", "messageTemplate": "您已啟用 {{tools}}(透過 {{servers}})。這麼多的工具可能會混淆模型並導致錯誤。請嘗試保持在 {{threshold}} 以下。", "openMcpSettings": "開啟 MCP 設定" + }, + "readCommandOutput": { + "title": "Roo read command output" } } diff --git a/webview-ui/src/i18n/locales/zh-TW/settings.json b/webview-ui/src/i18n/locales/zh-TW/settings.json index 47f614932b9..d18a5c8443f 100644 --- a/webview-ui/src/i18n/locales/zh-TW/settings.json +++ b/webview-ui/src/i18n/locales/zh-TW/settings.json @@ -733,6 +733,15 @@ "label": "終端機字元限制", "description": "透過強制限制輸出大小來覆寫行限制以防止記憶體問題。如果超出,保留開頭和結尾並向 Roo 顯示內容被跳過的佔位符。<0>了解更多" }, + "outputPreviewSize": { + "label": "命令輸出預覽大小", + "description": "控制 Roo 直接看到的命令輸出量。完整輸出始終會被儲存,需要時可以存取。", + "options": { + "small": "小 (5KB)", + "medium": "中 (10KB)", + "large": "大 (20KB)" + } + }, "shellIntegrationTimeout": { "label": "終端機 shell 整合逾時", "description": "執行命令前等待 VS Code shell 整合的時間。如果 shell 啟動緩慢或看到 'Shell Integration Unavailable' 錯誤,請提高此值。<0>了解更多" @@ -745,10 +754,6 @@ "label": "終端機命令延遲", "description": "在每個命令後新增短暫暫停,以便 VS Code 終端機刷新所有輸出(bash/zsh: PROMPT_COMMAND sleep; PowerShell: start-sleep)。僅在看到缺少尾部輸出時使用;否則保持為 0。<0>了解更多" }, - "compressProgressBar": { - "label": "壓縮進度條輸出", - "description": "折疊進度條/旋轉器,僅保留最終狀態(節省 Token)。<0>了解更多" - }, "powershellCounter": { "label": "啟用 PowerShell 計數器解決方案", "description": "當 PowerShell 輸出遺失或重複時啟用此選項;它會為每個命令附加一個小計數器以穩定輸出。如果輸出已正常,請保持關閉。<0>了解更多"