@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,437 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def build_feature_paths(flow_dir: Path, slug: str) -> dict[str, Path]:
5
+ return {
6
+ "design": flow_dir / f"{slug}-design.md",
7
+ "checklist": flow_dir / f"{slug}-checklist.yaml",
8
+ "acceptance": flow_dir / f"{slug}-acceptance.md",
9
+ }
10
+
11
+
12
+ def build_issue_paths(flow_dir: Path, slug: str) -> dict[str, Path]:
13
+ return {
14
+ "report": flow_dir / f"{slug}-report.md",
15
+ "analysis": flow_dir / f"{slug}-analysis.md",
16
+ "fix": flow_dir / f"{slug}-fix.yaml",
17
+ "fix_note": flow_dir / f"{slug}-fix-note.md",
18
+ }
19
+
20
+
21
+ def render_bullet_list(items: list[str], indent: str, fallback: str) -> str:
22
+ if not items:
23
+ return f"{indent}- {fallback}"
24
+ return "\n".join(f"{indent}- {item}" for item in items)
25
+
26
+
27
+ def render_optional_bullet_list(items: list[str], indent: str) -> str:
28
+ if not items:
29
+ return ""
30
+ return "\n".join(f"{indent}- {item}" for item in items)
31
+
32
+
33
+ def build_scope_lines(kind: str, target_paths: list[str]) -> list[str]:
34
+ if target_paths:
35
+ return [f"仅修改 `{path}`。" for path in target_paths]
36
+ if kind == "frontend":
37
+ return ["实现一个仅前端范围、且目标文件明确的执行步骤。"]
38
+ if kind == "backend":
39
+ return ["实现一个仅后端范围、且目标文件明确的执行步骤。"]
40
+ return ["在真实执行前,先把工作拆成单执行器可接管的范围。"]
41
+
42
+
43
+ def build_non_goal_lines(kind: str) -> list[str]:
44
+ if kind == "frontend":
45
+ return [
46
+ "不要改动后端 API、持久化或服务端业务逻辑。",
47
+ "不要把这个执行步骤扩展成前后端混合工作。",
48
+ ]
49
+ if kind == "backend":
50
+ return [
51
+ "不要改动页面布局、样式或仅浏览器侧的交互行为。",
52
+ "不要把这个执行步骤扩展成前后端混合工作。",
53
+ ]
54
+ return [
55
+ "不要在一个执行步骤中混合前端和后端执行。",
56
+ "不要把尚未拍板的设计选择留在可执行步骤里。",
57
+ ]
58
+
59
+
60
+ def build_acceptance_lines(kind: str, target_paths: list[str]) -> list[str]:
61
+ lines = ["返回结构化执行结果。"]
62
+ if target_paths:
63
+ lines.append("变更文件必须保持在 target_paths 范围内。")
64
+ if kind == "frontend":
65
+ lines.append("用户可见的前端行为只覆盖当前已批准的范围。")
66
+ elif kind == "backend":
67
+ lines.append("后端行为变更只覆盖当前已批准的修复或功能步骤。")
68
+ return lines
69
+
70
+
71
+ def build_constraint_lines(kind: str) -> list[str]:
72
+ lines = ["不要修改 target_paths 之外的文件。"]
73
+ if kind == "frontend":
74
+ lines.append("不要改动后端 API。")
75
+ elif kind == "backend":
76
+ lines.append("不要改动前端 UI 行为。")
77
+ return lines
78
+
79
+
80
+ def build_test_acceptance_lines(kind: str, target_paths: list[str]) -> list[str]:
81
+ lines = ["返回结构化执行结果。", "只补充或更新当前范围内的测试。"]
82
+ if target_paths:
83
+ lines.append("测试相关变更文件必须保持在 target_paths 范围内。")
84
+ if kind == "frontend":
85
+ lines.append("优先覆盖界面、交互或前端行为回归。")
86
+ elif kind == "backend":
87
+ lines.append("优先覆盖接口、服务或后端行为回归。")
88
+ return lines
89
+
90
+
91
+ def build_test_constraint_lines(kind: str) -> list[str]:
92
+ lines = ["不要修改测试范围外的业务文件。"]
93
+ if kind == "frontend":
94
+ lines.append("不要新增后端 API 逻辑。")
95
+ elif kind == "backend":
96
+ lines.append("不要新增前端 UI 行为。")
97
+ return lines
98
+
99
+
100
+ def render_feature_design(
101
+ directory_name: str,
102
+ summary: str,
103
+ kind: str,
104
+ target_paths: list[str],
105
+ artifact_class: str = "product",
106
+ ) -> str:
107
+ owner = "前端 / Gemini" if kind == "frontend" else "后端 / Codex" if kind == "backend" else "待拆分"
108
+ return f"""---
109
+ doc_type: feature-design
110
+ artifact_class: {artifact_class}
111
+ feature: {directory_name}
112
+ status: draft
113
+ summary: {summary}
114
+ tags: []
115
+ ---
116
+
117
+ # {summary}
118
+
119
+ ## 1. 目标
120
+
121
+ - 摘要: {summary}
122
+ - 计划执行归属: {owner}
123
+ - 候选目标路径:
124
+ {render_bullet_list(target_paths, " ", "待补路径")}
125
+
126
+ ## 2. 范围内
127
+
128
+ {render_bullet_list(build_scope_lines(kind, target_paths), "", "待补充")}
129
+
130
+ ## 3. 范围外
131
+
132
+ {render_bullet_list(build_non_goal_lines(kind), "", "待补充")}
133
+
134
+ ## 4. 执行说明
135
+
136
+ - 该产物应作为单一归属的执行步骤处理。
137
+ - 如果当前执行步骤仍然过于模糊,应先补齐验收条件,再进行非“仅预演”执行。
138
+ - 如果目标路径或归属变成混合状态,应重新拆分工作。
139
+ """
140
+
141
+
142
+ def render_feature_checklist(
143
+ directory_name: str,
144
+ slug: str,
145
+ created_date: str,
146
+ kind: str,
147
+ target_paths: list[str],
148
+ artifact_class: str = "product",
149
+ ) -> str:
150
+ return render_feature_checklist_steps(
151
+ directory_name,
152
+ created_date,
153
+ artifact_class,
154
+ [
155
+ {
156
+ "action": "定义一个可执行的功能开发步骤",
157
+ "exit_signal": "步骤契约已经可以进入委派执行",
158
+ "status": "pending",
159
+ "codecgc": {
160
+ "kind": kind,
161
+ "task_id": f"{slug}-step-1",
162
+ "task_summary": "只实现当前已批准的功能开发步骤。",
163
+ "target_paths": target_paths or ["待补路径"],
164
+ "constraints": build_constraint_lines(kind),
165
+ "acceptance": build_acceptance_lines(kind, target_paths),
166
+ "cd": ".",
167
+ },
168
+ }
169
+ ],
170
+ )
171
+
172
+
173
+ def render_feature_acceptance(summary: str, artifact_class: str = "product") -> str:
174
+ return f"""---
175
+ doc_type: feature-acceptance
176
+ artifact_class: {artifact_class}
177
+ status: draft
178
+ summary: {summary}
179
+ tags: []
180
+ ---
181
+
182
+ # {summary} 验收
183
+
184
+ ## 1. 范围检查
185
+
186
+ 待补充
187
+
188
+ ## 2. 执行器检查
189
+
190
+ 待补充
191
+
192
+ ## 3. 剩余风险
193
+
194
+ 待补充
195
+ """
196
+
197
+
198
+ def render_issue_report(
199
+ directory_name: str,
200
+ summary: str,
201
+ kind: str,
202
+ target_paths: list[str],
203
+ artifact_class: str = "product",
204
+ ) -> str:
205
+ owner = "前端 / Gemini" if kind == "frontend" else "后端 / Codex" if kind == "backend" else "待拆分"
206
+ return f"""---
207
+ doc_type: issue-report
208
+ artifact_class: {artifact_class}
209
+ issue: {directory_name}
210
+ status: draft
211
+ severity: P2
212
+ summary: {summary}
213
+ tags: []
214
+ ---
215
+
216
+ # {summary} 问题报告
217
+
218
+ ## 1. 现象
219
+
220
+ - 摘要: {summary}
221
+ - 预估执行归属: {owner}
222
+ - 候选影响路径:
223
+ {render_bullet_list(target_paths, " ", "待补路径")}
224
+
225
+ ## 2. 复现方式
226
+
227
+ - 待补充:描述这个问题的最小复现路径。
228
+
229
+ ## 3. 预期与实际
230
+
231
+ - 预期: 待补充
232
+ - 实际: 待补充
233
+ """
234
+
235
+
236
+ def render_issue_analysis(
237
+ directory_name: str,
238
+ summary: str,
239
+ kind: str,
240
+ target_paths: list[str],
241
+ artifact_class: str = "product",
242
+ ) -> str:
243
+ owner = "前端 / Gemini" if kind == "frontend" else "后端 / Codex" if kind == "backend" else "待拆分"
244
+ return f"""---
245
+ doc_type: issue-analysis
246
+ artifact_class: {artifact_class}
247
+ issue: {directory_name}
248
+ status: draft
249
+ summary: {summary}
250
+ tags: []
251
+ ---
252
+
253
+ # {summary} 分析
254
+
255
+ ## 1. 根因
256
+
257
+ - 当前假设归属: {owner}
258
+ - 根因说明: 待补充
259
+
260
+ ## 2. 范围
261
+
262
+ {render_bullet_list(build_scope_lines(kind, target_paths), "", "待补充")}
263
+
264
+ ## 3. 修复方案
265
+
266
+ - 首选定点修复: 待补充
267
+ - 明确不采用的更大范围修复: 待补充
268
+ """
269
+
270
+
271
+ def render_issue_fix(
272
+ directory_name: str,
273
+ slug: str,
274
+ created_date: str,
275
+ kind: str,
276
+ target_paths: list[str],
277
+ artifact_class: str = "product",
278
+ ) -> str:
279
+ return render_issue_fix_steps(
280
+ directory_name,
281
+ created_date,
282
+ artifact_class,
283
+ [
284
+ {
285
+ "action": "执行一个定点问题修复步骤",
286
+ "exit_signal": "修复步骤已经可以进入委派执行",
287
+ "status": "pending",
288
+ "codecgc": {
289
+ "kind": kind,
290
+ "task_id": f"{slug}-fix-step-1",
291
+ "task_summary": "只执行当前已批准的问题修复步骤。",
292
+ "target_paths": target_paths or ["待补路径"],
293
+ "constraints": build_constraint_lines(kind),
294
+ "acceptance": build_acceptance_lines(kind, target_paths),
295
+ "cd": ".",
296
+ },
297
+ }
298
+ ],
299
+ )
300
+
301
+
302
+ def render_issue_fix_note(
303
+ directory_name: str,
304
+ summary: str,
305
+ fix_date: str,
306
+ artifact_class: str = "product",
307
+ ) -> str:
308
+ return f"""---
309
+ doc_type: issue-fix
310
+ artifact_class: {artifact_class}
311
+ issue: {directory_name}
312
+ path: standard
313
+ fix_date: {fix_date}
314
+ tags: []
315
+ ---
316
+
317
+ # {summary} 修复说明
318
+
319
+ ## 1. 已应用修复
320
+
321
+ 待补充
322
+
323
+ ## 2. 验证结果
324
+
325
+ 待补充
326
+
327
+ ## 3. 剩余风险
328
+
329
+ 待补充
330
+ """
331
+
332
+
333
+ def render_step_entry(step: dict[str, object]) -> str:
334
+ lines = [
335
+ f' - action: "{step["action"]}"',
336
+ f' exit_signal: "{step["exit_signal"]}"',
337
+ f' status: {step.get("status", "pending")}',
338
+ ]
339
+
340
+ owner_hint = str(step.get("owner_hint", "")).strip()
341
+ planning_note = str(step.get("planning_note", "")).strip()
342
+ if owner_hint:
343
+ lines.append(f" owner_hint: {owner_hint}")
344
+ if planning_note:
345
+ lines.append(f" planning_note: {planning_note}")
346
+
347
+ codecgc = step.get("codecgc")
348
+ if isinstance(codecgc, dict):
349
+ lines.append(" codecgc:")
350
+ lines.append(f" kind: {codecgc['kind']}")
351
+ if codecgc.get("step_type"):
352
+ lines.append(f" step_type: {codecgc['step_type']}")
353
+ lines.append(f" task_id: {codecgc['task_id']}")
354
+ lines.append(f' task_summary: "{codecgc["task_summary"]}"')
355
+ lines.append(" target_paths:")
356
+ lines.append(render_bullet_list(codecgc.get("target_paths", []), " ", "待补路径"))
357
+ lines.append(" constraints:")
358
+ lines.append(render_bullet_list(codecgc.get("constraints", []), " ", "待补充"))
359
+ lines.append(" acceptance:")
360
+ lines.append(render_bullet_list(codecgc.get("acceptance", []), " ", "返回结构化执行结果。"))
361
+ lines.append(f" cd: {codecgc.get('cd', '.')}")
362
+ return "\n".join(lines)
363
+
364
+
365
+ def render_feature_checklist_steps(
366
+ directory_name: str,
367
+ created_date: str,
368
+ artifact_class: str,
369
+ steps: list[dict[str, object]],
370
+ ) -> str:
371
+ rendered_steps = "\n".join(render_step_entry(step) for step in steps)
372
+ return f"""feature: {directory_name}
373
+ artifact_class: {artifact_class}
374
+ created: {created_date}
375
+
376
+ steps:
377
+ {rendered_steps}
378
+
379
+ checks:
380
+ - item: "共享或混合路径必须先拆分"
381
+ source: scope-guard
382
+ status: pending
383
+ - item: "一个执行器必须端到端负责这个执行步骤"
384
+ source: owner-guard
385
+ status: pending
386
+ """
387
+
388
+
389
+ def render_issue_fix_steps(
390
+ directory_name: str,
391
+ created_date: str,
392
+ artifact_class: str,
393
+ steps: list[dict[str, object]],
394
+ ) -> str:
395
+ rendered_steps = "\n".join(render_step_entry(step) for step in steps)
396
+ return f"""issue: {directory_name}
397
+ artifact_class: {artifact_class}
398
+ created: {created_date}
399
+
400
+ steps:
401
+ {rendered_steps}
402
+
403
+ checks:
404
+ - item: "混合或共享范围必须先拆分"
405
+ source: scope-guard
406
+ status: pending
407
+ - item: "一个执行器必须端到端负责这个执行步骤"
408
+ source: owner-guard
409
+ status: pending
410
+ """
411
+
412
+
413
+ def build_test_step(
414
+ *,
415
+ slug: str,
416
+ flow: str,
417
+ kind: str,
418
+ target_paths: list[str],
419
+ step_index: int,
420
+ ) -> dict[str, object]:
421
+ target_label = "前端" if kind == "frontend" else "后端" if kind == "backend" else "当前"
422
+ flow_label = "问题修复" if flow == "issue" else "功能开发"
423
+ return {
424
+ "action": f"执行一个{target_label}测试补充步骤",
425
+ "exit_signal": "测试步骤已可进入委派执行",
426
+ "status": "pending",
427
+ "codecgc": {
428
+ "kind": kind,
429
+ "step_type": "test",
430
+ "task_id": f"{slug}-test-step-{step_index}",
431
+ "task_summary": f"只补充当前已批准的{flow_label}{target_label}测试步骤。",
432
+ "target_paths": target_paths or ["待补路径"],
433
+ "constraints": build_test_constraint_lines(kind),
434
+ "acceptance": build_test_acceptance_lines(kind, target_paths),
435
+ "cd": ".",
436
+ },
437
+ }