ccgx-workflow 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +469 -0
- package/README.zh-CN.md +466 -0
- package/bin/ccg.mjs +2 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +173 -0
- package/dist/index.d.mts +1774 -0
- package/dist/index.d.ts +1774 -0
- package/dist/index.mjs +2029 -0
- package/dist/shared/ccgx-workflow.WgUzkiC3.mjs +5248 -0
- package/package.json +129 -0
- package/templates/commands/agents/assumptions-analyzer.md +129 -0
- package/templates/commands/agents/code-fixer.md +292 -0
- package/templates/commands/agents/codebase-mapper.md +152 -0
- package/templates/commands/agents/debug-session-manager.md +247 -0
- package/templates/commands/agents/debugger.md +111 -0
- package/templates/commands/agents/eval-auditor.md +171 -0
- package/templates/commands/agents/framework-selector.md +152 -0
- package/templates/commands/agents/get-current-datetime.md +29 -0
- package/templates/commands/agents/init-architect.md +114 -0
- package/templates/commands/agents/integration-checker.md +163 -0
- package/templates/commands/agents/interface-auditor.md +170 -0
- package/templates/commands/agents/nyquist-auditor.md +131 -0
- package/templates/commands/agents/pattern-mapper.md +111 -0
- package/templates/commands/agents/phase-runner.md +321 -0
- package/templates/commands/agents/plan-checker.md +255 -0
- package/templates/commands/agents/planner.md +320 -0
- package/templates/commands/agents/team-architect.md +186 -0
- package/templates/commands/agents/team-qa.md +121 -0
- package/templates/commands/agents/team-reviewer.md +157 -0
- package/templates/commands/agents/ui-ux-designer.md +573 -0
- package/templates/commands/agents/verifier.md +274 -0
- package/templates/commands/analyze.md +210 -0
- package/templates/commands/autonomous.md +792 -0
- package/templates/commands/cancel.md +132 -0
- package/templates/commands/clean-branches.md +117 -0
- package/templates/commands/codex-exec.md +404 -0
- package/templates/commands/commit.md +151 -0
- package/templates/commands/context.md +332 -0
- package/templates/commands/debate.md +165 -0
- package/templates/commands/debug.md +226 -0
- package/templates/commands/enhance.md +64 -0
- package/templates/commands/execute.md +380 -0
- package/templates/commands/init.md +123 -0
- package/templates/commands/optimize.md +217 -0
- package/templates/commands/plan.md +373 -0
- package/templates/commands/result.md +106 -0
- package/templates/commands/review.md +338 -0
- package/templates/commands/rollback.md +116 -0
- package/templates/commands/spec-impl.md +139 -0
- package/templates/commands/spec-init.md +101 -0
- package/templates/commands/spec-plan.md +210 -0
- package/templates/commands/spec-research.md +152 -0
- package/templates/commands/spec-review.md +120 -0
- package/templates/commands/status.md +206 -0
- package/templates/commands/team-exec.md +265 -0
- package/templates/commands/test.md +236 -0
- package/templates/commands/verify-work.md +338 -0
- package/templates/commands/verify.md +66 -0
- package/templates/commands/workflow.md +190 -0
- package/templates/commands/worktree.md +128 -0
- package/templates/hooks/ccg-context-monitor.js +159 -0
- package/templates/hooks/ccg-session-state.cjs +510 -0
- package/templates/hooks/ccg-statusline.js +142 -0
- package/templates/output-styles/abyss-command.md +56 -0
- package/templates/output-styles/abyss-concise.md +89 -0
- package/templates/output-styles/abyss-cultivator.md +302 -0
- package/templates/output-styles/abyss-ritual.md +70 -0
- package/templates/output-styles/engineer-professional.md +89 -0
- package/templates/output-styles/laowang-engineer.md +127 -0
- package/templates/output-styles/nekomata-engineer.md +120 -0
- package/templates/output-styles/ojousama-engineer.md +121 -0
- package/templates/prompts/claude/analyzer.md +59 -0
- package/templates/prompts/claude/architect.md +54 -0
- package/templates/prompts/claude/debugger.md +71 -0
- package/templates/prompts/claude/optimizer.md +73 -0
- package/templates/prompts/claude/reviewer.md +63 -0
- package/templates/prompts/claude/tester.md +69 -0
- package/templates/prompts/codex/analyzer.md +58 -0
- package/templates/prompts/codex/architect.md +54 -0
- package/templates/prompts/codex/debugger.md +74 -0
- package/templates/prompts/codex/optimizer.md +81 -0
- package/templates/prompts/codex/reviewer.md +73 -0
- package/templates/prompts/codex/tester.md +62 -0
- package/templates/prompts/gemini/analyzer.md +61 -0
- package/templates/prompts/gemini/architect.md +55 -0
- package/templates/prompts/gemini/debugger.md +78 -0
- package/templates/prompts/gemini/frontend.md +64 -0
- package/templates/prompts/gemini/optimizer.md +84 -0
- package/templates/prompts/gemini/reviewer.md +80 -0
- package/templates/prompts/gemini/tester.md +68 -0
- package/templates/rules/ccg-skill-routing.md +83 -0
- package/templates/rules/ccg-skills.md +71 -0
- package/templates/scripts/ccg-phase-runner-launcher.mjs +467 -0
- package/templates/scripts/invoke-model.mjs +949 -0
- package/templates/scripts/repatch-gemini-plugin.mjs +194 -0
- package/templates/skills/SKILL.md +92 -0
- package/templates/skills/domains/ai/SKILL.md +35 -0
- package/templates/skills/domains/ai/agent-dev.md +242 -0
- package/templates/skills/domains/ai/llm-security.md +288 -0
- package/templates/skills/domains/ai/prompt-and-eval.md +279 -0
- package/templates/skills/domains/ai/rag-system.md +542 -0
- package/templates/skills/domains/architecture/SKILL.md +43 -0
- package/templates/skills/domains/architecture/api-design.md +225 -0
- package/templates/skills/domains/architecture/caching.md +299 -0
- package/templates/skills/domains/architecture/cloud-native.md +285 -0
- package/templates/skills/domains/architecture/message-queue.md +329 -0
- package/templates/skills/domains/architecture/security-arch.md +297 -0
- package/templates/skills/domains/data-engineering/SKILL.md +208 -0
- package/templates/skills/domains/development/SKILL.md +47 -0
- package/templates/skills/domains/development/cpp.md +246 -0
- package/templates/skills/domains/development/go.md +323 -0
- package/templates/skills/domains/development/java.md +277 -0
- package/templates/skills/domains/development/python.md +288 -0
- package/templates/skills/domains/development/rust.md +313 -0
- package/templates/skills/domains/development/shell.md +313 -0
- package/templates/skills/domains/development/typescript.md +277 -0
- package/templates/skills/domains/devops/SKILL.md +40 -0
- package/templates/skills/domains/devops/cost-optimization.md +272 -0
- package/templates/skills/domains/devops/database.md +217 -0
- package/templates/skills/domains/devops/devsecops.md +198 -0
- package/templates/skills/domains/devops/git-workflow.md +181 -0
- package/templates/skills/domains/devops/observability.md +280 -0
- package/templates/skills/domains/devops/performance.md +336 -0
- package/templates/skills/domains/devops/testing.md +283 -0
- package/templates/skills/domains/frontend-design/SKILL.md +244 -0
- package/templates/skills/domains/frontend-design/agents/openai.yaml +4 -0
- package/templates/skills/domains/frontend-design/claymorphism/SKILL.md +121 -0
- package/templates/skills/domains/frontend-design/claymorphism/references/tokens.css +52 -0
- package/templates/skills/domains/frontend-design/component-patterns.md +202 -0
- package/templates/skills/domains/frontend-design/engineering.md +287 -0
- package/templates/skills/domains/frontend-design/glassmorphism/SKILL.md +142 -0
- package/templates/skills/domains/frontend-design/glassmorphism/references/tokens.css +32 -0
- package/templates/skills/domains/frontend-design/liquid-glass/SKILL.md +139 -0
- package/templates/skills/domains/frontend-design/liquid-glass/references/tokens.css +81 -0
- package/templates/skills/domains/frontend-design/neubrutalism/SKILL.md +145 -0
- package/templates/skills/domains/frontend-design/neubrutalism/references/tokens.css +44 -0
- package/templates/skills/domains/frontend-design/reference/color-and-contrast.md +132 -0
- package/templates/skills/domains/frontend-design/reference/interaction-design.md +195 -0
- package/templates/skills/domains/frontend-design/reference/motion-design.md +99 -0
- package/templates/skills/domains/frontend-design/reference/responsive-design.md +114 -0
- package/templates/skills/domains/frontend-design/reference/spatial-design.md +100 -0
- package/templates/skills/domains/frontend-design/reference/typography.md +133 -0
- package/templates/skills/domains/frontend-design/reference/ux-writing.md +107 -0
- package/templates/skills/domains/frontend-design/state-management.md +680 -0
- package/templates/skills/domains/frontend-design/ui-aesthetics.md +110 -0
- package/templates/skills/domains/frontend-design/ux-principles.md +156 -0
- package/templates/skills/domains/infrastructure/SKILL.md +201 -0
- package/templates/skills/domains/mobile/SKILL.md +225 -0
- package/templates/skills/domains/orchestration/SKILL.md +30 -0
- package/templates/skills/domains/orchestration/multi-agent.md +263 -0
- package/templates/skills/domains/security/SKILL.md +73 -0
- package/templates/skills/domains/security/blue-team.md +436 -0
- package/templates/skills/domains/security/code-audit.md +265 -0
- package/templates/skills/domains/security/pentest.md +226 -0
- package/templates/skills/domains/security/red-team.md +374 -0
- package/templates/skills/domains/security/threat-intel.md +372 -0
- package/templates/skills/domains/security/vuln-research.md +369 -0
- package/templates/skills/impeccable/adapt/SKILL.md +201 -0
- package/templates/skills/impeccable/animate/SKILL.md +176 -0
- package/templates/skills/impeccable/arrange/SKILL.md +126 -0
- package/templates/skills/impeccable/audit/SKILL.md +149 -0
- package/templates/skills/impeccable/bolder/SKILL.md +118 -0
- package/templates/skills/impeccable/clarify/SKILL.md +185 -0
- package/templates/skills/impeccable/colorize/SKILL.md +144 -0
- package/templates/skills/impeccable/critique/SKILL.md +203 -0
- package/templates/skills/impeccable/critique/reference/cognitive-load.md +106 -0
- package/templates/skills/impeccable/critique/reference/heuristics-scoring.md +234 -0
- package/templates/skills/impeccable/critique/reference/personas.md +178 -0
- package/templates/skills/impeccable/delight/SKILL.md +305 -0
- package/templates/skills/impeccable/distill/SKILL.md +123 -0
- package/templates/skills/impeccable/extract/SKILL.md +94 -0
- package/templates/skills/impeccable/harden/SKILL.md +357 -0
- package/templates/skills/impeccable/normalize/SKILL.md +72 -0
- package/templates/skills/impeccable/onboard/SKILL.md +248 -0
- package/templates/skills/impeccable/optimize/SKILL.md +268 -0
- package/templates/skills/impeccable/overdrive/SKILL.md +143 -0
- package/templates/skills/impeccable/polish/SKILL.md +205 -0
- package/templates/skills/impeccable/quieter/SKILL.md +104 -0
- package/templates/skills/impeccable/teach-impeccable/SKILL.md +72 -0
- package/templates/skills/impeccable/typeset/SKILL.md +117 -0
- package/templates/skills/orchestration/multi-agent/SKILL.md +533 -0
- package/templates/skills/run_skill.js +129 -0
- package/templates/skills/scrapling/SKILL.md +98 -0
- package/templates/skills/scrapling/references/api-quick-ref.md +127 -0
- package/templates/skills/scrapling/references/cookie-vault.md +56 -0
- package/templates/skills/scrapling/references/maintenance.md +79 -0
- package/templates/skills/scrapling/references/site-patterns.md +86 -0
- package/templates/skills/scrapling/references/troubleshooting.md +95 -0
- package/templates/skills/scrapling/templates/basic_fetch.py +19 -0
- package/templates/skills/scrapling/templates/parse_only.py +15 -0
- package/templates/skills/scrapling/templates/session_login.py +19 -0
- package/templates/skills/scrapling/templates/stealth_cloudflare.py +28 -0
- package/templates/skills/tools/extract-learnings/SKILL.md +77 -0
- package/templates/skills/tools/forensics/SKILL.md +89 -0
- package/templates/skills/tools/gen-docs/SKILL.md +116 -0
- package/templates/skills/tools/gen-docs/scripts/doc_generator.js +435 -0
- package/templates/skills/tools/health/SKILL.md +121 -0
- package/templates/skills/tools/lib/shared.js +98 -0
- package/templates/skills/tools/map-codebase/SKILL.md +118 -0
- package/templates/skills/tools/override-refusal/SKILL.md +53 -0
- package/templates/skills/tools/override-refusal/agents/openai.yaml +4 -0
- package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -0
- package/templates/skills/tools/verify-change/SKILL.md +143 -0
- package/templates/skills/tools/verify-change/scripts/change_analyzer.js +289 -0
- package/templates/skills/tools/verify-module/SKILL.md +130 -0
- package/templates/skills/tools/verify-module/scripts/module_scanner.js +171 -0
- package/templates/skills/tools/verify-quality/SKILL.md +163 -0
- package/templates/skills/tools/verify-quality/scripts/quality_checker.js +337 -0
- package/templates/skills/tools/verify-security/SKILL.md +146 -0
- package/templates/skills/tools/verify-security/scripts/security_scanner.js +283 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1774 @@
|
|
|
1
|
+
import * as i18next from 'i18next';
|
|
2
|
+
|
|
3
|
+
interface CliOptions {
|
|
4
|
+
lang?: SupportedLang;
|
|
5
|
+
force?: boolean;
|
|
6
|
+
skipPrompt?: boolean;
|
|
7
|
+
skipMcp?: boolean;
|
|
8
|
+
frontend?: string;
|
|
9
|
+
backend?: string;
|
|
10
|
+
mode?: CollaborationMode;
|
|
11
|
+
workflows?: string;
|
|
12
|
+
installDir?: string;
|
|
13
|
+
/** v4.1-p18: --sync mode, list locally-installed CCG files no longer in templates */
|
|
14
|
+
sync?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type SupportedLang = 'zh-CN' | 'en';
|
|
18
|
+
type ModelType = 'codex' | 'gemini' | 'claude';
|
|
19
|
+
type CollaborationMode = 'parallel' | 'smart' | 'sequential';
|
|
20
|
+
type RoutingStrategy = 'parallel' | 'fallback' | 'round-robin';
|
|
21
|
+
interface ModelRouting {
|
|
22
|
+
frontend: {
|
|
23
|
+
models: ModelType[];
|
|
24
|
+
primary: ModelType;
|
|
25
|
+
strategy: RoutingStrategy;
|
|
26
|
+
};
|
|
27
|
+
backend: {
|
|
28
|
+
models: ModelType[];
|
|
29
|
+
primary: ModelType;
|
|
30
|
+
strategy: RoutingStrategy;
|
|
31
|
+
};
|
|
32
|
+
review: {
|
|
33
|
+
models: ModelType[];
|
|
34
|
+
strategy: 'parallel';
|
|
35
|
+
};
|
|
36
|
+
mode: CollaborationMode;
|
|
37
|
+
geminiModel?: string;
|
|
38
|
+
}
|
|
39
|
+
interface CcgConfig {
|
|
40
|
+
general: {
|
|
41
|
+
version: string;
|
|
42
|
+
language: SupportedLang;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
};
|
|
45
|
+
routing: ModelRouting;
|
|
46
|
+
workflows: {
|
|
47
|
+
installed: string[];
|
|
48
|
+
};
|
|
49
|
+
paths: {
|
|
50
|
+
commands: string;
|
|
51
|
+
prompts: string;
|
|
52
|
+
backup: string;
|
|
53
|
+
};
|
|
54
|
+
mcp: {
|
|
55
|
+
provider: string;
|
|
56
|
+
setup_url: string;
|
|
57
|
+
};
|
|
58
|
+
performance?: {
|
|
59
|
+
liteMode?: boolean;
|
|
60
|
+
skipImpeccable?: boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
interface WorkflowConfig {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
nameEn: string;
|
|
67
|
+
category: string;
|
|
68
|
+
commands: string[];
|
|
69
|
+
defaultSelected: boolean;
|
|
70
|
+
order: number;
|
|
71
|
+
description?: string;
|
|
72
|
+
descriptionEn?: string;
|
|
73
|
+
}
|
|
74
|
+
interface InitOptions {
|
|
75
|
+
lang?: SupportedLang;
|
|
76
|
+
skipPrompt?: boolean;
|
|
77
|
+
skipMcp?: boolean;
|
|
78
|
+
force?: boolean;
|
|
79
|
+
frontend?: string;
|
|
80
|
+
backend?: string;
|
|
81
|
+
mode?: CollaborationMode;
|
|
82
|
+
workflows?: string;
|
|
83
|
+
installDir?: string;
|
|
84
|
+
/** v4.1-p18: --sync mode (read-only diff, prompt user to delete stale files) */
|
|
85
|
+
sync?: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface InstallResult {
|
|
88
|
+
success: boolean;
|
|
89
|
+
installedCommands: string[];
|
|
90
|
+
installedPrompts: string[];
|
|
91
|
+
installedSkills?: number;
|
|
92
|
+
installedSkillCommands?: number;
|
|
93
|
+
installedRules?: boolean;
|
|
94
|
+
errors: string[];
|
|
95
|
+
configPath: string;
|
|
96
|
+
binPath?: string;
|
|
97
|
+
binInstalled?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface AceToolConfig {
|
|
100
|
+
baseUrl: string;
|
|
101
|
+
token: string;
|
|
102
|
+
}
|
|
103
|
+
interface FastContextConfig {
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
includeSnippets?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare function init(options?: InitOptions): Promise<void>;
|
|
109
|
+
|
|
110
|
+
declare function showMainMenu(): Promise<void>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Main update command - checks for updates and installs if available
|
|
114
|
+
*/
|
|
115
|
+
declare function update(): Promise<void>;
|
|
116
|
+
|
|
117
|
+
declare const i18n: i18next.i18n;
|
|
118
|
+
declare function initI18n(lang?: SupportedLang): Promise<void>;
|
|
119
|
+
declare function changeLanguage(lang: SupportedLang): Promise<void>;
|
|
120
|
+
|
|
121
|
+
declare function getCcgDir(): string;
|
|
122
|
+
declare function getConfigPath(): string;
|
|
123
|
+
declare function readCcgConfig(): Promise<CcgConfig | null>;
|
|
124
|
+
declare function writeCcgConfig(config: CcgConfig): Promise<void>;
|
|
125
|
+
declare function createDefaultConfig(options: {
|
|
126
|
+
language: SupportedLang;
|
|
127
|
+
routing: ModelRouting;
|
|
128
|
+
installedWorkflows: string[];
|
|
129
|
+
mcpProvider?: string;
|
|
130
|
+
liteMode?: boolean;
|
|
131
|
+
skipImpeccable?: boolean;
|
|
132
|
+
}): CcgConfig;
|
|
133
|
+
declare function createDefaultRouting(): ModelRouting;
|
|
134
|
+
|
|
135
|
+
declare function getWorkflowConfigs(): WorkflowConfig[];
|
|
136
|
+
declare function getWorkflowById(id: string): WorkflowConfig | undefined;
|
|
137
|
+
|
|
138
|
+
type McpInstallResult = {
|
|
139
|
+
success: boolean;
|
|
140
|
+
message: string;
|
|
141
|
+
configPath?: string;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Uninstall ace-tool MCP configuration from ~/.claude.json
|
|
145
|
+
*/
|
|
146
|
+
declare function uninstallAceTool(): Promise<{
|
|
147
|
+
success: boolean;
|
|
148
|
+
message: string;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Install and configure ace-tool MCP for Claude Code.
|
|
152
|
+
*/
|
|
153
|
+
declare function installAceTool(config: AceToolConfig): Promise<McpInstallResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Install and configure ace-tool-rs MCP for Claude Code.
|
|
156
|
+
* ace-tool-rs is a Rust implementation — more lightweight and faster.
|
|
157
|
+
*/
|
|
158
|
+
declare function installAceToolRs(config: AceToolConfig): Promise<McpInstallResult>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Skill Registry — SKILL.md frontmatter 驱动的技能发现与命令生成
|
|
162
|
+
*
|
|
163
|
+
* 移植自 code-abyss skill-registry.js,TypeScript 化。
|
|
164
|
+
* 核心功能:
|
|
165
|
+
* 1. 递归扫描 templates/skills/ 下所有 SKILL.md
|
|
166
|
+
* 2. 解析 frontmatter 提取 name/description/user-invocable 等元数据
|
|
167
|
+
* 3. 为 user-invocable=true 的技能自动生成 slash commands
|
|
168
|
+
*/
|
|
169
|
+
type SkillCategory = 'tool' | 'domain' | 'orchestration' | 'impeccable' | 'root';
|
|
170
|
+
type SkillRuntimeType = 'scripted' | 'knowledge';
|
|
171
|
+
interface SkillMeta {
|
|
172
|
+
/** kebab-case slug, e.g. 'red-team' */
|
|
173
|
+
name: string;
|
|
174
|
+
/** Human-readable description */
|
|
175
|
+
description: string;
|
|
176
|
+
/** Whether to auto-generate a slash command */
|
|
177
|
+
userInvocable: boolean;
|
|
178
|
+
/** Allowed Claude tools for this skill */
|
|
179
|
+
allowedTools: string[];
|
|
180
|
+
/** Argument hint shown to user, e.g. '[target]' */
|
|
181
|
+
argumentHint: string;
|
|
182
|
+
/** Optional aliases for the skill name */
|
|
183
|
+
aliases: string[];
|
|
184
|
+
/** Inferred from directory: tool/domain/orchestration/impeccable/root */
|
|
185
|
+
category: SkillCategory;
|
|
186
|
+
/** scripted (has scripts/) or knowledge (no scripts) */
|
|
187
|
+
runtimeType: SkillRuntimeType;
|
|
188
|
+
/** Relative path from skills root, e.g. 'domains/security' */
|
|
189
|
+
relPath: string;
|
|
190
|
+
/** Absolute path to the SKILL.md file */
|
|
191
|
+
skillPath: string;
|
|
192
|
+
/** Absolute path to the script .js file (if scripted) */
|
|
193
|
+
scriptPath: string | null;
|
|
194
|
+
/**
|
|
195
|
+
* v4.1-p19: Context isolation hint.
|
|
196
|
+
* - `fork`: heavy skills should be loaded in fresh-context subagent (domains/impeccable)
|
|
197
|
+
* - `inline` (default): lightweight skills loaded in main thread (tools/)
|
|
198
|
+
*/
|
|
199
|
+
context: 'fork' | 'inline';
|
|
200
|
+
/**
|
|
201
|
+
* v4.1-p19: Glob path filters.
|
|
202
|
+
* Skill is only activated when matching files exist (e.g. *.tsx for frontend skills).
|
|
203
|
+
* Empty array = always active.
|
|
204
|
+
*/
|
|
205
|
+
paths: string[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Parse YAML frontmatter from a markdown file.
|
|
209
|
+
* Returns a plain key-value object, or null if no frontmatter found.
|
|
210
|
+
*/
|
|
211
|
+
declare function parseFrontmatter(content: string): Record<string, string> | null;
|
|
212
|
+
/**
|
|
213
|
+
* Recursively scan a skills directory and collect all valid skill definitions.
|
|
214
|
+
*/
|
|
215
|
+
declare function collectSkills(skillsDir: string): SkillMeta[];
|
|
216
|
+
/**
|
|
217
|
+
* Collect only user-invocable skills.
|
|
218
|
+
*/
|
|
219
|
+
declare function collectInvocableSkills(skillsDir: string): SkillMeta[];
|
|
220
|
+
/**
|
|
221
|
+
* Generate slash command content for a user-invocable skill.
|
|
222
|
+
*
|
|
223
|
+
* For knowledge skills: instructs Claude to read the SKILL.md and follow its guidance.
|
|
224
|
+
* For scripted skills: runs the script via run_skill.js.
|
|
225
|
+
*/
|
|
226
|
+
declare function generateCommandContent(skill: SkillMeta, skillsInstallDir: string): string;
|
|
227
|
+
/**
|
|
228
|
+
* Install auto-generated commands for all user-invocable skills.
|
|
229
|
+
*
|
|
230
|
+
* @param skillsTemplateDir - Path to templates/skills/ (source)
|
|
231
|
+
* @param skillsInstallDir - Path to ~/.claude/skills/ccg/ (installed destination)
|
|
232
|
+
* @param commandsDir - Path to ~/.claude/commands/ccg/ (command output)
|
|
233
|
+
* @param existingCommandNames - Set of command names already defined in installer-data.ts (to avoid conflicts)
|
|
234
|
+
* @returns List of generated command names
|
|
235
|
+
*/
|
|
236
|
+
declare function installSkillCommands(skillsTemplateDir: string, skillsInstallDir: string, commandsDir: string, existingCommandNames: Set<string>, skipCategories?: SkillCategory[]): Promise<string[]>;
|
|
237
|
+
|
|
238
|
+
declare function installWorkflows(workflowIds: string[], installDir: string, force?: boolean, config?: {
|
|
239
|
+
routing?: {
|
|
240
|
+
mode?: string;
|
|
241
|
+
frontend?: {
|
|
242
|
+
models?: string[];
|
|
243
|
+
primary?: string;
|
|
244
|
+
};
|
|
245
|
+
backend?: {
|
|
246
|
+
models?: string[];
|
|
247
|
+
primary?: string;
|
|
248
|
+
};
|
|
249
|
+
review?: {
|
|
250
|
+
models?: string[];
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
liteMode?: boolean;
|
|
254
|
+
mcpProvider?: string;
|
|
255
|
+
skipImpeccable?: boolean;
|
|
256
|
+
}): Promise<InstallResult>;
|
|
257
|
+
interface UninstallResult {
|
|
258
|
+
success: boolean;
|
|
259
|
+
removedCommands: string[];
|
|
260
|
+
removedPrompts: string[];
|
|
261
|
+
removedAgents: string[];
|
|
262
|
+
removedSkills: string[];
|
|
263
|
+
removedRules: boolean;
|
|
264
|
+
removedBin: boolean;
|
|
265
|
+
errors: string[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Uninstall workflows by removing their command files.
|
|
269
|
+
* @param options.preserveBinary — when true, skip binary removal (used during update)
|
|
270
|
+
*/
|
|
271
|
+
declare function uninstallWorkflows(installDir: string, options?: {
|
|
272
|
+
preserveBinary?: boolean;
|
|
273
|
+
}): Promise<UninstallResult>;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Migration utilities for v1.4.0
|
|
277
|
+
* Handles automatic migration from old directory structure to new one
|
|
278
|
+
*/
|
|
279
|
+
interface MigrationResult {
|
|
280
|
+
success: boolean;
|
|
281
|
+
migratedFiles: string[];
|
|
282
|
+
errors: string[];
|
|
283
|
+
skipped: string[];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Migrate from v1.3.x to v1.4.0
|
|
287
|
+
*
|
|
288
|
+
* Changes:
|
|
289
|
+
* 1. ~/.ccg/ → ~/.claude/.ccg/
|
|
290
|
+
* 2. ~/.claude/prompts/ccg/ → ~/.claude/.ccg/prompts/
|
|
291
|
+
*/
|
|
292
|
+
declare function migrateToV1_4_0(): Promise<MigrationResult>;
|
|
293
|
+
/**
|
|
294
|
+
* Check if migration is needed
|
|
295
|
+
*/
|
|
296
|
+
declare function needsMigration(): Promise<boolean>;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Get current installed version from package.json
|
|
300
|
+
*/
|
|
301
|
+
declare function getCurrentVersion(): Promise<string>;
|
|
302
|
+
/**
|
|
303
|
+
* Get latest version from npm registry
|
|
304
|
+
*/
|
|
305
|
+
declare function getLatestVersion(packageName?: string): Promise<string | null>;
|
|
306
|
+
/**
|
|
307
|
+
* Compare two semantic versions
|
|
308
|
+
* @returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal
|
|
309
|
+
*/
|
|
310
|
+
declare function compareVersions(v1: string, v2: string): number;
|
|
311
|
+
/**
|
|
312
|
+
* Check if update is available
|
|
313
|
+
*/
|
|
314
|
+
declare function checkForUpdates(): Promise<{
|
|
315
|
+
hasUpdate: boolean;
|
|
316
|
+
currentVersion: string;
|
|
317
|
+
latestVersion: string | null;
|
|
318
|
+
}>;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Phase-scoped context state machine (v4.0 Phase 2).
|
|
322
|
+
*
|
|
323
|
+
* Manages `.context/<phase>/{CONTEXT,SUMMARY}.md` files that decouple the
|
|
324
|
+
* orchestrator (main thread) from builder subagents:
|
|
325
|
+
*
|
|
326
|
+
* - CONTEXT.md — frozen decisions from /ccg:plan, consumed by downstream
|
|
327
|
+
* plan/exec stages. Markdown body is human-readable; YAML
|
|
328
|
+
* frontmatter is machine-readable.
|
|
329
|
+
* - SUMMARY.md — machine-readable frontmatter written by /ccg:execute
|
|
330
|
+
* (and team-exec) after each plan completes. The orchestrator
|
|
331
|
+
* reads ONLY the frontmatter (< 200 tokens / phase) instead of
|
|
332
|
+
* piping back the full builder stdout.
|
|
333
|
+
*
|
|
334
|
+
* Token budget contract: parsing 5 SUMMARY.md frontmatters MUST stay < 1000
|
|
335
|
+
* tokens of orchestrator context (the `summaryTokenEstimate` helper makes this
|
|
336
|
+
* empirically verifiable in unit tests).
|
|
337
|
+
*/
|
|
338
|
+
interface PhaseContext {
|
|
339
|
+
phase: string;
|
|
340
|
+
plan: string;
|
|
341
|
+
goal: string;
|
|
342
|
+
decisions: string[];
|
|
343
|
+
constraints: string[];
|
|
344
|
+
files: string[];
|
|
345
|
+
createdAt: string;
|
|
346
|
+
}
|
|
347
|
+
interface PhaseSummary {
|
|
348
|
+
phase: string;
|
|
349
|
+
plan: string;
|
|
350
|
+
provides: string[];
|
|
351
|
+
affects: string[];
|
|
352
|
+
keyFiles: string[];
|
|
353
|
+
completed: boolean;
|
|
354
|
+
completedAt?: string;
|
|
355
|
+
notes?: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Resolve the directory holding phase-scoped state files.
|
|
359
|
+
* Convention: `<workdir>/.context/<phase>/`.
|
|
360
|
+
*/
|
|
361
|
+
declare function phaseDir(workdir: string, phase: string): string;
|
|
362
|
+
declare function contextPath(workdir: string, phase: string): string;
|
|
363
|
+
declare function summaryPath(workdir: string, phase: string): string;
|
|
364
|
+
/**
|
|
365
|
+
* Strip filesystem-hostile characters from a phase id so it can be used as a
|
|
366
|
+
* directory name on Windows / macOS / Linux. Keeps alphanumerics, dashes,
|
|
367
|
+
* underscores and dots; collapses everything else to `-`.
|
|
368
|
+
*/
|
|
369
|
+
declare function sanitizePhase(phase: string): string;
|
|
370
|
+
/**
|
|
371
|
+
* Extract the YAML frontmatter block from a Markdown file. Returns `null` if
|
|
372
|
+
* the file does not start with `---\n`.
|
|
373
|
+
*/
|
|
374
|
+
declare function extractFrontmatter(content: string): string | null;
|
|
375
|
+
/**
|
|
376
|
+
* Parse a small subset of YAML — enough for SUMMARY.md frontmatter:
|
|
377
|
+
*
|
|
378
|
+
* key: scalar value
|
|
379
|
+
* key: [a, b, c]
|
|
380
|
+
* key:
|
|
381
|
+
* - a
|
|
382
|
+
* - b
|
|
383
|
+
*
|
|
384
|
+
* Quoted strings (single or double) are unwrapped. No anchors, no nested maps.
|
|
385
|
+
* Throws on malformed input — keeps parser small and predictable.
|
|
386
|
+
*/
|
|
387
|
+
declare function parseFrontmatterFields(yaml: string): Record<string, string | string[] | boolean>;
|
|
388
|
+
/**
|
|
389
|
+
* Write `.context/<phase>/CONTEXT.md` capturing the frozen decisions from
|
|
390
|
+
* /ccg:plan. The body is plain Markdown so it remains diffable; the
|
|
391
|
+
* frontmatter is the machine-readable contract.
|
|
392
|
+
*/
|
|
393
|
+
declare function writeContext(workdir: string, ctx: PhaseContext): string;
|
|
394
|
+
declare function readContext(workdir: string, phase: string): PhaseContext | null;
|
|
395
|
+
/**
|
|
396
|
+
* Write `.context/<phase>/SUMMARY.md`. The orchestrator must be able to make
|
|
397
|
+
* advance / retry / skip decisions reading ONLY this file's frontmatter.
|
|
398
|
+
*
|
|
399
|
+
* Frontmatter fields (acceptance b):
|
|
400
|
+
* phase, plan, provides, affects, key-files (key_files), completed,
|
|
401
|
+
* completed_at, notes
|
|
402
|
+
*/
|
|
403
|
+
declare function writeSummary(workdir: string, summary: PhaseSummary): string;
|
|
404
|
+
declare function readSummary(workdir: string, phase: string): PhaseSummary | null;
|
|
405
|
+
/**
|
|
406
|
+
* Read only the frontmatter block of SUMMARY.md without parsing the body.
|
|
407
|
+
* This is the path orchestrators (autonomous, team-exec) must take to keep
|
|
408
|
+
* context usage bounded.
|
|
409
|
+
*
|
|
410
|
+
* Returns the frontmatter raw text, or `null` if the file does not exist.
|
|
411
|
+
*/
|
|
412
|
+
declare function readSummaryFrontmatter(workdir: string, phase: string): string | null;
|
|
413
|
+
/**
|
|
414
|
+
* Estimate the orchestrator token cost of reading a frontmatter block.
|
|
415
|
+
* Conservative heuristic: ceil(chars / 3.5). Not exact tokenization, but
|
|
416
|
+
* tight enough that test assertions stay valid against real tokenizers.
|
|
417
|
+
*/
|
|
418
|
+
declare function summaryTokenEstimate(frontmatter: string): number;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Wave Scheduler (CCG v4.1 Phase 14).
|
|
422
|
+
*
|
|
423
|
+
* `/ccg:autonomous --parallel` 的依赖图调度核心。把扁平的 phase 序列按
|
|
424
|
+
* `Depends on` 字段拓扑排序成 wave(无依赖 → wave 1,依赖 wave 1 → wave 2,
|
|
425
|
+
* ...),波内 phase 没有依赖关系可主线一次性并行 spawn `Agent(phase-runner)`。
|
|
426
|
+
*
|
|
427
|
+
* 设计原则(与 v4.0 phase-context.ts / debug-session.ts 一致):
|
|
428
|
+
* - 纯函数;不读文件系统、不 spawn 子进程
|
|
429
|
+
* - 输入 markdown 字符串 / 结构化对象,输出结构化结果
|
|
430
|
+
* - 跨平台:无路径假设
|
|
431
|
+
* - 失败用 throw + 明确错误信息(依赖循环 / 引用未知 phase)
|
|
432
|
+
*
|
|
433
|
+
* 调用方:
|
|
434
|
+
* - `templates/commands/autonomous.md` Step 4.0(解析 roadmap)
|
|
435
|
+
* - `templates/commands/autonomous.md` Step 4.2(按 wave 并行 spawn)
|
|
436
|
+
*
|
|
437
|
+
* 不做:
|
|
438
|
+
* - 不实际 spawn Agent(那是主线 LLM 的职责,本 helper 只决定 wave 划分)
|
|
439
|
+
* - 不写 `.ccg/roadmap.md`(autonomous 主线唯一写者)
|
|
440
|
+
* - 不读 SUMMARY.md / state.md(与 phase-context / team-exec 协议解耦)
|
|
441
|
+
*/
|
|
442
|
+
type PhaseStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'skipped';
|
|
443
|
+
/**
|
|
444
|
+
* 单个 phase 的最小结构化记录。从 roadmap.md 的 `## Phase N: <name> (<status>)`
|
|
445
|
+
* 标题 + `- **Depends on**: ...` 行解析得到。
|
|
446
|
+
*
|
|
447
|
+
* `id` 保留为字符串以容纳 "1.5" 这类小数 phase 编号(v3.1 / v4.0 实际场景)。
|
|
448
|
+
*/
|
|
449
|
+
interface RoadmapPhase {
|
|
450
|
+
/** phase 标识,例如 "1" / "1.5" / "13" */
|
|
451
|
+
id: string;
|
|
452
|
+
/** phase 标题(不含 "Phase N: " 前缀和状态括号) */
|
|
453
|
+
name: string;
|
|
454
|
+
/** 状态括号内的关键字 */
|
|
455
|
+
status: PhaseStatus;
|
|
456
|
+
/** 依赖的 phase id 列表。`(none)` 表示空 */
|
|
457
|
+
dependsOn: string[];
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Wave 调度结果。`waves[i]` 是第 i+1 wave 内的 phase id 列表(顺序无意义,波内
|
|
461
|
+
* 可以并行)。`skipped` 是因上游 failed/skipped 而 cascade 标 blocked 的 phase。
|
|
462
|
+
*/
|
|
463
|
+
interface WaveSchedule {
|
|
464
|
+
/** waves[0] = wave 1(最先跑),waves[1] = wave 2,... */
|
|
465
|
+
waves: string[][];
|
|
466
|
+
/** cascade-skip 决策的 phase id 集合 */
|
|
467
|
+
skipped: string[];
|
|
468
|
+
/** wave-i phase 数量超过 maxConcurrent 时的批分组:batches[w][b] = wave w 第 b 批 */
|
|
469
|
+
batches?: string[][][];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* 解析 roadmap.md 文本,抽出每个 phase 的 id / name / status / dependsOn。
|
|
473
|
+
*
|
|
474
|
+
* 容错原则:
|
|
475
|
+
* - phase 标题正则不匹配的行直接忽略(roadmap.md 含里程碑总结表等噪音)
|
|
476
|
+
* - 单个 phase 没有 `- **Depends on**:` 行视为 `(none)`(向后兼容老格式)
|
|
477
|
+
* - 同一 phase 出现多次(不该发生)时后者覆盖前者并 throw
|
|
478
|
+
*
|
|
479
|
+
* 抛错场景:phase id 重复声明 / 状态值不合法
|
|
480
|
+
*/
|
|
481
|
+
declare function parseRoadmap(content: string): RoadmapPhase[];
|
|
482
|
+
/**
|
|
483
|
+
* 解析 `Depends on` 字段右侧的内容,支持:
|
|
484
|
+
* - `(none)` → []
|
|
485
|
+
* - `1` → ["1"]
|
|
486
|
+
* - `6, 8` → ["6", "8"]
|
|
487
|
+
* - `1-11` → ["1", "2", ..., "11"](整数范围;不展开 "1-1.5")
|
|
488
|
+
* - 混合:"1, 3-5, 8" → ["1", "3", "4", "5", "8"]
|
|
489
|
+
*/
|
|
490
|
+
declare function parseDependsOn(raw: string): string[];
|
|
491
|
+
/**
|
|
492
|
+
* 把 phase 列表按依赖图拓扑分波。Kahn 算法每轮选出当前没未满足依赖的 phase
|
|
493
|
+
* 集合作为下一 wave,从图中移除后继续。
|
|
494
|
+
*
|
|
495
|
+
* 行为:
|
|
496
|
+
* - 引用未知 phase(`Depends on: 99` 而无 Phase 99)→ throw
|
|
497
|
+
* - 依赖循环(A → B → A)→ throw(剩余 phase 没人能进 wave)
|
|
498
|
+
* - 输入空数组 → 返回空 waves
|
|
499
|
+
* - phase 顺序不影响 wave 分组,但同 wave 内 phase 按输入声明顺序保留
|
|
500
|
+
*
|
|
501
|
+
* @param phases 解析后的 phase 列表
|
|
502
|
+
* @returns wave 划分(waves[i] 内 phase 可并行)
|
|
503
|
+
*/
|
|
504
|
+
declare function buildWaves(phases: RoadmapPhase[]): string[][];
|
|
505
|
+
/**
|
|
506
|
+
* 计算 cascade-skip 集合:当某 phase 状态为 `failed` 或 `skipped` 时,所有
|
|
507
|
+
* 依赖(直接或间接)该 phase 的 phase 都标 skipped。
|
|
508
|
+
*
|
|
509
|
+
* 输入是已 status-标注的 phase 列表(来自 parseRoadmap 或 mock);返回
|
|
510
|
+
* **新增**应被 cascade-skip 的 phase id 集合(不重复列出已经 failed/skipped 的)。
|
|
511
|
+
*
|
|
512
|
+
* @param phases 全量 phase
|
|
513
|
+
* @returns 应 cascade-skip 的 phase id 列表(按 phase 输入顺序去重)
|
|
514
|
+
*/
|
|
515
|
+
declare function cascadeSkip(phases: RoadmapPhase[]): string[];
|
|
516
|
+
/**
|
|
517
|
+
* 把单个 wave 按 maxConcurrent 切分成多个批次(顺序执行批,批内并行)。
|
|
518
|
+
*
|
|
519
|
+
* 例:wave = [a, b, c, d, e, f],maxConcurrent = 2 → batches = [[a,b],[c,d],[e,f]]
|
|
520
|
+
*
|
|
521
|
+
* @param wave 单 wave 的 phase 列表
|
|
522
|
+
* @param maxConcurrent 每批最大并发数(≥ 1)
|
|
523
|
+
* @returns 批次数组
|
|
524
|
+
*/
|
|
525
|
+
declare function batchByMaxConcurrent(wave: string[], maxConcurrent: number): string[][];
|
|
526
|
+
interface ScheduleOptions {
|
|
527
|
+
/** 单 wave 最大并发数;省略则不分批 */
|
|
528
|
+
maxConcurrent?: number;
|
|
529
|
+
/** 是否仅调度 status=pending 或 in_progress 的 phase(默认 true,跳过 completed) */
|
|
530
|
+
skipCompleted?: boolean;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* 一站式调度:解析 → cascade skip → 拓扑分波 → 可选批分组。
|
|
534
|
+
*
|
|
535
|
+
* 完整 schedule 流程,autonomous Step 4.0 直接调用即可。
|
|
536
|
+
*
|
|
537
|
+
* @param phases 已解析的 phase 列表(来自 parseRoadmap)
|
|
538
|
+
* @param options 调度参数
|
|
539
|
+
*/
|
|
540
|
+
declare function schedule(phases: RoadmapPhase[], options?: ScheduleOptions): WaveSchedule;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Multi-Model Routing — Single Source of Truth (CCG v4.2 Phase 21).
|
|
544
|
+
*
|
|
545
|
+
* v4.1 收尾审计揭示 4 个独立路由模块(specialist-router / challenger-orchestrator /
|
|
546
|
+
* debate-orchestrator / phase-runner)各自定义 layer / model / availability 类型,
|
|
547
|
+
* 类型并集相同但 export 路径不同,导致:
|
|
548
|
+
* - 跨模块 import 时类型不互通(PluginAvailability 重复定义即一例)
|
|
549
|
+
* - 任一模块新增 layer 时其他模块不会同步
|
|
550
|
+
* - 路由假设无法集中审计
|
|
551
|
+
*
|
|
552
|
+
* 本模块作为 SSoT 把 4 个路由共用的核心 union types 全部上提到此处,
|
|
553
|
+
* 由各路由模块 re-export 给业务消费者。本模块**不实现路由逻辑**,
|
|
554
|
+
* 只统一类型;逻辑仍在各 router/orchestrator 中。
|
|
555
|
+
*
|
|
556
|
+
* 设计原则:
|
|
557
|
+
* - 纯类型 + 极少量纯函数辅助;不读文件、不 spawn
|
|
558
|
+
* - union string literal 类型(不引入 enum,与 v4.1 风格一致)
|
|
559
|
+
* - 各 router 通过 re-export 暴露给 src/index.ts,外部消费者不感知拆分
|
|
560
|
+
*
|
|
561
|
+
* 不做:
|
|
562
|
+
* - 不替代各 router 的具体路由表(routeSpecialist / planChallengerSpawns / debateStateMachine)
|
|
563
|
+
* - 不暴露已退役的 SpecialistLayer / DebateLayer / PhaseType 别名(v4.2 起统一为 Layer)
|
|
564
|
+
*/
|
|
565
|
+
/**
|
|
566
|
+
* 实施 / 对辩 / challenger / phase-runner 路由共用的 layer union。
|
|
567
|
+
*
|
|
568
|
+
* v4.1 历史:specialist-router 用 'backend' | 'frontend' | 'fullstack',
|
|
569
|
+
* debate-orchestrator 同;phase-runner 多了 'docs' | 'generic'。v4.2 起统一为
|
|
570
|
+
* 5 项并集——具体路由模块按需在 switch 里覆盖各自支持的子集。
|
|
571
|
+
*/
|
|
572
|
+
type Layer = 'backend' | 'frontend' | 'fullstack' | 'docs' | 'generic';
|
|
573
|
+
/** 所有合法 Layer 的运行期数组(保持与 type 同步) */
|
|
574
|
+
declare const ALL_LAYERS: readonly Layer[];
|
|
575
|
+
/** 类型守卫:运行期 layer 校验 */
|
|
576
|
+
declare function isLayer(value: unknown): value is Layer;
|
|
577
|
+
/**
|
|
578
|
+
* CCG 路由可达的底层模型 union。
|
|
579
|
+
* - codex / gemini:plugin subagent(Agent: `codex:codex-rescue` / `gemini:gemini-rescue` 双前缀;Skill: `codex:rescue` / `gemini:rescue` 单前缀)
|
|
580
|
+
* - claude:主线 Claude,无 external prompt
|
|
581
|
+
* - general-purpose:plugin 缺失降级(debate-orchestrator);CCG 自家 prompt 模板兜底
|
|
582
|
+
*/
|
|
583
|
+
type Model = 'codex' | 'gemini' | 'claude' | 'general-purpose';
|
|
584
|
+
/**
|
|
585
|
+
* Plugin 可用性。由 plugin-detection 模块在 orchestrator 启动前探测填充。
|
|
586
|
+
*
|
|
587
|
+
* 历史:plugin-detection.ts 与 challenger-orchestrator.ts 各定义一份完全相同的
|
|
588
|
+
* interface 各自 export 给 src/index.ts(`PluginAvailability` +
|
|
589
|
+
* `PluginDetectionAvailability` 两个名字)。v4.2 起合并为单一定义。
|
|
590
|
+
*/
|
|
591
|
+
interface PluginAvailability {
|
|
592
|
+
codex: boolean;
|
|
593
|
+
gemini: boolean;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* 跨 specialist-router / challenger 共用的语义角色 union。
|
|
597
|
+
*
|
|
598
|
+
* 历史:specialist-router 用 5 项 (architect|critic|implementer|tester|writer),
|
|
599
|
+
* challenger-orchestrator 隐式用 advisor/critic 区分。v4.2 SSoT 收并到
|
|
600
|
+
* 一个 7 项并集,各路由按需子集消费。
|
|
601
|
+
*
|
|
602
|
+
* 角色含义(参考 v4.1 各 module 注释):
|
|
603
|
+
* - architect: 建设性视角(propose/build)
|
|
604
|
+
* - critic: 对抗性视角(adversarial review)
|
|
605
|
+
* - implementer: 实施代码改动;v4.2 起 specialist-router 不再借用 architect.md
|
|
606
|
+
* - tester: 撰写测试
|
|
607
|
+
* - writer: 撰写文档 / 文案;主线 Claude 接管多数场景
|
|
608
|
+
* - advisor: challenger 中的 plugin 角色(codex/gemini rescue)
|
|
609
|
+
* - verifier: verify-work 编排里的校验角色(v4.2 P22 预留)
|
|
610
|
+
*/
|
|
611
|
+
type Role = 'architect' | 'critic' | 'implementer' | 'tester' | 'writer' | 'advisor' | 'verifier';
|
|
612
|
+
/**
|
|
613
|
+
* SSoT 模块版本号。任何 union 调整时 bump,触发依赖模块在 type-check 阶段
|
|
614
|
+
* 显式 import 此常量做兼容声明(可选;目前未强制)。
|
|
615
|
+
*/
|
|
616
|
+
declare const ROUTING_SCHEMA_VERSION: "4.2.0";
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Specialist matrix router (CCG v4.1 Phase 15)
|
|
620
|
+
*
|
|
621
|
+
* 6 core commands (`/ccg:plan`, `/ccg:analyze`, `/ccg:debug`, `/ccg:review`,
|
|
622
|
+
* `/ccg:optimize`, `/ccg:test`) accept an optional `--role=<name>` flag that
|
|
623
|
+
* selects a specialized prompt file from `templates/prompts/{codex,gemini,
|
|
624
|
+
* claude}/<role>.md`. Combined with the implicit *layer* derived from file
|
|
625
|
+
* type (backend / frontend / fullstack), this forms a 5×3 routing matrix.
|
|
626
|
+
*
|
|
627
|
+
* This module is the **single source of truth** for the matrix. Command
|
|
628
|
+
* templates (markdown) reference it conceptually via documentation; tests
|
|
629
|
+
* pin its behavior so future refactors stay in sync. Templates themselves
|
|
630
|
+
* remain plain markdown — Claude reads the `--role` flag and picks the
|
|
631
|
+
* prompt file path documented in the template's "Role-based routing"
|
|
632
|
+
* section, which in turn is generated to mirror this matrix.
|
|
633
|
+
*
|
|
634
|
+
* v4.0 backward compatibility: when `role` is omitted (`null`), callers fall
|
|
635
|
+
* back to the legacy `{{BACKEND_PRIMARY}} / {{FRONTEND_PRIMARY}}` template
|
|
636
|
+
* variable routing — i.e. nothing changes for existing users.
|
|
637
|
+
*/
|
|
638
|
+
|
|
639
|
+
type SpecialistRole = 'architect' | 'critic' | 'implementer' | 'tester' | 'writer';
|
|
640
|
+
/**
|
|
641
|
+
* Specialist 路由识别的 layer 子集。
|
|
642
|
+
* SSoT `Layer` 5 项中 specialist-router 仅消费 backend/frontend/fullstack。
|
|
643
|
+
* docs / generic 在 specialist-router 上下文不适用——由调用方在 v4.0 fallback 路由覆盖。
|
|
644
|
+
*/
|
|
645
|
+
type SpecialistLayer = Extract<Layer, 'backend' | 'frontend' | 'fullstack'>;
|
|
646
|
+
/**
|
|
647
|
+
* Which underlying model owns a given (role, layer) intersection.
|
|
648
|
+
* `claude` here means "main thread / no external model spawn".
|
|
649
|
+
*
|
|
650
|
+
* v4.2 P21 起继承自 multi-model-routing SSoT 的 Model union(取 codex/gemini/claude 子集)。
|
|
651
|
+
*/
|
|
652
|
+
type SpecialistModel = 'codex' | 'gemini' | 'claude';
|
|
653
|
+
interface SpecialistRoute {
|
|
654
|
+
/**
|
|
655
|
+
* Resolved model(s). For `fullstack` × {architect, critic} this is two
|
|
656
|
+
* models running in parallel (codex + gemini). For other slots a single
|
|
657
|
+
* model is returned.
|
|
658
|
+
*/
|
|
659
|
+
models: SpecialistModel[];
|
|
660
|
+
/**
|
|
661
|
+
* Path-relative (under `~/.claude/.ccg/prompts/<model>/`) prompt file name
|
|
662
|
+
* for each model in `models`, in the same order. `null` entries mean the
|
|
663
|
+
* main thread (Claude) handles the slot directly without an external
|
|
664
|
+
* prompt file (e.g. `writer × backend`).
|
|
665
|
+
*/
|
|
666
|
+
promptFiles: (string | null)[];
|
|
667
|
+
/**
|
|
668
|
+
* `true` for the `critic` role — caller must inject "adversarial review"
|
|
669
|
+
* framing (deliberately hunt for flaws / contradict majority view).
|
|
670
|
+
*/
|
|
671
|
+
adversarial: boolean;
|
|
672
|
+
/**
|
|
673
|
+
* `true` when the underlying spec leaves the call site to runner-decided
|
|
674
|
+
* (e.g. fullstack implementer/tester picks codex OR gemini per file).
|
|
675
|
+
* Caller falls back to v4.0 layer-based routing in that case.
|
|
676
|
+
*/
|
|
677
|
+
runnerDecides: boolean;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Resolve the (role × layer) intersection to one or more model invocations.
|
|
681
|
+
*
|
|
682
|
+
* Routing matrix (mirrors phase-15-specialist-matrix acceptance a):
|
|
683
|
+
*
|
|
684
|
+
* | Role × Layer | architect | critic | implementer | tester | writer |
|
|
685
|
+
* | backend | codex | codex (adversarial) | codex | codex | claude |
|
|
686
|
+
* | frontend | gemini | gemini (adversarial)| gemini | gemini | gemini |
|
|
687
|
+
* | fullstack | codex+gemini | both debate | runner 决 | runner 决 | claude |
|
|
688
|
+
*/
|
|
689
|
+
declare function routeSpecialist(role: SpecialistRole, layer: SpecialistLayer): SpecialistRoute;
|
|
690
|
+
/**
|
|
691
|
+
* Parse a `--role=<name>` CLI flag fragment, tolerant of whitespace and
|
|
692
|
+
* surrounding text. Returns `null` if no recognized role flag is present
|
|
693
|
+
* (caller should then fall back to v4.0 layer-only routing).
|
|
694
|
+
*/
|
|
695
|
+
declare function parseRoleFlag(args: string): SpecialistRole | null;
|
|
696
|
+
/**
|
|
697
|
+
* Build the absolute prompt file path that command templates reference.
|
|
698
|
+
* Returns null entries unchanged (writer × backend → main-thread).
|
|
699
|
+
*/
|
|
700
|
+
declare function promptFilePath(model: SpecialistModel, promptFile: string | null): string | null;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Skill Description Audit (v4.1-p19, ROI #2 / #3)
|
|
704
|
+
*
|
|
705
|
+
* Scans templates/skills/**\/SKILL.md and audits the `description` frontmatter
|
|
706
|
+
* field. Flags descriptions that exceed the 80-character soft limit (descriptions
|
|
707
|
+
* are loaded into Claude's context budget — long descriptions inflate every
|
|
708
|
+
* conversation that touches the skill registry).
|
|
709
|
+
*
|
|
710
|
+
* Companion to v4.1-p19 skill system optimization:
|
|
711
|
+
* - C1: this audit script + 80-char soft limit + 1% context budget warning
|
|
712
|
+
* - C2: `context: fork` frontmatter on heavy skills (domains/, impeccable/)
|
|
713
|
+
* - C3: `paths` filter on frontend-design skills
|
|
714
|
+
* - A3: Chinese translation of impeccable descriptions (preserve trigger keywords)
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
/** Soft limit for description length (chars). Above this we flag for audit. */
|
|
718
|
+
declare const DESCRIPTION_SOFT_LIMIT = 80;
|
|
719
|
+
/**
|
|
720
|
+
* 1% context budget threshold (in chars).
|
|
721
|
+
* Default Claude context window ≈ 200k tokens ≈ 800k chars,
|
|
722
|
+
* 1% ≈ 8000 chars. If total skill descriptions exceed this,
|
|
723
|
+
* the registry alone consumes 1%+ of context on every load.
|
|
724
|
+
*/
|
|
725
|
+
declare const CONTEXT_BUDGET_THRESHOLD = 8000;
|
|
726
|
+
interface AuditRow {
|
|
727
|
+
name: string;
|
|
728
|
+
category: string;
|
|
729
|
+
length: number;
|
|
730
|
+
overLimit: boolean;
|
|
731
|
+
description: string;
|
|
732
|
+
}
|
|
733
|
+
interface AuditReport {
|
|
734
|
+
rows: AuditRow[];
|
|
735
|
+
totalLength: number;
|
|
736
|
+
overLimitCount: number;
|
|
737
|
+
budgetExceeded: boolean;
|
|
738
|
+
budgetThreshold: number;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Audit a list of skill metadata records, producing per-row length + overall
|
|
742
|
+
* budget analysis.
|
|
743
|
+
*/
|
|
744
|
+
declare function auditSkillDescriptions(skills: SkillMeta[]): AuditReport;
|
|
745
|
+
/**
|
|
746
|
+
* Convenience wrapper: scan a skills directory then audit its contents.
|
|
747
|
+
*/
|
|
748
|
+
declare function auditSkillsDirectory(skillsDir: string): AuditReport;
|
|
749
|
+
/**
|
|
750
|
+
* Render a markdown table of the audit, sorted by length descending so the
|
|
751
|
+
* worst offenders are at the top.
|
|
752
|
+
*/
|
|
753
|
+
declare function renderAuditMarkdown(report: AuditReport): string;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Challenger Orchestrator (CCG v4.1 Phase 16).
|
|
757
|
+
*
|
|
758
|
+
* Critical phase(roadmap.md frontmatter `Critical: true`)在 phase-runner
|
|
759
|
+
* 实施完成后,由**主线** spawn 一组 challenger agents 做"双视角对辩 + 假设/边界
|
|
760
|
+
* 审计",再综合反馈让 implementer 修订一轮。
|
|
761
|
+
*
|
|
762
|
+
* v4.0.1 commit a7cdffd 实测证伪 subagent 嵌套 spawn —— 所以这是**主线扁平化**
|
|
763
|
+
* 编排(spawn implementer → 接 200-token 摘要 → 主线判 Critical → spawn
|
|
764
|
+
* challenger group → 综合 → spawn implementer 修订),而不是 phase-runner
|
|
765
|
+
* 内部 spawn challenger。
|
|
766
|
+
*
|
|
767
|
+
* 设计原则(与 v4.1 wave-scheduler / specialist-router 一致):
|
|
768
|
+
* - 纯函数;不读文件系统、不 spawn 子进程
|
|
769
|
+
* - 输入 phase 元数据 + plugin 可用性,输出结构化 spawn 计划 / 摘要解析 / 决策
|
|
770
|
+
* - 跨平台:无路径假设
|
|
771
|
+
* - 失败用 throw + 明确错误信息(输入非法 / 类型未知)
|
|
772
|
+
*
|
|
773
|
+
* 调用方(概念上):
|
|
774
|
+
* - `templates/commands/autonomous.md` Step 4.4 challenger 分支
|
|
775
|
+
*
|
|
776
|
+
* 不做:
|
|
777
|
+
* - 不实际 spawn Agent(主线 LLM 的职责,本 helper 只产出 spawn 计划)
|
|
778
|
+
* - 不写 roadmap.md / .context/<phase>/SUMMARY.md
|
|
779
|
+
* - 不解析 phase-runner 摘要(`phase-runner.ts` 已覆盖)
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Plugin advisor agent type. Maps to Claude Code subagent_type identifiers
|
|
784
|
+
* for the codex / gemini rescue plugins shipped via the `claude-plugins-*`
|
|
785
|
+
* marketplace.
|
|
786
|
+
*/
|
|
787
|
+
type PluginAdvisor = 'codex:codex-rescue' | 'gemini:gemini-rescue';
|
|
788
|
+
/**
|
|
789
|
+
* CCG-built specialist critic agent. These ship with CCG installer
|
|
790
|
+
* (templates/commands/agents/*.md) so are always available — no plugin
|
|
791
|
+
* detection required.
|
|
792
|
+
*/
|
|
793
|
+
type SpecialistCritic = 'assumptions-analyzer' | 'nyquist-auditor';
|
|
794
|
+
type ChallengerAgent = PluginAdvisor | SpecialistCritic;
|
|
795
|
+
/**
|
|
796
|
+
* Severity tier of a finding raised by a challenger.
|
|
797
|
+
* `critical` — must address before advancing the phase
|
|
798
|
+
* `major` — strongly recommended; degrades quality if ignored
|
|
799
|
+
* `info` — informational only
|
|
800
|
+
*/
|
|
801
|
+
type FindingSeverity = 'critical' | 'major' | 'info';
|
|
802
|
+
/**
|
|
803
|
+
* Input describing the phase under challenge.
|
|
804
|
+
*/
|
|
805
|
+
interface ChallengeInput {
|
|
806
|
+
/** Phase id, e.g. "16" */
|
|
807
|
+
phaseId: string;
|
|
808
|
+
/**
|
|
809
|
+
* Phase layer from roadmap.md `Type` field.
|
|
810
|
+
*
|
|
811
|
+
* v4.2 P21 起统一用 multi-model-routing SSoT 的 `Layer`,
|
|
812
|
+
* 替代历史 phase-runner.ts 自定义的 `PhaseType`(已收并)。
|
|
813
|
+
*/
|
|
814
|
+
phaseType: Layer;
|
|
815
|
+
/** Whether `Critical: true` was declared in the phase frontmatter */
|
|
816
|
+
critical: boolean;
|
|
817
|
+
/** What plugins the user has installed (detected at orchestrator start) */
|
|
818
|
+
plugins: PluginAvailability;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* One agent invocation in the spawn plan. Main thread spawns all entries
|
|
822
|
+
* from `ChallengerPlan.spawns` in a single message (Claude Code engine
|
|
823
|
+
* runs them in parallel).
|
|
824
|
+
*/
|
|
825
|
+
interface SpawnEntry$1 {
|
|
826
|
+
agent: ChallengerAgent;
|
|
827
|
+
/** Adversarial framing flag; `true` for plugin advisors and specialist critics alike */
|
|
828
|
+
adversarial: true;
|
|
829
|
+
/** Short rationale for logs / user visibility */
|
|
830
|
+
rationale: string;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Final spawn plan returned by `planChallengerSpawns`.
|
|
834
|
+
* `skipped` means Critical=false → no challengers, advance directly.
|
|
835
|
+
*/
|
|
836
|
+
interface ChallengerPlan {
|
|
837
|
+
/** Whether challenger phase runs at all */
|
|
838
|
+
skipped: boolean;
|
|
839
|
+
/** Reason when `skipped: true` (e.g. "phase not Critical") */
|
|
840
|
+
skipReason?: string;
|
|
841
|
+
/** List of agents to spawn in parallel */
|
|
842
|
+
spawns: SpawnEntry$1[];
|
|
843
|
+
/** `true` if any plugin was unavailable and orchestrator degraded */
|
|
844
|
+
degraded: boolean;
|
|
845
|
+
/** Specific degradation note when `degraded: true` */
|
|
846
|
+
degradeNote?: string;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* One challenger's ≤200-token summary. Format mirrors phase-runner
|
|
850
|
+
* summary loosely but is challenger-specific: focus on findings list.
|
|
851
|
+
*
|
|
852
|
+
* STATUS: complete | error
|
|
853
|
+
* FINDINGS: [{severity, category, message}, ...] (JSON-ish, lenient parse)
|
|
854
|
+
* NOTES: <≤80 chars>
|
|
855
|
+
*/
|
|
856
|
+
interface ChallengerSummary {
|
|
857
|
+
agent: ChallengerAgent;
|
|
858
|
+
status: 'complete' | 'error';
|
|
859
|
+
findings: Finding[];
|
|
860
|
+
notes: string;
|
|
861
|
+
raw: string;
|
|
862
|
+
}
|
|
863
|
+
interface Finding {
|
|
864
|
+
severity: FindingSeverity;
|
|
865
|
+
category: string;
|
|
866
|
+
message: string;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Decision after collecting all challenger summaries.
|
|
870
|
+
* `revise` — at least one critical finding → main thread re-spawns
|
|
871
|
+
* phase-runner with synthesized feedback (one revision round only)
|
|
872
|
+
* `advance` — no critical findings → proceed with original implementation
|
|
873
|
+
* `escalate` — challenger errors prevent decision → AskUserQuestion
|
|
874
|
+
*/
|
|
875
|
+
type ChallengerDecision = 'revise' | 'advance' | 'escalate';
|
|
876
|
+
/**
|
|
877
|
+
* Build the spawn plan for a Critical phase.
|
|
878
|
+
*
|
|
879
|
+
* Routing rules (acceptance c):
|
|
880
|
+
*
|
|
881
|
+
* backend + Critical=true → codex:codex-rescue + assumptions-analyzer
|
|
882
|
+
* frontend + Critical=true → gemini:gemini-rescue + nyquist-auditor
|
|
883
|
+
* fullstack+ Critical=true → codex:codex-rescue + gemini:gemini-rescue
|
|
884
|
+
* + assumptions-analyzer + nyquist-auditor
|
|
885
|
+
* docs + Critical=true → assumptions-analyzer (single specialist)
|
|
886
|
+
* generic + Critical=true → assumptions-analyzer (single specialist)
|
|
887
|
+
*
|
|
888
|
+
* Critical=false → skip entirely, return `{ skipped: true }`.
|
|
889
|
+
*
|
|
890
|
+
* Plugin degradation (acceptance d): if a required plugin is unavailable,
|
|
891
|
+
* drop that plugin entry and keep specialists. Do NOT fall back to
|
|
892
|
+
* codeagent-wrapper (avoids re-establishing the dependency v3.0 retired).
|
|
893
|
+
*/
|
|
894
|
+
declare function planChallengerSpawns(input: ChallengeInput): ChallengerPlan;
|
|
895
|
+
/**
|
|
896
|
+
* Parse a challenger's ≤200-token structured summary.
|
|
897
|
+
*
|
|
898
|
+
* Lenient: missing FINDINGS line → empty array; malformed JSON-ish list →
|
|
899
|
+
* best-effort extraction of `severity:critical|major|info` substrings.
|
|
900
|
+
*
|
|
901
|
+
* Throws only when `STATUS` is missing or unrecognized — that signals a
|
|
902
|
+
* bug in the challenger agent contract, not a bad phase.
|
|
903
|
+
*/
|
|
904
|
+
declare function parseChallengerSummary(agent: ChallengerAgent, text: string): ChallengerSummary;
|
|
905
|
+
/**
|
|
906
|
+
* Decide what main thread does after collecting all challenger summaries.
|
|
907
|
+
*
|
|
908
|
+
* any critical finding → revise (one revision round; caller enforces cap)
|
|
909
|
+
* no critical, all complete → advance
|
|
910
|
+
* any error status → escalate (AskUserQuestion)
|
|
911
|
+
*/
|
|
912
|
+
declare function decideFromSummaries(summaries: ChallengerSummary[]): ChallengerDecision;
|
|
913
|
+
/**
|
|
914
|
+
* Synthesize critical findings across all challengers into a single
|
|
915
|
+
* feedback block to inject into the implementer's revision prompt.
|
|
916
|
+
*
|
|
917
|
+
* Returns a markdown string suitable for embedding in the phase-runner
|
|
918
|
+
* spawn prompt's `phase_acceptance` extension.
|
|
919
|
+
*/
|
|
920
|
+
declare function synthesizeRevisionFeedback(summaries: ChallengerSummary[]): string;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Plugin Detection (CCG v4.1 Phase 20).
|
|
924
|
+
*
|
|
925
|
+
* Detects whether the user has installed Claude Code plugins that CCG's
|
|
926
|
+
* 6 core commands prefer over `codeagent-wrapper`:
|
|
927
|
+
*
|
|
928
|
+
* - codex@openai-codex (provides `Agent(subagent_type="codex:codex-rescue")` — Agent 双前缀)
|
|
929
|
+
* - gemini@google-gemini (provides `Agent(subagent_type="gemini:gemini-rescue")` — Agent 双前缀)
|
|
930
|
+
*
|
|
931
|
+
* 命名空间分离(v4.4.1 校正):
|
|
932
|
+
* - Agent(subagent_type=...) 真名 = `codex:codex-rescue` / `gemini:gemini-rescue`(双前缀)
|
|
933
|
+
* - Skill(skill=...) 真名 = `codex:rescue` / `gemini:rescue`(单前缀)
|
|
934
|
+
*
|
|
935
|
+
* Plugins live under `~/.claude/plugins/<plugin-name>/SKILL.md` (or any
|
|
936
|
+
* marker file). The detection here is intentionally lightweight: if a
|
|
937
|
+
* recognizable directory exists with at least one of the plugin's standard
|
|
938
|
+
* marker files, we treat the plugin as installed. Failures are non-fatal —
|
|
939
|
+
* detection returns `false` so that callers fallback to `codeagent-wrapper`.
|
|
940
|
+
*
|
|
941
|
+
* Design principles:
|
|
942
|
+
* - Pure synchronous fs probe; no spawn / network
|
|
943
|
+
* - Cross-platform (uses pathe-style `/` joins via `path.join`)
|
|
944
|
+
* - Never throws on unexpected errors — those map to "not installed"
|
|
945
|
+
*
|
|
946
|
+
* Used by:
|
|
947
|
+
* - `templates/commands/{plan,execute,analyze,optimize,test,review}.md`
|
|
948
|
+
* preflight (orchestrator inlines this logic in narrative form)
|
|
949
|
+
* - `src/utils/challenger-orchestrator.ts` `PluginAvailability` populator
|
|
950
|
+
*
|
|
951
|
+
* Not used by:
|
|
952
|
+
* - `phase-runner` subagent (engine forbids spawning Agent inside a
|
|
953
|
+
* subagent — see commit a7cdffd)
|
|
954
|
+
*/
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Plugin slugs CCG cares about for v4.1 codeagent retirement.
|
|
958
|
+
* Must mirror `PluginAdvisor` in `challenger-orchestrator.ts`.
|
|
959
|
+
*/
|
|
960
|
+
type PluginName = 'codex' | 'gemini';
|
|
961
|
+
/**
|
|
962
|
+
* Detection result for a single plugin.
|
|
963
|
+
*/
|
|
964
|
+
interface PluginDetectionResult {
|
|
965
|
+
name: PluginName;
|
|
966
|
+
installed: boolean;
|
|
967
|
+
/** Absolute path probed (for diagnostic logging) */
|
|
968
|
+
probedPath: string;
|
|
969
|
+
/** Reason when `installed: false` */
|
|
970
|
+
reason?: 'missing-dir' | 'missing-marker' | 'fs-error';
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Detect a single plugin by name.
|
|
974
|
+
*
|
|
975
|
+
* Returns `{ installed: false, reason: ... }` for any failure mode rather
|
|
976
|
+
* than throwing. Caller logic (template fallback / orchestrator degrade)
|
|
977
|
+
* only cares about the boolean.
|
|
978
|
+
*
|
|
979
|
+
* `homeDir` parameter exists for tests — production callers omit it.
|
|
980
|
+
*/
|
|
981
|
+
declare function detectPlugin(name: PluginName, homeDir?: string): PluginDetectionResult;
|
|
982
|
+
/**
|
|
983
|
+
* Detect both CCG-relevant plugins in one call. Returns the
|
|
984
|
+
* `PluginAvailability` shape consumed by challenger-orchestrator.
|
|
985
|
+
*/
|
|
986
|
+
declare function detectPluginAvailability(homeDir?: string): PluginAvailability;
|
|
987
|
+
/**
|
|
988
|
+
* Convenience: are *both* plugins installed (default route in v4.1)?
|
|
989
|
+
* When `false`, command templates instruct LLM to fallback to
|
|
990
|
+
* `codeagent-wrapper` for the missing model only (per-model degrade,
|
|
991
|
+
* not all-or-nothing).
|
|
992
|
+
*/
|
|
993
|
+
declare function bothPluginsInstalled(homeDir?: string): boolean;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Quality Tier Router (CCG v4.2 Phase 22).
|
|
997
|
+
*
|
|
998
|
+
* v4.2 旗舰能力:把 v4.1 单波 phase-runner 调度扩展为**三档分级**:
|
|
999
|
+
*
|
|
1000
|
+
* - `--quality=fast` — v4.1 单波 + 1 路 verify(壁钟 +30%,质量 6.5→7.5)
|
|
1001
|
+
* - `--quality=triple` — Plan-Critic-Verify 三段式(默认;4 wave;壁钟 +60-90%,质量→8.5)
|
|
1002
|
+
* - `--quality=debate` — triple + codex↔gemini 多轮对辩(壁钟 +100-150%,质量→9)
|
|
1003
|
+
*
|
|
1004
|
+
* 设计哲学(基于市面 SOTA Plan-Critic-Verify 实测):
|
|
1005
|
+
* - Plan 阶段 lateral diversity(codex+gemini+claude 3 路并行)
|
|
1006
|
+
* - Critic 阶段 angle-based 不是 model-based(assumptions-analyzer + nyquist-auditor)
|
|
1007
|
+
* - Implementer 单 strong model(一致性 > 多样性,phase-runner 全权 Bash)
|
|
1008
|
+
* - Verify cross-vendor(codex+gemini 抓 race / commit drift / 半成品)
|
|
1009
|
+
*
|
|
1010
|
+
* 设计原则(与 v4.1 challenger-orchestrator / specialist-router 一致):
|
|
1011
|
+
* - 纯函数;不读文件、不 spawn 子进程
|
|
1012
|
+
* - 输入 quality flag + phase 元数据 + plugin 可用性,输出 wave 计划
|
|
1013
|
+
* - 失败用 throw + 明确错误信息(非法 tier)
|
|
1014
|
+
* - 类型全部从 multi-model-routing SSoT 导入
|
|
1015
|
+
*
|
|
1016
|
+
* 调用方:
|
|
1017
|
+
* - templates/commands/autonomous.md Step 4.0(解析 quality flag → wave 计划)
|
|
1018
|
+
*
|
|
1019
|
+
* 不做:
|
|
1020
|
+
* - 不实际 spawn Agent(主线 LLM 职责)
|
|
1021
|
+
* - 不读 plugin 状态(plugin-detection.ts 职责)
|
|
1022
|
+
* - 不写 roadmap.md / SUMMARY.md
|
|
1023
|
+
*/
|
|
1024
|
+
|
|
1025
|
+
/** Quality tier 三档 */
|
|
1026
|
+
type QualityTier = 'fast' | 'triple' | 'debate';
|
|
1027
|
+
/** Wave 类型:plan / critic / impl / verify / debate(仅 debate 模式) */
|
|
1028
|
+
type WaveKind = 'plan' | 'critic' | 'impl' | 'verify' | 'debate';
|
|
1029
|
+
/**
|
|
1030
|
+
* 单个 spawn entry。复用 challenger-orchestrator 的 SpawnEntry 概念但本模块
|
|
1031
|
+
* 不强依赖那边的 ChallengerAgent union——quality-router 还要 spawn
|
|
1032
|
+
* phase-runner / claude opus 等非 challenger 角色,所以用更宽松的 string union。
|
|
1033
|
+
*/
|
|
1034
|
+
interface SpawnEntry {
|
|
1035
|
+
/**
|
|
1036
|
+
* 要 spawn 的 subagent_type。
|
|
1037
|
+
* - phase-runner — implementer
|
|
1038
|
+
* - codex:codex-rescue — plugin advisor / verify (Agent subagent_type, double-prefix)
|
|
1039
|
+
* - gemini:gemini-rescue — plugin advisor / verify (Agent subagent_type, double-prefix)
|
|
1040
|
+
* - assumptions-analyzer — critic specialist
|
|
1041
|
+
* - nyquist-auditor — critic specialist
|
|
1042
|
+
* - general-purpose — 降级到 main-thread Claude(含 ccgPromptFile 引用)
|
|
1043
|
+
*/
|
|
1044
|
+
agent: string;
|
|
1045
|
+
/** 调用风格:建设性 / 对抗性 / 校验性 */
|
|
1046
|
+
role: 'planner' | 'critic' | 'implementer' | 'verifier' | 'debater';
|
|
1047
|
+
/** 一句话给主线展示的理由 */
|
|
1048
|
+
rationale: string;
|
|
1049
|
+
/** 当 agent='general-purpose' 时引用的 CCG prompt 模板路径(降级路径) */
|
|
1050
|
+
ccgPromptFile?: string;
|
|
1051
|
+
/**
|
|
1052
|
+
* v4.4.2 verify wave 字段透传(来自 verify-orchestrator.VerifySpawnEntry):
|
|
1053
|
+
* 'bash-direct' 走 Bash 直调 plugin script 跳过 sonnet wrapper(消除 silent
|
|
1054
|
+
* fallback),'agent' 走传统 Agent spawn。仅 verify wave 当前使用,其他 wave
|
|
1055
|
+
* 字段保持 undefined。
|
|
1056
|
+
*/
|
|
1057
|
+
invocationMode?: 'agent' | 'bash-direct';
|
|
1058
|
+
/**
|
|
1059
|
+
* v4.4.2: 当 invocationMode='bash-direct' 时,主线 Bash 工具消费的命令模板
|
|
1060
|
+
* (含 `<PROMPT>` 占位)。来自 verify-orchestrator.buildBashDirectCommand。
|
|
1061
|
+
*/
|
|
1062
|
+
bashCommand?: string;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* 一个 wave 的执行计划。多 wave 顺序执行;wave 内 spawns 并行。
|
|
1066
|
+
*/
|
|
1067
|
+
interface WavePlan {
|
|
1068
|
+
kind: WaveKind;
|
|
1069
|
+
/** 1-indexed wave 序号(仅 debate 子 wave 用 round 表达) */
|
|
1070
|
+
index: number;
|
|
1071
|
+
spawns: SpawnEntry[];
|
|
1072
|
+
/** debate 子 wave 才有:当前是第几轮(1..N) */
|
|
1073
|
+
round?: number;
|
|
1074
|
+
/** 该 wave 是否因 plugin 缺失走了降级 */
|
|
1075
|
+
degraded: boolean;
|
|
1076
|
+
/** 降级原因(仅 degraded=true 时填) */
|
|
1077
|
+
degradeNote?: string;
|
|
1078
|
+
}
|
|
1079
|
+
/** Phase 元数据子集(quality-router 只关心这几个字段) */
|
|
1080
|
+
interface PhaseMeta {
|
|
1081
|
+
phaseId: string;
|
|
1082
|
+
/** Layer 字段,参考 phase frontmatter `Type` */
|
|
1083
|
+
phaseType: Layer;
|
|
1084
|
+
/**
|
|
1085
|
+
* Phase 自带 quality override(roadmap.md frontmatter `Quality:` 字段)。
|
|
1086
|
+
* 若设置,优先级高于全局 --quality flag。
|
|
1087
|
+
*/
|
|
1088
|
+
quality?: QualityTier;
|
|
1089
|
+
/**
|
|
1090
|
+
* v4.5 P1a: phase-runner CLI subprocess 调用所需的额外字段。
|
|
1091
|
+
* - `workdir`: subprocess 的 cwd(必含 D5 决策;默认空时 helper 会 fallback 到 `<WORKDIR>` 占位符)
|
|
1092
|
+
* - `jobId`: 用于 stream-json 落盘 `.context/jobs/<jobId>/progress.jsonl`
|
|
1093
|
+
* 仅在 `useDirectBashInvocation=true` 路径生效;不影响 verify wave / Agent spawn。
|
|
1094
|
+
*/
|
|
1095
|
+
workdir?: string;
|
|
1096
|
+
jobId?: string;
|
|
1097
|
+
/**
|
|
1098
|
+
* v4.5 P1f: phase frontmatter `nested_rescue: true|false` override。
|
|
1099
|
+
* 若设置,优先级高于全局 --nested CLI flag。phase-runner prompt 注入路径
|
|
1100
|
+
* 参见 `resolveNestedRescue()`。
|
|
1101
|
+
*/
|
|
1102
|
+
nestedRescue?: boolean;
|
|
1103
|
+
}
|
|
1104
|
+
/** 解析 --quality=<tier> flag 的输入 */
|
|
1105
|
+
interface ResolveInput {
|
|
1106
|
+
/** Raw CLI args 字符串(包含 `--quality=...`),可空 */
|
|
1107
|
+
cliArgs?: string;
|
|
1108
|
+
/** Phase frontmatter `Quality:` 字段(若解析到) */
|
|
1109
|
+
phaseQuality?: QualityTier;
|
|
1110
|
+
}
|
|
1111
|
+
/** 路由完整结果(含降级摘要) */
|
|
1112
|
+
interface QualityPlan {
|
|
1113
|
+
tier: QualityTier;
|
|
1114
|
+
/** 实际使用的 tier(resolveQualityTier 返回值,phase 优先 > flag > 默认) */
|
|
1115
|
+
source: 'phase-override' | 'cli-flag' | 'default';
|
|
1116
|
+
waves: WavePlan[];
|
|
1117
|
+
/** 是否因 plugin 缺失整体降级到更低 tier */
|
|
1118
|
+
degraded: boolean;
|
|
1119
|
+
/** 实际降级到的目标 tier(degraded=true 时填) */
|
|
1120
|
+
degradedTo?: QualityTier;
|
|
1121
|
+
degradeNote?: string;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* 解析 --quality=<tier> CLI flag。容错:未提供或非法值返回 null。
|
|
1125
|
+
*/
|
|
1126
|
+
declare function parseQualityFlag(args: string | undefined): QualityTier | null;
|
|
1127
|
+
/**
|
|
1128
|
+
* 综合 phase override / cli flag / 默认值确定 quality tier。
|
|
1129
|
+
*
|
|
1130
|
+
* 优先级(高 → 低):
|
|
1131
|
+
* 1. phase frontmatter `Quality:` 字段(roadmap.md 单 phase 覆盖)
|
|
1132
|
+
* 2. `--quality=<tier>` CLI flag
|
|
1133
|
+
* 3. 默认 `triple`
|
|
1134
|
+
*/
|
|
1135
|
+
declare function resolveQualityTier(input: ResolveInput): {
|
|
1136
|
+
tier: QualityTier;
|
|
1137
|
+
source: 'phase-override' | 'cli-flag' | 'default';
|
|
1138
|
+
};
|
|
1139
|
+
/** v4.5 P1a: planWavesForTier / buildQualityPlan 选项 */
|
|
1140
|
+
interface PlanWavesOptions {
|
|
1141
|
+
/**
|
|
1142
|
+
* v4.5 P1a: 把 impl wave 的 phase-runner spawn 从 Agent sidechain 改为 Bash
|
|
1143
|
+
* 直调 `claude -p --agent ccg/phase-runner ...` OS-level 子进程。同时也会
|
|
1144
|
+
* 把 verify wave 的 plugin spawn 切到 bash-direct(v4.4.2 verify 治理)。
|
|
1145
|
+
*
|
|
1146
|
+
* 默认 false 时:
|
|
1147
|
+
* - impl wave 走 `Agent(subagent_type="phase-runner")`(v4.0~v4.4 行为)
|
|
1148
|
+
* - verify wave 走 Agent spawn(v4.4.1 及以前的 sonnet wrapper 路径)
|
|
1149
|
+
*
|
|
1150
|
+
* 默认 true(autonomous Step 4.0+ 启用)时:
|
|
1151
|
+
* - impl wave 走 Bash 直调,subprocess RSS 与主进程隔离
|
|
1152
|
+
* - verify wave 走 plugin script 直调,跳过 sonnet wrapper
|
|
1153
|
+
*/
|
|
1154
|
+
useDirectBashInvocation?: boolean;
|
|
1155
|
+
/**
|
|
1156
|
+
* v4.5 P1f: 当 `useDirectBashInvocation=true` 时,用 ccg-phase-runner-launcher.mjs
|
|
1157
|
+
* 包装 `claude -p` 调用而非直接裸 spawn。解锁 Phase 2 supervisor 全部能力:
|
|
1158
|
+
* atomic state.json / process-tree kill-tree / cancel.flag 协作 / reconciler。
|
|
1159
|
+
*
|
|
1160
|
+
* autonomous Step 4.2-4.3 默认开启。Test / dev workflow 可关闭走 P1a 裸 spawn 路径。
|
|
1161
|
+
* 默认 false 时保持 P1a 裸 `claude -p` BC(v4.5.0 → v4.5.1 升级路径)。
|
|
1162
|
+
*/
|
|
1163
|
+
useLauncherWiring?: boolean;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* 给定 tier + phase + plugin 可用性,返回 wave 计划。
|
|
1167
|
+
*
|
|
1168
|
+
* 降级路径:
|
|
1169
|
+
* - debate → triple:双 plugin 都缺失(debate 失去对辩多样性意义)
|
|
1170
|
+
* - triple → fast:双 plugin 都缺失(plan/verify 双方向都降级到 main-thread)
|
|
1171
|
+
*
|
|
1172
|
+
* 注意:单 plugin 缺失不触发整体降级——具体 wave 内走 general-purpose
|
|
1173
|
+
* fallback(degraded: true);只有双 plugin 都缺时才整体降阶。
|
|
1174
|
+
*/
|
|
1175
|
+
declare function planWavesForTier(tier: QualityTier, phase: PhaseMeta, plugins: PluginAvailability, options?: PlanWavesOptions): {
|
|
1176
|
+
effectiveTier: QualityTier;
|
|
1177
|
+
waves: WavePlan[];
|
|
1178
|
+
degraded: boolean;
|
|
1179
|
+
degradedTo?: QualityTier;
|
|
1180
|
+
degradeNote?: string;
|
|
1181
|
+
};
|
|
1182
|
+
/**
|
|
1183
|
+
* One-shot 入口:解析 flag → 算 tier → 构 wave。
|
|
1184
|
+
*
|
|
1185
|
+
* 主线 autonomous Step 4.0 直接调这个,得到完整执行计划。
|
|
1186
|
+
*
|
|
1187
|
+
* v4.5 P1a: `options.useDirectBashInvocation=true` 时 impl wave + verify wave
|
|
1188
|
+
* 都切到 Bash 直调(subprocess RSS 隔离 + verify wave silent fallback 治理)。
|
|
1189
|
+
*/
|
|
1190
|
+
declare function buildQualityPlan(resolveInput: ResolveInput, phase: PhaseMeta, plugins: PluginAvailability, options?: PlanWavesOptions): QualityPlan;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Plan Aggregator (CCG v4.2 Phase 22).
|
|
1194
|
+
*
|
|
1195
|
+
* triple/debate 模式 plan wave 完成后,汇总 3 路 plan contribution 成
|
|
1196
|
+
* 单一 DesignBrief(共识 / 分歧 / 必决策点),由主线在 impl wave 注入
|
|
1197
|
+
* phase-runner 的 prompt 里。
|
|
1198
|
+
*
|
|
1199
|
+
* 综合算法(P22 起步实现,P23 dogfood 后可调优):
|
|
1200
|
+
* 1. 把每路 plan 切成 bullet points(按 markdown `-` 或换行)
|
|
1201
|
+
* 2. 共识 = 同样 bullet 出现在 ≥ 2 路(≥ 70% 字面相似度)
|
|
1202
|
+
* 3. 分歧 = 仅 1 路出现 或 不同路给冲突方案
|
|
1203
|
+
* 4. decision_required = 分歧中标"high-stakes"关键词的(架构 / 破坏性 / 安全 / schema / 迁移)
|
|
1204
|
+
*
|
|
1205
|
+
* 设计原则(与 quality-router 一致):
|
|
1206
|
+
* - 纯函数;不读文件、不 spawn 子进程
|
|
1207
|
+
* - 输入 PlanContribution[],输出 DesignBrief
|
|
1208
|
+
* - 失败容错:单路解析失败仍用其他 N-1 路(不抛错)
|
|
1209
|
+
*
|
|
1210
|
+
* 调用方:
|
|
1211
|
+
* - templates/commands/autonomous.md Step 4.x triple/debate 模式 plan wave 后
|
|
1212
|
+
*
|
|
1213
|
+
* 不做:
|
|
1214
|
+
* - 不解析 phase-runner 摘要(phase-runner.ts 职责)
|
|
1215
|
+
* - 不做语义级对齐(只做字符级相似度,控制复杂度)
|
|
1216
|
+
*/
|
|
1217
|
+
|
|
1218
|
+
interface PlanContribution {
|
|
1219
|
+
/** 哪个 model 给出的 plan(codex / gemini / claude / general-purpose 兜底) */
|
|
1220
|
+
model: Model;
|
|
1221
|
+
/** Plan 文本(subagent 摘要里的 PLAN 字段或全文,主线传入哪个由编排决定) */
|
|
1222
|
+
plan: string;
|
|
1223
|
+
/** plan 文本长度(字符),传入计算可缓存;缺省自动算 */
|
|
1224
|
+
length?: number;
|
|
1225
|
+
}
|
|
1226
|
+
/** 一个分歧主题(topic 一致但选项不同) */
|
|
1227
|
+
interface Divergence {
|
|
1228
|
+
topic: string;
|
|
1229
|
+
options: {
|
|
1230
|
+
from: Model;
|
|
1231
|
+
option: string;
|
|
1232
|
+
}[];
|
|
1233
|
+
}
|
|
1234
|
+
interface DesignBrief {
|
|
1235
|
+
/** ≥ 2 路提到的共识要点 */
|
|
1236
|
+
consensus: string[];
|
|
1237
|
+
/** 各模型间的分歧主题 + 各自方案 */
|
|
1238
|
+
divergences: Divergence[];
|
|
1239
|
+
/**
|
|
1240
|
+
* 必须由主线 / 用户决策的高 stakes 项(含 high-stakes keyword 的分歧主题)
|
|
1241
|
+
* 这是 divergences 的子集(按 topic 引用),不是新内容。
|
|
1242
|
+
*/
|
|
1243
|
+
decision_required: string[];
|
|
1244
|
+
/** 解析过程的告警(路解析失败等) */
|
|
1245
|
+
warnings: string[];
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* 综合多路 plan 成单一 DesignBrief。
|
|
1249
|
+
*
|
|
1250
|
+
* 容错:单路 plan 解析失败/为空时 warning 记录,用其他路继续。
|
|
1251
|
+
*/
|
|
1252
|
+
declare function aggregatePlans(contributions: PlanContribution[]): DesignBrief;
|
|
1253
|
+
/**
|
|
1254
|
+
* 估算文本的 token 数量(v4.2.1 P24,替代字符长度估算)。
|
|
1255
|
+
*
|
|
1256
|
+
* 按字符类型加权求和:
|
|
1257
|
+
* - 英文 word(match `[a-zA-Z]+`):1 word ≈ 1 token,平均 4 char/word → 0.25 token/char
|
|
1258
|
+
* - 中文 char(match `[一-鿿]`):1 char ≈ 1 token (GPT/Claude tokenizer 实测)
|
|
1259
|
+
* - 数字 / 标点 / 空白:0.3 token/char (中性估算)
|
|
1260
|
+
*
|
|
1261
|
+
* 返回 Math.ceil(总和),避免低估导致超预算。
|
|
1262
|
+
*
|
|
1263
|
+
* 例子:
|
|
1264
|
+
* - "hello world this is a test" → 6 token (6 word)
|
|
1265
|
+
* - "这是一个测试" → 6 token (6 中文字)
|
|
1266
|
+
* - "this is 中文测试" → ~3 word + 4 中文 = ~7 token + 空格 = ~8 token
|
|
1267
|
+
*/
|
|
1268
|
+
declare function estimateTokens(text: string): number;
|
|
1269
|
+
/**
|
|
1270
|
+
* 把 DesignBrief 序列化成 markdown,供 phase-runner prompt 注入。
|
|
1271
|
+
*
|
|
1272
|
+
* 长度上限 ≈ BRIEF_MAX_TOKENS token(v4.2.1 P24 token-aware 截断;旧版按 char 估算
|
|
1273
|
+
* 对纯中文低估 2 倍)。边构建边检查,超过预算则截断尾部并加 `(truncated)` 标记。
|
|
1274
|
+
*/
|
|
1275
|
+
declare function serializeBriefForPrompt(brief: DesignBrief): string;
|
|
1276
|
+
/**
|
|
1277
|
+
* 返回 brief 序列化结果的 token 估算(v4.2.1 P24 用 estimateTokens 替代字符长度)。
|
|
1278
|
+
*
|
|
1279
|
+
* 旧 API 名保持兼容,但语义从 char 数改为 token 估算。
|
|
1280
|
+
*/
|
|
1281
|
+
declare function estimateBriefLength(brief: DesignBrief): number;
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Verify Orchestrator (CCG v4.2 Phase 22; v4.2.1 Phase 24 — SSoT 化).
|
|
1285
|
+
*
|
|
1286
|
+
* fast/triple/debate 模式 verify wave 完成后,综合 verify reports 决定主线
|
|
1287
|
+
* 后续行为(advance / revise / escalate)。
|
|
1288
|
+
*
|
|
1289
|
+
* **SSoT 声明 (v4.2.1 P24)**:本模块的 `planVerifyWave()` 是 **verify wave 路由
|
|
1290
|
+
* 的权威实现**。`quality-router.ts.buildVerifyWave` 必须 import 本函数后做
|
|
1291
|
+
* schema adapter,不得复制实现。任何 verify 路由策略变更只在本文件改。
|
|
1292
|
+
*
|
|
1293
|
+
* 设计原则:
|
|
1294
|
+
* - 纯函数;不读文件、不 spawn 子进程
|
|
1295
|
+
* - 输入 verify reports(≤200 token 摘要文本),输出决策枚举
|
|
1296
|
+
* - 复用 challenger-orchestrator 的 parseFindings 鲁棒化解析
|
|
1297
|
+
*
|
|
1298
|
+
* 调用方:
|
|
1299
|
+
* - templates/commands/autonomous.md verify wave 完成后
|
|
1300
|
+
* - quality-router.ts.buildVerifyWave (内部 wrap 成 WavePlan schema)
|
|
1301
|
+
*
|
|
1302
|
+
* 不做:
|
|
1303
|
+
* - 不实际 spawn verify agent(quality-router 出 spawn 计划,主线 LLM 派发)
|
|
1304
|
+
* - 不修订 phase(修订由主线再 spawn impl wave 完成)
|
|
1305
|
+
*/
|
|
1306
|
+
|
|
1307
|
+
/** Verify 模式:单 verify (fast) / 双 verify (triple+debate) */
|
|
1308
|
+
type VerifyMode = 'single' | 'dual';
|
|
1309
|
+
/** 单条 verify 摘要解析后的结构 */
|
|
1310
|
+
interface VerifyReport {
|
|
1311
|
+
/** 哪个 agent 返回的 verify 结果 */
|
|
1312
|
+
agent: string;
|
|
1313
|
+
/** 解析状态 */
|
|
1314
|
+
status: 'complete' | 'error';
|
|
1315
|
+
/** Critical 级别 findings */
|
|
1316
|
+
criticals: Finding[];
|
|
1317
|
+
/** Major 级别 findings(参考用,不阻塞推进) */
|
|
1318
|
+
majors: Finding[];
|
|
1319
|
+
/** Notes 字段 */
|
|
1320
|
+
notes: string;
|
|
1321
|
+
/** 原始文本(debug 用) */
|
|
1322
|
+
raw: string;
|
|
1323
|
+
}
|
|
1324
|
+
/** 主线决策:advance / revise / escalate(与 challenger 一致) */
|
|
1325
|
+
type VerifyDecision = 'advance' | 'revise' | 'escalate';
|
|
1326
|
+
/**
|
|
1327
|
+
* 调用方式(v4.4.2 起 verify wave 支持两种):
|
|
1328
|
+
* - 'agent' — Agent(subagent_type=...) plugin spawn(含 sonnet wrapper,silent fallback 风险)
|
|
1329
|
+
* - 'bash-direct' — Bash 直调 plugin script(codex-companion.mjs / gemini-companion.mjs)跳过 wrapper
|
|
1330
|
+
*
|
|
1331
|
+
* v4.4.2 verify wave 默认切到 'bash-direct' 架构性消除 silent contamination。
|
|
1332
|
+
* 其他用例(impl/autonomous/debate)仍走 'agent' 保 ≤200 token 摘要预算。
|
|
1333
|
+
*/
|
|
1334
|
+
type VerifyInvocationMode = 'agent' | 'bash-direct';
|
|
1335
|
+
/** Verify wave spawn entry(与 quality-router 的 SpawnEntry 子集对齐) */
|
|
1336
|
+
interface VerifySpawnEntry {
|
|
1337
|
+
agent: string;
|
|
1338
|
+
rationale: string;
|
|
1339
|
+
/** plugin 缺失走 general-purpose 时引用的 prompt 文件 */
|
|
1340
|
+
ccgPromptFile?: string;
|
|
1341
|
+
/** v4.4.2: 'agent' 走 Agent spawn / 'bash-direct' 走 Bash 直调 plugin script */
|
|
1342
|
+
invocationMode?: VerifyInvocationMode;
|
|
1343
|
+
/**
|
|
1344
|
+
* v4.4.2: 当 invocationMode='bash-direct' 时,模板渲染用的 Bash 命令模板。
|
|
1345
|
+
* 主线 Bash 工具直接执行此命令,stdout 为 plugin 完整 JSON 响应。
|
|
1346
|
+
* Plugin 脚本路径用 glob `~/.claude/plugins/cache/<vendor>/<plugin>/*\/scripts/*-companion.mjs`,
|
|
1347
|
+
* 主线消费时按需 ls 解析具体版本号。
|
|
1348
|
+
*/
|
|
1349
|
+
bashCommand?: string;
|
|
1350
|
+
}
|
|
1351
|
+
/** v4.4.2 planVerifyWave 选项 */
|
|
1352
|
+
interface PlanVerifyWaveOptions {
|
|
1353
|
+
/**
|
|
1354
|
+
* 把所有 plugin spawn entry 切成 'bash-direct' 模式(v4.4.2 verify wave 默认 true)。
|
|
1355
|
+
* 仅影响 plugin 路径,general-purpose 降级路径不受影响。
|
|
1356
|
+
*/
|
|
1357
|
+
useDirectBashInvocation?: boolean;
|
|
1358
|
+
}
|
|
1359
|
+
/** Verify wave 计划输出 */
|
|
1360
|
+
interface VerifyWavePlan {
|
|
1361
|
+
mode: VerifyMode;
|
|
1362
|
+
spawns: VerifySpawnEntry[];
|
|
1363
|
+
degraded: boolean;
|
|
1364
|
+
degradeNote?: string;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* 给定 quality tier + phase layer + plugin 可用性,构造 verify wave 计划。
|
|
1368
|
+
*
|
|
1369
|
+
* - fast → single verify (cross-vendor: layer=frontend → codex;其他 → gemini)
|
|
1370
|
+
* - triple → dual verify (codex + gemini 并行)
|
|
1371
|
+
* - debate → dual verify
|
|
1372
|
+
*
|
|
1373
|
+
* **SSoT (v4.2.1)**:quality-router.buildVerifyWave 必须 import 此函数 + 走
|
|
1374
|
+
* schema adapter,不得复制路由实现。
|
|
1375
|
+
*
|
|
1376
|
+
* **v4.4.2 (E only)**:`options.useDirectBashInvocation=true` 时所有 plugin
|
|
1377
|
+
* spawn entry 标 invocationMode='bash-direct' + 附 bashCommand,主线模板渲染
|
|
1378
|
+
* 为 Bash 直调跳过 sonnet wrapper(架构性消除 silent contamination)。默认
|
|
1379
|
+
* false 保持向后兼容(v4.4.1 及以前的 Agent spawn 行为)。
|
|
1380
|
+
*/
|
|
1381
|
+
declare function planVerifyWave(tier: 'fast' | 'triple' | 'debate', layer: Layer, plugins: PluginAvailability, options?: PlanVerifyWaveOptions): VerifyWavePlan;
|
|
1382
|
+
/**
|
|
1383
|
+
* 解析单条 verify summary 文本。复用 challenger-orchestrator.parseChallengerSummary
|
|
1384
|
+
* 的鲁棒化 parser(同样的 STATUS / FINDINGS / NOTES schema)。
|
|
1385
|
+
*
|
|
1386
|
+
* 与 challenger 不同点:verify 没有"adversarial"语义,但摘要协议复用同一格式
|
|
1387
|
+
* 简化代码 + 测试。caller 决定调用语义。
|
|
1388
|
+
*
|
|
1389
|
+
* @param agent 调用方传入的 agent 名(quality-router 的 SpawnEntry.agent)
|
|
1390
|
+
* @param text subagent 返回的 ≤200 token 摘要原文
|
|
1391
|
+
*/
|
|
1392
|
+
declare function parseVerifyReport(agent: string, text: string): VerifyReport;
|
|
1393
|
+
/**
|
|
1394
|
+
* 综合多个 verify reports 给主线决策。
|
|
1395
|
+
*
|
|
1396
|
+
* - 任一 status='error' → escalate (AskUserQuestion)
|
|
1397
|
+
* - 任一 critical finding → revise (主线 spawn 修订轮)
|
|
1398
|
+
* - 全部 complete + 0 critical → advance
|
|
1399
|
+
* - 空报告列表(异常) → escalate
|
|
1400
|
+
*/
|
|
1401
|
+
declare function synthesizeVerifyResults(reports: VerifyReport[]): VerifyDecision;
|
|
1402
|
+
/**
|
|
1403
|
+
* 综合 verify reports 中的 critical findings 成单一反馈块,注入修订轮
|
|
1404
|
+
* phase-runner 的 prompt(与 challenger.synthesizeRevisionFeedback 同源)。
|
|
1405
|
+
*
|
|
1406
|
+
* 修订轮要求:仅修复 critical 项,不重做整个 phase。
|
|
1407
|
+
*/
|
|
1408
|
+
declare function synthesizeVerifyFeedback(reports: VerifyReport[]): string;
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Pipeline Check (CCG v4.3 Phase 25).
|
|
1412
|
+
*
|
|
1413
|
+
* 主线 spawn phase-runner 完成 commit 后,强制跑一次端到端 release pipeline 验证:
|
|
1414
|
+
* 1. pnpm pack 看 tarball 能否生成
|
|
1415
|
+
* 2. 解 tarball 列内容
|
|
1416
|
+
* 3. 比对 templates/commands/*.md 实际文件 vs package.json `files` 数组——找漏列
|
|
1417
|
+
*
|
|
1418
|
+
* v4.2.0 release blocker `debate.md` 漏 package.json files 这种事就由这个 helper
|
|
1419
|
+
* 在 commit 后立刻被抓,不必等用户 cold-start。
|
|
1420
|
+
*
|
|
1421
|
+
* 设计原则(与 v4.0 phase-context / debug-session / wave-scheduler 一致):
|
|
1422
|
+
* - 纯函数 + 几个 spawn 子进程的入口;不读 ~/.claude/、不写持久状态
|
|
1423
|
+
* - 输入 workdir 路径,输出结构化 PipelineCheckReport
|
|
1424
|
+
* - 失败优雅:pnpm 没装 / tar 没装 / 子进程 crash 都返回 ok=false + 错误,不抛
|
|
1425
|
+
* - Cross-platform:用 child_process.execSync + node:fs + node:path 内建模块
|
|
1426
|
+
*
|
|
1427
|
+
* 调用方(主线):
|
|
1428
|
+
* - autonomous.md Step 4.4 phase 完成后(runPipelineCheck → 任何 critical → blocker 路径)
|
|
1429
|
+
* - 用户手动跑 `node -e "..."` 验证
|
|
1430
|
+
*
|
|
1431
|
+
* 不做:
|
|
1432
|
+
* - 不实际跑 npm install -g(破坏用户全局环境,留给用户手动)
|
|
1433
|
+
* - 不修复发现的问题(建议性输出,主线决策)
|
|
1434
|
+
* - 不读 settings.json / ~/.claude/(那是 ground-truth-sampler 职责,P26)
|
|
1435
|
+
*/
|
|
1436
|
+
/** 单条错误的分类。category 用于主线决策严重程度。 */
|
|
1437
|
+
type PipelineErrorCategory = 'pack-failed' | 'tar-extract-failed' | 'missing-from-tarball' | 'package-json-missing' | 'package-json-invalid';
|
|
1438
|
+
/**
|
|
1439
|
+
* 单条错误。message 给主线 / 用户读,detail 是可选 debug 信息。
|
|
1440
|
+
*/
|
|
1441
|
+
interface PipelineError {
|
|
1442
|
+
category: PipelineErrorCategory;
|
|
1443
|
+
message: string;
|
|
1444
|
+
detail?: string;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Pipeline check 完整报告。ok=true 才允许 phase 推进。
|
|
1448
|
+
*/
|
|
1449
|
+
interface PipelineCheckReport {
|
|
1450
|
+
ok: boolean;
|
|
1451
|
+
errors: PipelineError[];
|
|
1452
|
+
warnings: string[];
|
|
1453
|
+
/** tarball 路径(pack 成功时填) */
|
|
1454
|
+
tarballPath?: string;
|
|
1455
|
+
/** tarball 内文件清单(前缀通常是 "package/") */
|
|
1456
|
+
tarballEntries?: string[];
|
|
1457
|
+
/**
|
|
1458
|
+
* templates/commands/*.md 中存在但 package.json `files` 漏列的文件。
|
|
1459
|
+
* 这是 v4.2.0 debate.md 漏 register 那种事故的最常见 root cause。
|
|
1460
|
+
*/
|
|
1461
|
+
missingFromPackageJson: string[];
|
|
1462
|
+
}
|
|
1463
|
+
/** runPipelineCheck 输入选项 */
|
|
1464
|
+
interface PipelineCheckOptions {
|
|
1465
|
+
/** 项目根目录(含 package.json + templates/)。默认 process.cwd() */
|
|
1466
|
+
workdir?: string;
|
|
1467
|
+
/** 是否真跑 `pnpm pack`(默认 true);false 时跳过仅做 package.json 静态比对 */
|
|
1468
|
+
doPnpmPack?: boolean;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* 跑 `pnpm pack` 在 workdir 下,返回生成的 tarball 绝对路径。
|
|
1472
|
+
*
|
|
1473
|
+
* pnpm pack 输出最后一行是 tarball 文件名(如 "ccg-workflow-4.3.0.tgz")。
|
|
1474
|
+
* 失败 → throw 给上层 catch。
|
|
1475
|
+
*/
|
|
1476
|
+
declare function runPnpmPack(workdir: string): string;
|
|
1477
|
+
/**
|
|
1478
|
+
* 列 tarball 内所有文件路径(不解压)。tar 工具 cross-platform:
|
|
1479
|
+
* Unix tar / Windows bsdtar / Git Bash tar 都支持 `-tzf`。
|
|
1480
|
+
*
|
|
1481
|
+
* 失败 → throw(多半是 tar 工具不存在)。
|
|
1482
|
+
*/
|
|
1483
|
+
declare function auditTarballContents(tarballPath: string): string[];
|
|
1484
|
+
/**
|
|
1485
|
+
* 比对 `templates/commands/*.md` 实际存在的文件 vs `package.json` `files`
|
|
1486
|
+
* 数组 / tarball 实际打包内容,找出漏列文件。
|
|
1487
|
+
*
|
|
1488
|
+
* 这是 v4.2.0 release blocker `debate.md` 漏 package.json files 那种事故
|
|
1489
|
+
* 的核心检测——`templates/commands/debate.md` 在 git 树里有但 package.json
|
|
1490
|
+
* `files` 数组未列出,导致 npm pack 不打入 tarball。
|
|
1491
|
+
*
|
|
1492
|
+
* 检测分两层:
|
|
1493
|
+
* 1. 实际文件 vs package.json files 静态比对(不需要 tarball)
|
|
1494
|
+
* 2. 实际文件 vs tarball entries 比对(如果 tarball 提供)
|
|
1495
|
+
*
|
|
1496
|
+
* 任一层报漏列即视为问题。
|
|
1497
|
+
*/
|
|
1498
|
+
declare function verifyAllCommandsIncluded(workdir: string, tarballEntries?: string[]): {
|
|
1499
|
+
packageFiles: string[];
|
|
1500
|
+
actualCommands: string[];
|
|
1501
|
+
missingInPackageJson: string[];
|
|
1502
|
+
missingInTarball: string[];
|
|
1503
|
+
};
|
|
1504
|
+
/**
|
|
1505
|
+
* 端到端 pipeline check:pack → audit → 漏列检测。
|
|
1506
|
+
*
|
|
1507
|
+
* 主线 spawn phase-runner 完成 commit 后调一次。任一 critical 错误(pack-failed
|
|
1508
|
+
* / missing-from-tarball / package-json-missing)→ ok=false → 主线进 blocker 路径。
|
|
1509
|
+
*
|
|
1510
|
+
* @param opts 配置;workdir 默认 process.cwd()
|
|
1511
|
+
* @returns PipelineCheckReport(不抛错,所有失败模式都进 errors 数组)
|
|
1512
|
+
*/
|
|
1513
|
+
declare function runPipelineCheck(opts?: PipelineCheckOptions): PipelineCheckReport;
|
|
1514
|
+
/**
|
|
1515
|
+
* 把 PipelineCheckReport 渲染为人可读的 markdown,主线给用户展示用。
|
|
1516
|
+
*/
|
|
1517
|
+
declare function renderPipelineReport(report: PipelineCheckReport): string;
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Ground Truth Sampler (CCG v4.3 Phase 26).
|
|
1521
|
+
*
|
|
1522
|
+
* 实时从用户机器**采样**外部接口的真实状态——不是写一份"基于历史快照的猜测"
|
|
1523
|
+
* 文档(CCG 自己都做不到把所有 spec 文档同步),而是每次需要时即时读取真实
|
|
1524
|
+
* 状态:
|
|
1525
|
+
*
|
|
1526
|
+
* - plugin 列表(~/.claude/plugins/installed_plugins.json)
|
|
1527
|
+
* - skill 列表(~/.claude/skills/**\/SKILL.md frontmatter)
|
|
1528
|
+
* - hook event schema(~/.claude/settings.json hooks 段)
|
|
1529
|
+
* - package.json files vs templates/commands/ 一致性
|
|
1530
|
+
*
|
|
1531
|
+
* 输出到 .context/ground-truth/<ISO timestamp>.json + 软链 latest.json,
|
|
1532
|
+
* phase-runner prompt 强约束 "写涉及外部接口代码前必须 Read latest.json"。
|
|
1533
|
+
*
|
|
1534
|
+
* 解决 v4.2.0 codex:codex-rescue 同型事故:phase-runner 写代码时根本没机会
|
|
1535
|
+
* 凭训练数据猜外部接口名——它必须 Read 真实采样数据。
|
|
1536
|
+
*
|
|
1537
|
+
* 设计原则(与 v4.0 phase-context / v4.3 P25 pipeline-check 一致):
|
|
1538
|
+
* - 纯读取;不修改用户机器任何文件(仅读 ~/.claude/* 几个 known path)
|
|
1539
|
+
* - 失败优雅:缺文件 / 解析失败 / 权限不足都返回空数组,不抛
|
|
1540
|
+
* - Cross-platform:node:fs + node:os.homedir + node:path 内建模块
|
|
1541
|
+
* - 输出 schema 自描述(含 sampledAt timestamp + 来源路径)
|
|
1542
|
+
*
|
|
1543
|
+
* 调用方:
|
|
1544
|
+
* - autonomous.md Step 4.0 启动时 sampleAll + writeGroundTruth
|
|
1545
|
+
* - phase-runner 的子任务(间接通过 prompt Read latest.json)
|
|
1546
|
+
* - P28 测试 fixtures 自动生成(基于真采样输出)
|
|
1547
|
+
*
|
|
1548
|
+
* 不做:
|
|
1549
|
+
* - 不真 spawn plugin 验证(引擎层禁,且开销大)
|
|
1550
|
+
* - 不修改 settings.json / installed_plugins.json
|
|
1551
|
+
* - 不下载 marketplace 元数据
|
|
1552
|
+
*/
|
|
1553
|
+
/**
|
|
1554
|
+
* 单个 plugin 的真实状态摘要。subagentTypeHints 是从 plugin 名/manifest 推断
|
|
1555
|
+
* 的可能 subagent_type(仅启发,不是绝对真值——绝对真值得真 spawn 试,引擎禁)。
|
|
1556
|
+
*/
|
|
1557
|
+
interface PluginInfo {
|
|
1558
|
+
/** plugin 唯一标识(如 "codex@claude-plugins-official") */
|
|
1559
|
+
name: string;
|
|
1560
|
+
/** 简单名("codex" / "gemini") */
|
|
1561
|
+
shortName: string;
|
|
1562
|
+
/** 安装版本 */
|
|
1563
|
+
version: string;
|
|
1564
|
+
/** 安装绝对路径,可选 */
|
|
1565
|
+
installPath?: string;
|
|
1566
|
+
/**
|
|
1567
|
+
* 经验性 subagent_type 名称提示(基于已知 marketplace 命名规则):
|
|
1568
|
+
* - codex@... → "codex:codex-rescue" (Agent), "codex:setup"
|
|
1569
|
+
* - gemini@... → "gemini:gemini-rescue" (Agent), "gemini:setup"
|
|
1570
|
+
* 命名空间分离(v4.4.1):Agent subagent_type 双前缀;Skill 单前缀。
|
|
1571
|
+
* 仅供 phase-runner 参考;真值需 user 机器实际 system prompt 验证。
|
|
1572
|
+
*/
|
|
1573
|
+
subagentTypeHints?: string[];
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* 单个 skill 的真实状态摘要(CCG 安装的 skills/ccg/ 命名空间下)。
|
|
1577
|
+
*/
|
|
1578
|
+
interface SkillInfo {
|
|
1579
|
+
/** SKILL.md frontmatter `name` 字段 */
|
|
1580
|
+
name: string;
|
|
1581
|
+
/** SKILL.md 绝对路径 */
|
|
1582
|
+
path: string;
|
|
1583
|
+
/** frontmatter `user-invocable` 字段(默认 false) */
|
|
1584
|
+
userInvocable: boolean;
|
|
1585
|
+
/** 推断分类(按目录路径) */
|
|
1586
|
+
category?: 'tool' | 'domain' | 'impeccable' | 'orchestration' | 'unknown';
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* 单个 hook event 的真实 schema 摘要(settings.json hooks 段)。
|
|
1590
|
+
*/
|
|
1591
|
+
interface HookInfo {
|
|
1592
|
+
/** event 名(如 "PostToolUse" / "SessionStart") */
|
|
1593
|
+
event: string;
|
|
1594
|
+
/** matcher 字段实际类型(用户机器上就是怎么写的) */
|
|
1595
|
+
matcherType: 'string' | 'array' | 'object' | 'null' | 'absent' | 'other';
|
|
1596
|
+
/** 该 event 注册了几个 hook 入口 */
|
|
1597
|
+
hookCount: number;
|
|
1598
|
+
/** 第一个 hook command 字符串前 80 字符(仅 debug 用,不含敏感路径) */
|
|
1599
|
+
firstCommandPreview?: string;
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* 项目维度采样:package.json files 跟 templates/commands/ 的一致性快照。
|
|
1603
|
+
*/
|
|
1604
|
+
interface PackageStructureInfo {
|
|
1605
|
+
/** package.json `files` 数组原文 */
|
|
1606
|
+
packageFiles: string[];
|
|
1607
|
+
/** templates/commands/*.md 实际文件相对路径列表 */
|
|
1608
|
+
templateCommands: string[];
|
|
1609
|
+
/** 实际存在但 packageFiles 漏列的文件(v4.2.0 debate.md 同型事故的检测) */
|
|
1610
|
+
missingFromPackageFiles: string[];
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* 完整 ground truth snapshot。所有 sub-section 都可能为空(来源文件不存在时)。
|
|
1614
|
+
*/
|
|
1615
|
+
interface GroundTruth {
|
|
1616
|
+
/** ISO 8601 采样时间戳 */
|
|
1617
|
+
sampledAt: string;
|
|
1618
|
+
/** ~/.claude/plugins/installed_plugins.json 读出的 plugin 列表 */
|
|
1619
|
+
plugins: PluginInfo[];
|
|
1620
|
+
/** ~/.claude/skills/ccg/**\/SKILL.md 解析的 skill 列表 */
|
|
1621
|
+
skills: SkillInfo[];
|
|
1622
|
+
/** ~/.claude/settings.json hooks 段实际 schema */
|
|
1623
|
+
hooks: HookInfo[];
|
|
1624
|
+
/** 项目维度(仅 sampleAll 传 workdir 时填) */
|
|
1625
|
+
packageStructure?: PackageStructureInfo;
|
|
1626
|
+
/** 采样过程中的非致命警告 */
|
|
1627
|
+
warnings: string[];
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* 读 ~/.claude/plugins/installed_plugins.json,返回标准化的 PluginInfo[]。
|
|
1631
|
+
* 文件不存在 → [] + warning;JSON 解析失败 → [] + warning。
|
|
1632
|
+
*/
|
|
1633
|
+
declare function samplePluginList(homeDir?: string): {
|
|
1634
|
+
plugins: PluginInfo[];
|
|
1635
|
+
warnings: string[];
|
|
1636
|
+
};
|
|
1637
|
+
/**
|
|
1638
|
+
* 扫 ~/.claude/skills/ccg/**\/SKILL.md,解析 frontmatter 给出 skill 列表。
|
|
1639
|
+
*
|
|
1640
|
+
* 仅读 ccg/ 命名空间,避免读到用户自建或其他 plugin 的 skill。
|
|
1641
|
+
*/
|
|
1642
|
+
declare function sampleSkillList(homeDir?: string): {
|
|
1643
|
+
skills: SkillInfo[];
|
|
1644
|
+
warnings: string[];
|
|
1645
|
+
};
|
|
1646
|
+
/**
|
|
1647
|
+
* 读 ~/.claude/settings.json 的 hooks 段,输出每个 event 的真实 schema 摘要。
|
|
1648
|
+
*
|
|
1649
|
+
* 这次 v4.1 P13 SessionStart hook 注册写错(matcher 字段是 string 还是 array)就是
|
|
1650
|
+
* 此采样要解决的——phase-runner 写 hook 集成代码前必须先看这份采样。
|
|
1651
|
+
*/
|
|
1652
|
+
declare function sampleHookSchema(homeDir?: string): {
|
|
1653
|
+
hooks: HookInfo[];
|
|
1654
|
+
warnings: string[];
|
|
1655
|
+
};
|
|
1656
|
+
/**
|
|
1657
|
+
* 采样项目 package.json `files` vs templates/commands/ 真实状态。
|
|
1658
|
+
* 跟 P25 pipeline-check.verifyAllCommandsIncluded 同源逻辑,但这里**仅采样**
|
|
1659
|
+
* 不做判定(pipeline-check 才决定 ok/fail)。
|
|
1660
|
+
*/
|
|
1661
|
+
declare function samplePackageStructure(workdir: string): {
|
|
1662
|
+
info: PackageStructureInfo | null;
|
|
1663
|
+
warnings: string[];
|
|
1664
|
+
};
|
|
1665
|
+
interface SampleOptions {
|
|
1666
|
+
/** 用户机器 home dir。默认 os.homedir()。仅测试用。 */
|
|
1667
|
+
homeDir?: string;
|
|
1668
|
+
/** 项目根目录。传入则采样项目维度(package.json + templates/) */
|
|
1669
|
+
workdir?: string;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* 一站式采样:plugins / skills / hooks /(可选)packageStructure。
|
|
1673
|
+
*
|
|
1674
|
+
* 不抛错——所有失败都进 warnings 数组让上层决定要不要 escalate。
|
|
1675
|
+
*/
|
|
1676
|
+
declare function sampleAll(opts?: SampleOptions): GroundTruth;
|
|
1677
|
+
/**
|
|
1678
|
+
* 把 GroundTruth 序列化为人可读的简短摘要(≤500 token),phase-runner prompt
|
|
1679
|
+
* 注入用。完整版见 latest.json。
|
|
1680
|
+
*/
|
|
1681
|
+
declare function summarizeGroundTruth(gt: GroundTruth): string;
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* Interface Auditor (CCG v4.3 Phase 27).
|
|
1685
|
+
*
|
|
1686
|
+
* 跨 phase 接口审计 verifier specialist。每 phase commit 后由主线在 quality-router
|
|
1687
|
+
* triple/debate 模式的 verify wave 内并行 spawn 一次(与 codex+gemini cross-vendor
|
|
1688
|
+
* verify 并列)。
|
|
1689
|
+
*
|
|
1690
|
+
* 检测 6 类**真实事故型**风险:
|
|
1691
|
+
*
|
|
1692
|
+
* 1. SSoT 违反(critical)— 重复 type / 重复实现(v4.2 P22 重新引入 planVerifyWave 同型)
|
|
1693
|
+
* 2. 半成品(major)— export 但无 import consumer(v4.1 P19 paths 字段无 consumer 同型)
|
|
1694
|
+
* 3. magic string 不在 ground truth(critical)— 硬编码 subagent_type / hook event
|
|
1695
|
+
* 跟 P26 sampler 实采集合不符(v4.2.0 codex:codex-rescue 同型)
|
|
1696
|
+
* 4. commit message vs diff 一致性(major)— 与 P29 hook 协作的事后审
|
|
1697
|
+
* 5. mock 与 ground truth schema 偏差(info/major)— 与 P28 fixtures 协作的线索提供
|
|
1698
|
+
* 6. alien files staged(critical)— `git diff --cached --name-only` 含本 phase 范围
|
|
1699
|
+
* 外文件(v4.4 P34:wave 1 race 检查;与 phase-runner.md "git add 显式列文件"约束配套)
|
|
1700
|
+
*
|
|
1701
|
+
* 设计原则(与 v4.2.1 verify-orchestrator / challenger-orchestrator 一致):
|
|
1702
|
+
* - 纯函数:本模块仅提供 parser + 类型 schema;agent 实现逻辑放 prompt 里
|
|
1703
|
+
* - 复用 challenger-orchestrator.parseFindings 鲁棒化(单/双引号 / json fence /
|
|
1704
|
+
* balanced-bracket tokenizer 兜底)
|
|
1705
|
+
* - 输出协议与 challenger / verify summary 同源(STATUS / FINDINGS / NOTES),
|
|
1706
|
+
* 调用方决定语义
|
|
1707
|
+
*
|
|
1708
|
+
* 调用方:
|
|
1709
|
+
* - templates/commands/autonomous.md Step 4.4 verify wave 综合
|
|
1710
|
+
* - quality-router.ts.buildVerifyWave (triple/debate spawns 内追加 interface-auditor)
|
|
1711
|
+
*
|
|
1712
|
+
* 不做:
|
|
1713
|
+
* - 不实际 spawn agent(主线 LLM 派发;本 helper 只产出 schema + 解析)
|
|
1714
|
+
* - 不读 ground truth 文件(agent prompt 内 Read,本 helper 处理结果摘要)
|
|
1715
|
+
* - 不实现 5 项检查(agent 自己 grep + Bash 完成,本 helper 仅解析摘要)
|
|
1716
|
+
*/
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Interface auditor 5 类 finding category 枚举。
|
|
1720
|
+
*
|
|
1721
|
+
* 严格枚举的目的:主线综合 verify 决策时可按 category 分组阈值(譬如 ssot-violation
|
|
1722
|
+
* 永远 critical,mock-drift 永远 info)。
|
|
1723
|
+
*/
|
|
1724
|
+
type InterfaceAuditCategory = 'ssot-violation' | 'leftover' | 'magic-string-mismatch' | 'commit-diff-drift' | 'mock-drift' | 'alien-files-staged' | 'unknown';
|
|
1725
|
+
/**
|
|
1726
|
+
* Interface auditor 单条 finding。比通用 Finding 更紧(category 严格枚举)。
|
|
1727
|
+
*/
|
|
1728
|
+
interface InterfaceAuditFinding {
|
|
1729
|
+
severity: FindingSeverity;
|
|
1730
|
+
category: InterfaceAuditCategory;
|
|
1731
|
+
message: string;
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Interface auditor ≤200 token 摘要解析后的结构。
|
|
1735
|
+
*/
|
|
1736
|
+
interface InterfaceAuditReport {
|
|
1737
|
+
/** 解析状态 */
|
|
1738
|
+
status: 'complete' | 'error';
|
|
1739
|
+
/** 5 类检查命中的 finding(含 critical/major/info 三档) */
|
|
1740
|
+
findings: InterfaceAuditFinding[];
|
|
1741
|
+
/** Notes 字段 */
|
|
1742
|
+
notes: string;
|
|
1743
|
+
/** 原始摘要文本(debug 用) */
|
|
1744
|
+
raw: string;
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* 解析 interface-auditor agent 返回的 ≤200 token 摘要文本。
|
|
1748
|
+
*
|
|
1749
|
+
* 复用 challenger-orchestrator.parseChallengerSummary 的鲁棒化 parser(同样的
|
|
1750
|
+
* STATUS / FINDINGS / NOTES 协议 + 单引号/双引号/json-fence/嵌套 {} 容错),
|
|
1751
|
+
* 然后把 generic Finding[] 收紧成 InterfaceAuditFinding[](category 枚举 normalize)。
|
|
1752
|
+
*
|
|
1753
|
+
* 与 verify-orchestrator.parseVerifyReport 不同点:
|
|
1754
|
+
* - 不区分 criticals / majors(本模块由调用方在 synthesize 时按 severity 分组)
|
|
1755
|
+
* - category 严格枚举到 InterfaceAuditCategory(unknown 兜底,不丢 finding)
|
|
1756
|
+
*
|
|
1757
|
+
* @param text agent 返回的 ≤200 token 摘要原文
|
|
1758
|
+
*/
|
|
1759
|
+
declare function parseInterfaceAuditorReport(text: string): InterfaceAuditReport;
|
|
1760
|
+
/**
|
|
1761
|
+
* 取出 critical findings(主线 synthesize 决策:任一 critical → revise)。
|
|
1762
|
+
*/
|
|
1763
|
+
declare function criticalFindings(report: InterfaceAuditReport): InterfaceAuditFinding[];
|
|
1764
|
+
/**
|
|
1765
|
+
* 取出 major findings(参考用,不阻塞推进;与 verify-orchestrator 语义一致)。
|
|
1766
|
+
*/
|
|
1767
|
+
declare function majorFindings(report: InterfaceAuditReport): InterfaceAuditFinding[];
|
|
1768
|
+
/**
|
|
1769
|
+
* 是否含可阻塞推进的 finding(critical)。供主线 synthesize 调用。
|
|
1770
|
+
*/
|
|
1771
|
+
declare function hasBlockingFindings(report: InterfaceAuditReport): boolean;
|
|
1772
|
+
|
|
1773
|
+
export { ALL_LAYERS, CONTEXT_BUDGET_THRESHOLD, DESCRIPTION_SOFT_LIMIT, ROUTING_SCHEMA_VERSION, aggregatePlans, auditSkillDescriptions, auditSkillsDirectory, auditTarballContents, batchByMaxConcurrent, bothPluginsInstalled, buildQualityPlan, buildWaves, cascadeSkip, changeLanguage, checkForUpdates, collectInvocableSkills, collectSkills, compareVersions, contextPath, createDefaultConfig, createDefaultRouting, decideFromSummaries, detectPlugin, detectPluginAvailability, estimateBriefLength, estimateTokens, extractFrontmatter, generateCommandContent, getCcgDir, getConfigPath, getCurrentVersion, getLatestVersion, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installAceTool, installAceToolRs, installSkillCommands, installWorkflows, criticalFindings as interfaceAuditCriticals, hasBlockingFindings as interfaceAuditHasBlocking, majorFindings as interfaceAuditMajors, isLayer, migrateToV1_4_0, needsMigration, parseChallengerSummary, parseDependsOn, parseFrontmatter, parseFrontmatterFields, parseInterfaceAuditorReport, parseQualityFlag, parseRoadmap, parseRoleFlag, parseVerifyReport, phaseDir, planChallengerSpawns, planVerifyWave, planWavesForTier, promptFilePath, readCcgConfig, readContext, readSummary, readSummaryFrontmatter, renderAuditMarkdown, renderPipelineReport, resolveQualityTier, routeSpecialist, runPipelineCheck, runPnpmPack, sampleAll, sampleHookSchema, samplePackageStructure, samplePluginList, sampleSkillList, sanitizePhase, schedule, serializeBriefForPrompt, showMainMenu, summarizeGroundTruth, summaryPath, summaryTokenEstimate, synthesizeRevisionFeedback, synthesizeVerifyFeedback, synthesizeVerifyResults, uninstallAceTool, uninstallWorkflows, update, verifyAllCommandsIncluded, writeCcgConfig, writeContext, writeSummary };
|
|
1774
|
+
export type { AceToolConfig, AuditReport, AuditRow, CcgConfig, ChallengeInput, ChallengerAgent, ChallengerDecision, ChallengerPlan, ChallengerSummary, CliOptions, CollaborationMode, DesignBrief, Divergence, FastContextConfig, Finding, FindingSeverity, GroundTruth, PluginInfo as GroundTruthPluginInfo, SkillInfo as GroundTruthSkillInfo, HookInfo, InitOptions, InstallResult, InterfaceAuditCategory, InterfaceAuditFinding, InterfaceAuditReport, Layer, Model, ModelRouting, ModelType, PackageStructureInfo, PhaseContext, PhaseMeta, PhaseStatus, PhaseSummary, PipelineCheckOptions, PipelineCheckReport, PipelineError, PipelineErrorCategory, PlanContribution, PlanVerifyWaveOptions, PluginAdvisor, PluginAvailability, PluginAvailability as PluginDetectionAvailability, PluginDetectionResult, PluginName, QualityPlan, SpawnEntry as QualitySpawnEntry, QualityTier, WavePlan as QualityWavePlan, ResolveInput, RoadmapPhase, Role, PluginAvailability as RoutingPluginAvailability, RoutingStrategy, SampleOptions, ScheduleOptions, SkillCategory, SkillMeta, SkillRuntimeType, SpawnEntry$1 as SpawnEntry, SpecialistCritic, SpecialistLayer, SpecialistModel, SpecialistRole, SpecialistRoute, SupportedLang, VerifyDecision, VerifyInvocationMode, VerifyMode, VerifyReport, VerifySpawnEntry, VerifyWavePlan, WaveKind, WaveSchedule, WorkflowConfig };
|