feat(cli): add --thinking flag for runtime budget override

- parse --thinking=value from CLI arguments

- pass thinking value to config generator

- update help command with --thinking documentation

Refs #307
This commit is contained in:
kaitranntt
2026-01-08 15:19:42 -05:00
parent 014b5e68b8
commit 4d361b2ecf
2 changed files with 31 additions and 2 deletions
+27 -2
View File
@@ -27,6 +27,7 @@ import {
CLIPROXY_DEFAULT_PORT,
getCliproxyWritablePath,
validatePort,
applyThinkingConfig,
} from './config-generator';
import { checkRemoteProxy } from './remote-proxy-client';
import { isAuthenticated } from './auth-handler';
@@ -311,6 +312,21 @@ export async function execClaudeWithCLIProxy(
setNickname = argsWithoutProxy[nicknameIdx + 1];
}
// Parse --thinking <value> flag for thinking budget control
// Supports: level names (low, medium, high, xhigh, auto), numeric budget, or 'off'/'none'
let thinkingOverride: string | number | undefined;
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
if (
thinkingIdx !== -1 &&
argsWithoutProxy[thinkingIdx + 1] &&
!argsWithoutProxy[thinkingIdx + 1].startsWith('-')
) {
const val = argsWithoutProxy[thinkingIdx + 1];
// Parse as number if numeric, otherwise keep as string (level name)
const numVal = parseInt(val, 10);
thinkingOverride = !isNaN(numVal) ? numVal : val;
}
// Handle --accounts: list accounts and exit
if (showAccounts) {
const accounts = getProviderAccounts(provider);
@@ -704,6 +720,10 @@ export async function execClaudeWithCLIProxy(
)
: getEffectiveEnvVars(provider, cfg.port, cfg.customSettingsPath, remoteRewriteConfig);
// Apply thinking configuration to model (auto tier-based or manual override)
// This adds thinking suffix like model(high) or model(8192) for CLIProxyAPIPlus
applyThinkingConfig(envVars, provider, thinkingOverride);
// Codex-only: inject OpenAI reasoning effort based on tier model mapping.
// Maps by request.model:
// - OPUS/default model → xhigh
@@ -789,6 +809,7 @@ export async function execClaudeWithCLIProxy(
'--accounts',
'--use',
'--nickname',
'--thinking',
'--incognito',
'--no-incognito',
'--import',
@@ -798,8 +819,12 @@ export async function execClaudeWithCLIProxy(
const claudeArgs = argsWithoutProxy.filter((arg, idx) => {
// Filter out CCS flags
if (ccsFlags.includes(arg)) return false;
// Filter out value after --use or --nickname
if (argsWithoutProxy[idx - 1] === '--use' || argsWithoutProxy[idx - 1] === '--nickname')
// Filter out value after --use, --nickname, or --thinking
if (
argsWithoutProxy[idx - 1] === '--use' ||
argsWithoutProxy[idx - 1] === '--nickname' ||
argsWithoutProxy[idx - 1] === '--thinking'
)
return false;
return true;
});
+4
View File
@@ -172,6 +172,10 @@ Run ${color('ccs config', 'command')} for web dashboard`.trim();
['ccs <provider> --accounts', 'List all accounts'],
['ccs <provider> --use <name>', 'Switch to account'],
['ccs <provider> --config', 'Change model (agy, gemini)'],
[
'ccs <provider> --thinking <value>',
'Set thinking budget (low/medium/high/xhigh/auto/off or number)',
],
['ccs <provider> --logout', 'Clear authentication'],
['ccs <provider> --headless', 'Headless auth (for SSH)'],
['ccs kiro --import', 'Import token from Kiro IDE'],