mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 08:15:17 +00:00
fix(cli): add --thinking=value format and improve flag handling
- Support --thinking=value in addition to --thinking value - Warn when multiple --thinking flags detected (uses first) - Document intentional negative number blocking
This commit is contained in:
1 parent
5f8d23c60b
commit
3060373797
1 file changed
+43
-7
@@ -314,17 +314,51 @@ export async function execClaudeWithCLIProxy(
|
|||||||
|
|
||||||
// Parse --thinking <value> flag for thinking budget control
|
// Parse --thinking <value> flag for thinking budget control
|
||||||
// Supports: level names (low, medium, high, xhigh, auto), numeric budget, or 'off'/'none'
|
// Supports: level names (low, medium, high, xhigh, auto), numeric budget, or 'off'/'none'
|
||||||
|
// Accepts both --thinking=value and --thinking value formats
|
||||||
let thinkingOverride: string | number | undefined;
|
let thinkingOverride: string | number | undefined;
|
||||||
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
|
|
||||||
if (
|
// Check for --thinking=value format first
|
||||||
thinkingIdx !== -1 &&
|
const thinkingEqArg = argsWithoutProxy.find((arg) => arg.startsWith('--thinking='));
|
||||||
argsWithoutProxy[thinkingIdx + 1] &&
|
if (thinkingEqArg) {
|
||||||
!argsWithoutProxy[thinkingIdx + 1].startsWith('-')
|
const val = thinkingEqArg.substring('--thinking='.length);
|
||||||
) {
|
|
||||||
const val = argsWithoutProxy[thinkingIdx + 1];
|
|
||||||
// Parse as number if numeric, otherwise keep as string (level name)
|
// Parse as number if numeric, otherwise keep as string (level name)
|
||||||
const numVal = parseInt(val, 10);
|
const numVal = parseInt(val, 10);
|
||||||
thinkingOverride = !isNaN(numVal) ? numVal : val;
|
thinkingOverride = !isNaN(numVal) ? numVal : val;
|
||||||
|
|
||||||
|
// W2: Warn if multiple --thinking flags found (check both formats)
|
||||||
|
const allThinkingFlags = argsWithoutProxy.filter(
|
||||||
|
(arg) => arg === '--thinking' || arg.startsWith('--thinking=')
|
||||||
|
);
|
||||||
|
if (allThinkingFlags.length > 1) {
|
||||||
|
console.warn(
|
||||||
|
`[!] Multiple --thinking flags detected. Using first occurrence: ${thinkingEqArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Fall back to --thinking value format
|
||||||
|
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
|
||||||
|
if (
|
||||||
|
thinkingIdx !== -1 &&
|
||||||
|
argsWithoutProxy[thinkingIdx + 1] &&
|
||||||
|
// W4: Intentionally block negative numbers (negative budgets don't make sense)
|
||||||
|
// Values starting with '-' are treated as next flag, not a negative number
|
||||||
|
!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;
|
||||||
|
|
||||||
|
// W2: Warn if multiple --thinking flags found (check both formats)
|
||||||
|
const allThinkingFlags = argsWithoutProxy.filter(
|
||||||
|
(arg) => arg === '--thinking' || arg.startsWith('--thinking=')
|
||||||
|
);
|
||||||
|
if (allThinkingFlags.length > 1) {
|
||||||
|
console.warn(
|
||||||
|
`[!] Multiple --thinking flags detected. Using first occurrence: --thinking ${val}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle --accounts: list accounts and exit
|
// Handle --accounts: list accounts and exit
|
||||||
@@ -819,6 +853,8 @@ 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 --thinking=value format
|
||||||
|
if (arg.startsWith('--thinking=')) return false;
|
||||||
// Filter out value after --use, --nickname, or --thinking
|
// Filter out value after --use, --nickname, or --thinking
|
||||||
if (
|
if (
|
||||||
argsWithoutProxy[idx - 1] === '--use' ||
|
argsWithoutProxy[idx - 1] === '--use' ||
|
||||||
|
|||||||
Reference in new issue
Block a user