@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.
Files changed (128) hide show
  1. package/.claude/hooks/route-edit.ps1 +86 -0
  2. package/INSTALLATION.md +550 -0
  3. package/LICENSE +21 -0
  4. package/README.md +171 -0
  5. package/bin/cgc-build.js +4 -0
  6. package/bin/cgc-doctor.js +4 -0
  7. package/bin/cgc-entry.js +4 -0
  8. package/bin/cgc-external-audit.js +4 -0
  9. package/bin/cgc-fix.js +4 -0
  10. package/bin/cgc-history.js +4 -0
  11. package/bin/cgc-install.js +4 -0
  12. package/bin/cgc-lifecycle.js +4 -0
  13. package/bin/cgc-package-audit.js +4 -0
  14. package/bin/cgc-plan.js +4 -0
  15. package/bin/cgc-release-readiness.js +4 -0
  16. package/bin/cgc-review.js +4 -0
  17. package/bin/cgc-route.js +4 -0
  18. package/bin/cgc-status.js +4 -0
  19. package/bin/cgc-test.js +4 -0
  20. package/bin/cgc.js +4 -0
  21. package/bin/codecgc.js +1284 -0
  22. package/codecgc/cgc/SKILL.md +46 -0
  23. package/codecgc/cgc-arch/SKILL.md +61 -0
  24. package/codecgc/cgc-build/SKILL.md +53 -0
  25. package/codecgc/cgc-decide/SKILL.md +55 -0
  26. package/codecgc/cgc-fix/SKILL.md +47 -0
  27. package/codecgc/cgc-learn/SKILL.md +46 -0
  28. package/codecgc/cgc-onboard/SKILL.md +52 -0
  29. package/codecgc/cgc-plan/SKILL.md +48 -0
  30. package/codecgc/cgc-refactor/SKILL.md +46 -0
  31. package/codecgc/cgc-req/SKILL.md +61 -0
  32. package/codecgc/cgc-review/SKILL.md +57 -0
  33. package/codecgc/cgc-roadmap/SKILL.md +55 -0
  34. package/codecgc/cgc-test/SKILL.md +21 -0
  35. package/codecgc/reference/api-cgc-review-libdoc.md +13 -0
  36. package/codecgc/reference/artifact-class-policy.md +81 -0
  37. package/codecgc/reference/build-flow.md +95 -0
  38. package/codecgc/reference/checklist-contract.md +103 -0
  39. package/codecgc/reference/execution-audit.md +121 -0
  40. package/codecgc/reference/execution-model.md +118 -0
  41. package/codecgc/reference/execution-routing.md +130 -0
  42. package/codecgc/reference/executor-contract.md +87 -0
  43. package/codecgc/reference/external-capability-registry.json +104 -0
  44. package/codecgc/reference/fix-flow.md +94 -0
  45. package/codecgc/reference/fixture-governance.md +60 -0
  46. package/codecgc/reference/flow-execution.md +65 -0
  47. package/codecgc/reference/lifecycle-map.md +172 -0
  48. package/codecgc/reference/lifecycle-playbook.md +104 -0
  49. package/codecgc/reference/long-lived-artifacts.md +98 -0
  50. package/codecgc/reference/operation-guide.md +242 -0
  51. package/codecgc/reference/release-maintenance-playbook.md +150 -0
  52. package/codecgc/reference/review-writeback.md +141 -0
  53. package/codecgc/reference/role-model.md +128 -0
  54. package/codecgc/reference/runtime-boundary.md +72 -0
  55. package/codecgc/reference/shared-conventions.md +93 -0
  56. package/codecgc/reference/workflow-scaffold.md +57 -0
  57. package/codexmcp/LICENSE +21 -0
  58. package/codexmcp/README.md +294 -0
  59. package/codexmcp/pyproject.toml +37 -0
  60. package/codexmcp/src/codexmcp/__init__.py +4 -0
  61. package/codexmcp/src/codexmcp/cli.py +12 -0
  62. package/codexmcp/src/codexmcp/server.py +529 -0
  63. package/geminimcp/README.md +258 -0
  64. package/geminimcp/pyproject.toml +15 -0
  65. package/geminimcp/src/geminimcp/__init__.py +4 -0
  66. package/geminimcp/src/geminimcp/cli.py +12 -0
  67. package/geminimcp/src/geminimcp/server.py +465 -0
  68. package/model-routing.yaml +30 -0
  69. package/package.json +90 -0
  70. package/requirements.txt +1 -0
  71. package/scripts/README-codecgc-cli.md +89 -0
  72. package/scripts/audit_codecgc_external_capabilities.py +276 -0
  73. package/scripts/audit_codecgc_historical_audits.py +242 -0
  74. package/scripts/audit_codecgc_lifecycle.py +241 -0
  75. package/scripts/audit_codecgc_package_runtime.py +445 -0
  76. package/scripts/audit_codecgc_release_readiness.py +202 -0
  77. package/scripts/audit_codecgc_review_policy.py +82 -0
  78. package/scripts/audit_codecgc_workflow_history.py +317 -0
  79. package/scripts/build_codecgc_task.py +487 -0
  80. package/scripts/codecgc_artifact_roots.py +40 -0
  81. package/scripts/codecgc_cli.py +843 -0
  82. package/scripts/codecgc_command_surface.py +28 -0
  83. package/scripts/codecgc_console_io.py +45 -0
  84. package/scripts/codecgc_executor_registry.py +54 -0
  85. package/scripts/codecgc_file_evidence.py +349 -0
  86. package/scripts/codecgc_flow_control.py +233 -0
  87. package/scripts/codecgc_governance_dedupe.py +161 -0
  88. package/scripts/codecgc_plan_decision.py +103 -0
  89. package/scripts/codecgc_review_control.py +588 -0
  90. package/scripts/codecgc_roadmap_templates.py +149 -0
  91. package/scripts/codecgc_routing_paths.py +16 -0
  92. package/scripts/codecgc_routing_template.py +135 -0
  93. package/scripts/codecgc_runtime_paths.py +22 -0
  94. package/scripts/codecgc_session_recovery.py +44 -0
  95. package/scripts/codecgc_step_control.py +154 -0
  96. package/scripts/codecgc_workflow_runtime.py +63 -0
  97. package/scripts/codecgc_workflow_templates.py +437 -0
  98. package/scripts/entry_codecgc_workflow.py +3419 -0
  99. package/scripts/exercise_mcp_tools.py +109 -0
  100. package/scripts/expand_codecgc_roadmap.py +664 -0
  101. package/scripts/init_codecgc_roadmap.py +134 -0
  102. package/scripts/init_codecgc_workflow.py +207 -0
  103. package/scripts/install_codecgc.py +938 -0
  104. package/scripts/migrate_demo_workflows_to_fixtures.py +128 -0
  105. package/scripts/normalize_codecgc_audits.py +114 -0
  106. package/scripts/normalize_codecgc_governance_docs.py +79 -0
  107. package/scripts/normalize_codecgc_workflow_docs.py +269 -0
  108. package/scripts/plan_codecgc_workflow.py +970 -0
  109. package/scripts/refresh_codecgc_review_policy.py +223 -0
  110. package/scripts/review_codecgc_workflow.py +88 -0
  111. package/scripts/route_codecgc_workflow.py +671 -0
  112. package/scripts/run_codecgc_build.py +104 -0
  113. package/scripts/run_codecgc_fix.py +104 -0
  114. package/scripts/run_codecgc_flow_step.py +165 -0
  115. package/scripts/run_codecgc_task.py +410 -0
  116. package/scripts/run_codecgc_test.py +105 -0
  117. package/scripts/sync_codecgc_mcp_config.py +41 -0
  118. package/scripts/write_codecgc_architecture.py +78 -0
  119. package/scripts/write_codecgc_decision.py +83 -0
  120. package/scripts/write_codecgc_explore.py +118 -0
  121. package/scripts/write_codecgc_guide.py +141 -0
  122. package/scripts/write_codecgc_learning.py +87 -0
  123. package/scripts/write_codecgc_libdoc.py +140 -0
  124. package/scripts/write_codecgc_refactor.py +78 -0
  125. package/scripts/write_codecgc_requirement.py +78 -0
  126. package/scripts/write_codecgc_review.py +291 -0
  127. package/scripts/write_codecgc_roadmap.py +122 -0
  128. package/scripts/write_codecgc_trick.py +123 -0
