mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-05 12:22:35 +00:00
fix(delegation): improve profile discovery and CI workflow (#310)
* fix(doctor): use dynamic profile discovery for delegation check Replace hardcoded ['glm', 'kimi'] list with DelegationValidator.getReadyProfiles() to detect all configured *.settings.json profiles including mm, or1, g7, etc. * fix(ci): exclude bot comments from triggering AI review Bot progress comments were triggering new workflow runs, which cancelled in-progress reviews due to concurrency group. Added check for github.event.comment.user.type != 'Bot'. * chore(release): 7.18.0-dev.1 [skip ci] * 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. * chore(release): 7.18.0-dev.2 [skip ci] --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
github-actions[bot] <github-actions[bot]@users.noreply.github.com>
parent
f290aae4cb
commit
affdaead80
@@ -38,13 +38,14 @@ jobs:
|
|||||||
|
|
||||||
# Conditions:
|
# Conditions:
|
||||||
# - PR event: only on opened (not synchronize to avoid cancel-on-push)
|
# - PR event: only on opened (not synchronize to avoid cancel-on-push)
|
||||||
# - Comment event: only if it's a PR and contains /review
|
# - Comment event: only if it's a PR, contains /review, and NOT from a bot
|
||||||
if: >
|
if: >
|
||||||
github.event_name == 'pull_request_target' ||
|
github.event_name == 'pull_request_target' ||
|
||||||
github.event_name == 'workflow_dispatch' ||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
(github.event_name == 'issue_comment' &&
|
(github.event_name == 'issue_comment' &&
|
||||||
github.event.issue.pull_request &&
|
github.event.issue.pull_request &&
|
||||||
contains(github.event.comment.body, '/review'))
|
contains(github.event.comment.body, '/review') &&
|
||||||
|
github.event.comment.user.type != 'Bot')
|
||||||
|
|
||||||
# CLIProxy environment for model routing
|
# CLIProxy environment for model routing
|
||||||
env:
|
env:
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kaitranntt/ccs",
|
"name": "@kaitranntt/ccs",
|
||||||
"version": "7.18.0",
|
"version": "7.18.0-dev.2",
|
||||||
"description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
|
"description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"cli",
|
"cli",
|
||||||
|
|||||||
@@ -193,16 +193,9 @@ export class DelegationChecker implements IHealthChecker {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check profile validity using DelegationValidator
|
// Check profile validity using DelegationValidator (dynamic discovery)
|
||||||
const { DelegationValidator } = require('../../utils/delegation-validator');
|
const { DelegationValidator } = require('../../utils/delegation-validator');
|
||||||
const readyProfiles: string[] = [];
|
const readyProfiles = DelegationValidator.getReadyProfiles();
|
||||||
|
|
||||||
for (const profile of ['glm', 'kimi']) {
|
|
||||||
const validation = DelegationValidator.validate(profile);
|
|
||||||
if (validation.valid) {
|
|
||||||
readyProfiles.push(profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readyProfiles.length === 0) {
|
if (readyProfiles.length === 0) {
|
||||||
spinner.warn();
|
spinner.warn();
|
||||||
|
|||||||
@@ -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