agent-orchestrator-kit 0.1.14 → 0.3.0
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/CHANGELOG.md +25 -0
- package/README.md +50 -16
- package/bin/agent-orchestrator.js +405 -3
- package/package.json +1 -1
- package/profiles/generic/orchestrator.yaml +2 -1
- package/profiles/mvp/openspec-config.yaml.example +2 -0
- package/profiles/mvp/orchestrator.yaml +2 -1
- package/profiles/node/orchestrator.yaml +2 -1
- package/profiles/vue3/openspec-config.yaml.example +2 -0
- package/profiles/vue3/orchestrator.yaml +2 -1
- package/templates/.agents/commands/opsx-apply.md +18 -46
- package/templates/.agents/commands/opsx-archive.md +10 -163
- package/templates/.agents/commands/opsx-design.md +3 -10
- package/templates/.agents/commands/opsx-explore.md +3 -10
- package/templates/.agents/commands/opsx-propose.md +14 -10
- package/templates/.agents/commands/opsx-quick.md +3 -10
- package/templates/.agents/commands/opsx-review.md +27 -55
- package/templates/.agents/commands/opsx-sync.md +2 -0
- package/templates/.agents/rules/agent-orchestration.mdc +21 -69
- package/templates/.agents/rules/figma-token-setup.mdc +1 -1
- package/templates/.agents/rules/memory-mcp-autosetup.mdc +4 -67
- package/templates/.agents/rules/session-handoff.mdc +21 -37
- package/templates/.agents/skills/agent-orchestration/SKILL.md +28 -29
- package/templates/.agents/skills/openspec-apply-change/SKILL.md +15 -20
- package/templates/.agents/skills/openspec-archive-change/SKILL.md +12 -99
- package/templates/.agents/skills/openspec-propose/SKILL.md +11 -0
- package/templates/.agents/subagents/session-handoff.md +5 -5
- package/templates/.agents/subagents/spec-architect.md +1 -1
- package/templates/.agents/subagents/spec-archiver.md +1 -1
- package/templates/.agents/subagents/spec-reviewer.md +11 -7
- package/templates/AGENTS.md +22 -124
- package/templates/CLAUDE.md +6 -68
- package/templates/orchestrator.yaml +2 -1
|
@@ -5,9 +5,9 @@ category: Workflow
|
|
|
5
5
|
description: Read-only spec review of an OpenSpec change — approve or request changes before apply
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
## Session Start
|
|
8
|
+
## Session Start
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Follow the canonical Session Start protocol in `.agents/rules/session-handoff.mdc`, then announce the Spec Reviewer role.
|
|
11
11
|
|
|
12
12
|
Review an OpenSpec change. Read artifacts, validate structure, output Approve or Request Changes.
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ Review an OpenSpec change. Read artifacts, validate structure, output Approve or
|
|
|
15
15
|
|
|
16
16
|
**Input**: Optionally specify a change name (e.g., `/opsx:review add-auth`). If omitted, auto-select if one active change exists, otherwise list and ask.
|
|
17
17
|
|
|
18
|
-
**
|
|
18
|
+
**Review is two-tiered:** Tier 1 is a deterministic script (`gate-check --review`) run by the parent **before** any artifact is read by an LLM. Tier 2 is the `spec-reviewer` subagent with a shortened, LLM-only checklist. Spawning `spec-reviewer` is mandatory only when Tier 1 passes. The parent MUST NOT review artifacts or write `review.md` itself when Tier 2 runs. Never substitute `code-reviewer`.
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -30,59 +30,36 @@ If name provided — use it. Otherwise:
|
|
|
30
30
|
|
|
31
31
|
Announce: "Reviewing change: **<name>**"
|
|
32
32
|
|
|
33
|
-
### 2.
|
|
34
|
-
|
|
35
|
-
Spawn `spec-reviewer` and delegate steps 3–6 below. Require `## Subagent report: spec-reviewer`. Do not perform the review in the parent session.
|
|
36
|
-
|
|
37
|
-
### 3. Validate structure
|
|
33
|
+
### 2. Tier 1 — deterministic gate-check
|
|
38
34
|
|
|
39
35
|
```bash
|
|
40
|
-
npx
|
|
36
|
+
npx agent-orchestrator-kit gate-check --review <name>
|
|
41
37
|
```
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
The script runs `openspec validate --strict --type change`, the task-contract lint (Files/Do/Done-when), the `Non-goals` / `Acceptance criteria` proposal sections check, and non-empty ADDED/MODIFIED/REMOVED delta-spec sections check. Add `--json` for a `{pass, errors[]}` report.
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
**If Tier 1 fails (exit ≠ 0):** do NOT spawn `spec-reviewer` and do NOT read the artifacts. Write `openspec/changes/<name>/review.md` with `Verdict: REQUEST CHANGES` listing the gate-check errors (source: gate-check), output the Request Changes verdict in chat, and go straight to Session Exit.
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
npx openspec status --change "<name>" --json
|
|
49
|
-
```
|
|
43
|
+
### 3. Tier 2 — spawn the specialist
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
- `proposal.md`
|
|
53
|
-
- `design.md`
|
|
54
|
-
- `tasks.md`
|
|
55
|
-
- all `specs/<domain>/spec.md` files
|
|
45
|
+
Only after Tier 1 passes: spawn `spec-reviewer` with the complete change paths, project constraints, and the shortened checklist below. Require `## Subagent report: spec-reviewer`. Do not perform the review in the parent session.
|
|
56
46
|
|
|
57
|
-
|
|
47
|
+
### 4. Review checklist (Tier 2 — LLM-only)
|
|
58
48
|
|
|
59
|
-
|
|
49
|
+
Do NOT re-check what Tier 1 already covered (strict validation, contract field presence, proposal sections, delta-spec section structure). Evaluate each item. Mark ✓ or ✗:
|
|
60
50
|
|
|
61
|
-
|
|
51
|
+
**Consistency**
|
|
52
|
+
- [ ] proposal ↔ design ↔ tasks tell the same story — no contradictions or drift
|
|
53
|
+
- [ ] Delta specs cover all changed/added behavior described in design
|
|
62
54
|
|
|
63
|
-
**
|
|
64
|
-
- [ ]
|
|
65
|
-
- [ ] Non-goals are listed
|
|
66
|
-
- [ ] Acceptance criteria are present and testable (not "should work" — must be verifiable)
|
|
67
|
-
- [ ] Scope matches a ~1–3 day change
|
|
55
|
+
**Main specs**
|
|
56
|
+
- [ ] No conflicts with existing `openspec/specs/` requirements
|
|
68
57
|
|
|
69
|
-
**
|
|
70
|
-
- [ ] Approach is concrete (not "we will handle this")
|
|
71
|
-
- [ ] Trade-offs or alternatives mentioned
|
|
72
|
-
- [ ] Does not contradict existing `openspec/specs/` domain specs
|
|
58
|
+
**Scope**
|
|
73
59
|
- [ ] No scope creep vs proposal Non-goals
|
|
74
60
|
|
|
75
|
-
**
|
|
76
|
-
- [ ]
|
|
77
|
-
- [ ] Each task has a clear done condition
|
|
78
|
-
- [ ] Tasks are in logical implementation order
|
|
79
|
-
- [ ] No task requires information not in design/spec
|
|
80
|
-
- [ ] No task says "update X as needed" (must be specific)
|
|
81
|
-
|
|
82
|
-
**Delta Specs**
|
|
83
|
-
- [ ] Cover all changed/added behavior
|
|
84
|
-
- [ ] ADDED/MODIFIED/REMOVED sections used correctly
|
|
85
|
-
- [ ] No conflicts with main `openspec/specs/`
|
|
61
|
+
**Task self-sufficiency**
|
|
62
|
+
- [ ] A blind implementer can execute each task from Files/Do/Done-when alone, without reading design.md
|
|
86
63
|
|
|
87
64
|
**Vue 3** (when `project.stack: vue3` in `.agents/orchestrator.yaml`)
|
|
88
65
|
- [ ] Components use `<script setup>` + Composition API (no Options API)
|
|
@@ -91,7 +68,7 @@ Evaluate each item. Mark ✓ or ✗:
|
|
|
91
68
|
- [ ] Tasks reference concrete component/store paths under `src/`
|
|
92
69
|
- [ ] No scope creep into unrelated UI refactors
|
|
93
70
|
|
|
94
|
-
###
|
|
71
|
+
### 5. Write and report the verdict
|
|
95
72
|
|
|
96
73
|
#### If all ✓ (or only minor notes):
|
|
97
74
|
|
|
@@ -131,11 +108,13 @@ Create or update `openspec/changes/<name>/review.md`:
|
|
|
131
108
|
<optional notes>
|
|
132
109
|
```
|
|
133
110
|
|
|
134
|
-
|
|
111
|
+
On **APPROVE**, `spec-reviewer` also writes `openspec/changes/<name>/apply-notes.md` (≤ 20 lines): critical constraints, pitfalls, what NOT to touch, verification commands. It is the distilled input for `/opsx:apply` and the **second allowed file** next to `review.md`.
|
|
112
|
+
|
|
113
|
+
For **REQUEST CHANGES**, write only `review.md` with `Verdict: REQUEST CHANGES` and the issues list.
|
|
135
114
|
|
|
136
|
-
|
|
115
|
+
`review.md` (always) and `apply-notes.md` (on APPROVE) are the **only files** you may write during review (not `src/`, not `tasks.md` checkboxes).
|
|
137
116
|
|
|
138
|
-
The conductor verifies the subagent's `Status: done`, checks that `review.md` exists with the reported verdict, and relays the result without editing
|
|
117
|
+
The conductor verifies the subagent's `Status: done`, checks that `review.md` exists with the reported verdict (and `apply-notes.md` on APPROVE), and relays the result without editing them.
|
|
139
118
|
|
|
140
119
|
#### If any ✗:
|
|
141
120
|
|
|
@@ -162,19 +141,12 @@ Fix the above, then re-run `/opsx:review <name>`.
|
|
|
162
141
|
|
|
163
142
|
## Session Exit (HARD STOP)
|
|
164
143
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
|
|
168
|
-
2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
|
|
169
|
-
3. Run `npx agent-orchestrator-kit handoff <name>` and require exit 0. The CLI upserts Memory JSON (absolute path) and prints the expanded self-contained prompt on stdout.
|
|
170
|
-
4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
|
|
171
|
-
5. Paste CLI stdout into chat as one fenced block beginning with the next `/opsx:*` command (`/opsx:apply <name>` only after APPROVE). Keep it complete. No banner.
|
|
172
|
-
6. Stop. Do not start the next phase in this chat.
|
|
144
|
+
Close via the canonical Session Exit protocol in `.agents/rules/session-handoff.mdc`. First line of the pasted prompt is the next `/opsx:*` command (`/opsx:apply <name>` only after APPROVE). Do not start the next phase in this chat.
|
|
173
145
|
|
|
174
146
|
## Guardrails
|
|
175
147
|
|
|
176
148
|
- **Never** edit source code, `src/`, or `tasks.md` checkboxes
|
|
177
|
-
- **May write only** `openspec/changes/<name>/review.md` (verdict record for apply gate)
|
|
149
|
+
- **May write only** `openspec/changes/<name>/review.md` (verdict record for apply gate) and, on APPROVE, `openspec/changes/<name>/apply-notes.md`
|
|
178
150
|
- **Never** run apply commands
|
|
179
151
|
- Ask for clarification only if a critical artifact is missing or unreadable
|
|
180
152
|
- If proposal is ambiguous on scope, flag as ✗ — do not assume intent
|
|
@@ -7,6 +7,8 @@ description: Sync delta specs from a change to main specs
|
|
|
7
7
|
|
|
8
8
|
Sync delta specs from a change to main specs.
|
|
9
9
|
|
|
10
|
+
If run as a standalone `/opsx:*` session, follow the canonical Session Start / Session Exit protocol in `.agents/rules/session-handoff.mdc`.
|
|
11
|
+
|
|
10
12
|
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
|
11
13
|
|
|
12
14
|
**Input**: Optionally specify a change name after `/opsx:sync` (e.g., `/opsx:sync add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
@@ -5,78 +5,30 @@ alwaysApply: true
|
|
|
5
5
|
|
|
6
6
|
# Agent Orchestration Rules
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Spec-driven pipeline. Read `.agents/orchestrator.yaml`. Details: skill `agent-orchestration`. Handoff: `.agents/rules/session-handoff.mdc`. CLI: `npx` only (`.agents/rules/cli-via-npm.mdc`).
|
|
9
9
|
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
- `/opsx:design <name>` → writes only `design-brief.md` + `assets/` (optional design intake)
|
|
13
|
-
- `/opsx:propose <name>` → creates `openspec/changes/<name>/` artifacts only
|
|
14
|
-
- `/opsx:review <name>` → read-only spec review, writes `review.md`, outputs Approve or Request Changes
|
|
15
|
-
- `/opsx:apply <name>` → writes `src/`, marks `tasks.md [x]` (blocked if no review when `require_spec_review: true`)
|
|
16
|
-
- `/opsx:quick <name>` → MVP: propose + apply in one session (when `require_spec_review: false`)
|
|
17
|
-
- `/opsx:archive` → merges delta specs, moves change to archive
|
|
10
|
+
## Commands
|
|
11
|
+
`/opsx:explore` read-only · `/opsx:design <name>` brief+assets only · `/opsx:propose <name>` change artifacts · `/opsx:review <name>` review.md · `/opsx:apply <name>` code (blocked without Approve when `require_spec_review`) · `/opsx:quick <name>` MVP propose+apply · `/opsx:archive`
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
The parent `/opsx:*` session is the **conductor**. Delegation is differentiated by phase: propose/review MUST spawn their specialist; apply is parent-driven with optional subagents; archive is a CLI call with phase subagents forbidden. Only the parent marks `tasks.md`. `spec-reviewer` ≠ `code-reviewer`.
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
| Phase / signal | Subagent | Status |
|
|
16
|
+
|--------|------------|--------|
|
|
17
|
+
| Status / gate / next command | `openspec-guide` | optional |
|
|
18
|
+
| Restore/persist when handoff CLI failed | `session-handoff` | fallback only |
|
|
19
|
+
| Broken kit / MCP / sync | `setup-doctor` | on signal |
|
|
20
|
+
| `/opsx:explore` | `codebase-explorer` | mandatory |
|
|
21
|
+
| `/opsx:design` | `design-intake` | mandatory |
|
|
22
|
+
| `/opsx:propose` | `spec-architect` | mandatory |
|
|
23
|
+
| `/opsx:review` (after `gate-check --review` passes) | `spec-reviewer` | mandatory |
|
|
24
|
+
| Apply + design brief/Figma/image | `design-implementer` | mandatory on signal |
|
|
25
|
+
| Apply: ≥ 2 independent tasks, no shared files, or explicit request | `code-writer` / `test-writer` | optional |
|
|
26
|
+
| Apply pre-PR | `code-reviewer` | optional |
|
|
27
|
+
| `/opsx:archive` | — use `npx agent-orchestrator-kit archive <name>` | CLI; subagent forbidden (`spec-archiver` = CLI-failure fallback only) |
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| Status, gate failure, next command | `openspec-guide` | Pipeline diagnosis |
|
|
26
|
-
| Session start restore / session exit persist | `session-handoff` | Memory, `handoff.md`, next-thread prompt |
|
|
27
|
-
| Broken kit, MCP, or generated-file sync | `setup-doctor` | Kit setup repair |
|
|
28
|
-
| `/opsx:explore` repository investigation | `codebase-explorer` | Repository research; no specs or code |
|
|
29
|
-
| `/opsx:design` | `design-intake` | `design-brief.md` and `assets/` |
|
|
30
|
-
| `/opsx:propose` | `spec-architect` | Change proposal/design/specs/tasks |
|
|
31
|
-
| `/opsx:review` | `spec-reviewer` | Pre-apply spec verdict and `review.md` |
|
|
32
|
-
| Apply task with design brief/Figma/image | `design-implementer` | UI implementation |
|
|
33
|
-
| Apply ordinary implementation task | `code-writer` | One task's production code |
|
|
34
|
-
| Apply after implementation | `test-writer` | Automated tests |
|
|
35
|
-
| Apply before PR/MR | `code-reviewer` | Post-implementation spec review |
|
|
36
|
-
| `/opsx:archive` | `spec-archiver` | Delta merge and archive move |
|
|
29
|
+
## Session
|
|
30
|
+
Start: honor pasted `/opsx:*` → `npx agent-orchestrator-kit status` → `handoff --restore`. Spawn `session-handoff` restore **only if** restore CLI failed or printed no briefing (Amp: isolated `subagent-session-handoff`). Then spawn the phase specialist isolated. Free-form continue → `Handoff.next_command`.
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
Exit HARD STOP: persist via `session-handoff` → `handoff.md` → `npx agent-orchestrator-kit handoff <name>` (exit 0) → paste CLI stdout as one fenced `/opsx:*` prompt. Do not start the next phase here.
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
1. Honor the pasted `/opsx:<phase> <name>` command and announce that role.
|
|
43
|
-
2. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`; resolve the active change without exceeding `max_active_changes`.
|
|
44
|
-
3. Run `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Use the printed briefing.
|
|
45
|
-
4. Read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works.
|
|
46
|
-
5. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`. Memory failure alone MUST NOT block the session when the file exists.
|
|
47
|
-
6. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`, never the main thread).
|
|
48
|
-
7. Only after context is restored, spawn the routed phase specialist. Amp MUST spawn `subagent-<name>` isolated.
|
|
49
|
-
|
|
50
|
-
If the user says “continue” / “next” / «продовжуй» / «далі» without a command and exactly one active change has `Handoff.next_command` (from Memory, CLI restore, or `handoff.md`), execute that command instead of asking which phase to run.
|
|
51
|
-
|
|
52
|
-
Follow `.agents/rules/session-handoff.mdc`.
|
|
53
|
-
|
|
54
|
-
## Session Exit Protocol (HARD STOP)
|
|
55
|
-
|
|
56
|
-
A phase is not closed until the conductor performs these steps in order. FORBIDDEN: saying done/готово, starting the next phase, or omitting the fenced prompt.
|
|
57
|
-
|
|
58
|
-
1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
|
|
59
|
-
2. Write `openspec/changes/<name>/handoff.md` with sections **Closed role**, **Change**, **Done**, **Decisions**, **Blocked**, **Next command**, **Next role**, **Attach**, **Subagents to spawn**, and **Constraints**. Do this even if Memory MCP is unavailable.
|
|
60
|
-
3. Run `npx agent-orchestrator-kit handoff <name>` and require exit 0. The CLI upserts `.cursor/memory.json` with an absolute path and prints the expanded self-contained next-session prompt on stdout.
|
|
61
|
-
4. If Memory MCP tools work, also update `Change:<name>` (`status`, `tasks n/m`, `last_role`, `review`), `Handoff:<name>` (`next_role`, `next_command`, `session_count`, `summary`, `blocked`), and each new `Decision:<topic>` (`chosen`, `reason`).
|
|
62
|
-
5. Paste the CLI stdout as one fenced copy/paste prompt. First line MUST be `/opsx:<next> <name>`; body MUST use `project.agent_language`; MUST keep Done/Decisions/Blocked/spawn/HARD STOP complete. Do not add a banner or shorten the prompt. Amp often skips Memory MCP — the pasted prompt is the next thread's operating brief.
|
|
63
|
-
6. Do NOT start the next phase in this chat.
|
|
64
|
-
|
|
65
|
-
## Session Rules
|
|
66
|
-
- One active change at a time (unless mvp profile: up to 3)
|
|
67
|
-
- Each role = new chat session (except `/opsx:quick` combines propose+apply)
|
|
68
|
-
- No code in explore, design, or review sessions
|
|
69
|
-
- Design Intake may write only `openspec/changes/<name>/design-brief.md` and `assets/`
|
|
70
|
-
- No apply without review when `pipeline.require_spec_review: true` — check `review.md` or Approve in context
|
|
71
|
-
- When `require_design_brief: true` and the change touches UI — need `design-brief.md`, or `Design: none` in `proposal.md` for non-UI
|
|
72
|
-
- Apply uses the design brief, not live Figma MCP
|
|
73
|
-
- After apply: build + lint before PR
|
|
74
|
-
- After merge: run `/opsx:archive` (when `archive_after_merge: true`)
|
|
75
|
-
- CLI: `npx agent-orchestrator-kit status`, `npx openspec …` — never bare globals (see `cli-via-npm.mdc`)
|
|
76
|
-
|
|
77
|
-
## Never
|
|
78
|
-
- Mix propose and apply in one session
|
|
79
|
-
- Edit `src/` during explore, design, or review
|
|
80
|
-
- Skip spec review before apply
|
|
81
|
-
- Call live Figma MCP during apply when a design brief exists
|
|
82
|
-
- Leave changes un-archived after merge
|
|
34
|
+
Never mix propose+apply (except `/opsx:quick`). No `src/` in explore/design/review. Skip live Figma during apply when a brief exists.
|
|
@@ -3,73 +3,10 @@ description: Memory MCP auto-setup for Cursor and Amp
|
|
|
3
3
|
alwaysApply: true
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Memory MCP
|
|
6
|
+
# Memory MCP
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
If `memory` MCP is absent or uses a **relative** `MEMORY_FILE_PATH` — run `npx agent-orchestrator-kit memory-setup` silently.
|
|
8
|
+
If `.mcp.json` / `.amp/settings.json` lacks `memory`, or `MEMORY_FILE_PATH` is relative: run `npx agent-orchestrator-kit memory-setup`. Relative paths resolve inside npx `dist/` and look like “memory ignored”.
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
Use `node scripts/memory-mcp-launcher.cjs` (no relative `MEMORY_FILE_PATH`). Shared file: `.cursor/memory.json` (gitignored). Do not delete other MCP servers.
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Cursor (.mcp.json)
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
"memory": {
|
|
19
|
-
"command": "node",
|
|
20
|
-
"args": ["scripts/memory-mcp-launcher.cjs"]
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Amp (.amp/settings.json)
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
"amp.mcpServers": {
|
|
28
|
-
"memory": {
|
|
29
|
-
"command": "node",
|
|
30
|
-
"args": ["scripts/memory-mcp-launcher.cjs"]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
If Amp CLI is available and memory is missing:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npx agent-orchestrator-kit memory-setup
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Do not run `amp mcp add` with a relative `MEMORY_FILE_PATH`.
|
|
42
|
-
|
|
43
|
-
## .gitignore
|
|
44
|
-
|
|
45
|
-
Ensure present (do not duplicate):
|
|
46
|
-
```
|
|
47
|
-
.cursor/memory.json
|
|
48
|
-
.amp/settings.json
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Memory Entity Format
|
|
52
|
-
|
|
53
|
-
Use these keys and fields for orchestration state:
|
|
54
|
-
|
|
55
|
-
| Key | Required fields |
|
|
56
|
-
|-----|-----------------|
|
|
57
|
-
| `Change:<name>` | `status`, `tasks n/m`, `last_role`, `review` |
|
|
58
|
-
| `Handoff:<name>` | `next_role`, `next_command`, `session_count`, `summary`, `blocked` |
|
|
59
|
-
| `Decision:<topic>` | `chosen`, `reason` |
|
|
60
|
-
| `Convention:<area>` | project-specific rules |
|
|
61
|
-
|
|
62
|
-
The deterministic writer is `npx agent-orchestrator-kit handoff <name>` — it upserts `.cursor/memory.json` even when MCP tools are ignored. Also call Memory MCP create/update when tools work.
|
|
63
|
-
|
|
64
|
-
## Session Lifecycle
|
|
65
|
-
|
|
66
|
-
At the start of every `/opsx:*` role session, after resolving the change and before specialist work: `npx agent-orchestrator-kit handoff --restore`, then read `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory MCP is unavailable or those entities are empty, read `openspec/changes/<name>/handoff.md` and continue; Memory failure is not a blocker.
|
|
67
|
-
|
|
68
|
-
At session exit, spawn `session-handoff` (Amp: isolated `subagent-session-handoff`), write `handoff.md`, then run `npx agent-orchestrator-kit handoff <name>` (exit 0 required). Paste the CLI stdout prompt complete. Only after that attempt Memory MCP updates. You are not done without the fenced prompt.
|
|
69
|
-
|
|
70
|
-
## Rules
|
|
71
|
-
- Do not overwrite existing correct launcher config
|
|
72
|
-
- Do not delete other MCP servers
|
|
73
|
-
- Notify once: "Memory MCP connected."
|
|
74
|
-
- Never treat unavailable Memory MCP as a reason to skip `handoff.md` or the CLI
|
|
75
|
-
- Never leave a relative `MEMORY_FILE_PATH` in Cursor or Amp config
|
|
12
|
+
Entities: `Change:<name>` (status, tasks n/m, last_role, review) · `Handoff:<name>` (next_role, next_command, session_count, summary, blocked) · `Decision:<topic>` (chosen, reason). Writer: `npx agent-orchestrator-kit handoff <name>`. Notify once: “Memory MCP connected.”
|
|
@@ -1,46 +1,30 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: Canonical Session Start and Session Exit protocol for every /opsx:* session
|
|
3
3
|
alwaysApply: true
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Session Handoff —
|
|
6
|
+
# Session Handoff — canonical protocol (HARD STOP)
|
|
7
7
|
|
|
8
|
-
This rule
|
|
8
|
+
This rule is the single source of the Session Start / Session Exit protocol. Commands reference it; they do not duplicate it. A `/opsx:*` session is incomplete without persist + the fenced next-thread prompt. FORBIDDEN until persist succeeds: done/готово, next phase, or omitting the prompt.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Session Start (before any work)
|
|
11
|
+
1. Honor pasted `/opsx:<phase> <name>` and announce the role.
|
|
12
|
+
2. `npx agent-orchestrator-kit status`
|
|
13
|
+
3. `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). The CLI briefing is canonical — it already reads memory.json and handoff.md; no separate Memory MCP read step.
|
|
14
|
+
4. If the restore CLI failed → read `openspec/changes/<name>/handoff.md` directly.
|
|
15
|
+
5. Spawn `session-handoff` in restore mode ONLY if both the CLI and handoff.md are unavailable (Amp: isolated `subagent-session-handoff`). This is a fallback, never a routine step.
|
|
16
|
+
6. Free-form continue/next/«далі» with one active change → execute `Handoff.next_command`.
|
|
17
|
+
7. Only then start phase work (spawn a specialist when the phase routing requires one).
|
|
11
18
|
|
|
12
|
-
##
|
|
19
|
+
## Session Exit (order)
|
|
20
|
+
1. The parent writes `openspec/changes/<name>/handoff.md` itself: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
|
|
21
|
+
2. `npx agent-orchestrator-kit handoff <name>` — require exit 0 (upserts absolute-path Memory JSON, prints the expanded prompt on stdout).
|
|
22
|
+
3. Spawn `session-handoff` in persist mode ONLY if step 2 failed (Amp: isolated `subagent-session-handoff`). Fallback, never routine.
|
|
23
|
+
4. Memory MCP is an optional mirror: if tools are available, update `Change:<name>`, `Handoff:<name>`, `Decision:*` in one call; unavailability never blocks closing.
|
|
24
|
+
5. Paste CLI stdout as one fenced block. First line `/opsx:…`. Body uses `project.agent_language`. Self-contained (Done/Decisions/Blocked/spawn/HARD STOP). No banner.
|
|
25
|
+
6. Stop. Next role = new chat.
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
## Archive exception
|
|
28
|
+
`npx agent-orchestrator-kit archive <name>` writes the final `handoff.md` (`next_command: none`) in the archive folder and upserts memory itself. After a successful archive no fenced next-prompt is required — the pipeline is complete.
|
|
15
29
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
1. Honor the pasted `/opsx:<phase> <name>` command and announce that role.
|
|
19
|
-
2. Run `npx agent-orchestrator-kit status`.
|
|
20
|
-
3. Run `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Use the printed briefing.
|
|
21
|
-
4. Read Memory `Change:<name>`, `Handoff:<name>`, `Decision:*` when MCP works.
|
|
22
|
-
5. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`. Memory failure is not a blocker when the file exists.
|
|
23
|
-
6. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`, never the main thread).
|
|
24
|
-
7. Spawn the routed phase specialist from `.agents/rules/agent-orchestration.mdc`. Amp: isolated `subagent-<name>`. Executing specialist work in the parent thread is a protocol violation.
|
|
25
|
-
8. Free-form “continue” / “next” / «продовжуй» / «далі» with one active change → execute `Handoff.next_command`. Do not ask which phase.
|
|
26
|
-
|
|
27
|
-
## Session exit (mandatory order)
|
|
28
|
-
|
|
29
|
-
1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, do the persist steps in the parent — never skip.
|
|
30
|
-
2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
|
|
31
|
-
3. Run `npx agent-orchestrator-kit handoff <name>` and require exit 0. The CLI upserts `.cursor/memory.json` with an absolute path and prints the expanded prompt on stdout.
|
|
32
|
-
4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, `Decision:*` to match.
|
|
33
|
-
5. Paste the CLI stdout into chat as one fenced block. Keep it complete. No `NEXT_SESSION_PROMPT` banner. First line is `/opsx:…`. Body uses `project.agent_language`.
|
|
34
|
-
6. Stop. The next role starts in a **new** chat with that pasted prompt.
|
|
35
|
-
|
|
36
|
-
## Next-thread prompt must be self-contained
|
|
37
|
-
|
|
38
|
-
The prompt is the next thread’s operating brief. It MUST include: role, change name, language, hard constraints, start checklist, which subagent to spawn (including Amp isolated wrapper name), full Done / Decisions / Blocked / tasks / review / attach, and the exit HARD STOP. Do not emit a thin “read Memory” stub. Amp often skips Memory MCP; the pasted prompt must still be enough to work.
|
|
39
|
-
|
|
40
|
-
## Memory path
|
|
41
|
-
|
|
42
|
-
Never configure Memory MCP with a relative `MEMORY_FILE_PATH`. Relative `.cursor/memory.json` resolves inside npx `dist/` and looks like “memory ignored”. Use `node scripts/memory-mcp-launcher.cjs` (Cursor `.mcp.json` and Amp `.amp/settings.json`). Run `npx agent-orchestrator-kit memory-setup` when the launcher is missing or the path is relative.
|
|
43
|
-
|
|
44
|
-
## Amp isolation
|
|
45
|
-
|
|
46
|
-
Every `subagent-*` skill MUST be spawned as an isolated subagent with fresh context. Running the wrapper body in the main Amp thread is a protocol violation. If spawn is unavailable, STOP and report blocked — do not impersonate the specialist.
|
|
30
|
+
Memory MCP: launcher `node scripts/memory-mcp-launcher.cjs`, never a relative `MEMORY_FILE_PATH`.
|
|
@@ -42,26 +42,25 @@ Read `.agents/orchestrator.yaml` for project-specific config (language, flags, M
|
|
|
42
42
|
| Quick (MVP) | `/opsx:quick <name>` | specs+code | strong | `openspec/changes/` + `src/` |
|
|
43
43
|
| Verifier | CI / local scripts | — | — | exit codes |
|
|
44
44
|
|
|
45
|
-
## Conductor Routing (
|
|
46
|
-
|
|
47
|
-
The parent `/opsx:*` session is the conductor.
|
|
48
|
-
|
|
49
|
-
| Phase / signal |
|
|
50
|
-
|
|
51
|
-
| Status, gate failure, next command | `openspec-guide` |
|
|
52
|
-
|
|
|
53
|
-
| Broken kit, MCP, or generated-file sync | `setup-doctor` |
|
|
54
|
-
| `/opsx:explore` repository investigation | `codebase-explorer` |
|
|
55
|
-
| `/opsx:design` | `design-intake` |
|
|
56
|
-
| `/opsx:propose` | `spec-architect` |
|
|
57
|
-
| `/opsx:review` | `spec-reviewer` |
|
|
58
|
-
| Apply task with design brief/Figma/image | `design-implementer` |
|
|
59
|
-
| Apply
|
|
60
|
-
| Apply
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`spec-reviewer` is not `code-reviewer`. During apply, specialists MUST NOT edit `tasks.md`; only the conductor may mark a checkbox after a `Status: done` report and verification that the reported files exist.
|
|
45
|
+
## Conductor Routing (Differentiated by Phase)
|
|
46
|
+
|
|
47
|
+
The parent `/opsx:*` session is the conductor. Delegation cost must match phase uncertainty: **propose and review MUST spawn their specialist** (the parent never writes artifacts or the verdict); **apply is parent-driven** — the parent writes code and tests itself from `tasks.md` + `apply-notes.md`, subagents are optional; **archive is one CLI call** — phase subagents are forbidden.
|
|
48
|
+
|
|
49
|
+
| Phase / signal | Subagent | Status |
|
|
50
|
+
|----------------|------------|--------|
|
|
51
|
+
| Status, gate failure, next command | `openspec-guide` | optional |
|
|
52
|
+
| Restore/persist when handoff CLI failed | `session-handoff` | fallback only |
|
|
53
|
+
| Broken kit, MCP, or generated-file sync | `setup-doctor` | on signal |
|
|
54
|
+
| `/opsx:explore` repository investigation | `codebase-explorer` | mandatory |
|
|
55
|
+
| `/opsx:design` | `design-intake` | mandatory |
|
|
56
|
+
| `/opsx:propose` | `spec-architect` | mandatory |
|
|
57
|
+
| `/opsx:review` (Tier 2, after `gate-check --review` passes) | `spec-reviewer` | mandatory |
|
|
58
|
+
| Apply task with design brief/Figma/image | `design-implementer` | mandatory on signal |
|
|
59
|
+
| Apply: ≥ 2 independent tasks with no shared files, or explicit user request | `code-writer` / `test-writer` | optional |
|
|
60
|
+
| Apply before PR/MR | `code-reviewer` | optional |
|
|
61
|
+
| `/opsx:archive` | — run `npx agent-orchestrator-kit archive <name>` | CLI; phase subagent forbidden (`spec-archiver` = CLI-failure fallback only) |
|
|
62
|
+
|
|
63
|
+
`spec-reviewer` is not `code-reviewer`. Spawned specialists MUST NOT edit `tasks.md`; the parent checks a box only after verifying the task's Done-when condition. If an apply task requires information beyond its Files/Do/Done-when contract + `apply-notes.md` + referenced artifacts, STOP: record the gap in `handoff.md` and route back to `/opsx:propose <name>` — improvisation is forbidden.
|
|
65
64
|
|
|
66
65
|
## Handoff Protocol
|
|
67
66
|
|
|
@@ -127,6 +126,7 @@ After PR merged + CI green:
|
|
|
127
126
|
```
|
|
128
127
|
/opsx:archive <name>
|
|
129
128
|
```
|
|
129
|
+
Archive is one deterministic CLI call — `npx agent-orchestrator-kit archive <name> [--sync | --no-sync --force]` — which checks gates, merges delta specs on `--sync`, moves the change to the dated archive, validates with rollback, and writes the final handoff. No phase subagent.
|
|
130
130
|
|
|
131
131
|
## Session Rules
|
|
132
132
|
|
|
@@ -136,7 +136,7 @@ After PR merged + CI green:
|
|
|
136
136
|
3. Run `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`).
|
|
137
137
|
4. Read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works.
|
|
138
138
|
5. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; Memory failure alone is not a blocker.
|
|
139
|
-
6. Spawn `session-handoff` in restore mode
|
|
139
|
+
6. Spawn `session-handoff` in restore mode **only if** `handoff --restore` failed or printed no briefing (Amp: isolated `subagent-session-handoff`). Skip this spawn when CLI restore exits 0.
|
|
140
140
|
7. Only after restoration, spawn the routed phase specialist. If the user said “continue” / “next” and exactly one active change has `Handoff.next_command`, execute it instead of asking for a phase.
|
|
141
141
|
|
|
142
142
|
**During session:**
|
|
@@ -145,12 +145,11 @@ After PR merged + CI green:
|
|
|
145
145
|
- Never edit files outside your role's allowed output
|
|
146
146
|
|
|
147
147
|
**End of each session (HARD STOP — you are NOT done):**
|
|
148
|
-
1.
|
|
149
|
-
2.
|
|
150
|
-
3.
|
|
151
|
-
4.
|
|
152
|
-
5.
|
|
153
|
-
6. Do not start the next phase in this chat. If apply, include build/lint status in the persisted Done section.
|
|
148
|
+
1. Write `openspec/changes/<name>/handoff.md` in the parent using the template below.
|
|
149
|
+
2. Run `npx agent-orchestrator-kit handoff <name>` and require exit 0. The CLI upserts Memory JSON with an absolute path and prints the expanded self-contained prompt on stdout. Spawn `session-handoff` in persist mode ONLY if this CLI step failed.
|
|
150
|
+
3. If Memory MCP tools are available, mirror `Change:<name>`, `Handoff:<name>`, and new `Decision:<topic>` entities in one call — optional; its absence never blocks closing.
|
|
151
|
+
4. Paste the CLI stdout as one fenced next-session prompt. First line is `/opsx:<next> <name>`; body uses `project.agent_language`; keep Done/Decisions/Blocked/spawn/HARD STOP complete. No banner. Do not emit a thin “read Memory” stub.
|
|
152
|
+
5. Do not start the next phase in this chat. If apply, include build/lint status in the persisted Done section.
|
|
154
153
|
|
|
155
154
|
`handoff.md` template:
|
|
156
155
|
|
|
@@ -213,9 +212,9 @@ The Prompt section is overwritten by `npx agent-orchestrator-kit handoff <name>`
|
|
|
213
212
|
|
|
214
213
|
## Mandatory Memory and Handoff Protocol
|
|
215
214
|
|
|
216
|
-
Before specialist work, the
|
|
215
|
+
Before specialist work, the parent MUST restore context in order: honor the pasted `/opsx:*` command; run `npx agent-orchestrator-kit handoff --restore` (the CLI briefing is canonical — no separate Memory MCP read step); if the CLI failed, read `openspec/changes/<name>/handoff.md`; spawn `session-handoff` in restore mode ONLY when both failed. Missing Memory MCP never blocks a session. With one active change, free-form “continue” uses `Handoff.next_command` instead of asking for the phase. Amp spawns any needed subagent as an isolated `subagent-*` skill.
|
|
217
216
|
|
|
218
|
-
Before declaring a session closed, the
|
|
217
|
+
Before declaring a session closed, the parent MUST, in order: (1) write `openspec/changes/<name>/handoff.md` itself, (2) run `npx agent-orchestrator-kit handoff <name>` (exit 0) — spawn `session-handoff` persist ONLY if this CLI step failed, (3) paste the CLI stdout prompt whose first line is `/opsx:<next> <name>`. Memory MCP mirroring is an optional single call. The prompt has no `NEXT_SESSION_PROMPT` label, uses `project.agent_language`, and MUST be self-contained (Done, Decisions, Blocked, attach, spawn, HARD STOP) so the next thread can run if Memory MCP is ignored. Never start the next phase in the current chat.
|
|
219
218
|
|
|
220
219
|
| Entity | Required fields |
|
|
221
220
|
|--------|-----------------|
|
|
@@ -13,7 +13,9 @@ Implement tasks from an OpenSpec change.
|
|
|
13
13
|
|
|
14
14
|
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
15
15
|
|
|
16
|
-
**
|
|
16
|
+
**Parent-driven apply:** the parent reads `tasks.md` + `apply-notes.md` (open `design.md`/`proposal.md` only when a task explicitly references them or a contract field is incomplete) and writes code and tests itself, task by task, checking its own `tasks.md` checkboxes. Subagents are optional: spawn `code-writer`/`test-writer` for ≥ 2 independent tasks with no shared files (parallelization) or on explicit user request. `design-implementer` remains mandatory for tasks with a design-brief/Figma signal.
|
|
17
|
+
|
|
18
|
+
**Escape valve (STOP — improvisation is forbidden):** if a task requires information beyond its Files/Do/Done-when + `apply-notes.md` + artifacts it explicitly references, STOP: record the gap in `handoff.md`, set the next command to `/opsx:propose <name>` (plan amendment), and end the session. Do not guess.
|
|
17
19
|
|
|
18
20
|
**Steps**
|
|
19
21
|
|
|
@@ -54,12 +56,9 @@ Implement tasks from an OpenSpec change.
|
|
|
54
56
|
|
|
55
57
|
**Workspace guard:** If status JSON reports `actionContext.mode: "workspace-planning"` and `allowedEditRoots` is empty, explain that full workspace apply is not supported in this slice. Treat linked repos and folders as read-only context, ask the user to select an affected area through an explicit implementation workflow, and STOP before editing files.
|
|
56
58
|
|
|
57
|
-
4. **Read
|
|
59
|
+
4. **Read the working set**
|
|
58
60
|
|
|
59
|
-
Read
|
|
60
|
-
The files depend on the schema being used:
|
|
61
|
-
- **spec-driven**: proposal, specs, design, tasks
|
|
62
|
-
- Other schemas: follow the contextFiles from CLI output
|
|
61
|
+
Read `tasks.md` and `apply-notes.md` — they are the primary input for apply. Open `design.md`, `proposal.md`, or delta specs only when a task explicitly references them or a contract field is incomplete. For non-spec-driven schemas, follow `contextFiles` from the CLI output.
|
|
63
62
|
|
|
64
63
|
5. **Show current progress**
|
|
65
64
|
|
|
@@ -73,15 +72,13 @@ Implement tasks from an OpenSpec change.
|
|
|
73
72
|
|
|
74
73
|
For each pending task:
|
|
75
74
|
- Show which task is being worked on
|
|
76
|
-
-
|
|
77
|
-
- Verify
|
|
78
|
-
-
|
|
79
|
-
- Only then, as conductor, mark the task complete in the tasks file: `- [ ]` → `- [x]`
|
|
75
|
+
- Implement it in the parent session from its Files/Do/Done-when contract (spawn `code-writer`/`test-writer` only for ≥ 2 independent tasks with no shared files, or on explicit user request; `design-implementer` for design-brief/Figma tasks)
|
|
76
|
+
- Verify the task's Done-when condition actually holds
|
|
77
|
+
- Mark the task complete in the tasks file: `- [ ]` → `- [x]`
|
|
80
78
|
- Continue to next task
|
|
81
79
|
|
|
82
|
-
**
|
|
83
|
-
-
|
|
84
|
-
- Implementation reveals a design issue → suggest updating artifacts
|
|
80
|
+
**STOP (escape valve) if:**
|
|
81
|
+
- The task requires information beyond its contract + `apply-notes.md` + referenced artifacts → record the gap in `handoff.md`, next command `/opsx:propose <name>` — never improvise
|
|
85
82
|
- Error or blocker encountered → report and wait for guidance
|
|
86
83
|
- User interrupts
|
|
87
84
|
|
|
@@ -146,13 +143,11 @@ What would you like to do?
|
|
|
146
143
|
|
|
147
144
|
**Guardrails**
|
|
148
145
|
- Keep going through tasks until done or blocked
|
|
149
|
-
- Always read
|
|
150
|
-
- If task is
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
154
|
-
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
155
|
-
- Use contextFiles from CLI output, don't assume specific file names
|
|
146
|
+
- Always read `tasks.md` + `apply-notes.md` before starting
|
|
147
|
+
- If a task contract is insufficient, STOP via the escape valve — don't guess or improvise
|
|
148
|
+
- Keep code changes minimal and scoped to each task's `Files:` list
|
|
149
|
+
- Never let a spawned specialist update `tasks.md`; the parent checks a box only after verifying Done-when
|
|
150
|
+
- Pause on errors and blockers
|
|
156
151
|
|
|
157
152
|
**Fluid Workflow Integration**
|
|
158
153
|
|