@hunyed15/codecgc 0.1.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/.claude/hooks/route-edit.ps1 +86 -0
- package/INSTALLATION.md +550 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/bin/cgc-build.js +4 -0
- package/bin/cgc-doctor.js +4 -0
- package/bin/cgc-entry.js +4 -0
- package/bin/cgc-external-audit.js +4 -0
- package/bin/cgc-fix.js +4 -0
- package/bin/cgc-history.js +4 -0
- package/bin/cgc-install.js +4 -0
- package/bin/cgc-lifecycle.js +4 -0
- package/bin/cgc-package-audit.js +4 -0
- package/bin/cgc-plan.js +4 -0
- package/bin/cgc-release-readiness.js +4 -0
- package/bin/cgc-review.js +4 -0
- package/bin/cgc-route.js +4 -0
- package/bin/cgc-status.js +4 -0
- package/bin/cgc-test.js +4 -0
- package/bin/cgc.js +4 -0
- package/bin/codecgc.js +1284 -0
- package/codecgc/cgc/SKILL.md +46 -0
- package/codecgc/cgc-arch/SKILL.md +61 -0
- package/codecgc/cgc-build/SKILL.md +53 -0
- package/codecgc/cgc-decide/SKILL.md +55 -0
- package/codecgc/cgc-fix/SKILL.md +47 -0
- package/codecgc/cgc-learn/SKILL.md +46 -0
- package/codecgc/cgc-onboard/SKILL.md +52 -0
- package/codecgc/cgc-plan/SKILL.md +48 -0
- package/codecgc/cgc-refactor/SKILL.md +46 -0
- package/codecgc/cgc-req/SKILL.md +61 -0
- package/codecgc/cgc-review/SKILL.md +57 -0
- package/codecgc/cgc-roadmap/SKILL.md +55 -0
- package/codecgc/cgc-test/SKILL.md +21 -0
- package/codecgc/reference/api-cgc-review-libdoc.md +13 -0
- package/codecgc/reference/artifact-class-policy.md +81 -0
- package/codecgc/reference/build-flow.md +95 -0
- package/codecgc/reference/checklist-contract.md +103 -0
- package/codecgc/reference/execution-audit.md +121 -0
- package/codecgc/reference/execution-model.md +118 -0
- package/codecgc/reference/execution-routing.md +130 -0
- package/codecgc/reference/executor-contract.md +87 -0
- package/codecgc/reference/external-capability-registry.json +104 -0
- package/codecgc/reference/fix-flow.md +94 -0
- package/codecgc/reference/fixture-governance.md +60 -0
- package/codecgc/reference/flow-execution.md +65 -0
- package/codecgc/reference/lifecycle-map.md +172 -0
- package/codecgc/reference/lifecycle-playbook.md +104 -0
- package/codecgc/reference/long-lived-artifacts.md +98 -0
- package/codecgc/reference/operation-guide.md +242 -0
- package/codecgc/reference/release-maintenance-playbook.md +150 -0
- package/codecgc/reference/review-writeback.md +141 -0
- package/codecgc/reference/role-model.md +128 -0
- package/codecgc/reference/runtime-boundary.md +72 -0
- package/codecgc/reference/shared-conventions.md +93 -0
- package/codecgc/reference/workflow-scaffold.md +57 -0
- package/codexmcp/LICENSE +21 -0
- package/codexmcp/README.md +294 -0
- package/codexmcp/pyproject.toml +37 -0
- package/codexmcp/src/codexmcp/__init__.py +4 -0
- package/codexmcp/src/codexmcp/cli.py +12 -0
- package/codexmcp/src/codexmcp/server.py +529 -0
- package/geminimcp/README.md +258 -0
- package/geminimcp/pyproject.toml +15 -0
- package/geminimcp/src/geminimcp/__init__.py +4 -0
- package/geminimcp/src/geminimcp/cli.py +12 -0
- package/geminimcp/src/geminimcp/server.py +465 -0
- package/model-routing.yaml +30 -0
- package/package.json +90 -0
- package/requirements.txt +1 -0
- package/scripts/README-codecgc-cli.md +89 -0
- package/scripts/audit_codecgc_external_capabilities.py +276 -0
- package/scripts/audit_codecgc_historical_audits.py +242 -0
- package/scripts/audit_codecgc_lifecycle.py +241 -0
- package/scripts/audit_codecgc_package_runtime.py +445 -0
- package/scripts/audit_codecgc_release_readiness.py +202 -0
- package/scripts/audit_codecgc_review_policy.py +82 -0
- package/scripts/audit_codecgc_workflow_history.py +317 -0
- package/scripts/build_codecgc_task.py +487 -0
- package/scripts/codecgc_artifact_roots.py +40 -0
- package/scripts/codecgc_cli.py +843 -0
- package/scripts/codecgc_command_surface.py +28 -0
- package/scripts/codecgc_console_io.py +45 -0
- package/scripts/codecgc_executor_registry.py +54 -0
- package/scripts/codecgc_file_evidence.py +349 -0
- package/scripts/codecgc_flow_control.py +233 -0
- package/scripts/codecgc_governance_dedupe.py +161 -0
- package/scripts/codecgc_plan_decision.py +103 -0
- package/scripts/codecgc_review_control.py +588 -0
- package/scripts/codecgc_roadmap_templates.py +149 -0
- package/scripts/codecgc_routing_paths.py +16 -0
- package/scripts/codecgc_routing_template.py +135 -0
- package/scripts/codecgc_runtime_paths.py +22 -0
- package/scripts/codecgc_session_recovery.py +44 -0
- package/scripts/codecgc_step_control.py +154 -0
- package/scripts/codecgc_workflow_runtime.py +63 -0
- package/scripts/codecgc_workflow_templates.py +437 -0
- package/scripts/entry_codecgc_workflow.py +3419 -0
- package/scripts/exercise_mcp_tools.py +109 -0
- package/scripts/expand_codecgc_roadmap.py +664 -0
- package/scripts/init_codecgc_roadmap.py +134 -0
- package/scripts/init_codecgc_workflow.py +207 -0
- package/scripts/install_codecgc.py +938 -0
- package/scripts/migrate_demo_workflows_to_fixtures.py +128 -0
- package/scripts/normalize_codecgc_audits.py +114 -0
- package/scripts/normalize_codecgc_governance_docs.py +79 -0
- package/scripts/normalize_codecgc_workflow_docs.py +269 -0
- package/scripts/plan_codecgc_workflow.py +970 -0
- package/scripts/refresh_codecgc_review_policy.py +223 -0
- package/scripts/review_codecgc_workflow.py +88 -0
- package/scripts/route_codecgc_workflow.py +671 -0
- package/scripts/run_codecgc_build.py +104 -0
- package/scripts/run_codecgc_fix.py +104 -0
- package/scripts/run_codecgc_flow_step.py +165 -0
- package/scripts/run_codecgc_task.py +410 -0
- package/scripts/run_codecgc_test.py +105 -0
- package/scripts/sync_codecgc_mcp_config.py +41 -0
- package/scripts/write_codecgc_architecture.py +78 -0
- package/scripts/write_codecgc_decision.py +83 -0
- package/scripts/write_codecgc_explore.py +118 -0
- package/scripts/write_codecgc_guide.py +141 -0
- package/scripts/write_codecgc_learning.py +87 -0
- package/scripts/write_codecgc_libdoc.py +140 -0
- package/scripts/write_codecgc_refactor.py +78 -0
- package/scripts/write_codecgc_requirement.py +78 -0
- package/scripts/write_codecgc_review.py +291 -0
- package/scripts/write_codecgc_roadmap.py +122 -0
- package/scripts/write_codecgc_trick.py +123 -0
package/bin/codecgc.js
ADDED
|
@@ -0,0 +1,1284 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const { existsSync } = require("node:fs");
|
|
5
|
+
const { readFileSync } = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const repoRoot = path.resolve(__dirname, "..");
|
|
9
|
+
const invocationCwd = process.cwd();
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const invokedBinary = (process.env.CODECGC_BIN_NAME || path.basename(process.argv[1] || "cgc")).toLowerCase();
|
|
12
|
+
const packageJson = JSON.parse(readFileSync(path.join(repoRoot, "package.json"), "utf8"));
|
|
13
|
+
const productVersion = packageJson.version || "0.0.0";
|
|
14
|
+
const DIRECT_COMMANDS = new Set([
|
|
15
|
+
"install",
|
|
16
|
+
"status",
|
|
17
|
+
"doctor",
|
|
18
|
+
"package-audit",
|
|
19
|
+
"external-audit",
|
|
20
|
+
"release-readiness",
|
|
21
|
+
"lifecycle",
|
|
22
|
+
"history",
|
|
23
|
+
"entry",
|
|
24
|
+
"plan",
|
|
25
|
+
"build",
|
|
26
|
+
"fix",
|
|
27
|
+
"test",
|
|
28
|
+
"review",
|
|
29
|
+
"route",
|
|
30
|
+
]);
|
|
31
|
+
const DASH_COMMANDS = new Set(Array.from(DIRECT_COMMANDS, (command) => `cgc-${command}`));
|
|
32
|
+
|
|
33
|
+
const helpText = `CodeCGC 命令入口
|
|
34
|
+
|
|
35
|
+
用法:
|
|
36
|
+
cgc --help
|
|
37
|
+
cgc --version
|
|
38
|
+
cgc <自然语言需求>
|
|
39
|
+
cgc --request <text>
|
|
40
|
+
cgc --latest
|
|
41
|
+
cgc --slug <workflow-slug>
|
|
42
|
+
cgc-install [--mode local|user-dry-run|user|status|doctor] [--workspace <dir>] [--user-root <dir>]
|
|
43
|
+
cgc-status [--format json|summary]
|
|
44
|
+
cgc-doctor [--format json|summary]
|
|
45
|
+
cgc-package-audit [--format json|summary]
|
|
46
|
+
cgc-external-audit [--format json|summary] [--workspace <dir>]
|
|
47
|
+
cgc-release-readiness [--format json|summary] [--workspace <dir>]
|
|
48
|
+
cgc-lifecycle [--format json|summary]
|
|
49
|
+
cgc-history [--flow all|feature|issue] [--status all|open|closed] [--last <n>] [--format json|summary]
|
|
50
|
+
cgc-entry [--request <text> | --payload-file <file> | --payload-base64 <b64>]
|
|
51
|
+
cgc-plan ...
|
|
52
|
+
cgc-build ...
|
|
53
|
+
cgc-fix ...
|
|
54
|
+
cgc-test ...
|
|
55
|
+
cgc-review ...
|
|
56
|
+
cgc-route ...
|
|
57
|
+
|
|
58
|
+
按目标选择:
|
|
59
|
+
我只想直接说一句需求,让 CodeCGC 自己判断下一步
|
|
60
|
+
cgc "新增一个登录页面,放在 src/components/LoginForm.tsx"
|
|
61
|
+
我想继续刚刚的工作,不想先判断该用哪个子命令
|
|
62
|
+
cgc "继续刚刚的工作"
|
|
63
|
+
我只想对最近工作流说“直接做 / 通过 / 不通过 / 看下一步”
|
|
64
|
+
cgc "直接做"
|
|
65
|
+
cgc "通过"
|
|
66
|
+
cgc "现在下一步该做什么"
|
|
67
|
+
我想直接问当前工作流下一步做什么
|
|
68
|
+
cgc --slug 2026-05-01-demo-login-ui
|
|
69
|
+
我已经知道这是新需求或问题,但还想先补齐规划再执行
|
|
70
|
+
cgc-plan ...
|
|
71
|
+
我已经确认当前步骤可以开始执行
|
|
72
|
+
cgc-build / cgc-fix
|
|
73
|
+
我已经进入当前工作流的测试补充阶段
|
|
74
|
+
cgc-test
|
|
75
|
+
我已经有 audit,想回写审核结果
|
|
76
|
+
cgc-review ...
|
|
77
|
+
我只想让 CodeCGC 告诉我下一步该跑哪个命令
|
|
78
|
+
cgc-route ...
|
|
79
|
+
我想把 CodeCGC 安装或重新同步到当前项目
|
|
80
|
+
cgc-install
|
|
81
|
+
我想知道集成面现在是否就绪
|
|
82
|
+
cgc-status
|
|
83
|
+
我想知道运行前置和执行器能不能真正启动
|
|
84
|
+
cgc-doctor
|
|
85
|
+
我想确认发布包没有漏掉运行时文件
|
|
86
|
+
cgc-package-audit
|
|
87
|
+
我想确认第三方能力接入策略和本地 MCP 注册状态
|
|
88
|
+
cgc-external-audit
|
|
89
|
+
我想在发布或长期维护前跑一次总检查
|
|
90
|
+
cgc-release-readiness
|
|
91
|
+
我想快速判断当前仓库处于哪个生命周期阶段
|
|
92
|
+
cgc-lifecycle
|
|
93
|
+
我想只读查看最近 workflow 历史
|
|
94
|
+
cgc-history
|
|
95
|
+
我只描述需求,让 CodeCGC 帮我判断下一步
|
|
96
|
+
cgc-entry
|
|
97
|
+
我已经知道当前阶段,想直接执行某个工作流命令
|
|
98
|
+
cgc-plan / cgc-build / cgc-fix / cgc-review / cgc-route
|
|
99
|
+
|
|
100
|
+
命令职责:
|
|
101
|
+
cgc-install 同步项目级或用户级集成面
|
|
102
|
+
cgc-status 检查集成是否就绪,并给出下一步
|
|
103
|
+
cgc-doctor 检查运行前置、执行器导入与项目集成状态
|
|
104
|
+
cgc-package-audit 检查发布包是否覆盖运行时依赖
|
|
105
|
+
cgc-external-audit 检查外部能力白名单、接入状态与本地 MCP 观测结果
|
|
106
|
+
cgc-release-readiness 汇总安装、运行时、发布包、外部接入与生命周期就绪状态
|
|
107
|
+
cgc-lifecycle 汇总 roadmap、workflow 与 execution 的生命周期阶段
|
|
108
|
+
cgc-history 只读汇总最近 feature / issue workflow 历史
|
|
109
|
+
cgc-entry 单入口路由:新需求、继续、解释下一步
|
|
110
|
+
cgc-plan 澄清并整理需求,判断是否可执行
|
|
111
|
+
cgc-build 执行一个功能开发步骤
|
|
112
|
+
cgc-fix 执行一个问题修复步骤
|
|
113
|
+
cgc-test 执行一个测试步骤
|
|
114
|
+
cgc-review 审核一次执行结果并回写状态
|
|
115
|
+
cgc-route 根据当前产物判断下一步命令
|
|
116
|
+
version 输出当前产品壳版本
|
|
117
|
+
|
|
118
|
+
首次使用:
|
|
119
|
+
1. 先在目标项目根目录执行 cgc-install
|
|
120
|
+
2. 再执行 cgc-status,必要时补 cgc-doctor
|
|
121
|
+
3. 然后直接使用 cgc "<自然语言需求>" 或 cgc-entry
|
|
122
|
+
4. 只有当你已经明确知道当前阶段时,再改用 cgc-plan / cgc-build / cgc-fix / cgc-test / cgc-review / cgc-route
|
|
123
|
+
|
|
124
|
+
示例:
|
|
125
|
+
cgc "新增一个登录页面,放在 src/components/LoginForm.tsx"
|
|
126
|
+
cgc "继续刚刚的工作"
|
|
127
|
+
cgc "直接做"
|
|
128
|
+
cgc "通过"
|
|
129
|
+
cgc --request "现在下一步该做什么"
|
|
130
|
+
cgc --latest
|
|
131
|
+
cgc --slug 2026-05-01-demo-login-ui
|
|
132
|
+
cgc-plan --flow feature --slug demo-login-ui --summary "Demo login UI feature" --target-path src/components/LoginForm.tsx --kind frontend
|
|
133
|
+
cgc-build --slug 2026-05-01-demo-login-ui --step-number 1 --dry-run
|
|
134
|
+
cgc-fix --slug 2026-05-01-demo-sync-bug --step-number 1 --dry-run
|
|
135
|
+
cgc-test --flow feature --slug 2026-05-01-demo-login-ui --step-number 2 --dry-run
|
|
136
|
+
cgc-review --audit-file codecgc/execution/demo-login-ui-step-1.json --decision accepted
|
|
137
|
+
cgc-route --flow feature --slug 2026-05-01-demo-login-ui
|
|
138
|
+
cgc-install
|
|
139
|
+
cgc-status
|
|
140
|
+
cgc-status --format summary
|
|
141
|
+
cgc-doctor --format summary
|
|
142
|
+
cgc-package-audit --format summary
|
|
143
|
+
cgc-external-audit --format summary
|
|
144
|
+
cgc-release-readiness --format summary
|
|
145
|
+
cgc-lifecycle --format summary
|
|
146
|
+
cgc-history --status open --last 10
|
|
147
|
+
cgc-install --mode user-dry-run --user-root C:\\Users\\Admin\\.claude
|
|
148
|
+
cgc-install --workspace D:\\Projects\\MyApp
|
|
149
|
+
cgc-entry --request "新增一个登录页面,放在 src/components/LoginForm.tsx"
|
|
150
|
+
|
|
151
|
+
环境变量:
|
|
152
|
+
CODECGC_PYTHON_COMMAND 覆盖产品壳与生成的 MCP 配置所使用的 Python 命令
|
|
153
|
+
CODECGC_WORKSPACE_ROOT 当当前 shell 目录不是目标项目根目录时,显式覆盖目标工作区
|
|
154
|
+
`;
|
|
155
|
+
|
|
156
|
+
const installHelpText = `CodeCGC 安装与自检
|
|
157
|
+
|
|
158
|
+
用法:
|
|
159
|
+
cgc-install [--mode <local|user-dry-run|user|status|doctor>] [--workspace <dir>] [--user-root <dir>] [--format <json|summary>]
|
|
160
|
+
|
|
161
|
+
用途:
|
|
162
|
+
准备、检查或修复 CodeCGC 在 Claude 与 MCP 启动链路上的集成面。
|
|
163
|
+
|
|
164
|
+
模式:
|
|
165
|
+
local
|
|
166
|
+
把项目级 .mcp.json、.claude/settings.json 与 route-edit.ps1 hook 同步到目标工作区。
|
|
167
|
+
user-dry-run
|
|
168
|
+
只预演用户级 Claude 集成,不写入文件。
|
|
169
|
+
user
|
|
170
|
+
把用户级 Claude 集成写入指定的 Claude 根目录。
|
|
171
|
+
status
|
|
172
|
+
检查项目级集成是否就绪,并附带用户级集成预览状态。
|
|
173
|
+
doctor
|
|
174
|
+
检查运行前置、执行器可导入性,以及项目级集成是否就绪。
|
|
175
|
+
|
|
176
|
+
主要参数:
|
|
177
|
+
--workspace <dir>
|
|
178
|
+
local/status/doctor 模式下的目标项目根目录。默认使用当前 shell 所在目录。
|
|
179
|
+
--user-root <dir>
|
|
180
|
+
user 与 user-dry-run 模式下显式指定 Claude 用户目录。
|
|
181
|
+
--format <json|summary>
|
|
182
|
+
面向 Claude 或人工阅读时建议使用 summary;排查底层细节时用 json。
|
|
183
|
+
|
|
184
|
+
推荐用法:
|
|
185
|
+
cgc-install
|
|
186
|
+
cgc-install --workspace D:\\Projects\\MyApp
|
|
187
|
+
cgc-install --mode status --format summary
|
|
188
|
+
cgc-install --mode doctor --format summary
|
|
189
|
+
cgc-install --mode user-dry-run --user-root C:\\Users\\Admin\\.claude
|
|
190
|
+
|
|
191
|
+
相关命令:
|
|
192
|
+
cgc-status
|
|
193
|
+
快速查看集成状态。
|
|
194
|
+
cgc-doctor
|
|
195
|
+
快速查看运行前置与集成前置是否齐全。
|
|
196
|
+
cgc-package-audit
|
|
197
|
+
检查 package.json files 是否覆盖安装运行所需文件。
|
|
198
|
+
cgc-external-audit
|
|
199
|
+
检查外部能力接入白名单、状态声明与本地注册观测。
|
|
200
|
+
cgc-release-readiness
|
|
201
|
+
汇总发布前与长期维护前的总检查结果。
|
|
202
|
+
cgc-lifecycle
|
|
203
|
+
汇总 roadmap、workflow 与 execution 的生命周期阶段。
|
|
204
|
+
`;
|
|
205
|
+
|
|
206
|
+
const statusHelpText = `CodeCGC 安装状态
|
|
207
|
+
|
|
208
|
+
用法:
|
|
209
|
+
cgc-status [--format <summary|json>] [--workspace <dir>]
|
|
210
|
+
|
|
211
|
+
用途:
|
|
212
|
+
检查当前项目工作区的 CodeCGC 集成是否就绪,并给出下一步建议。
|
|
213
|
+
|
|
214
|
+
默认行为:
|
|
215
|
+
不传 --format 时默认输出 summary,更适合人和 Claude 直接阅读。
|
|
216
|
+
只有在调试底层细节时才建议改用 --format json。
|
|
217
|
+
|
|
218
|
+
主要参数:
|
|
219
|
+
--workspace <dir>
|
|
220
|
+
显式指定目标项目根目录。默认使用当前 shell 所在目录。
|
|
221
|
+
--format <summary|json>
|
|
222
|
+
summary 用于产品化状态摘要,json 用于调试和自动化消费。
|
|
223
|
+
|
|
224
|
+
推荐用法:
|
|
225
|
+
cgc-status
|
|
226
|
+
cgc-status --workspace D:\\Projects\\MyApp
|
|
227
|
+
cgc-status --format json
|
|
228
|
+
|
|
229
|
+
相关命令:
|
|
230
|
+
cgc-install
|
|
231
|
+
同步或修复当前项目集成面。
|
|
232
|
+
cgc-doctor
|
|
233
|
+
检查运行前置、执行器导入和项目集成状态。
|
|
234
|
+
`;
|
|
235
|
+
|
|
236
|
+
const doctorHelpText = `CodeCGC Doctor
|
|
237
|
+
|
|
238
|
+
用法:
|
|
239
|
+
cgc-doctor [--format <summary|json>] [--workspace <dir>]
|
|
240
|
+
|
|
241
|
+
用途:
|
|
242
|
+
检查运行前置、执行器可导入性,以及当前项目工作区的集成状态。
|
|
243
|
+
|
|
244
|
+
默认行为:
|
|
245
|
+
不传 --format 时默认输出 summary,更适合直接判断环境是否可用。
|
|
246
|
+
只有在需要查看完整检查细节时才建议改用 --format json。
|
|
247
|
+
|
|
248
|
+
主要参数:
|
|
249
|
+
--workspace <dir>
|
|
250
|
+
显式指定目标项目根目录。默认使用当前 shell 所在目录。
|
|
251
|
+
--format <summary|json>
|
|
252
|
+
summary 用于产品化自检摘要,json 用于底层排查。
|
|
253
|
+
|
|
254
|
+
推荐用法:
|
|
255
|
+
cgc-doctor
|
|
256
|
+
cgc-doctor --workspace D:\\Projects\\MyApp
|
|
257
|
+
cgc-doctor --format json
|
|
258
|
+
|
|
259
|
+
相关命令:
|
|
260
|
+
cgc-status
|
|
261
|
+
快速查看项目集成是否就绪。
|
|
262
|
+
cgc-install
|
|
263
|
+
同步或修复集成文件。
|
|
264
|
+
cgc-package-audit
|
|
265
|
+
检查发布包运行面与发布就绪状态。
|
|
266
|
+
`;
|
|
267
|
+
|
|
268
|
+
const packageAuditHelpText = `CodeCGC 发布包审计
|
|
269
|
+
|
|
270
|
+
用法:
|
|
271
|
+
cgc-package-audit [--format <summary|json>]
|
|
272
|
+
|
|
273
|
+
用途:
|
|
274
|
+
检查发布包运行时覆盖、发布元数据,以及历史审计一致性是否就绪。
|
|
275
|
+
|
|
276
|
+
默认行为:
|
|
277
|
+
不传 --format 时默认输出 summary,更适合发布前快速判断是否可继续。
|
|
278
|
+
只有在需要保留结构化结果做调试或自动化时才建议改用 --format json。
|
|
279
|
+
|
|
280
|
+
主要参数:
|
|
281
|
+
--format <summary|json>
|
|
282
|
+
summary 用于发布前人工检查,json 用于底层调试或流水线消费。
|
|
283
|
+
|
|
284
|
+
推荐用法:
|
|
285
|
+
cgc-package-audit
|
|
286
|
+
cgc-package-audit --format json
|
|
287
|
+
|
|
288
|
+
相关命令:
|
|
289
|
+
cgc-install
|
|
290
|
+
检查并同步当前项目的 Claude/MCP 集成面。
|
|
291
|
+
cgc-status
|
|
292
|
+
查看当前项目集成状态。
|
|
293
|
+
cgc-doctor
|
|
294
|
+
检查运行前置与执行器导入状态。
|
|
295
|
+
`;
|
|
296
|
+
|
|
297
|
+
const externalAuditHelpText = `CodeCGC 外部能力审计
|
|
298
|
+
|
|
299
|
+
用法:
|
|
300
|
+
cgc-external-audit [--format <summary|json>] [--workspace <dir>]
|
|
301
|
+
|
|
302
|
+
用途:
|
|
303
|
+
检查 CodeCGC 已批准的第三方能力清单、接入状态声明,以及当前项目工作区可观测到的 MCP 注册状态。
|
|
304
|
+
|
|
305
|
+
默认行为:
|
|
306
|
+
不传 --format 时默认输出 summary,更适合维护者快速判断“哪些能力已正式接入、哪些只是预留位”。
|
|
307
|
+
只有在需要查看完整结构化登记信息时才建议改用 --format json。
|
|
308
|
+
|
|
309
|
+
主要参数:
|
|
310
|
+
--workspace <dir>
|
|
311
|
+
显式指定目标项目根目录。默认使用当前 shell 所在目录。
|
|
312
|
+
--format <summary|json>
|
|
313
|
+
summary 用于维护检查,json 用于调试和自动化消费。
|
|
314
|
+
|
|
315
|
+
推荐用法:
|
|
316
|
+
cgc-external-audit
|
|
317
|
+
cgc-external-audit --workspace D:\\Projects\\MyApp
|
|
318
|
+
cgc-external-audit --format json
|
|
319
|
+
`;
|
|
320
|
+
|
|
321
|
+
const releaseReadinessHelpText = `CodeCGC Release Readiness
|
|
322
|
+
|
|
323
|
+
用法:
|
|
324
|
+
cgc-release-readiness [--format <summary|json>] [--workspace <dir>]
|
|
325
|
+
|
|
326
|
+
用途:
|
|
327
|
+
汇总安装集成、运行前置、发布包、外部能力接入与生命周期资产是否就绪,用于 release / maintenance / ops 前的总检查。
|
|
328
|
+
|
|
329
|
+
默认行为:
|
|
330
|
+
不传 --format 时默认输出 summary,更适合发布前或长期维护前快速判断是否还存在阻塞。
|
|
331
|
+
只有在需要查看所有底层检查细节时才建议改用 --format json。
|
|
332
|
+
|
|
333
|
+
主要参数:
|
|
334
|
+
--workspace <dir>
|
|
335
|
+
显式指定目标项目根目录。默认使用当前 shell 所在目录。
|
|
336
|
+
--format <summary|json>
|
|
337
|
+
summary 用于维护检查,json 用于调试和自动化消费。
|
|
338
|
+
|
|
339
|
+
推荐用法:
|
|
340
|
+
cgc-release-readiness
|
|
341
|
+
cgc-release-readiness --workspace D:\\Projects\\MyApp
|
|
342
|
+
cgc-release-readiness --format json
|
|
343
|
+
`;
|
|
344
|
+
|
|
345
|
+
const lifecycleHelpText = `CodeCGC Lifecycle
|
|
346
|
+
|
|
347
|
+
用法:
|
|
348
|
+
cgc-lifecycle [--format <summary|json>]
|
|
349
|
+
|
|
350
|
+
用途:
|
|
351
|
+
汇总 roadmap、feature、issue 与 execution 审计的当前分布,帮助判断仓库处于 setup、规划、执行还是维护阶段。
|
|
352
|
+
|
|
353
|
+
默认行为:
|
|
354
|
+
不传 --format 时默认输出 summary,更适合人和 Claude 直接阅读。
|
|
355
|
+
只有在需要保留结构化统计时才建议改用 --format json。
|
|
356
|
+
|
|
357
|
+
推荐用法:
|
|
358
|
+
cgc-lifecycle
|
|
359
|
+
cgc-lifecycle --format json
|
|
360
|
+
`;
|
|
361
|
+
|
|
362
|
+
const historyHelpText = `CodeCGC Workflow History
|
|
363
|
+
|
|
364
|
+
用法:
|
|
365
|
+
cgc-history [--flow <all|feature|issue>] [--status <all|open|closed|needs-planning|awaiting-build|awaiting-fix|awaiting-review>] [--last <n>] [--include-fixtures] [--format <summary|json>]
|
|
366
|
+
|
|
367
|
+
用途:
|
|
368
|
+
只读汇总最近的 CodeCGC workflow 历史,帮助你快速知道哪些工作流还开着、下一步该跟进哪条。
|
|
369
|
+
|
|
370
|
+
默认行为:
|
|
371
|
+
不传 --format 时默认输出 summary,更适合人和 Claude 直接阅读。
|
|
372
|
+
默认只看 product 工作流;只有在维护样例或回归时,才建议加 --include-fixtures。
|
|
373
|
+
|
|
374
|
+
主要参数:
|
|
375
|
+
--flow <all|feature|issue>
|
|
376
|
+
过滤 feature、issue 或全部工作流。
|
|
377
|
+
--status <...>
|
|
378
|
+
过滤 open / closed / needs-planning / awaiting-build / awaiting-fix / awaiting-review 等状态。
|
|
379
|
+
--last <n>
|
|
380
|
+
限制返回最近 N 条记录。
|
|
381
|
+
--include-fixtures
|
|
382
|
+
把 fixture 工作流一并纳入结果。
|
|
383
|
+
--format <summary|json>
|
|
384
|
+
summary 用于产品化历史摘要,json 用于调试和自动化消费。
|
|
385
|
+
|
|
386
|
+
推荐用法:
|
|
387
|
+
cgc-history
|
|
388
|
+
cgc-history --status open --last 10
|
|
389
|
+
cgc-history --flow feature --status awaiting-review
|
|
390
|
+
cgc-history --include-fixtures --format json
|
|
391
|
+
`;
|
|
392
|
+
|
|
393
|
+
const entryHelpText = `CodeCGC Workflow Entry
|
|
394
|
+
|
|
395
|
+
用法:
|
|
396
|
+
cgc-entry [--request <text> | --payload-file <file> | --payload-json <json> | --payload-base64 <b64>] [options]
|
|
397
|
+
|
|
398
|
+
用途:
|
|
399
|
+
用一个单入口处理新需求、继续已有工作流,或解释当前下一步。
|
|
400
|
+
|
|
401
|
+
什么时候优先用它:
|
|
402
|
+
- 你只想直接描述需求,不想先决定该用 plan、build、fix、review 还是 route
|
|
403
|
+
- 你想继续刚刚的工作
|
|
404
|
+
- 你只想问“现在下一步该做什么”
|
|
405
|
+
|
|
406
|
+
关键参数:
|
|
407
|
+
--request <text>
|
|
408
|
+
自然语言请求或操作指令。
|
|
409
|
+
--mode <auto|new|continue|explain>
|
|
410
|
+
让 CodeCGC 自动判断意图,或强制指定交互模式。
|
|
411
|
+
--flow <feature|issue>
|
|
412
|
+
在已知时显式指定工作流类型。
|
|
413
|
+
--slug <slug>
|
|
414
|
+
continue / explain 场景下的已有工作流标识。
|
|
415
|
+
--payload-file / --payload-json / --payload-base64
|
|
416
|
+
重新喂入上一轮结构化补全数据,避免手动重复拼长参数。
|
|
417
|
+
|
|
418
|
+
典型用法:
|
|
419
|
+
cgc-entry --request "新增一个登录页面,放在 src/components/LoginForm.tsx"
|
|
420
|
+
cgc-entry --request "继续刚刚的工作"
|
|
421
|
+
cgc-entry --request "直接做"
|
|
422
|
+
cgc-entry --request "通过"
|
|
423
|
+
cgc-entry --request "现在下一步该做什么"
|
|
424
|
+
|
|
425
|
+
典型结果:
|
|
426
|
+
返回澄清问题、推荐命令,或在条件具备时自动调度到 cgc-build / cgc-fix / cgc-review。
|
|
427
|
+
`;
|
|
428
|
+
|
|
429
|
+
const planHelpText = `CodeCGC Workflow Plan
|
|
430
|
+
|
|
431
|
+
用法:
|
|
432
|
+
cgc-plan --flow <feature|issue> --slug <slug> --summary <text> [options]
|
|
433
|
+
|
|
434
|
+
用途:
|
|
435
|
+
在真正委派执行前,澄清或修复一份工作流规划。
|
|
436
|
+
|
|
437
|
+
什么时候优先用它:
|
|
438
|
+
- 需求还不完整,需要补 design、checklist 或 acceptance
|
|
439
|
+
- route 结果仍显示“需要回到规划阶段”
|
|
440
|
+
- 你已经知道这就是一个 feature 或 issue,只想直接补齐规划
|
|
441
|
+
|
|
442
|
+
关键参数:
|
|
443
|
+
--flow <feature|issue>
|
|
444
|
+
指定是 feature 规划还是 issue 规划。
|
|
445
|
+
--slug <slug>
|
|
446
|
+
用于存储产物的稳定工作流标识。
|
|
447
|
+
--summary <text>
|
|
448
|
+
写入产物中的简短说明。
|
|
449
|
+
--target-path <path>
|
|
450
|
+
定义执行范围的文件或目录,可重复传入。
|
|
451
|
+
--kind <auto|frontend|backend>
|
|
452
|
+
让 CodeCGC 自动判断归属,或在已知时直接指定前后端。
|
|
453
|
+
|
|
454
|
+
高价值字段:
|
|
455
|
+
--goal / --user-story / --in-scope / --acceptance
|
|
456
|
+
更适合 feature 规划。
|
|
457
|
+
--symptom / --expected / --actual / --preferred-fix
|
|
458
|
+
更适合 issue 规划。
|
|
459
|
+
|
|
460
|
+
典型结果:
|
|
461
|
+
更新规划产物,并明确告诉你下一步是继续澄清,还是进入 cgc-build / cgc-fix。
|
|
462
|
+
`;
|
|
463
|
+
|
|
464
|
+
const buildHelpText = `CodeCGC Workflow Build
|
|
465
|
+
|
|
466
|
+
用法:
|
|
467
|
+
cgc-build --slug <slug> [--step-number <n>] [options]
|
|
468
|
+
|
|
469
|
+
用途:
|
|
470
|
+
执行一个功能开发步骤,并沿用 CodeCGC 的强制路由、审计和 review 约束。
|
|
471
|
+
|
|
472
|
+
什么时候优先用它:
|
|
473
|
+
- feature checklist 已准备好
|
|
474
|
+
- route 已推荐你进入 cgc-build
|
|
475
|
+
- 你需要真的开始执行当前功能开发步骤
|
|
476
|
+
|
|
477
|
+
关键参数:
|
|
478
|
+
--slug <slug>
|
|
479
|
+
feature 工作流标识。
|
|
480
|
+
--step-number <n>
|
|
481
|
+
可选的精确步骤;不传时会自动选择当前 pending step。
|
|
482
|
+
--checklist-file <path>
|
|
483
|
+
可选的显式 checklist 路径。
|
|
484
|
+
--dry-run
|
|
485
|
+
只生成执行意图,不真正委派执行器写代码。
|
|
486
|
+
|
|
487
|
+
典型结果:
|
|
488
|
+
生成 execution audit;成功后通常进入 cgc-review。
|
|
489
|
+
`;
|
|
490
|
+
|
|
491
|
+
const fixHelpText = `CodeCGC Workflow Fix
|
|
492
|
+
|
|
493
|
+
用法:
|
|
494
|
+
cgc-fix --slug <slug> [--step-number <n>] [options]
|
|
495
|
+
|
|
496
|
+
用途:
|
|
497
|
+
执行一个问题修复步骤,并沿用与 feature 相同的审计和 review 约束。
|
|
498
|
+
|
|
499
|
+
什么时候优先用它:
|
|
500
|
+
- issue 分析已经收敛到可执行修复步骤
|
|
501
|
+
- route 已推荐你进入 cgc-fix
|
|
502
|
+
- 你现在要做的是修复,不是继续诊断或补规划
|
|
503
|
+
|
|
504
|
+
关键参数:
|
|
505
|
+
--slug <slug>
|
|
506
|
+
issue 工作流标识。
|
|
507
|
+
--step-number <n>
|
|
508
|
+
可选的精确步骤;不传时会自动选择当前 pending step。
|
|
509
|
+
--checklist-file <path>
|
|
510
|
+
可选的显式修复清单路径。
|
|
511
|
+
--dry-run
|
|
512
|
+
只生成执行意图,不真正委派执行器写代码。
|
|
513
|
+
|
|
514
|
+
典型结果:
|
|
515
|
+
生成 execution audit;成功后通常进入 cgc-review。
|
|
516
|
+
`;
|
|
517
|
+
|
|
518
|
+
const testHelpText = `CodeCGC Workflow Test
|
|
519
|
+
|
|
520
|
+
用法:
|
|
521
|
+
cgc-test --flow <feature|issue> --slug <slug> [--step-number <n>] [options]
|
|
522
|
+
|
|
523
|
+
用途:
|
|
524
|
+
执行一个测试步骤,并沿用与 build/fix 相同的审计和 review 约束。
|
|
525
|
+
|
|
526
|
+
什么时候优先用它:
|
|
527
|
+
- 当前主代码步骤已经完成,下一步是补充或更新对应测试
|
|
528
|
+
- route 已推荐你进入 cgc-test
|
|
529
|
+
- 你希望测试也纳入现有主工作流,而不是停留在手工动作
|
|
530
|
+
|
|
531
|
+
关键参数:
|
|
532
|
+
--flow <feature|issue>
|
|
533
|
+
测试步骤所属的工作流类型。
|
|
534
|
+
--slug <slug>
|
|
535
|
+
稳定工作流标识。
|
|
536
|
+
--step-number <n>
|
|
537
|
+
可选的精确步骤;不传时会自动选择当前 pending 测试步骤。
|
|
538
|
+
--dry-run
|
|
539
|
+
只生成执行意图,不真正委派执行器写代码。
|
|
540
|
+
|
|
541
|
+
典型结果:
|
|
542
|
+
生成 execution audit;成功后通常进入 cgc-review。
|
|
543
|
+
`;
|
|
544
|
+
|
|
545
|
+
const reviewHelpText = `CodeCGC Workflow Review
|
|
546
|
+
|
|
547
|
+
用法:
|
|
548
|
+
cgc-review --audit-file <path> --decision <accepted|changes-requested> [options]
|
|
549
|
+
|
|
550
|
+
用途:
|
|
551
|
+
审核一次 execution audit,并把结果回写到 acceptance 或 fix-note 中。
|
|
552
|
+
|
|
553
|
+
什么时候优先用它:
|
|
554
|
+
- build 或 fix 已执行完成,并产出了 audit 文件
|
|
555
|
+
- route 已推荐你进入 cgc-review
|
|
556
|
+
- 你要明确当前步骤是“通过”,还是退回继续修改
|
|
557
|
+
|
|
558
|
+
关键参数:
|
|
559
|
+
--audit-file <path>
|
|
560
|
+
build、fix 或 exec 生成的 execution audit 文件。
|
|
561
|
+
--decision <accepted|changes-requested>
|
|
562
|
+
希望写回的审核结论。
|
|
563
|
+
--risk <text>
|
|
564
|
+
可选的额外风险说明,可重复传入。
|
|
565
|
+
--next-step <text>
|
|
566
|
+
可选的下一步动作说明。
|
|
567
|
+
|
|
568
|
+
典型结果:
|
|
569
|
+
回写 review 结论,并明确后续是关闭、继续执行,还是回到规划。
|
|
570
|
+
`;
|
|
571
|
+
|
|
572
|
+
const routeHelpText = `CodeCGC Workflow Route
|
|
573
|
+
|
|
574
|
+
用法:
|
|
575
|
+
cgc-route --flow <feature|issue> --slug <slug>
|
|
576
|
+
|
|
577
|
+
用途:
|
|
578
|
+
根据当前工作流产物状态,判断下一步最合适的命令。
|
|
579
|
+
|
|
580
|
+
什么时候优先用它:
|
|
581
|
+
- 你已经有 slug,但不想手工判断该走 plan、build、fix 还是 review
|
|
582
|
+
- 你希望 Claude 在回复人前,先拿到稳定、确定的下一步命令
|
|
583
|
+
- 你想确认当前工作流是待规划、待执行、待审核,还是已经关闭
|
|
584
|
+
|
|
585
|
+
关键参数:
|
|
586
|
+
--flow <feature|issue>
|
|
587
|
+
工作流类型。
|
|
588
|
+
--slug <slug>
|
|
589
|
+
稳定工作流标识。
|
|
590
|
+
|
|
591
|
+
典型结果:
|
|
592
|
+
返回推荐命令、当前 route 状态,以及为什么做出这个判断。
|
|
593
|
+
`;
|
|
594
|
+
|
|
595
|
+
function findPython() {
|
|
596
|
+
const override = (process.env.CODECGC_PYTHON_COMMAND || "").trim();
|
|
597
|
+
if (override) {
|
|
598
|
+
const probe = spawnSync(override, ["--version"], {
|
|
599
|
+
cwd: repoRoot,
|
|
600
|
+
encoding: "utf8",
|
|
601
|
+
shell: false,
|
|
602
|
+
});
|
|
603
|
+
if (probe.status === 0) {
|
|
604
|
+
return override;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const candidates = process.platform === "win32"
|
|
609
|
+
? ["python", "py"]
|
|
610
|
+
: ["python3", "python"];
|
|
611
|
+
|
|
612
|
+
for (const command of candidates) {
|
|
613
|
+
const probe = spawnSync(command, ["--version"], {
|
|
614
|
+
cwd: repoRoot,
|
|
615
|
+
encoding: "utf8",
|
|
616
|
+
shell: false,
|
|
617
|
+
});
|
|
618
|
+
if (probe.status === 0) {
|
|
619
|
+
return command;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function run(command, commandArgs) {
|
|
626
|
+
const commandEnv = {
|
|
627
|
+
...process.env,
|
|
628
|
+
CODECGC_WORKSPACE_ROOT: process.env.CODECGC_WORKSPACE_ROOT || invocationCwd,
|
|
629
|
+
PYTHONIOENCODING: process.env.PYTHONIOENCODING || "utf-8",
|
|
630
|
+
PYTHONUTF8: process.env.PYTHONUTF8 || "1",
|
|
631
|
+
};
|
|
632
|
+
const result = spawnSync(command, commandArgs, {
|
|
633
|
+
cwd: repoRoot,
|
|
634
|
+
env: commandEnv,
|
|
635
|
+
stdio: "inherit",
|
|
636
|
+
shell: false,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
if (typeof result.status === "number") {
|
|
640
|
+
process.exit(result.status);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
process.exit(1);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function runCapture(command, commandArgs) {
|
|
647
|
+
const commandEnv = {
|
|
648
|
+
...process.env,
|
|
649
|
+
CODECGC_WORKSPACE_ROOT: process.env.CODECGC_WORKSPACE_ROOT || invocationCwd,
|
|
650
|
+
PYTHONIOENCODING: process.env.PYTHONIOENCODING || "utf-8",
|
|
651
|
+
PYTHONUTF8: process.env.PYTHONUTF8 || "1",
|
|
652
|
+
};
|
|
653
|
+
return spawnSync(command, commandArgs, {
|
|
654
|
+
cwd: repoRoot,
|
|
655
|
+
env: commandEnv,
|
|
656
|
+
encoding: "utf8",
|
|
657
|
+
shell: false,
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function tryParseJsonObject(rawText) {
|
|
662
|
+
const text = String(rawText || "").trim();
|
|
663
|
+
if (!text) {
|
|
664
|
+
return null;
|
|
665
|
+
}
|
|
666
|
+
try {
|
|
667
|
+
const parsed = JSON.parse(text);
|
|
668
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
669
|
+
} catch {
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function buildRootEntryText(result) {
|
|
675
|
+
if (!result || typeof result !== "object") {
|
|
676
|
+
return "";
|
|
677
|
+
}
|
|
678
|
+
function quoteShellArg(value) {
|
|
679
|
+
const text = String(value || "");
|
|
680
|
+
if (!text) {
|
|
681
|
+
return '""';
|
|
682
|
+
}
|
|
683
|
+
if (!/[\s"`]/.test(text)) {
|
|
684
|
+
return text;
|
|
685
|
+
}
|
|
686
|
+
return `"${text.replace(/(["`])/g, "\\$1")}"`;
|
|
687
|
+
}
|
|
688
|
+
function splitSummaryAndNext(summaryText) {
|
|
689
|
+
const text = String(summaryText || "").trim();
|
|
690
|
+
if (!text) {
|
|
691
|
+
return { summary: "", inlineNext: "" };
|
|
692
|
+
}
|
|
693
|
+
const markerPattern = /\s+下一步建议[::]\s*/;
|
|
694
|
+
const match = markerPattern.exec(text);
|
|
695
|
+
if (!match || match.index < 0) {
|
|
696
|
+
return { summary: text, inlineNext: "" };
|
|
697
|
+
}
|
|
698
|
+
const summaryPart = text.slice(0, match.index).trim();
|
|
699
|
+
const nextPart = text.slice(match.index + match[0].length).trim();
|
|
700
|
+
return {
|
|
701
|
+
summary: summaryPart || text,
|
|
702
|
+
inlineNext: nextPart,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
const operatorBrief = result.operator_brief && typeof result.operator_brief === "object"
|
|
706
|
+
? result.operator_brief
|
|
707
|
+
: {};
|
|
708
|
+
const routeStatus = result.route_status && typeof result.route_status === "object"
|
|
709
|
+
? result.route_status
|
|
710
|
+
: {};
|
|
711
|
+
const machineNextAction = operatorBrief.machine_next_action && typeof operatorBrief.machine_next_action === "object"
|
|
712
|
+
? operatorBrief.machine_next_action
|
|
713
|
+
: {};
|
|
714
|
+
const execution = machineNextAction.execution && typeof machineNextAction.execution === "object"
|
|
715
|
+
? machineNextAction.execution
|
|
716
|
+
: {};
|
|
717
|
+
const replyKind = String(operatorBrief.reply_kind || "").trim();
|
|
718
|
+
const actionType = String(machineNextAction.type || "").trim();
|
|
719
|
+
const governanceType = String(operatorBrief.governance_type || machineNextAction.governance_type || "").trim();
|
|
720
|
+
const conciseSummary = String(
|
|
721
|
+
operatorBrief.human_summary
|
|
722
|
+
|| result.human_summary
|
|
723
|
+
|| ""
|
|
724
|
+
).trim();
|
|
725
|
+
const detailedSummary = String(
|
|
726
|
+
operatorBrief.user_message
|
|
727
|
+
|| result.assistant_reply
|
|
728
|
+
|| conciseSummary
|
|
729
|
+
|| result.next
|
|
730
|
+
|| ""
|
|
731
|
+
).trim();
|
|
732
|
+
const summary = String(
|
|
733
|
+
replyKind === "clarification"
|
|
734
|
+
? detailedSummary
|
|
735
|
+
: (conciseSummary || detailedSummary)
|
|
736
|
+
).trim();
|
|
737
|
+
if (!summary) {
|
|
738
|
+
return "";
|
|
739
|
+
}
|
|
740
|
+
const splitDisplay = replyKind === "clarification"
|
|
741
|
+
? { summary, inlineNext: "" }
|
|
742
|
+
: splitSummaryAndNext(summary);
|
|
743
|
+
const displaySummary = splitDisplay.summary || summary;
|
|
744
|
+
|
|
745
|
+
const lines = [displaySummary];
|
|
746
|
+
const workflowState = String(
|
|
747
|
+
execution.workflow_state
|
|
748
|
+
|| machineNextAction.workflow_state
|
|
749
|
+
|| routeStatus.workflow_state
|
|
750
|
+
|| ""
|
|
751
|
+
).trim();
|
|
752
|
+
const workflowStateLabels = {
|
|
753
|
+
"needs-new-workflow": "需要先开始新的工作流",
|
|
754
|
+
"needs-review-target": "需要先定位待审核工作流",
|
|
755
|
+
"needs-planning": "需要回到规划阶段",
|
|
756
|
+
"awaiting-build": "等待功能开发执行",
|
|
757
|
+
"awaiting-fix": "等待问题修复执行",
|
|
758
|
+
"awaiting-review": "等待审核决策",
|
|
759
|
+
"step-selected": "已选中当前步骤",
|
|
760
|
+
"closed": "已关闭",
|
|
761
|
+
"governance-routing": "治理动作路由中",
|
|
762
|
+
};
|
|
763
|
+
const command = String(
|
|
764
|
+
execution.command
|
|
765
|
+
|| machineNextAction.command
|
|
766
|
+
|| operatorBrief.recommended_command
|
|
767
|
+
|| result.recommended_command
|
|
768
|
+
|| ""
|
|
769
|
+
).trim();
|
|
770
|
+
const commandArgs = Array.isArray(execution.command_args)
|
|
771
|
+
? execution.command_args.map((item) => String(item).trim()).filter(Boolean)
|
|
772
|
+
: Array.isArray(machineNextAction.command_args)
|
|
773
|
+
? machineNextAction.command_args.map((item) => String(item).trim()).filter(Boolean)
|
|
774
|
+
: [];
|
|
775
|
+
function buildShortCommandHintParts(baseCommand, argsList) {
|
|
776
|
+
const normalizedCommand = String(baseCommand || "").trim();
|
|
777
|
+
if (!normalizedCommand) {
|
|
778
|
+
return [];
|
|
779
|
+
}
|
|
780
|
+
const normalizedArgs = Array.isArray(argsList) ? argsList : [];
|
|
781
|
+
if (normalizedCommand === "cgc-plan") {
|
|
782
|
+
const flowIndex = normalizedArgs.indexOf("--flow");
|
|
783
|
+
const slugIndex = normalizedArgs.indexOf("--slug");
|
|
784
|
+
const parts = [normalizedCommand];
|
|
785
|
+
if (flowIndex >= 0 && normalizedArgs[flowIndex + 1]) {
|
|
786
|
+
parts.push("--flow", normalizedArgs[flowIndex + 1]);
|
|
787
|
+
}
|
|
788
|
+
if (slugIndex >= 0 && normalizedArgs[slugIndex + 1]) {
|
|
789
|
+
parts.push("--slug", normalizedArgs[slugIndex + 1]);
|
|
790
|
+
}
|
|
791
|
+
return parts;
|
|
792
|
+
}
|
|
793
|
+
if (normalizedCommand === "cgc-build" || normalizedCommand === "cgc-fix" || normalizedCommand === "cgc-test") {
|
|
794
|
+
const flowIndex = normalizedArgs.indexOf("--flow");
|
|
795
|
+
const slugIndex = normalizedArgs.indexOf("--slug");
|
|
796
|
+
const stepIndex = normalizedArgs.indexOf("--step-number");
|
|
797
|
+
const parts = [normalizedCommand];
|
|
798
|
+
if (flowIndex >= 0 && normalizedArgs[flowIndex + 1]) {
|
|
799
|
+
parts.push("--flow", normalizedArgs[flowIndex + 1]);
|
|
800
|
+
}
|
|
801
|
+
if (slugIndex >= 0 && normalizedArgs[slugIndex + 1]) {
|
|
802
|
+
parts.push("--slug", normalizedArgs[slugIndex + 1]);
|
|
803
|
+
}
|
|
804
|
+
if (stepIndex >= 0 && normalizedArgs[stepIndex + 1]) {
|
|
805
|
+
parts.push("--step-number", normalizedArgs[stepIndex + 1]);
|
|
806
|
+
}
|
|
807
|
+
return parts;
|
|
808
|
+
}
|
|
809
|
+
if (normalizedCommand === "cgc-review") {
|
|
810
|
+
const auditIndex = normalizedArgs.indexOf("--audit-file");
|
|
811
|
+
const decisionIndex = normalizedArgs.indexOf("--decision");
|
|
812
|
+
const parts = [normalizedCommand];
|
|
813
|
+
if (auditIndex >= 0 && normalizedArgs[auditIndex + 1]) {
|
|
814
|
+
parts.push("--audit-file", normalizedArgs[auditIndex + 1]);
|
|
815
|
+
}
|
|
816
|
+
if (decisionIndex >= 0 && normalizedArgs[decisionIndex + 1]) {
|
|
817
|
+
parts.push("--decision", normalizedArgs[decisionIndex + 1]);
|
|
818
|
+
}
|
|
819
|
+
return parts;
|
|
820
|
+
}
|
|
821
|
+
return [normalizedCommand];
|
|
822
|
+
}
|
|
823
|
+
const nextStep = String(
|
|
824
|
+
machineNextAction.user_action && machineNextAction.user_action.next_step
|
|
825
|
+
? machineNextAction.user_action.next_step
|
|
826
|
+
: result.next || ""
|
|
827
|
+
).trim();
|
|
828
|
+
const normalizedNextStep = nextStep.replace(/^下一步[::]?\s*/, "").trim();
|
|
829
|
+
const normalizedSummary = displaySummary.replace(/\s+/g, " ").trim();
|
|
830
|
+
const compactSummary = normalizedSummary.replace(/\n+/g, " ").trim();
|
|
831
|
+
const recoveryHint = String(
|
|
832
|
+
machineNextAction.user_action && machineNextAction.user_action.recovery_hint
|
|
833
|
+
? machineNextAction.user_action.recovery_hint
|
|
834
|
+
: ""
|
|
835
|
+
).trim();
|
|
836
|
+
const dispatchFailureType = String(
|
|
837
|
+
machineNextAction.diagnostics && machineNextAction.diagnostics.dispatch_failure_type
|
|
838
|
+
? machineNextAction.diagnostics.dispatch_failure_type
|
|
839
|
+
: machineNextAction.dispatch_failure_type || ""
|
|
840
|
+
).trim();
|
|
841
|
+
const dispatchState = String(
|
|
842
|
+
machineNextAction.diagnostics && machineNextAction.diagnostics.dispatch_state
|
|
843
|
+
? machineNextAction.diagnostics.dispatch_state
|
|
844
|
+
: machineNextAction.dispatch_state || ""
|
|
845
|
+
).trim();
|
|
846
|
+
let displayWorkflowState = workflowState;
|
|
847
|
+
if (replyKind === "clarification" || actionType === "wait-user-reply") {
|
|
848
|
+
displayWorkflowState = "needs-clarification";
|
|
849
|
+
}
|
|
850
|
+
if (replyKind === "blocked" || actionType === "dispatch-failed") {
|
|
851
|
+
if (dispatchFailureType === "executor-failure") {
|
|
852
|
+
displayWorkflowState = "blocked-executor";
|
|
853
|
+
} else if (dispatchFailureType === "environment-or-tooling") {
|
|
854
|
+
displayWorkflowState = "blocked-environment";
|
|
855
|
+
} else if (dispatchFailureType === "workflow-state") {
|
|
856
|
+
displayWorkflowState = "blocked-workflow-state";
|
|
857
|
+
} else if (
|
|
858
|
+
dispatchState === "returned-to-planning"
|
|
859
|
+
|| dispatchFailureType === "design-gap"
|
|
860
|
+
|| dispatchFailureType === "scope-error"
|
|
861
|
+
) {
|
|
862
|
+
displayWorkflowState = "needs-planning";
|
|
863
|
+
} else if (command) {
|
|
864
|
+
if (command.startsWith("cgc-plan")) {
|
|
865
|
+
displayWorkflowState = "needs-planning";
|
|
866
|
+
} else if (command.startsWith("cgc-build")) {
|
|
867
|
+
displayWorkflowState = "awaiting-build";
|
|
868
|
+
} else if (command.startsWith("cgc-fix")) {
|
|
869
|
+
displayWorkflowState = "awaiting-fix";
|
|
870
|
+
} else if (command.startsWith("cgc-review")) {
|
|
871
|
+
displayWorkflowState = "awaiting-review";
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
displayWorkflowState = "blocked";
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
const mergedNextStep = (
|
|
878
|
+
splitDisplay.inlineNext
|
|
879
|
+
&& normalizedNextStep
|
|
880
|
+
&& normalizedNextStep !== splitDisplay.inlineNext
|
|
881
|
+
)
|
|
882
|
+
? splitDisplay.inlineNext
|
|
883
|
+
: (normalizedNextStep || splitDisplay.inlineNext);
|
|
884
|
+
const shouldShowNextStep = (
|
|
885
|
+
mergedNextStep
|
|
886
|
+
&& normalizedNextStep !== summary
|
|
887
|
+
&& normalizedNextStep !== compactSummary
|
|
888
|
+
&& !compactSummary.includes(mergedNextStep)
|
|
889
|
+
);
|
|
890
|
+
const resultLabels = {
|
|
891
|
+
"review-target-missing": "当前还不能直接审核,需要先找到待审核工作流。",
|
|
892
|
+
"start-new-workflow": "当前还没有可继续的工作流,可以直接开始一个新需求。",
|
|
893
|
+
"clarification": "当前还需要先补齐信息,再进入后续步骤。",
|
|
894
|
+
"review": "当前已进入待审核状态。",
|
|
895
|
+
"execution": "当前工作流已具备进入执行阶段的条件。",
|
|
896
|
+
"closed": "当前工作流已收口。",
|
|
897
|
+
"governance": "当前请求已按治理动作处理。",
|
|
898
|
+
};
|
|
899
|
+
const resultLabel = resultLabels[replyKind] || "";
|
|
900
|
+
const fullCommandParts = [command, ...commandArgs].filter(Boolean);
|
|
901
|
+
const shortCommandParts = buildShortCommandHintParts(command, commandArgs);
|
|
902
|
+
const fullCommandText = fullCommandParts.join(" ").trim();
|
|
903
|
+
const shortCommandHint = shortCommandParts.join(" ").trim();
|
|
904
|
+
const renderedFullCommandText = [command, ...commandArgs].map(quoteShellArg).join(" ").trim();
|
|
905
|
+
const renderedShortCommandHint = shortCommandParts.length
|
|
906
|
+
? shortCommandParts.map(quoteShellArg).join(" ").trim()
|
|
907
|
+
: "";
|
|
908
|
+
const shouldShowShortCommand = Boolean(
|
|
909
|
+
fullCommandText
|
|
910
|
+
&& shortCommandHint
|
|
911
|
+
&& shortCommandHint !== fullCommandText
|
|
912
|
+
);
|
|
913
|
+
|
|
914
|
+
const displayStateLabel = displayWorkflowState === "needs-clarification"
|
|
915
|
+
? "需要补充规划信息"
|
|
916
|
+
: displayWorkflowState === "blocked-executor"
|
|
917
|
+
? "执行器返回异常"
|
|
918
|
+
: displayWorkflowState === "blocked-environment"
|
|
919
|
+
? "本地环境或工具阻塞"
|
|
920
|
+
: displayWorkflowState === "blocked-workflow-state"
|
|
921
|
+
? "工作流状态未就绪"
|
|
922
|
+
: displayWorkflowState === "blocked"
|
|
923
|
+
? "当前工作流存在阻塞"
|
|
924
|
+
: (workflowStateLabels[displayWorkflowState] || displayWorkflowState);
|
|
925
|
+
if (displayWorkflowState) {
|
|
926
|
+
lines.push(`状态: ${displayStateLabel}`);
|
|
927
|
+
}
|
|
928
|
+
if (governanceType) {
|
|
929
|
+
lines.push(`治理类型: ${governanceType}`);
|
|
930
|
+
}
|
|
931
|
+
if (command && actionType !== "closed") {
|
|
932
|
+
if (shouldShowShortCommand) {
|
|
933
|
+
lines.push(`建议命令: ${renderedShortCommandHint}`);
|
|
934
|
+
lines.push(`完整命令: ${renderedFullCommandText}`);
|
|
935
|
+
} else {
|
|
936
|
+
lines.push(`建议命令: ${renderedFullCommandText}`);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (shouldShowNextStep) {
|
|
940
|
+
lines.push(`下一步: ${mergedNextStep}`);
|
|
941
|
+
}
|
|
942
|
+
if (replyKind === "blocked" && recoveryHint) {
|
|
943
|
+
if (recoveryHint !== mergedNextStep) {
|
|
944
|
+
lines.push(`恢复建议: ${recoveryHint}`);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
if (replyKind === "closed" || actionType === "closed") {
|
|
948
|
+
lines.push("结果: 当前工作流已收口。");
|
|
949
|
+
} else if (replyKind === "review" || actionType === "wait-review-decision") {
|
|
950
|
+
lines.push("结果: 当前已进入待审核状态。");
|
|
951
|
+
} else if (replyKind === "execution" || actionType === "dispatch") {
|
|
952
|
+
lines.push("结果: 当前工作流已具备进入执行阶段的条件。");
|
|
953
|
+
} else if (replyKind === "blocked") {
|
|
954
|
+
const blockedResultLabel = displayWorkflowState === "needs-planning"
|
|
955
|
+
? "当前工作流已返回规划阶段,需先补齐规划后再继续。"
|
|
956
|
+
: displayWorkflowState === "blocked-executor"
|
|
957
|
+
? "当前执行器返回异常,需先检查执行日志与审计产物。"
|
|
958
|
+
: displayWorkflowState === "blocked-environment"
|
|
959
|
+
? "当前被本地环境或工具问题阻塞,需先修复环境后再继续。"
|
|
960
|
+
: displayWorkflowState === "blocked-workflow-state"
|
|
961
|
+
? "当前工作流状态未就绪,需先修复状态后再继续。"
|
|
962
|
+
: "当前工作流有阻塞,需先按恢复建议处理。";
|
|
963
|
+
lines.push(`结果: ${blockedResultLabel}`);
|
|
964
|
+
} else if (replyKind === "governance" || actionType === "governance") {
|
|
965
|
+
lines.push("结果: 当前请求已按治理动作处理。");
|
|
966
|
+
} else if (resultLabel) {
|
|
967
|
+
lines.push(`结果: ${resultLabel}`);
|
|
968
|
+
}
|
|
969
|
+
return lines.join("\n");
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
function buildRootEntryErrorText(parsedStdout, parsedStderr, rawStdout, rawStderr) {
|
|
973
|
+
const candidates = [
|
|
974
|
+
parsedStderr && parsedStderr.error,
|
|
975
|
+
parsedStdout && parsedStdout.error,
|
|
976
|
+
rawStderr,
|
|
977
|
+
rawStdout,
|
|
978
|
+
];
|
|
979
|
+
for (const item of candidates) {
|
|
980
|
+
const text = String(item || "").trim();
|
|
981
|
+
if (text) {
|
|
982
|
+
return text;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return "CodeCGC entry request failed.";
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
function runRootEntry(command, commandArgs) {
|
|
989
|
+
const result = runCapture(command, commandArgs);
|
|
990
|
+
const parsedStdout = tryParseJsonObject(result.stdout);
|
|
991
|
+
const parsedStderr = tryParseJsonObject(result.stderr);
|
|
992
|
+
|
|
993
|
+
if ((result.status || 0) === 0) {
|
|
994
|
+
const text = buildRootEntryText(parsedStdout);
|
|
995
|
+
if (text) {
|
|
996
|
+
process.stdout.write(`${text}\n`);
|
|
997
|
+
} else if (typeof result.stdout === "string" && result.stdout.trim()) {
|
|
998
|
+
process.stdout.write(result.stdout);
|
|
999
|
+
if (!result.stdout.endsWith("\n")) {
|
|
1000
|
+
process.stdout.write("\n");
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
process.exit(0);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
const errorText = buildRootEntryErrorText(parsedStdout, parsedStderr, result.stdout, result.stderr);
|
|
1007
|
+
process.stderr.write(`${errorText}\n`);
|
|
1008
|
+
process.exit(typeof result.status === "number" ? result.status : 1);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
function normalizeWorkflowHelpText(rawText, subcommand) {
|
|
1012
|
+
const directHelp = `python scripts/codecgc_cli.py ${subcommand}`;
|
|
1013
|
+
return String(rawText || "")
|
|
1014
|
+
.replaceAll(directHelp, `cgc-${subcommand}`)
|
|
1015
|
+
.replaceAll(`python scripts/codecgc_cli.py ${subcommand}`, `cgc-${subcommand}`)
|
|
1016
|
+
.replaceAll("python scripts/codecgc_cli.py", "cgc")
|
|
1017
|
+
.replaceAll("python scripts/codecgc_cli.py", "cgc");
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function resolveCommandInvocation(invokedName, rawArgs) {
|
|
1021
|
+
if (DASH_COMMANDS.has(invokedName)) {
|
|
1022
|
+
return {
|
|
1023
|
+
subcommand: invokedName.slice(4),
|
|
1024
|
+
rest: rawArgs,
|
|
1025
|
+
invokedAsRoot: false,
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
if (rawArgs.length > 0 && DASH_COMMANDS.has(rawArgs[0])) {
|
|
1030
|
+
return {
|
|
1031
|
+
subcommand: rawArgs[0].slice(4),
|
|
1032
|
+
rest: rawArgs.slice(1),
|
|
1033
|
+
invokedAsRoot: invokedName === "cgc",
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
if (rawArgs.length > 0 && DIRECT_COMMANDS.has(rawArgs[0])) {
|
|
1038
|
+
return {
|
|
1039
|
+
subcommand: rawArgs[0],
|
|
1040
|
+
rest: rawArgs.slice(1),
|
|
1041
|
+
invokedAsRoot: invokedName === "cgc",
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
return {
|
|
1046
|
+
subcommand: "",
|
|
1047
|
+
rest: rawArgs,
|
|
1048
|
+
invokedAsRoot: invokedName === "cgc",
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
function looksLikeEntryFlag(flag) {
|
|
1053
|
+
return new Set([
|
|
1054
|
+
"--payload-json",
|
|
1055
|
+
"--payload-base64",
|
|
1056
|
+
"--payload-file",
|
|
1057
|
+
"--mode",
|
|
1058
|
+
"--flow",
|
|
1059
|
+
"--slug",
|
|
1060
|
+
"--summary",
|
|
1061
|
+
"--request",
|
|
1062
|
+
"--date",
|
|
1063
|
+
"--target-path",
|
|
1064
|
+
"--kind",
|
|
1065
|
+
"--goal",
|
|
1066
|
+
"--context",
|
|
1067
|
+
"--user-story",
|
|
1068
|
+
"--in-scope",
|
|
1069
|
+
"--out-of-scope",
|
|
1070
|
+
"--acceptance",
|
|
1071
|
+
"--risk",
|
|
1072
|
+
"--dependency",
|
|
1073
|
+
"--assumption",
|
|
1074
|
+
"--open-question",
|
|
1075
|
+
"--symptom",
|
|
1076
|
+
"--reproduction",
|
|
1077
|
+
"--expected",
|
|
1078
|
+
"--actual",
|
|
1079
|
+
"--root-cause",
|
|
1080
|
+
"--preferred-fix",
|
|
1081
|
+
"--rejected-fix",
|
|
1082
|
+
"--decision",
|
|
1083
|
+
"--audit-file",
|
|
1084
|
+
"--next-step",
|
|
1085
|
+
"--artifact-class",
|
|
1086
|
+
"--latest",
|
|
1087
|
+
"--include-fixtures",
|
|
1088
|
+
"--step-number",
|
|
1089
|
+
"--checklist-file",
|
|
1090
|
+
"--audit-root",
|
|
1091
|
+
"--timeout-seconds",
|
|
1092
|
+
"--dry-run",
|
|
1093
|
+
"--return-all-messages",
|
|
1094
|
+
"--auto-dispatch",
|
|
1095
|
+
"--force",
|
|
1096
|
+
]).has(flag);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function shouldRouteRootInvocationToEntry(rawArgs) {
|
|
1100
|
+
if (rawArgs.length === 0) {
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
const first = String(rawArgs[0] || "");
|
|
1104
|
+
if (!first.startsWith("-")) {
|
|
1105
|
+
return true;
|
|
1106
|
+
}
|
|
1107
|
+
return looksLikeEntryFlag(first);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
function main() {
|
|
1111
|
+
const python = findPython();
|
|
1112
|
+
if (!python) {
|
|
1113
|
+
console.error("CodeCGC requires Python in PATH.");
|
|
1114
|
+
process.exit(1);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
const { subcommand, rest, invokedAsRoot } = resolveCommandInvocation(invokedBinary, args);
|
|
1118
|
+
|
|
1119
|
+
if (!subcommand && (args.length === 0 || (args.length === 1 && (args[0] === "--help" || args[0] === "-h")))) {
|
|
1120
|
+
console.log(helpText);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "version")) {
|
|
1125
|
+
console.log(productVersion);
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
if (invokedAsRoot && subcommand && DIRECT_COMMANDS.has(subcommand)) {
|
|
1130
|
+
console.error(`Use cgc-${subcommand} instead of cgc ${subcommand}.`);
|
|
1131
|
+
process.exit(1);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
if (rest.length === 1 && (rest[0] === "--help" || rest[0] === "-h")) {
|
|
1135
|
+
if (subcommand === "install") {
|
|
1136
|
+
console.log(installHelpText);
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
if (subcommand === "status") {
|
|
1140
|
+
console.log(statusHelpText);
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
if (subcommand === "doctor") {
|
|
1144
|
+
console.log(doctorHelpText);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
if (subcommand === "package-audit") {
|
|
1148
|
+
console.log(packageAuditHelpText);
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
if (subcommand === "external-audit") {
|
|
1152
|
+
console.log(externalAuditHelpText);
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
if (subcommand === "release-readiness") {
|
|
1156
|
+
console.log(releaseReadinessHelpText);
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
if (subcommand === "lifecycle") {
|
|
1160
|
+
console.log(lifecycleHelpText);
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
if (subcommand === "history") {
|
|
1164
|
+
console.log(historyHelpText);
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
if (subcommand === "entry") {
|
|
1168
|
+
console.log(entryHelpText);
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
if (subcommand === "plan") {
|
|
1172
|
+
console.log(planHelpText);
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
if (subcommand === "build") {
|
|
1176
|
+
console.log(buildHelpText);
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
if (subcommand === "fix") {
|
|
1180
|
+
console.log(fixHelpText);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
if (subcommand === "test") {
|
|
1184
|
+
console.log(testHelpText);
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
if (subcommand === "review") {
|
|
1188
|
+
console.log(reviewHelpText);
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
if (subcommand === "route") {
|
|
1192
|
+
console.log(routeHelpText);
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
const helpResult = runCapture(python, [path.join(repoRoot, "scripts", "codecgc_cli.py"), subcommand, "--help"]);
|
|
1196
|
+
if (typeof helpResult.stdout === "string" && helpResult.stdout.trim()) {
|
|
1197
|
+
process.stdout.write(normalizeWorkflowHelpText(helpResult.stdout, subcommand));
|
|
1198
|
+
}
|
|
1199
|
+
if (typeof helpResult.stderr === "string" && helpResult.stderr.trim()) {
|
|
1200
|
+
process.stderr.write(helpResult.stderr);
|
|
1201
|
+
}
|
|
1202
|
+
if (typeof helpResult.status === "number") {
|
|
1203
|
+
process.exit(helpResult.status);
|
|
1204
|
+
}
|
|
1205
|
+
process.exit(1);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
if (!subcommand) {
|
|
1209
|
+
if (invokedAsRoot && shouldRouteRootInvocationToEntry(args)) {
|
|
1210
|
+
if (args[0].startsWith("-")) {
|
|
1211
|
+
runRootEntry(python, [path.join(repoRoot, "scripts", "codecgc_cli.py"), "entry", ...args]);
|
|
1212
|
+
}
|
|
1213
|
+
runRootEntry(python, [path.join(repoRoot, "scripts", "codecgc_cli.py"), "entry", "--request", args.join(" ")]);
|
|
1214
|
+
}
|
|
1215
|
+
console.log(helpText);
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
if (subcommand === "install") {
|
|
1220
|
+
run(python, [path.join(repoRoot, "scripts", "install_codecgc.py"), ...rest]);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
if (subcommand === "status" || subcommand === "doctor") {
|
|
1224
|
+
run(
|
|
1225
|
+
python,
|
|
1226
|
+
[
|
|
1227
|
+
path.join(repoRoot, "scripts", "install_codecgc.py"),
|
|
1228
|
+
"--mode",
|
|
1229
|
+
subcommand === "doctor" ? "doctor" : "status",
|
|
1230
|
+
...rest,
|
|
1231
|
+
],
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
if (subcommand === "package-audit") {
|
|
1236
|
+
run(
|
|
1237
|
+
python,
|
|
1238
|
+
[
|
|
1239
|
+
path.join(repoRoot, "scripts", "audit_codecgc_package_runtime.py"),
|
|
1240
|
+
...rest,
|
|
1241
|
+
],
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
if (subcommand === "external-audit") {
|
|
1246
|
+
run(
|
|
1247
|
+
python,
|
|
1248
|
+
[
|
|
1249
|
+
path.join(repoRoot, "scripts", "audit_codecgc_external_capabilities.py"),
|
|
1250
|
+
...rest,
|
|
1251
|
+
],
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
if (subcommand === "release-readiness") {
|
|
1256
|
+
run(
|
|
1257
|
+
python,
|
|
1258
|
+
[
|
|
1259
|
+
path.join(repoRoot, "scripts", "audit_codecgc_release_readiness.py"),
|
|
1260
|
+
...rest,
|
|
1261
|
+
],
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
if (subcommand === "lifecycle") {
|
|
1266
|
+
run(
|
|
1267
|
+
python,
|
|
1268
|
+
[
|
|
1269
|
+
path.join(repoRoot, "scripts", "audit_codecgc_lifecycle.py"),
|
|
1270
|
+
...rest,
|
|
1271
|
+
],
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const cliPath = path.join(repoRoot, "scripts", "codecgc_cli.py");
|
|
1276
|
+
if (!existsSync(cliPath)) {
|
|
1277
|
+
console.error(`CodeCGC CLI not found: ${cliPath}`);
|
|
1278
|
+
process.exit(1);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
run(python, [cliPath, subcommand, ...rest]);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
main();
|