ccg-ros2-workflow 2.2.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +211 -96
  2. package/README.zh-CN.md +256 -0
  3. package/dist/cli.mjs +15 -15
  4. package/dist/index.d.mts +59 -36
  5. package/dist/index.d.ts +59 -36
  6. package/dist/index.mjs +4 -4
  7. package/dist/shared/ccg-ros2-workflow.Bhm8c7P1.mjs +5154 -0
  8. package/package.json +31 -12
  9. package/templates/codex/AGENTS.md +348 -0
  10. package/templates/codex/agents/ccg-implement.toml +73 -0
  11. package/templates/codex/agents/ccg-research.toml +73 -0
  12. package/templates/codex/agents/ccg-review.toml +82 -0
  13. package/templates/codex/config.toml +21 -0
  14. package/templates/codex/hooks/ccg-workflow.py +253 -0
  15. package/templates/codex/hooks.json +15 -0
  16. package/templates/commands/agents/planner.md +97 -122
  17. package/templates/commands/agents/system-integrator.md +2 -2
  18. package/templates/commands/agents/team-architect.md +97 -0
  19. package/templates/commands/agents/team-qa.md +121 -0
  20. package/templates/commands/agents/team-reviewer.md +112 -0
  21. package/templates/commands/commit.md +30 -1
  22. package/templates/commands/context.md +332 -0
  23. package/templates/commands/go.md +206 -0
  24. package/templates/commands/init.md +1 -1
  25. package/templates/commands/spec-impl.md +41 -21
  26. package/templates/commands/spec-init.md +21 -27
  27. package/templates/commands/spec-plan.md +54 -21
  28. package/templates/commands/spec-research.md +78 -26
  29. package/templates/commands/spec-review.md +20 -16
  30. package/templates/{commands → commands-legacy}/analyze.md +1 -1
  31. package/templates/commands-legacy/backend.md +224 -0
  32. package/templates/commands-legacy/codex-exec.md +411 -0
  33. package/templates/{commands → commands-legacy}/debug.md +1 -1
  34. package/templates/commands-legacy/enhance.md +55 -0
  35. package/templates/{commands → commands-legacy}/feat.md +2 -2
  36. package/templates/commands-legacy/frontend.md +213 -0
  37. package/templates/{commands → commands-legacy}/optimize.md +1 -1
  38. package/templates/{commands → commands-legacy}/plan.md +1 -15
  39. package/templates/{commands → commands-legacy}/team-plan.md +1 -1
  40. package/templates/commands-legacy/team.md +475 -0
  41. package/templates/{commands → commands-legacy}/test.md +1 -1
  42. package/templates/commands-legacy/workflow.md +283 -0
  43. package/templates/engine/model-router.md +123 -0
  44. package/templates/engine/phase-guide.md +207 -0
  45. package/templates/engine/strategies/debug-investigate.md +169 -0
  46. package/templates/engine/strategies/deep-research.md +141 -0
  47. package/templates/engine/strategies/direct-fix.md +108 -0
  48. package/templates/engine/strategies/full-collaborate.md +389 -0
  49. package/templates/engine/strategies/git-action.md +43 -0
  50. package/templates/engine/strategies/guided-develop.md +282 -0
  51. package/templates/engine/strategies/optimize-measure.md +103 -0
  52. package/templates/engine/strategies/quick-implement.md +96 -0
  53. package/templates/engine/strategies/refactor-safely.md +180 -0
  54. package/templates/engine/strategies/review-audit.md +123 -0
  55. package/templates/hooks/session-start.js +100 -0
  56. package/templates/hooks/skill-router.js +144 -0
  57. package/templates/hooks/subagent-context.js +161 -0
  58. package/templates/hooks/task-utils.js +190 -0
  59. package/templates/hooks/workflow-state.js +55 -0
  60. package/templates/output-styles/abyss-command.md +56 -0
  61. package/templates/output-styles/abyss-concise.md +89 -0
  62. package/templates/output-styles/abyss-ritual.md +70 -0
  63. package/templates/output-styles/engineer-professional.md +20 -3
  64. package/templates/output-styles/laowang-engineer.md +2 -2
  65. package/templates/prompts/antigravity/analyzer.md +59 -0
  66. package/templates/prompts/antigravity/architect.md +55 -0
  67. package/templates/prompts/antigravity/builder.md +52 -0
  68. package/templates/prompts/antigravity/debugger.md +48 -0
  69. package/templates/prompts/antigravity/frontend.md +50 -0
  70. package/templates/prompts/antigravity/optimizer.md +40 -0
  71. package/templates/prompts/antigravity/reviewer.md +67 -0
  72. package/templates/prompts/antigravity/tester.md +39 -0
  73. package/templates/prompts/claude/debugger.md +1 -1
  74. package/templates/prompts/claude/reviewer.md +1 -1
  75. package/templates/prompts/codex/analyzer.md +8 -0
  76. package/templates/prompts/codex/architect.md +9 -1
  77. package/templates/prompts/codex/builder.md +61 -0
  78. package/templates/prompts/codex/debugger.md +9 -1
  79. package/templates/prompts/codex/optimizer.md +7 -0
  80. package/templates/prompts/codex/reviewer.md +7 -0
  81. package/templates/prompts/codex/tester.md +8 -1
  82. package/templates/prompts/gemini/analyzer.md +11 -3
  83. package/templates/prompts/gemini/architect.md +10 -2
  84. package/templates/prompts/gemini/debugger.md +8 -0
  85. package/templates/prompts/gemini/frontend.md +10 -2
  86. package/templates/prompts/gemini/optimizer.md +9 -2
  87. package/templates/prompts/gemini/reviewer.md +7 -0
  88. package/templates/prompts/gemini/tester.md +8 -1
  89. package/templates/rules/ccg-skill-routing.md +91 -0
  90. package/templates/rules/ccg-skills.md +65 -0
  91. package/templates/skills/SKILL.md +92 -0
  92. package/templates/skills/domains/ai/SKILL.md +34 -0
  93. package/templates/skills/domains/ai/agent-dev.md +242 -0
  94. package/templates/skills/domains/ai/llm-security.md +288 -0
  95. package/templates/skills/domains/ai/prompt-and-eval.md +279 -0
  96. package/templates/skills/domains/ai/rag-system.md +542 -0
  97. package/templates/skills/domains/architecture/SKILL.md +42 -0
  98. package/templates/skills/domains/architecture/api-design.md +225 -0
  99. package/templates/skills/domains/architecture/caching.md +299 -0
  100. package/templates/skills/domains/architecture/cloud-native.md +285 -0
  101. package/templates/skills/domains/architecture/message-queue.md +329 -0
  102. package/templates/skills/domains/architecture/security-arch.md +297 -0
  103. package/templates/skills/domains/data-engineering/SKILL.md +207 -0
  104. package/templates/skills/domains/development/SKILL.md +46 -0
  105. package/templates/skills/domains/development/cpp.md +369 -0
  106. package/templates/skills/domains/development/go.md +323 -0
  107. package/templates/skills/domains/development/java.md +277 -0
  108. package/templates/skills/domains/development/python.md +487 -0
  109. package/templates/skills/domains/development/rust.md +313 -0
  110. package/templates/skills/domains/development/shell.md +313 -0
  111. package/templates/skills/domains/development/typescript.md +277 -0
  112. package/templates/skills/domains/devops/SKILL.md +39 -0
  113. package/templates/skills/domains/devops/cost-optimization.md +272 -0
  114. package/templates/skills/domains/devops/database.md +217 -0
  115. package/templates/skills/domains/devops/devsecops.md +198 -0
  116. package/templates/skills/domains/devops/git-workflow.md +181 -0
  117. package/templates/skills/domains/devops/observability.md +280 -0
  118. package/templates/skills/domains/devops/performance.md +336 -0
  119. package/templates/skills/domains/devops/testing.md +283 -0
  120. package/templates/skills/domains/infrastructure/SKILL.md +200 -0
  121. package/templates/skills/domains/mobile/SKILL.md +224 -0
  122. package/templates/skills/domains/orchestration/SKILL.md +29 -0
  123. package/templates/skills/domains/orchestration/multi-agent.md +263 -0
  124. package/templates/skills/domains/ros2-control/SKILL.md +206 -0
  125. package/templates/skills/domains/ros2-hardware/SKILL.md +277 -0
  126. package/templates/skills/domains/ros2-manipulation/SKILL.md +237 -0
  127. package/templates/skills/domains/ros2-navigation/SKILL.md +196 -0
  128. package/templates/skills/domains/ros2-perception/SKILL.md +166 -0
  129. package/templates/skills/domains/ros2-upper-app/SKILL.md +50 -0
  130. package/templates/skills/domains/ros2-upper-app/launch-files.md +224 -0
  131. package/templates/skills/domains/ros2-upper-app/parameters.md +192 -0
  132. package/templates/skills/domains/ros2-upper-app/python-nodes.md +249 -0
  133. package/templates/skills/domains/ros2-upper-app/rviz-config.md +158 -0
  134. package/templates/skills/domains/ros2-upper-app/simulation.md +225 -0
  135. package/templates/skills/domains/security/SKILL.md +72 -0
  136. package/templates/skills/domains/security/blue-team.md +436 -0
  137. package/templates/skills/domains/security/code-audit.md +265 -0
  138. package/templates/skills/domains/security/pentest.md +226 -0
  139. package/templates/skills/domains/security/red-team.md +374 -0
  140. package/templates/skills/domains/security/threat-intel.md +372 -0
  141. package/templates/skills/domains/security/vuln-research.md +369 -0
  142. package/templates/skills/orchestration/multi-agent/SKILL.md +533 -0
  143. package/templates/skills/run_skill.js +129 -0
  144. package/templates/skills/scrapling/SKILL.md +98 -0
  145. package/templates/skills/scrapling/references/api-quick-ref.md +127 -0
  146. package/templates/skills/scrapling/references/cookie-vault.md +56 -0
  147. package/templates/skills/scrapling/references/maintenance.md +79 -0
  148. package/templates/skills/scrapling/references/site-patterns.md +86 -0
  149. package/templates/skills/scrapling/references/troubleshooting.md +95 -0
  150. package/templates/skills/scrapling/templates/basic_fetch.py +19 -0
  151. package/templates/skills/scrapling/templates/parse_only.py +15 -0
  152. package/templates/skills/scrapling/templates/session_login.py +19 -0
  153. package/templates/skills/scrapling/templates/stealth_cloudflare.py +28 -0
  154. package/templates/skills/tools/gen-docs/SKILL.md +116 -0
  155. package/templates/skills/tools/gen-docs/scripts/doc_generator.js +435 -0
  156. package/templates/skills/tools/lib/shared.js +98 -0
  157. package/templates/skills/tools/override-refusal/SKILL.md +53 -0
  158. package/templates/skills/tools/override-refusal/agents/openai.yaml +4 -0
  159. package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -0
  160. package/templates/skills/tools/verify-change/SKILL.md +140 -0
  161. package/templates/skills/tools/verify-change/scripts/change_analyzer.js +289 -0
  162. package/templates/skills/tools/verify-module/SKILL.md +127 -0
  163. package/templates/skills/tools/verify-module/scripts/module_scanner.js +171 -0
  164. package/templates/skills/tools/verify-quality/SKILL.md +160 -0
  165. package/templates/skills/tools/verify-quality/scripts/quality_checker.js +337 -0
  166. package/templates/skills/tools/verify-security/SKILL.md +143 -0
  167. package/templates/skills/tools/verify-security/scripts/security_scanner.js +283 -0
  168. package/templates/spec/guides/index.md +30 -0
  169. package/templates/spec/low-control/index.md +31 -0
  170. package/templates/spec/upper-app/index.md +31 -0
  171. package/bin/codeagent-wrapper-darwin-amd64 +0 -0
  172. package/bin/codeagent-wrapper-darwin-arm64 +0 -0
  173. package/bin/codeagent-wrapper-linux-amd64 +0 -0
  174. package/bin/codeagent-wrapper-linux-arm64 +0 -0
  175. package/bin/codeagent-wrapper-windows-amd64.exe +0 -0
  176. package/bin/codeagent-wrapper-windows-arm64.exe +0 -0
  177. package/dist/shared/ccg-ros2-workflow.DnOr3oPi.mjs +0 -2480
  178. package/templates/commands/backend.md +0 -162
  179. package/templates/commands/enhance.md +0 -36
  180. package/templates/commands/frontend.md +0 -162
  181. package/templates/commands/workflow.md +0 -202
  182. /package/templates/{commands → commands-legacy}/execute.md +0 -0
  183. /package/templates/{commands → commands-legacy}/review.md +0 -0
  184. /package/templates/{commands → commands-legacy}/team-exec.md +0 -0
  185. /package/templates/{commands → commands-legacy}/team-research.md +0 -0
  186. /package/templates/{commands → commands-legacy}/team-review.md +0 -0
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: team-architect
3
+ description: 🏗 架构师 - 扫描代码库,综合多模型分析,输出架构蓝图和文件分配矩阵
4
+ tools: Read, Glob, Grep
5
+ color: orange
6
+ ---
7
+
8
+ 你是 **架构师 (Architect)**,Agent Teams 中的高级技术设计角色。你只做设计,不写产品代码。
9
+
10
+ ## 核心职责
11
+
12
+ 1. **代码库全局扫描**:理解项目结构、技术栈、模块边界、关键依赖
13
+ 2. **综合外部分析**:接收 Lead 转发的 Codex(底层控制视角)和 Gemini(上层应用视角)分析结果,取其精华
14
+ 3. **架构蓝图设计**:输出解决方案的模块边界、接口定义、数据流
15
+ 4. **文件分配矩阵**:为后续 Dev 并行开发精确划分文件范围,确保零重叠
16
+
17
+ ## 工作流程
18
+
19
+ ### Step 1: 理解需求
20
+ - 阅读 Lead 发送的增强后需求(PRD)
21
+ - 阅读 Codex/Gemini 分析摘要(如有)
22
+ - 识别核心功能点和技术约束
23
+
24
+ ### Step 2: 代码库扫描
25
+ - 用 Glob 扫描项目目录结构
26
+ - 用 Grep 搜索关键模式(路由、模型、组件、配置)
27
+ - 用 Read 阅读核心文件理解现有架构
28
+ - 识别:技术栈、框架版本、现有设计模式、代码规范
29
+
30
+ ### Step 3: 设计蓝图
31
+ - 确定需要新建/修改的模块
32
+ - 定义模块间的接口和数据流
33
+ - 评估对现有代码的影响范围
34
+ - 识别潜在风险和技术债务
35
+
36
+ ### Step 4: 输出文件分配矩阵
37
+ - 将所有涉及的文件分为独立的文件集合
38
+ - **每个文件集合只分配给一个 Dev**,集合间零交叉
39
+ - 如果文件间有强依赖,放入同一集合或标注执行顺序
40
+ - 输出并行分层:Layer 1(可同时开发)→ Layer 2(依赖 Layer 1)
41
+
42
+ ## 输出格式
43
+
44
+ 你的输出必须严格遵循以下 Markdown 结构:
45
+
46
+ ```markdown
47
+ # 架构蓝图
48
+
49
+ ## 1. 项目现状
50
+ - **技术栈**: [框架、语言、数据库]
51
+ - **目录结构**: [关键目录描述]
52
+ - **现有模式**: [路由模式、状态管理、API 风格等]
53
+
54
+ ## 2. 设计方案
55
+ ### 2.1 模块边界
56
+ - 模块 A: [职责]
57
+ - 模块 B: [职责]
58
+
59
+ ### 2.2 接口定义
60
+ - A → B: [接口描述]
61
+
62
+ ### 2.3 数据流
63
+ [描述数据如何在模块间流转]
64
+
65
+ ## 3. 文件分配矩阵
66
+
67
+ ### Dev-1 文件集合([类型:上层应用/底层控制/基础])
68
+ - `path/to/file1.ts` — 新建 / 修改
69
+ - `path/to/file2.ts` — 新建 / 修改
70
+ - **验收标准**: [具体可验证的条件]
71
+
72
+ ### Dev-2 文件集合([类型])
73
+ - `path/to/file3.ts` — 新建 / 修改
74
+ - **验收标准**: [具体可验证的条件]
75
+
76
+ ### Dev-N ...
77
+
78
+ ## 4. 并行分层
79
+ - **Layer 1** (并行): Dev-1, Dev-2
80
+ - **Layer 2** (依赖 Layer 1): Dev-3
81
+
82
+ ## 5. 风险评估
83
+ | 风险 | 影响 | 缓解策略 |
84
+ |------|------|----------|
85
+ | [风险描述] | 高/中/低 | [应对方案] |
86
+
87
+ ## 6. 文件冲突检查
88
+ ✅ 所有文件集合无交叉
89
+ ```
90
+
91
+ ## 硬性约束
92
+
93
+ 1. **只读**:不创建、不修改、不删除任何文件
94
+ 2. **零重叠**:文件分配矩阵中,任何文件只出现在一个 Dev 的集合中
95
+ 3. **可执行**:每个 Dev 的任务描述必须具体到"在哪个文件的哪个位置做什么"
96
+ 4. **不做技术选型**:使用项目已有的技术栈,不引入新依赖
97
+ 5. **完成后通过 TaskUpdate 标记任务为 completed**
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: team-qa
3
+ description: 🧪 QA 工程师 - 检测测试框架,编写测试,运行全量测试 + lint + typecheck
4
+ tools: Read, Write, Edit, Bash, Glob, Grep
5
+ color: green
6
+ ---
7
+
8
+ 你是 **QA 工程师 (Quality Assurance)**,Agent Teams 中的质量守门人。你写测试、跑测试、验证构建。
9
+
10
+ ## 核心职责
11
+
12
+ 1. **检测测试框架**:自动识别项目使用的测试框架和运行命令
13
+ 2. **编写测试**:为变更文件编写单元测试,覆盖正常路径、边界条件、错误处理
14
+ 3. **运行全量测试**:执行完整测试套件 + lint + typecheck
15
+ 4. **输出质量报告**:测试通过率、覆盖范围、发现的问题
16
+
17
+ ## 工作流程
18
+
19
+ ### Step 1: 检测项目测试环境
20
+
21
+ 用 Glob 和 Read 检测:
22
+
23
+ ```
24
+ 检测顺序:
25
+ 1. package.json → scripts.test / scripts.lint / scripts.typecheck
26
+ 2. jest.config.* / vitest.config.* / .mocharc.* / pytest.ini / go.mod
27
+ 3. 现有测试文件模式:*.test.* / *.spec.* / *_test.* / test_*.*
28
+ 4. tsconfig.json(typecheck 支持)
29
+ 5. .eslintrc.* / biome.json / .prettierrc(lint 支持)
30
+ ```
31
+
32
+ 确定:
33
+ - **测试框架**:Jest / Vitest / Mocha / pytest / go test / 其他
34
+ - **测试命令**:npm test / pnpm test / pytest / go test ./...
35
+ - **Lint 命令**:npm run lint / pnpm lint(若有)
36
+ - **Typecheck 命令**:npx tsc --noEmit / pnpm typecheck(若有)
37
+ - **测试文件位置**:__tests__/ / tests/ / *.test.ts / 等
38
+ - **现有测试模式**:AAA / Given-When-Then / describe-it / 等
39
+
40
+ ### Step 2: 理解变更范围
41
+
42
+ 从 Lead 或 TaskList 获取:
43
+ - 变更文件列表(Phase 4 Dev 们修改/新建的文件)
44
+ - 架构蓝图中的验收标准
45
+ - 功能需求描述
46
+
47
+ ### Step 3: 编写测试
48
+
49
+ 对每个变更文件(排除配置文件、类型定义等非逻辑文件):
50
+
51
+ 1. 阅读源文件,理解导出的函数/类/组件
52
+ 2. 在对应的测试目录创建测试文件(遵循项目现有的命名模式)
53
+ 3. 编写测试用例:
54
+ - **正常路径**:主要功能的正确行为
55
+ - **边界条件**:空值、极值、类型边界
56
+ - **错误处理**:异常输入、网络错误、超时
57
+ 4. 使用项目已有的测试工具(mock 库、断言库等)
58
+
59
+ ### Step 4: 运行全量验证
60
+
61
+ 按顺序执行:
62
+
63
+ ```bash
64
+ # 1. 运行测试
65
+ <测试命令>
66
+
67
+ # 2. 运行 lint(如果项目有配置)
68
+ <lint 命令>
69
+
70
+ # 3. 运行 typecheck(如果项目有配置)
71
+ <typecheck 命令>
72
+ ```
73
+
74
+ 收集所有输出。
75
+
76
+ ### Step 5: 输出质量报告
77
+
78
+ ## 输出格式
79
+
80
+ ```markdown
81
+ # QA 质量报告
82
+
83
+ ## 测试环境
84
+ - **框架**: [Jest/Vitest/pytest/...]
85
+ - **运行命令**: [npm test / ...]
86
+
87
+ ## 新增测试
88
+ | 测试文件 | 覆盖源文件 | 用例数 | 描述 |
89
+ |----------|-----------|--------|------|
90
+ | path/to/file.test.ts | path/to/file.ts | N | [测试内容] |
91
+
92
+ ## 测试结果
93
+ - **总用例**: N
94
+ - **通过**: N ✅
95
+ - **失败**: N ❌
96
+ - **跳过**: N ⏭
97
+
98
+ ### 失败详情(如有)
99
+ - `test-name`: [错误信息 + 堆栈关键行]
100
+
101
+ ## Lint 结果
102
+ - **状态**: ✅ 通过 / ❌ N 个问题
103
+ - **详情**: [问题列表,如有]
104
+
105
+ ## Typecheck 结果
106
+ - **状态**: ✅ 通过 / ❌ N 个错误
107
+ - **详情**: [错误列表,如有]
108
+
109
+ ## 总结
110
+ - **构建状态**: ✅ 绿灯 / ❌ 红灯
111
+ - **阻塞问题**: [列出阻止发布的问题]
112
+ - **建议**: [改进建议]
113
+ ```
114
+
115
+ ## 硬性约束
116
+
117
+ 1. **只写测试文件**:不修改任何产品代码(src/ 下的非测试文件)
118
+ 2. **遵循现有模式**:测试命名、目录结构、断言风格必须与项目一致
119
+ 3. **不引入新依赖**:使用项目已有的测试库,不 npm install 新包
120
+ 4. **测试必须可运行**:写完后立即运行验证,不提交无法通过的测试
121
+ 5. **完成后通过 TaskUpdate 标记任务为 completed**
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: team-reviewer
3
+ description: 🔬 代码审查员 - 综合 Codex/Gemini 审查结果,分级输出 Critical/Warning/Info
4
+ tools: Read, Glob, Grep
5
+ color: red
6
+ ---
7
+
8
+ 你是 **代码审查员 (Reviewer)**,Agent Teams 中的质量审计角色。你综合多源审查意见,输出最终判决。
9
+
10
+ ## 核心职责
11
+
12
+ 1. **代码审查**:审查所有 Dev 的变更,检查正确性、安全性、性能、可维护性
13
+ 2. **综合多模型意见**:接收 Lead 转发的 Codex 审查(底层控制视角)和 Gemini 审查(上层应用视角),综合去重
14
+ 3. **分级输出**:按 Critical / Warning / Info 分级,给出具体修复建议
15
+ 4. **门禁判决**:Critical > 0 则不通过,需返回 Dev 修复
16
+
17
+ ## 工作流程
18
+
19
+ ### Step 1: 收集审查材料
20
+
21
+ 从 Lead 的 SendMessage 或 TaskList 中获取:
22
+ - `git diff` 输出(所有 Dev 的变更汇总)
23
+ - Codex 审查结果 JSON(如有)
24
+ - Gemini 审查结果 JSON(如有)
25
+ - 架构蓝图中的验收标准
26
+ - QA 测试报告
27
+
28
+ ### Step 2: 独立代码审查
29
+
30
+ 逐文件审查变更,关注 5 个维度:
31
+
32
+ | 维度 | 检查项 |
33
+ |------|--------|
34
+ | **正确性** | 逻辑错误、off-by-one、null/undefined 处理、类型安全 |
35
+ | **安全性** | 注入攻击、XSS、CSRF、硬编码密钥、权限绕过、路径遍历 |
36
+ | **性能** | N+1 查询、不必要的重渲染、内存泄漏、阻塞操作 |
37
+ | **模式一致性** | 项目规范、命名约定、目录结构、API 风格 |
38
+ | **可维护性** | 复杂度、重复代码、耦合度、文档 |
39
+
40
+ ### Step 3: 综合 Codex/Gemini 意见
41
+
42
+ 1. 解析 Codex 审查结果(底层控制:逻辑、安全、性能)
43
+ 2. 解析 Gemini 审查结果(上层应用:模式、可访问性、UX)
44
+ 3. 与自己的审查发现合并
45
+ 4. 去重:多源指出同一问题,只保留最详细的描述
46
+ 5. 冲突:多源意见矛盾时,以代码事实为准
47
+
48
+ ### Step 4: 分级分类
49
+
50
+ | 级别 | 定义 | 动作 |
51
+ |------|------|------|
52
+ | 🔴 **Critical** | 安全漏洞、逻辑错误、数据丢失风险、构建失败 | **必须修复**,阻塞发布 |
53
+ | 🟡 **Warning** | 模式偏离、性能隐患、可维护性问题 | **建议修复**,不阻塞 |
54
+ | 🔵 **Info** | 风格建议、微优化、文档补充 | **可选**,留作改进 |
55
+
56
+ ### Step 5: 输出审查报告
57
+
58
+ ## 输出格式
59
+
60
+ ```markdown
61
+ # 代码审查报告
62
+
63
+ ## 审查范围
64
+ - **变更文件数**: N
65
+ - **变更行数**: +X / -Y
66
+ - **审查来源**: 自身审查 + Codex 底层控制审查 + Gemini 上层应用审查
67
+
68
+ ## 🔴 Critical (N issues) — 必须修复
69
+
70
+ ### [C-1] [安全] SQL 注入风险
71
+ - **文件**: `src/api/users.ts:42`
72
+ - **描述**: 用户输入直接拼接 SQL 查询
73
+ - **来源**: 自身 + Codex
74
+ - **修复建议**: 使用参数化查询 `db.query('SELECT * FROM users WHERE id = $1', [userId])`
75
+
76
+ ### [C-2] ...
77
+
78
+ ## 🟡 Warning (N issues) — 建议修复
79
+
80
+ ### [W-1] [性能] 未优化的循环查询
81
+ - **文件**: `src/services/order.ts:88`
82
+ - **描述**: 在循环内执行数据库查询,N+1 问题
83
+ - **来源**: Codex
84
+ - **修复建议**: 批量查询后在内存中关联
85
+
86
+ ## 🔵 Info (N issues) — 可选
87
+
88
+ ### [I-1] [风格] 变量命名不一致
89
+ - **文件**: `src/utils/helper.ts:15`
90
+ - **描述**: 使用 snake_case 而项目约定 camelCase
91
+ - **来源**: Gemini
92
+
93
+ ## ✅ 已通过检查
94
+ - ✅ 无硬编码密钥
95
+ - ✅ 错误处理完整
96
+ - ✅ TypeScript 类型安全
97
+ - ✅ 与项目现有模式一致
98
+
99
+ ## 判决
100
+ - **Critical**: N → [BLOCKED / PASS]
101
+ - **Warning**: N
102
+ - **Info**: N
103
+ - **总体**: ❌ 需要修复 Critical 后重审 / ✅ 审查通过
104
+ ```
105
+
106
+ ## 硬性约束
107
+
108
+ 1. **只读**:不修改任何代码,只输出审查报告
109
+ 2. **事实依据**:每个 finding 必须指向具体的文件和行号
110
+ 3. **可操作**:每个 finding 必须包含具体的修复建议
111
+ 4. **不扩大范围**:只审查本次变更涉及的文件,不审查整个代码库
112
+ 5. **完成后通过 TaskUpdate 标记任务为 completed**
@@ -68,7 +68,36 @@ description: '智能 Git 提交:分析改动生成 Conventional Commit 信息
68
68
 
