claude-code-workflow 6.3.51 → 6.3.53
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.
- package/.claude/agents/cli-lite-planning-agent.md +66 -2
- package/.claude/commands/codex-coordinator.md +513 -0
- package/.claude/commands/workflow/collaborative-plan-with-file.md +761 -0
- package/.claude/commands/workflow/lite-fix.md +49 -20
- package/.claude/commands/workflow/lite-plan.md +35 -8
- package/.claude/commands/workflow/unified-execute-with-file.md +101 -4
- package/.codex/prompts/brainstorm-with-file.md +99 -32
- package/.codex/prompts/merge-plans-with-file.md +530 -0
- package/.codex/skills/codex-issue-plan-execute/SKILL.md +17 -42
- package/.codex/skills/codex-issue-plan-execute/phases/orchestrator.md +2 -0
- package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent-system.md +32 -136
- package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent.md +323 -135
- package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent-system.md +32 -107
- package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent.md +224 -122
- package/.codex/skills/codex-issue-plan-execute/specs/agent-roles.md +468 -0
- package/.codex/skills/codex-issue-plan-execute/specs/subagent-roles.md +32 -268
- package/ccw/dist/tools/claude-cli-tools.d.ts +8 -0
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +13 -2
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor-core.js +24 -3
- package/ccw/dist/tools/cli-executor-core.js.map +1 -1
- package/ccw/dist/tools/cli-executor-utils.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor-utils.js +6 -0
- package/ccw/dist/tools/cli-executor-utils.js.map +1 -1
- package/ccw/src/templates/dashboard-js/components/cli-status.js +28 -0
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +44 -0
- package/ccw/src/tools/claude-cli-tools.ts +20 -2
- package/ccw/src/tools/cli-executor-core.ts +23 -4
- package/ccw/src/tools/cli-executor-utils.ts +6 -0
- package/package.json +1 -1
- package/.codex/prompts/UNIFIED_EXECUTE_COMPARISON.md +0 -205
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cli-lite-planning-agent
|
|
3
3
|
description: |
|
|
4
|
-
Generic planning agent for lite-plan and lite-fix workflows. Generates structured plan JSON based on provided schema reference.
|
|
4
|
+
Generic planning agent for lite-plan, collaborative-plan, and lite-fix workflows. Generates structured plan JSON based on provided schema reference.
|
|
5
5
|
|
|
6
6
|
Core capabilities:
|
|
7
7
|
- Schema-driven output (plan-json-schema or fix-plan-json-schema)
|
|
8
8
|
- Task decomposition with dependency analysis
|
|
9
9
|
- CLI execution ID assignment for fork/merge strategies
|
|
10
10
|
- Multi-angle context integration (explorations or diagnoses)
|
|
11
|
+
- Process documentation (planning-context.md) for collaborative workflows
|
|
11
12
|
color: cyan
|
|
12
13
|
---
|
|
13
14
|
|
|
@@ -15,6 +16,40 @@ You are a generic planning agent that generates structured plan JSON for lite wo
|
|
|
15
16
|
|
|
16
17
|
**CRITICAL**: After generating plan.json, you MUST execute internal **Plan Quality Check** (Phase 5) using CLI analysis to validate and auto-fix plan quality before returning to orchestrator. Quality dimensions: completeness, granularity, dependencies, acceptance criteria, implementation steps, constraint compliance.
|
|
17
18
|
|
|
19
|
+
## Output Artifacts
|
|
20
|
+
|
|
21
|
+
The agent produces different artifacts based on workflow context:
|
|
22
|
+
|
|
23
|
+
### Standard Output (lite-plan, lite-fix)
|
|
24
|
+
|
|
25
|
+
| Artifact | Description |
|
|
26
|
+
|----------|-------------|
|
|
27
|
+
| `plan.json` | Structured plan following plan-json-schema.json |
|
|
28
|
+
|
|
29
|
+
### Extended Output (collaborative-plan sub-agents)
|
|
30
|
+
|
|
31
|
+
When invoked with `process_docs: true` in input context:
|
|
32
|
+
|
|
33
|
+
| Artifact | Description |
|
|
34
|
+
|----------|-------------|
|
|
35
|
+
| `planning-context.md` | Evidence paths + synthesized understanding (insights, decisions, approach) |
|
|
36
|
+
| `sub-plan.json` | Sub-plan following plan-json-schema.json with source_agent metadata |
|
|
37
|
+
|
|
38
|
+
**planning-context.md format**:
|
|
39
|
+
```markdown
|
|
40
|
+
# Planning Context: {focus_area}
|
|
41
|
+
|
|
42
|
+
## Source Evidence
|
|
43
|
+
- `exploration-{angle}.json` - {key finding}
|
|
44
|
+
- `{file}:{line}` - {what this proves}
|
|
45
|
+
|
|
46
|
+
## Understanding
|
|
47
|
+
- Current state: {analysis}
|
|
48
|
+
- Proposed approach: {strategy}
|
|
49
|
+
|
|
50
|
+
## Key Decisions
|
|
51
|
+
- Decision: {what} | Rationale: {why} | Evidence: {file ref}
|
|
52
|
+
```
|
|
18
53
|
|
|
19
54
|
## Input Context
|
|
20
55
|
|
|
@@ -34,10 +69,39 @@ You are a generic planning agent that generates structured plan JSON for lite wo
|
|
|
34
69
|
clarificationContext: { [question]: answer } | null,
|
|
35
70
|
complexity: "Low" | "Medium" | "High", // For lite-plan
|
|
36
71
|
severity: "Low" | "Medium" | "High" | "Critical", // For lite-fix
|
|
37
|
-
cli_config: { tool, template, timeout, fallback }
|
|
72
|
+
cli_config: { tool, template, timeout, fallback },
|
|
73
|
+
|
|
74
|
+
// Process documentation (collaborative-plan)
|
|
75
|
+
process_docs: boolean, // If true, generate planning-context.md
|
|
76
|
+
focus_area: string, // Sub-requirement focus area (collaborative-plan)
|
|
77
|
+
output_folder: string // Where to write process docs (collaborative-plan)
|
|
38
78
|
}
|
|
39
79
|
```
|
|
40
80
|
|
|
81
|
+
## Process Documentation (collaborative-plan)
|
|
82
|
+
|
|
83
|
+
When `process_docs: true`, generate planning-context.md before sub-plan.json:
|
|
84
|
+
|
|
85
|
+
```markdown
|
|
86
|
+
# Planning Context: {focus_area}
|
|
87
|
+
|
|
88
|
+
## Source Evidence
|
|
89
|
+
- `exploration-{angle}.json` - {key finding from exploration}
|
|
90
|
+
- `{file}:{line}` - {code evidence for decision}
|
|
91
|
+
|
|
92
|
+
## Understanding
|
|
93
|
+
- **Current State**: {what exists now}
|
|
94
|
+
- **Problem**: {what needs to change}
|
|
95
|
+
- **Approach**: {proposed solution strategy}
|
|
96
|
+
|
|
97
|
+
## Key Decisions
|
|
98
|
+
- Decision: {what} | Rationale: {why} | Evidence: {file:line or exploration ref}
|
|
99
|
+
|
|
100
|
+
## Dependencies
|
|
101
|
+
- Depends on: {other sub-requirements or none}
|
|
102
|
+
- Provides for: {what this enables}
|
|
103
|
+
```
|
|
104
|
+
|
|
41
105
|
## Schema-Driven Output
|
|
42
106
|
|
|
43
107
|
**CRITICAL**: Read the schema reference first to determine output structure:
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codex-coordinator
|
|
3
|
+
description: Command orchestration tool for Codex - analyze requirements, recommend command chain, execute sequentially with state persistence
|
|
4
|
+
argument-hint: "TASK=\"<task description>\" [--depth=standard|deep] [--auto-confirm] [--verbose]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Codex Coordinator Command
|
|
8
|
+
|
|
9
|
+
Interactive orchestration tool for Codex commands: analyze task → discover commands → recommend chain → execute sequentially → track state.
|
|
10
|
+
|
|
11
|
+
**Execution Model**: Intelligent agent-driven workflow. Claude analyzes each phase and orchestrates command execution.
|
|
12
|
+
|
|
13
|
+
## Core Concept: Minimum Execution Units (最小执行单元)
|
|
14
|
+
|
|
15
|
+
### What is a Minimum Execution Unit?
|
|
16
|
+
|
|
17
|
+
**Definition**: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone. Splitting these commands breaks the logical flow and creates incomplete states.
|
|
18
|
+
|
|
19
|
+
**Why This Matters**:
|
|
20
|
+
- **Prevents Incomplete States**: Avoid stopping after task generation without execution
|
|
21
|
+
- **User Experience**: User gets complete results, not intermediate artifacts requiring manual follow-up
|
|
22
|
+
- **Workflow Integrity**: Maintains logical coherence of multi-step operations
|
|
23
|
+
|
|
24
|
+
### Codex Minimum Execution Units
|
|
25
|
+
|
|
26
|
+
**Planning + Execution Units** (规划+执行单元):
|
|
27
|
+
|
|
28
|
+
| Unit Name | Commands | Purpose | Output |
|
|
29
|
+
|-----------|----------|---------|--------|
|
|
30
|
+
| **Quick Implementation** | lite-plan-a → execute | Lightweight plan and immediate execution | Working code |
|
|
31
|
+
| **Bug Fix** | lite-fix → execute | Quick bug diagnosis and fix execution | Fixed code |
|
|
32
|
+
| **Issue Workflow** | issue-discover → issue-plan → issue-queue → issue-execute | Complete issue lifecycle | Completed issues |
|
|
33
|
+
| **Discovery & Analysis** | issue-discover → issue-discover-by-prompt | Issue discovery with multiple perspectives | Generated issues |
|
|
34
|
+
| **Brainstorm to Execution** | brainstorm-with-file → execute | Brainstorm ideas then implement | Working code |
|
|
35
|
+
|
|
36
|
+
**With-File Workflows** (文档化单元):
|
|
37
|
+
|
|
38
|
+
| Unit Name | Commands | Purpose | Output |
|
|
39
|
+
|-----------|----------|---------|--------|
|
|
40
|
+
| **Brainstorm With File** | brainstorm-with-file | Multi-perspective ideation with documentation | brainstorm.md |
|
|
41
|
+
| **Debug With File** | debug-with-file | Hypothesis-driven debugging with documentation | understanding.md |
|
|
42
|
+
| **Analyze With File** | analyze-with-file | Collaborative analysis with documentation | discussion.md |
|
|
43
|
+
| **Clean & Analyze** | clean → analyze-with-file | Cleanup then analyze | Cleaned code + analysis |
|
|
44
|
+
|
|
45
|
+
### Command-to-Unit Mapping (命令与最小单元的映射)
|
|
46
|
+
|
|
47
|
+
| Command | Precedes | Atomic Units |
|
|
48
|
+
|---------|----------|--------------|
|
|
49
|
+
| lite-plan-a | execute, brainstorm-with-file | Quick Implementation |
|
|
50
|
+
| lite-fix | execute | Bug Fix |
|
|
51
|
+
| issue-discover | issue-plan | Issue Workflow |
|
|
52
|
+
| issue-plan | issue-queue | Issue Workflow |
|
|
53
|
+
| issue-queue | issue-execute | Issue Workflow |
|
|
54
|
+
| brainstorm-with-file | execute, issue-execute | Brainstorm to Execution |
|
|
55
|
+
| debug-with-file | execute | Debug With File |
|
|
56
|
+
| analyze-with-file | (standalone) | Analyze With File |
|
|
57
|
+
| clean | analyze-with-file, execute | Clean & Analyze |
|
|
58
|
+
| quick-plan-with-file | execute | Quick Planning with File |
|
|
59
|
+
| merge-plans-with-file | execute | Merge Multiple Plans |
|
|
60
|
+
| unified-execute-with-file | (terminal) | Execute with File Tracking |
|
|
61
|
+
|
|
62
|
+
### Atomic Group Rules
|
|
63
|
+
|
|
64
|
+
1. **Never Split Units**: Coordinator must recommend complete units, not partial chains
|
|
65
|
+
2. **Multi-Unit Participation**: Some commands can participate in multiple units
|
|
66
|
+
3. **User Override**: User can explicitly request partial execution (advanced mode)
|
|
67
|
+
4. **Visualization**: Pipeline view shows unit boundaries with 【 】markers
|
|
68
|
+
5. **Validation**: Before execution, verify all unit commands are included
|
|
69
|
+
|
|
70
|
+
**Example Pipeline with Units**:
|
|
71
|
+
```
|
|
72
|
+
需求 → 【lite-plan-a → execute】→ 代码 → 【issue-discover → issue-plan → issue-queue → issue-execute】→ 完成
|
|
73
|
+
└──── Quick Implementation ────┘ └────────── Issue Workflow ─────────┘
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 3-Phase Workflow
|
|
77
|
+
|
|
78
|
+
### Phase 1: Analyze Requirements
|
|
79
|
+
|
|
80
|
+
Parse task to extract: goal, scope, complexity, and task type.
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
function analyzeRequirements(taskDescription) {
|
|
84
|
+
return {
|
|
85
|
+
goal: extractMainGoal(taskDescription), // e.g., "Fix login bug"
|
|
86
|
+
scope: extractScope(taskDescription), // e.g., ["auth", "login"]
|
|
87
|
+
complexity: determineComplexity(taskDescription), // 'simple' | 'medium' | 'complex'
|
|
88
|
+
task_type: detectTaskType(taskDescription) // See task type patterns below
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Task Type Detection Patterns
|
|
93
|
+
function detectTaskType(text) {
|
|
94
|
+
// Priority order (first match wins)
|
|
95
|
+
if (/fix|bug|error|crash|fail|debug|diagnose/.test(text)) return 'bugfix';
|
|
96
|
+
if (/生成|generate|discover|找出|issue|问题/.test(text)) return 'discovery';
|
|
97
|
+
if (/plan|规划|设计|design|analyze|分析/.test(text)) return 'analysis';
|
|
98
|
+
if (/清理|cleanup|clean|refactor|重构/.test(text)) return 'cleanup';
|
|
99
|
+
if (/头脑|brainstorm|创意|ideation/.test(text)) return 'brainstorm';
|
|
100
|
+
if (/合并|merge|combine|batch/.test(text)) return 'batch-planning';
|
|
101
|
+
return 'feature'; // Default
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Complexity Assessment
|
|
105
|
+
function determineComplexity(text) {
|
|
106
|
+
let score = 0;
|
|
107
|
+
if (/refactor|重构|migrate|迁移|architect|架构|system|系统/.test(text)) score += 2;
|
|
108
|
+
if (/multiple|多个|across|跨|all|所有|entire|整个/.test(text)) score += 2;
|
|
109
|
+
if (/integrate|集成|api|database|数据库/.test(text)) score += 1;
|
|
110
|
+
if (/security|安全|performance|性能|scale|扩展/.test(text)) score += 1;
|
|
111
|
+
return score >= 4 ? 'complex' : score >= 2 ? 'medium' : 'simple';
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Display to user**:
|
|
116
|
+
```
|
|
117
|
+
Analysis Complete:
|
|
118
|
+
Goal: [extracted goal]
|
|
119
|
+
Scope: [identified areas]
|
|
120
|
+
Complexity: [level]
|
|
121
|
+
Task Type: [detected type]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Phase 2: Discover Commands & Recommend Chain
|
|
125
|
+
|
|
126
|
+
Dynamic command chain assembly using task type and complexity matching.
|
|
127
|
+
|
|
128
|
+
#### Available Codex Commands (Discovery)
|
|
129
|
+
|
|
130
|
+
All commands from `~/.codex/prompts/`:
|
|
131
|
+
- **Planning**: @~/.codex/prompts/lite-plan-a.md, @~/.codex/prompts/lite-plan-b.md, @~/.codex/prompts/lite-plan-c.md, @~/.codex/prompts/quick-plan-with-file.md, @~/.codex/prompts/merge-plans-with-file.md
|
|
132
|
+
- **Execution**: @~/.codex/prompts/execute.md, @~/.codex/prompts/unified-execute-with-file.md
|
|
133
|
+
- **Bug Fixes**: @~/.codex/prompts/lite-fix.md, @~/.codex/prompts/debug-with-file.md
|
|
134
|
+
- **Discovery**: @~/.codex/prompts/issue-discover.md, @~/.codex/prompts/issue-discover-by-prompt.md, @~/.codex/prompts/issue-plan.md, @~/.codex/prompts/issue-queue.md, @~/.codex/prompts/issue-execute.md
|
|
135
|
+
- **Analysis**: @~/.codex/prompts/analyze-with-file.md
|
|
136
|
+
- **Brainstorming**: @~/.codex/prompts/brainstorm-with-file.md, @~/.codex/prompts/brainstorm-to-cycle.md
|
|
137
|
+
- **Cleanup**: @~/.codex/prompts/clean.md, @~/.codex/prompts/compact.md
|
|
138
|
+
|
|
139
|
+
#### Recommendation Algorithm
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
async function recommendCommandChain(analysis) {
|
|
143
|
+
// Step 1: 根据任务类型确定流程
|
|
144
|
+
const { inputPort, outputPort } = determinePortFlow(analysis.task_type, analysis.complexity);
|
|
145
|
+
|
|
146
|
+
// Step 2: Claude 根据命令特性和任务特征,智能选择命令序列
|
|
147
|
+
const chain = selectChainByTaskType(analysis);
|
|
148
|
+
|
|
149
|
+
return chain;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 任务类型对应的端口流
|
|
153
|
+
function determinePortFlow(taskType, complexity) {
|
|
154
|
+
const flows = {
|
|
155
|
+
'bugfix': { flow: ['lite-fix', 'execute'], depth: complexity === 'complex' ? 'deep' : 'standard' },
|
|
156
|
+
'discovery': { flow: ['issue-discover', 'issue-plan', 'issue-queue', 'issue-execute'], depth: 'standard' },
|
|
157
|
+
'analysis': { flow: ['analyze-with-file'], depth: complexity === 'complex' ? 'deep' : 'standard' },
|
|
158
|
+
'cleanup': { flow: ['clean'], depth: 'standard' },
|
|
159
|
+
'brainstorm': { flow: ['brainstorm-with-file', 'execute'], depth: complexity === 'complex' ? 'deep' : 'standard' },
|
|
160
|
+
'batch-planning': { flow: ['merge-plans-with-file', 'execute'], depth: 'standard' },
|
|
161
|
+
'feature': { flow: complexity === 'complex' ? ['lite-plan-b'] : ['lite-plan-a', 'execute'], depth: complexity === 'complex' ? 'deep' : 'standard' }
|
|
162
|
+
};
|
|
163
|
+
return flows[taskType] || flows['feature'];
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Display to User
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
Recommended Command Chain:
|
|
171
|
+
|
|
172
|
+
Pipeline (管道视图):
|
|
173
|
+
需求 → @~/.codex/prompts/lite-plan-a.md → 计划 → @~/.codex/prompts/execute.md → 代码完成
|
|
174
|
+
|
|
175
|
+
Commands (命令列表):
|
|
176
|
+
1. @~/.codex/prompts/lite-plan-a.md
|
|
177
|
+
2. @~/.codex/prompts/execute.md
|
|
178
|
+
|
|
179
|
+
Proceed? [Confirm / Show Details / Adjust / Cancel]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Phase 2b: Get User Confirmation
|
|
183
|
+
|
|
184
|
+
Ask user for confirmation before proceeding with execution.
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
async function getUserConfirmation(chain) {
|
|
188
|
+
const response = await AskUserQuestion({
|
|
189
|
+
questions: [{
|
|
190
|
+
question: 'Proceed with this command chain?',
|
|
191
|
+
header: 'Confirm Chain',
|
|
192
|
+
multiSelect: false,
|
|
193
|
+
options: [
|
|
194
|
+
{ label: 'Confirm and execute', description: 'Proceed with commands' },
|
|
195
|
+
{ label: 'Show details', description: 'View each command' },
|
|
196
|
+
{ label: 'Adjust chain', description: 'Remove or reorder' },
|
|
197
|
+
{ label: 'Cancel', description: 'Abort' }
|
|
198
|
+
]
|
|
199
|
+
}]
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
return response;
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Phase 3: Execute Sequential Command Chain
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
async function executeCommandChain(chain, analysis) {
|
|
210
|
+
const sessionId = `codex-coord-${Date.now()}`;
|
|
211
|
+
const stateDir = `.workflow/.codex-coordinator/${sessionId}`;
|
|
212
|
+
|
|
213
|
+
// Create state directory
|
|
214
|
+
const state = {
|
|
215
|
+
session_id: sessionId,
|
|
216
|
+
status: 'running',
|
|
217
|
+
created_at: new Date().toISOString(),
|
|
218
|
+
analysis: analysis,
|
|
219
|
+
command_chain: chain.map((cmd, idx) => ({ ...cmd, index: idx, status: 'pending' })),
|
|
220
|
+
execution_results: [],
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// Save initial state
|
|
224
|
+
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
|
225
|
+
|
|
226
|
+
for (let i = 0; i < chain.length; i++) {
|
|
227
|
+
const cmd = chain[i];
|
|
228
|
+
console.log(`[${i+1}/${chain.length}] Executing: @~/.codex/prompts/${cmd.name}.md`);
|
|
229
|
+
|
|
230
|
+
// Update status to running
|
|
231
|
+
state.command_chain[i].status = 'running';
|
|
232
|
+
state.updated_at = new Date().toISOString();
|
|
233
|
+
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
// Build command with parameters using full path
|
|
237
|
+
let commandStr = `@~/.codex/prompts/${cmd.name}.md`;
|
|
238
|
+
|
|
239
|
+
// Add parameters based on previous results and task context
|
|
240
|
+
if (i > 0 && state.execution_results.length > 0) {
|
|
241
|
+
const lastResult = state.execution_results[state.execution_results.length - 1];
|
|
242
|
+
commandStr += ` --resume="${lastResult.session_id || lastResult.artifact}"`;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// For analysis-based commands, add depth parameter
|
|
246
|
+
if (analysis.complexity === 'complex' && (cmd.name.includes('analyze') || cmd.name.includes('plan'))) {
|
|
247
|
+
commandStr += ` --depth=deep`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Add task description for planning commands
|
|
251
|
+
if (cmd.type === 'planning' && i === 0) {
|
|
252
|
+
commandStr += ` TASK="${analysis.goal}"`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Execute command via Bash (spawning as background task)
|
|
256
|
+
// Format: @~/.codex/prompts/command-name.md [] parameters
|
|
257
|
+
// Note: This simulates the execution; actual implementation uses hook callbacks
|
|
258
|
+
console.log(`Executing: ${commandStr}`);
|
|
259
|
+
|
|
260
|
+
// Save execution record
|
|
261
|
+
state.execution_results.push({
|
|
262
|
+
index: i,
|
|
263
|
+
command: cmd.name,
|
|
264
|
+
status: 'in-progress',
|
|
265
|
+
started_at: new Date().toISOString(),
|
|
266
|
+
session_id: null,
|
|
267
|
+
artifact: null
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
state.command_chain[i].status = 'completed';
|
|
271
|
+
state.updated_at = new Date().toISOString();
|
|
272
|
+
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
|
273
|
+
|
|
274
|
+
console.log(`[${i+1}/${chain.length}] ✓ Completed: @~/.codex/prompts/${cmd.name}.md`);
|
|
275
|
+
|
|
276
|
+
} catch (error) {
|
|
277
|
+
state.command_chain[i].status = 'failed';
|
|
278
|
+
state.updated_at = new Date().toISOString();
|
|
279
|
+
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
|
280
|
+
|
|
281
|
+
console.log(`❌ Command failed: ${error.message}`);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
state.status = 'completed';
|
|
287
|
+
state.updated_at = new Date().toISOString();
|
|
288
|
+
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
|
|
289
|
+
|
|
290
|
+
console.log(`\n✅ Orchestration Complete: ${state.session_id}`);
|
|
291
|
+
return state;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## State File Structure
|
|
296
|
+
|
|
297
|
+
**Location**: `.workflow/.codex-coordinator/{session_id}/state.json`
|
|
298
|
+
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"session_id": "codex-coord-20250129-143025",
|
|
302
|
+
"status": "running|waiting|completed|failed",
|
|
303
|
+
"created_at": "2025-01-29T14:30:25Z",
|
|
304
|
+
"updated_at": "2025-01-29T14:35:45Z",
|
|
305
|
+
"analysis": {
|
|
306
|
+
"goal": "Fix login authentication bug",
|
|
307
|
+
"scope": ["auth", "login"],
|
|
308
|
+
"complexity": "medium",
|
|
309
|
+
"task_type": "bugfix"
|
|
310
|
+
},
|
|
311
|
+
"command_chain": [
|
|
312
|
+
{
|
|
313
|
+
"index": 0,
|
|
314
|
+
"name": "lite-fix",
|
|
315
|
+
"type": "bugfix",
|
|
316
|
+
"status": "completed"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"index": 1,
|
|
320
|
+
"name": "execute",
|
|
321
|
+
"type": "execution",
|
|
322
|
+
"status": "pending"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"execution_results": [
|
|
326
|
+
{
|
|
327
|
+
"index": 0,
|
|
328
|
+
"command": "lite-fix",
|
|
329
|
+
"status": "completed",
|
|
330
|
+
"started_at": "2025-01-29T14:30:25Z",
|
|
331
|
+
"session_id": "fix-login-2025-01-29",
|
|
332
|
+
"artifact": ".workflow/.lite-fix/fix-login-2025-01-29/fix-plan.json"
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Status Values
|
|
339
|
+
|
|
340
|
+
- `running`: Orchestrator actively executing
|
|
341
|
+
- `waiting`: Paused, waiting for external events
|
|
342
|
+
- `completed`: All commands finished successfully
|
|
343
|
+
- `failed`: Error occurred or user aborted
|
|
344
|
+
|
|
345
|
+
## Task Type Routing (Pipeline Summary)
|
|
346
|
+
|
|
347
|
+
**Note**: 【 】marks Minimum Execution Units (最小执行单元) - these commands must execute together.
|
|
348
|
+
|
|
349
|
+
| Task Type | Pipeline | Minimum Units |
|
|
350
|
+
|-----------|----------|---|
|
|
351
|
+
| **bugfix** | Bug报告 →【@~/.codex/prompts/lite-fix.md → @~/.codex/prompts/execute.md】→ 修复代码 | Bug Fix |
|
|
352
|
+
| **discovery** | 需求 →【@~/.codex/prompts/issue-discover.md → @~/.codex/prompts/issue-plan.md → @~/.codex/prompts/issue-queue.md → @~/.codex/prompts/issue-execute.md】→ 完成 issues | Issue Workflow |
|
|
353
|
+
| **analysis** | 需求 → @~/.codex/prompts/analyze-with-file.md → 分析报告 | Analyze With File |
|
|
354
|
+
| **cleanup** | 代码库 → @~/.codex/prompts/clean.md → 清理完成 | Cleanup |
|
|
355
|
+
| **brainstorm** | 主题 →【@~/.codex/prompts/brainstorm-with-file.md → @~/.codex/prompts/execute.md】→ 实现代码 | Brainstorm to Execution |
|
|
356
|
+
| **batch-planning** | 需求集合 →【@~/.codex/prompts/merge-plans-with-file.md → @~/.codex/prompts/execute.md】→ 代码完成 | Merge Multiple Plans |
|
|
357
|
+
| **feature** (simple) | 需求 →【@~/.codex/prompts/lite-plan-a.md → @~/.codex/prompts/execute.md】→ 代码 | Quick Implementation |
|
|
358
|
+
| **feature** (complex) | 需求 → @~/.codex/prompts/lite-plan-b.md → 详细计划 → @~/.codex/prompts/execute.md → 代码 | Complex Planning |
|
|
359
|
+
|
|
360
|
+
## Available Commands Reference
|
|
361
|
+
|
|
362
|
+
### Planning Commands
|
|
363
|
+
|
|
364
|
+
| Command | Purpose | Usage | Output |
|
|
365
|
+
|---------|---------|-------|--------|
|
|
366
|
+
| **lite-plan-a** | Lightweight merged-mode planning | `@~/.codex/prompts/lite-plan-a.md TASK="..."` | plan.json |
|
|
367
|
+
| **lite-plan-b** | Multi-angle exploration planning | `@~/.codex/prompts/lite-plan-b.md TASK="..."` | plan.json |
|
|
368
|
+
| **lite-plan-c** | Parallel angle planning | `@~/.codex/prompts/lite-plan-c.md TASK="..."` | plan.json |
|
|
369
|
+
| **quick-plan-with-file** | Quick planning with file tracking | `@~/.codex/prompts/quick-plan-with-file.md TASK="..."` | plan + docs |
|
|
370
|
+
| **merge-plans-with-file** | Merge multiple plans | `@~/.codex/prompts/merge-plans-with-file.md PLANS="..."` | merged-plan.json |
|
|
371
|
+
|
|
372
|
+
### Execution Commands
|
|
373
|
+
|
|
374
|
+
| Command | Purpose | Usage | Output |
|
|
375
|
+
|---------|---------|-------|--------|
|
|
376
|
+
| **execute** | Execute tasks from plan | `@~/.codex/prompts/execute.md SESSION=".../plan/"` | Working code |
|
|
377
|
+
| **unified-execute-with-file** | Execute with file tracking | `@~/.codex/prompts/unified-execute-with-file.md SESSION="..."` | Code + tracking |
|
|
378
|
+
|
|
379
|
+
### Bug Fix Commands
|
|
380
|
+
|
|
381
|
+
| Command | Purpose | Usage | Output |
|
|
382
|
+
|---------|---------|-------|--------|
|
|
383
|
+
| **lite-fix** | Quick bug diagnosis and planning | `@~/.codex/prompts/lite-fix.md BUG="..."` | fix-plan.json |
|
|
384
|
+
| **debug-with-file** | Hypothesis-driven debugging | `@~/.codex/prompts/debug-with-file.md BUG="..."` | understanding.md |
|
|
385
|
+
|
|
386
|
+
### Discovery Commands
|
|
387
|
+
|
|
388
|
+
| Command | Purpose | Usage | Output |
|
|
389
|
+
|---------|---------|-------|--------|
|
|
390
|
+
| **issue-discover** | Multi-perspective issue discovery | `@~/.codex/prompts/issue-discover.md PATTERN="src/**"` | issues.jsonl |
|
|
391
|
+
| **issue-discover-by-prompt** | Prompt-based discovery | `@~/.codex/prompts/issue-discover-by-prompt.md PROMPT="..."` | issues |
|
|
392
|
+
| **issue-plan** | Plan issue solutions | `@~/.codex/prompts/issue-plan.md --all-pending` | issue-plans.json |
|
|
393
|
+
| **issue-queue** | Form execution queue | `@~/.codex/prompts/issue-queue.md --from-plan` | queue.json |
|
|
394
|
+
| **issue-execute** | Execute issue queue | `@~/.codex/prompts/issue-execute.md QUEUE="..."` | Completed |
|
|
395
|
+
|
|
396
|
+
### Analysis Commands
|
|
397
|
+
|
|
398
|
+
| Command | Purpose | Usage | Output |
|
|
399
|
+
|---------|---------|-------|--------|
|
|
400
|
+
| **analyze-with-file** | Collaborative analysis | `@~/.codex/prompts/analyze-with-file.md TOPIC="..."` | discussion.md |
|
|
401
|
+
|
|
402
|
+
### Brainstorm Commands
|
|
403
|
+
|
|
404
|
+
| Command | Purpose | Usage | Output |
|
|
405
|
+
|---------|---------|-------|--------|
|
|
406
|
+
| **brainstorm-with-file** | Multi-perspective brainstorming | `@~/.codex/prompts/brainstorm-with-file.md TOPIC="..."` | brainstorm.md |
|
|
407
|
+
| **brainstorm-to-cycle** | Bridge brainstorm to execution | `@~/.codex/prompts/brainstorm-to-cycle.md` | Executable plan |
|
|
408
|
+
|
|
409
|
+
### Utility Commands
|
|
410
|
+
|
|
411
|
+
| Command | Purpose | Usage | Output |
|
|
412
|
+
|---------|---------|-------|--------|
|
|
413
|
+
| **clean** | Intelligent code cleanup | `@~/.codex/prompts/clean.md` | Cleaned code |
|
|
414
|
+
| **compact** | Compact session memory | `@~/.codex/prompts/compact.md SESSION="..."` | Compressed state |
|
|
415
|
+
|
|
416
|
+
## Execution Flow
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
User Input: TASK="..."
|
|
420
|
+
↓
|
|
421
|
+
Phase 1: analyzeRequirements(task)
|
|
422
|
+
↓
|
|
423
|
+
Phase 2: recommendCommandChain(analysis)
|
|
424
|
+
Display pipeline and commands
|
|
425
|
+
↓
|
|
426
|
+
User Confirmation
|
|
427
|
+
↓
|
|
428
|
+
Phase 3: executeCommandChain(chain, analysis)
|
|
429
|
+
├─ For each command:
|
|
430
|
+
│ ├─ Update state to "running"
|
|
431
|
+
│ ├─ Build command string with parameters
|
|
432
|
+
│ ├─ Execute @command [] with parameters
|
|
433
|
+
│ ├─ Save execution results
|
|
434
|
+
│ └─ Update state to "completed"
|
|
435
|
+
↓
|
|
436
|
+
Output completion summary
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
## Key Design Principles
|
|
440
|
+
|
|
441
|
+
1. **Atomic Execution** - Never split minimum execution units
|
|
442
|
+
2. **State Persistence** - All state saved to JSON
|
|
443
|
+
3. **User Control** - Confirmation before execution
|
|
444
|
+
4. **Context Passing** - Parameters chain across commands
|
|
445
|
+
5. **Resume Support** - Can resume from state.json
|
|
446
|
+
6. **Intelligent Routing** - Task type determines command chain
|
|
447
|
+
7. **Complexity Awareness** - Different paths for simple vs complex tasks
|
|
448
|
+
|
|
449
|
+
## Command Invocation Format
|
|
450
|
+
|
|
451
|
+
**Format**: `@~/.codex/prompts/<command-name>.md <parameters>`
|
|
452
|
+
|
|
453
|
+
**Examples**:
|
|
454
|
+
```bash
|
|
455
|
+
@~/.codex/prompts/lite-plan-a.md TASK="Implement user authentication"
|
|
456
|
+
@~/.codex/prompts/execute.md SESSION=".workflow/.lite-plan/..."
|
|
457
|
+
@~/.codex/prompts/lite-fix.md BUG="Login fails with 404 error"
|
|
458
|
+
@~/.codex/prompts/issue-discover.md PATTERN="src/auth/**"
|
|
459
|
+
@~/.codex/prompts/brainstorm-with-file.md TOPIC="Improve user onboarding"
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
## Error Handling
|
|
463
|
+
|
|
464
|
+
| Situation | Action |
|
|
465
|
+
|-----------|--------|
|
|
466
|
+
| Unknown task type | Default to feature implementation |
|
|
467
|
+
| Command not found | Error: command not available |
|
|
468
|
+
| Execution fails | Report error, offer retry or skip |
|
|
469
|
+
| Invalid parameters | Validate and ask for correction |
|
|
470
|
+
| Circular dependency | Detect and report |
|
|
471
|
+
| All commands fail | Report and suggest manual intervention |
|
|
472
|
+
|
|
473
|
+
## Session Management
|
|
474
|
+
|
|
475
|
+
**Resume Previous Session**:
|
|
476
|
+
```
|
|
477
|
+
1. Find session in .workflow/.codex-coordinator/
|
|
478
|
+
2. Load state.json
|
|
479
|
+
3. Identify last completed command
|
|
480
|
+
4. Restart from next pending command
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**View Session Progress**:
|
|
484
|
+
```
|
|
485
|
+
cat .workflow/.codex-coordinator/{session-id}/state.json
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Execution Instructions
|
|
491
|
+
|
|
492
|
+
The coordinator workflow follows these steps:
|
|
493
|
+
|
|
494
|
+
1. **Parse Input**: Extract task description from TASK parameter
|
|
495
|
+
2. **Analyze**: Determine goal, scope, complexity, and task type
|
|
496
|
+
3. **Recommend**: Build optimal command chain based on analysis
|
|
497
|
+
4. **Confirm**: Display pipeline and request user approval
|
|
498
|
+
5. **Execute**: Run commands sequentially with state tracking
|
|
499
|
+
6. **Report**: Display final results and artifacts
|
|
500
|
+
|
|
501
|
+
To use this coordinator, invoke it as a Claude Code command (not a Codex command):
|
|
502
|
+
|
|
503
|
+
From the Claude Code CLI, you would call Codex commands like:
|
|
504
|
+
```bash
|
|
505
|
+
@~/.codex/prompts/lite-plan-a.md TASK="Your task description"
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Or with options:
|
|
509
|
+
```bash
|
|
510
|
+
@~/.codex/prompts/lite-plan-a.md TASK="..." --depth=deep
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
This coordinator orchestrates such Codex commands based on your task requirements.
|