mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-15 06:16:03 +00:00
fix(cliproxy): prune stale control panel alias clusters
- prune stale generated Gemini preview clusters during config regeneration - preserve manual preview overrides on built-in Gemini alias names - add regression coverage for stale cluster cleanup and manual pins
This commit is contained in:
1 parent
9307bb857f
commit
061cd9679f
2 files changed
+252
-3
No files matched your search
@@ -753,6 +753,135 @@ oauth-model-alias:
|
||||
);
|
||||
});
|
||||
|
||||
it('drops stale generated Gemini preview clusters while preserving true custom aliases', () => {
|
||||
const cliproxyDir = path.join(testDir, '.ccs', 'cliproxy');
|
||||
fs.mkdirSync(cliproxyDir, { recursive: true });
|
||||
|
||||
const initialConfig = `# CLIProxyAPI config generated by CCS v12
|
||||
port: 8317
|
||||
api-keys:
|
||||
- "ccs-internal-managed"
|
||||
auth-dir: "${cliproxyDir.replace(/\\/g, '/')}/auth"
|
||||
oauth-model-alias:
|
||||
antigravity:
|
||||
- name: gemini-3-pro-high
|
||||
alias: gemini-3.9-pro-preview
|
||||
- name: gemini-3-pro-high
|
||||
alias: gemini-3.9-pro-preview-customtools
|
||||
- name: gemini-3-pro-high
|
||||
alias: gemini-3-9-pro-preview
|
||||
- name: gemini-3-pro-high
|
||||
alias: gemini-3-9-pro-preview-customtools
|
||||
- name: gemini-3-flash
|
||||
alias: gemini-3.9-flash-preview
|
||||
- name: gemini-3-flash
|
||||
alias: gemini-3.9-flash-preview-customtools
|
||||
- name: gemini-3-flash
|
||||
alias: gemini-3-9-flash-preview
|
||||
- name: gemini-3-flash
|
||||
alias: gemini-3-9-flash-preview-customtools
|
||||
- name: custom-model
|
||||
alias: keep-me
|
||||
`;
|
||||
fs.writeFileSync(path.join(cliproxyDir, 'config.yaml'), initialConfig);
|
||||
|
||||
regenerateConfig();
|
||||
|
||||
const newConfig = fs.readFileSync(path.join(cliproxyDir, 'config.yaml'), 'utf-8');
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3.9-pro-preview'),
|
||||
'Should remove stale generated Pro preview alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3.9-pro-preview-customtools'),
|
||||
'Should remove stale generated Pro customtools alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3-9-pro-preview'),
|
||||
'Should remove stale generated hyphenated Pro alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3-9-pro-preview-customtools'),
|
||||
'Should remove stale generated hyphenated Pro customtools alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3.9-flash-preview'),
|
||||
'Should remove stale generated Flash preview alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3.9-flash-preview-customtools'),
|
||||
'Should remove stale generated Flash customtools alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3-9-flash-preview'),
|
||||
'Should remove stale generated hyphenated Flash alias noise'
|
||||
);
|
||||
assert(
|
||||
!newConfig.includes('alias: gemini-3-9-flash-preview-customtools'),
|
||||
'Should remove stale generated Flash preview alias noise'
|
||||
);
|
||||
assert(newConfig.includes('alias: keep-me'), 'Should preserve true custom aliases');
|
||||
assert(
|
||||
newConfig.includes('alias: gemini-3-pro-preview'),
|
||||
'Should still keep current baseline Pro preview alias'
|
||||
);
|
||||
assert(
|
||||
newConfig.includes('alias: gemini-3.1-flash-preview-customtools'),
|
||||
'Should still keep current baseline Flash compatibility alias'
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves manual Gemini preview overrides on built-in alias names', () => {
|
||||
const cliproxyDir = path.join(testDir, '.ccs', 'cliproxy');
|
||||
fs.mkdirSync(cliproxyDir, { recursive: true });
|
||||
|
||||
const initialConfig = `# CLIProxyAPI config generated by CCS v12
|
||||
port: 8317
|
||||
api-keys:
|
||||
- "ccs-internal-managed"
|
||||
auth-dir: "${cliproxyDir.replace(/\\/g, '/')}/auth"
|
||||
oauth-model-alias:
|
||||
antigravity:
|
||||
- name: gemini-3-pro-high
|
||||
alias: gemini-3.2-pro-preview
|
||||
- name: gemini-3-flash
|
||||
alias: gemini-3.2-flash-preview
|
||||
fork: true
|
||||
`;
|
||||
fs.writeFileSync(path.join(cliproxyDir, 'config.yaml'), initialConfig);
|
||||
|
||||
regenerateConfig();
|
||||
|
||||
const newConfig = fs.readFileSync(path.join(cliproxyDir, 'config.yaml'), 'utf-8');
|
||||
assert(
|
||||
newConfig.includes('alias: gemini-3.2-pro-preview'),
|
||||
'Should preserve manual Pro preview overrides on built-in alias names'
|
||||
);
|
||||
assert(
|
||||
newConfig.includes('alias: gemini-3.2-flash-preview'),
|
||||
'Should preserve manual Flash preview overrides on built-in alias names'
|
||||
);
|
||||
assert(
|
||||
newConfig.includes('alias: gemini-3.2-pro-preview-customtools'),
|
||||
'Should still expand compatibility aliases for preserved manual Pro override'
|
||||
);
|
||||
assert(
|
||||
newConfig.includes('alias: gemini-3.2-flash-preview-customtools'),
|
||||
'Should still expand compatibility aliases for preserved manual Flash override'
|
||||
);
|
||||
|
||||
const lines = newConfig.split('\n');
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].includes('alias: gemini-3.2-flash-preview')) {
|
||||
assert(
|
||||
lines[i + 1] && lines[i + 1].trim() === 'fork: true',
|
||||
'Should preserve fork: true on manual Flash preview override'
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('preserves user-added aliases with fork during regeneration', () => {
|
||||
const cliproxyDir = path.join(testDir, '.ccs', 'cliproxy');
|
||||
fs.mkdirSync(cliproxyDir, { recursive: true });
|
||||
|
||||
Reference in new issue
Block a user