feat(cli): sanitize ANSI escape sequences in non-interactive output (#17172)

This commit is contained in:
Sehoon Shon
2026-01-20 23:58:37 -05:00
committed by GitHub
parent 367e7bf401
commit 7990073543
5 changed files with 301 additions and 3 deletions
+13
View File
@@ -83,6 +83,8 @@ export interface CliArgs {
outputFormat: string | undefined;
fakeResponses: string | undefined;
recordResponses: string | undefined;
rawOutput: boolean | undefined;
acceptRawOutputRisk: boolean | undefined;
}
export async function parseArguments(
@@ -248,6 +250,15 @@ export async function parseArguments(
type: 'string',
description: 'Path to a file to record model responses for testing.',
hidden: true,
})
.option('raw-output', {
type: 'boolean',
description:
'Disable sanitization of model output (e.g. allow ANSI escape sequences). WARNING: This can be a security risk if the model output is untrusted.',
})
.option('accept-raw-output-risk', {
type: 'boolean',
description: 'Suppress the security warning when using --raw-output.',
}),
)
// Register MCP subcommands
@@ -759,6 +770,8 @@ export async function loadCliConfig(
retryFetchErrors: settings.general?.retryFetchErrors,
ptyInfo: ptyInfo?.name,
disableLLMCorrection: settings.tools?.disableLLMCorrection,
rawOutput: argv.rawOutput,
acceptRawOutputRisk: argv.acceptRawOutputRisk,
modelConfigServiceConfig: settings.modelConfigs,
// TODO: loading of hooks based on workspace trust
enableHooks: