mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-20 02:27:45 +00:00
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:
@@ -27,6 +27,7 @@ import {
|
|||||||
CLIPROXY_DEFAULT_PORT,
|
CLIPROXY_DEFAULT_PORT,
|
||||||
getCliproxyWritablePath,
|
getCliproxyWritablePath,
|
||||||
validatePort,
|
validatePort,
|
||||||
|
applyThinkingConfig,
|
||||||
} from './config-generator';
|
} from './config-generator';
|
||||||
import { checkRemoteProxy } from './remote-proxy-client';
|
import { checkRemoteProxy } from './remote-proxy-client';
|
||||||
import { isAuthenticated } from './auth-handler';
|
import { isAuthenticated } from './auth-handler';
|
||||||
@@ -311,6 +312,21 @@ export async function execClaudeWithCLIProxy(
|
|||||||
setNickname = argsWithoutProxy[nicknameIdx + 1];
|
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
|
// Handle --accounts: list accounts and exit
|
||||||
if (showAccounts) {
|
if (showAccounts) {
|
||||||
const accounts = getProviderAccounts(provider);
|
const accounts = getProviderAccounts(provider);
|
||||||
@@ -704,6 +720,10 @@ export async function execClaudeWithCLIProxy(
|
|||||||
)
|
)
|
||||||
: getEffectiveEnvVars(provider, cfg.port, cfg.customSettingsPath, remoteRewriteConfig);
|
: 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.
|
// Codex-only: inject OpenAI reasoning effort based on tier model mapping.
|
||||||
// Maps by request.model:
|
// Maps by request.model:
|
||||||
// - OPUS/default model → xhigh
|
// - OPUS/default model → xhigh
|
||||||
@@ -789,6 +809,7 @@ export async function execClaudeWithCLIProxy(
|
|||||||
'--accounts',
|
'--accounts',
|
||||||
'--use',
|
'--use',
|
||||||
'--nickname',
|
'--nickname',
|
||||||
|
'--thinking',
|
||||||
'--incognito',
|
'--incognito',
|
||||||
'--no-incognito',
|
'--no-incognito',
|
||||||
'--import',
|
'--import',
|
||||||
@@ -798,8 +819,12 @@ export async function execClaudeWithCLIProxy(
|
|||||||
const claudeArgs = argsWithoutProxy.filter((arg, idx) => {
|
const claudeArgs = argsWithoutProxy.filter((arg, idx) => {
|
||||||
// Filter out CCS flags
|
// Filter out CCS flags
|
||||||
if (ccsFlags.includes(arg)) return false;
|
if (ccsFlags.includes(arg)) return false;
|
||||||
// Filter out value after --use or --nickname
|
// Filter out value after --use, --nickname, or --thinking
|
||||||
if (argsWithoutProxy[idx - 1] === '--use' || argsWithoutProxy[idx - 1] === '--nickname')
|
if (
|
||||||
|
argsWithoutProxy[idx - 1] === '--use' ||
|
||||||
|
argsWithoutProxy[idx - 1] === '--nickname' ||
|
||||||
|
argsWithoutProxy[idx - 1] === '--thinking'
|
||||||
|
)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -172,6 +172,10 @@ Run ${color('ccs config', 'command')} for web dashboard`.trim();
|
|||||||
['ccs <provider> --accounts', 'List all accounts'],
|
['ccs <provider> --accounts', 'List all accounts'],
|
||||||
['ccs <provider> --use <name>', 'Switch to account'],
|
['ccs <provider> --use <name>', 'Switch to account'],
|
||||||
['ccs <provider> --config', 'Change model (agy, gemini)'],
|
['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> --logout', 'Clear authentication'],
|
||||||
['ccs <provider> --headless', 'Headless auth (for SSH)'],
|
['ccs <provider> --headless', 'Headless auth (for SSH)'],
|
||||||
['ccs kiro --import', 'Import token from Kiro IDE'],
|
['ccs kiro --import', 'Import token from Kiro IDE'],
|
||||||
|
|||||||
Reference in New Issue
Block a user