@@ -0,0 +1,843 @@
1
+ import argparse
2
+ import subprocess
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ from codecgc_runtime_paths import PACKAGE_ROOT
7
+ from codecgc_runtime_paths import PROJECT_ROOT
8
+
9
+ WORKSPACE = PACKAGE_ROOT
10
+ PROJECT_WORKSPACE = PROJECT_ROOT
11
+
12
+ HELP_TEXT = """CodeCGC 底层工作流 CLI
13
+
14
+ 用法:
15
+ python scripts/codecgc_cli.py <command> [options]
16
+
17
+ 说明:
18
+ 这是实现层调试入口。日常使用优先走 `cgc-*` 产品命令;
19
+ 只有在维护 CodeCGC 本身或排查运行时问题时,才直接调用这里。
20
+
21
+ 按目标选择:
22
+ 我要先创建最小工作流脚手架
23
+ init
24
+ 我要澄清或修复规划
25
+ plan
26
+ 我要用单入口接收新需求、继续任务或解释下一步
27
+ entry
28
+ 我要执行一个功能开发步骤
29
+ build
30
+ 我要执行一个问题修复步骤
31
+ fix
32
+ 我要执行一个测试步骤
33
+ test
34
+ 我已经知道 flow + slug + step number,要精确执行一个步骤
35
+ exec
36
+ 我要审核一次执行结果并回写
37
+ review
38
+ 我要让 CodeCGC 判断下一步命令
39
+ route
40
+ 我要只读查看最近工作流历史
41
+ history
42
+
43
+ 命令职责:
44
+ init 初始化 feature 或 issue 的最小产物
45
+ plan 创建或修复规划产物,并整理下一步可执行内容
46
+ entry 单入口调度:新需求、继续、解释下一步
47
+ build 通过高层 feature 执行入口运行一个步骤
48
+ fix 通过高层 issue 执行入口运行一个步骤
49
+ test 通过高层测试执行入口运行一个测试步骤
50
+ exec 精确执行一个指定步骤
51
+ review 根据 audit 结果回写审核结论
52
+ route 根据当前产物状态推荐下一步命令
53
+ history 只读汇总最近 workflow 历史
54
+
55
+ 示例:
56
+ python scripts/codecgc_cli.py entry --request "新增一个登录页面,放在 src/components/LoginForm.tsx"
57
+ python scripts/codecgc_cli.py entry --request "继续刚刚的工作"
58
+ python scripts/codecgc_cli.py plan --flow feature --slug demo-login-ui --summary "Demo login UI feature" --target-path src/components/LoginForm.tsx --kind frontend
59
+ python scripts/codecgc_cli.py build --slug 2026-05-01-demo-login-ui --step-number 1 --dry-run
60
+ python scripts/codecgc_cli.py fix --slug 2026-05-01-demo-sync-bug --step-number 1 --dry-run
61
+ python scripts/codecgc_cli.py test --flow feature --slug 2026-05-01-demo-login-ui --step-number 2 --dry-run
62
+ python scripts/codecgc_cli.py review --audit-file codecgc/execution/demo-login-ui-step-1.json --decision accepted
63
+ python scripts/codecgc_cli.py route --flow feature --slug 2026-05-01-demo-login-ui
64
+ python scripts/codecgc_cli.py history --flow all --status open --last 10
65
+ """
66
+
67
+ SUBCOMMAND_HELP_TEXT: dict[str, str] = {
68
+ "init": """CodeCGC Workflow Init
69
+
70
+ 用法:
71
+ python scripts/codecgc_cli.py init --flow <feature|issue> --slug <slug> --summary <text> [options]
72
+
73
+ 用途:
74
+ 为 feature 或 issue 创建第一份最小工作流脚手架。
75
+
76
+ 适用场景:
77
+ - 这是一个全新的工作流,还没有任何产物。
78
+ - 你已经知道基本的 slug、summary 和大致目标范围。
79
+ - 你想先把最小文件结构建出来,再进入 plan 或 entry。
80
+
81
+ 关键参数:
82
+ --flow <feature|issue>
83
+ 指定是 feature 流还是 issue 流。
84
+ --slug <slug>
85
+ 用于存储产物的稳定工作流标识。
86
+ --summary <text>
87
+ 写入产物中的简短说明。
88
+ --target-path <path>
89
+ 可选的初始范围提示。多个路径可重复传入。
90
+ --kind <auto|frontend|backend>
91
+ 让 CodeCGC 自动判断路由,或在已知时直接指定前后端。
92
+
93
+ 典型结果:
94
+ 生成最小工作流产物,后续可继续走 plan 或 entry。
95
+ """,
96
+ "plan": """CodeCGC Workflow Plan
97
+
98
+ 用法:
99
+ python scripts/codecgc_cli.py plan --flow <feature|issue> --slug <slug> --summary <text> [options]
100
+
101
+ 用途:
102
+ 在真正委派执行前,澄清或修复一份工作流规划。
103
+
104
+ 适用场景:
105
+ - 需求还不完整,需要补 design 或 checklist。
106
+ - 当前产物里还有只用于规划的 step,或缺少 acceptance。
107
+ - 你希望 CodeCGC 判断下一步是否已经可以进入 build 或 fix。
108
+
109
+ 关键参数:
110
+ --flow <feature|issue>
111
+ 指定是 feature 规划还是 issue 规划。
112
+ --slug <slug>
113
+ 用于存储产物的稳定工作流标识。
114
+ --summary <text>
115
+ 写入产物中的简短说明。
116
+ --target-path <path>
117
+ 定义执行范围的文件或目录,可重复传入。
118
+ --kind <auto|frontend|backend>
119
+ 让 CodeCGC 自动判断归属,或在已知时直接指定前后端。
120
+
121
+ 高价值规划字段:
122
+ --goal / --user-story / --in-scope / --acceptance
123
+ 更适合 feature 规划。
124
+ --symptom / --expected / --actual / --preferred-fix
125
+ 更适合 issue 规划。
126
+
127
+ 典型结果:
128
+ 更新规划产物,并告诉你是继续 build、fix,还是先继续澄清。
129
+ """,
130
+ "build": """CodeCGC Workflow Build
131
+
132
+ 用法:
133
+ python scripts/codecgc_cli.py build --slug <slug> [--step-number <n>] [options]
134
+
135
+ 用途:
136
+ 通过高层 feature 执行入口,运行一个功能开发步骤。
137
+
138
+ 适用场景:
139
+ - feature 规划已经确认。
140
+ - checklist 已存在,并且某个前端或后端步骤已可执行。
141
+ - 你希望 CodeCGC 在写代码前先强制检查路由归属。
142
+
143
+ 关键参数:
144
+ --slug <slug>
145
+ feature 工作流标识。
146
+ --step-number <n>
147
+ 可选的精确步骤;不传时,CodeCGC 会自动选择当前 pending step。
148
+ --checklist-file <path>
149
+ 可选的显式 checklist 路径。
150
+ --dry-run
151
+ 只生成执行意图,不真正委派代码执行。
152
+
153
+ 典型结果:
154
+ 运行一个功能开发步骤,写出 execution audit,并进入 review。
155
+ """,
156
+ "fix": """CodeCGC Workflow Fix
157
+
158
+ 用法:
159
+ python scripts/codecgc_cli.py fix --slug <slug> [--step-number <n>] [options]
160
+
161
+ 用途:
162
+ 通过高层 issue 执行入口,运行一个问题修复步骤。
163
+
164
+ 适用场景:
165
+ - issue 规划或分析已经收敛出一个可执行修复步骤。
166
+ - 下一步是路由后的代码修改,而不是继续诊断。
167
+ - 你希望沿用与 feature 相同的 audit 与 review 约束。
168
+
169
+ 关键参数:
170
+ --slug <slug>
171
+ issue 工作流标识。
172
+ --step-number <n>
173
+ 可选的精确步骤;不传时,CodeCGC 会自动选择当前 pending step。
174
+ --checklist-file <path>
175
+ 可选的显式修复清单路径。
176
+ --dry-run
177
+ 只生成执行意图,不真正委派代码执行。
178
+
179
+ 典型结果:
180
+ 运行一个问题修复步骤,写出 execution audit,并进入 review。
181
+ """,
182
+ "test": """CodeCGC Workflow Test
183
+
184
+ 用法:
185
+ python scripts/codecgc_cli.py test --flow <feature|issue> --slug <slug> [--step-number <n>] [options]
186
+
187
+ 用途:
188
+ 通过高层测试执行入口,运行一个测试步骤。
189
+
190
+ 适用场景:
191
+ - 主代码步骤已经规划完成,下一步是补充或更新对应测试。
192
+ - 你希望测试也进入与 build/fix 一致的 audit 与 review 主流程。
193
+ - 你不希望测试仍然停留在主流程之外的手工动作。
194
+
195
+ 关键参数:
196
+ --flow <feature|issue>
197
+ 指定该测试步骤属于 feature 还是 issue 工作流。
198
+ --slug <slug>
199
+ 稳定工作流标识。
200
+ --step-number <n>
201
+ 可选的精确步骤;不传时,CodeCGC 会自动选择当前 pending 测试步骤。
202
+ --dry-run
203
+ 只生成执行意图,不真正委派代码执行。
204
+
205
+ 典型结果:
206
+ 运行一个测试步骤,写出 execution audit,并进入 review。
207
+ """,
208
+ "review": """CodeCGC Workflow Review
209
+
210
+ 用法:
211
+ python scripts/codecgc_cli.py review --audit-file <path> --decision <accepted|changes-requested> [options]
212
+
213
+ 用途:
214
+ 审核一次 execution audit,并把结果回写到工作流产物中。
215
+
216
+ 适用场景:
217
+ - build 或 fix 已执行完成,并产出了 audit 文件。
218
+ - 你要判断这个步骤是“通过”,还是应该退回修改。
219
+ - 你希望把 review 状态写回去,供 route 判断下一步命令。
220
+
221
+ 关键参数:
222
+ --audit-file <path>
223
+ build、fix 或 exec 生成的 execution audit 文件。
224
+ --decision <accepted|changes-requested>
225
+ 希望写回的审核结论。
226
+ --risk <text>
227
+ 可选的额外风险说明,可重复传入。
228
+ --next-step <text>
229
+ 可选的下一步动作说明。
230
+
231
+ 典型结果:
232
+ 回写 review 结果,并告诉你当前工作流是关闭、继续执行,还是退回规划。
233
+ """,
234
+ "route": """CodeCGC Workflow Route
235
+
236
+ 用法:
237
+ python scripts/codecgc_cli.py route --flow <feature|issue> --slug <slug>
238
+
239
+ 用途:
240
+ 根据当前工作流产物状态,让 CodeCGC 判断下一步应该运行哪个命令。
241
+
242
+ 适用场景:
243
+ - 你已经有 workflow slug,但不想手动读产物判断状态。
244
+ - 你需要知道现在该回到 plan、进入 build/fix、进入 review,还是已经结束。
245
+ - Claude 在回复用户前,希望先拿到稳定、确定的下一步命令摘要。
246
+
247
+ 关键参数:
248
+ --flow <feature|issue>
249
+ 工作流类型。
250
+ --slug <slug>
251
+ 稳定工作流标识。
252
+
253
+ 典型结果:
254
+ 返回推荐命令、当前 route 状态,以及为什么做出这个判断。
255
+ """,
256
+ "entry": """CodeCGC Workflow Entry
257
+
258
+ 用法:
259
+ python scripts/codecgc_cli.py entry [--request <text> | --payload-file <file> | --payload-json <json>] [options]
260
+
261
+ 用途:
262
+ 通过一个单入口处理新需求、继续已有工作流,或解释下一步。
263
+
264
+ 适用场景:
265
+ - 你希望以 Claude 面向用户的方式工作,而不是手动选择 plan/build/fix/review。
266
+ - 你只有自然语言需求,希望 CodeCGC 自动抽取规划信息。
267
+ - 你想继续已有 slug,或直接问 CodeCGC 现在下一步是什么。
268
+
269
+ 关键参数:
270
+ --request <text>
271
+ 自然语言请求或操作指令。
272
+ --mode <auto|new|continue|explain>
273
+ 让 CodeCGC 自动判断意图,或强制指定交互模式。
274
+ --flow <feature|issue>
275
+ 在已知时,可显式指定工作流类型。
276
+ --slug <slug>
277
+ continue / explain 场景下的已有工作流标识。
278
+ --payload-file / --payload-json / --payload-base64
279
+ 重新喂入上一轮结构化规划数据,避免重复拼接长参数。
280
+
281
+ 典型结果:
282
+ CodeCGC 会根据当前状态选择继续追问、更新规划,或在准备好后直接调度到 build、fix、review。
283
+ """,
284
+ "exec": """CodeCGC Workflow Exec
285
+
286
+ 用法:
287
+ python scripts/codecgc_cli.py exec --flow <feature|issue> --slug <slug> --step-number <n> [options]
288
+
289
+ 用途:
290
+ 在你已经明确知道 flow、slug 和 step 编号时,精确执行一个 step。
291
+
292
+ 适用场景:
293
+ - 你需要一个比 build/fix 更底层的执行入口。
294
+ - 你已经知道具体 step,不需要 route 再帮你选择。
295
+ - 你在调试执行行为,或重放某一个特定 step。
296
+
297
+ 关键参数:
298
+ --flow <feature|issue>
299
+ 工作流类型。
300
+ --slug <slug>
301
+ 稳定工作流标识。
302
+ --step-number <n>
303
+ 要执行的精确 step 编号。
304
+ --checklist-file <path>
305
+ 可选的显式 checklist 路径。
306
+ --dry-run
307
+ 只生成执行意图,不真正委派代码执行。
308
+
309
+ 典型结果:
310
+ 执行一个精确 step,写出 execution audit,并把结果留给 review 处理。
311
+ """,
312
+ "history": """CodeCGC Workflow History
313
+
314
+ 用法:
315
+ python scripts/codecgc_cli.py history [--flow <all|feature|issue>] [--status <all|open|closed|needs-planning|awaiting-build|awaiting-fix|awaiting-review>] [--last <n>] [options]
316
+
317
+ 用途:
318
+ 只读查看最近的 CodeCGC workflow 历史,不改任何状态。
319
+
320
+ 适用场景:
321
+ - 你想知道最近哪些 feature / issue 还没关闭
322
+ - 你不想手工翻 codecgc/features 和 codecgc/issues 目录
323
+ - Claude 想快速拿到“最近应该继续哪条 workflow”
324
+
325
+ 关键参数:
326
+ --flow <all|feature|issue>
327
+ 过滤 feature、issue 或全部工作流。
328
+ --status <...>
329
+ 过滤 open / closed / needs-planning / awaiting-build / awaiting-fix / awaiting-review 等状态。
330
+ --last <n>
331
+ 限制返回最近 N 条记录。
332
+ --include-fixtures
333
+ 默认只看 product 工作流;传入后把 fixture 也一起纳入。
334
+ --format <summary|json>
335
+ summary 适合人和 Claude 直接阅读,json 适合自动化。
336
+
337
+ 典型结果:
338
+ 返回最近工作流的关闭状态、下一条推荐命令,以及可继续跟进的 slug 列表。
339
+ """,
340
+ }
341
+
342
+
343
+ def build_parser() -> argparse.ArgumentParser:
344
+ parser = argparse.ArgumentParser(
345
+ description="Unified local CLI wrapper for CodeCGC workflow initialization, execution, and review."
346
+ )
347
+ subparsers = parser.add_subparsers(dest="command", required=True)
348
+
349
+ init_parser = subparsers.add_parser("init", help="Initialize feature or issue workflow artifacts.")
350
+ init_parser.add_argument("--flow", required=True, choices=["feature", "issue"])
351
+ init_parser.add_argument("--slug", required=True)
352
+ init_parser.add_argument("--summary", required=True)
353
+ init_parser.add_argument("--date", default="")
354
+ init_parser.add_argument("--target-path", action="append", default=[])
355
+ init_parser.add_argument("--kind", choices=["auto", "frontend", "backend"], default="auto")
356
+ init_parser.add_argument("--artifact-class", choices=["product", "fixture"], default="product")
357
+ init_parser.add_argument("--force", action="store_true")
358
+
359
+ plan_parser = subparsers.add_parser("plan", help="Create or repair a workflow scaffold and route the next step.")
360
+ plan_parser.add_argument("--flow", required=True, choices=["feature", "issue"])
361
+ plan_parser.add_argument("--slug", required=True)
362
+ plan_parser.add_argument("--summary", required=True)
363
+ plan_parser.add_argument("--date", default="")
364
+ plan_parser.add_argument("--target-path", action="append", default=[])
365
+ plan_parser.add_argument("--kind", choices=["auto", "frontend", "backend"], default="auto")
366
+ plan_parser.add_argument("--goal", default="")
367
+ plan_parser.add_argument("--context", action="append", default=[])
368
+ plan_parser.add_argument("--user-story", default="")
369
+ plan_parser.add_argument("--in-scope", action="append", default=[])
370
+ plan_parser.add_argument("--out-of-scope", action="append", default=[])
371
+ plan_parser.add_argument("--acceptance", action="append", default=[])
372
+ plan_parser.add_argument("--risk", action="append", default=[])
373
+ plan_parser.add_argument("--dependency", action="append", default=[])
374
+ plan_parser.add_argument("--assumption", action="append", default=[])
375
+ plan_parser.add_argument("--open-question", action="append", default=[])
376
+ plan_parser.add_argument("--validation", action="append", default=[])
377
+ plan_parser.add_argument("--rollback", action="append", default=[])
378
+ plan_parser.add_argument("--symptom", default="")
379
+ plan_parser.add_argument("--reproduction", default="")
380
+ plan_parser.add_argument("--expected", default="")
381
+ plan_parser.add_argument("--actual", default="")
382
+ plan_parser.add_argument("--root-cause", default="")
383
+ plan_parser.add_argument("--preferred-fix", default="")
384
+ plan_parser.add_argument("--rejected-fix", default="")
385
+ plan_parser.add_argument("--artifact-class", choices=["product", "fixture"], default="product")
386
+ plan_parser.add_argument("--force", action="store_true")
387
+
388
+ entry_parser = subparsers.add_parser("entry", help="Single-entry orchestration for new work, continue flow, or explain-next-step.")
389
+ entry_parser.add_argument("--payload-json", default="")
390
+ entry_parser.add_argument("--payload-base64", default="")
391
+ entry_parser.add_argument("--payload-file", default="")
392
+ entry_parser.add_argument("--mode", choices=["auto", "new", "continue", "explain"], default="auto")
393
+ entry_parser.add_argument("--flow", choices=["feature", "issue"], default="")
394
+ entry_parser.add_argument("--slug", default="")
395
+ entry_parser.add_argument("--summary", default="")
396
+ entry_parser.add_argument("--request", default="")
397
+ entry_parser.add_argument("--date", default="")
398
+ entry_parser.add_argument("--target-path", action="append", default=[])
399
+ entry_parser.add_argument("--kind", choices=["auto", "frontend", "backend"], default="auto")
400
+ entry_parser.add_argument("--goal", default="")
401
+ entry_parser.add_argument("--context", action="append", default=[])
402
+ entry_parser.add_argument("--user-story", default="")
403
+ entry_parser.add_argument("--in-scope", action="append", default=[])
404
+ entry_parser.add_argument("--out-of-scope", action="append", default=[])
405
+ entry_parser.add_argument("--acceptance", action="append", default=[])
406
+ entry_parser.add_argument("--risk", action="append", default=[])
407
+ entry_parser.add_argument("--dependency", action="append", default=[])
408
+ entry_parser.add_argument("--assumption", action="append", default=[])
409
+ entry_parser.add_argument("--open-question", action="append", default=[])
410
+ entry_parser.add_argument("--validation", action="append", default=[])
411
+ entry_parser.add_argument("--rollback", action="append", default=[])
412
+ entry_parser.add_argument("--symptom", default="")
413
+ entry_parser.add_argument("--reproduction", default="")
414
+ entry_parser.add_argument("--expected", default="")
415
+ entry_parser.add_argument("--actual", default="")
416
+ entry_parser.add_argument("--root-cause", default="")
417
+ entry_parser.add_argument("--preferred-fix", default="")
418
+ entry_parser.add_argument("--rejected-fix", default="")
419
+ entry_parser.add_argument("--artifact-class", choices=["product", "fixture"], default="product")
420
+ entry_parser.add_argument("--latest", action="store_true")
421
+ entry_parser.add_argument("--include-fixtures", action="store_true")
422
+ entry_parser.add_argument("--step-number", type=int)
423
+ entry_parser.add_argument("--checklist-file", default="")
424
+ entry_parser.add_argument("--audit-root", default="")
425
+ entry_parser.add_argument("--timeout-seconds", type=int, default=120)
426
+ entry_parser.add_argument("--dry-run", action="store_true")
427
+ entry_parser.add_argument("--return-all-messages", action="store_true")
428
+ entry_parser.add_argument("--auto-dispatch", action="store_true")
429
+ entry_parser.add_argument("--decision", choices=["accepted", "changes-requested"], default="")
430
+ entry_parser.add_argument("--audit-file", default="")
431
+ entry_parser.add_argument("--next-step", default="")
432
+ entry_parser.add_argument("--force", action="store_true")
433
+
434
+ build_parser = subparsers.add_parser("build", help="Run one feature step through the high-level feature workflow entry.")
435
+ build_parser.add_argument("--slug", required=True)
436
+ build_parser.add_argument("--step-number", type=int)
437
+ build_parser.add_argument("--checklist-file", default="")
438
+ build_parser.add_argument("--audit-root", default="")
439
+ build_parser.add_argument("--timeout-seconds", type=int, default=120)
440
+ build_parser.add_argument("--session-id", default="")
441
+ build_parser.add_argument("--dry-run", action="store_true")
442
+ build_parser.add_argument("--return-all-messages", action="store_true")
443
+
444
+ fix_parser = subparsers.add_parser("fix", help="Run one issue-fix step through the high-level fix workflow entry.")
445
+ fix_parser.add_argument("--slug", required=True)
446
+ fix_parser.add_argument("--step-number", type=int)
447
+ fix_parser.add_argument("--checklist-file", default="")
448
+ fix_parser.add_argument("--audit-root", default="")
449
+ fix_parser.add_argument("--timeout-seconds", type=int, default=120)
450
+ fix_parser.add_argument("--session-id", default="")
451
+ fix_parser.add_argument("--dry-run", action="store_true")
452
+ fix_parser.add_argument("--return-all-messages", action="store_true")
453
+
454
+ test_parser = subparsers.add_parser("test", help="Run one test step through the high-level test workflow entry.")
455
+ test_parser.add_argument("--flow", required=True, choices=["feature", "issue"])
456
+ test_parser.add_argument("--slug", required=True)
457
+ test_parser.add_argument("--step-number", type=int)
458
+ test_parser.add_argument("--checklist-file", default="")
459
+ test_parser.add_argument("--audit-root", default="")
460
+ test_parser.add_argument("--timeout-seconds", type=int, default=120)
461
+ test_parser.add_argument("--session-id", default="")
462
+ test_parser.add_argument("--dry-run", action="store_true")
463
+ test_parser.add_argument("--return-all-messages", action="store_true")
464
+
465
+ exec_parser = subparsers.add_parser("exec", help="Execute one feature or issue step.")
466
+ exec_parser.add_argument("--flow", required=True, choices=["feature", "issue"])
467
+ exec_parser.add_argument("--slug", required=True)
468
+ exec_parser.add_argument("--step-number", required=True, type=int)
469
+ exec_parser.add_argument("--checklist-file", default="")
470
+ exec_parser.add_argument("--audit-root", default="")
471
+ exec_parser.add_argument("--timeout-seconds", type=int, default=120)
472
+ exec_parser.add_argument("--session-id", default="")
473
+ exec_parser.add_argument("--dry-run", action="store_true")
474
+ exec_parser.add_argument("--return-all-messages", action="store_true")
475
+
476
+ review_parser = subparsers.add_parser("review", help="Write review results back from an audit artifact.")
477
+ review_parser.add_argument("--audit-file", required=True)
478
+ review_parser.add_argument("--decision", required=True, choices=["accepted", "changes-requested"])
479
+ review_parser.add_argument("--risk", action="append", default=[])
480
+ review_parser.add_argument("--next-step", default="")
481
+ review_parser.add_argument("--force", action="store_true")
482
+
483
+ route_parser = subparsers.add_parser("route", help="Recommend the next CodeCGC command from current artifact state.")
484
+ route_parser.add_argument("--flow", required=True, choices=["feature", "issue"])
485
+ route_parser.add_argument("--slug", required=True)
486
+
487
+ history_parser = subparsers.add_parser("history", help="Read-only query of recent CodeCGC workflow history.")
488
+ history_parser.add_argument("--flow", choices=["all", "feature", "issue"], default="all")
489
+ history_parser.add_argument("--status", default="all")
490
+ history_parser.add_argument("--last", type=int, default=10)
491
+ history_parser.add_argument("--include-fixtures", action="store_true")
492
+ history_parser.add_argument("--format", choices=["summary", "json"], default="summary")
493
+
494
+ return parser
495
+
496
+
497
+ def build_command(args: argparse.Namespace) -> list[str]:
498
+ if args.command == "init":
499
+ command = [
500
+ sys.executable,
501
+ str(WORKSPACE / "scripts" / "init_codecgc_workflow.py"),
502
+ "--flow",
503
+ args.flow,
504
+ "--slug",
505
+ args.slug,
506
+ "--summary",
507
+ args.summary,
508
+ "--kind",
509
+ args.kind,
510
+ "--artifact-class",
511
+ args.artifact_class,
512
+ ]
513
+ if args.date:
514
+ command.extend(["--date", args.date])
515
+ for item in args.target_path:
516
+ command.extend(["--target-path", item])
517
+ if args.force:
518
+ command.append("--force")
519
+ return command
520
+
521
+ if args.command == "plan":
522
+ command = [
523
+ sys.executable,
524
+ str(WORKSPACE / "scripts" / "plan_codecgc_workflow.py"),
525
+ "--flow",
526
+ args.flow,
527
+ "--slug",
528
+ args.slug,
529
+ "--summary",
530
+ args.summary,
531
+ "--kind",
532
+ args.kind,
533
+ "--artifact-class",
534
+ args.artifact_class,
535
+ ]
536
+ if args.date:
537
+ command.extend(["--date", args.date])
538
+ for item in args.target_path:
539
+ command.extend(["--target-path", item])
540
+ if args.goal:
541
+ command.extend(["--goal", args.goal])
542
+ if args.user_story:
543
+ command.extend(["--user-story", args.user_story])
544
+ for item in args.context:
545
+ command.extend(["--context", item])
546
+ for item in args.in_scope:
547
+ command.extend(["--in-scope", item])
548
+ for item in args.out_of_scope:
549
+ command.extend(["--out-of-scope", item])
550
+ for item in args.acceptance:
551
+ command.extend(["--acceptance", item])
552
+ for item in args.risk:
553
+ command.extend(["--risk", item])
554
+ for item in args.dependency:
555
+ command.extend(["--dependency", item])
556
+ for item in args.assumption:
557
+ command.extend(["--assumption", item])
558
+ for item in args.open_question:
559
+ command.extend(["--open-question", item])
560
+ for item in args.validation:
561
+ command.extend(["--validation", item])
562
+ for item in args.rollback:
563
+ command.extend(["--rollback", item])
564
+ if args.symptom:
565
+ command.extend(["--symptom", args.symptom])
566
+ if args.reproduction:
567
+ command.extend(["--reproduction", args.reproduction])
568
+ if args.expected:
569
+ command.extend(["--expected", args.expected])
570
+ if args.actual:
571
+ command.extend(["--actual", args.actual])
572
+ if args.root_cause:
573
+ command.extend(["--root-cause", args.root_cause])
574
+ if args.preferred_fix:
575
+ command.extend(["--preferred-fix", args.preferred_fix])
576
+ if args.rejected_fix:
577
+ command.extend(["--rejected-fix", args.rejected_fix])
578
+ if args.force:
579
+ command.append("--force")
580
+ return command
581
+
582
+ if args.command == "entry":
583
+ command = [
584
+ sys.executable,
585
+ str(WORKSPACE / "scripts" / "entry_codecgc_workflow.py"),
586
+ ]
587
+ if args.payload_json:
588
+ command.extend(["--payload-json", args.payload_json])
589
+ if args.payload_base64:
590
+ command.extend(["--payload-base64", args.payload_base64])
591
+ if args.payload_file:
592
+ command.extend(["--payload-file", args.payload_file])
593
+ command.extend([
594
+ "--mode",
595
+ args.mode,
596
+ "--kind",
597
+ args.kind,
598
+ "--artifact-class",
599
+ args.artifact_class,
600
+ "--timeout-seconds",
601
+ str(args.timeout_seconds),
602
+ ])
603
+ if args.flow:
604
+ command.extend(["--flow", args.flow])
605
+ if args.slug:
606
+ command.extend(["--slug", args.slug])
607
+ if args.summary:
608
+ command.extend(["--summary", args.summary])
609
+ if args.request:
610
+ command.extend(["--request", args.request])
611
+ if args.date:
612
+ command.extend(["--date", args.date])
613
+ for item in args.target_path:
614
+ command.extend(["--target-path", item])
615
+ if args.goal:
616
+ command.extend(["--goal", args.goal])
617
+ if args.user_story:
618
+ command.extend(["--user-story", args.user_story])
619
+ for item in args.context:
620
+ command.extend(["--context", item])
621
+ for item in args.in_scope:
622
+ command.extend(["--in-scope", item])
623
+ for item in args.out_of_scope:
624
+ command.extend(["--out-of-scope", item])
625
+ for item in args.acceptance:
626
+ command.extend(["--acceptance", item])
627
+ for item in args.risk:
628
+ command.extend(["--risk", item])
629
+ for item in args.dependency:
630
+ command.extend(["--dependency", item])
631
+ for item in args.assumption:
632
+ command.extend(["--assumption", item])
633
+ for item in args.open_question:
634
+ command.extend(["--open-question", item])
635
+ for item in args.validation:
636
+ command.extend(["--validation", item])
637
+ for item in args.rollback:
638
+ command.extend(["--rollback", item])
639
+ if args.symptom:
640
+ command.extend(["--symptom", args.symptom])
641
+ if args.reproduction:
642
+ command.extend(["--reproduction", args.reproduction])
643
+ if args.expected:
644
+ command.extend(["--expected", args.expected])
645
+ if args.actual:
646
+ command.extend(["--actual", args.actual])
647
+ if args.root_cause:
648
+ command.extend(["--root-cause", args.root_cause])
649
+ if args.preferred_fix:
650
+ command.extend(["--preferred-fix", args.preferred_fix])
651
+ if args.rejected_fix:
652
+ command.extend(["--rejected-fix", args.rejected_fix])
653
+ if args.latest:
654
+ command.append("--latest")
655
+ if args.include_fixtures:
656
+ command.append("--include-fixtures")
657
+ if args.step_number is not None:
658
+ command.extend(["--step-number", str(args.step_number)])
659
+ if args.checklist_file:
660
+ command.extend(["--checklist-file", args.checklist_file])
661
+ if args.audit_root:
662
+ command.extend(["--audit-root", args.audit_root])
663
+ if args.session_id:
664
+ command.extend(["--session-id", args.session_id])
665
+ if args.dry_run:
666
+ command.append("--dry-run")
667
+ if args.return_all_messages:
668
+ command.append("--return-all-messages")
669
+ if args.auto_dispatch:
670
+ command.append("--auto-dispatch")
671
+ if args.decision:
672
+ command.extend(["--decision", args.decision])
673
+ if args.audit_file:
674
+ command.extend(["--audit-file", args.audit_file])
675
+ if args.next_step:
676
+ command.extend(["--next-step", args.next_step])
677
+ if args.force:
678
+ command.append("--force")
679
+ return command
680
+
681
+ if args.command == "build":
682
+ command = [
683
+ sys.executable,
684
+ str(WORKSPACE / "scripts" / "run_codecgc_build.py"),
685
+ "--slug",
686
+ args.slug,
687
+ "--timeout-seconds",
688
+ str(args.timeout_seconds),
689
+ ]
690
+ if args.step_number is not None:
691
+ command.extend(["--step-number", str(args.step_number)])
692
+ if args.checklist_file:
693
+ command.extend(["--checklist-file", args.checklist_file])
694
+ if args.audit_root:
695
+ command.extend(["--audit-root", args.audit_root])
696
+ if args.session_id:
697
+ command.extend(["--session-id", args.session_id])
698
+ if args.dry_run:
699
+ command.append("--dry-run")
700
+ if args.return_all_messages:
701
+ command.append("--return-all-messages")
702
+ return command
703
+
704
+ if args.command == "fix":
705
+ command = [
706
+ sys.executable,
707
+ str(WORKSPACE / "scripts" / "run_codecgc_fix.py"),
708
+ "--slug",
709
+ args.slug,
710
+ "--timeout-seconds",
711
+ str(args.timeout_seconds),
712
+ ]
713
+ if args.step_number is not None:
714
+ command.extend(["--step-number", str(args.step_number)])
715
+ if args.checklist_file:
716
+ command.extend(["--checklist-file", args.checklist_file])
717
+ if args.audit_root:
718
+ command.extend(["--audit-root", args.audit_root])
719
+ if args.session_id:
720
+ command.extend(["--session-id", args.session_id])
721
+ if args.dry_run:
722
+ command.append("--dry-run")
723
+ if args.return_all_messages:
724
+ command.append("--return-all-messages")
725
+ return command
726
+
727
+ if args.command == "test":
728
+ command = [
729
+ sys.executable,
730
+ str(WORKSPACE / "scripts" / "run_codecgc_test.py"),
731
+ "--flow",
732
+ args.flow,
733
+ "--slug",
734
+ args.slug,
735
+ "--timeout-seconds",
736
+ str(args.timeout_seconds),
737
+ ]
738
+ if args.step_number is not None:
739
+ command.extend(["--step-number", str(args.step_number)])
740
+ if args.checklist_file:
741
+ command.extend(["--checklist-file", args.checklist_file])
742
+ if args.audit_root:
743
+ command.extend(["--audit-root", args.audit_root])
744
+ if args.session_id:
745
+ command.extend(["--session-id", args.session_id])
746
+ if args.dry_run:
747
+ command.append("--dry-run")
748
+ if args.return_all_messages:
749
+ command.append("--return-all-messages")
750
+ return command
751
+
752
+ if args.command == "exec":
753
+ command = [
754
+ sys.executable,
755
+ str(WORKSPACE / "scripts" / "run_codecgc_flow_step.py"),
756
+ "--flow",
757
+ args.flow,
758
+ "--slug",
759
+ args.slug,
760
+ "--step-number",
761
+ str(args.step_number),
762
+ "--timeout-seconds",
763
+ str(args.timeout_seconds),
764
+ ]
765
+ if args.checklist_file:
766
+ command.extend(["--checklist-file", args.checklist_file])
767
+ if args.audit_root:
768
+ command.extend(["--audit-root", args.audit_root])
769
+ if args.dry_run:
770
+ command.append("--dry-run")
771
+ if args.return_all_messages:
772
+ command.append("--return-all-messages")
773
+ return command
774
+
775
+ if args.command == "review":
776
+ command = [
777
+ sys.executable,
778
+ str(WORKSPACE / "scripts" / "review_codecgc_workflow.py"),
779
+ "--audit-file",
780
+ args.audit_file,
781
+ "--decision",
782
+ args.decision,
783
+ ]
784
+ for item in args.risk:
785
+ command.extend(["--risk", item])
786
+ if args.next_step:
787
+ command.extend(["--next-step", args.next_step])
788
+ if args.force:
789
+ command.append("--force")
790
+ return command
791
+
792
+ if args.command == "route":
793
+ return [
794
+ sys.executable,
795
+ str(WORKSPACE / "scripts" / "route_codecgc_workflow.py"),
796
+ "--flow",
797
+ args.flow,
798
+ "--slug",
799
+ args.slug,
800
+ ]
801
+
802
+ if args.command == "history":
803
+ command = [
804
+ sys.executable,
805
+ str(WORKSPACE / "scripts" / "audit_codecgc_workflow_history.py"),
806
+ "--flow",
807
+ args.flow,
808
+ "--status",
809
+ args.status,
810
+ "--last",
811
+ str(args.last),
812
+ "--format",
813
+ args.format,
814
+ ]
815
+ if args.include_fixtures:
816
+ command.append("--include-fixtures")
817
+ return command
818
+
819
+ raise ValueError(f"Unsupported command: {args.command}")
820
+
821
+
822
+ def main() -> int:
823
+ if len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] in {"--help", "-h"}):
824
+ print(HELP_TEXT)
825
+ return 0
826
+
827
+ if len(sys.argv) == 3 and sys.argv[2] in {"--help", "-h"}:
828
+ subcommand = sys.argv[1]
829
+ help_text = SUBCOMMAND_HELP_TEXT.get(subcommand, "")
830
+ if help_text:
831
+ print(help_text)
832
+ return 0
833
+
834
+ parser = build_parser()
835
+ args = parser.parse_args()
836
+ command = build_command(args)
837
+
838
+ completed = subprocess.run(command, cwd=PROJECT_WORKSPACE)
839
+ return completed.returncode
840
+
841
+
842
+ if __name__ == "__main__":
843
+ raise SystemExit(main())