Skip to content

Commit a94c790

Browse files
author
catlog22
committed
feat: Enhance workflow execution and documentation processes
- Added compact protection directives to execution phases to ensure critical instructions are preserved during context compression. - Introduced checkpoints in execution steps to verify active memory of execution protocols. - Created new command files for team lifecycle roles: - `dispatch.md`: Manage task chains based on execution modes. - `monitor.md`: Event-driven pipeline coordination with worker callbacks. - `critique.md`: Multi-perspective CLI critique for structured analysis. - `implement.md`: Multi-backend code implementation with retry and fallback mechanisms. - `explore.md`: Complexity-driven codebase exploration for task planning. - `generate-doc.md`: Multi-CLI document generation for various document types. - Updated SKILL.md to include compact protection patterns and phase reference documentation.
1 parent f10351e commit a94c790

10 files changed

Lines changed: 1059 additions & 54 deletions

File tree

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Command: dispatch
2+
3+
## Purpose
4+
5+
Create task chains based on execution mode. Each mode maps to a predefined pipeline from SKILL.md Task Metadata Registry. Tasks are created with proper dependency chains, owner assignments, and session references.
6+
7+
## Phase 2: Context Loading
8+
9+
| Input | Source | Required |
10+
|-------|--------|----------|
11+
| Mode | Phase 1 requirements (spec-only, impl-only, etc.) | Yes |
12+
| Session folder | `<session-folder>` from Phase 2 | Yes |
13+
| Scope | User requirements description | Yes |
14+
| Spec file | User-provided path (impl-only mode only) | Conditional |
15+
16+
## Phase 3: Task Chain Creation
17+
18+
### Mode-to-Pipeline Routing
19+
20+
| Mode | Tasks | Pipeline | First Task |
21+
|------|-------|----------|------------|
22+
| spec-only | 12 | Spec pipeline | RESEARCH-001 |
23+
| impl-only | 4 | Impl pipeline | PLAN-001 |
24+
| fe-only | 3 | FE pipeline | PLAN-001 |
25+
| fullstack | 6 | Fullstack pipeline | PLAN-001 |
26+
| full-lifecycle | 16 | Spec + Impl | RESEARCH-001 |
27+
| full-lifecycle-fe | 18 | Spec + Fullstack | RESEARCH-001 |
28+
29+
---
30+
31+
### Spec Pipeline (12 tasks)
32+
33+
Used by: spec-only, full-lifecycle, full-lifecycle-fe
34+
35+
| # | Subject | Owner | BlockedBy | Description |
36+
|---|---------|-------|-----------|-------------|
37+
| 1 | RESEARCH-001 | analyst | (none) | Seed analysis and context gathering |
38+
| 2 | DISCUSS-001 | discussant | RESEARCH-001 | Critique research findings |
39+
| 3 | DRAFT-001 | writer | DISCUSS-001 | Generate Product Brief |
40+
| 4 | DISCUSS-002 | discussant | DRAFT-001 | Critique Product Brief |
41+
| 5 | DRAFT-002 | writer | DISCUSS-002 | Generate Requirements/PRD |
42+
| 6 | DISCUSS-003 | discussant | DRAFT-002 | Critique Requirements/PRD |
43+
| 7 | DRAFT-003 | writer | DISCUSS-003 | Generate Architecture Document |
44+
| 8 | DISCUSS-004 | discussant | DRAFT-003 | Critique Architecture Document |
45+
| 9 | DRAFT-004 | writer | DISCUSS-004 | Generate Epics |
46+
| 10 | DISCUSS-005 | discussant | DRAFT-004 | Critique Epics |
47+
| 11 | QUALITY-001 | reviewer | DISCUSS-005 | 5-dimension spec quality validation |
48+
| 12 | DISCUSS-006 | discussant | QUALITY-001 | Final review discussion and sign-off |
49+
50+
### Impl Pipeline (4 tasks)
51+
52+
Used by: impl-only, full-lifecycle (PLAN-001 blockedBy DISCUSS-006)
53+
54+
| # | Subject | Owner | BlockedBy | Description |
55+
|---|---------|-------|-----------|-------------|
56+
| 1 | PLAN-001 | planner | (none) | Multi-angle exploration and planning |
57+
| 2 | IMPL-001 | executor | PLAN-001 | Code implementation |
58+
| 3 | TEST-001 | tester | IMPL-001 | Test-fix cycles |
59+
| 4 | REVIEW-001 | reviewer | IMPL-001 | 4-dimension code review |
60+
61+
### FE Pipeline (3 tasks)
62+
63+
Used by: fe-only
64+
65+
| # | Subject | Owner | BlockedBy | Description |
66+
|---|---------|-------|-----------|-------------|
67+
| 1 | PLAN-001 | planner | (none) | Planning (frontend focus) |
68+
| 2 | DEV-FE-001 | fe-developer | PLAN-001 | Frontend implementation |
69+
| 3 | QA-FE-001 | fe-qa | DEV-FE-001 | 5-dimension frontend QA |
70+
71+
GC loop (max 2 rounds): QA-FE verdict=NEEDS_FIX → create DEV-FE-002 + QA-FE-002 dynamically.
72+
73+
### Fullstack Pipeline (6 tasks)
74+
75+
Used by: fullstack, full-lifecycle-fe (PLAN-001 blockedBy DISCUSS-006)
76+
77+
| # | Subject | Owner | BlockedBy | Description |
78+
|---|---------|-------|-----------|-------------|
79+
| 1 | PLAN-001 | planner | (none) | Fullstack planning |
80+
| 2 | IMPL-001 | executor | PLAN-001 | Backend implementation |
81+
| 3 | DEV-FE-001 | fe-developer | PLAN-001 | Frontend implementation |
82+
| 4 | TEST-001 | tester | IMPL-001 | Backend test-fix cycles |
83+
| 5 | QA-FE-001 | fe-qa | DEV-FE-001 | Frontend QA |
84+
| 6 | REVIEW-001 | reviewer | TEST-001, QA-FE-001 | Full code review |
85+
86+
### Composite Modes
87+
88+
| Mode | Construction | PLAN-001 BlockedBy |
89+
|------|-------------|-------------------|
90+
| full-lifecycle | Spec (12) + Impl (4) | DISCUSS-006 |
91+
| full-lifecycle-fe | Spec (12) + Fullstack (6) | DISCUSS-006 |
92+
93+
---
94+
95+
### Impl-Only Pre-check
96+
97+
Before creating impl-only tasks, verify specification exists:
98+
99+
```
100+
Spec exists?
101+
├─ YES → read spec path → proceed with task creation
102+
└─ NO → error: "impl-only requires existing spec, use spec-only or full-lifecycle"
103+
```
104+
105+
### Task Description Template
106+
107+
Every task description includes session and scope context:
108+
109+
```
110+
TaskCreate({
111+
subject: "<TASK-ID>",
112+
owner: "<role>",
113+
description: "<task description from pipeline table>\nSession: <session-folder>\nScope: <scope>",
114+
blockedBy: [<dependency-list>],
115+
status: "pending"
116+
})
117+
```
118+
119+
### Execution Method
120+
121+
| Method | Behavior |
122+
|--------|----------|
123+
| sequential | One task active at a time; next activated after predecessor completes |
124+
| parallel | Tasks with all deps met run concurrently (e.g., TEST-001 + REVIEW-001) |
125+
126+
## Phase 4: Validation
127+
128+
| Check | Criteria |
129+
|-------|----------|
130+
| Task count | Matches mode total from routing table |
131+
| Dependencies | Every blockedBy references an existing task subject |
132+
| Owner assignment | Each task owner matches SKILL.md Role Registry prefix |
133+
| Session reference | Every task description contains `Session: <session-folder>` |
134+
135+
## Error Handling
136+
137+
| Scenario | Resolution |
138+
|----------|------------|
139+
| Unknown mode | Reject with supported mode list |
140+
| Missing spec for impl-only | Error, suggest spec-only or full-lifecycle |
141+
| TaskCreate fails | Log error, report to user |
142+
| Duplicate task subject | Skip creation, log warning |
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Command: monitor
2+
3+
## Purpose
4+
5+
Event-driven pipeline coordination with Spawn-and-Stop pattern. Three wake-up sources drive pipeline advancement: worker callbacks (auto-advance), user `check` (status report), user `resume` (manual advance).
6+
7+
## Constants
8+
9+
| Constant | Value | Description |
10+
|----------|-------|-------------|
11+
| SPAWN_MODE | background | All workers spawned via `Task(run_in_background: true)` |
12+
| ONE_STEP_PER_INVOCATION | true | Coordinator does one operation then STOPS |
13+
14+
## Phase 2: Context Loading
15+
16+
| Input | Source | Required |
17+
|-------|--------|----------|
18+
| Session file | `<session-folder>/team-session.json` | Yes |
19+
| Task list | `TaskList()` | Yes |
20+
| Active workers | session.active_workers[] | Yes |
21+
| Pipeline mode | session.mode | Yes |
22+
23+
## Phase 3: Handler Routing
24+
25+
### Wake-up Source Detection
26+
27+
Parse `$ARGUMENTS` to determine handler:
28+
29+
| Priority | Condition | Handler |
30+
|----------|-----------|---------|
31+
| 1 | Message contains `[<role-name>]` from known worker role | handleCallback |
32+
| 2 | Contains "check" or "status" | handleCheck |
33+
| 3 | Contains "resume", "continue", or "next" | handleResume |
34+
| 4 | None of the above (initial spawn after dispatch) | handleSpawnNext |
35+
36+
Known worker roles: analyst, writer, discussant, planner, executor, tester, reviewer, explorer, architect, fe-developer, fe-qa.
37+
38+
---
39+
40+
### Handler: handleCallback
41+
42+
Worker completed a task. Verify completion, update state, auto-advance.
43+
44+
```
45+
Receive callback from [<role>]
46+
├─ Find matching active worker by role
47+
├─ Task status = completed?
48+
│ ├─ YES → remove from active_workers → update session
49+
│ │ ├─ Handle checkpoints (see below)
50+
│ │ └─ → handleSpawnNext
51+
│ └─ NO → progress message, do not advance → STOP
52+
└─ No matching worker found
53+
├─ Scan all active workers for completed tasks
54+
├─ Found completed → process each → handleSpawnNext
55+
└─ None completed → STOP
56+
```
57+
58+
---
59+
60+
### Handler: handleCheck
61+
62+
Read-only status report. No pipeline advancement.
63+
64+
**Output format**:
65+
66+
```
67+
[coordinator] Pipeline Status
68+
[coordinator] Mode: <mode> | Progress: <completed>/<total> (<percent>%)
69+
70+
[coordinator] Execution Graph:
71+
Spec Phase: (if applicable)
72+
[<icon> RESEARCH-001] → [<icon> DISCUSS-001] → ...
73+
Impl Phase: (if applicable)
74+
[<icon> PLAN-001]
75+
├─ BE: [<icon> IMPL-001] → [<icon> TEST-001] → [<icon> REVIEW-001]
76+
└─ FE: [<icon> DEV-FE-001] → [<icon> QA-FE-001]
77+
78+
done=completed >>>=running o=pending .=not created
79+
80+
[coordinator] Active Workers:
81+
> <subject> (<role>) - running <elapsed>
82+
83+
[coordinator] Ready to spawn: <subjects>
84+
[coordinator] Commands: 'resume' to advance | 'check' to refresh
85+
```
86+
87+
**Icon mapping**: completed=done, in_progress=>>>, pending=o, not created=.
88+
89+
Then STOP.
90+
91+
---
92+
93+
### Handler: handleResume
94+
95+
Check active worker completion, process results, advance pipeline.
96+
97+
```
98+
Load active_workers from session
99+
├─ No active workers → handleSpawnNext
100+
└─ Has active workers → check each:
101+
├─ status = completed → mark done, log
102+
├─ status = in_progress → still running, log
103+
└─ other status → worker failure → reset to pending
104+
After processing:
105+
├─ Some completed → handleSpawnNext
106+
├─ All still running → report status → STOP
107+
└─ All failed → handleSpawnNext (retry)
108+
```
109+
110+
---
111+
112+
### Handler: handleSpawnNext
113+
114+
Find all ready tasks, spawn workers in background, update session, STOP.
115+
116+
```
117+
Collect task states from TaskList()
118+
├─ completedSubjects: status = completed
119+
├─ inProgressSubjects: status = in_progress
120+
└─ readySubjects: pending + all blockedBy in completedSubjects
121+
122+
Ready tasks found?
123+
├─ NONE + work in progress → report waiting → STOP
124+
├─ NONE + nothing in progress → PIPELINE_COMPLETE → Phase 5
125+
└─ HAS ready tasks → for each:
126+
├─ TaskUpdate → in_progress
127+
├─ team_msg log → task_unblocked
128+
├─ Spawn worker (see tool call below)
129+
└─ Add to session.active_workers
130+
Update session file → output summary → STOP
131+
```
132+
133+
**Spawn worker tool call** (one per ready task):
134+
135+
```bash
136+
Task({
137+
subagent_type: "general-purpose",
138+
description: "Spawn <role> worker for <subject>",
139+
team_name: <team-name>,
140+
name: "<role>",
141+
run_in_background: true,
142+
prompt: "<worker prompt from SKILL.md Coordinator Spawn Template>"
143+
})
144+
```
145+
146+
---
147+
148+
### Checkpoints
149+
150+
| Completed Task | Mode Condition | Action |
151+
|---------------|----------------|--------|
152+
| DISCUSS-006 | full-lifecycle or full-lifecycle-fe | Output "SPEC PHASE COMPLETE" checkpoint, pause for user review before impl |
153+
154+
---
155+
156+
### Worker Failure Handling
157+
158+
When a worker has unexpected status (not completed, not in_progress):
159+
160+
1. Reset task → pending via TaskUpdate
161+
2. Log via team_msg (type: error)
162+
3. Report to user: task reset, will retry on next resume
163+
164+
## Phase 4: Validation
165+
166+
| Check | Criteria |
167+
|-------|----------|
168+
| Session state consistent | active_workers matches TaskList in_progress tasks |
169+
| No orphaned tasks | Every in_progress task has an active_worker entry |
170+
| Pipeline completeness | All expected tasks exist per mode |
171+
| Completion detection | readySubjects=0 + inProgressSubjects=0 → PIPELINE_COMPLETE |
172+
173+
## Error Handling
174+
175+
| Scenario | Resolution |
176+
|----------|------------|
177+
| Session file not found | Error, suggest re-initialization |
178+
| Worker callback from unknown role | Log info, scan for other completions |
179+
| All workers still running on resume | Report status, suggest check later |
180+
| Pipeline stall (no ready, no running) | Check for missing tasks, report to user |

0 commit comments

Comments
 (0)