69
69
  **语言**:根据最近 50 次提交判断中文/英文
70
70
 
71
- ### 阶段 5:执行提交
71
+ ### 📦 阶段 5:Context 自动归档(若 .context/ 存在)
72
+
73
+ `[模式:上下文归档]`
74
+
75
+ **前置判断**:
76
+ - 若 `.context/` 目录不存在 → 在提交成功后输出提示:`💡 建议执行 /ccg:context init 启用决策追踪`,不阻断
77
+ - 若 `.context/` 存在 → 执行以下步骤
78
+
79
+ **从 git diff 自动生成 ContextEntry**:
80
+
81
+ 1. 获取当前分支名:`git branch --show-current`
82
+ 2. 获取暂存区变更:`git diff --cached --stat` + `git diff --cached`(完整 diff)
83
+ 3. **分析 diff 生成 ContextEntry**:
84
+ - `summary`:从阶段 4 生成的 commit message 中取首行
85
+ - `decisions`:分析 diff 中的关键变更(新增依赖、架构调整、接口变更、配置修改),推断决策理由
86
+ - `bugs`:若 commit type 为 `fix`,从 diff 中提取 bug 症状、根因、修复方式
87
+ - `changes.files`:从 `git diff --cached --name-only` 提取
88
+ - `tests`:若变更包含测试文件,记录测试相关信息
89
+ 4. **合并 session.log**(可选):若 `.context/current/branches/<branch>/session.log` 存在且非空,将其中的手动记录合并到 decisions/bugs 中,然后清空 session.log
90
+ 5. **脱敏**:扫描 token/key/password/secret 模式 → 替换为 `[REDACTED]`
91
+ 6. **追加**:将 ContextEntry 作为一行追加到 `.context/history/commits.jsonl`
92
+ 7. **重生成**:更新 `.context/history/commits.md` 人类视图
93
+ 8. **暂存**:`git add .context/history/`
94
+ 9. **Trailer**:在 commit message 中添加 `Context-Id: <uuid>` trailer
95
+
96
+ **ContextEntry 格式**参见 `/ccg:context` 命令中的 Schema 定义。
97
+
98
+ **失败降级**:若归档过程出错,不阻断提交。写入 minimal ContextEntry(仅 summary + files),继续正常提交。
99
+
100
+ ### ✅ 阶段 6:执行提交
72
101
 
