fix(cliproxy): address 3 code review issues in composite variants

- P1: Remove premature variant deletion in --force mode
  Fix destructive overwrite path - old variant preserved if user
  cancels auth or creation fails (createVariant handles overwrite)

- P2: Validate all composite tier providers at runtime
  Backend gating now checks all providers in composite, not just
  default tier. Prevents kiro/ghcp on non-default tiers bypassing
  Plus backend requirement.

- P2: Preserve tier thinking when default tier is off
  Early return skipped tier processing when default thinking was
  "off". Now uses flag-based approach - only main model skipped,
  tier loop continues with per-tier thinking config.
This commit is contained in:
Tam Nhu Tran
2026-02-12 12:29:43 +07:00
parent 27d22e836f
commit 399d7e163a
3 changed files with 18 additions and 24 deletions
+4 -6
View File
@@ -152,13 +152,11 @@ export function applyThinkingConfig(
}
thinkingValue = validation.value;
// If validation says off, don't apply suffix
if (thinkingValue === 'off') {
return result;
}
// Track whether to apply to main model (skip if validation says off)
const applyToMainModel = thinkingValue !== 'off';
// Apply thinking suffix to main model
if (result.ANTHROPIC_MODEL) {
// Apply thinking suffix to main model (only if not off)
if (applyToMainModel && result.ANTHROPIC_MODEL) {
result.ANTHROPIC_MODEL = applyThinkingSuffix(result.ANTHROPIC_MODEL, thinkingValue);
}
+14 -9
View File
@@ -124,15 +124,20 @@ export async function execClaudeWithCLIProxy(
// 0a. Runtime backend/provider validation
const backend: CLIProxyBackend = unifiedConfig.cliproxy?.backend ?? DEFAULT_BACKEND;
if (backend === 'original' && PLUS_ONLY_PROVIDERS.includes(provider)) {
console.error('');
console.error(fail(`${provider} requires CLIProxyAPIPlus backend`));
console.error('');
console.error('To use this provider, either:');
console.error(' 1. Set `cliproxy.backend: plus` in ~/.ccs/config.yaml');
console.error(' 2. Use --backend=plus flag: ccs ' + provider + ' --backend=plus');
console.error('');
throw new Error(`Provider ${provider} requires Plus backend`);
// Collect all providers to validate (default + composite tiers)
const allProviders = [provider, ...compositeProviders];
for (const p of allProviders) {
if (backend === 'original' && PLUS_ONLY_PROVIDERS.includes(p as CLIProxyProvider)) {
console.error('');
console.error(fail(`${p} requires CLIProxyAPIPlus backend`));
console.error('');
console.error('To use this provider, either:');
console.error(' 1. Set `cliproxy.backend: plus` in ~/.ccs/config.yaml');
console.error(' 2. Use --backend=plus flag: ccs ' + p + ' --backend=plus');
console.error('');
throw new Error(`Provider ${p} requires Plus backend`);
}
}
const cliproxyServerConfig = unifiedConfig.cliproxy_server;
@@ -168,15 +168,6 @@ export async function handleCreate(
process.exit(1);
}
// Clean up old variant if --force is set
if (variantExists(name) && parsedArgs.force) {
const removeResult = removeVariant(name);
if (!removeResult.success) {
console.log(fail(`Cannot overwrite variant '${name}': ${removeResult.error}`));
process.exit(1);
}
}
// Composite mode: select provider+model per tier
if (parsedArgs.composite) {
console.log(info('Composite variant — select provider and model for each tier'));