claude-code-workflow 6.3.49 → 6.3.51

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 (90) hide show
  1. package/.claude/commands/issue/new.md +1 -2
  2. package/.claude/commands/view.md +367 -0
  3. package/.claude/commands/workflow/unified-execute-with-file.md +807 -0
  4. package/.claude/skills/ccw-help/SKILL.md +72 -12
  5. package/.claude/skills/ccw-help/command.json +922 -520
  6. package/.claude/skills/ccw-help/index/all-agents.json +97 -0
  7. package/.claude/skills/ccw-help/index/all-commands.json +805 -0
  8. package/.claude/skills/ccw-help/index/by-category.json +833 -0
  9. package/.claude/skills/ccw-help/index/by-use-case.json +819 -0
  10. package/.claude/skills/ccw-help/index/command-relationships.json +160 -0
  11. package/.claude/skills/ccw-help/index/essential-commands.json +90 -0
  12. package/.claude/skills/ccw-help/scripts/auto-update.py +34 -0
  13. package/.claude/skills/skill-generator/SKILL.md +255 -208
  14. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +238 -228
  15. package/.claude/skills/skill-generator/phases/02-structure-generation.md +261 -262
  16. package/.claude/skills/skill-generator/phases/03-phase-generation.md +976 -969
  17. package/.claude/skills/skill-generator/phases/04-specs-templates.md +398 -398
  18. package/.claude/skills/skill-generator/phases/05-validation.md +417 -417
  19. package/.claude/skills/skill-generator/specs/cli-integration.md +131 -131
  20. package/.claude/skills/skill-generator/specs/execution-modes.md +399 -396
  21. package/.claude/skills/skill-generator/specs/reference-docs-spec.md +271 -0
  22. package/.claude/skills/skill-generator/specs/scripting-integration.md +265 -265
  23. package/.claude/skills/skill-generator/specs/skill-requirements.md +466 -466
  24. package/.claude/skills/skill-generator/templates/autonomous-action.md +91 -88
  25. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +89 -89
  26. package/.claude/skills/skill-generator/templates/code-analysis-action.md +148 -149
  27. package/.claude/skills/skill-generator/templates/llm-action.md +367 -367
  28. package/.claude/skills/skill-generator/templates/script-template.md +79 -79
  29. package/.claude/skills/skill-generator/templates/sequential-phase.md +129 -129
  30. package/.claude/skills/skill-generator/templates/skill-md.md +134 -75
  31. package/.codex/prompts/UNIFIED_EXECUTE_COMPARISON.md +205 -0
  32. package/.codex/prompts/analyze-with-file.md +5 -2
  33. package/.codex/prompts/brainstorm-to-cycle.md +4 -3
  34. package/.codex/prompts/brainstorm-with-file.md +6 -2
  35. package/.codex/prompts/clean.md +7 -2
  36. package/.codex/prompts/compact.md +5 -3
  37. package/.codex/prompts/debug-with-file.md +6 -2
  38. package/.codex/prompts/execute.md +6 -2
  39. package/.codex/prompts/issue-execute.md +10 -2
  40. package/.codex/prompts/issue-new.md +390 -285
  41. package/.codex/prompts/lite-execute.md +8 -7
  42. package/.codex/prompts/lite-fix.md +6 -2
  43. package/.codex/prompts/lite-plan-a.md +6 -2
  44. package/.codex/prompts/lite-plan-b.md +6 -2
  45. package/.codex/prompts/lite-plan-c.md +6 -2
  46. package/.codex/prompts/unified-execute-with-file.md +722 -0
  47. package/.codex/skills/codex-issue-plan-execute/SKILL.md +239 -0
  48. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-complete.md +173 -0
  49. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-execute.md +220 -0
  50. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-init.md +86 -0
  51. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-list.md +165 -0
  52. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-plan.md +170 -0
  53. package/.codex/skills/codex-issue-plan-execute/phases/orchestrator.md +210 -0
  54. package/.codex/skills/codex-issue-plan-execute/phases/state-schema.md +136 -0
  55. package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent-system.md +136 -0
  56. package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent.md +135 -0
  57. package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent-system.md +107 -0
  58. package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent.md +122 -0
  59. package/.codex/skills/codex-issue-plan-execute/specs/issue-handling.md +187 -0
  60. package/.codex/skills/codex-issue-plan-execute/specs/quality-standards.md +231 -0
  61. package/.codex/skills/codex-issue-plan-execute/specs/solution-schema.md +270 -0
  62. package/.codex/skills/codex-issue-plan-execute/specs/subagent-roles.md +268 -0
  63. package/ccw/dist/cli.d.ts.map +1 -1
  64. package/ccw/dist/cli.js +1 -0
  65. package/ccw/dist/cli.js.map +1 -1
  66. package/ccw/dist/commands/cli.d.ts +1 -0
  67. package/ccw/dist/commands/cli.d.ts.map +1 -1
  68. package/ccw/dist/commands/cli.js +74 -6
  69. package/ccw/dist/commands/cli.js.map +1 -1
  70. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  71. package/ccw/dist/core/routes/cli-routes.js +16 -1
  72. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  73. package/ccw/dist/core/routes/help-routes.d.ts.map +1 -1
  74. package/ccw/dist/core/routes/help-routes.js +51 -1
  75. package/ccw/dist/core/routes/help-routes.js.map +1 -1
  76. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  77. package/ccw/dist/tools/cli-executor-core.js +5 -3
  78. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  79. package/ccw/dist/tools/cli-executor-utils.d.ts +1 -0
  80. package/ccw/dist/tools/cli-executor-utils.d.ts.map +1 -1
  81. package/ccw/dist/tools/cli-executor-utils.js +3 -1
  82. package/ccw/dist/tools/cli-executor-utils.js.map +1 -1
  83. package/ccw/src/cli.ts +1 -0
  84. package/ccw/src/commands/cli.ts +77 -6
  85. package/ccw/src/core/routes/cli-routes.ts +16 -1
  86. package/ccw/src/core/routes/help-routes.ts +60 -1
  87. package/ccw/src/templates/dashboard-js/views/help.js +423 -1
  88. package/ccw/src/tools/cli-executor-core.ts +6 -3
  89. package/ccw/src/tools/cli-executor-utils.ts +5 -2
  90. package/package.json +1 -1
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: codex-issue-plan-execute
3
+ description: Autonomous issue planning and execution workflow for Codex. Supports batch issue processing with integrated planning, queuing, and execution stages. Triggers on "codex-issue", "plan execute issue", "issue workflow".
4
+ allowed-tools: Task, AskUserQuestion, Read, Write, Bash, Glob, Grep
5
+ ---
6
+
7
+ # Codex Issue Plan-Execute Workflow
8
+
9
+ Streamlined autonomous workflow for Codex that integrates issue planning, queue management, and solution execution in a single stateful Skill. Supports batch processing with minimal queue overhead and dual-agent execution strategy.
10
+
11
+ ## Architecture Overview
12
+
13
+ ```
14
+ ┌─────────────────────────────────────────────────────────────────────┐
15
+ │ Main Orchestrator (Claude Code Entry Point) │
16
+ │ • Loads issues │
17
+ │ • Spawns persistent agents │
18
+ │ • Manages pipeline flow │
19
+ └──────┬──────────────────────────────────────┬──────────────────────┘
20
+ │ spawn_agent(planning-system-prompt) │ spawn_agent(execution-system-prompt)
21
+ │ (创建一次) │ (创建一次)
22
+ ▼ ▼
23
+ ┌─────────────────────────────┐ ┌────────────────────────────────┐
24
+ │ Planning Agent │ │ Execution Agent │
25
+ │ (持久化 - 不关闭) │ │ (持久化 - 不关闭) │
26
+ │ │ │ │
27
+ │ Loop: receive issue → │ │ Loop: receive solution → │
28
+ │ analyze & design │ │ implement & test │
29
+ │ return solution │ │ return results │
30
+ └────────┬────────────────────┘ └────────┬─────────────────────┘
31
+ │ send_input(issue) │ send_input(solution)
32
+ │ wait for response │ wait for response
33
+ │ (逐个 issue) │ (逐个 solution)
34
+ ▼ ▼
35
+ Planning Results Execution Results
36
+ (unified JSON) (unified JSON)
37
+ ```
38
+
39
+
40
+ ## Key Design Principles
41
+
42
+ 1. **Persistent Agent Architecture**: Two long-running agents (Planning + Execution) that never close until all work completes
43
+ 2. **Pipeline Flow**: Main orchestrator feeds issues sequentially to Planning Agent via `send_input`, then feeds solutions to Execution Agent via `send_input`
44
+ 3. **Unified Results Storage**: Single JSON files (`planning-results.json`, `execution-results.json`) accumulate all results instead of per-issue files
45
+ 4. **Context Preservation**: Agents maintain context across multiple tasks without being recreated
46
+ 5. **Efficient Communication**: Uses `send_input()` mechanism to communicate with agents without spawn/close overhead
47
+
48
+ ---
49
+
50
+ ## ⚠️ Mandatory Prerequisites (强制前置条件)
51
+
52
+ > **⛔ 禁止跳过**: 在执行任何操作之前,**必须**阅读以下两份P0规范文档。未理解规范直接执行将导致输出质量不符合标准。
53
+
54
+ | Document | Purpose | When |
55
+ |----------|---------|------|
56
+ | [specs/issue-handling.md](specs/issue-handling.md) | Issue 处理规范和数据结构 | **执行前必读** |
57
+ | [specs/solution-schema.md](specs/solution-schema.md) | 解决方案数据结构和验证规则 | **执行前必读** |
58
+
59
+ ---
60
+
61
+ ## Execution Flow
62
+
63
+ ### Phase 1: Initialize Persistent Agents
64
+ → **查阅**: [phases/orchestrator.md](phases/orchestrator.md) - 理解编排逻辑
65
+ → Spawn Planning Agent with `planning-agent-system.md` prompt (stays alive)
66
+ → Spawn Execution Agent with `execution-agent-system.md` prompt (stays alive)
67
+
68
+ ### Phase 2: Planning Pipeline
69
+ → **查阅**: [phases/actions/action-plan.md](phases/actions/action-plan.md), [specs/subagent-roles.md](specs/subagent-roles.md)
70
+ For each issue sequentially:
71
+ 1. Send issue to Planning Agent via `send_input()` with planning request
72
+ 2. Wait for Planning Agent to return solution JSON
73
+ 3. Store result in unified `planning-results.json` array
74
+ 4. Continue to next issue (agent stays alive)
75
+
76
+ ### Phase 3: Execution Pipeline
77
+ → **查阅**: [phases/actions/action-execute.md](phases/actions/action-execute.md), [specs/quality-standards.md](specs/quality-standards.md)
78
+ For each successful planning result sequentially:
79
+ 1. Send solution to Execution Agent via `send_input()` with execution request
80
+ 2. Wait for Execution Agent to complete implementation and testing
81
+ 3. Store result in unified `execution-results.json` array
82
+ 4. Continue to next solution (agent stays alive)
83
+
84
+ ### Phase 4: Finalize
85
+ → **查阅**: [phases/actions/action-complete.md](phases/actions/action-complete.md)
86
+ → Close Planning Agent (after all issues planned)
87
+ → Close Execution Agent (after all solutions executed)
88
+ → Generate final report with statistics
89
+
90
+ ### State Schema
91
+
92
+ ```json
93
+ {
94
+ "status": "pending|running|completed",
95
+ "phase": "init|listing|planning|executing|complete",
96
+ "issues": {
97
+ "{issue_id}": {
98
+ "id": "ISS-xxx",
99
+ "status": "registered|planning|planned|executing|completed",
100
+ "solution_id": "SOL-xxx-1",
101
+ "planned_at": "ISO-8601",
102
+ "executed_at": "ISO-8601"
103
+ }
104
+ },
105
+ "queue": [
106
+ {
107
+ "item_id": "S-1",
108
+ "issue_id": "ISS-xxx",
109
+ "solution_id": "SOL-xxx-1",
110
+ "status": "pending|executing|completed"
111
+ }
112
+ ],
113
+ "context": {
114
+ "work_dir": ".workflow/.scratchpad/...",
115
+ "total_issues": 0,
116
+ "completed_count": 0,
117
+ "failed_count": 0
118
+ },
119
+ "errors": []
120
+ }
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Directory Setup
126
+
127
+ ```javascript
128
+ const timestamp = new Date().toISOString().slice(0,19).replace(/[-:T]/g, '');
129
+ const workDir = `.workflow/.scratchpad/codex-issue-${timestamp}`;
130
+
131
+ Bash(`mkdir -p "${workDir}"`);
132
+ Bash(`mkdir -p "${workDir}/solutions"`);
133
+ Bash(`mkdir -p "${workDir}/snapshots"`);
134
+ ```
135
+
136
+ ## Output Structure
137
+
138
+ ```
139
+ .workflow/.scratchpad/codex-issue-{timestamp}/
140
+ ├── planning-results.json # All planning results in single file
141
+ │ ├── phase: "planning"
142
+ │ ├── created_at: "ISO-8601"
143
+ │ └── results: [
144
+ │ { issue_id, solution_id, status, solution, planned_at }
145
+ │ ]
146
+ ├── execution-results.json # All execution results in single file
147
+ │ ├── phase: "execution"
148
+ │ ├── created_at: "ISO-8601"
149
+ │ └── results: [
150
+ │ { issue_id, solution_id, status, commit_hash, files_modified, executed_at }
151
+ │ ]
152
+ └── final-report.md # Summary statistics and report
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Reference Documents by Phase
158
+
159
+ ### 🔧 Setup & Understanding (初始化阶段)
160
+ 用于理解整个系统架构和执行流程
161
+
162
+ | Document | Purpose | Key Topics |
163
+ |----------|---------|-----------|
164
+ | [phases/orchestrator.md](phases/orchestrator.md) | 编排器核心逻辑 | 如何管理agents、pipeline流程、状态转换 |
165
+ | [phases/state-schema.md](phases/state-schema.md) | 状态结构定义 | 完整状态模型、验证规则、持久化 |
166
+ | [specs/subagent-roles.md](specs/subagent-roles.md) | Subagent角色定义 | Planning Agent & Execution Agent职责 |
167
+
168
+ ### 📋 Planning Phase (规划阶段)
169
+ 执行Phase 2时查阅 - Planning逻辑和Issue处理
170
+
171
+ | Document | Purpose | When to Use |
172
+ |----------|---------|-------------|
173
+ | [phases/actions/action-plan.md](phases/actions/action-plan.md) | Planning流程详解 | 理解issue→solution转换逻辑 |
174
+ | [phases/actions/action-list.md](phases/actions/action-list.md) | Issue列表处理 | 学习issue加载和列举逻辑 |
175
+ | [specs/issue-handling.md](specs/issue-handling.md) | Issue数据规范 | 理解issue结构和验证规则 ✅ **必读** |
176
+ | [specs/solution-schema.md](specs/solution-schema.md) | 解决方案数据结构 | 了解solution JSON格式 ✅ **必读** |
177
+
178
+ ### ⚙️ Execution Phase (执行阶段)
179
+ 执行Phase 3时查阅 - 实现和验证逻辑
180
+
181
+ | Document | Purpose | When to Use |
182
+ |----------|---------|-------------|
183
+ | [phases/actions/action-execute.md](phases/actions/action-execute.md) | Execution流程详解 | 理解solution→implementation逻辑 |
184
+ | [specs/quality-standards.md](specs/quality-standards.md) | 质量标准和验收条件 | 检查implementation是否达标 |
185
+
186
+ ### 🏁 Completion Phase (完成阶段)
187
+ 执行Phase 4时查阅 - 收尾和报告逻辑
188
+
189
+ | Document | Purpose | When to Use |
190
+ |----------|---------|-------------|
191
+ | [phases/actions/action-complete.md](phases/actions/action-complete.md) | 完成流程 | 生成最终报告、统计信息 |
192
+
193
+ ### 🔍 Debugging & Troubleshooting (问题排查)
194
+ 遇到问题时查阅 - 快速定位和解决
195
+
196
+ | Issue | Solution Document |
197
+ |-------|------------------|
198
+ | 执行过程中状态异常 | [phases/state-schema.md](phases/state-schema.md) - 验证状态结构 |
199
+ | Planning Agent输出不符合预期 | [phases/actions/action-plan.md](phases/actions/action-plan.md) + [specs/solution-schema.md](specs/solution-schema.md) |
200
+ | Execution Agent实现失败 | [phases/actions/action-execute.md](phases/actions/action-execute.md) + [specs/quality-standards.md](specs/quality-standards.md) |
201
+ | Issue数据格式错误 | [specs/issue-handling.md](specs/issue-handling.md) |
202
+
203
+ ### 📚 Reference & Background (深度学习)
204
+ 用于理解原始实现和设计决策
205
+
206
+ | Document | Purpose | Notes |
207
+ |----------|---------|-------|
208
+ | [../issue-plan.md](../../.codex/prompts/issue-plan.md) | Codex Issue Plan 原始实现 | Planning Agent system prompt原型 |
209
+ | [../issue-execute.md](../../.codex/prompts/issue-execute.md) | Codex Issue Execute 原始实现 | Execution Agent system prompt原型 |
210
+ | [../codex SUBAGENT 策略补充.md](../../workflow/.scratchpad/codex%20SUBAGENT%20策略补充.md) | Subagent使用指南 | Agent交互最佳实践 |
211
+
212
+ ---
213
+
214
+ ## Usage Examples
215
+
216
+ ### Batch Process Specific Issues
217
+
218
+ ```bash
219
+ codex -p "@.codex/prompts/codex-issue-plan-execute ISS-001,ISS-002,ISS-003"
220
+ ```
221
+
222
+ ### Interactive Selection
223
+
224
+ ```bash
225
+ codex -p "@.codex/prompts/codex-issue-plan-execute"
226
+ # Then select issues from the list
227
+ ```
228
+
229
+ ### Resume from Snapshot
230
+
231
+ ```bash
232
+ codex -p "@.codex/prompts/codex-issue-plan-execute --resume snapshot-path"
233
+ ```
234
+
235
+ ---
236
+
237
+ *Skill Version: 1.0*
238
+ *Execution Mode: Autonomous*
239
+ *Status: Ready for Customization*
@@ -0,0 +1,173 @@
1
+ # Action: Complete
2
+
3
+ 完成工作流并生成最终报告。
4
+
5
+ ## Purpose
6
+
7
+ 序列化最终状态,生成执行摘要,清理临时文件。
8
+
9
+ ## Preconditions
10
+
11
+ - [ ] `state.status === "running"`
12
+ - [ ] 所有 issues 已处理或错误限制达到
13
+
14
+ ## Execution
15
+
16
+ ```javascript
17
+ async function execute(state) {
18
+ const workDir = state.work_dir;
19
+ const issues = state.issues || {};
20
+
21
+ console.log("\n=== Finalizing Workflow ===");
22
+
23
+ // 1. 生成统计信息
24
+ const totalIssues = Object.keys(issues).length;
25
+ const completedCount = Object.values(issues).filter(i => i.status === "completed").length;
26
+ const failedCount = Object.values(issues).filter(i => i.status === "failed").length;
27
+ const pendingCount = totalIssues - completedCount - failedCount;
28
+
29
+ const stats = {
30
+ total_issues: totalIssues,
31
+ completed: completedCount,
32
+ failed: failedCount,
33
+ pending: pendingCount,
34
+ success_rate: totalIssues > 0 ? ((completedCount / totalIssues) * 100).toFixed(1) : 0,
35
+ duration_ms: new Date() - new Date(state.created_at)
36
+ };
37
+
38
+ console.log("\n=== Summary ===");
39
+ console.log(`Total Issues: ${stats.total_issues}`);
40
+ console.log(`✓ Completed: ${stats.completed}`);
41
+ console.log(`✗ Failed: ${stats.failed}`);
42
+ console.log(`○ Pending: ${stats.pending}`);
43
+ console.log(`Success Rate: ${stats.success_rate}%`);
44
+ console.log(`Duration: ${(stats.duration_ms / 1000).toFixed(1)}s`);
45
+
46
+ // 2. 生成详细报告
47
+ const reportLines = [
48
+ "# Execution Report",
49
+ "",
50
+ `## Summary`,
51
+ `- Total Issues: ${stats.total_issues}`,
52
+ `- Completed: ${stats.completed}`,
53
+ `- Failed: ${stats.failed}`,
54
+ `- Pending: ${stats.pending}`,
55
+ `- Success Rate: ${stats.success_rate}%`,
56
+ `- Duration: ${(stats.duration_ms / 1000).toFixed(1)}s`,
57
+ "",
58
+ "## Results by Issue"
59
+ ];
60
+
61
+ Object.values(issues).forEach((issue, index) => {
62
+ const status = issue.status === "completed" ? "✓" : issue.status === "failed" ? "✗" : "○";
63
+ reportLines.push(`### ${status} [${index + 1}] ${issue.id}: ${issue.title}`);
64
+ reportLines.push(`- Status: ${issue.status}`);
65
+ if (issue.solution_id) {
66
+ reportLines.push(`- Solution: ${issue.solution_id}`);
67
+ }
68
+ if (issue.planned_at) {
69
+ reportLines.push(`- Planned: ${issue.planned_at}`);
70
+ }
71
+ if (issue.executed_at) {
72
+ reportLines.push(`- Executed: ${issue.executed_at}`);
73
+ }
74
+ if (issue.error) {
75
+ reportLines.push(`- Error: ${issue.error}`);
76
+ }
77
+ reportLines.push("");
78
+ });
79
+
80
+ if (state.errors && state.errors.length > 0) {
81
+ reportLines.push("## Errors");
82
+ state.errors.forEach(error => {
83
+ reportLines.push(`- [${error.timestamp}] ${error.action}: ${error.message}`);
84
+ });
85
+ reportLines.push("");
86
+ }
87
+
88
+ reportLines.push("## Files Generated");
89
+ reportLines.push(`- Work Directory: ${workDir}`);
90
+ reportLines.push(`- State File: ${workDir}/state.json`);
91
+ reportLines.push(`- Execution Results: ${workDir}/execution-results.json`);
92
+ reportLines.push(`- Solutions: ${workDir}/solutions/`);
93
+ reportLines.push(`- Snapshots: ${workDir}/snapshots/`);
94
+
95
+ // 3. 保存报告
96
+ const reportPath = `${workDir}/final-report.md`;
97
+ Write(reportPath, reportLines.join("\n"));
98
+
99
+ // 4. 保存最终状态
100
+ const finalState = {
101
+ ...state,
102
+ status: "completed",
103
+ phase: "completed",
104
+ completed_at: new Date().toISOString(),
105
+ completed_actions: [...state.completed_actions, "action-complete"],
106
+ context: {
107
+ ...state.context,
108
+ ...stats
109
+ }
110
+ };
111
+
112
+ Write(`${workDir}/state.json`, JSON.stringify(finalState, null, 2));
113
+
114
+ // 5. 保存汇总 JSON
115
+ Write(`${workDir}/summary.json`, JSON.stringify({
116
+ status: "completed",
117
+ stats: stats,
118
+ report_file: reportPath,
119
+ work_dir: workDir,
120
+ completed_at: new Date().toISOString()
121
+ }, null, 2));
122
+
123
+ // 6. 输出完成消息
124
+ console.log(`\n✓ Workflow completed`);
125
+ console.log(`📄 Report: ${reportPath}`);
126
+ console.log(`📁 Working directory: ${workDir}`);
127
+
128
+ return {
129
+ stateUpdates: {
130
+ status: "completed",
131
+ phase: "completed",
132
+ completed_at: new Date().toISOString(),
133
+ completed_actions: [...state.completed_actions, "action-complete"],
134
+ context: finalState.context
135
+ }
136
+ };
137
+ }
138
+ ```
139
+
140
+ ## State Updates
141
+
142
+ ```javascript
143
+ return {
144
+ stateUpdates: {
145
+ status: "completed",
146
+ phase: "completed",
147
+ completed_at: timestamp,
148
+ completed_actions: [...state.completed_actions, "action-complete"],
149
+ context: {
150
+ total_issues: stats.total_issues,
151
+ completed_count: stats.completed,
152
+ failed_count: stats.failed,
153
+ success_rate: stats.success_rate
154
+ }
155
+ }
156
+ };
157
+ ```
158
+
159
+ ## Error Handling
160
+
161
+ | Error Type | Recovery |
162
+ |------------|----------|
163
+ | 报告生成失败 | 输出文本摘要到控制台 |
164
+ | 文件写入失败 | 继续完成,允许手动保存 |
165
+ | 权限错误 | 使用替代目录 |
166
+
167
+ ## Next Actions (Hints)
168
+
169
+ - 无(终止状态)
170
+ - 用户可选择:
171
+ - 查看报告:`cat {report_path}`
172
+ - 恢复并重试失败的 issues:`codex issue:plan-execute --resume {work_dir}`
173
+ - 清理临时文件:`rm -rf {work_dir}`
@@ -0,0 +1,220 @@
1
+ # Action: Execute Solutions
2
+
3
+ 按队列顺序执行已规划的解决方案。
4
+
5
+ ## Purpose
6
+
7
+ 加载计划的解决方案并使用 subagent 执行所有任务、提交更改。
8
+
9
+ ## Preconditions
10
+
11
+ - [ ] `state.status === "running"`
12
+ - [ ] `issues with solution_id` exist (来自规划阶段)
13
+
14
+ ## Execution
15
+
16
+ ```javascript
17
+ async function execute(state) {
18
+ const workDir = state.work_dir;
19
+ const issues = state.issues || {};
20
+ const queue = state.queue || [];
21
+
22
+ // 1. 构建执行队列(来自已规划的 issues)
23
+ const plannedIssues = Object.values(issues).filter(i => i.status === "planned");
24
+
25
+ if (plannedIssues.length === 0) {
26
+ console.log("No planned solutions to execute");
27
+ return { stateUpdates: { queue } };
28
+ }
29
+
30
+ console.log(`\n=== Executing ${plannedIssues.length} Solutions ===`);
31
+
32
+ // 2. 序列化执行每个解决方案
33
+ const executionResults = [];
34
+
35
+ for (let i = 0; i < plannedIssues.length; i++) {
36
+ const issue = plannedIssues[i];
37
+ const solutionId = issue.solution_id;
38
+
39
+ console.log(`\n[${i + 1}/${plannedIssues.length}] Executing: ${solutionId}`);
40
+
41
+ try {
42
+ // 创建快照(便于恢复)
43
+ const beforeSnapshot = {
44
+ timestamp: new Date().toISOString(),
45
+ phase: "before-execute",
46
+ issue_id: issue.id,
47
+ solution_id: solutionId,
48
+ state: { ...state }
49
+ };
50
+ Write(`${workDir}/snapshots/snapshot-before-execute-${i}.json`, JSON.stringify(beforeSnapshot, null, 2));
51
+
52
+ // 执行 subagent
53
+ const executionPrompt = `
54
+ ## TASK ASSIGNMENT
55
+
56
+ ### MANDATORY FIRST STEPS (Agent Execute)
57
+ 1. **Read role definition**: ~/.codex/agents/issue-execute-agent.md (MUST read first)
58
+ 2. Read: .workflow/project-tech.json
59
+ 3. Read: .workflow/project-guidelines.json
60
+
61
+ ---
62
+
63
+ Goal: Execute solution "${solutionId}" for issue "${issue.id}"
64
+
65
+ Scope:
66
+ - CAN DO: Implement tasks, run tests, commit code
67
+ - CANNOT DO: Push to remote or create PRs without approval
68
+ - Directory: ${process.cwd()}
69
+
70
+ Solution ID: ${solutionId}
71
+
72
+ Load solution details:
73
+ - Read: ${workDir}/solutions/${issue.id}-plan.json
74
+
75
+ Execution steps:
76
+ 1. Parse all tasks from solution
77
+ 2. Execute each task: implement → test → verify
78
+ 3. Commit once for all tasks with formatted summary
79
+ 4. Report completion
80
+
81
+ Quality bar:
82
+ - All acceptance criteria verified
83
+ - Tests passing
84
+ - Commit message follows conventions
85
+
86
+ Return: JSON with files_modified[], commit_hash, status
87
+ `;
88
+
89
+ const result = await Task({
90
+ subagent_type: "universal-executor",
91
+ run_in_background: false,
92
+ description: `Execute solution ${solutionId}`,
93
+ prompt: executionPrompt
94
+ });
95
+
96
+ // 解析执行结果
97
+ let execResult;
98
+ try {
99
+ execResult = typeof result === "string" ? JSON.parse(result) : result;
100
+ } catch {
101
+ execResult = { status: "executed", commit_hash: "unknown" };
102
+ }
103
+
104
+ // 保存执行结果
105
+ Write(`${workDir}/solutions/${issue.id}-execution.json`, JSON.stringify({
106
+ solution_id: solutionId,
107
+ issue_id: issue.id,
108
+ status: "completed",
109
+ executed_at: new Date().toISOString(),
110
+ execution_result: execResult
111
+ }, null, 2));
112
+
113
+ // 更新 issue 状态
114
+ issues[issue.id].status = "completed";
115
+ issues[issue.id].executed_at = new Date().toISOString();
116
+
117
+ // 更新队列项
118
+ const queueIndex = queue.findIndex(q => q.solution_id === solutionId);
119
+ if (queueIndex >= 0) {
120
+ queue[queueIndex].status = "completed";
121
+ }
122
+
123
+ // 更新 ccw
124
+ try {
125
+ Bash(`ccw issue update ${issue.id} --status completed`);
126
+ } catch (error) {
127
+ console.log(`Note: Could not update ccw status (${error.message})`);
128
+ }
129
+
130
+ console.log(`✓ ${solutionId} completed`);
131
+ executionResults.push({
132
+ issue_id: issue.id,
133
+ solution_id: solutionId,
134
+ status: "completed",
135
+ commit: execResult.commit_hash
136
+ });
137
+
138
+ state.context.completed_count++;
139
+
140
+ } catch (error) {
141
+ console.error(`✗ Execution failed for ${solutionId}: ${error.message}`);
142
+
143
+ // 更新失败状态
144
+ issues[issue.id].status = "failed";
145
+ issues[issue.id].error = error.message;
146
+
147
+ state.context.failed_count++;
148
+
149
+ executionResults.push({
150
+ issue_id: issue.id,
151
+ solution_id: solutionId,
152
+ status: "failed",
153
+ error: error.message
154
+ });
155
+ }
156
+ }
157
+
158
+ // 3. 保存执行结果摘要
159
+ Write(`${workDir}/execution-results.json`, JSON.stringify({
160
+ total: plannedIssues.length,
161
+ completed: state.context.completed_count,
162
+ failed: state.context.failed_count,
163
+ results: executionResults,
164
+ timestamp: new Date().toISOString()
165
+ }, null, 2));
166
+
167
+ return {
168
+ stateUpdates: {
169
+ issues: issues,
170
+ queue: queue,
171
+ context: state.context,
172
+ completed_actions: [...state.completed_actions, "action-execute"]
173
+ }
174
+ };
175
+ }
176
+ ```
177
+
178
+ ## State Updates
179
+
180
+ ```javascript
181
+ return {
182
+ stateUpdates: {
183
+ issues: {
184
+ [issue.id]: {
185
+ ...issue,
186
+ status: "completed|failed",
187
+ executed_at: timestamp,
188
+ error: errorMessage
189
+ }
190
+ },
191
+ queue: [
192
+ ...queue.map(item =>
193
+ item.solution_id === solutionId
194
+ ? { ...item, status: "completed|failed" }
195
+ : item
196
+ )
197
+ ],
198
+ context: {
199
+ ...state.context,
200
+ completed_count: newCompletedCount,
201
+ failed_count: newFailedCount
202
+ }
203
+ }
204
+ };
205
+ ```
206
+
207
+ ## Error Handling
208
+
209
+ | Error Type | Recovery |
210
+ |------------|----------|
211
+ | 任务执行失败 | 标记为失败,继续下一个 |
212
+ | 测试失败 | 不提交,标记为失败 |
213
+ | 提交失败 | 保存快照便于恢复 |
214
+ | Subagent 超时 | 记录超时,继续 |
215
+
216
+ ## Next Actions (Hints)
217
+
218
+ - 执行完成:转入 action-complete 阶段
219
+ - 有失败项:用户选择是否重试
220
+ - 全部完成:生成最终报告