claude-code-workflow 7.2.3 → 7.2.4
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/team-worker.md +2 -2
- package/.claude/skills/team-arch-opt/SKILL.md +1 -1
- package/.claude/skills/team-arch-opt/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-arch-opt/specs/team-config.json +1 -1
- package/.claude/skills/team-brainstorm/SKILL.md +2 -2
- package/.claude/skills/team-brainstorm/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-designer/SKILL.md +2 -2
- package/.claude/skills/team-designer/phases/03-content-generation.md +2 -2
- package/.claude/skills/team-edict/SKILL.md +1 -1
- package/.claude/skills/team-edict/role-specs/xingbu.md +1 -1
- package/.claude/skills/team-edict/roles/coordinator/role.md +4 -4
- package/.claude/skills/team-frontend/SKILL.md +1 -1
- package/.claude/skills/team-frontend/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-frontend-debug/SKILL.md +1 -1
- package/.claude/skills/team-frontend-debug/roles/coordinator/commands/dispatch.md +11 -11
- package/.claude/skills/team-issue/SKILL.md +2 -2
- package/.claude/skills/team-issue/roles/coordinator/commands/monitor.md +2 -2
- package/.claude/skills/team-iterdev/SKILL.md +1 -1
- package/.claude/skills/team-iterdev/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-lifecycle-v4/SKILL.md +2 -2
- package/.claude/skills/team-lifecycle-v4/roles/coordinator/commands/dispatch.md +2 -2
- package/.claude/skills/team-perf-opt/SKILL.md +1 -1
- package/.claude/skills/team-perf-opt/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-perf-opt/roles/coordinator/role.md +1 -1
- package/.claude/skills/team-perf-opt/specs/team-config.json +1 -1
- package/.claude/skills/team-planex/SKILL.md +1 -1
- package/.claude/skills/team-planex/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-quality-assurance/SKILL.md +1 -1
- package/.claude/skills/team-quality-assurance/roles/coordinator/commands/dispatch.md +1 -1
- package/.claude/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +3 -3
- package/.claude/skills/team-review/SKILL.md +1 -1
- package/.claude/skills/team-review/roles/coordinator/commands/dispatch.md +1 -1
- package/.claude/skills/team-review/roles/coordinator/commands/monitor.md +4 -4
- package/.claude/skills/team-roadmap-dev/SKILL.md +1 -1
- package/.claude/skills/team-roadmap-dev/roles/coordinator/commands/monitor.md +4 -4
- package/.claude/skills/team-roadmap-dev/specs/pipelines.md +3 -3
- package/.claude/skills/team-roadmap-dev/specs/team-config.json +1 -1
- package/.claude/skills/team-tech-debt/SKILL.md +1 -1
- package/.claude/skills/team-tech-debt/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-testing/SKILL.md +1 -1
- package/.claude/skills/team-testing/roles/coordinator/commands/dispatch.md +1 -1
- package/.claude/skills/team-testing/roles/coordinator/commands/monitor.md +7 -7
- package/.claude/skills/team-uidesign/SKILL.md +1 -1
- package/.claude/skills/team-uidesign/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-ultra-analyze/SKILL.md +1 -1
- package/.claude/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +5 -5
- package/.claude/skills/team-ultra-analyze/roles/coordinator/role.md +1 -1
- package/.claude/skills/team-ux-improve/SKILL.md +1 -1
- package/.claude/skills/team-ux-improve/roles/coordinator/commands/monitor.md +1 -1
- package/.claude/skills/team-ux-improve/roles/coordinator/role.md +2 -2
- package/.claude/skills/team-ux-improve/specs/pipelines.md +1 -1
- package/.claude/skills/team-ux-improve/specs/team-config.json +1 -1
- package/.codex/skills/team-arch-opt/SKILL.md +38 -0
- package/.codex/skills/team-arch-opt/instructions/agent-instruction.md +114 -114
- package/.codex/skills/team-brainstorm/SKILL.md +725 -687
- package/.codex/skills/team-coordinate/SKILL.md +38 -0
- package/.codex/skills/team-designer/SKILL.md +691 -653
- package/.codex/skills/team-designer/schemas/tasks-schema.md +180 -180
- package/.codex/skills/team-edict/SKILL.md +781 -742
- package/.codex/skills/team-edict/agents/aggregator.md +246 -246
- package/.codex/skills/team-edict/agents/qa-verifier.md +274 -274
- package/.codex/skills/team-edict/agents/shangshu-dispatcher.md +247 -247
- package/.codex/skills/team-edict/agents/zhongshu-planner.md +198 -198
- package/.codex/skills/team-edict/instructions/agent-instruction.md +177 -177
- package/.codex/skills/team-executor/SKILL.md +38 -0
- package/.codex/skills/team-frontend/SKILL.md +38 -0
- package/.codex/skills/team-frontend-debug/SKILL.md +38 -0
- package/.codex/skills/team-issue/SKILL.md +740 -702
- package/.codex/skills/team-iterdev/SKILL.md +826 -788
- package/.codex/skills/team-lifecycle/SKILL.md +38 -0
- package/.codex/skills/team-lifecycle/agents/analyst.md +6 -6
- package/.codex/skills/team-lifecycle/agents/discuss-agent.md +1 -1
- package/.codex/skills/team-lifecycle/agents/explore-agent.md +3 -3
- package/.codex/skills/team-lifecycle/agents/writer.md +3 -3
- package/.codex/skills/team-lifecycle/phases/01-requirement-clarification.md +1 -1
- package/.codex/skills/team-lifecycle/phases/02-team-initialization.md +1 -1
- package/.codex/skills/team-lifecycle/phases/03-task-chain-creation.md +1 -1
- package/.codex/skills/team-lifecycle/phases/04-pipeline-coordination.md +1 -1
- package/.codex/skills/team-lifecycle/phases/05-completion-report.md +1 -1
- package/.codex/skills/team-lifecycle-v4/SKILL.md +775 -737
- package/.codex/skills/team-perf-opt/SKILL.md +38 -0
- package/.codex/skills/team-perf-opt/instructions/agent-instruction.md +122 -122
- package/.codex/skills/team-planex/SKILL.md +38 -0
- package/.codex/skills/team-planex-v2/SKILL.md +39 -1
- package/.codex/skills/team-quality-assurance/SKILL.md +38 -0
- package/.codex/skills/team-review/SKILL.md +38 -0
- package/.codex/skills/team-roadmap-dev/SKILL.md +38 -0
- package/.codex/skills/team-tech-debt/SKILL.md +38 -0
- package/.codex/skills/team-testing/SKILL.md +38 -0
- package/.codex/skills/team-uidesign/SKILL.md +38 -0
- package/.codex/skills/team-ultra-analyze/SKILL.md +787 -749
- package/.codex/skills/team-ux-improve/SKILL.md +38 -0
- package/ccw/dist/tools/smart-search.d.ts +23 -0
- package/ccw/dist/tools/smart-search.d.ts.map +1 -1
- package/ccw/dist/tools/smart-search.js +41 -10
- package/ccw/dist/tools/smart-search.js.map +1 -1
- package/codex-lens/src/codexlens/config.py +32 -0
- package/codex-lens/src/codexlens/storage/index_tree.py +101 -33
- package/package.json +1 -1
|
@@ -1,742 +1,781 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: team-edict
|
|
3
|
-
description: |
|
|
4
|
-
三省六部 multi-agent collaboration framework. Imperial edict workflow:
|
|
5
|
-
Crown Prince receives edict -> Zhongshu (Planning) -> Menxia (Multi-dimensional Review) ->
|
|
6
|
-
Shangshu (Dispatch) -> Six Ministries parallel execution.
|
|
7
|
-
Mandatory kanban state reporting, Blocked as first-class state, full observability.
|
|
8
|
-
argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"task description / edict\""
|
|
9
|
-
allowed-tools: spawn_agents_on_csv, spawn_agent, wait, send_input, close_agent, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Auto Mode
|
|
13
|
-
|
|
14
|
-
When `--yes` or `-y`: Auto-confirm task decomposition, skip interactive validation, use defaults.
|
|
15
|
-
|
|
16
|
-
# Team Edict -- Three Departments Six Ministries
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
$team-edict "Implement user authentication module with JWT tokens"
|
|
22
|
-
$team-edict -c 4 "Refactor the data pipeline for better performance"
|
|
23
|
-
$team-edict -y "Add comprehensive test coverage for auth module"
|
|
24
|
-
$team-edict --continue "EDT-20260308-143022"
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Flags**:
|
|
28
|
-
- `-y, --yes`: Skip all confirmations (auto mode)
|
|
29
|
-
- `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
|
|
30
|
-
- `--continue`: Resume existing session
|
|
31
|
-
|
|
32
|
-
**Output Directory**: `.workflow/.csv-wave/{session-id}/`
|
|
33
|
-
**Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Overview
|
|
38
|
-
|
|
39
|
-
Imperial edict-inspired multi-agent collaboration framework with **strict cascading approval pipeline** and **parallel ministry execution**. The Three Departments (zhongshu/menxia/shangshu) perform serial planning, review, and dispatch. The Six Ministries (gongbu/bingbu/hubu/libu/libu-hr/xingbu) execute tasks in dependency-ordered waves.
|
|
40
|
-
|
|
41
|
-
**Execution Model**: Hybrid -- CSV wave pipeline (primary) + individual agent spawn (secondary)
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
+-------------------------------------------------------------------------+
|
|
45
|
-
| TEAM EDICT WORKFLOW |
|
|
46
|
-
+-------------------------------------------------------------------------+
|
|
47
|
-
| |
|
|
48
|
-
| Phase 0: Pre-Wave Interactive (Three Departments Serial Pipeline) |
|
|
49
|
-
| +-- Stage 1: Zhongshu (Planning) -- drafts execution plan |
|
|
50
|
-
| +-- Stage 2: Menxia (Review) -- multi-dimensional review |
|
|
51
|
-
| | +-- Reject -> loop back to Zhongshu (max 3 rounds) |
|
|
52
|
-
| +-- Stage 3: Shangshu (Dispatch) -- routes to Six Ministries |
|
|
53
|
-
| +-- Output: tasks.csv with ministry assignments + dependency waves |
|
|
54
|
-
| |
|
|
55
|
-
| Phase 1: Requirement -> CSV + Classification |
|
|
56
|
-
| +-- Parse Shangshu dispatch plan into tasks.csv |
|
|
57
|
-
| +-- Classify tasks: csv-wave (ministry work) | interactive (QA loop) |
|
|
58
|
-
| +-- Compute dependency waves (topological sort) |
|
|
59
|
-
| +-- Generate tasks.csv with wave + exec_mode columns |
|
|
60
|
-
| +-- User validates task breakdown (skip if -y) |
|
|
61
|
-
| |
|
|
62
|
-
| Phase 2: Wave Execution Engine (Extended) |
|
|
63
|
-
| +-- For each wave (1..N): |
|
|
64
|
-
| | +-- Build wave CSV (filter csv-wave tasks for this wave) |
|
|
65
|
-
| | +-- Inject previous findings into prev_context column |
|
|
66
|
-
| | +-- spawn_agents_on_csv(wave CSV) |
|
|
67
|
-
| | +-- Execute post-wave interactive tasks (if any) |
|
|
68
|
-
| | +-- Merge all results into master tasks.csv |
|
|
69
|
-
| | +-- Check: any failed? -> skip dependents |
|
|
70
|
-
| +-- discoveries.ndjson shared across all modes (append-only) |
|
|
71
|
-
| |
|
|
72
|
-
| Phase 3: Post-Wave Interactive (Quality Aggregation) |
|
|
73
|
-
| +-- Aggregation Agent: collects all ministry outputs |
|
|
74
|
-
| +-- Generates final edict completion report |
|
|
75
|
-
| +-- Quality gate validation against specs/quality-gates.md |
|
|
76
|
-
| |
|
|
77
|
-
| Phase 4: Results Aggregation |
|
|
78
|
-
| +-- Export final results.csv |
|
|
79
|
-
| +-- Generate context.md with all findings |
|
|
80
|
-
| +-- Display summary: completed/failed/skipped per wave |
|
|
81
|
-
| +-- Offer: view results | retry failed | done |
|
|
82
|
-
| |
|
|
83
|
-
+-------------------------------------------------------------------------+
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## Task Classification Rules
|
|
89
|
-
|
|
90
|
-
Each task is classified by `exec_mode`:
|
|
91
|
-
|
|
92
|
-
| exec_mode | Mechanism | Criteria |
|
|
93
|
-
|-----------|-----------|----------|
|
|
94
|
-
| `csv-wave` | `spawn_agents_on_csv` | One-shot, structured I/O, no multi-round interaction |
|
|
95
|
-
| `interactive` | `spawn_agent`/`wait`/`send_input`/`close_agent` | Multi-round, clarification, inline utility |
|
|
96
|
-
|
|
97
|
-
**Classification Decision**:
|
|
98
|
-
|
|
99
|
-
| Task Property | Classification |
|
|
100
|
-
|---------------|---------------|
|
|
101
|
-
| Ministry implementation (IMPL/OPS/DATA/DOC/HR) | `csv-wave` |
|
|
102
|
-
| Quality assurance with test-fix loop (QA) | `interactive` |
|
|
103
|
-
| Single-department self-contained work | `csv-wave` |
|
|
104
|
-
| Cross-department coordination needed | `interactive` |
|
|
105
|
-
| Requires iterative feedback (test -> fix -> retest) | `interactive` |
|
|
106
|
-
| Standalone analysis or generation | `csv-wave` |
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## CSV Schema
|
|
111
|
-
|
|
112
|
-
### tasks.csv (Master State)
|
|
113
|
-
|
|
114
|
-
```csv
|
|
115
|
-
id,title,description,deps,context_from,exec_mode,department,task_prefix,priority,dispatch_batch,acceptance_criteria,wave,status,findings,artifact_path,error
|
|
116
|
-
IMPL-001,"Implement JWT auth","Create JWT authentication middleware with token validation","","","csv-wave","gongbu","IMPL","P0","1","All auth endpoints return valid JWT tokens","1","pending","","",""
|
|
117
|
-
DOC-001,"Write API docs","Generate OpenAPI documentation for auth endpoints","IMPL-001","IMPL-001","csv-wave","libu","DOC","P1","2","API docs cover all auth endpoints","2","pending","","",""
|
|
118
|
-
QA-001,"Test auth module","Execute test suite and validate coverage >= 95%","IMPL-001","IMPL-001","interactive","xingbu","QA","P1","2","Test pass rate >= 95%, no Critical bugs","2","pending","","",""
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**Columns**:
|
|
122
|
-
|
|
123
|
-
| Column | Phase | Description |
|
|
124
|
-
|--------|-------|-------------|
|
|
125
|
-
| `id` | Input | Unique task identifier (DEPT-NNN format) |
|
|
126
|
-
| `title` | Input | Short task title |
|
|
127
|
-
| `description` | Input | Detailed task description (self-contained for agent execution) |
|
|
128
|
-
| `deps` | Input | Semicolon-separated dependency task IDs |
|
|
129
|
-
| `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
|
|
130
|
-
| `exec_mode` | Input | `csv-wave` or `interactive` |
|
|
131
|
-
| `department` | Input | Target ministry: gongbu/bingbu/hubu/libu/libu-hr/xingbu |
|
|
132
|
-
| `task_prefix` | Input | Task type prefix: IMPL/OPS/DATA/DOC/HR/QA |
|
|
133
|
-
| `priority` | Input | Priority level: P0 (highest) to P3 (lowest) |
|
|
134
|
-
| `dispatch_batch` | Input | Batch number from Shangshu dispatch plan (1-based) |
|
|
135
|
-
| `acceptance_criteria` | Input | Specific, measurable acceptance criteria from dispatch plan |
|
|
136
|
-
| `wave` | Computed | Wave number (computed by topological sort, 1-based) |
|
|
137
|
-
| `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
|
|
138
|
-
| `findings` | Output | Key discoveries or implementation notes (max 500 chars) |
|
|
139
|
-
| `artifact_path` | Output | Path to output artifact file relative to session dir |
|
|
140
|
-
| `error` | Output | Error message if failed (empty if success) |
|
|
141
|
-
|
|
142
|
-
### Per-Wave CSV (Temporary)
|
|
143
|
-
|
|
144
|
-
Each wave generates a temporary `wave-{N}.csv` with extra `prev_context` column (csv-wave tasks only).
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## Agent Registry (Interactive Agents)
|
|
149
|
-
|
|
150
|
-
| Agent | Role File | Pattern | Responsibility | Position |
|
|
151
|
-
|-------|-----------|---------|----------------|----------|
|
|
152
|
-
| zhongshu-planner | agents/zhongshu-planner.md | 2.3 (sequential pipeline) | Draft structured execution plan from edict requirements | standalone (Phase 0, Stage 1) |
|
|
153
|
-
| menxia-reviewer | agents/menxia-reviewer.md | 2.4 (multi-perspective analysis) | Multi-dimensional review with 4 CLI analyses | standalone (Phase 0, Stage 2) |
|
|
154
|
-
| shangshu-dispatcher | agents/shangshu-dispatcher.md | 2.3 (sequential pipeline) | Parse approved plan and generate ministry task assignments | standalone (Phase 0, Stage 3) |
|
|
155
|
-
| qa-verifier | agents/qa-verifier.md | 2.5 (iterative refinement) | Quality assurance with test-fix loop (max 3 rounds) | post-wave |
|
|
156
|
-
| aggregator | agents/aggregator.md | 2.3 (sequential pipeline) | Collect all ministry outputs and generate final report | standalone (Phase 3) |
|
|
157
|
-
|
|
158
|
-
> **COMPACT PROTECTION**: Agent files are execution documents. When context compression occurs, **you MUST immediately `Read` the corresponding agent.md** to reload.
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Output Artifacts
|
|
163
|
-
|
|
164
|
-
| File | Purpose | Lifecycle |
|
|
165
|
-
|------|---------|-----------|
|
|
166
|
-
| `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
|
|
167
|
-
| `wave-{N}.csv` | Per-wave input (temporary, csv-wave tasks only) | Created before wave, deleted after |
|
|
168
|
-
| `results.csv` | Final export of all task results | Created in Phase 4 |
|
|
169
|
-
| `discoveries.ndjson` | Shared exploration board (all agents, both modes) | Append-only, carries across waves |
|
|
170
|
-
| `context.md` | Human-readable execution report | Created in Phase 4 |
|
|
171
|
-
| `plan/zhongshu-plan.md` | Zhongshu execution plan | Created in Phase 0 Stage 1 |
|
|
172
|
-
| `review/menxia-review.md` | Menxia review report with 4-dimensional analysis | Created in Phase 0 Stage 2 |
|
|
173
|
-
| `plan/dispatch-plan.md` | Shangshu dispatch plan with ministry assignments | Created in Phase 0 Stage 3 |
|
|
174
|
-
| `artifacts/{dept}-output.md` | Per-ministry output artifact | Created during wave execution |
|
|
175
|
-
| `interactive/{id}-result.json` | Results from interactive tasks (QA loops) | Created per interactive task |
|
|
176
|
-
| `agents/registry.json` | Active interactive agent tracking | Updated on spawn/close |
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## Session Structure
|
|
181
|
-
|
|
182
|
-
```
|
|
183
|
-
.workflow/.csv-wave/{session-id}/
|
|
184
|
-
+-- tasks.csv # Master state (all tasks, both modes)
|
|
185
|
-
+-- results.csv # Final results export
|
|
186
|
-
+-- discoveries.ndjson # Shared discovery board (all agents)
|
|
187
|
-
+-- context.md # Human-readable report
|
|
188
|
-
+-- wave-{N}.csv # Temporary per-wave input (csv-wave only)
|
|
189
|
-
+-- plan/
|
|
190
|
-
| +-- zhongshu-plan.md # Zhongshu execution plan
|
|
191
|
-
| +-- dispatch-plan.md # Shangshu dispatch plan
|
|
192
|
-
+-- review/
|
|
193
|
-
| +-- menxia-review.md # Menxia review report
|
|
194
|
-
+-- artifacts/
|
|
195
|
-
| +-- gongbu-output.md # Ministry outputs
|
|
196
|
-
| +-- bingbu-output.md
|
|
197
|
-
| +-- hubu-output.md
|
|
198
|
-
| +-- libu-output.md
|
|
199
|
-
| +-- libu-hr-output.md
|
|
200
|
-
| +-- xingbu-report.md
|
|
201
|
-
+-- interactive/ # Interactive task artifacts
|
|
202
|
-
| +-- {id}-result.json # Per-task results
|
|
203
|
-
+-- agents/
|
|
204
|
-
+-- registry.json # Active interactive agent tracking
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Implementation
|
|
210
|
-
|
|
211
|
-
### Session Initialization
|
|
212
|
-
|
|
213
|
-
```
|
|
214
|
-
1. Parse $ARGUMENTS for task description (the "edict")
|
|
215
|
-
2. Generate session ID: EDT-{slug}-{YYYYMMDD-HHmmss}
|
|
216
|
-
3. Create session directory: .workflow/.csv-wave/{session-id}/
|
|
217
|
-
4. Create subdirectories: plan/, review/, artifacts/, interactive/, agents/
|
|
218
|
-
5. Initialize registry.json: { "active": [], "closed": [] }
|
|
219
|
-
6. Initialize discoveries.ndjson (empty file)
|
|
220
|
-
7. Read specs:
|
|
221
|
-
8. Read quality gates:
|
|
222
|
-
9. Log session start to context.md
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
### Phase 0: Pre-Wave Interactive (Three Departments Serial Pipeline)
|
|
228
|
-
|
|
229
|
-
**Objective**: Execute the serial approval pipeline (zhongshu -> menxia -> shangshu) to produce a validated, reviewed dispatch plan that decomposes the edict into ministry-level tasks.
|
|
230
|
-
|
|
231
|
-
#### Stage 1: Zhongshu Planning
|
|
232
|
-
|
|
233
|
-
```javascript
|
|
234
|
-
const zhongshu = spawn_agent({
|
|
235
|
-
message: `
|
|
236
|
-
## TASK ASSIGNMENT
|
|
237
|
-
|
|
238
|
-
### MANDATORY FIRST STEPS (Agent Execute)
|
|
239
|
-
1. **Read role definition**:
|
|
240
|
-
2. Read: ${sessionDir}/discoveries.ndjson (shared discoveries, skip if not exists)
|
|
241
|
-
3. Read:
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
Goal: Draft a structured execution plan for the following edict
|
|
246
|
-
Scope: Analyze codebase, decompose into ministry-level subtasks, define acceptance criteria
|
|
247
|
-
Deliverables: ${sessionDir}/plan/zhongshu-plan.md
|
|
248
|
-
|
|
249
|
-
### Edict (Original Requirement)
|
|
250
|
-
${edictText}
|
|
251
|
-
`
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
const zhongshuResult = wait({ ids: [zhongshu], timeout_ms: 600000 })
|
|
255
|
-
|
|
256
|
-
if (zhongshuResult.timed_out) {
|
|
257
|
-
send_input({ id: zhongshu, message: "Please finalize your execution plan immediately and output current findings." })
|
|
258
|
-
const retry = wait({ ids: [zhongshu], timeout_ms: 120000 })
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Store result
|
|
262
|
-
Write(`${sessionDir}/interactive/zhongshu-result.json`, JSON.stringify({
|
|
263
|
-
task_id: "PLAN-001",
|
|
264
|
-
status: "completed",
|
|
265
|
-
findings: parseFindings(zhongshuResult),
|
|
266
|
-
timestamp: new Date().toISOString()
|
|
267
|
-
}))
|
|
268
|
-
|
|
269
|
-
close_agent({ id: zhongshu })
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
#### Stage 2: Menxia Multi-Dimensional Review
|
|
273
|
-
|
|
274
|
-
**Rejection Loop**: If menxia rejects (approved=false), respawn zhongshu with feedback. Max 3 rounds.
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
let reviewRound = 0
|
|
278
|
-
let approved = false
|
|
279
|
-
|
|
280
|
-
while (!approved && reviewRound < 3) {
|
|
281
|
-
reviewRound++
|
|
282
|
-
|
|
283
|
-
const menxia = spawn_agent({
|
|
284
|
-
message: `
|
|
285
|
-
## TASK ASSIGNMENT
|
|
286
|
-
|
|
287
|
-
### MANDATORY FIRST STEPS (Agent Execute)
|
|
288
|
-
1. **Read role definition**:
|
|
289
|
-
2. Read: ${sessionDir}/plan/zhongshu-plan.md (plan to review)
|
|
290
|
-
3. Read: ${sessionDir}/discoveries.ndjson (shared discoveries)
|
|
291
|
-
|
|
292
|
-
---
|
|
293
|
-
|
|
294
|
-
Goal: Multi-dimensional review of Zhongshu plan (Round ${reviewRound}/3)
|
|
295
|
-
Scope: Feasibility, completeness, risk, resource allocation
|
|
296
|
-
Deliverables: ${sessionDir}/review/menxia-review.md
|
|
297
|
-
|
|
298
|
-
### Original Edict
|
|
299
|
-
${edictText}
|
|
300
|
-
|
|
301
|
-
### Previous Review (if rejection round > 1)
|
|
302
|
-
${reviewRound > 1 ? readPreviousReview() : "First review round"}
|
|
303
|
-
`
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
const menxiaResult = wait({ ids: [menxia], timeout_ms: 600000 })
|
|
307
|
-
|
|
308
|
-
if (menxiaResult.timed_out) {
|
|
309
|
-
send_input({ id: menxia, message: "Please finalize review and output verdict (approved/rejected)." })
|
|
310
|
-
const retry = wait({ ids: [menxia], timeout_ms: 120000 })
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
close_agent({ id: menxia })
|
|
314
|
-
|
|
315
|
-
// Parse verdict from review report
|
|
316
|
-
const reviewReport = Read(`${sessionDir}/review/menxia-review.md`)
|
|
317
|
-
approved = reviewReport.includes("approved") || reviewReport.includes("approved: true")
|
|
318
|
-
|
|
319
|
-
if (!approved && reviewRound < 3) {
|
|
320
|
-
// Respawn zhongshu with rejection feedback (Stage 1 again)
|
|
321
|
-
// ... spawn zhongshu with rejection_feedback = reviewReport ...
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (!approved && reviewRound >= 3) {
|
|
326
|
-
// Max rounds reached, ask user
|
|
327
|
-
AskUserQuestion("Menxia rejected the plan 3 times. Please review and decide: approve, reject, or provide guidance.")
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
#### Stage 3: Shangshu Dispatch
|
|
332
|
-
|
|
333
|
-
```javascript
|
|
334
|
-
const shangshu = spawn_agent({
|
|
335
|
-
message: `
|
|
336
|
-
## TASK ASSIGNMENT
|
|
337
|
-
|
|
338
|
-
### MANDATORY FIRST STEPS (Agent Execute)
|
|
339
|
-
1. **Read role definition**:
|
|
340
|
-
2. Read: ${sessionDir}/plan/zhongshu-plan.md (approved plan)
|
|
341
|
-
3. Read: ${sessionDir}/review/menxia-review.md (review conditions)
|
|
342
|
-
4. Read:
|
|
343
|
-
|
|
344
|
-
---
|
|
345
|
-
|
|
346
|
-
Goal: Parse approved plan and generate Six Ministries dispatch plan
|
|
347
|
-
Scope: Route subtasks to departments, define execution batches, set dependencies
|
|
348
|
-
Deliverables: ${sessionDir}/plan/dispatch-plan.md
|
|
349
|
-
`
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
const shangshuResult = wait({ ids: [shangshu], timeout_ms: 300000 })
|
|
353
|
-
close_agent({ id: shangshu })
|
|
354
|
-
|
|
355
|
-
// Parse dispatch-plan.md to generate tasks.csv (Phase 1 input)
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
**Success Criteria**:
|
|
359
|
-
- zhongshu-plan.md written with structured subtask list
|
|
360
|
-
- menxia-review.md written with 4-dimensional analysis verdict
|
|
361
|
-
- dispatch-plan.md written with ministry assignments and batch ordering
|
|
362
|
-
- Interactive agents closed, results stored
|
|
363
|
-
|
|
364
|
-
---
|
|
365
|
-
|
|
366
|
-
### Phase 1: Requirement -> CSV + Classification
|
|
367
|
-
|
|
368
|
-
**Objective**: Parse the Shangshu dispatch plan into a tasks.csv with proper wave computation and exec_mode classification.
|
|
369
|
-
|
|
370
|
-
**Decomposition Rules**:
|
|
371
|
-
|
|
372
|
-
1. Read `${sessionDir}/plan/dispatch-plan.md`
|
|
373
|
-
2. For each ministry task in the dispatch plan:
|
|
374
|
-
- Extract: task ID, title, description, department, priority, batch number, acceptance criteria
|
|
375
|
-
- Determine dependencies from the dispatch plan's batch ordering and explicit blockedBy
|
|
376
|
-
- Set `context_from` for tasks that need predecessor findings
|
|
377
|
-
3. Apply classification rules (see Task Classification Rules above)
|
|
378
|
-
4. Compute waves via topological sort (Kahn's BFS with depth tracking)
|
|
379
|
-
5. Generate `tasks.csv` with all columns
|
|
380
|
-
|
|
381
|
-
**Classification Rules**:
|
|
382
|
-
|
|
383
|
-
| Department | Default exec_mode | Override Condition |
|
|
384
|
-
|------------|-------------------|-------------------|
|
|
385
|
-
| gongbu (IMPL) | csv-wave | Interactive if requires iterative codebase exploration |
|
|
386
|
-
| bingbu (OPS) | csv-wave | - |
|
|
387
|
-
| hubu (DATA) | csv-wave | - |
|
|
388
|
-
| libu (DOC) | csv-wave | - |
|
|
389
|
-
| libu-hr (HR) | csv-wave | - |
|
|
390
|
-
| xingbu (QA) | interactive | Always interactive (test-fix loop) |
|
|
391
|
-
|
|
392
|
-
**Wave Computation**: Kahn's BFS topological sort with depth tracking (csv-wave tasks only).
|
|
393
|
-
|
|
394
|
-
**User Validation**: Display task breakdown with wave + exec_mode assignment (skip if AUTO_YES).
|
|
395
|
-
|
|
396
|
-
**Success Criteria**:
|
|
397
|
-
- tasks.csv created with valid schema, wave, and exec_mode assignments
|
|
398
|
-
- No circular dependencies
|
|
399
|
-
- User approved (or AUTO_YES)
|
|
400
|
-
|
|
401
|
-
---
|
|
402
|
-
|
|
403
|
-
### Phase 2: Wave Execution Engine (Extended)
|
|
404
|
-
|
|
405
|
-
**Objective**: Execute tasks wave-by-wave with hybrid mechanism support and cross-wave context propagation.
|
|
406
|
-
|
|
407
|
-
```
|
|
408
|
-
For each wave W in 1..max_wave:
|
|
409
|
-
|
|
410
|
-
1. FILTER csv-wave tasks where wave == W and status == "pending"
|
|
411
|
-
2. CHECK dependencies: if any dep has status == "failed", mark task as "skipped"
|
|
412
|
-
3. BUILD prev_context for each task from context_from references:
|
|
413
|
-
- For csv-wave predecessors: read findings from master tasks.csv
|
|
414
|
-
- For interactive predecessors: read from interactive/{id}-result.json
|
|
415
|
-
4. GENERATE wave-{W}.csv with prev_context column added
|
|
416
|
-
5. EXECUTE csv-wave tasks:
|
|
417
|
-
spawn_agents_on_csv({
|
|
418
|
-
task_csv_path: "${sessionDir}/wave-{W}.csv",
|
|
419
|
-
instruction_path: "
|
|
420
|
-
schema_path: "
|
|
421
|
-
additional_instructions: "Session directory: ${sessionDir}. Department: {department}. Priority: {priority}.",
|
|
422
|
-
concurrency: CONCURRENCY
|
|
423
|
-
})
|
|
424
|
-
6. MERGE results back into master tasks.csv (update status, findings, artifact_path, error)
|
|
425
|
-
7. EXECUTE interactive tasks for this wave (post-wave):
|
|
426
|
-
For each interactive task in wave W:
|
|
427
|
-
Read agents/qa-verifier.md
|
|
428
|
-
Spawn QA verifier agent with task context + wave results
|
|
429
|
-
Handle test-fix loop via send_input
|
|
430
|
-
Store result in interactive/{id}-result.json
|
|
431
|
-
Close agent, update registry.json
|
|
432
|
-
8. CLEANUP: delete wave-{W}.csv
|
|
433
|
-
9. LOG wave completion to context.md and discoveries.ndjson
|
|
434
|
-
|
|
435
|
-
Wave completion check:
|
|
436
|
-
- All tasks completed or skipped -> proceed to next wave
|
|
437
|
-
- Any failed non-skippable task -> log error, continue (dependents will be skipped)
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
**Success Criteria**:
|
|
441
|
-
- All waves executed in order
|
|
442
|
-
- Both csv-wave and interactive tasks handled per wave
|
|
443
|
-
- Each wave's results merged into master CSV before next wave starts
|
|
444
|
-
- Dependent tasks skipped when predecessor failed
|
|
445
|
-
- discoveries.ndjson accumulated across all waves and mechanisms
|
|
446
|
-
- Interactive agent lifecycle tracked in registry.json
|
|
447
|
-
|
|
448
|
-
---
|
|
449
|
-
|
|
450
|
-
### Phase 3: Post-Wave Interactive (Quality Aggregation)
|
|
451
|
-
|
|
452
|
-
**Objective**: Collect all ministry outputs, validate against quality gates, and generate the final edict completion report.
|
|
453
|
-
|
|
454
|
-
```javascript
|
|
455
|
-
const aggregator = spawn_agent({
|
|
456
|
-
message: `
|
|
457
|
-
## TASK ASSIGNMENT
|
|
458
|
-
|
|
459
|
-
### MANDATORY FIRST STEPS (Agent Execute)
|
|
460
|
-
1. **Read role definition**:
|
|
461
|
-
2. Read: ${sessionDir}/tasks.csv (master state)
|
|
462
|
-
3. Read: ${sessionDir}/discoveries.ndjson (all discoveries)
|
|
463
|
-
4. Read:
|
|
464
|
-
|
|
465
|
-
---
|
|
466
|
-
|
|
467
|
-
Goal: Aggregate all ministry outputs into final edict completion report
|
|
468
|
-
Scope: All artifacts in ${sessionDir}/artifacts/, all interactive results
|
|
469
|
-
Deliverables: ${sessionDir}/context.md (final report)
|
|
470
|
-
|
|
471
|
-
### Ministry Artifacts to Collect
|
|
472
|
-
${listAllArtifacts()}
|
|
473
|
-
|
|
474
|
-
### Quality Gate Standards
|
|
475
|
-
Read from:
|
|
476
|
-
`
|
|
477
|
-
})
|
|
478
|
-
|
|
479
|
-
const aggResult = wait({ ids: [aggregator], timeout_ms: 300000 })
|
|
480
|
-
close_agent({ id: aggregator })
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
**Success Criteria**:
|
|
484
|
-
- Post-wave interactive processing complete
|
|
485
|
-
- Interactive agents closed, results stored
|
|
486
|
-
|
|
487
|
-
---
|
|
488
|
-
|
|
489
|
-
### Phase 4: Results Aggregation
|
|
490
|
-
|
|
491
|
-
**Objective**: Generate final results and human-readable report.
|
|
492
|
-
|
|
493
|
-
```
|
|
494
|
-
1. READ master tasks.csv
|
|
495
|
-
2. EXPORT results.csv with final status for all tasks
|
|
496
|
-
3. GENERATE context.md (if not already done by aggregator):
|
|
497
|
-
- Edict summary
|
|
498
|
-
- Pipeline stages: Planning -> Review -> Dispatch -> Execution
|
|
499
|
-
- Per-department output summaries
|
|
500
|
-
- Quality gate results
|
|
501
|
-
- Discoveries summary
|
|
502
|
-
4. DISPLAY summary to user:
|
|
503
|
-
- Total tasks: N (completed: X, failed: Y, skipped: Z)
|
|
504
|
-
- Per-wave breakdown
|
|
505
|
-
- Key findings
|
|
506
|
-
5. CLEANUP:
|
|
507
|
-
- Close any remaining interactive agents (registry.json)
|
|
508
|
-
- Remove temporary wave CSV files
|
|
509
|
-
6. OFFER: view full report | retry failed tasks | done
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
**Success Criteria**:
|
|
513
|
-
- results.csv exported (all tasks, both modes)
|
|
514
|
-
- context.md generated
|
|
515
|
-
- All interactive agents closed (registry.json cleanup)
|
|
516
|
-
- Summary displayed to user
|
|
517
|
-
|
|
518
|
-
---
|
|
519
|
-
|
|
520
|
-
## Shared Discovery Board Protocol
|
|
521
|
-
|
|
522
|
-
All agents (both csv-wave and interactive) share a single `discoveries.ndjson` file for cross-agent knowledge propagation.
|
|
523
|
-
|
|
524
|
-
### Discovery Types
|
|
525
|
-
|
|
526
|
-
| Type | Dedup Key | Data Schema | Description |
|
|
527
|
-
|------|-----------|-------------|-------------|
|
|
528
|
-
| `codebase_pattern` | `pattern_name` | `{pattern_name, files, description}` | Identified codebase patterns and conventions |
|
|
529
|
-
| `dependency_found` | `dep_name` | `{dep_name, version, used_by}` | External dependency discoveries |
|
|
530
|
-
| `risk_identified` | `risk_id` | `{risk_id, severity, description, mitigation}` | Risk findings from any agent |
|
|
531
|
-
| `implementation_note` | `file_path` | `{file_path, note, line_range}` | Implementation decisions and notes |
|
|
532
|
-
| `test_result` | `test_suite` | `{test_suite, pass_rate, failures}` | Test execution results |
|
|
533
|
-
| `quality_issue` | `issue_id` | `{issue_id, severity, file, description}` | Quality issues found during review |
|
|
534
|
-
| `routing_note` | `task_id` | `{task_id, department, reason}` | Dispatch routing decisions |
|
|
535
|
-
|
|
536
|
-
### Protocol
|
|
537
|
-
|
|
538
|
-
```bash
|
|
539
|
-
# Append discovery (any agent, any mode)
|
|
540
|
-
echo '{"ts":"<ISO8601>","worker":"{id}","type":"<type>","data":{...}}' >> ${sessionDir}/discoveries.ndjson
|
|
541
|
-
|
|
542
|
-
# Read discoveries (any agent, any mode)
|
|
543
|
-
# Read ${sessionDir}/discoveries.ndjson, parse each line as JSON
|
|
544
|
-
# Deduplicate by type + dedup_key
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
### Rules
|
|
548
|
-
- **Append-only**: Never modify or delete existing entries
|
|
549
|
-
- **Deduplicate on read**: When reading, use type + dedup_key to skip duplicates
|
|
550
|
-
- **Both mechanisms share**: csv-wave agents and interactive agents use the same file
|
|
551
|
-
- **Carry across waves**: Discoveries persist across all waves
|
|
552
|
-
|
|
553
|
-
---
|
|
554
|
-
|
|
555
|
-
## Six Ministries Routing Rules
|
|
556
|
-
|
|
557
|
-
Shangshu dispatcher uses these rules to assign tasks to ministries:
|
|
558
|
-
|
|
559
|
-
| Keyword Signals | Target Ministry | Role ID | Task Prefix |
|
|
560
|
-
|----------------|-----------------|---------|-------------|
|
|
561
|
-
| Feature dev, architecture, code, refactor, implement, API | Engineering | gongbu | IMPL |
|
|
562
|
-
| Deploy, CI/CD, infrastructure, container, monitoring, security ops | Operations | bingbu | OPS |
|
|
563
|
-
| Data analysis, statistics, cost, reports, resource mgmt | Data & Resources | hubu | DATA |
|
|
564
|
-
| Documentation, README, UI copy, specs, API docs, comms | Documentation | libu | DOC |
|
|
565
|
-
| Testing, QA, bug, code review, compliance audit | Quality Assurance | xingbu | QA |
|
|
566
|
-
| Agent management, training, skill optimization, evaluation | Personnel | libu-hr | HR |
|
|
567
|
-
|
|
568
|
-
---
|
|
569
|
-
|
|
570
|
-
## Kanban State Protocol
|
|
571
|
-
|
|
572
|
-
All agents must report state transitions. In Codex context, agents write state to discoveries.ndjson:
|
|
573
|
-
|
|
574
|
-
### State Machine
|
|
575
|
-
|
|
576
|
-
```
|
|
577
|
-
Pending -> Doing -> Done
|
|
578
|
-
|
|
|
579
|
-
Blocked (can enter at any time, must report reason)
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
### State Reporting via Discoveries
|
|
583
|
-
|
|
584
|
-
```bash
|
|
585
|
-
# Task start
|
|
586
|
-
echo '{"ts":"<ISO8601>","worker":"{id}","type":"state_update","data":{"state":"Doing","task_id":"{id}","department":"{department}","step":"Starting execution"}}' >> ${sessionDir}/discoveries.ndjson
|
|
587
|
-
|
|
588
|
-
# Progress update
|
|
589
|
-
echo '{"ts":"<ISO8601>","worker":"{id}","type":"progress","data":{"task_id":"{id}","current":"Step 2: Implementing API","plan":"Step1 done|Step2 in progress|Step3 pending"}}' >> ${sessionDir}/discoveries.ndjson
|
|
590
|
-
|
|
591
|
-
# Completion
|
|
592
|
-
echo '{"ts":"<ISO8601>","worker":"{id}","type":"state_update","data":{"state":"Done","task_id":"{id}","remark":"Completed: implementation summary"}}' >> ${sessionDir}/discoveries.ndjson
|
|
593
|
-
|
|
594
|
-
# Blocked
|
|
595
|
-
echo '{"ts":"<ISO8601>","worker":"{id}","type":"state_update","data":{"state":"Blocked","task_id":"{id}","reason":"Cannot proceed: missing dependency"}}' >> ${sessionDir}/discoveries.ndjson
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
---
|
|
599
|
-
|
|
600
|
-
## Interactive Task Execution
|
|
601
|
-
|
|
602
|
-
For interactive tasks within a wave (primarily QA test-fix loops):
|
|
603
|
-
|
|
604
|
-
**Spawn Protocol**:
|
|
605
|
-
|
|
606
|
-
```javascript
|
|
607
|
-
const agent = spawn_agent({
|
|
608
|
-
message: `
|
|
609
|
-
## TASK ASSIGNMENT
|
|
610
|
-
|
|
611
|
-
### MANDATORY FIRST STEPS (Agent Execute)
|
|
612
|
-
1. **Read role definition**:
|
|
613
|
-
2. Read: ${sessionDir}/discoveries.ndjson (shared discoveries)
|
|
614
|
-
3. Read:
|
|
615
|
-
|
|
616
|
-
---
|
|
617
|
-
|
|
618
|
-
Goal: Execute QA verification for task ${taskId}
|
|
619
|
-
Scope: ${taskDescription}
|
|
620
|
-
Deliverables: Test report + pass/fail verdict
|
|
621
|
-
|
|
622
|
-
### Previous Context
|
|
623
|
-
${prevContextFromCompletedTasks}
|
|
624
|
-
|
|
625
|
-
### Acceptance Criteria
|
|
626
|
-
${acceptanceCriteria}
|
|
627
|
-
`
|
|
628
|
-
})
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
**Wait + Process**:
|
|
632
|
-
|
|
633
|
-
```javascript
|
|
634
|
-
const result = wait({ ids: [agent], timeout_ms: 600000 })
|
|
635
|
-
|
|
636
|
-
if (result.timed_out) {
|
|
637
|
-
send_input({ id: agent, message: "Please finalize and output current findings." })
|
|
638
|
-
const retry = wait({ ids: [agent], timeout_ms: 120000 })
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// Store result
|
|
642
|
-
Write(`${sessionDir}/interactive/${taskId}-result.json`, JSON.stringify({
|
|
643
|
-
task_id: taskId,
|
|
644
|
-
status: "completed",
|
|
645
|
-
findings: parseFindings(result),
|
|
646
|
-
timestamp: new Date().toISOString()
|
|
647
|
-
}))
|
|
648
|
-
```
|
|
649
|
-
|
|
650
|
-
**Lifecycle Tracking**:
|
|
651
|
-
|
|
652
|
-
```javascript
|
|
653
|
-
// On spawn: register
|
|
654
|
-
registry.active.push({ id: agent, task_id: taskId, pattern: "qa-verifier", spawned_at: now })
|
|
655
|
-
|
|
656
|
-
// On close: move to closed
|
|
657
|
-
close_agent({ id: agent })
|
|
658
|
-
registry.active = registry.active.filter(a => a.id !== agent)
|
|
659
|
-
registry.closed.push({ id: agent, task_id: taskId, closed_at: now })
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
---
|
|
663
|
-
|
|
664
|
-
## Cross-Mechanism Context Bridging
|
|
665
|
-
|
|
666
|
-
### Interactive Result -> CSV Task
|
|
667
|
-
|
|
668
|
-
When a pre-wave interactive task produces results needed by csv-wave tasks:
|
|
669
|
-
|
|
670
|
-
```javascript
|
|
671
|
-
// 1. Interactive result stored in file
|
|
672
|
-
const resultFile = `${sessionDir}/interactive/${taskId}-result.json`
|
|
673
|
-
|
|
674
|
-
// 2. Wave engine reads when building prev_context for csv-wave tasks
|
|
675
|
-
// If a csv-wave task has context_from referencing an interactive task:
|
|
676
|
-
// Read the interactive result file and include in prev_context
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
### CSV Result -> Interactive Task
|
|
680
|
-
|
|
681
|
-
When a post-wave interactive task needs CSV wave results:
|
|
682
|
-
|
|
683
|
-
```javascript
|
|
684
|
-
// Include in spawn message
|
|
685
|
-
const csvFindings = readMasterCSV().filter(t => t.wave === currentWave && t.exec_mode === 'csv-wave')
|
|
686
|
-
const context = csvFindings.map(t => `## Task ${t.id}: ${t.title}\n${t.findings}`).join('\n\n')
|
|
687
|
-
|
|
688
|
-
spawn_agent({
|
|
689
|
-
message: `...\n### Wave ${currentWave} Results\n${context}\n...`
|
|
690
|
-
})
|
|
691
|
-
```
|
|
692
|
-
|
|
693
|
-
---
|
|
694
|
-
|
|
695
|
-
## Error Handling
|
|
696
|
-
|
|
697
|
-
| Error | Resolution |
|
|
698
|
-
|-------|------------|
|
|
699
|
-
| Circular dependency | Detect in wave computation, abort with error message |
|
|
700
|
-
| CSV agent timeout | Mark as failed in results, continue with wave |
|
|
701
|
-
| CSV agent failed | Mark as failed, skip dependent tasks in later waves |
|
|
702
|
-
| Interactive agent timeout | Urge convergence via send_input, then close if still timed out |
|
|
703
|
-
| Interactive agent failed | Mark as failed, skip dependents |
|
|
704
|
-
| Pre-wave interactive failed | Skip dependent csv-wave tasks in same wave |
|
|
705
|
-
| All agents in wave failed | Log error, offer retry or abort |
|
|
706
|
-
| CSV parse error | Validate CSV format before execution, show line number |
|
|
707
|
-
| discoveries.ndjson corrupt | Ignore malformed lines, continue with valid entries |
|
|
708
|
-
| Lifecycle leak | Cleanup all active agents via registry.json at end |
|
|
709
|
-
| Continue mode: no session found | List available sessions, prompt user to select |
|
|
710
|
-
| Menxia rejection loop >= 3 rounds | AskUserQuestion for user decision |
|
|
711
|
-
| Zhongshu plan file missing | Abort Phase 0, report error |
|
|
712
|
-
| Shangshu dispatch plan parse failure | Abort, ask user to review dispatch-plan.md |
|
|
713
|
-
| Ministry artifact not written | Mark task as failed, include in QA report |
|
|
714
|
-
| Test-fix loop exceeds 3 rounds | Mark QA as failed, report to aggregator |
|
|
715
|
-
|
|
716
|
-
---
|
|
717
|
-
|
|
718
|
-
## Specs Reference
|
|
719
|
-
|
|
720
|
-
| File | Content | Used By |
|
|
721
|
-
|------|---------|---------|
|
|
722
|
-
| [specs/team-config.json](specs/team-config.json) | Role registry, routing rules, pipeline definition, session structure, artifact paths | Orchestrator (session init), Shangshu (routing), all agents (artifact paths) |
|
|
723
|
-
| [specs/quality-gates.md](specs/quality-gates.md) | Per-phase quality gate standards, cross-phase consistency checks | Aggregator (Phase 3), QA verifier (test validation) |
|
|
724
|
-
|
|
725
|
-
---
|
|
726
|
-
|
|
727
|
-
## Core Rules
|
|
728
|
-
|
|
729
|
-
1. **Start Immediately**: First action is session initialization, then Phase 0
|
|
730
|
-
2. **Wave Order is Sacred**: Never execute wave N before wave N-1 completes and results are merged
|
|
731
|
-
3. **CSV is Source of Truth**: Master tasks.csv holds all state (both csv-wave and interactive)
|
|
732
|
-
4. **CSV First**: Default to csv-wave for tasks; only use interactive when interaction pattern requires it
|
|
733
|
-
5. **Context Propagation**: prev_context built from master CSV, not from memory
|
|
734
|
-
6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson -- both mechanisms share it
|
|
735
|
-
7. **Skip on Failure**: If a dependency failed, skip the dependent task (regardless of mechanism)
|
|
736
|
-
8. **Lifecycle Balance**: Every spawn_agent MUST have a matching close_agent (tracked in registry.json)
|
|
737
|
-
9. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
|
|
738
|
-
10. **DO NOT STOP**: Continuous execution until all waves complete or all remaining tasks are skipped
|
|
739
|
-
11. **Three Departments are Serial**: Zhongshu -> Menxia -> Shangshu must execute in strict order
|
|
740
|
-
12. **Rejection Loop Max 3**: Menxia can reject max 3 times before escalating to user
|
|
741
|
-
13. **Kanban is Mandatory**: All agents must report state transitions via discoveries.ndjson
|
|
742
|
-
14. **Quality Gates Apply**: Phase 3 aggregator validates all outputs against specs/quality-gates.md
|
|
1
|
+
---
|
|
2
|
+
name: team-edict
|
|
3
|
+
description: |
|
|
4
|
+
三省六部 multi-agent collaboration framework. Imperial edict workflow:
|
|
5
|
+
Crown Prince receives edict -> Zhongshu (Planning) -> Menxia (Multi-dimensional Review) ->
|
|
6
|
+
Shangshu (Dispatch) -> Six Ministries parallel execution.
|
|
7
|
+
Mandatory kanban state reporting, Blocked as first-class state, full observability.
|
|
8
|
+
argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"task description / edict\""
|
|
9
|
+
allowed-tools: spawn_agents_on_csv, spawn_agent, wait, send_input, close_agent, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Auto Mode
|
|
13
|
+
|
|
14
|
+
When `--yes` or `-y`: Auto-confirm task decomposition, skip interactive validation, use defaults.
|
|
15
|
+
|
|
16
|
+
# Team Edict -- Three Departments Six Ministries
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
$team-edict "Implement user authentication module with JWT tokens"
|
|
22
|
+
$team-edict -c 4 "Refactor the data pipeline for better performance"
|
|
23
|
+
$team-edict -y "Add comprehensive test coverage for auth module"
|
|
24
|
+
$team-edict --continue "EDT-20260308-143022"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Flags**:
|
|
28
|
+
- `-y, --yes`: Skip all confirmations (auto mode)
|
|
29
|
+
- `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
|
|
30
|
+
- `--continue`: Resume existing session
|
|
31
|
+
|
|
32
|
+
**Output Directory**: `.workflow/.csv-wave/{session-id}/`
|
|
33
|
+
**Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Overview
|
|
38
|
+
|
|
39
|
+
Imperial edict-inspired multi-agent collaboration framework with **strict cascading approval pipeline** and **parallel ministry execution**. The Three Departments (zhongshu/menxia/shangshu) perform serial planning, review, and dispatch. The Six Ministries (gongbu/bingbu/hubu/libu/libu-hr/xingbu) execute tasks in dependency-ordered waves.
|
|
40
|
+
|
|
41
|
+
**Execution Model**: Hybrid -- CSV wave pipeline (primary) + individual agent spawn (secondary)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
+-------------------------------------------------------------------------+
|
|
45
|
+
| TEAM EDICT WORKFLOW |
|
|
46
|
+
+-------------------------------------------------------------------------+
|
|
47
|
+
| |
|
|
48
|
+
| Phase 0: Pre-Wave Interactive (Three Departments Serial Pipeline) |
|
|
49
|
+
| +-- Stage 1: Zhongshu (Planning) -- drafts execution plan |
|
|
50
|
+
| +-- Stage 2: Menxia (Review) -- multi-dimensional review |
|
|
51
|
+
| | +-- Reject -> loop back to Zhongshu (max 3 rounds) |
|
|
52
|
+
| +-- Stage 3: Shangshu (Dispatch) -- routes to Six Ministries |
|
|
53
|
+
| +-- Output: tasks.csv with ministry assignments + dependency waves |
|
|
54
|
+
| |
|
|
55
|
+
| Phase 1: Requirement -> CSV + Classification |
|
|
56
|
+
| +-- Parse Shangshu dispatch plan into tasks.csv |
|
|
57
|
+
| +-- Classify tasks: csv-wave (ministry work) | interactive (QA loop) |
|
|
58
|
+
| +-- Compute dependency waves (topological sort) |
|
|
59
|
+
| +-- Generate tasks.csv with wave + exec_mode columns |
|
|
60
|
+
| +-- User validates task breakdown (skip if -y) |
|
|
61
|
+
| |
|
|
62
|
+
| Phase 2: Wave Execution Engine (Extended) |
|
|
63
|
+
| +-- For each wave (1..N): |
|
|
64
|
+
| | +-- Build wave CSV (filter csv-wave tasks for this wave) |
|
|
65
|
+
| | +-- Inject previous findings into prev_context column |
|
|
66
|
+
| | +-- spawn_agents_on_csv(wave CSV) |
|
|
67
|
+
| | +-- Execute post-wave interactive tasks (if any) |
|
|
68
|
+
| | +-- Merge all results into master tasks.csv |
|
|
69
|
+
| | +-- Check: any failed? -> skip dependents |
|
|
70
|
+
| +-- discoveries.ndjson shared across all modes (append-only) |
|
|
71
|
+
| |
|
|
72
|
+
| Phase 3: Post-Wave Interactive (Quality Aggregation) |
|
|
73
|
+
| +-- Aggregation Agent: collects all ministry outputs |
|
|
74
|
+
| +-- Generates final edict completion report |
|
|
75
|
+
| +-- Quality gate validation against specs/quality-gates.md |
|
|
76
|
+
| |
|
|
77
|
+
| Phase 4: Results Aggregation |
|
|
78
|
+
| +-- Export final results.csv |
|
|
79
|
+
| +-- Generate context.md with all findings |
|
|
80
|
+
| +-- Display summary: completed/failed/skipped per wave |
|
|
81
|
+
| +-- Offer: view results | retry failed | done |
|
|
82
|
+
| |
|
|
83
|
+
+-------------------------------------------------------------------------+
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Task Classification Rules
|
|
89
|
+
|
|
90
|
+
Each task is classified by `exec_mode`:
|
|
91
|
+
|
|
92
|
+
| exec_mode | Mechanism | Criteria |
|
|
93
|
+
|-----------|-----------|----------|
|
|
94
|
+
| `csv-wave` | `spawn_agents_on_csv` | One-shot, structured I/O, no multi-round interaction |
|
|
95
|
+
| `interactive` | `spawn_agent`/`wait`/`send_input`/`close_agent` | Multi-round, clarification, inline utility |
|
|
96
|
+
|
|
97
|
+
**Classification Decision**:
|
|
98
|
+
|
|
99
|
+
| Task Property | Classification |
|
|
100
|
+
|---------------|---------------|
|
|
101
|
+
| Ministry implementation (IMPL/OPS/DATA/DOC/HR) | `csv-wave` |
|
|
102
|
+
| Quality assurance with test-fix loop (QA) | `interactive` |
|
|
103
|
+
| Single-department self-contained work | `csv-wave` |
|
|
104
|
+
| Cross-department coordination needed | `interactive` |
|
|
105
|
+
| Requires iterative feedback (test -> fix -> retest) | `interactive` |
|
|
106
|
+
| Standalone analysis or generation | `csv-wave` |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## CSV Schema
|
|
111
|
+
|
|
112
|
+
### tasks.csv (Master State)
|
|
113
|
+
|
|
114
|
+
```csv
|
|
115
|
+
id,title,description,deps,context_from,exec_mode,department,task_prefix,priority,dispatch_batch,acceptance_criteria,wave,status,findings,artifact_path,error
|
|
116
|
+
IMPL-001,"Implement JWT auth","Create JWT authentication middleware with token validation","","","csv-wave","gongbu","IMPL","P0","1","All auth endpoints return valid JWT tokens","1","pending","","",""
|
|
117
|
+
DOC-001,"Write API docs","Generate OpenAPI documentation for auth endpoints","IMPL-001","IMPL-001","csv-wave","libu","DOC","P1","2","API docs cover all auth endpoints","2","pending","","",""
|
|
118
|
+
QA-001,"Test auth module","Execute test suite and validate coverage >= 95%","IMPL-001","IMPL-001","interactive","xingbu","QA","P1","2","Test pass rate >= 95%, no Critical bugs","2","pending","","",""
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Columns**:
|
|
122
|
+
|
|
123
|
+
| Column | Phase | Description |
|
|
124
|
+
|--------|-------|-------------|
|
|
125
|
+
| `id` | Input | Unique task identifier (DEPT-NNN format) |
|
|
126
|
+
| `title` | Input | Short task title |
|
|
127
|
+
| `description` | Input | Detailed task description (self-contained for agent execution) |
|
|
128
|
+
| `deps` | Input | Semicolon-separated dependency task IDs |
|
|
129
|
+
| `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
|
|
130
|
+
| `exec_mode` | Input | `csv-wave` or `interactive` |
|
|
131
|
+
| `department` | Input | Target ministry: gongbu/bingbu/hubu/libu/libu-hr/xingbu |
|
|
132
|
+
| `task_prefix` | Input | Task type prefix: IMPL/OPS/DATA/DOC/HR/QA |
|
|
133
|
+
| `priority` | Input | Priority level: P0 (highest) to P3 (lowest) |
|
|
134
|
+
| `dispatch_batch` | Input | Batch number from Shangshu dispatch plan (1-based) |
|
|
135
|
+
| `acceptance_criteria` | Input | Specific, measurable acceptance criteria from dispatch plan |
|
|
136
|
+
| `wave` | Computed | Wave number (computed by topological sort, 1-based) |
|
|
137
|
+
| `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
|
|
138
|
+
| `findings` | Output | Key discoveries or implementation notes (max 500 chars) |
|
|
139
|
+
| `artifact_path` | Output | Path to output artifact file relative to session dir |
|
|
140
|
+
| `error` | Output | Error message if failed (empty if success) |
|
|
141
|
+
|
|
142
|
+
### Per-Wave CSV (Temporary)
|
|
143
|
+
|
|
144
|
+
Each wave generates a temporary `wave-{N}.csv` with extra `prev_context` column (csv-wave tasks only).
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Agent Registry (Interactive Agents)
|
|
149
|
+
|
|
150
|
+
| Agent | Role File | Pattern | Responsibility | Position |
|
|
151
|
+
|-------|-----------|---------|----------------|----------|
|
|
152
|
+
| zhongshu-planner | agents/zhongshu-planner.md | 2.3 (sequential pipeline) | Draft structured execution plan from edict requirements | standalone (Phase 0, Stage 1) |
|
|
153
|
+
| menxia-reviewer | agents/menxia-reviewer.md | 2.4 (multi-perspective analysis) | Multi-dimensional review with 4 CLI analyses | standalone (Phase 0, Stage 2) |
|
|
154
|
+
| shangshu-dispatcher | agents/shangshu-dispatcher.md | 2.3 (sequential pipeline) | Parse approved plan and generate ministry task assignments | standalone (Phase 0, Stage 3) |
|
|
155
|
+
| qa-verifier | agents/qa-verifier.md | 2.5 (iterative refinement) | Quality assurance with test-fix loop (max 3 rounds) | post-wave |
|
|
156
|
+
| aggregator | agents/aggregator.md | 2.3 (sequential pipeline) | Collect all ministry outputs and generate final report | standalone (Phase 3) |
|
|
157
|
+
|
|
158
|
+
> **COMPACT PROTECTION**: Agent files are execution documents. When context compression occurs, **you MUST immediately `Read` the corresponding agent.md** to reload.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Output Artifacts
|
|
163
|
+
|
|
164
|
+
| File | Purpose | Lifecycle |
|
|
165
|
+
|------|---------|-----------|
|
|
166
|
+
| `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
|
|
167
|
+
| `wave-{N}.csv` | Per-wave input (temporary, csv-wave tasks only) | Created before wave, deleted after |
|
|
168
|
+
| `results.csv` | Final export of all task results | Created in Phase 4 |
|
|
169
|
+
| `discoveries.ndjson` | Shared exploration board (all agents, both modes) | Append-only, carries across waves |
|
|
170
|
+
| `context.md` | Human-readable execution report | Created in Phase 4 |
|
|
171
|
+
| `plan/zhongshu-plan.md` | Zhongshu execution plan | Created in Phase 0 Stage 1 |
|
|
172
|
+
| `review/menxia-review.md` | Menxia review report with 4-dimensional analysis | Created in Phase 0 Stage 2 |
|
|
173
|
+
| `plan/dispatch-plan.md` | Shangshu dispatch plan with ministry assignments | Created in Phase 0 Stage 3 |
|
|
174
|
+
| `artifacts/{dept}-output.md` | Per-ministry output artifact | Created during wave execution |
|
|
175
|
+
| `interactive/{id}-result.json` | Results from interactive tasks (QA loops) | Created per interactive task |
|
|
176
|
+
| `agents/registry.json` | Active interactive agent tracking | Updated on spawn/close |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Session Structure
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
.workflow/.csv-wave/{session-id}/
|
|
184
|
+
+-- tasks.csv # Master state (all tasks, both modes)
|
|
185
|
+
+-- results.csv # Final results export
|
|
186
|
+
+-- discoveries.ndjson # Shared discovery board (all agents)
|
|
187
|
+
+-- context.md # Human-readable report
|
|
188
|
+
+-- wave-{N}.csv # Temporary per-wave input (csv-wave only)
|
|
189
|
+
+-- plan/
|
|
190
|
+
| +-- zhongshu-plan.md # Zhongshu execution plan
|
|
191
|
+
| +-- dispatch-plan.md # Shangshu dispatch plan
|
|
192
|
+
+-- review/
|
|
193
|
+
| +-- menxia-review.md # Menxia review report
|
|
194
|
+
+-- artifacts/
|
|
195
|
+
| +-- gongbu-output.md # Ministry outputs
|
|
196
|
+
| +-- bingbu-output.md
|
|
197
|
+
| +-- hubu-output.md
|
|
198
|
+
| +-- libu-output.md
|
|
199
|
+
| +-- libu-hr-output.md
|
|
200
|
+
| +-- xingbu-report.md
|
|
201
|
+
+-- interactive/ # Interactive task artifacts
|
|
202
|
+
| +-- {id}-result.json # Per-task results
|
|
203
|
+
+-- agents/
|
|
204
|
+
+-- registry.json # Active interactive agent tracking
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Implementation
|
|
210
|
+
|
|
211
|
+
### Session Initialization
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
1. Parse $ARGUMENTS for task description (the "edict")
|
|
215
|
+
2. Generate session ID: EDT-{slug}-{YYYYMMDD-HHmmss}
|
|
216
|
+
3. Create session directory: .workflow/.csv-wave/{session-id}/
|
|
217
|
+
4. Create subdirectories: plan/, review/, artifacts/, interactive/, agents/
|
|
218
|
+
5. Initialize registry.json: { "active": [], "closed": [] }
|
|
219
|
+
6. Initialize discoveries.ndjson (empty file)
|
|
220
|
+
7. Read specs: ~ or <project>/.codex/skills/team-edict/specs/team-config.json
|
|
221
|
+
8. Read quality gates: ~ or <project>/.codex/skills/team-edict/specs/quality-gates.md
|
|
222
|
+
9. Log session start to context.md
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### Phase 0: Pre-Wave Interactive (Three Departments Serial Pipeline)
|
|
228
|
+
|
|
229
|
+
**Objective**: Execute the serial approval pipeline (zhongshu -> menxia -> shangshu) to produce a validated, reviewed dispatch plan that decomposes the edict into ministry-level tasks.
|
|
230
|
+
|
|
231
|
+
#### Stage 1: Zhongshu Planning
|
|
232
|
+
|
|
233
|
+
```javascript
|
|
234
|
+
const zhongshu = spawn_agent({
|
|
235
|
+
message: `
|
|
236
|
+
## TASK ASSIGNMENT
|
|
237
|
+
|
|
238
|
+
### MANDATORY FIRST STEPS (Agent Execute)
|
|
239
|
+
1. **Read role definition**: ~ or <project>/.codex/skills/team-edict/agents/zhongshu-planner.md (MUST read first)
|
|
240
|
+
2. Read: ${sessionDir}/discoveries.ndjson (shared discoveries, skip if not exists)
|
|
241
|
+
3. Read: ~ or <project>/.codex/skills/team-edict/specs/team-config.json (routing rules)
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
Goal: Draft a structured execution plan for the following edict
|
|
246
|
+
Scope: Analyze codebase, decompose into ministry-level subtasks, define acceptance criteria
|
|
247
|
+
Deliverables: ${sessionDir}/plan/zhongshu-plan.md
|
|
248
|
+
|
|
249
|
+
### Edict (Original Requirement)
|
|
250
|
+
${edictText}
|
|
251
|
+
`
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
const zhongshuResult = wait({ ids: [zhongshu], timeout_ms: 600000 })
|
|
255
|
+
|
|
256
|
+
if (zhongshuResult.timed_out) {
|
|
257
|
+
send_input({ id: zhongshu, message: "Please finalize your execution plan immediately and output current findings." })
|
|
258
|
+
const retry = wait({ ids: [zhongshu], timeout_ms: 120000 })
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Store result
|
|
262
|
+
Write(`${sessionDir}/interactive/zhongshu-result.json`, JSON.stringify({
|
|
263
|
+
task_id: "PLAN-001",
|
|
264
|
+
status: "completed",
|
|
265
|
+
findings: parseFindings(zhongshuResult),
|
|
266
|
+
timestamp: new Date().toISOString()
|
|
267
|
+
}))
|
|
268
|
+
|
|
269
|
+
close_agent({ id: zhongshu })
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### Stage 2: Menxia Multi-Dimensional Review
|
|
273
|
+
|
|
274
|
+
**Rejection Loop**: If menxia rejects (approved=false), respawn zhongshu with feedback. Max 3 rounds.
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
let reviewRound = 0
|
|
278
|
+
let approved = false
|
|
279
|
+
|
|
280
|
+
while (!approved && reviewRound < 3) {
|
|
281
|
+
reviewRound++
|
|
282
|
+
|
|
283
|
+
const menxia = spawn_agent({
|
|
284
|
+
message: `
|
|
285
|
+
## TASK ASSIGNMENT
|
|
286
|
+
|
|
287
|
+
### MANDATORY FIRST STEPS (Agent Execute)
|
|
288
|
+
1. **Read role definition**: ~ or <project>/.codex/skills/team-edict/agents/menxia-reviewer.md (MUST read first)
|
|
289
|
+
2. Read: ${sessionDir}/plan/zhongshu-plan.md (plan to review)
|
|
290
|
+
3. Read: ${sessionDir}/discoveries.ndjson (shared discoveries)
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
Goal: Multi-dimensional review of Zhongshu plan (Round ${reviewRound}/3)
|
|
295
|
+
Scope: Feasibility, completeness, risk, resource allocation
|
|
296
|
+
Deliverables: ${sessionDir}/review/menxia-review.md
|
|
297
|
+
|
|
298
|
+
### Original Edict
|
|
299
|
+
${edictText}
|
|
300
|
+
|
|
301
|
+
### Previous Review (if rejection round > 1)
|
|
302
|
+
${reviewRound > 1 ? readPreviousReview() : "First review round"}
|
|
303
|
+
`
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
const menxiaResult = wait({ ids: [menxia], timeout_ms: 600000 })
|
|
307
|
+
|
|
308
|
+
if (menxiaResult.timed_out) {
|
|
309
|
+
send_input({ id: menxia, message: "Please finalize review and output verdict (approved/rejected)." })
|
|
310
|
+
const retry = wait({ ids: [menxia], timeout_ms: 120000 })
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
close_agent({ id: menxia })
|
|
314
|
+
|
|
315
|
+
// Parse verdict from review report
|
|
316
|
+
const reviewReport = Read(`${sessionDir}/review/menxia-review.md`)
|
|
317
|
+
approved = reviewReport.includes("approved") || reviewReport.includes("approved: true")
|
|
318
|
+
|
|
319
|
+
if (!approved && reviewRound < 3) {
|
|
320
|
+
// Respawn zhongshu with rejection feedback (Stage 1 again)
|
|
321
|
+
// ... spawn zhongshu with rejection_feedback = reviewReport ...
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (!approved && reviewRound >= 3) {
|
|
326
|
+
// Max rounds reached, ask user
|
|
327
|
+
AskUserQuestion("Menxia rejected the plan 3 times. Please review and decide: approve, reject, or provide guidance.")
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
#### Stage 3: Shangshu Dispatch
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
const shangshu = spawn_agent({
|
|
335
|
+
message: `
|
|
336
|
+
## TASK ASSIGNMENT
|
|
337
|
+
|
|
338
|
+
### MANDATORY FIRST STEPS (Agent Execute)
|
|
339
|
+
1. **Read role definition**: ~ or <project>/.codex/skills/team-edict/agents/shangshu-dispatcher.md (MUST read first)
|
|
340
|
+
2. Read: ${sessionDir}/plan/zhongshu-plan.md (approved plan)
|
|
341
|
+
3. Read: ${sessionDir}/review/menxia-review.md (review conditions)
|
|
342
|
+
4. Read: ~ or <project>/.codex/skills/team-edict/specs/team-config.json (routing rules)
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
Goal: Parse approved plan and generate Six Ministries dispatch plan
|
|
347
|
+
Scope: Route subtasks to departments, define execution batches, set dependencies
|
|
348
|
+
Deliverables: ${sessionDir}/plan/dispatch-plan.md
|
|
349
|
+
`
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
const shangshuResult = wait({ ids: [shangshu], timeout_ms: 300000 })
|
|
353
|
+
close_agent({ id: shangshu })
|
|
354
|
+
|
|
355
|
+
// Parse dispatch-plan.md to generate tasks.csv (Phase 1 input)
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Success Criteria**:
|
|
359
|
+
- zhongshu-plan.md written with structured subtask list
|
|
360
|
+
- menxia-review.md written with 4-dimensional analysis verdict
|
|
361
|
+
- dispatch-plan.md written with ministry assignments and batch ordering
|
|
362
|
+
- Interactive agents closed, results stored
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
### Phase 1: Requirement -> CSV + Classification
|
|
367
|
+
|
|
368
|
+
**Objective**: Parse the Shangshu dispatch plan into a tasks.csv with proper wave computation and exec_mode classification.
|
|
369
|
+
|
|
370
|
+
**Decomposition Rules**:
|
|
371
|
+
|
|
372
|
+
1. Read `${sessionDir}/plan/dispatch-plan.md`
|
|
373
|
+
2. For each ministry task in the dispatch plan:
|
|
374
|
+
- Extract: task ID, title, description, department, priority, batch number, acceptance criteria
|
|
375
|
+
- Determine dependencies from the dispatch plan's batch ordering and explicit blockedBy
|
|
376
|
+
- Set `context_from` for tasks that need predecessor findings
|
|
377
|
+
3. Apply classification rules (see Task Classification Rules above)
|
|
378
|
+
4. Compute waves via topological sort (Kahn's BFS with depth tracking)
|
|
379
|
+
5. Generate `tasks.csv` with all columns
|
|
380
|
+
|
|
381
|
+
**Classification Rules**:
|
|
382
|
+
|
|
383
|
+
| Department | Default exec_mode | Override Condition |
|
|
384
|
+
|------------|-------------------|-------------------|
|
|
385
|
+
| gongbu (IMPL) | csv-wave | Interactive if requires iterative codebase exploration |
|
|
386
|
+
| bingbu (OPS) | csv-wave | - |
|
|
387
|
+
| hubu (DATA) | csv-wave | - |
|
|
388
|
+
| libu (DOC) | csv-wave | - |
|
|
389
|
+
| libu-hr (HR) | csv-wave | - |
|
|
390
|
+
| xingbu (QA) | interactive | Always interactive (test-fix loop) |
|
|
391
|
+
|
|
392
|
+
**Wave Computation**: Kahn's BFS topological sort with depth tracking (csv-wave tasks only).
|
|
393
|
+
|
|
394
|
+
**User Validation**: Display task breakdown with wave + exec_mode assignment (skip if AUTO_YES).
|
|
395
|
+
|
|
396
|
+
**Success Criteria**:
|
|
397
|
+
- tasks.csv created with valid schema, wave, and exec_mode assignments
|
|
398
|
+
- No circular dependencies
|
|
399
|
+
- User approved (or AUTO_YES)
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
### Phase 2: Wave Execution Engine (Extended)
|
|
404
|
+
|
|
405
|
+
**Objective**: Execute tasks wave-by-wave with hybrid mechanism support and cross-wave context propagation.
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
For each wave W in 1..max_wave:
|
|
409
|
+
|
|
410
|
+
1. FILTER csv-wave tasks where wave == W and status == "pending"
|
|
411
|
+
2. CHECK dependencies: if any dep has status == "failed", mark task as "skipped"
|
|
412
|
+
3. BUILD prev_context for each task from context_from references:
|
|
413
|
+
- For csv-wave predecessors: read findings from master tasks.csv
|
|
414
|
+
- For interactive predecessors: read from interactive/{id}-result.json
|
|
415
|
+
4. GENERATE wave-{W}.csv with prev_context column added
|
|
416
|
+
5. EXECUTE csv-wave tasks:
|
|
417
|
+
spawn_agents_on_csv({
|
|
418
|
+
task_csv_path: "${sessionDir}/wave-{W}.csv",
|
|
419
|
+
instruction_path: "~ or <project>/.codex/skills/team-edict/instructions/agent-instruction.md",
|
|
420
|
+
schema_path: "~ or <project>/.codex/skills/team-edict/schemas/tasks-schema.md",
|
|
421
|
+
additional_instructions: "Session directory: ${sessionDir}. Department: {department}. Priority: {priority}.",
|
|
422
|
+
concurrency: CONCURRENCY
|
|
423
|
+
})
|
|
424
|
+
6. MERGE results back into master tasks.csv (update status, findings, artifact_path, error)
|
|
425
|
+
7. EXECUTE interactive tasks for this wave (post-wave):
|
|
426
|
+
For each interactive task in wave W:
|
|
427
|
+
Read agents/qa-verifier.md
|
|
428
|
+
Spawn QA verifier agent with task context + wave results
|
|
429
|
+
Handle test-fix loop via send_input
|
|
430
|
+
Store result in interactive/{id}-result.json
|
|
431
|
+
Close agent, update registry.json
|
|
432
|
+
8. CLEANUP: delete wave-{W}.csv
|
|
433
|
+
9. LOG wave completion to context.md and discoveries.ndjson
|
|
434
|
+
|
|
435
|
+
Wave completion check:
|
|
436
|
+
- All tasks completed or skipped -> proceed to next wave
|
|
437
|
+
- Any failed non-skippable task -> log error, continue (dependents will be skipped)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Success Criteria**:
|
|
441
|
+
- All waves executed in order
|
|
442
|
+
- Both csv-wave and interactive tasks handled per wave
|
|
443
|
+
- Each wave's results merged into master CSV before next wave starts
|
|
444
|
+
- Dependent tasks skipped when predecessor failed
|
|
445
|
+
- discoveries.ndjson accumulated across all waves and mechanisms
|
|
446
|
+
- Interactive agent lifecycle tracked in registry.json
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
### Phase 3: Post-Wave Interactive (Quality Aggregation)
|
|
451
|
+
|
|
452
|
+
**Objective**: Collect all ministry outputs, validate against quality gates, and generate the final edict completion report.
|
|
453
|
+
|
|
454
|
+
```javascript
|
|
455
|
+
const aggregator = spawn_agent({
|
|
456
|
+
message: `
|
|
457
|
+
## TASK ASSIGNMENT
|
|
458
|
+
|
|
459
|
+
### MANDATORY FIRST STEPS (Agent Execute)
|
|
460
|
+
1. **Read role definition**: ~ or <project>/.codex/skills/team-edict/agents/aggregator.md (MUST read first)
|
|
461
|
+
2. Read: ${sessionDir}/tasks.csv (master state)
|
|
462
|
+
3. Read: ${sessionDir}/discoveries.ndjson (all discoveries)
|
|
463
|
+
4. Read: ~ or <project>/.codex/skills/team-edict/specs/quality-gates.md (quality standards)
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
Goal: Aggregate all ministry outputs into final edict completion report
|
|
468
|
+
Scope: All artifacts in ${sessionDir}/artifacts/, all interactive results
|
|
469
|
+
Deliverables: ${sessionDir}/context.md (final report)
|
|
470
|
+
|
|
471
|
+
### Ministry Artifacts to Collect
|
|
472
|
+
${listAllArtifacts()}
|
|
473
|
+
|
|
474
|
+
### Quality Gate Standards
|
|
475
|
+
Read from: ~ or <project>/.codex/skills/team-edict/specs/quality-gates.md
|
|
476
|
+
`
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
const aggResult = wait({ ids: [aggregator], timeout_ms: 300000 })
|
|
480
|
+
close_agent({ id: aggregator })
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**Success Criteria**:
|
|
484
|
+
- Post-wave interactive processing complete
|
|
485
|
+
- Interactive agents closed, results stored
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
### Phase 4: Results Aggregation
|
|
490
|
+
|
|
491
|
+
**Objective**: Generate final results and human-readable report.
|
|
492
|
+
|
|
493
|
+
```
|
|
494
|
+
1. READ master tasks.csv
|
|
495
|
+
2. EXPORT results.csv with final status for all tasks
|
|
496
|
+
3. GENERATE context.md (if not already done by aggregator):
|
|
497
|
+
- Edict summary
|
|
498
|
+
- Pipeline stages: Planning -> Review -> Dispatch -> Execution
|
|
499
|
+
- Per-department output summaries
|
|
500
|
+
- Quality gate results
|
|
501
|
+
- Discoveries summary
|
|
502
|
+
4. DISPLAY summary to user:
|
|
503
|
+
- Total tasks: N (completed: X, failed: Y, skipped: Z)
|
|
504
|
+
- Per-wave breakdown
|
|
505
|
+
- Key findings
|
|
506
|
+
5. CLEANUP:
|
|
507
|
+
- Close any remaining interactive agents (registry.json)
|
|
508
|
+
- Remove temporary wave CSV files
|
|
509
|
+
6. OFFER: view full report | retry failed tasks | done
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Success Criteria**:
|
|
513
|
+
- results.csv exported (all tasks, both modes)
|
|
514
|
+
- context.md generated
|
|
515
|
+
- All interactive agents closed (registry.json cleanup)
|
|
516
|
+
- Summary displayed to user
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
## Shared Discovery Board Protocol
|
|
521
|
+
|
|
522
|
+
All agents (both csv-wave and interactive) share a single `discoveries.ndjson` file for cross-agent knowledge propagation.
|
|
523
|
+
|
|
524
|
+
### Discovery Types
|
|
525
|
+
|
|
526
|
+
| Type | Dedup Key | Data Schema | Description |
|
|
527
|
+
|------|-----------|-------------|-------------|
|
|
528
|
+
| `codebase_pattern` | `pattern_name` | `{pattern_name, files, description}` | Identified codebase patterns and conventions |
|
|
529
|
+
| `dependency_found` | `dep_name` | `{dep_name, version, used_by}` | External dependency discoveries |
|
|
530
|
+
| `risk_identified` | `risk_id` | `{risk_id, severity, description, mitigation}` | Risk findings from any agent |
|
|
531
|
+
| `implementation_note` | `file_path` | `{file_path, note, line_range}` | Implementation decisions and notes |
|
|
532
|
+
| `test_result` | `test_suite` | `{test_suite, pass_rate, failures}` | Test execution results |
|
|
533
|
+
| `quality_issue` | `issue_id` | `{issue_id, severity, file, description}` | Quality issues found during review |
|
|
534
|
+
| `routing_note` | `task_id` | `{task_id, department, reason}` | Dispatch routing decisions |
|
|
535
|
+
|
|
536
|
+
### Protocol
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
# Append discovery (any agent, any mode)
|
|
540
|
+
echo '{"ts":"<ISO8601>","worker":"{id}","type":"<type>","data":{...}}' >> ${sessionDir}/discoveries.ndjson
|
|
541
|
+
|
|
542
|
+
# Read discoveries (any agent, any mode)
|
|
543
|
+
# Read ${sessionDir}/discoveries.ndjson, parse each line as JSON
|
|
544
|
+
# Deduplicate by type + dedup_key
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### Rules
|
|
548
|
+
- **Append-only**: Never modify or delete existing entries
|
|
549
|
+
- **Deduplicate on read**: When reading, use type + dedup_key to skip duplicates
|
|
550
|
+
- **Both mechanisms share**: csv-wave agents and interactive agents use the same file
|
|
551
|
+
- **Carry across waves**: Discoveries persist across all waves
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## Six Ministries Routing Rules
|
|
556
|
+
|
|
557
|
+
Shangshu dispatcher uses these rules to assign tasks to ministries:
|
|
558
|
+
|
|
559
|
+
| Keyword Signals | Target Ministry | Role ID | Task Prefix |
|
|
560
|
+
|----------------|-----------------|---------|-------------|
|
|
561
|
+
| Feature dev, architecture, code, refactor, implement, API | Engineering | gongbu | IMPL |
|
|
562
|
+
| Deploy, CI/CD, infrastructure, container, monitoring, security ops | Operations | bingbu | OPS |
|
|
563
|
+
| Data analysis, statistics, cost, reports, resource mgmt | Data & Resources | hubu | DATA |
|
|
564
|
+
| Documentation, README, UI copy, specs, API docs, comms | Documentation | libu | DOC |
|
|
565
|
+
| Testing, QA, bug, code review, compliance audit | Quality Assurance | xingbu | QA |
|
|
566
|
+
| Agent management, training, skill optimization, evaluation | Personnel | libu-hr | HR |
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
## Kanban State Protocol
|
|
571
|
+
|
|
572
|
+
All agents must report state transitions. In Codex context, agents write state to discoveries.ndjson:
|
|
573
|
+
|
|
574
|
+
### State Machine
|
|
575
|
+
|
|
576
|
+
```
|
|
577
|
+
Pending -> Doing -> Done
|
|
578
|
+
|
|
|
579
|
+
Blocked (can enter at any time, must report reason)
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### State Reporting via Discoveries
|
|
583
|
+
|
|
584
|
+
```bash
|
|
585
|
+
# Task start
|
|
586
|
+
echo '{"ts":"<ISO8601>","worker":"{id}","type":"state_update","data":{"state":"Doing","task_id":"{id}","department":"{department}","step":"Starting execution"}}' >> ${sessionDir}/discoveries.ndjson
|
|
587
|
+
|
|
588
|
+
# Progress update
|
|
589
|
+
echo '{"ts":"<ISO8601>","worker":"{id}","type":"progress","data":{"task_id":"{id}","current":"Step 2: Implementing API","plan":"Step1 done|Step2 in progress|Step3 pending"}}' >> ${sessionDir}/discoveries.ndjson
|
|
590
|
+
|
|
591
|
+
# Completion
|
|
592
|
+
echo '{"ts":"<ISO8601>","worker":"{id}","type":"state_update","data":{"state":"Done","task_id":"{id}","remark":"Completed: implementation summary"}}' >> ${sessionDir}/discoveries.ndjson
|
|
593
|
+
|
|
594
|
+
# Blocked
|
|
595
|
+
echo '{"ts":"<ISO8601>","worker":"{id}","type":"state_update","data":{"state":"Blocked","task_id":"{id}","reason":"Cannot proceed: missing dependency"}}' >> ${sessionDir}/discoveries.ndjson
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## Interactive Task Execution
|
|
601
|
+
|
|
602
|
+
For interactive tasks within a wave (primarily QA test-fix loops):
|
|
603
|
+
|
|
604
|
+
**Spawn Protocol**:
|
|
605
|
+
|
|
606
|
+
```javascript
|
|
607
|
+
const agent = spawn_agent({
|
|
608
|
+
message: `
|
|
609
|
+
## TASK ASSIGNMENT
|
|
610
|
+
|
|
611
|
+
### MANDATORY FIRST STEPS (Agent Execute)
|
|
612
|
+
1. **Read role definition**: ~ or <project>/.codex/skills/team-edict/agents/qa-verifier.md (MUST read first)
|
|
613
|
+
2. Read: ${sessionDir}/discoveries.ndjson (shared discoveries)
|
|
614
|
+
3. Read: ~ or <project>/.codex/skills/team-edict/specs/quality-gates.md (quality standards)
|
|
615
|
+
|
|
616
|
+
---
|
|
617
|
+
|
|
618
|
+
Goal: Execute QA verification for task ${taskId}
|
|
619
|
+
Scope: ${taskDescription}
|
|
620
|
+
Deliverables: Test report + pass/fail verdict
|
|
621
|
+
|
|
622
|
+
### Previous Context
|
|
623
|
+
${prevContextFromCompletedTasks}
|
|
624
|
+
|
|
625
|
+
### Acceptance Criteria
|
|
626
|
+
${acceptanceCriteria}
|
|
627
|
+
`
|
|
628
|
+
})
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
**Wait + Process**:
|
|
632
|
+
|
|
633
|
+
```javascript
|
|
634
|
+
const result = wait({ ids: [agent], timeout_ms: 600000 })
|
|
635
|
+
|
|
636
|
+
if (result.timed_out) {
|
|
637
|
+
send_input({ id: agent, message: "Please finalize and output current findings." })
|
|
638
|
+
const retry = wait({ ids: [agent], timeout_ms: 120000 })
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Store result
|
|
642
|
+
Write(`${sessionDir}/interactive/${taskId}-result.json`, JSON.stringify({
|
|
643
|
+
task_id: taskId,
|
|
644
|
+
status: "completed",
|
|
645
|
+
findings: parseFindings(result),
|
|
646
|
+
timestamp: new Date().toISOString()
|
|
647
|
+
}))
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
**Lifecycle Tracking**:
|
|
651
|
+
|
|
652
|
+
```javascript
|
|
653
|
+
// On spawn: register
|
|
654
|
+
registry.active.push({ id: agent, task_id: taskId, pattern: "qa-verifier", spawned_at: now })
|
|
655
|
+
|
|
656
|
+
// On close: move to closed
|
|
657
|
+
close_agent({ id: agent })
|
|
658
|
+
registry.active = registry.active.filter(a => a.id !== agent)
|
|
659
|
+
registry.closed.push({ id: agent, task_id: taskId, closed_at: now })
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
---
|
|
663
|
+
|
|
664
|
+
## Cross-Mechanism Context Bridging
|
|
665
|
+
|
|
666
|
+
### Interactive Result -> CSV Task
|
|
667
|
+
|
|
668
|
+
When a pre-wave interactive task produces results needed by csv-wave tasks:
|
|
669
|
+
|
|
670
|
+
```javascript
|
|
671
|
+
// 1. Interactive result stored in file
|
|
672
|
+
const resultFile = `${sessionDir}/interactive/${taskId}-result.json`
|
|
673
|
+
|
|
674
|
+
// 2. Wave engine reads when building prev_context for csv-wave tasks
|
|
675
|
+
// If a csv-wave task has context_from referencing an interactive task:
|
|
676
|
+
// Read the interactive result file and include in prev_context
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
### CSV Result -> Interactive Task
|
|
680
|
+
|
|
681
|
+
When a post-wave interactive task needs CSV wave results:
|
|
682
|
+
|
|
683
|
+
```javascript
|
|
684
|
+
// Include in spawn message
|
|
685
|
+
const csvFindings = readMasterCSV().filter(t => t.wave === currentWave && t.exec_mode === 'csv-wave')
|
|
686
|
+
const context = csvFindings.map(t => `## Task ${t.id}: ${t.title}\n${t.findings}`).join('\n\n')
|
|
687
|
+
|
|
688
|
+
spawn_agent({
|
|
689
|
+
message: `...\n### Wave ${currentWave} Results\n${context}\n...`
|
|
690
|
+
})
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
## Error Handling
|
|
696
|
+
|
|
697
|
+
| Error | Resolution |
|
|
698
|
+
|-------|------------|
|
|
699
|
+
| Circular dependency | Detect in wave computation, abort with error message |
|
|
700
|
+
| CSV agent timeout | Mark as failed in results, continue with wave |
|
|
701
|
+
| CSV agent failed | Mark as failed, skip dependent tasks in later waves |
|
|
702
|
+
| Interactive agent timeout | Urge convergence via send_input, then close if still timed out |
|
|
703
|
+
| Interactive agent failed | Mark as failed, skip dependents |
|
|
704
|
+
| Pre-wave interactive failed | Skip dependent csv-wave tasks in same wave |
|
|
705
|
+
| All agents in wave failed | Log error, offer retry or abort |
|
|
706
|
+
| CSV parse error | Validate CSV format before execution, show line number |
|
|
707
|
+
| discoveries.ndjson corrupt | Ignore malformed lines, continue with valid entries |
|
|
708
|
+
| Lifecycle leak | Cleanup all active agents via registry.json at end |
|
|
709
|
+
| Continue mode: no session found | List available sessions, prompt user to select |
|
|
710
|
+
| Menxia rejection loop >= 3 rounds | AskUserQuestion for user decision |
|
|
711
|
+
| Zhongshu plan file missing | Abort Phase 0, report error |
|
|
712
|
+
| Shangshu dispatch plan parse failure | Abort, ask user to review dispatch-plan.md |
|
|
713
|
+
| Ministry artifact not written | Mark task as failed, include in QA report |
|
|
714
|
+
| Test-fix loop exceeds 3 rounds | Mark QA as failed, report to aggregator |
|
|
715
|
+
|
|
716
|
+
---
|
|
717
|
+
|
|
718
|
+
## Specs Reference
|
|
719
|
+
|
|
720
|
+
| File | Content | Used By |
|
|
721
|
+
|------|---------|---------|
|
|
722
|
+
| [specs/team-config.json](specs/team-config.json) | Role registry, routing rules, pipeline definition, session structure, artifact paths | Orchestrator (session init), Shangshu (routing), all agents (artifact paths) |
|
|
723
|
+
| [specs/quality-gates.md](specs/quality-gates.md) | Per-phase quality gate standards, cross-phase consistency checks | Aggregator (Phase 3), QA verifier (test validation) |
|
|
724
|
+
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
## Core Rules
|
|
728
|
+
|
|
729
|
+
1. **Start Immediately**: First action is session initialization, then Phase 0
|
|
730
|
+
2. **Wave Order is Sacred**: Never execute wave N before wave N-1 completes and results are merged
|
|
731
|
+
3. **CSV is Source of Truth**: Master tasks.csv holds all state (both csv-wave and interactive)
|
|
732
|
+
4. **CSV First**: Default to csv-wave for tasks; only use interactive when interaction pattern requires it
|
|
733
|
+
5. **Context Propagation**: prev_context built from master CSV, not from memory
|
|
734
|
+
6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson -- both mechanisms share it
|
|
735
|
+
7. **Skip on Failure**: If a dependency failed, skip the dependent task (regardless of mechanism)
|
|
736
|
+
8. **Lifecycle Balance**: Every spawn_agent MUST have a matching close_agent (tracked in registry.json)
|
|
737
|
+
9. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
|
|
738
|
+
10. **DO NOT STOP**: Continuous execution until all waves complete or all remaining tasks are skipped
|
|
739
|
+
11. **Three Departments are Serial**: Zhongshu -> Menxia -> Shangshu must execute in strict order
|
|
740
|
+
12. **Rejection Loop Max 3**: Menxia can reject max 3 times before escalating to user
|
|
741
|
+
13. **Kanban is Mandatory**: All agents must report state transitions via discoveries.ndjson
|
|
742
|
+
14. **Quality Gates Apply**: Phase 3 aggregator validates all outputs against specs/quality-gates.md
|
|
743
|
+
|
|
744
|
+
---
|
|
745
|
+
|
|
746
|
+
## Coordinator Role Constraints (Crown Prince / Main Agent)
|
|
747
|
+
|
|
748
|
+
**CRITICAL**: The coordinator (main agent executing this skill) is responsible for **orchestration only**, NOT implementation.
|
|
749
|
+
|
|
750
|
+
15. **Coordinator Does NOT Execute Code**: The main agent MUST NOT write, modify, or implement any code directly. All implementation work is delegated to spawned agents (Three Departments and Six Ministries). The coordinator only:
|
|
751
|
+
- Spawns agents with task assignments
|
|
752
|
+
- Waits for agent callbacks
|
|
753
|
+
- Merges results into master CSV
|
|
754
|
+
- Coordinates workflow transitions between phases
|
|
755
|
+
|
|
756
|
+
16. **Patient Waiting is Mandatory**: Agent execution takes significant time (typically 10-30 minutes per phase, sometimes longer). The coordinator MUST:
|
|
757
|
+
- Wait patiently for `wait()` calls to complete
|
|
758
|
+
- NOT skip workflow steps due to perceived delays
|
|
759
|
+
- NOT assume agents have failed just because they're taking time
|
|
760
|
+
- Trust the timeout mechanisms (600s for planning, 300s for execution)
|
|
761
|
+
|
|
762
|
+
17. **Use send_input for Clarification**: When agents need guidance or appear stuck, the coordinator MUST:
|
|
763
|
+
- Use `send_input()` to ask questions or provide clarification
|
|
764
|
+
- NOT skip the agent or move to next phase prematurely
|
|
765
|
+
- Give agents opportunity to respond before escalating
|
|
766
|
+
- Example: `send_input({ id: agent_id, message: "Please provide status update or clarify blockers" })`
|
|
767
|
+
|
|
768
|
+
18. **No Workflow Shortcuts**: The coordinator MUST NOT:
|
|
769
|
+
- Skip phases or stages (e.g., jumping from Zhongshu directly to Shangshu)
|
|
770
|
+
- Bypass the Three Departments serial pipeline
|
|
771
|
+
- Execute wave N before wave N-1 completes
|
|
772
|
+
- Assume task completion without explicit agent callback
|
|
773
|
+
- Make up or fabricate agent results
|
|
774
|
+
|
|
775
|
+
19. **Respect Long-Running Processes**: This is a complex multi-agent workflow that requires patience:
|
|
776
|
+
- Total execution time: 30-90 minutes for typical edicts
|
|
777
|
+
- Phase 0 (Three Departments): 15-30 minutes
|
|
778
|
+
- Phase 2 (Wave Execution): 10-20 minutes per wave
|
|
779
|
+
- Phase 3 (Aggregation): 5-10 minutes
|
|
780
|
+
- The coordinator must remain active and attentive throughout the entire process
|
|
781
|
+
|