zhuge-workflow 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 (80) hide show
  1. package/dist/index.js +801 -0
  2. package/dist/index.js.map +1 -0
  3. package/package.json +61 -0
  4. package/templates/claude/CLAUDE-ccg.md +258 -0
  5. package/templates/claude/CLAUDE.md +106 -0
  6. package/templates/claude/commands/ccg/_context.md +152 -0
  7. package/templates/claude/commands/ccg/spec-impl.md +161 -0
  8. package/templates/claude/commands/ccg/spec-plan-trellis.md +239 -0
  9. package/templates/claude/commands/ccg/spec-plan.md +225 -0
  10. package/templates/claude/commands/ccg/spec-research.md +113 -0
  11. package/templates/claude/commands/ccg/spec-review.md +127 -0
  12. package/templates/claude/commands/developer/brainstorm.md +5 -0
  13. package/templates/claude/commands/developer/design-checklist.md +81 -0
  14. package/templates/claude/commands/developer/design-doc.md +188 -0
  15. package/templates/claude/commands/developer/requirement-doc.md +150 -0
  16. package/templates/claude/commands/developer/requirement-interrogate.md +71 -0
  17. package/templates/claude/commands/developer/status.md +55 -0
  18. package/templates/claude/rules/bash-style.md +46 -0
  19. package/templates/claude/rules/claude-code-defensive.md +99 -0
  20. package/templates/claude/rules/doc-sync.md +49 -0
  21. package/templates/claude/rules/ops-safety.md +32 -0
  22. package/templates/claude/skills/bash-style/SKILL.md +244 -0
  23. package/templates/claude/skills/brainstorming/SKILL.md +48 -0
  24. package/templates/claude/skills/dotnet-dev/SKILL.md +250 -0
  25. package/templates/claude/skills/dotnet-dev/references/dotnet-style.md +991 -0
  26. package/templates/claude/skills/mcp-builder/LICENSE.txt +202 -0
  27. package/templates/claude/skills/mcp-builder/SKILL.md +328 -0
  28. package/templates/claude/skills/mcp-builder/reference/evaluation.md +602 -0
  29. package/templates/claude/skills/mcp-builder/reference/mcp_best_practices.md +915 -0
  30. package/templates/claude/skills/mcp-builder/reference/node_mcp_server.md +916 -0
  31. package/templates/claude/skills/mcp-builder/reference/python_mcp_server.md +752 -0
  32. package/templates/claude/skills/mcp-builder/scripts/connections.py +151 -0
  33. package/templates/claude/skills/mcp-builder/scripts/evaluation.py +373 -0
  34. package/templates/claude/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
  35. package/templates/claude/skills/mcp-builder/scripts/requirements.txt +2 -0
  36. package/templates/claude/skills/ops-safety/SKILL.md +130 -0
  37. package/templates/claude/skills/python-dev/SKILL.md +281 -0
  38. package/templates/claude/skills/skill-creator/LICENSE.txt +202 -0
  39. package/templates/claude/skills/skill-creator/SKILL.md +209 -0
  40. package/templates/claude/skills/skill-creator/scripts/init_skill.py +303 -0
  41. package/templates/claude/skills/skill-creator/scripts/package_skill.py +110 -0
  42. package/templates/claude/skills/skill-creator/scripts/quick_validate.py +65 -0
  43. package/templates/claude/skills/sqlserver-executor/SKILL.md +201 -0
  44. package/templates/claude/skills/sqlserver-executor/assets/config-example.json +26 -0
  45. package/templates/claude/skills/sqlserver-executor/config.json +12 -0
  46. package/templates/claude/skills/sqlserver-executor/scripts/sql_executor.py +404 -0
  47. package/templates/claude/skills/ui-ux-pro-max/SKILL.md +228 -0
  48. package/templates/claude/skills/ui-ux-pro-max/data/charts.csv +26 -0
  49. package/templates/claude/skills/ui-ux-pro-max/data/colors.csv +97 -0
  50. package/templates/claude/skills/ui-ux-pro-max/data/landing.csv +31 -0
  51. package/templates/claude/skills/ui-ux-pro-max/data/products.csv +97 -0
  52. package/templates/claude/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  53. package/templates/claude/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  54. package/templates/claude/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  55. package/templates/claude/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  56. package/templates/claude/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  57. package/templates/claude/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  58. package/templates/claude/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  59. package/templates/claude/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  60. package/templates/claude/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  61. package/templates/claude/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  62. package/templates/claude/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  63. package/templates/claude/skills/ui-ux-pro-max/data/styles.csv +59 -0
  64. package/templates/claude/skills/ui-ux-pro-max/data/typography.csv +58 -0
  65. package/templates/claude/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  66. package/templates/claude/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  67. package/templates/claude/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
  68. package/templates/claude/skills/ui-ux-pro-max/scripts/core.py +238 -0
  69. package/templates/claude/skills/ui-ux-pro-max/scripts/search.py +61 -0
  70. package/templates/claude/skills/webapp-testing/LICENSE.txt +202 -0
  71. package/templates/claude/skills/webapp-testing/SKILL.md +96 -0
  72. package/templates/claude/skills/webapp-testing/examples/console_logging.py +35 -0
  73. package/templates/claude/skills/webapp-testing/examples/element_discovery.py +40 -0
  74. package/templates/claude/skills/webapp-testing/examples/static_html_automation.py +33 -0
  75. package/templates/claude/skills/webapp-testing/scripts/with_server.py +106 -0
  76. package/templates/init/claude-agents/ccg-impl.md +199 -0
  77. package/templates/init/claude-agents/ccg-review.md +146 -0
  78. package/templates/init/claude-agents/dispatch.md +253 -0
  79. package/templates/init/claude-hooks/inject-subagent-context.py +964 -0
  80. package/templates/init/trellis-scripts/task.sh +1326 -0
