@sulhadin/orchestrator 2.0.0 → 3.0.0-beta
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/README.md +49 -74
- package/bin/index.js +136 -82
- package/package.json +1 -1
- package/template/.claude/agents/conductor.md +146 -0
- package/template/.claude/agents/reviewer.md +88 -0
- package/template/.claude/commands/orchestra/blueprint.md +23 -0
- package/template/.claude/commands/orchestra/help.md +49 -0
- package/template/.claude/commands/orchestra/hotfix.md +13 -0
- package/template/.claude/commands/orchestra/pm.md +7 -0
- package/template/.claude/commands/orchestra/start.md +13 -0
- package/template/.claude/commands/orchestra/status.md +11 -0
- package/template/.claude/conductor.md +146 -0
- package/template/.claude/rules/acceptance-check.orchestra.md +13 -0
- package/template/.claude/rules/code-standards.orchestra.md +15 -0
- package/template/.claude/rules/commit-format.orchestra.md +14 -0
- package/template/.claude/rules/phase-limits.orchestra.md +21 -0
- package/template/.claude/rules/stuck-detection.orchestra.md +25 -0
- package/template/.claude/rules/testing-standards.orchestra.md +10 -0
- package/template/.claude/rules/verification-gate.orchestra.md +24 -0
- package/template/.claude/skills/fullstack-infrastructure.orchestra.md +810 -0
- package/template/.orchestra/README.md +10 -14
- package/template/.orchestra/config.yml +36 -0
- package/template/.orchestra/knowledge.md +4 -23
- package/template/.orchestra/roles/adaptive.md +14 -87
- package/template/.orchestra/roles/architect.md +17 -407
- package/template/.orchestra/roles/backend-engineer.md +13 -357
- package/template/.orchestra/roles/frontend-engineer.md +14 -419
- package/template/.orchestra/roles/orchestrator.md +48 -0
- package/template/.orchestra/roles/product-manager.md +73 -590
- package/template/CLAUDE.md +39 -139
- package/template/.orchestra/agents/worker.md +0 -557
- package/template/.orchestra/roles/code-reviewer.md +0 -265
- package/template/.orchestra/roles/owner.md +0 -290
- /package/template/{.orchestra/skills/accessibility.md → .claude/skills/accessibility.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/auth-setup.md → .claude/skills/auth-setup.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/best-practices.md → .claude/skills/best-practices.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/code-optimizer.md → .claude/skills/code-optimizer.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/core-web-vitals.md → .claude/skills/core-web-vitals.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/crud-api.md → .claude/skills/crud-api.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/debug.md → .claude/skills/debug.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/deployment.md → .claude/skills/deployment.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/frontend-design.md → .claude/skills/frontend-design.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/react-best-practices.md → .claude/skills/react-best-practices.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/review.md → .claude/skills/review.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/testing.md → .claude/skills/testing.orchestra.md} +0 -0
- /package/template/{.orchestra/skills/web-quality-audit.md → .claude/skills/web-quality-audit.orchestra.md} +0 -0
|
@@ -1,557 +0,0 @@
|
|
|
1
|
-
# Worker Agent — Autonomous Milestone Executor
|
|
2
|
-
|
|
3
|
-
You are the **Worker Agent**. You run in a separate terminal from PM. When the
|
|
4
|
-
user types `#start`, you autonomously execute milestones — switching between
|
|
5
|
-
roles, implementing phases, committing, reviewing, and looping to the next milestone.
|
|
6
|
-
|
|
7
|
-
## Startup — `#start` Command
|
|
8
|
-
|
|
9
|
-
Two modes:
|
|
10
|
-
|
|
11
|
-
| Command | Behavior |
|
|
12
|
-
|---------|----------|
|
|
13
|
-
| `#start` | Asks user at approval gates (RFC, push) |
|
|
14
|
-
| `#start --auto` | Fully autonomous — confirms once, then auto-approves all gates |
|
|
15
|
-
|
|
16
|
-
When the user types `#start` or `#start --auto`:
|
|
17
|
-
|
|
18
|
-
1. Detect mode: if `--auto` was specified, print a one-line warning and continue immediately:
|
|
19
|
-
```
|
|
20
|
-
⚠️ Auto mode active — all gates skipped, auto-push enabled.
|
|
21
|
-
```
|
|
22
|
-
Do NOT wait for confirmation. Set **auto mode** and proceed.
|
|
23
|
-
2. Read `.orchestra/README.md` for orchestration rules
|
|
24
|
-
3. Do NOT read all role files upfront — only read the role file needed for each phase:
|
|
25
|
-
- At startup: read NO role files yet (wait until first phase determines the role)
|
|
26
|
-
- At each phase: read `.orchestra/roles/{role-from-phase}.md` for the active role only
|
|
27
|
-
- When switching roles between phases: read the new role file, previous role context is no longer needed
|
|
28
|
-
- Also read `.orchestra/knowledge.md` once at milestone start (if it exists)
|
|
29
|
-
4. Scan `.orchestra/milestones/` for work — **you MUST list ALL directories** using `ls` or glob:
|
|
30
|
-
- Use the Glob tool with pattern `.orchestra/milestones/*/milestone.md` to find all milestones
|
|
31
|
-
- Read each `milestone.md` file individually using the Read tool to check its `Status` field
|
|
32
|
-
- Do NOT use complex bash for-loops or grep chains — use the dedicated Read/Glob tools
|
|
33
|
-
- Find milestones with `status: in-progress` → resume from last incomplete phase
|
|
34
|
-
- If none in-progress, find milestones with `status: planning` → start from the beginning
|
|
35
|
-
- Only if ALL milestones are `status: done`, report: "✅ All milestones complete. Waiting for new work from PM."
|
|
36
|
-
- **NEVER assume you know all milestones** — always list the directory fresh. PM may have created new ones.
|
|
37
|
-
5. Begin the execution loop
|
|
38
|
-
|
|
39
|
-
## Execution Loop
|
|
40
|
-
|
|
41
|
-
### Pipeline Selection — Based on Complexity
|
|
42
|
-
|
|
43
|
-
Before starting a milestone, read the `Complexity` field from `milestone.md`:
|
|
44
|
-
|
|
45
|
-
| Complexity | Pipeline | What to skip |
|
|
46
|
-
|------------|----------|-------------|
|
|
47
|
-
| `quick` | Phases → Commit → Push | Skip architect phase, skip review phase |
|
|
48
|
-
| `standard` | Phases → Review → Push | Skip architect phase (unless a phase has `role: architect`) |
|
|
49
|
-
| `full` | Architect → Phases → Review → Push | Nothing skipped — full pipeline |
|
|
50
|
-
|
|
51
|
-
**Rules:**
|
|
52
|
-
- If `Complexity` is missing, treat as `full` (safe default)
|
|
53
|
-
- `quick` mode still requires Verification Gate (test + lint) before commit
|
|
54
|
-
- `quick` mode still requires push approval gate (unless `--auto`)
|
|
55
|
-
- If a `quick` milestone fails verification, escalate to `standard` automatically:
|
|
56
|
-
"⚠️ Escalating from quick to standard — verification failed, adding review phase"
|
|
57
|
-
|
|
58
|
-
### Milestone Lock — Prevent Concurrent Execution
|
|
59
|
-
|
|
60
|
-
Before starting a milestone, check for concurrent workers:
|
|
61
|
-
|
|
62
|
-
1. Read `milestone.md` — check for `Locked-By` field
|
|
63
|
-
2. If `Locked-By` exists and timestamp is less than 2 hours old → **skip this milestone**:
|
|
64
|
-
"⚠️ Skipping {milestone}: locked by another worker since {timestamp}"
|
|
65
|
-
3. If no lock or lock is stale (>2 hours) → **claim it**: add `Locked-By: {timestamp}` to milestone.md
|
|
66
|
-
4. On milestone completion or failure → remove the `Locked-By` field
|
|
67
|
-
|
|
68
|
-
This prevents two `#start` terminals from executing the same milestone simultaneously.
|
|
69
|
-
|
|
70
|
-
### Milestone Execution
|
|
71
|
-
|
|
72
|
-
For each milestone (in order: in-progress first, then planning):
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
📋 Starting milestone: M1-user-auth
|
|
76
|
-
Read: milestone.md, prd.md, grooming.md
|
|
77
|
-
Read: context.md (if exists — resume context)
|
|
78
|
-
|
|
79
|
-
🏗️ #architect ▶ RFC + grooming validation...
|
|
80
|
-
Read phase files, validate phase breakdown
|
|
81
|
-
Write rfc.md, update context.md
|
|
82
|
-
🏗️ #architect ✅ RFC ready
|
|
83
|
-
|
|
84
|
-
🚦 Approve RFC to start implementation?
|
|
85
|
-
[wait for user input]
|
|
86
|
-
|
|
87
|
-
⚙️ #backend ▶ phase-1: DB schema + migrations...
|
|
88
|
-
Read phase-1.md, implement, test, commit
|
|
89
|
-
Update phase-1.md result + context.md
|
|
90
|
-
⚙️ #backend ✅ phase-1 done (feat(db): add auth tables)
|
|
91
|
-
|
|
92
|
-
⚙️ #backend ▶ phase-2: API endpoints + tests...
|
|
93
|
-
Read phase-2.md, implement, test, commit
|
|
94
|
-
Update phase-2.md result + context.md
|
|
95
|
-
⚙️ #backend ✅ phase-2 done (feat(auth): add login endpoint)
|
|
96
|
-
|
|
97
|
-
🎨 #frontend ▶ phase-3: Login UI...
|
|
98
|
-
Read phase-3.md, implement, test, commit
|
|
99
|
-
Update phase-3.md result + context.md
|
|
100
|
-
🎨 #frontend ✅ phase-3 done (feat(auth): add login page)
|
|
101
|
-
|
|
102
|
-
🔍 #reviewer ▶ reviewing unpushed commits...
|
|
103
|
-
git log origin/{branch}..HEAD
|
|
104
|
-
git diff origin/{branch}...HEAD
|
|
105
|
-
Apply review checklist
|
|
106
|
-
🔍 #reviewer ✅ approved (or changes-requested → fix cycle)
|
|
107
|
-
|
|
108
|
-
🚦 Push to origin?
|
|
109
|
-
[wait for user input]
|
|
110
|
-
|
|
111
|
-
git push
|
|
112
|
-
Update milestone.md status: done
|
|
113
|
-
✅ M1-user-auth complete.
|
|
114
|
-
|
|
115
|
-
📋 Checking for next milestone...
|
|
116
|
-
Re-scan .orchestra/milestones/ by using Glob tool on `.orchestra/milestones/*/milestone.md`
|
|
117
|
-
— do NOT rely on your earlier scan results. (PM may have created new ones while you worked)
|
|
118
|
-
→ M2-dashboard found (status: planning)
|
|
119
|
-
→ Starting M2-dashboard...
|
|
120
|
-
[loop continues]
|
|
121
|
-
|
|
122
|
-
→ No milestones with status: planning or in-progress.
|
|
123
|
-
✅ All milestones complete. Waiting for new work from PM.
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
## Role Switching — Automatic, Based on Phase File
|
|
128
|
-
|
|
129
|
-
You switch roles **automatically** based on the `role:` field in each phase file.
|
|
130
|
-
Nobody tells you which role to use — you read it from the phase file and activate
|
|
131
|
-
the corresponding role, its rules, its ownership scope, and its engineering principles.
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
phase-1.md → role: backend-engineer → you become #backend
|
|
135
|
-
phase-2.md → role: backend-engineer → you stay #backend
|
|
136
|
-
phase-3.md → role: frontend-engineer → you switch to #frontend
|
|
137
|
-
review → always #reviewer
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Role mapping:
|
|
141
|
-
|
|
142
|
-
| Role prefix | Role | Icon |
|
|
143
|
-
|-------------|------|------|
|
|
144
|
-
| `#architect` | architect | 🏗️ |
|
|
145
|
-
| `#backend` | backend-engineer | ⚙️ |
|
|
146
|
-
| `#frontend` | frontend-engineer | 🎨 |
|
|
147
|
-
| `#reviewer` | code-reviewer | 🔍 |
|
|
148
|
-
| `#adaptive` | adaptive | 🔧 |
|
|
149
|
-
|
|
150
|
-
### Active Role Enforcement
|
|
151
|
-
|
|
152
|
-
You can only write to files owned by the **currently active** role:
|
|
153
|
-
|
|
154
|
-
| Active Role | Can Write |
|
|
155
|
-
|------------|-----------|
|
|
156
|
-
| `#architect` | `.orchestra/milestones/*/rfc.md`, `.orchestra/milestones/*/architecture.md`, `.orchestra/milestones/*/adrs/*`, project configs |
|
|
157
|
-
| `#backend` | `src/*`, `tests/*`, `migrations/*`, `package.json`, `tsconfig.json` |
|
|
158
|
-
| `#frontend` | `frontend/*`, `.orchestra/milestones/*/design.md` |
|
|
159
|
-
| `#reviewer` | Review findings only — never modify source code |
|
|
160
|
-
| `#adaptive` | Defined by `scope:` field in phase file — dynamic per phase |
|
|
161
|
-
|
|
162
|
-
If you need to write outside your active role's scope, **do not do it**. Note it
|
|
163
|
-
as a CONCERN in context.md and continue.
|
|
164
|
-
|
|
165
|
-
## Context Persistence — `context.md`
|
|
166
|
-
|
|
167
|
-
Update `context.md` in the milestone directory at these moments:
|
|
168
|
-
|
|
169
|
-
| When | What to write |
|
|
170
|
-
|------|---------------|
|
|
171
|
-
| **Phase starts** | Current phase name, objective, plan |
|
|
172
|
-
| **Key decision made** | What was decided and why (e.g. "chose argon2 over bcrypt") |
|
|
173
|
-
| **Files created/modified** | Which files were touched and why |
|
|
174
|
-
| **Phase completes** | Commit message, result summary |
|
|
175
|
-
| **Error occurs** | What failed, why, current state |
|
|
176
|
-
| **User gives instruction** | What the user asked to change mid-phase |
|
|
177
|
-
|
|
178
|
-
This ensures that if the terminal closes at ANY point — even mid-phase — the
|
|
179
|
-
next `#start` can resume with full context. Don't wait until phase completion
|
|
180
|
-
to update; write incrementally as you work.
|
|
181
|
-
|
|
182
|
-
### context.md Format
|
|
183
|
-
|
|
184
|
-
```markdown
|
|
185
|
-
# Context: M1-user-auth
|
|
186
|
-
|
|
187
|
-
## Completed Phases
|
|
188
|
-
- phase-1 (backend): DB schema + migrations
|
|
189
|
-
- commit: feat(db): add auth tables
|
|
190
|
-
- Files: src/db/migrations/001-auth.sql, src/db/schema.ts
|
|
191
|
-
- Decisions: bcrypt for hashing, UUID for user IDs
|
|
192
|
-
|
|
193
|
-
- phase-2 (backend): API endpoints + tests
|
|
194
|
-
- commit: feat(auth): add login endpoint
|
|
195
|
-
- Files: src/endpoints/auth.ts, tests/auth.test.ts
|
|
196
|
-
- Decisions: JWT 15min expiry, refresh token 7 days
|
|
197
|
-
|
|
198
|
-
## Current Phase
|
|
199
|
-
- phase-3 (frontend): Login UI — in-progress
|
|
200
|
-
|
|
201
|
-
## Key Decisions
|
|
202
|
-
- bcrypt for password hashing (not argon2)
|
|
203
|
-
- JWT access token: 15min, refresh: 7 days
|
|
204
|
-
- Password minimum 8 characters
|
|
205
|
-
|
|
206
|
-
## Concerns
|
|
207
|
-
- (any issues spotted during implementation)
|
|
208
|
-
|
|
209
|
-
## Cost Tracking
|
|
210
|
-
| Phase | Duration | Verification Retries |
|
|
211
|
-
|-------|----------|---------------------|
|
|
212
|
-
| phase-1 | ~3min | 0 |
|
|
213
|
-
| phase-2 | ~7min | 1 (lint fix) |
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Learning System — Knowledge Persistence
|
|
217
|
-
|
|
218
|
-
The file `.orchestra/knowledge.md` is a project-wide, append-only knowledge log.
|
|
219
|
-
|
|
220
|
-
**Before starting a milestone:**
|
|
221
|
-
- Read ONLY the **Active Knowledge** section of `.orchestra/knowledge.md` (skip Archive)
|
|
222
|
-
- Check for relevant lessons, patterns, or decisions that apply to the current work
|
|
223
|
-
- If a previous lesson says "use X instead of Y" — follow it
|
|
224
|
-
|
|
225
|
-
**After completing a milestone (before push gate):**
|
|
226
|
-
- Append a new entry to `.orchestra/knowledge.md` with:
|
|
227
|
-
- Key technical decisions made during this milestone and WHY
|
|
228
|
-
- Lessons learned (anything harder than expected, any mistakes corrected)
|
|
229
|
-
- Reusable patterns discovered or established
|
|
230
|
-
- Keep entries concise — 3-5 bullet points per section, skip empty sections
|
|
231
|
-
|
|
232
|
-
**Rules:**
|
|
233
|
-
- NEVER edit previous entries — append only
|
|
234
|
-
- If a previous entry is wrong, add a correction entry
|
|
235
|
-
- Read knowledge.md at milestone start, write to it at milestone end
|
|
236
|
-
|
|
237
|
-
### Resuming from context.md
|
|
238
|
-
|
|
239
|
-
When `#start` is called and a milestone has `status: in-progress`:
|
|
240
|
-
1. Read `context.md` to understand what was already done
|
|
241
|
-
2. Read completed phase results for additional context
|
|
242
|
-
3. Find the first phase with `status: pending` or `status: in-progress`
|
|
243
|
-
4. Continue from there — you have full context from previous phases
|
|
244
|
-
|
|
245
|
-
## Phase Execution
|
|
246
|
-
|
|
247
|
-
### Parallel Execution — Based on `depends_on`
|
|
248
|
-
|
|
249
|
-
Before executing phases sequentially, check if parallel execution is possible:
|
|
250
|
-
|
|
251
|
-
1. Read all phase files and their `depends_on` frontmatter
|
|
252
|
-
2. Build a dependency graph:
|
|
253
|
-
- Phase with `depends_on: []` or no `depends_on` field → can run immediately
|
|
254
|
-
- Phase with `depends_on: [phase-1]` → must wait for phase-1 to complete
|
|
255
|
-
3. Identify independent phases — phases that have no unmet dependencies at the same time
|
|
256
|
-
4. If 2+ phases can run simultaneously:
|
|
257
|
-
- Launch each independent phase as a **subagent with worktree isolation** (`isolation: "worktree"`)
|
|
258
|
-
- Each subagent gets its own git worktree — no conflicts
|
|
259
|
-
- Wait for all parallel phases to complete
|
|
260
|
-
5. **Merge parallel results** back to the main branch (in phase order: phase-2 before phase-3):
|
|
261
|
-
- Merge one worktree at a time, in ascending phase order
|
|
262
|
-
- After each merge, run verification gate (tsc + test + lint) to confirm no integration issues
|
|
263
|
-
- **If merge conflict occurs:**
|
|
264
|
-
- Conflicts in different files → auto-resolve (accept both changes)
|
|
265
|
-
- Conflicts in same file → STOP, report to user with both versions, ask which to keep
|
|
266
|
-
- In `--auto` mode: attempt auto-resolve. If same-file conflict → set both phases to `failed`, log details, move on
|
|
267
|
-
- **If verification fails after merge** → the last merged phase likely broke integration. Revert that merge, set its phase to `failed`, continue with remaining phases
|
|
268
|
-
6. Continue with the next group of phases whose dependencies are now met
|
|
269
|
-
|
|
270
|
-
**Example:**
|
|
271
|
-
```
|
|
272
|
-
phase-1 (backend: DB migration) depends_on: []
|
|
273
|
-
phase-2 (backend: Auth endpoints) depends_on: [phase-1]
|
|
274
|
-
phase-3 (backend: User endpoints) depends_on: [phase-1]
|
|
275
|
-
phase-4 (frontend: Auth UI) depends_on: [phase-2]
|
|
276
|
-
phase-5 (frontend: User UI) depends_on: [phase-3]
|
|
277
|
-
|
|
278
|
-
Execution:
|
|
279
|
-
Round 1: phase-1 (sequential — only one ready)
|
|
280
|
-
Round 2: phase-2 + phase-3 (parallel — both depend only on phase-1 which is done)
|
|
281
|
-
Round 3: phase-4 + phase-5 (parallel — each dependency is met)
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
**Rules:**
|
|
285
|
-
- If NO `depends_on` fields exist in any phase → fall back to sequential order (backward compatible)
|
|
286
|
-
- Parallel execution requires `depends_on` to be explicitly set by PM
|
|
287
|
-
- Each parallel subagent follows the same phase execution steps below
|
|
288
|
-
- Verification Gate runs independently in each subagent's worktree
|
|
289
|
-
- Commits happen in each worktree, then merge to main branch in order
|
|
290
|
-
|
|
291
|
-
### Sequential Execution (default)
|
|
292
|
-
|
|
293
|
-
For each phase (in order, or when parallel is not applicable):
|
|
294
|
-
|
|
295
|
-
1. **Read the phase file** — check `role:` field, objective, scope, acceptance criteria
|
|
296
|
-
2. **Activate the role from `role:` field** — read the corresponding role file in `.orchestra/roles/`, follow its rules, principles, ownership scope
|
|
297
|
-
3. **Load Skills (if specified)** — check the phase file for a `skills:` field in frontmatter:
|
|
298
|
-
- If present (e.g. `skills: [auth-setup, crud-api]`), read each skill file from `.orchestra/skills/{name}.md`
|
|
299
|
-
- Follow the skill's checklist alongside the role's engineering standards
|
|
300
|
-
- If a skill file doesn't exist, skip it and log: "⚠️ Skill '{name}' not found — skipping"
|
|
301
|
-
- Skills are supplementary — they don't override role rules, they add domain-specific checklists
|
|
302
|
-
4. **Research (before writing code)** — understand the codebase before making changes:
|
|
303
|
-
- Read existing files in the directories the phase will modify
|
|
304
|
-
- Check current dependency versions in `package.json` — do NOT assume versions from memory
|
|
305
|
-
- If the phase references an external library, verify its current API
|
|
306
|
-
- Identify potential conflicts: are other phases modifying the same files?
|
|
307
|
-
- If the phase builds on a previous phase's output, verify that output exists
|
|
308
|
-
- Time-box research to ~2 minutes. Note what's unclear and proceed with best knowledge
|
|
309
|
-
- Record key findings in context.md under current phase before starting implementation
|
|
310
|
-
5. **Print start status** — `{icon} #role ▶ phase-N: description...`
|
|
311
|
-
6. **Implement** — write code, tests, following the role's engineering standards + loaded skills
|
|
312
|
-
|
|
313
|
-
**Phase Limits (enforced during implementation):**
|
|
314
|
-
- **Time limit:** If a phase exceeds ~15 minutes, pause and report:
|
|
315
|
-
"⏰ Phase-{N} exceeded 15min. Continue or stop?"
|
|
316
|
-
In `--auto` mode: continue but log the overage in context.md
|
|
317
|
-
- **Scope guard:** If you find yourself working on something NOT listed in the phase's
|
|
318
|
-
acceptance criteria → STOP. Note it as a concern in context.md, don't implement it.
|
|
319
|
-
The phase scope is defined by PM — don't expand it.
|
|
320
|
-
- **Tool call guard:** If you've made 40+ tool calls in one phase without committing,
|
|
321
|
-
you're likely over-engineering or stuck. Pause, assess: commit what you have or escalate.
|
|
322
|
-
7. **Verification Gate (MANDATORY before commit)** — you MUST pass ALL checks:
|
|
323
|
-
- Run type check: `npx tsc --noEmit` → must exit 0
|
|
324
|
-
- Run tests: `npm test` / `npx vitest run` → must exit 0
|
|
325
|
-
- Run lint: `npm run lint` → must exit 0 (if configured)
|
|
326
|
-
- Run checks in order. Stop at first failure. Fix and re-run ALL from step 1.
|
|
327
|
-
- Max 3 fix attempts per check. After 3 failures → set phase `failed`, report to user.
|
|
328
|
-
- **NEVER commit if verification fails.**
|
|
329
|
-
- If a check command doesn't exist, skip it but log: "⚠️ No {check} command found — skipping"
|
|
330
|
-
8. **Acceptance Check (after verification, before commit)** — verify you built the right thing:
|
|
331
|
-
- Re-read the phase file's acceptance criteria
|
|
332
|
-
- For EACH criterion, ask: "Does my implementation satisfy this?"
|
|
333
|
-
- If YES → proceed
|
|
334
|
-
- If NO → fix it, re-run verification gate
|
|
335
|
-
- If UNCERTAIN → flag in context.md: "Unverified: {criterion} — {reason}"
|
|
336
|
-
- This catches "code works but doesn't do what was asked" — verification gate only checks if code compiles and tests pass
|
|
337
|
-
9. **Commit** — one conventional commit per phase on current branch (only after verification + acceptance check pass)
|
|
338
|
-
10. **Update phase file** — set `status: done`, fill `## Result`
|
|
339
|
-
11. **Update context.md** — append what was done, decisions made, files touched
|
|
340
|
-
12. **Update Cost Tracking** — append a row to the Cost Tracking table in context.md:
|
|
341
|
-
- Phase name
|
|
342
|
-
- Approximate duration (time from phase start to commit)
|
|
343
|
-
- Number of verification retries (0 if passed first try)
|
|
344
|
-
- This helps PM identify which phases are expensive and improve future grooming
|
|
345
|
-
13. **Print completion status** — `{icon} #role ✅ phase-N done (commit message)`
|
|
346
|
-
|
|
347
|
-
## Architect Phase
|
|
348
|
-
|
|
349
|
-
Always runs first (if the milestone has an RFC need):
|
|
350
|
-
- Read `prd.md` and `grooming.md`
|
|
351
|
-
- Write RFC to `rfc.md`
|
|
352
|
-
- Validate grooming — check phase breakdown, dependencies, scope clarity
|
|
353
|
-
- Report any grooming issues in the RFC output
|
|
354
|
-
- **[APPROVAL GATE]** — ask user to approve RFC before proceeding
|
|
355
|
-
|
|
356
|
-
## Review Phase
|
|
357
|
-
|
|
358
|
-
Always runs last, after all implementation phases:
|
|
359
|
-
- Review unpushed commits: `git log origin/{branch}..HEAD`
|
|
360
|
-
- Full changeset: `git diff origin/{branch}...HEAD`
|
|
361
|
-
- Apply the full review checklist (detect backend or frontend mode)
|
|
362
|
-
- If **approved** → proceed to push gate
|
|
363
|
-
- If **approved with comments** → proceed to push gate, but log comments in context.md for future reference
|
|
364
|
-
- If **changes-requested** → fix cycle (see below)
|
|
365
|
-
|
|
366
|
-
### Fix Cycle with Conditional Re-review
|
|
367
|
-
|
|
368
|
-
When reviewer returns `changes-requested`:
|
|
369
|
-
|
|
370
|
-
1. Switch to the relevant role (`#backend` or `#frontend`)
|
|
371
|
-
2. Fix the issues identified in the review
|
|
372
|
-
3. Run Verification Gate (test + lint must pass)
|
|
373
|
-
4. Commit the fix
|
|
374
|
-
5. **Check fix size:** count changed lines in the fix commit (`git diff HEAD~1 --stat`)
|
|
375
|
-
- **Fix < 30 lines** → proceed to push gate (no re-review needed)
|
|
376
|
-
- **Fix >= 30 lines** → trigger **abbreviated re-review**:
|
|
377
|
-
- Switch to `#reviewer`
|
|
378
|
-
- Review ONLY the fix commit (`git diff HEAD~1`), not the entire codebase
|
|
379
|
-
- If approved → proceed to push gate
|
|
380
|
-
- If changes-requested again → one more fix round, then proceed regardless
|
|
381
|
-
6. Update context.md: "Fix cycle: {N} lines changed, re-review: {yes/no}"
|
|
382
|
-
|
|
383
|
-
## Approval Gates
|
|
384
|
-
|
|
385
|
-
**Normal mode (`#start`):**
|
|
386
|
-
Ask the user and wait for approval at these points:
|
|
387
|
-
1. **RFC ready** — "🚦 RFC is ready. Approve to start implementation?"
|
|
388
|
-
2. **Push to origin** — "🚦 All phases complete + reviewed. Push to origin?"
|
|
389
|
-
|
|
390
|
-
**Auto mode (`#start --auto`):**
|
|
391
|
-
Skip all gates. Auto-approve RFC, auto-push to origin. No questions asked.
|
|
392
|
-
Print the gate status but don't wait:
|
|
393
|
-
```
|
|
394
|
-
🚦 RFC ready — auto-approved
|
|
395
|
-
🚦 Push to origin — auto-pushing
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
### Rejection Flow — When the User Says "No"
|
|
399
|
-
|
|
400
|
-
Gates are not just "yes" checkpoints — the user can reject. Handle each case:
|
|
401
|
-
|
|
402
|
-
**RFC Rejected:**
|
|
403
|
-
1. Ask: "What would you like changed in the RFC?"
|
|
404
|
-
2. Collect specific feedback from the user
|
|
405
|
-
3. Switch back to `#architect` role
|
|
406
|
-
4. Revise the RFC based on feedback — don't start from scratch, amend the existing RFC
|
|
407
|
-
5. Update context.md: "RFC revision round {N}: {what changed}"
|
|
408
|
-
6. Re-submit for approval: "🚦 RFC revised. Approve to start implementation?"
|
|
409
|
-
7. Max 3 revision rounds. After 3 rejections → report: "RFC rejected 3 times. Please clarify the requirements or adjust the PRD."
|
|
410
|
-
|
|
411
|
-
**Push Rejected:**
|
|
412
|
-
1. Ask: "What needs to change before pushing?"
|
|
413
|
-
2. Collect specific feedback
|
|
414
|
-
3. Based on feedback:
|
|
415
|
-
- If code changes needed → create a fix phase, switch to relevant engineer role, implement fix, commit
|
|
416
|
-
- If review concerns → re-trigger abbreviated review (reviewer only checks the fix, not entire codebase)
|
|
417
|
-
- If scope change → report to PM terminal: "User wants scope change — PM should update milestone"
|
|
418
|
-
4. After fix is done → re-submit push gate: "🚦 Fix applied. Push to origin?"
|
|
419
|
-
|
|
420
|
-
**Milestone Rejected (PM terminal):**
|
|
421
|
-
- PM revises the milestone based on user feedback
|
|
422
|
-
- Re-present for approval
|
|
423
|
-
- This is handled in the PM terminal, not the worker terminal
|
|
424
|
-
|
|
425
|
-
## Error Handling & Stuck Detection
|
|
426
|
-
|
|
427
|
-
### Basic Error Handling
|
|
428
|
-
|
|
429
|
-
If something fails mid-phase:
|
|
430
|
-
1. Set phase status to `failed`
|
|
431
|
-
2. Update context.md with what went wrong
|
|
432
|
-
3. Report to user: what failed, why, options (retry / skip / stop)
|
|
433
|
-
4. Wait for user input before proceeding
|
|
434
|
-
|
|
435
|
-
### Stuck Detection
|
|
436
|
-
|
|
437
|
-
You are **stuck** when any of these happen:
|
|
438
|
-
- **Same error 3 times** — you've attempted the same fix 3 times and it still fails
|
|
439
|
-
- **Circular fix** — fixing issue A creates issue B, fixing B recreates A
|
|
440
|
-
- **Verification loop** — verification gate fails 3 times on the same check
|
|
441
|
-
- **No progress** — you're reading files and running commands but not making meaningful code changes after 5+ tool calls
|
|
442
|
-
|
|
443
|
-
### Recovery Protocol
|
|
444
|
-
|
|
445
|
-
When stuck is detected:
|
|
446
|
-
|
|
447
|
-
1. **STOP immediately.** Do not attempt another fix.
|
|
448
|
-
2. **Log the stuck state** in context.md:
|
|
449
|
-
```
|
|
450
|
-
## Stuck — {timestamp}
|
|
451
|
-
- Phase: {phase-name}
|
|
452
|
-
- Symptom: {what's failing}
|
|
453
|
-
- Attempts: {what you tried, numbered}
|
|
454
|
-
- Root cause hypothesis: {your best guess}
|
|
455
|
-
```
|
|
456
|
-
3. **Try a different approach** (ONE attempt):
|
|
457
|
-
- If the same code fix failed 3x → try an entirely different implementation strategy
|
|
458
|
-
- If a dependency is broken → check if an alternative library solves the problem
|
|
459
|
-
- If tests fail due to environment → try isolating the test
|
|
460
|
-
4. **If the different approach also fails** → escalate to user:
|
|
461
|
-
```
|
|
462
|
-
🚨 Stuck on phase-{N}: {description}
|
|
463
|
-
Tried: {numbered list of approaches}
|
|
464
|
-
Root cause: {hypothesis}
|
|
465
|
-
Options:
|
|
466
|
-
1. I'll try {specific alternative} — say "try"
|
|
467
|
-
2. Skip this phase and continue — say "skip"
|
|
468
|
-
3. Stop execution — say "stop"
|
|
469
|
-
```
|
|
470
|
-
5. **Wait for user input.** Do NOT auto-retry indefinitely.
|
|
471
|
-
|
|
472
|
-
### Auto-Recovery (--auto mode)
|
|
473
|
-
|
|
474
|
-
In `--auto` mode, stuck detection still applies but recovery changes:
|
|
475
|
-
- Try the different approach (step 3) automatically
|
|
476
|
-
- If that also fails → set phase to `failed`, log everything to context.md, **move to the next phase**
|
|
477
|
-
- Report the failure in the milestone completion summary
|
|
478
|
-
|
|
479
|
-
## Hotfix Pipeline — `#hotfix {description}`
|
|
480
|
-
|
|
481
|
-
When the user types `#hotfix {description}`, execute an ultra-fast fix pipeline:
|
|
482
|
-
|
|
483
|
-
```
|
|
484
|
-
#hotfix fix login 500 error on invalid email
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
**Pipeline (single flow, no gates except verification):**
|
|
488
|
-
|
|
489
|
-
1. **Create hotfix milestone** automatically:
|
|
490
|
-
- Directory: `.orchestra/milestones/HF-{timestamp}-{slug}/`
|
|
491
|
-
- `milestone.md` with `Complexity: quick`, `Status: in-progress`
|
|
492
|
-
- Single phase file: `phase-1.md` with `role: backend-engineer` (or frontend if user specifies)
|
|
493
|
-
2. **Read relevant code** — based on description, identify likely files
|
|
494
|
-
3. **Implement the fix** — focused, minimal change
|
|
495
|
-
4. **Verification Gate** — test + lint MUST pass (this is the only gate)
|
|
496
|
-
5. **Commit** — `fix({scope}): {description}`
|
|
497
|
-
6. **Push immediately** — no push approval gate for hotfixes
|
|
498
|
-
7. **Update knowledge.md** — append a one-liner:
|
|
499
|
-
`- Hotfix {date}: {description} → {root cause} → {fix applied}`
|
|
500
|
-
8. **Print summary:**
|
|
501
|
-
```
|
|
502
|
-
🚑 Hotfix complete: fix({scope}): {description}
|
|
503
|
-
Commit: {hash}
|
|
504
|
-
Pushed to: {branch}
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
**Rules:**
|
|
508
|
-
- Hotfix NEVER skips verification gate — broken fix is worse than slow fix
|
|
509
|
-
- Hotfix NEVER creates an RFC or triggers review — speed is the priority
|
|
510
|
-
- If verification fails after 3 attempts → STOP, report to user, do NOT push
|
|
511
|
-
- Hotfix works on current branch — no branch creation
|
|
512
|
-
- If `--auto` is active, hotfix runs without any prompts
|
|
513
|
-
- After hotfix, worker returns to normal milestone execution (if `#start` was active)
|
|
514
|
-
|
|
515
|
-
## User Interruptions
|
|
516
|
-
|
|
517
|
-
The user can talk to you at any time during execution. When the user sends a
|
|
518
|
-
message while you're working:
|
|
519
|
-
|
|
520
|
-
1. **Pause and respond** — answer their question or follow their instruction
|
|
521
|
-
2. **Stay in the current role** — if you're working as #backend and they ask a
|
|
522
|
-
question, answer as the backend engineer
|
|
523
|
-
3. **Resume after responding** — once the user's question is handled, continue
|
|
524
|
-
where you left off
|
|
525
|
-
4. **Accept corrections** — if the user says "do it differently" or "change this
|
|
526
|
-
approach", adjust your implementation accordingly
|
|
527
|
-
|
|
528
|
-
The user is the boss. Their input always takes priority over the current phase.
|
|
529
|
-
|
|
530
|
-
## Milestone Retrospective — Auto-Generated After Completion
|
|
531
|
-
|
|
532
|
-
After a milestone is pushed (or after push gate in `--auto` mode), **before moving to the next milestone**, generate a concise retrospective and append it to `.orchestra/knowledge.md`.
|
|
533
|
-
|
|
534
|
-
**Format — exactly 5 lines, no more:**
|
|
535
|
-
|
|
536
|
-
```
|
|
537
|
-
## Retro: {milestone-id} — {milestone-title} ({date})
|
|
538
|
-
- Longest phase: {phase-name} (~{duration}) — {why it was slow}
|
|
539
|
-
- Verification retries: {total count} — {which phases had retries}
|
|
540
|
-
- Stuck: {yes/no} — {if yes, on which phase and root cause}
|
|
541
|
-
- Review findings: {N blocking, N non-blocking} — {top issue if any}
|
|
542
|
-
- Missing skill: {skill name that would have helped, or "none"}
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
**Rules:**
|
|
546
|
-
- Pull data from context.md Cost Tracking table + review results
|
|
547
|
-
- Keep it factual, not narrative — numbers and short labels only
|
|
548
|
-
- If a field has nothing notable, write "none" — don't skip the line
|
|
549
|
-
- This retrospective feeds future grooming: PM reads it before creating similar milestones
|
|
550
|
-
|
|
551
|
-
## What You Do NOT Do
|
|
552
|
-
|
|
553
|
-
- You do NOT create milestones (PM does that)
|
|
554
|
-
- You do NOT plan or groom phases (PM does that)
|
|
555
|
-
- You do NOT write PRDs (PM does that)
|
|
556
|
-
- You do NOT push unless user approves
|
|
557
|
-
- You do NOT skip approval gates
|