ccgx-workflow 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +469 -0
  3. package/README.zh-CN.md +466 -0
  4. package/bin/ccg.mjs +2 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/cli.mjs +173 -0
  8. package/dist/index.d.mts +1774 -0
  9. package/dist/index.d.ts +1774 -0
  10. package/dist/index.mjs +2029 -0
  11. package/dist/shared/ccgx-workflow.WgUzkiC3.mjs +5248 -0
  12. package/package.json +129 -0
  13. package/templates/commands/agents/assumptions-analyzer.md +129 -0
  14. package/templates/commands/agents/code-fixer.md +292 -0
  15. package/templates/commands/agents/codebase-mapper.md +152 -0
  16. package/templates/commands/agents/debug-session-manager.md +247 -0
  17. package/templates/commands/agents/debugger.md +111 -0
  18. package/templates/commands/agents/eval-auditor.md +171 -0
  19. package/templates/commands/agents/framework-selector.md +152 -0
  20. package/templates/commands/agents/get-current-datetime.md +29 -0
  21. package/templates/commands/agents/init-architect.md +114 -0
  22. package/templates/commands/agents/integration-checker.md +163 -0
  23. package/templates/commands/agents/interface-auditor.md +170 -0
  24. package/templates/commands/agents/nyquist-auditor.md +131 -0
  25. package/templates/commands/agents/pattern-mapper.md +111 -0
  26. package/templates/commands/agents/phase-runner.md +321 -0
  27. package/templates/commands/agents/plan-checker.md +255 -0
  28. package/templates/commands/agents/planner.md +320 -0
  29. package/templates/commands/agents/team-architect.md +186 -0
  30. package/templates/commands/agents/team-qa.md +121 -0
  31. package/templates/commands/agents/team-reviewer.md +157 -0
  32. package/templates/commands/agents/ui-ux-designer.md +573 -0
  33. package/templates/commands/agents/verifier.md +274 -0
  34. package/templates/commands/analyze.md +210 -0
  35. package/templates/commands/autonomous.md +792 -0
  36. package/templates/commands/cancel.md +132 -0
  37. package/templates/commands/clean-branches.md +117 -0
  38. package/templates/commands/codex-exec.md +404 -0
  39. package/templates/commands/commit.md +151 -0
  40. package/templates/commands/context.md +332 -0
  41. package/templates/commands/debate.md +165 -0
  42. package/templates/commands/debug.md +226 -0
  43. package/templates/commands/enhance.md +64 -0
  44. package/templates/commands/execute.md +380 -0
  45. package/templates/commands/init.md +123 -0
  46. package/templates/commands/optimize.md +217 -0
  47. package/templates/commands/plan.md +373 -0
  48. package/templates/commands/result.md +106 -0
  49. package/templates/commands/review.md +338 -0
  50. package/templates/commands/rollback.md +116 -0
  51. package/templates/commands/spec-impl.md +139 -0
  52. package/templates/commands/spec-init.md +101 -0
  53. package/templates/commands/spec-plan.md +210 -0
  54. package/templates/commands/spec-research.md +152 -0
  55. package/templates/commands/spec-review.md +120 -0
  56. package/templates/commands/status.md +206 -0
  57. package/templates/commands/team-exec.md +265 -0
  58. package/templates/commands/test.md +236 -0
  59. package/templates/commands/verify-work.md +338 -0
  60. package/templates/commands/verify.md +66 -0
  61. package/templates/commands/workflow.md +190 -0
  62. package/templates/commands/worktree.md +128 -0
  63. package/templates/hooks/ccg-context-monitor.js +159 -0
  64. package/templates/hooks/ccg-session-state.cjs +510 -0
  65. package/templates/hooks/ccg-statusline.js +142 -0
  66. package/templates/output-styles/abyss-command.md +56 -0
  67. package/templates/output-styles/abyss-concise.md +89 -0
  68. package/templates/output-styles/abyss-cultivator.md +302 -0
  69. package/templates/output-styles/abyss-ritual.md +70 -0
  70. package/templates/output-styles/engineer-professional.md +89 -0
  71. package/templates/output-styles/laowang-engineer.md +127 -0
  72. package/templates/output-styles/nekomata-engineer.md +120 -0
  73. package/templates/output-styles/ojousama-engineer.md +121 -0
  74. package/templates/prompts/claude/analyzer.md +59 -0
  75. package/templates/prompts/claude/architect.md +54 -0
  76. package/templates/prompts/claude/debugger.md +71 -0
  77. package/templates/prompts/claude/optimizer.md +73 -0
  78. package/templates/prompts/claude/reviewer.md +63 -0
  79. package/templates/prompts/claude/tester.md +69 -0
  80. package/templates/prompts/codex/analyzer.md +58 -0
  81. package/templates/prompts/codex/architect.md +54 -0
  82. package/templates/prompts/codex/debugger.md +74 -0
  83. package/templates/prompts/codex/optimizer.md +81 -0
  84. package/templates/prompts/codex/reviewer.md +73 -0
  85. package/templates/prompts/codex/tester.md +62 -0
  86. package/templates/prompts/gemini/analyzer.md +61 -0
  87. package/templates/prompts/gemini/architect.md +55 -0
  88. package/templates/prompts/gemini/debugger.md +78 -0
  89. package/templates/prompts/gemini/frontend.md +64 -0
  90. package/templates/prompts/gemini/optimizer.md +84 -0
  91. package/templates/prompts/gemini/reviewer.md +80 -0
  92. package/templates/prompts/gemini/tester.md +68 -0
  93. package/templates/rules/ccg-skill-routing.md +83 -0
  94. package/templates/rules/ccg-skills.md +71 -0
  95. package/templates/scripts/ccg-phase-runner-launcher.mjs +467 -0
  96. package/templates/scripts/invoke-model.mjs +949 -0
  97. package/templates/scripts/repatch-gemini-plugin.mjs +194 -0
  98. package/templates/skills/SKILL.md +92 -0
  99. package/templates/skills/domains/ai/SKILL.md +35 -0
  100. package/templates/skills/domains/ai/agent-dev.md +242 -0
  101. package/templates/skills/domains/ai/llm-security.md +288 -0
  102. package/templates/skills/domains/ai/prompt-and-eval.md +279 -0
  103. package/templates/skills/domains/ai/rag-system.md +542 -0
  104. package/templates/skills/domains/architecture/SKILL.md +43 -0
  105. package/templates/skills/domains/architecture/api-design.md +225 -0
  106. package/templates/skills/domains/architecture/caching.md +299 -0
  107. package/templates/skills/domains/architecture/cloud-native.md +285 -0
  108. package/templates/skills/domains/architecture/message-queue.md +329 -0
  109. package/templates/skills/domains/architecture/security-arch.md +297 -0
  110. package/templates/skills/domains/data-engineering/SKILL.md +208 -0
  111. package/templates/skills/domains/development/SKILL.md +47 -0
  112. package/templates/skills/domains/development/cpp.md +246 -0
  113. package/templates/skills/domains/development/go.md +323 -0
  114. package/templates/skills/domains/development/java.md +277 -0
  115. package/templates/skills/domains/development/python.md +288 -0
  116. package/templates/skills/domains/development/rust.md +313 -0
  117. package/templates/skills/domains/development/shell.md +313 -0
  118. package/templates/skills/domains/development/typescript.md +277 -0
  119. package/templates/skills/domains/devops/SKILL.md +40 -0
  120. package/templates/skills/domains/devops/cost-optimization.md +272 -0
  121. package/templates/skills/domains/devops/database.md +217 -0
  122. package/templates/skills/domains/devops/devsecops.md +198 -0
  123. package/templates/skills/domains/devops/git-workflow.md +181 -0
  124. package/templates/skills/domains/devops/observability.md +280 -0
  125. package/templates/skills/domains/devops/performance.md +336 -0
  126. package/templates/skills/domains/devops/testing.md +283 -0
  127. package/templates/skills/domains/frontend-design/SKILL.md +244 -0
  128. package/templates/skills/domains/frontend-design/agents/openai.yaml +4 -0
  129. package/templates/skills/domains/frontend-design/claymorphism/SKILL.md +121 -0
  130. package/templates/skills/domains/frontend-design/claymorphism/references/tokens.css +52 -0
  131. package/templates/skills/domains/frontend-design/component-patterns.md +202 -0
  132. package/templates/skills/domains/frontend-design/engineering.md +287 -0
  133. package/templates/skills/domains/frontend-design/glassmorphism/SKILL.md +142 -0
  134. package/templates/skills/domains/frontend-design/glassmorphism/references/tokens.css +32 -0
  135. package/templates/skills/domains/frontend-design/liquid-glass/SKILL.md +139 -0
  136. package/templates/skills/domains/frontend-design/liquid-glass/references/tokens.css +81 -0
  137. package/templates/skills/domains/frontend-design/neubrutalism/SKILL.md +145 -0
  138. package/templates/skills/domains/frontend-design/neubrutalism/references/tokens.css +44 -0
  139. package/templates/skills/domains/frontend-design/reference/color-and-contrast.md +132 -0
  140. package/templates/skills/domains/frontend-design/reference/interaction-design.md +195 -0
  141. package/templates/skills/domains/frontend-design/reference/motion-design.md +99 -0
  142. package/templates/skills/domains/frontend-design/reference/responsive-design.md +114 -0
  143. package/templates/skills/domains/frontend-design/reference/spatial-design.md +100 -0
  144. package/templates/skills/domains/frontend-design/reference/typography.md +133 -0
  145. package/templates/skills/domains/frontend-design/reference/ux-writing.md +107 -0
  146. package/templates/skills/domains/frontend-design/state-management.md +680 -0
  147. package/templates/skills/domains/frontend-design/ui-aesthetics.md +110 -0
  148. package/templates/skills/domains/frontend-design/ux-principles.md +156 -0
  149. package/templates/skills/domains/infrastructure/SKILL.md +201 -0
  150. package/templates/skills/domains/mobile/SKILL.md +225 -0
  151. package/templates/skills/domains/orchestration/SKILL.md +30 -0
  152. package/templates/skills/domains/orchestration/multi-agent.md +263 -0
  153. package/templates/skills/domains/security/SKILL.md +73 -0
  154. package/templates/skills/domains/security/blue-team.md +436 -0
  155. package/templates/skills/domains/security/code-audit.md +265 -0
  156. package/templates/skills/domains/security/pentest.md +226 -0
  157. package/templates/skills/domains/security/red-team.md +374 -0
  158. package/templates/skills/domains/security/threat-intel.md +372 -0
  159. package/templates/skills/domains/security/vuln-research.md +369 -0
  160. package/templates/skills/impeccable/adapt/SKILL.md +201 -0
  161. package/templates/skills/impeccable/animate/SKILL.md +176 -0
  162. package/templates/skills/impeccable/arrange/SKILL.md +126 -0
  163. package/templates/skills/impeccable/audit/SKILL.md +149 -0
  164. package/templates/skills/impeccable/bolder/SKILL.md +118 -0
  165. package/templates/skills/impeccable/clarify/SKILL.md +185 -0
  166. package/templates/skills/impeccable/colorize/SKILL.md +144 -0
  167. package/templates/skills/impeccable/critique/SKILL.md +203 -0
  168. package/templates/skills/impeccable/critique/reference/cognitive-load.md +106 -0
  169. package/templates/skills/impeccable/critique/reference/heuristics-scoring.md +234 -0
  170. package/templates/skills/impeccable/critique/reference/personas.md +178 -0
  171. package/templates/skills/impeccable/delight/SKILL.md +305 -0
  172. package/templates/skills/impeccable/distill/SKILL.md +123 -0
  173. package/templates/skills/impeccable/extract/SKILL.md +94 -0
  174. package/templates/skills/impeccable/harden/SKILL.md +357 -0
  175. package/templates/skills/impeccable/normalize/SKILL.md +72 -0
  176. package/templates/skills/impeccable/onboard/SKILL.md +248 -0
  177. package/templates/skills/impeccable/optimize/SKILL.md +268 -0
  178. package/templates/skills/impeccable/overdrive/SKILL.md +143 -0
  179. package/templates/skills/impeccable/polish/SKILL.md +205 -0
  180. package/templates/skills/impeccable/quieter/SKILL.md +104 -0
  181. package/templates/skills/impeccable/teach-impeccable/SKILL.md +72 -0
  182. package/templates/skills/impeccable/typeset/SKILL.md +117 -0
  183. package/templates/skills/orchestration/multi-agent/SKILL.md +533 -0
  184. package/templates/skills/run_skill.js +129 -0
  185. package/templates/skills/scrapling/SKILL.md +98 -0
  186. package/templates/skills/scrapling/references/api-quick-ref.md +127 -0
  187. package/templates/skills/scrapling/references/cookie-vault.md +56 -0
  188. package/templates/skills/scrapling/references/maintenance.md +79 -0
  189. package/templates/skills/scrapling/references/site-patterns.md +86 -0
  190. package/templates/skills/scrapling/references/troubleshooting.md +95 -0
  191. package/templates/skills/scrapling/templates/basic_fetch.py +19 -0
  192. package/templates/skills/scrapling/templates/parse_only.py +15 -0
  193. package/templates/skills/scrapling/templates/session_login.py +19 -0
  194. package/templates/skills/scrapling/templates/stealth_cloudflare.py +28 -0
  195. package/templates/skills/tools/extract-learnings/SKILL.md +77 -0
  196. package/templates/skills/tools/forensics/SKILL.md +89 -0
  197. package/templates/skills/tools/gen-docs/SKILL.md +116 -0
  198. package/templates/skills/tools/gen-docs/scripts/doc_generator.js +435 -0
  199. package/templates/skills/tools/health/SKILL.md +121 -0
  200. package/templates/skills/tools/lib/shared.js +98 -0
  201. package/templates/skills/tools/map-codebase/SKILL.md +118 -0
  202. package/templates/skills/tools/override-refusal/SKILL.md +53 -0
  203. package/templates/skills/tools/override-refusal/agents/openai.yaml +4 -0
  204. package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -0
  205. package/templates/skills/tools/verify-change/SKILL.md +143 -0
  206. package/templates/skills/tools/verify-change/scripts/change_analyzer.js +289 -0
  207. package/templates/skills/tools/verify-module/SKILL.md +130 -0
  208. package/templates/skills/tools/verify-module/scripts/module_scanner.js +171 -0
  209. package/templates/skills/tools/verify-quality/SKILL.md +163 -0
  210. package/templates/skills/tools/verify-quality/scripts/quality_checker.js +337 -0
  211. package/templates/skills/tools/verify-security/SKILL.md +146 -0
  212. package/templates/skills/tools/verify-security/scripts/security_scanner.js +283 -0