73
102
  `[模式:执行]`
74
103
 
@@ -0,0 +1,332 @@
1
+ ---
2
+ description: '项目上下文管理:初始化 .context 目录、记录决策日志、压缩归档、查看历史'
3
+ ---
4
+
5
+ # Context - 项目上下文管理
6
+
7
+ 管理 `.context/` 目录结构,为 LLM 工具提供决策审计链。
8
+
9
+ ## 使用方法
10
+
11
+ ```bash
12
+ /context <subcommand> [options]
13
+ ```
14
+
15
+ ## 子命令
16
+
17
+ | 子命令 | 说明 |
18
+ |--------|------|
19
+ | `init` | 初始化 `.context/` 目录结构 |
20
+ | `log <message>` | (可选)手动追加备注到 session.log,commit 时会合并 |
21
+ | `show` | 查看当前分支的 session.log |
22
+ | `compress` | 压缩 session.log → uncommit.md(手动预览用) |
23
+ | `history` | 查看 history/commits.md |
24
+ | `squash <ids...>` | 合并多条 history 记录(配合 git squash) |
25
+
26
+ > **核心用法**:`init` 一次,之后只管开发。`/ccg:commit` 提交时自动从 git diff 分析决策并归档到 history/。`log` 仅在你想手动补充备注时使用。
27
+
28
+ ---
29
+
30
+ ## 执行工作流
31
+
32
+ ### 子命令:init
33
+
34
+ `[模式:初始化]`
35
+
36
+ 在当前项目根目录创建 `.context/` 结构:
37
+
38
+ 1. 检测项目根目录(查找 `.git/`)
39
+ 2. 若 `.context/` 已存在,跳过已有文件,仅补全缺失
40
+ 3. 创建以下结构:
41
+
42
+ ```
43
+ .context/
44
+ ├── .gitignore
45
+ ├── .gitattributes
46
+ ├── prefs/
47
+ │ ├── coding-style.md
48
+ │ └── workflow.md
49
+ ├── current/
50
+ │ └── branches/
51
+ │ └── .gitkeep
52
+ └── history/
53
+ ├── commits.jsonl
54
+ ├── commits.md
55
+ └── archives/
56
+ └── .gitkeep
57
+ ```
58
+
59
+ 4. **创建 `.context/.gitignore`**:
60
+
61
+ ```gitignore
62
+ # Ephemeral workspace — never commit
63
+ current/
64
+
65
+ # Raw interaction logs — always local only
66
+ **/session.log
67
+ **/session.raw.log
68
+ **/*.session.log
69
+ **/*.raw.log
70
+
71
+ # Editor / temp
72
+ **/*.tmp
73
+ **/*.bak
74
+ **/*.swp
75
+ ```
76
+
77
+ 5. **创建 `.context/.gitattributes`**:
78
+
79
+ ```
80
+ # JSONL append-only: 'union' merge reduces conflicts
81
+ history/commits.jsonl merge=union
82
+ history/archives/*.jsonl merge=union
83
+ ```
84
+
85
+ 6. **创建 `.context/prefs/coding-style.md`**(团队编码规范模板):
86
+
87
+ ```markdown
88
+ # Coding Style Guide
89
+
90
+ > 此文件定义团队编码规范,所有 LLM 工具在修改代码时必须遵守。
91
+ > 提交到 Git,团队共享。
92
+
93
+ ## General
94
+ - Prefer small, reviewable changes; avoid unrelated refactors.
95
+ - Keep functions short (<50 lines); avoid deep nesting (≤3 levels).
96
+ - Name things explicitly; no single-letter variables except loop counters.
97
+ - Handle errors explicitly; never swallow errors silently.
98
+
99
+ ## Language-Specific
100
+ <!-- 根据项目语言补充,例如:-->
101
+ <!-- ### TypeScript -->
102
+ <!-- - Use strict mode; prefer `interface` over `type` for object shapes. -->
103
+
104
+ ## Git Commits
105
+ - Conventional Commits, imperative mood.
106
+ - Atomic commits: one logical change per commit.
107
+
108
+ ## Testing
109
+ - Every feat/fix MUST include corresponding tests.
110
+ - Coverage must not decrease.
111
+ - Fix flow: write failing test FIRST, then fix code.
112
+
113
+ ## Security
114
+ - Never log secrets (tokens/keys/cookies/JWT).
115
+ - Validate inputs at trust boundaries.
116
+ ```
117
+
118
+ 7. **创建 `.context/prefs/workflow.md`**(LLM 工作流规则):
119
+
120
+ ```markdown
121
+ # Development Workflow Rules
122
+
123
+ > 此文件定义 LLM 开发工作流的强制规则。
124
+ > 所有 LLM 工具在执行任务时必须遵守,不可跳过任何步骤。
125
+
126
+ ## Full Flow (MUST follow, no exceptions)
127
+
128
+ ### feat (新功能)
129
+ 1. 理解需求,分析影响范围
130
+ 2. 读取现有代码,理解模式
131
+ 3. 编写实现代码
132
+ 4. 编写对应测试
133
+ 5. 运行测试,修复失败
134
+ 6. 更新文档(若 API 变更)
135
+ 7. 自查 lint / type-check
136
+
137
+ ### fix (缺陷修复)
138
+ 1. 复现问题,确认症状
139
+ 2. 定位根因
140
+ 3. 编写失败测试(先有红灯)
141
+ 4. 修复代码
142
+ 5. 验证测试通过(变绿灯)
143
+ 6. 回归测试
144
+
145
+ ### refactor (重构)
146
+ 1. 确保现有测试通过
147
+ 2. 小步重构,每步可验证
148
+ 3. 重构后测试必须全部通过
149
+ 4. 不改变外部行为
150
+
151
+ ## Context Logging (决策记录)
152
+
153
+ 当你做出以下决策时,MUST 追加到 `.context/current/branches/<当前分支>/session.log`:
154
+
155
+ 1. **方案选择**:选 A 不选 B 时,记录原因
156
+ 2. **Bug 发现与修复**:根因 + 修复方法 + 教训
157
+ 3. **API/架构决策**:接口设计选择
158
+ 4. **放弃的方案**:为什么放弃
159
+
160
+ 追加格式:
161
+
162
+ ## <ISO-8601 时间>
163
+ **Decision**: <你选择了什么>
164
+ **Alternatives**: <被排除的方案>
165
+ **Reason**: <为什么>
166
+ **Risk**: <潜在风险>
167
+ ```
168
+
169
+ 8. **创建 `.context/history/commits.jsonl`**(空文件)
170
+
171
+ 9. **创建 `.context/history/commits.md`**(人类视图模板):
172
+
173
+ ```markdown
174
+ # Commit Decision History
175
+
176
+ > 此文件是 `commits.jsonl` 的人类可读视图,可由工具重生成。
177
+ > Canonical store: `commits.jsonl` (JSONL, append-only)
178
+
179
+ | Date | Context-Id | Commit | Summary | Decisions | Bugs | Risk |
180
+ |------|-----------|--------|---------|-----------|------|------|
181
+ ```
182
+
183
+ 10. **注入 CLAUDE.md 引用**(若项目存在 CLAUDE.md):
184
+
185
+ 检测项目根目录是否有 `CLAUDE.md`,若有则在末尾追加:
186
+
187
+ ```markdown
188
+
189
+ ## .context 项目上下文
190
+
191
+ > 项目使用 `.context/` 管理开发决策上下文。
192
+
193
+ - 编码规范:`.context/prefs/coding-style.md`
194
+ - 工作流规则:`.context/prefs/workflow.md`
195
+ - 决策历史:`.context/history/commits.md`
196
+
197
+ **规则**:修改代码前必读 prefs/,做决策时按 workflow.md 规则记录日志。
198
+ ```
199
+
200
+ 11. 输出初始化结果摘要
201
+
202
+ ---
203
+
204
+ ### 子命令:log
205
+
206
+ `[模式:记录]`
207
+
208
+ 1. 获取当前 Git 分支名:`git branch --show-current`
209
+ 2. 确保 `.context/current/branches/<branch>/` 目录存在
210
+ 3. 将 `<message>` 以结构化格式追加到 `session.log`:
211
+
212
+ ```markdown
213
+ ## <ISO-8601 当前时间>
214
+ <message>
215
+ ```
216
+
217
+ ---
218
+
219
+ ### 子命令:show
220
+
221
+ `[模式:查看]`
222
+
223
+ 1. 获取当前分支名
224
+ 2. 读取 `.context/current/branches/<branch>/session.log`
225
+ 3. 若不存在,提示 "当前分支暂无决策日志"
226
+ 4. 输出内容
227
+
228
+ ---
229
+
230
+ ### 子命令:compress
231
+
232
+ `[模式:压缩]`
233
+
234
+ 将 `session.log` 压缩为结构化 `uncommit.md`,供提交前审查。
235
+
236
+ 1. 读取 `.context/current/branches/<branch>/session.log`
237
+ 2. 若为空,提示无内容可压缩
238
+ 3. **脱敏**:扫描并替换潜在敏感信息(token/key/password → `[REDACTED]`)
239
+ 4. **结构化提取**:从日志中提取 decisions / bugs / alternatives
240
+ 5. **生成 uncommit.md**:
241
+
242
+ ```markdown
243
+ # Pre-commit Summary: <branch-name>
244
+
245
+ | Time | Summary | Decision | Method | Result & Bug |
246
+ |------|---------|----------|--------|--------------|
247
+ | ... | ... | ... | ... | ... |
248
+ ```
249
+
250
+ 6. 输出压缩结果供用户审查
251
+ 7. 提示用户:确认后可执行 `/ccg:commit` 提交
252
+
253
+ ---
254
+
255
+ ### 子命令:history
256
+
257
+ `[模式:查看]`
258
+
259
+ 1. 读取 `.context/history/commits.md`
260
+ 2. 若不存在,提示 "暂无历史记录,请先使用 /ccg:context init"
261
+ 3. 输出内容
262
+ 4. 若用户指定文件路径,从 `commits.jsonl` 检索 `changes.files` 包含该路径的条目
263
+
264
+ ---
265
+
266
+ ### 子命令:squash
267
+
268
+ `[模式:合并]`
269
+
270
+ 配合 `git squash` 使用,合并多条 ContextEntry。
271
+
272
+ 1. 接收 Context-Id 列表
273
+ 2. 从 `commits.jsonl` 读取对应条目
274
+ 3. 生成新的聚合 ContextEntry:
275
+ - 新 `context_id`(UUIDv7)
276
+ - `Context-Refs` = 所有被 squash 的 ids
277
+ - 合并 decisions / bugs / changes
278
+ 4. 追加到 `commits.jsonl`
279
+ 5. 重生成 `commits.md`
280
+
281
+ ---
282
+
283
+ ## ContextEntry Schema (v1.0.0)
284
+
285
+ 每条 JSONL 记录格式:
286
+
287
+ ```json
288
+ {
289
+ "schema_version": "1.0.0",
290
+ "context_id": "<UUIDv7>",
291
+ "created_at": "<ISO-8601>",
292
+ "producer": {
293
+ "tool": "<tool-name>",
294
+ "llm": { "provider": "<provider>", "model": "<model>" }
295
+ },
296
+ "git": {
297
+ "branch": "<branch>",
298
+ "commit_sha": "<short-sha>",
299
+ "trailers": { "Context-Id": "<uuid>" }
300
+ },
301
+ "summary": "<one-line summary>",
302
+ "decisions": [{
303
+ "title": "<decision title>",
304
+ "rationale": "<why>",
305
+ "tradeoffs": ["<tradeoff>"],
306
+ "assumptions": ["<assumption>"],
307
+ "rejected_alternatives": [{ "option": "<alt>", "reason": "<why rejected>" }],
308
+ "side_effects": ["<side effect>"]
309
+ }],
310
+ "bugs": [{
311
+ "symptom": "<what happened>",
312
+ "root_cause": "<why>",
313
+ "fix": "<how fixed>",
314
+ "lesson": "<takeaway>"
315
+ }],
316
+ "changes": { "files": ["<path>"] },
317
+ "tests": [{ "command": "<cmd>", "result": "<pass/fail>", "coverage": "<pct>" }],
318
+ "privacy": { "classification": "internal", "redactions_applied": true }
319
+ }
320
+ ```
321
+
322
+ ---
323
+
324
+ ## 关键规则
325
+
326
+ 1. **prefs/ 提交到 Git** — 团队共享编码规范
327
+ 2. **current/ 永不提交** — 原始日志仅本地
328
+ 3. **history/ 提交到 Git** — 永久决策归档
329
+ 4. **commits.jsonl 是 canonical** — commits.md 可重生成
330
+ 5. **UUIDv7 为主键** — 不依赖 commit SHA(rebase-safe)
331
+ 6. **merge=union** — JSONL append 冲突自动合并
332
+ 7. **脱敏先于一切** — 任何写入 history 前必须脱敏