mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 08:15:17 +00:00
fix(delegation): only check profiles defined in config.yaml
Previously getReadyProfiles() scanned all *.settings.json files, including orphan files (ghcp, kiro) not in config.yaml. Now reads from config.yaml: - profiles section (excluding 'default') - cliproxy.providers section Fixes doctor showing 11 profiles instead of configured 9.
This commit is contained in:
1 parent
150b08fa6e
commit
0075248273
1 file changed
+30
-8
@@ -139,27 +139,49 @@ export class DelegationValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all delegation-ready profiles
|
* Get all delegation-ready profiles from config.yaml
|
||||||
|
* Only returns profiles explicitly defined in config, not orphan settings files
|
||||||
* @returns List of profile names ready for delegation
|
* @returns List of profile names ready for delegation
|
||||||
*/
|
*/
|
||||||
static getReadyProfiles(): string[] {
|
static getReadyProfiles(): string[] {
|
||||||
const homeDir = os.homedir();
|
const homeDir = os.homedir();
|
||||||
const ccsDir = path.join(homeDir, '.ccs');
|
const ccsDir = path.join(homeDir, '.ccs');
|
||||||
|
const configPath = path.join(ccsDir, 'config.yaml');
|
||||||
|
|
||||||
if (!fs.existsSync(ccsDir)) {
|
if (!fs.existsSync(ccsDir)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const profiles: string[] = [];
|
const profiles: string[] = [];
|
||||||
const entries = fs.readdirSync(ccsDir, { withFileTypes: true });
|
|
||||||
|
|
||||||
// Look for *.settings.json files
|
// Get profiles from config.yaml (excludes 'default' which uses ~/.claude/settings.json)
|
||||||
for (const entry of entries) {
|
if (fs.existsSync(configPath)) {
|
||||||
if (entry.isFile() && entry.name.endsWith('.settings.json')) {
|
try {
|
||||||
const profileName = entry.name.replace('.settings.json', '');
|
const yaml = require('js-yaml');
|
||||||
if (this.isReady(profileName)) {
|
const content = fs.readFileSync(configPath, 'utf8');
|
||||||
profiles.push(profileName);
|
const config = yaml.load(content) as Record<string, unknown>;
|
||||||
|
|
||||||
|
if (config.profiles && typeof config.profiles === 'object') {
|
||||||
|
for (const profileName of Object.keys(config.profiles as object)) {
|
||||||
|
if (profileName !== 'default' && this.isReady(profileName)) {
|
||||||
|
profiles.push(profileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also check CLIProxy providers (gemini, codex, agy, etc.)
|
||||||
|
if (config.cliproxy && typeof config.cliproxy === 'object') {
|
||||||
|
const cliproxy = config.cliproxy as Record<string, unknown>;
|
||||||
|
if (Array.isArray(cliproxy.providers)) {
|
||||||
|
for (const provider of cliproxy.providers) {
|
||||||
|
if (typeof provider === 'string' && this.isReady(provider)) {
|
||||||
|
profiles.push(provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Config parse error, fall back to empty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user