@@ -0,0 +1,190 @@
1
+ ---
2
+ description: '多模型协作开发工作流(研究→构思→计划→执行→优化→评审),智能路由前端→{{FRONTEND_PRIMARY}}、后端→{{BACKEND_PRIMARY}}'
3
+ context_budget: orchestrator-15
4
+ subagent_freshness: required
5
+ ---
6
+
7
+ # Workflow - 多模型协作开发
8
+
9
+ 使用质量把关、MCP 服务和多模型协作执行结构化开发工作流。
10
+
11
+ ## 使用方法
12
+
13
+ ```bash
14
+ /workflow <任务描述>
15
+ ```
16
+
17
+ ## 上下文
18
+
19
+ - 要开发的任务:$ARGUMENTS
20
+ - 带质量把关的结构化 6 阶段工作流
21
+ - 多模型协作:{{BACKEND_PRIMARY}}(后端)+ {{FRONTEND_PRIMARY}}(前端)+ Claude(编排)
22
+ - MCP 服务集成(ace-tool)以增强功能
23
+
24
+ ## 你的角色
25
+
26
+ 你是**编排者**,协调多模型协作系统(研究 → 构思 → 计划 → 执行 → 优化 → 评审),用中文协助用户,面向专业程序员,交互应简洁专业,避免不必要解释。
27
+
28
+ **协作模型**:
29
+ - **{{BACKEND_PRIMARY}}** – 后端逻辑、算法、调试(**后端权威,可信赖**)
30
+ - **{{FRONTEND_PRIMARY}}** – 前端 UI/UX、视觉设计(**前端高手,后端意见仅供参考**)
31
+ - **Claude (自己)** – 编排、计划、执行、交付
32
+
33
+ ---
34
+
35
+ ## 多模型调用规范
36
+
37
+ **工作目录**:
38
+ - `{{WORKDIR}}`:**必须通过 Bash 执行 `pwd`(Unix)或 `cd`(Windows CMD)获取当前工作目录的绝对路径**,禁止从 `$HOME` 或环境变量推断
39
+ - 如果用户通过 `/add-dir` 添加了多个工作区,先用 Glob/Grep 确定任务相关的工作区
40
+ - 如果无法确定,用 `AskUserQuestion` 询问用户选择目标工作区
41
+
42
+ **调用语法**(并行用 `run_in_background: true`,串行用 `false`):
43
+
44
+ ```
45
+ # 新会话调用
46
+ Bash({
47
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EOF'
48
+ ROLE_FILE: <角色提示词路径>
49
+ <TASK>
50
+ 需求:<增强后的需求(如未增强则用 $ARGUMENTS)>
51
+ 上下文:<前序阶段收集的项目上下文、分析结果等>
52
+ </TASK>
53
+ OUTPUT: 期望输出格式
54
+ EOF",
55
+ run_in_background: true,
56
+ timeout: 3600000,
57
+ description: "简短描述"
58
+ })
59
+
60
+ # 复用会话调用
61
+ Bash({
62
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}resume <SESSION_ID> - \"{{WORKDIR}}\" <<'EOF'
63
+ ROLE_FILE: <角色提示词路径>
64
+ <TASK>
65
+ 需求:<增强后的需求(如未增强则用 $ARGUMENTS)>
66
+ 上下文:<前序阶段收集的项目上下文、分析结果等>
67
+ </TASK>
68
+ OUTPUT: 期望输出格式
69
+ EOF",
70
+ run_in_background: true,
71
+ timeout: 3600000,
72
+ description: "简短描述"
73
+ })
74
+ ```
75
+
76
+ **角色提示词**:
77
+
78
+ | 阶段 | 后端 | 前端 |
79
+ |------|-------|--------|
80
+ | 分析 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/analyzer.md` | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/analyzer.md` |
81
+ | 规划 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/architect.md` | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/architect.md` |
82
+ | 审查 | `~/.claude/.ccg/prompts/{{BACKEND_PRIMARY}}/reviewer.md` | `~/.claude/.ccg/prompts/{{FRONTEND_PRIMARY}}/reviewer.md` |
83
+
84
+ **会话复用**:每次调用返回 `SESSION_ID: xxx`,后续阶段用 `resume xxx` 复用上下文(注意:是 `resume`,不是 `--resume`)。
85
+
86
+ **并行调用 + 事件驱动等待(v4.5.2 起)**:
87
+
88
+ 1. 同 message 内 spawn 多个 `Bash(run_in_background: true)` 并行任务
89
+ 2. spawn 完后主线说明已启动 task-id,**直接 turn end**,**不调 TaskOutput**
90
+ 3. Claude Code 引擎在每个 task 完成时自动发 `<task-notification>` system-reminder 触发主线新 turn
91
+ 4. 主线在新 turn 处理:从 `<output-file>` 路径 read stdout,按通道 schema parse 结果
92
+ 5. **必须等所有相关 task 都收到通知**才进入下一阶段(按 task-id 计数已收齐)
93
+
94
+ ⛔ **禁止**:
95
+ - 调 `TaskOutput({block: true, timeout: 600000})` —— v4.5.1 之前的旧 freeze poll 模式,已废弃
96
+ - 收到部分通知就跳过等其他模型
97
+ - 主动 Kill task
98
+
99
+ ⚠️ **失败处理**:notification status=failed / exit ≠ 0 / stdout < 100B / JSON parse 失败 → v1.7.87 标准 2-retry / 5s / 3-attempts;3 次全失败才降级单模型继续。
100
+
101
+ ---
102
+
103
+ ## 沟通守则
104
+
105
+ 1. 响应以模式标签 `[模式:X]` 开始,初始为 `[模式:研究]`。
106
+ 2. 核心工作流严格按 `研究 → 构思 → 计划 → 执行 → 优化 → 评审` 顺序流转。
107
+ 3. 每个阶段完成后必须请求用户确认。
108
+ 4. 评分低于 7 分或用户未批准时强制停止。
109
+ 5. 在需要询问用户时,尽量使用 `AskUserQuestion` 工具进行交互,举例场景:请求用户确认/选择/批准
110
+
111
+ ---
112
+
113
+ ## 执行工作流
114
+
115
+ **任务描述**:$ARGUMENTS
116
+
117
+ ### 🔍 阶段 1:研究与分析
118
+
119
+ `[模式:研究]` - 理解需求并收集上下文:
120
+
121
+ 1. **Prompt 增强**(按 `/ccg:enhance` 的逻辑执行):分析 $ARGUMENTS 的意图、缺失信息、隐含假设,补全为结构化需求(明确目标、技术约束、范围边界、验收标准),**用增强结果替代原始 $ARGUMENTS,后续调用后端/前端模型 时传入增强后的需求**
122
+ 2. **上下文检索**:调用 `{{MCP_SEARCH_TOOL}}`
123
+ 3. **需求完整性评分**(0-10 分):
124
+ - 目标明确性(0-3)、预期结果(0-3)、边界范围(0-2)、约束条件(0-2)
125
+ - ≥7 分:继续 | <7 分:⛔ 停止,提出补充问题
126
+
127
+ ### 💡 阶段 2:方案构思
128
+
129
+ `[模式:构思]` - 多模型并行分析:
130
+
131
+ **并行调用**(`run_in_background: true`):
132
+ - {{BACKEND_PRIMARY}}:使用分析提示词,输出技术可行性、方案、风险
133
+ - {{FRONTEND_PRIMARY}}:使用分析提示词,输出 UI 可行性、方案、体验
134
+
135
+ 用 `TaskOutput` 等待结果。**📌 保存 SESSION_ID**(`CODEX_SESSION` 和 `GEMINI_SESSION`)。
136
+
137
+ **务必遵循上方 `多模型调用规范` 的 `重要` 指示**
138
+
139
+ 综合两方分析,输出方案对比(至少 2 个方案),等待用户选择。
140
+
141
+ ### 📋 阶段 3:详细规划
142
+
143
+ `[模式:计划]` - 多模型协作规划:
144
+
145
+ **并行调用**(复用会话):
146
+ - {{BACKEND_PRIMARY}}:使用规划提示词 + `resume $CODEX_SESSION`,输出后端架构
147
+ - {{FRONTEND_PRIMARY}}:使用规划提示词 + `resume $GEMINI_SESSION`,输出前端架构
148
+
149
+ 用 `TaskOutput` 等待结果。
150
+
151
+ **务必遵循上方 `多模型调用规范` 的 `重要` 指示**
152
+
153
+ **Claude 综合规划**:采纳 {{BACKEND_PRIMARY}} 后端规划 + {{FRONTEND_PRIMARY}} 前端规划,用户批准后存入 `.claude/plan/任务名.md`
154
+
155
+ ### ⚡ 阶段 4:实施
156
+
157
+ `[模式:执行]` - 代码开发:
158
+
159
+ - 严格按批准的计划实施
160
+ - 遵循项目现有代码规范
161
+ - 在关键里程碑请求反馈
162
+
163
+ ### 🚀 阶段 5:代码优化
164
+
165
+ `[模式:优化]` - 多模型并行审查:
166
+
167
+ **并行调用**:
168
+ - {{BACKEND_PRIMARY}}:使用审查提示词,关注安全、性能、错误处理
169
+ - {{FRONTEND_PRIMARY}}:使用审查提示词,关注可访问性、设计一致性
170
+
171
+ 用 `TaskOutput` 等待结果。整合审查意见,用户确认后执行优化。
172
+
173
+ **务必遵循上方 `多模型调用规范` 的 `重要` 指示**
174
+
175
+ ### ✅ 阶段 6:质量审查
176
+
177
+ `[模式:评审]` - 最终评估:
178
+
179
+ - 对照计划检查完成情况
180
+ - 运行测试验证功能
181
+ - 报告问题与建议
182
+ - 请求最终用户确认
183
+
184
+ ---
185
+
186
+ ## 关键规则
187
+
188
+ 1. 阶段顺序不可跳过(除非用户明确指令)
189
+ 2. 外部模型对文件系统**零写入权限**,所有修改由 Claude 执行
190
+ 3. 评分 <7 或用户未批准时**强制停止**
@@ -0,0 +1,128 @@
1
+ ---
2
+ description: '管理 Git Worktree:在 ../.ccg/项目名/ 目录创建,支持 IDE 集成和内容迁移'
3
+ ---
4
+
5
+ # Worktree - Git Worktree 管理
6
+
7
+ 在结构化目录管理 Git worktree,支持智能默认和 IDE 集成。
8
+
9
+ ## 使用方法
10
+
11
+ ```bash
12
+ /worktree <add|list|remove|prune|migrate> [options]
13
+ ```
14
+
15
+ ## 子命令
16
+
17
+ | 命令 | 说明 |
18
+ |------|------|
19
+ | `add <path>` | 创建新 worktree |
20
+ | `list` | 列出所有 worktree |
21
+ | `remove <path>` | 删除指定 worktree |
22
+ | `prune` | 清理无效引用 |
23
+ | `migrate <target>` | 迁移内容到目标 worktree |
24
+
25
+ ## 选项
26
+
27
+ | 选项 | 说明 |
28
+ |------|------|
29
+ | `-b <branch>` | 创建新分支 |
30
+ | `-o, --open` | 创建后用 IDE 打开 |
31
+ | `--from <source>` | 迁移源路径 |
32
+ | `--stash` | 迁移 stash 内容 |
33
+ | `--track` | 跟踪远程分支 |
34
+ | `--detach` | 分离 HEAD |
35
+ | `--lock` | 锁定 worktree |
36
+
37
+ ---
38
+
39
+ ## 目录结构
40
+
41
+ ```
42
+ parent-directory/
43
+ ├── your-project/ # 主项目
44
+ │ ├── .git/
45
+ │ └── src/
46
+ └── .ccg/ # worktree 管理目录
47
+ └── your-project/
48
+ ├── feature-ui/ # 功能分支
49
+ ├── hotfix/ # 修复分支
50
+ └── debug/ # 调试 worktree
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 执行工作流
56
+
57
+ ### Add - 创建 Worktree
58
+
59
+ `[模式:创建]`
60
+
61
+ 1. 验证 Git 仓库
62
+ 2. 计算路径:`../.ccg/项目名/<path>`
63
+ 3. 创建 worktree
64
+ 4. 自动复制环境文件(`.env` 等)
65
+ 5. 可选:用 IDE 打开
66
+
67
+ ### Migrate - 迁移内容
68
+
69
+ `[模式:迁移]`
70
+
71
+ 1. 验证源有未提交内容
72
+ 2. 确保目标干净
73
+ 3. 显示即将迁移的改动
74
+ 4. 安全迁移
75
+ 5. 确认结果
76
+
77
+ ---
78
+
79
+ ## 示例
80
+
81
+ ```bash
82
+ # 基本创建
83
+ /worktree add feature-ui
84
+
85
+ # 创建并用 IDE 打开
86
+ /worktree add feature-ui -o
87
+
88
+ # 创建指定分支
89
+ /worktree add hotfix -b fix/login -o
90
+
91
+ # 迁移未提交内容
92
+ /worktree migrate feature-ui --from main
93
+
94
+ # 迁移 stash 内容
95
+ /worktree migrate feature-ui --stash
96
+
97
+ # 管理操作
98
+ /worktree list
99
+ /worktree remove feature-ui
100
+ /worktree prune
101
+ ```
102
+
103
+ ## 输出示例
104
+
105
+ ```
106
+ ✅ Worktree created at ../.ccg/项目名/feature-ui
107
+ ✅ 已复制 .env
108
+ ✅ 已复制 .env.local
109
+ 📋 已从 .gitignore 复制 2 个环境文件
110
+ 🖥️ 是否在 IDE 中打开?[y/n]: y
111
+ 🚀 正在用 VS Code 打开...
112
+ ```
113
+
114
+ ---
115
+
116
+ ## 智能特性
117
+
118
+ 1. **智能默认** – 未指定分支时使用路径名
119
+ 2. **IDE 集成** – 自动检测 VS Code / Cursor / WebStorm
120
+ 3. **环境文件** – 自动复制 `.gitignore` 中的 `.env` 文件
121
+ 4. **路径安全** – 始终使用绝对路径防止嵌套问题
122
+ 5. **分支保护** – 验证分支未被其他地方使用
123
+
124
+ ## 注意事项
125
+
126
+ - Worktree 共享 `.git` 目录,节省磁盘空间
127
+ - 迁移仅限未提交改动,已提交内容用 `git cherry-pick`
128
+ - 支持 Windows、macOS、Linux
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+ // ccg-hook: context-monitor
3
+ // Context Monitor - PostToolUse hook for CCG Workflow.
4
+ // Reads context metrics from the statusline bridge file and injects warnings
5
+ // into the agent's conversation when context usage is high. This makes the
6
+ // AGENT itself aware of context limits (the statusline only shows the user).
7
+ //
8
+ // How it works:
9
+ // 1. ccg-statusline.js writes metrics to {os.tmpdir()}/claude-ctx-{session_id}.json
10
+ // 2. This hook reads those metrics after each tool use
11
+ // 3. When remaining context drops below thresholds, it injects a warning
12
+ // as additionalContext, which the agent sees on its next turn
13
+ //
14
+ // Thresholds:
15
+ // WARNING (remaining <= 35%): Agent should wrap up current task
16
+ // CRITICAL (remaining <= 25%): Agent should stop immediately and inform user
17
+ //
18
+ // Debounce: 5 tool uses between warnings to avoid spam.
19
+ // Severity escalation (WARNING -> CRITICAL) bypasses debounce so the user
20
+ // always sees the elevated alert.
21
+
22
+ const fs = require('fs');
23
+ const os = require('os');
24
+ const path = require('path');
25
+
26
+ const WARNING_THRESHOLD = 35; // remaining_percentage <= 35%
27
+ const CRITICAL_THRESHOLD = 25; // remaining_percentage <= 25%
28
+ const STALE_SECONDS = 60; // ignore metrics older than 60s
29
+ const DEBOUNCE_CALLS = 5; // min tool uses between warnings
30
+
31
+ let input = '';
32
+ // Timeout guard: if stdin doesn't close within 10s (e.g. pipe issues on
33
+ // Windows/Git Bash, or slow Claude Code piping during large outputs),
34
+ // exit silently instead of hanging until Claude Code kills the process
35
+ // and reports "hook error".
36
+ const stdinTimeout = setTimeout(() => process.exit(0), 10000);
37
+ process.stdin.setEncoding('utf8');
38
+ process.stdin.on('data', chunk => input += chunk);
39
+ process.stdin.on('end', () => {
40
+ clearTimeout(stdinTimeout);
41
+ try {
42
+ const data = JSON.parse(input);
43
+ const sessionId = data.session_id;
44
+
45
+ if (!sessionId) {
46
+ process.exit(0);
47
+ }
48
+
49
+ // Reject session IDs that contain path traversal sequences or path separators.
50
+ // session_id is used to construct file paths in tmp — an unsanitized value
51
+ // could escape the temp directory and read or write arbitrary files.
52
+ if (/[/\\]|\.\./.test(sessionId)) {
53
+ process.exit(0);
54
+ }
55
+
56
+ // Per-project opt-out via .ccg/config.json:
57
+ // { "hooks": { "context_warnings": false } }
58
+ // Quick sentinel check: skip config read entirely for non-CCG projects.
59
+ const cwd = data.cwd || process.cwd();
60
+ const ccgDir = path.join(cwd, '.ccg');
61
+ if (fs.existsSync(ccgDir)) {
62
+ try {
63
+ const configPath = path.join(ccgDir, 'config.json');
64
+ if (fs.existsSync(configPath)) {
65
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
66
+ if (config.hooks?.context_warnings === false) {
67
+ process.exit(0);
68
+ }
69
+ }
70
+ } catch (e) {
71
+ // Ignore config read/parse errors (config is optional)
72
+ }
73
+ }
74
+
75
+ const tmpDir = os.tmpdir();
76
+ const metricsPath = path.join(tmpDir, `claude-ctx-${sessionId}.json`);
77
+
78
+ // If no metrics file, this is a subagent or fresh session -- exit silently
79
+ if (!fs.existsSync(metricsPath)) {
80
+ process.exit(0);
81
+ }
82
+
83
+ const metrics = JSON.parse(fs.readFileSync(metricsPath, 'utf8'));
84
+ const now = Math.floor(Date.now() / 1000);
85
+
86
+ // Ignore stale metrics
87
+ if (metrics.timestamp && (now - metrics.timestamp) > STALE_SECONDS) {
88
+ process.exit(0);
89
+ }
90
+
91
+ const remaining = metrics.remaining_percentage;
92
+ const usedPct = metrics.used_pct;
93
+
94
+ // No warning needed
95
+ if (remaining > WARNING_THRESHOLD) {
96
+ process.exit(0);
97
+ }
98
+
99
+ // Debounce: check if we warned recently
100
+ const warnPath = path.join(tmpDir, `claude-ctx-${sessionId}-warned.json`);
101
+ let warnData = { callsSinceWarn: 0, lastLevel: null };
102
+ let firstWarn = true;
103
+
104
+ if (fs.existsSync(warnPath)) {
105
+ try {
106
+ warnData = JSON.parse(fs.readFileSync(warnPath, 'utf8'));
107
+ firstWarn = false;
108
+ } catch (e) {
109
+ // Corrupted file, reset
110
+ }
111
+ }
112
+
113
+ warnData.callsSinceWarn = (warnData.callsSinceWarn || 0) + 1;
114
+
115
+ const isCritical = remaining <= CRITICAL_THRESHOLD;
116
+ const currentLevel = isCritical ? 'critical' : 'warning';
117
+
118
+ // Emit immediately on first warning, then debounce subsequent ones.
119
+ // Severity escalation (WARNING -> CRITICAL) bypasses debounce so the
120
+ // elevated alert is never missed.
121
+ const severityEscalated = currentLevel === 'critical' && warnData.lastLevel === 'warning';
122
+ if (!firstWarn && warnData.callsSinceWarn < DEBOUNCE_CALLS && !severityEscalated) {
123
+ // Update counter and exit without warning
124
+ fs.writeFileSync(warnPath, JSON.stringify(warnData));
125
+ process.exit(0);
126
+ }
127
+
128
+ // Reset debounce counter
129
+ warnData.callsSinceWarn = 0;
130
+ warnData.lastLevel = currentLevel;
131
+ fs.writeFileSync(warnPath, JSON.stringify(warnData));
132
+
133
+ // Build advisory warning message (advisory only — never imperative; the
134
+ // user, not the hook, decides how to proceed).
135
+ let message;
136
+ if (isCritical) {
137
+ message = `[CCG] CONTEXT CRITICAL: Usage at ${usedPct}%. Remaining: ${remaining}%. ` +
138
+ 'Context is nearly exhausted. Inform the user that context is low and ask how they ' +
139
+ 'want to proceed. Avoid starting new complex work, large refactors, or autonomous ' +
140
+ 'state-saving unless the user asks for it.';
141
+ } else {
142
+ message = `[CCG] CONTEXT WARNING: Usage at ${usedPct}%. Remaining: ${remaining}%. ` +
143
+ 'Context is getting limited. Avoid unnecessary exploration or starting new complex ' +
144
+ 'work. Consider wrapping up the current task at the next natural stopping point.';
145
+ }
146
+
147
+ const output = {
148
+ hookSpecificOutput: {
149
+ hookEventName: process.env.GEMINI_API_KEY ? 'AfterTool' : 'PostToolUse',
150
+ additionalContext: message,
151
+ },
152
+ };
153
+
154
+ process.stdout.write(JSON.stringify(output));
155
+ } catch (e) {
156
+ // Silent fail -- never block tool execution
157
+ process.exit(0);
158
+ }
159
+ });