@@ -0,0 +1,152 @@
1
+ # CCG Spec 上下文注入协议
2
+
3
+ > 本文件定义 CCG Spec 工作流的上下文注入规范。
4
+ > 所有 `/ccg:spec-*` 命令(除 `spec-init`)必须遵循此协议。
5
+
6
+ ---
7
+
8
+ ## 阶段一:基础规范(所有命令通用)
9
+
10
+ ### 1.1 发现规范目录结构
11
+
12
+ 使用 Glob 快速列出规范文件:
13
+
14
+ ```bash
15
+ # 列出规范目录结构
16
+ ls -la .trellis/spec/ 2>/dev/null
17
+ ```
18
+
19
+ ### 1.2 读取基础规范
20
+
21
+ 根据发现的目录结构和任务类型,读取相关规范:
22
+
23
+ ```
24
+ mcp__ace-tool__search_context({
25
+ project_root_path: "$PWD",
26
+ query: "<任务描述> 需要遵循哪些编码规范和开发指南"
27
+ })
28
+ ```
29
+
30
+ ### 1.3 规范约束
31
+
32
+ 读取的规范内容必须:
33
+ 1. **保持在工作记忆中** - 后续所有步骤都受这些规范约束
34
+ 2. **传递给外部模型** - 调用 Codex/Gemini 时,将相关规范内容包含在 prompt 中
35
+ 3. **优先于默认行为** - 规范与 AI 默认行为冲突时,以规范为准
36
+
37
+ ---
38
+
39
+ ## 阶段二:任务专属上下文(仅 spec-impl / spec-review)
40
+
41
+ ### 2.1 读取 ccg-context.jsonl
42
+
43
+ ```bash
44
+ cat openspec/changes/<change-id>/ccg-context.jsonl 2>/dev/null
45
+ ```
46
+
47
+ ### 2.2 JSONL 格式
48
+
49
+ 每条规范关联到具体的 task 编号,支持多任务关联:
50
+
51
+ ```jsonl
52
+ {"task": "1", "file": "<规范文件路径>", "reason": "<为什么与该任务相关>"}
53
+ {"task": "1,2", "file": "<规范文件路径>", "reason": "<任务1和2都需要>"}
54
+ {"task": "1,2,3", "file": "<规范文件路径>", "reason": "<多个任务共用>"}
55
+ {"task": "*", "file": "<规范文件路径>", "reason": "<所有任务通用>"}
56
+ ```
57
+
58
+ **字段说明**:
59
+ - `task`: 任务编号,多个用逗号分隔(如 `"1,2,3"`),`"*"` 表示所有任务通用
60
+ - `file`: 规范文件路径
61
+ - `reason`: 为什么该规范与此任务相关
62
+
63
+ ### 2.3 按当前任务读取规范
64
+
65
+ 在 `spec-impl` 阶段,根据当前执行的任务编号筛选并读取规范:
66
+
67
+ ```bash
68
+ # 读取任务 N 相关的规范(包括通用规范 "*" 和包含该任务的多任务条目)
69
+ TASK_ID="1"
70
+ cat openspec/changes/<change-id>/ccg-context.jsonl | while read line; do
71
+ task=$(echo "$line" | jq -r '.task')
72
+ # 匹配: "*" 或 精确匹配 或 在逗号分隔列表中
73
+ if [ "$task" = "*" ] || [ "$task" = "$TASK_ID" ] || echo ",$task," | grep -q ",$TASK_ID,"; then
74
+ file=$(echo "$line" | jq -r '.file')
75
+ echo "=== $file ==="
76
+ cat "$file" 2>/dev/null
77
+ fi
78
+ done
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 命令与阶段对应关系
84
+
85
+ | 命令 | 阶段一(基础规范) | 阶段二(专属上下文) | 特殊职责 |
86
+ |------|:------------------:|:--------------------:|----------|
87
+ | `/ccg:spec-init` | ❌ | ❌ | 验证工具 |
88
+ | `/ccg:spec-research` | ✅ | ❌ | 探索代码库 |
89
+ | `/ccg:spec-plan` | ✅ | ❌ | **创建** ccg-context.jsonl |
90
+ | `/ccg:spec-impl` | ✅ | ✅ | 按计划实现 |
91
+ | `/ccg:spec-review` | ✅ | ✅ | 双模型审查 |
92
+
93
+ ---
94
+
95
+ ## ccg-context.jsonl 创建指南(spec-plan 职责)
96
+
97
+ 在 `spec-plan` 阶段,基于研究和规划结果,为每个 task 创建上下文配置。
98
+
99
+ ### 步骤
100
+
101
+ 1. **读取 tasks.md**:获取所有任务列表和编号
102
+ 2. **为每个任务分析所需规范**:使用mcp__ace-tool__search_context工具语义化查询找到相关规范
103
+ 3. **创建 ccg-context.jsonl**:每条规范关联到具体任务
104
+
105
+ ### 发现相关规范
106
+
107
+ 使用语义化查询找到与当前任务相关的规范:
108
+
109
+ ```
110
+ mcp__ace-tool__search_context({
111
+ project_root_path: "$PWD",
112
+ query: "<任务描述> 需要遵循的具体规范文件"
113
+ })
114
+ ```
115
+
116
+ ### 创建示例
117
+
118
+ ```bash
119
+ cat > openspec/changes/<change-id>/ccg-context.jsonl << 'EOF'
120
+ {"task": "*", "file": ".trellis/spec/guides/index.md", "reason": "所有任务通用的思维指南"}
121
+ {"task": "1,2", "file": ".trellis/spec/backend/api.md", "reason": "任务1和2都涉及API开发"}
122
+ {"task": "3", "file": ".trellis/spec/frontend/components.md", "reason": "任务3涉及组件开发"}
123
+ EOF
124
+ ```
125
+
126
+ ### 选择原则
127
+
128
+ 1. **任务粒度** - 每条规范关联到具体任务,避免注入不相关内容
129
+ 2. **多任务共用** - 多个任务需要同一规范时用逗号分隔(如 `"1,2,3"`)
130
+ 3. **通用规范用 `"*"`** - 所有任务都需要的规范用 `"*"` 标记
131
+ 4. **明确理由** - 每个条目必须有清晰的 `reason`
132
+
133
+ ---
134
+
135
+ ## 传递规范给外部模型
136
+
137
+ 调用 Codex/Gemini 时,必须将相关规范包含在 prompt 中:
138
+
139
+ ```bash
140
+ SPEC_CONTENT=$(cat <规范文件路径>)
141
+
142
+ codeagent-wrapper --backend codex - "$PWD" <<EOF
143
+ ## 项目规范约束
144
+ $SPEC_CONTENT
145
+
146
+ ## 任务
147
+ <具体任务描述>
148
+
149
+ ## 输出格式
150
+ Unified Diff Patch
151
+ EOF
152
+ ```
@@ -0,0 +1,161 @@
1
+ ---
2
+ description: '按规范执行 + 多模型协作 + 归档'
3
+ ---
4
+ <!-- CCG:SPEC:IMPL:START -->
5
+
6
+ > ⚠️ **上下文注入(阶段一 + 阶段二)**
7
+ > 执行本命令前,必须完成上下文注入。参考:`~/.claude/commands/ccg/_context.md`
8
+ >
9
+ > **阶段一**:发现并读取 `.trellis/spec/` 下相关目录的规范
10
+ > **阶段二**:根据当前任务编号,从 `ccg-context.jsonl` 筛选并读取对应规范
11
+
12
+ **Core Philosophy**
13
+ - Implementation is pure mechanical execution—all decisions were made in Plan phase.
14
+ - External model outputs are prototypes only; must be rewritten to production-grade code.
15
+ - Keep changes tightly scoped; enforce side-effect review before any modification.
16
+ - Minimize documentation—prefer self-explanatory code over comments.
17
+
18
+ **Guardrails**
19
+ - **NEVER** apply Codex/Gemini prototypes directly—all outputs are reference only.
20
+ - **MANDATORY**: Request `unified diff patch` format from external models; they have zero write permission.
21
+ - Keep implementation strictly within `tasks.md` scope—no scope creep.
22
+ - Refer to `openspec/config.yaml` for conventions.
23
+
24
+ **Steps**
25
+ 1. **Select Change**
26
+ - Run `/opsx:list` to inspect Active Changes.
27
+ - Confirm with user which change ID to implement.
28
+ - Run `/opsx:show <change_id>` to review tasks.
29
+
30
+ 2. **Apply OPSX Change**
31
+ - Use `/ccg:spec-impl` (which uses OpenSpec skills internally) to enter implementation mode.
32
+ - This skill will guide you through the tasks defined in `tasks.md`.
33
+
34
+ 3. **Identify Minimal Verifiable Phase**
35
+ - Review `tasks.md` and identify the **smallest verifiable phase**.
36
+ - Do NOT complete all tasks at once—control context window.
37
+ - Announce: "Implementing Phase X: [task group name]"
38
+
39
+ 4. **按任务编号注入规范(阶段二)**
40
+
41
+ 在执行每个任务前,根据任务编号从 `ccg-context.jsonl` 筛选并读取规范。
42
+
43
+ **任务编号格式**:使用 `Phase.Section` 格式(如 `1.1`, `2.5`, `3.1`),与 tasks.md 保持一致。
44
+
45
+ ```bash
46
+ # 假设当前执行 Phase 2.5 预设选择器组件
47
+ TASK_ID="2.5"
48
+ CHANGE_ID="<change-id>"
49
+
50
+ cat openspec/changes/$CHANGE_ID/ccg-context.jsonl | while read line; do
51
+ task=$(echo "$line" | jq -r '.task')
52
+ # 匹配: "*" 或 精确匹配 或 在逗号分隔列表中
53
+ if [ "$task" = "*" ] || [ "$task" = "$TASK_ID" ] || echo ",$task," | grep -q ",$TASK_ID,"; then
54
+ file=$(echo "$line" | jq -r '.file')
55
+ reason=$(echo "$line" | jq -r '.reason')
56
+ echo "=== $file ($reason) ==="
57
+ cat "$file" 2>/dev/null
58
+ fi
59
+ done
60
+ ```
61
+
62
+ **匹配规则**:
63
+ - `"*"` - 所有任务通用,始终注入
64
+ - `"2.5"` - 精确匹配 Phase 2.5
65
+ - `"1.1,1.2,1.3"` - Phase 1.1、1.2、1.3 共用,匹配其中任一
66
+
67
+ 5. **Route Tasks to Appropriate Model**
68
+ - **Route A: Gemini** — Frontend/UI/styling (CSS, React, Vue, HTML, components)
69
+ - **Route B: Codex** — Backend/logic/algorithm (API, data processing, business logic)
70
+
71
+ For each task:
72
+ ```
73
+ codeagent-wrapper --backend <codex|gemini> - "$PWD" <<'EOF'
74
+ TASK: <task description from tasks.md>
75
+ CONTEXT: <relevant code context>
76
+ CONSTRAINTS: <constraints from spec>
77
+ OUTPUT: Unified Diff Patch format ONLY
78
+ EOF
79
+ ```
80
+
81
+ 5. **Rewrite Prototype to Production Code**
82
+ Upon receiving diff patch, **NEVER apply directly**. Rewrite by:
83
+ - Removing redundancy
84
+ - Ensuring clear naming and simple structure
85
+ - Aligning with project style
86
+ - Eliminating unnecessary comments
87
+ - Verifying no new dependencies introduced
88
+
89
+ 6. **Side-Effect Review** (Mandatory before apply)
90
+ Verify the change:
91
+ - [ ] Does not exceed `tasks.md` scope
92
+ - [ ] Does not affect unrelated modules
93
+ - [ ] Does not introduce new dependencies
94
+ - [ ] Does not break existing interfaces
95
+
96
+ If issues found, make targeted corrections.
97
+
98
+ 7. **Multi-Model Review (PARALLEL)**
99
+ - **CRITICAL**: You MUST launch BOTH Codex AND Gemini in a SINGLE message with TWO Bash tool calls.
100
+ - **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
101
+
102
+ **Step 7.1**: In ONE message, make TWO parallel Bash calls:
103
+
104
+ **FIRST Bash call (Codex)**:
105
+ ```
106
+ Bash({
107
+ command: "/Users/blackzhuge/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF'\nReview the implementation changes:\n- Correctness: logic errors, edge cases\n- Security: injection, auth issues\n- Spec compliance: constraints satisfied\nOUTPUT: JSON with findings\nEOF",
108
+ run_in_background: true,
109
+ timeout: 300000,
110
+ description: "Codex: correctness/security review"
111
+ })
112
+ ```
113
+
114
+ **SECOND Bash call (Gemini) - IN THE SAME MESSAGE**:
115
+ ```
116
+ Bash({
117
+ command: "/Users/blackzhuge/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF'\nReview the implementation changes:\n- Maintainability: readability, complexity\n- Patterns: consistency with project style\n- Integration: cross-module impacts\nOUTPUT: JSON with findings\nEOF",
118
+ run_in_background: true,
119
+ timeout: 300000,
120
+ description: "Gemini: maintainability/patterns review"
121
+ })
122
+ ```
123
+
124
+ **Step 7.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
125
+ ```
126
+ TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
127
+ TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })
128
+ ```
129
+
130
+ Address any critical findings before proceeding.
131
+
132
+ 8. **Update Task Status**
133
+ - Mark completed task in `tasks.md`: `- [x] Task description`
134
+ - Commit changes if appropriate.
135
+
136
+ 9. **Context Checkpoint**
137
+ - After completing a phase, report context usage.
138
+ - If below 80K: Ask user "Continue to next phase?"
139
+ - If approaching 80K: Suggest "Run `/clear` and resume with `/ccg:spec:impl`"
140
+
141
+ 10. **Sync Specs Before Archive (MANDATORY)**
142
+ - When ALL tasks in `tasks.md` are marked `[x]`:
143
+ - **MUST** run `/opsx:sync` first to merge delta specs to `openspec/specs/`
144
+ - Verify sync completed successfully before proceeding
145
+ - Only after sync succeeds, run `/opsx:archive` to archive the change
146
+
147
+ **WARNING**: Skipping sync will result in lost specifications!
148
+
149
+ **Reference**
150
+ - Check task status: `/opsx:show <id>`
151
+ - Validate before archive: `/opsx:validate <id>`
152
+ - View active changes: `/opsx:list`
153
+ - Search existing patterns: `rg -n "function|class" <file>`
154
+
155
+ **Exit Criteria**
156
+ Implementation is complete when:
157
+ - [ ] All tasks in `tasks.md` marked `[x]`
158
+ - [ ] All multi-model reviews passed
159
+ - [ ] Side-effect review confirmed no regressions
160
+ - [ ] Change archived successfully
161
+ <!-- CCG:SPEC:IMPL:END -->
@@ -0,0 +1,239 @@
1
+ ---
2
+ description: '多模型分析 → 消除歧义 → 零决策可执行计划 → 生成 Trellis Tasks'
3
+ ---
4
+ <!-- CCG:SPEC:PLAN-NEW:START -->
5
+
6
+ > ⚠️ **上下文注入(阶段一)**
7
+ > 执行本命令前,必须先读取基础规范。参考:`~/.claude/commands/ccg/_context.md`
8
+ >
9
+ > **必读规范**:
10
+ > 1. `.trellis/spec/guides/index.md` - 思维指南
11
+ > 2. 根据开发类型读取 `backend/index.md` 或 `frontend/index.md`
12
+
13
+ **Core Philosophy**
14
+ - The goal is to eliminate ALL decision points—implementation should be pure mechanical execution.
15
+ - Every ambiguity must be resolved into explicit constraints before proceeding.
16
+ - Multi-model collaboration surfaces blind spots and conflicting assumptions.
17
+ - Every requirement must have Property-Based Testing (PBT) properties—focus on invariants.
18
+
19
+ **Guardrails**
20
+ - Do not proceed to implementation until every ambiguity is resolved.
21
+ - Multi-model collaboration is **mandatory**: use both Codex and Gemini.
22
+ - If constraints cannot be fully specified, escalate to user or return to research phase.
23
+ - Refer to `openspec/config.yaml` for project conventions.
24
+
25
+ **Steps**
26
+ 1. **Select Change**
27
+ - Run `/opsx:list` to display Active Changes.
28
+ - Confirm with user which change ID to refine.
29
+ - Run `/opsx:status <change_id>` to review current state.
30
+
31
+ 2. **Multi-Model Implementation Analysis (PARALLEL)**
32
+ - **CRITICAL**: You MUST launch BOTH Codex AND Gemini in a SINGLE message with TWO Bash tool calls.
33
+ - **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
34
+
35
+ **Step 2.1**: In ONE message, make TWO parallel Bash calls:
36
+
37
+ **FIRST Bash call (Codex)**:
38
+ ```
39
+ Bash({
40
+ command: "/Users/blackzhuge/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF'\nAnalyze change <change_id> from backend perspective:\n- Implementation approach\n- Technical risks\n- Alternative architectures\n- Edge cases and failure modes\nOUTPUT: JSON with analysis\nEOF",
41
+ run_in_background: true,
42
+ timeout: 300000,
43
+ description: "Codex: backend analysis"
44
+ })
45
+ ```
46
+
47
+ **SECOND Bash call (Gemini) - IN THE SAME MESSAGE**:
48
+ ```
49
+ Bash({
50
+ command: "/Users/blackzhuge/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF'\nAnalyze change <change_id> from frontend/integration perspective:\n- Maintainability assessment\n- Scalability considerations\n- Integration conflicts\nOUTPUT: JSON with analysis\nEOF",
51
+ run_in_background: true,
52
+ timeout: 300000,
53
+ description: "Gemini: frontend analysis"
54
+ })
55
+ ```
56
+
57
+ **Step 2.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
58
+ ```
59
+ TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
60
+ TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })
61
+ ```
62
+
63
+ - Synthesize responses and present consolidated options to user.
64
+
65
+ 3. **Uncertainty Elimination Audit**
66
+ - **Codex**: "Review proposal for unspecified decision points. List each as: [AMBIGUITY] → [REQUIRED CONSTRAINT]"
67
+ - **Gemini**: "Identify implicit assumptions. Specify: [ASSUMPTION] → [EXPLICIT CONSTRAINT NEEDED]"
68
+
69
+ **Anti-Pattern Detection** (flag and reject):
70
+ - Information collection without decision boundaries
71
+ - Technical comparisons without selection criteria
72
+ - Deferred decisions marked "to be determined during implementation"
73
+
74
+ **Target Pattern** (required for approval):
75
+ - Explicit technology choices with parameters (e.g., "JWT with TTL=15min")
76
+ - Concrete algorithm selections with configs (e.g., "bcrypt cost=12")
77
+ - Precise behavioral rules (e.g., "Lock account 30min after 5 failed attempts")
78
+
79
+ Iterate with user until ALL ambiguities resolved.
80
+
81
+ 4. **PBT Property Extraction**
82
+ - **Codex**: "Extract PBT properties. For each requirement: [INVARIANT] → [FALSIFICATION STRATEGY]"
83
+ - **Gemini**: "Define system properties: [PROPERTY] | [DEFINITION] | [BOUNDARY CONDITIONS] | [COUNTEREXAMPLE GENERATION]"
84
+
85
+ **Property Categories**:
86
+ - **Commutativity/Associativity**: Order-independent operations
87
+ - **Idempotency**: Repeated operations yield same result
88
+ - **Round-trip**: Encode→Decode returns original
89
+ - **Invariant Preservation**: State constraints maintained
90
+ - **Monotonicity**: Ordering guarantees (e.g., timestamps increase)
91
+ - **Bounds**: Value ranges, size limits, rate constraints
92
+
93
+ 5. **Update OPSX Artifacts**
94
+ - The agent will use OpenSpec skills to generate/update:
95
+ * specs (Requirements + PBT)
96
+ * design (Technical decisions)
97
+ * tasks (Zero-decision implementation plan)
98
+ - Ensure all resolved constraints and PBT properties are included in the generated artifacts.
99
+
100
+ **tasks.md 格式约束(强制)**:
101
+
102
+ 每个任务必须使用 checkbox 格式,便于跟踪进度:
103
+
104
+ ```markdown
105
+ ### 1.1 任务标题
106
+
107
+ - [ ] **文件**: `path/to/file.cs`
108
+
109
+ **实现要点**:
110
+ - 要点1
111
+ - 要点2
112
+
113
+ **验收**: 验收标准
114
+ ```
115
+
116
+ **格式规则**:
117
+ - 每个任务条目必须以 `- [ ]` 开头(待完成)
118
+ - 完成后标记为 `- [x]`
119
+ - 文件末尾必须包含进度统计表
120
+
121
+ **测试任务(强制)**:
122
+ - 每个功能实现任务必须有对应的测试任务
123
+ - 单元测试:覆盖核心逻辑、边界条件、异常处理
124
+ - 集成测试:覆盖 API 端点、数据库交互、跨模块协作
125
+ - 测试任务使用独立编号(如 1.2 实现 → 1.3 单元测试 → 1.4 集成测试)
126
+ - 具体测试框架参考 `openspec/config.yaml` 中的项目约定
127
+ - **禁止**:跳过测试任务或标记为"后续补充"
128
+
129
+ **进度统计表**:
130
+
131
+ ```markdown
132
+ ## 进度统计
133
+
134
+ | Phase | 总任务 | 已完成 | 进度 |
135
+ |-------|--------|--------|------|
136
+ | Phase 1 | N | 0 | 0% |
137
+ | **总计** | **N** | **0** | **0%** |
138
+ ```
139
+
140
+ 6. **生成 Trellis Tasks(替代 ccg-context.jsonl)**
141
+
142
+ 基于 tasks.md 的 Phase 结构,为每个 Phase 创建独立的 Trellis Task。
143
+
144
+ **6.1 解析 tasks.md 获取所有 Phase**
145
+
146
+ ```bash
147
+ CHANGE_ID="<change-id>"
148
+ CHANGE_DIR="openspec/changes/$CHANGE_ID"
149
+
150
+ # 提取所有 Phase 编号和标题
151
+ grep -E "^## Phase [0-9]+:" "$CHANGE_DIR/tasks.md"
152
+ ```
153
+
154
+ **6.2 确定每个 Phase 的 dev_type**
155
+
156
+ 根据 Phase 内容判断开发类型:
157
+ - 包含 `.cs`, `API`, `Service`, `Controller` → `backend`
158
+ - 包含 `.vue`, `.tsx`, `Component`, `UI` → `frontend`
159
+ - 混合内容 → `fullstack`
160
+ - 测试相关 → `test`
161
+
162
+ **6.3 为每个 Phase 创建 Trellis Task**
163
+
164
+ 对每个 Phase 调用 task.sh:
165
+
166
+ ```bash
167
+ # Phase 1 示例
168
+ ./.trellis/scripts/task.sh create-from-phase \
169
+ --change "$CHANGE_DIR" \
170
+ --phase 1 \
171
+ --dev-type backend
172
+
173
+ # Phase 2 示例
174
+ ./.trellis/scripts/task.sh create-from-phase \
175
+ --change "$CHANGE_DIR" \
176
+ --phase 2 \
177
+ --dev-type backend
178
+
179
+ # Phase 3 示例(前端)
180
+ ./.trellis/scripts/task.sh create-from-phase \
181
+ --change "$CHANGE_DIR" \
182
+ --phase 3 \
183
+ --dev-type frontend
184
+ ```
185
+
186
+ **create-from-phase 输出结构**:
187
+
188
+ ```
189
+ .trellis/tasks/MM-DD-<change-name>-phase-N/
190
+ ├── task.json # 包含 openspec_change, phase_number, ccg-impl action
191
+ ├── prd.md # 描述执行哪个 change 的哪个 Phase
192
+ ├── implement.jsonl # 包含 specs.md, design.md, tasks.md
193
+ ├── check.jsonl
194
+ └── debug.jsonl
195
+ ```
196
+
197
+ **6.4 列出创建的任务**
198
+
199
+ ```bash
200
+ ./.trellis/scripts/task.sh list
201
+ ```
202
+
203
+ **6.5 输出任务执行顺序**
204
+
205
+ 向用户报告创建的任务列表和建议的执行顺序:
206
+
207
+ ```markdown
208
+ ## Trellis Tasks 已创建
209
+
210
+ | Task | Phase | Dev Type | 状态 |
211
+ |------|-------|----------|------|
212
+ | 02-10-xxx-phase-1 | Phase 1: 后端 DTO | backend | planning |
213
+ | 02-10-xxx-phase-2 | Phase 2: 树构建 | backend | planning |
214
+ | 02-10-xxx-phase-3 | Phase 3: API 端点 | backend | planning |
215
+ | ... | ... | ... | ... |
216
+
217
+ ```
218
+
219
+ 7. **Context Checkpoint**
220
+ - Report current context usage.
221
+ - If approaching 80K tokens, suggest: "Run `/clear` and start executing tasks"
222
+
223
+ **Exit Criteria**
224
+ A change is ready for implementation only when:
225
+ - [ ] All multi-model analyses completed and synthesized
226
+ - [ ] Zero ambiguities remain (verified by step 3 audit)
227
+ - [ ] All PBT properties documented with falsification strategies
228
+ - [ ] Artifacts (specs, design, tasks) generated via OpenSpec skills
229
+ - [ ] **tasks.md 包含单元测试和集成测试任务**(无"后续补充"标记)
230
+ - [ ] **Trellis Tasks 已创建**(每个 Phase 一个 Task)
231
+ - [ ] User has explicitly approved all constraint decisions
232
+
233
+ **Reference**
234
+ - Inspect change: `/opsx:status <id>`
235
+ - Check conflicts: `/opsx:schemas`
236
+ - Search patterns: `rg -n "INVARIANT:|PROPERTY:" openspec/`
237
+ - List tasks: `./.trellis/scripts/task.sh list`
238
+ - Use `AskUserQuestion` for ANY ambiguity—never assume
239
+ <!-- CCG:SPEC:PLAN-NEW:END -->