agent-orchestrator-kit 0.1.13 → 0.1.14

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +18 -11
  3. package/bin/agent-orchestrator.js +558 -2
  4. package/package.json +2 -2
  5. package/profiles/generic/orchestrator.yaml +3 -0
  6. package/profiles/mvp/orchestrator.yaml +3 -0
  7. package/profiles/node/orchestrator.yaml +3 -0
  8. package/profiles/vue3/orchestrator.yaml +3 -0
  9. package/templates/.agents/amp.settings.json.example +2 -5
  10. package/templates/.agents/commands/opsx-apply.md +10 -3
  11. package/templates/.agents/commands/opsx-archive.md +10 -3
  12. package/templates/.agents/commands/opsx-design.md +10 -3
  13. package/templates/.agents/commands/opsx-explore.md +10 -3
  14. package/templates/.agents/commands/opsx-propose.md +10 -3
  15. package/templates/.agents/commands/opsx-quick.md +10 -3
  16. package/templates/.agents/commands/opsx-review.md +10 -3
  17. package/templates/.agents/mcp.json.example +2 -5
  18. package/templates/.agents/rules/agent-orchestration.mdc +17 -10
  19. package/templates/.agents/rules/cli-via-npm.mdc +2 -1
  20. package/templates/.agents/rules/memory-mcp-autosetup.mdc +24 -11
  21. package/templates/.agents/rules/session-handoff.mdc +46 -0
  22. package/templates/.agents/skills/agent-orchestration/SKILL.md +36 -19
  23. package/templates/.agents/subagents/session-handoff.md +48 -0
  24. package/templates/.agents/subagents/setup-doctor.md +1 -1
  25. package/templates/AGENTS.md +8 -3
  26. package/templates/CLAUDE.md +5 -2
  27. package/templates/orchestrator.yaml +6 -0
  28. package/templates/scripts/memory-mcp-launcher.cjs +46 -0
  29. package/templates/scripts/sync-local-agent-skills.sh +1 -1
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "amp.mcpServers": {
3
3
  "memory": {
4
- "command": "npx",
5
- "args": ["-y", "@modelcontextprotocol/server-memory"],
6
- "env": {
7
- "MEMORY_FILE_PATH": ".cursor/memory.json"
8
- }
4
+ "command": "node",
5
+ "args": ["scripts/memory-mcp-launcher.cjs"]
9
6
  },
10
7
  "figma": {
11
8
  "command": "node",
@@ -7,7 +7,7 @@ description: Implement tasks from an OpenSpec change (Experimental)
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Implementer role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Implementer role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Implement tasks from an OpenSpec change.
13
13
 
@@ -157,9 +157,16 @@ All tasks complete! You can archive this change with `/opsx:archive`.
157
157
  What would you like to do?
158
158
  ```
159
159
 
160
- ## Session Exit (Mandatory Order)
160
+ ## Session Exit (HARD STOP)
161
161
 
162
- When apply completes or pauses: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`, including task and build/lint status; (2) write `openspec/changes/<name>/handoff.md` using the orchestration skill template even if Memory fails; (3) print one fenced prompt beginning with the next `/opsx:*` role command. Use `project.agent_language`, tell the next session to read Memory and the file fallback, omit banner labels and the full summary. Never start archive in this apply chat.
162
+ You have NOT finished until every step succeeds. Do not say done/готово, do not start archive, and do not omit the fenced next-thread prompt.
163
+
164
+ 1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
165
+ 2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints. Include task and build/lint status in Done.
166
+ 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.
167
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
168
+ 5. Paste CLI stdout into chat as one fenced block beginning with the next `/opsx:*` role command. Keep it complete. No banner.
169
+ 6. Stop. Never start archive in this apply chat.
163
170
 
164
171
  **Guardrails**
165
172
  - Keep going through tasks until done or blocked
@@ -7,7 +7,7 @@ description: Archive a completed change in the experimental workflow
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Archiver role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Archiver role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Archive a completed change in the experimental workflow.
13
13
 
@@ -160,9 +160,16 @@ Target archive directory already exists.
160
160
  3. Wait until a different date to archive
161
161
  ```
162
162
 
163
- ## Session Exit (Mandatory Order)
163
+ ## Session Exit (HARD STOP)
164
164
 
165
- Before closing archive: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`; (2) write the final handoff state at the archived change path using the orchestration skill template even if Memory fails; (3) when another role is required, print one fenced `/opsx:*` prompt using `project.agent_language`, Memory keys, and the file fallback, without a banner label or duplicated summary. Do not start another phase in this chat.
165
+ You have NOT finished until every step succeeds. Do not say done/готово and do not omit the fenced next-thread prompt when another role is required.
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 the final handoff state at the archived change path 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>` from the archived path context when possible, or write Memory JSON via the same CLI against the active name before the move. Require exit 0 when the change dir still exists.
170
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
171
+ 5. When another role is required, paste CLI stdout as one fenced `/opsx:*` prompt. Keep it complete. No banner.
172
+ 6. Stop. Do not start another phase in this chat.
166
173
 
167
174
  **Guardrails**
168
175
  - Always prompt for change selection if not provided
@@ -7,7 +7,7 @@ description: Capture design from any source into a durable design brief for an O
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Design Intake role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Design Intake role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Capture design into a durable brief for an OpenSpec change. One-shot intake from Figma, exports, screenshots, or photos — then apply never needs live design tools.
13
13
 
@@ -128,9 +128,16 @@ For non-UI changes: do not invent a brief. Tell the Architect to add a line `Des
128
128
 
129
129
  ---
130
130
 
131
- ## Session Exit (Mandatory Order)
131
+ ## Session Exit (HARD STOP)
132
132
 
133
- Before closing design: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`; (2) write `openspec/changes/<name>/handoff.md` using the orchestration skill template even if Memory fails; (3) print one fenced prompt beginning `/opsx:propose <name>`. Use `project.agent_language`, tell the next session to read Memory and the file fallback, omit banner labels and the full summary. Do not start propose in this chat.
133
+ You have NOT finished until every step succeeds. Do not say done/готово, do not start propose, and do not omit the fenced next-thread prompt.
134
+
135
+ 1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
136
+ 2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
137
+ 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.
138
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
139
+ 5. Paste CLI stdout into chat as one fenced block beginning `/opsx:propose <name>`. Keep it complete. No banner.
140
+ 6. Stop. Do not start propose in this chat.
134
141
 
135
142
  ## Guardrails
136
143
 
@@ -7,7 +7,7 @@ description: "Enter explore mode - think through ideas, investigate problems, cl
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Explorer role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Explorer role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
13
13
 
@@ -166,9 +166,16 @@ When things crystallize, you might offer a summary - but it's optional. Sometime
166
166
 
167
167
  ---
168
168
 
169
- ## Session Exit (Mandatory Order)
169
+ ## Session Exit (HARD STOP)
170
170
 
171
- Before closing explore: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`; (2) write `openspec/changes/<name>/handoff.md` using the orchestration skill template even if Memory fails; (3) print one fenced prompt whose first line is the chosen `/opsx:design <name>` or `/opsx:propose <name>`. Use `project.agent_language`, tell the next session to read Memory and the file fallback, omit banner labels and the full summary. Do not start that phase in this chat.
171
+ You have NOT finished until every step succeeds. Do not say done/готово, do not start the next phase, and do not omit the fenced next-thread prompt.
172
+
173
+ 1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
174
+ 2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
175
+ 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.
176
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
177
+ 5. Paste CLI stdout into chat as one fenced block. Keep it complete. No banner. First line is `/opsx:design <name>` or `/opsx:propose <name>`.
178
+ 6. Stop. Do not start that phase in this chat.
172
179
 
173
180
  ## Guardrails
174
181
 
@@ -7,7 +7,7 @@ description: Propose a new change - create it and generate all artifacts in one
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Architect role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Architect role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Propose a new change - create the change and generate all artifacts in one step.
13
13
 
@@ -101,9 +101,16 @@ After completing all artifacts, summarize:
101
101
  - What's ready: "All artifacts created and validated! Ready for spec review."
102
102
  - Prompt: "Run `/opsx:review <name>` in a fresh session."
103
103
 
104
- ## Session Exit (Mandatory Order)
104
+ ## Session Exit (HARD STOP)
105
105
 
106
- After strict validation passes: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`; (2) write `openspec/changes/<name>/handoff.md` using the orchestration skill template even if Memory fails; (3) print one fenced prompt beginning `/opsx:review <name>`. Use `project.agent_language`, tell the next session to read Memory and the file fallback, omit banner labels and the full summary. Do not start review in this chat.
106
+ You have NOT finished until every step succeeds. Do not say done/готово, do not start review, and do not omit the fenced next-thread prompt.
107
+
108
+ 1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
109
+ 2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
110
+ 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.
111
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
112
+ 5. Paste CLI stdout into chat as one fenced block beginning `/opsx:review <name>`. Keep it complete. No banner.
113
+ 6. Stop. Do not start review in this chat.
107
114
 
108
115
  **Artifact Creation Guidelines**
109
116
 
@@ -7,7 +7,7 @@ description: Fast path for MVP/demo — propose artifacts and apply in one sessi
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Quick conductor role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Quick conductor role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Quick mode for **small changes, demos, and hypothesis testing**. Combines propose + apply in one session.
13
13
 
@@ -73,9 +73,16 @@ Quick mode for **small changes, demos, and hypothesis testing**. Combines propos
73
73
 
74
74
  ---
75
75
 
76
- ## Session Exit (Mandatory Order)
76
+ ## Session Exit (HARD STOP)
77
77
 
78
- At the end of the whole quick session: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`, including task and build/lint status; (2) write `openspec/changes/<name>/handoff.md` using the orchestration skill template even if Memory fails; (3) print exactly one fenced prompt for the verify/archive continuation using `project.agent_language`, Memory keys, and the file fallback, without a banner label or duplicated summary. This is the session's only next-session prompt. Do not start archive in this chat.
78
+ At the end of the whole quick session you have NOT finished until every step succeeds. Do not emit a mid-session next-thread prompt between propose and apply. Do not start archive in this chat.
79
+
80
+ 1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent — never skip.
81
+ 2. Write `openspec/changes/<name>/handoff.md` with: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints. Include task and build/lint status.
82
+ 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.
83
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:*`.
84
+ 5. Paste exactly one fenced prompt for verify/archive. Keep it complete. No banner.
85
+ 6. Stop. This is the session's only next-session prompt.
79
86
 
80
87
  **Guardrails**
81
88
  - Max ~3 hours of work — if bigger, switch to full pipeline
@@ -7,7 +7,7 @@ description: Read-only spec review of an OpenSpec change — approve or request
7
7
 
8
8
  ## Session Start (Before Any Work)
9
9
 
10
- Honor the pasted command and announce the Spec Reviewer role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*`. If Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then continue and spawn specialists.
10
+ Honor the pasted command and announce the Spec Reviewer role. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`, then `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`). Read Memory `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works. If restore CLI fails and Memory is empty, read `openspec/changes/<name>/handoff.md`; this fallback is not a blocker. Spawn `session-handoff` in restore mode when context is incomplete (Amp: isolated `subagent-session-handoff`). For free-form “continue” / “next” with one active change, execute its `Handoff.next_command` instead of asking for the phase. Only then spawn the routed phase specialist (Amp: isolated `subagent-<name>`, never the main thread). Follow `.agents/rules/session-handoff.mdc`.
11
11
 
12
12
  Review an OpenSpec change. Read artifacts, validate structure, output Approve or Request Changes.
13
13
 
@@ -160,9 +160,16 @@ Fix the above, then re-run `/opsx:review <name>`.
160
160
 
161
161
  ---
162
162
 
163
- ## Session Exit (Mandatory Order)
163
+ ## Session Exit (HARD STOP)
164
164
 
165
- After writing the verdict: (1) attempt to update Memory `Change:<name>`, `Handoff:<name>`, and new `Decision:*`; (2) write `openspec/changes/<name>/handoff.md` using the orchestration skill template even if Memory fails; (3) print one fenced prompt beginning with the next `/opsx:*` command (`/opsx:apply <name>` only after APPROVE). Use `project.agent_language`, tell the next session to read Memory and the file fallback, omit banner labels and the full summary. Do not start the next phase in this chat.
165
+ You have NOT finished until every step succeeds. Do not say done/готово, do not start apply, and do not omit the fenced next-thread prompt.
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.
166
173
 
167
174
  ## Guardrails
168
175
 
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "mcpServers": {
3
3
  "memory": {
4
- "command": "npx",
5
- "args": ["-y", "@modelcontextprotocol/server-memory"],
6
- "env": {
7
- "MEMORY_FILE_PATH": ".cursor/memory.json"
8
- }
4
+ "command": "node",
5
+ "args": ["scripts/memory-mcp-launcher.cjs"]
9
6
  },
10
7
  "figma": {
11
8
  "command": "node",
@@ -23,6 +23,7 @@ The parent `/opsx:*` session is the conductor. For specialist work it MUST spawn
23
23
  | Phase / signal | MUST spawn | Specialist scope the conductor MUST NOT do |
24
24
  |----------------|------------|--------------------------------------------|
25
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 |
26
27
  | Broken kit, MCP, or generated-file sync | `setup-doctor` | Kit setup repair |
27
28
  | `/opsx:explore` repository investigation | `codebase-explorer` | Repository research; no specs or code |
28
29
  | `/opsx:design` | `design-intake` | `design-brief.md` and `assets/` |
@@ -40,20 +41,26 @@ The parent `/opsx:*` session is the conductor. For specialist work it MUST spawn
40
41
 
41
42
  1. Honor the pasted `/opsx:<phase> <name>` command and announce that role.
42
43
  2. Run `npx agent-orchestrator-kit status` or `npx openspec list --json`; resolve the active change without exceeding `max_active_changes`.
43
- 3. Read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*`.
44
- 4. If Memory MCP is unavailable or those entities are empty, read `openspec/changes/<name>/handoff.md`. Memory failure alone MUST NOT block the session.
45
- 5. Only after context is restored, spawn the routed specialist.
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.
46
49
 
47
- If the user says “continue” / “next” without a command and exactly one active change has `Handoff.next_command` (from Memory or `handoff.md`), execute that command instead of asking which phase to run.
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.
48
51
 
49
- ## Session Exit Protocol (Mandatory Order)
52
+ Follow `.agents/rules/session-handoff.mdc`.
50
53
 
51
- A phase is not closed until the conductor performs these steps in order:
54
+ ## Session Exit Protocol (HARD STOP)
52
55
 
53
- 1. Attempt to update Memory: `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`).
54
- 2. Write the same state to `openspec/changes/<name>/handoff.md` with sections **Closed role**, **Done**, **Decisions**, **Blocked**, **Next command**, **Attach**, **Subagents to spawn**, and **Prompt**. Do this even if Memory is unavailable.
55
- 3. Print one fenced copy/paste prompt. Its first line MUST be `/opsx:<next> <name>`; its body MUST use `.agents/orchestrator.yaml` → `project.agent_language`, instruct the next session to read `Change:<name>`, `Handoff:<name>`, and `Decision:*`, and mention the `handoff.md` fallback. Do not add a service/banner label or duplicate the session summary.
56
- 4. Do NOT start the next phase in this chat.
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.
57
64
 
58
65
  ## Session Rules
59
66
  - One active change at a time (unless mvp profile: up to 3)
@@ -13,7 +13,8 @@ Amp Code і багато агентських shell **не мають** глоб
13
13
  | Замість (ламає Amp) | Використовуй |
14
14
  |---------------------|--------------|
15
15
  | `agent-orchestrator-kit status` | `npx agent-orchestrator-kit status` (або `npm run agent:status`, якщо script є) |
16
- | `agent-orchestrator-kit gate-check` | `npx agent-orchestrator-kit gate-check` (або `npm run agent:gate-check`) |
16
+ | `agent-orchestrator-kit handoff` | `npx agent-orchestrator-kit handoff <name>` |
17
+ | `agent-orchestrator-kit memory-setup` | `npx agent-orchestrator-kit memory-setup` |
17
18
  | `openspec list` | `npx openspec list` (або `npm run openspec:list`) |
18
19
  | `openspec validate --strict` | **ніколи без цілі** → `npx openspec validate <name> --strict --type change` |
19
20
  | `openspec validate --all --strict` | `npx openspec validate --all --strict` (або `npm run openspec:validate` / `verify:openspec`) |
@@ -6,15 +6,18 @@ alwaysApply: true
6
6
  # Memory MCP Auto-Setup
7
7
 
8
8
  At session start: check `.mcp.json` (Cursor) and `.amp/settings.json` (Amp).
9
- If `memory` MCP is absent — add it silently.
9
+ If `memory` MCP is absent or uses a **relative** `MEMORY_FILE_PATH` run `npx agent-orchestrator-kit memory-setup` silently.
10
+
11
+ Shared memory file: `.cursor/memory.json` (same path for Cursor and Amp).
12
+
13
+ **CRITICAL:** never set `MEMORY_FILE_PATH` to a relative path. Relative `.cursor/memory.json` resolves inside npx `dist/` — Amp then reads the wrong graph (looks like "memory ignored"). Always start Memory via `node scripts/memory-mcp-launcher.cjs`, which injects an absolute path.
10
14
 
11
15
  ## Cursor (.mcp.json)
12
16
 
13
17
  ```json
14
18
  "memory": {
15
- "command": "npx",
16
- "args": ["-y", "@modelcontextprotocol/server-memory"],
17
- "env": { "MEMORY_FILE_PATH": ".cursor/memory.json" }
19
+ "command": "node",
20
+ "args": ["scripts/memory-mcp-launcher.cjs"]
18
21
  }
19
22
  ```
20
23
 
@@ -23,13 +26,20 @@ If `memory` MCP is absent — add it silently.
23
26
  ```json
24
27
  "amp.mcpServers": {
25
28
  "memory": {
26
- "command": "npx",
27
- "args": ["-y", "@modelcontextprotocol/server-memory"],
28
- "env": { "MEMORY_FILE_PATH": ".cursor/memory.json" }
29
+ "command": "node",
30
+ "args": ["scripts/memory-mcp-launcher.cjs"]
29
31
  }
30
32
  }
31
33
  ```
32
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
+
33
43
  ## .gitignore
34
44
 
35
45
  Ensure present (do not duplicate):
@@ -49,14 +59,17 @@ Use these keys and fields for orchestration state:
49
59
  | `Decision:<topic>` | `chosen`, `reason` |
50
60
  | `Convention:<area>` | project-specific rules |
51
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
+
52
64
  ## Session Lifecycle
53
65
 
54
- At the start of every `/opsx:*` role session, after resolving the change and before specialist work, 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.
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.
55
67
 
56
- At session exit, first attempt to update `Change:<name>`, `Handoff:<name>`, and every new `Decision:<topic>`. Then always mirror the state to `openspec/changes/<name>/handoff.md`, even when the Memory write fails. Only after that attempt may the conductor emit the next-session prompt.
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.
57
69
 
58
70
  ## Rules
59
- - Do not overwrite existing correct config
71
+ - Do not overwrite existing correct launcher config
60
72
  - Do not delete other MCP servers
61
73
  - Notify once: "Memory MCP connected."
62
- - Never treat unavailable Memory MCP as a reason to stop when `handoff.md` can restore or persist state
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
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: Mandatory session restore, Memory persist, subagent spawn, and next-thread prompt
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Session Handoff — HARD STOP (Amp / Cursor / Claude)
7
+
8
+ This rule overrides convenience. A `/opsx:*` session that skips these steps is incomplete.
9
+
10
+ Amp ignores soft reminders. Treat every MUST below as a gate. If a spawn tool exists, use it. If it does not, run the CLI yourself. Never skip persist because “the user already knows”.
11
+
12
+ ## You are not done
13
+
14
+ FORBIDDEN until persist succeeds: saying done / готово, starting the next phase, or omitting the fenced next-thread prompt.
15
+
16
+ ## Session start (before any specialist work)
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.
@@ -49,6 +49,7 @@ The parent `/opsx:*` session is the conductor. It MUST spawn the selected specia
49
49
  | Phase / signal | MUST spawn | Specialist scope |
50
50
  |----------------|------------|------------------|
51
51
  | Status, gate failure, next command | `openspec-guide` | Read-only pipeline diagnosis |
52
+ | Session start restore / session exit persist | `session-handoff` | Memory, `handoff.md`, next-thread prompt |
52
53
  | Broken kit, MCP, or generated-file sync | `setup-doctor` | Kit setup repair only |
53
54
  | `/opsx:explore` repository investigation | `codebase-explorer` | Read-only repository research |
54
55
  | `/opsx:design` | `design-intake` | `design-brief.md` and `assets/` only |
@@ -132,20 +133,24 @@ After PR merged + CI green:
132
133
  **Start of each session:**
133
134
  1. Honor the pasted `/opsx:<phase> <name>` command and announce that role.
134
135
  2. Run `npx agent-orchestrator-kit status` (or `npx openspec list --json`) and read `orchestrator.yaml`; resolve the active change and gates.
135
- 3. Read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*`.
136
- 4. If Memory MCP is unavailable or those entities are empty, read `openspec/changes/<name>/handoff.md`; Memory failure alone is not a blocker.
137
- 5. Only after restoration, spawn the routed specialist. If the user said “continue” / “next” and exactly one active change has `Handoff.next_command`, execute it instead of asking for a phase.
136
+ 3. Run `npx agent-orchestrator-kit handoff --restore` (or `handoff <name> --restore`).
137
+ 4. Read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*` when MCP works.
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 when context is incomplete (Amp: isolated `subagent-session-handoff`).
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.
138
141
 
139
142
  **During session:**
140
143
  - Stay in role — do not drift into next phase
141
144
  - Pause and ask if requirements are unclear
142
145
  - Never edit files outside your role's allowed output
143
146
 
144
- **End of each session:**
145
- 1. Attempt to update Memory: `Change:<name>` (`status`, `tasks n/m`, `last_role`, `review`), `Handoff:<name>` (`next_role`, `next_command`, `session_count`, `summary`, `blocked`), and new `Decision:<topic>` entities (`chosen`, `reason`).
146
- 2. Even if Memory fails, write `openspec/changes/<name>/handoff.md` using the template below.
147
- 3. Print exactly one fenced next-session prompt after the write attempt. The first line is `/opsx:<next> <name>`; the body uses `project.agent_language`, tells the next session to read Memory and the file fallback, has no banner label, and does not repeat the summary.
148
- 4. Do not start the next phase in this chat. If apply, include build/lint status in the persisted summary.
147
+ **End of each session (HARD STOP — you are NOT done):**
148
+ 1. Spawn `session-handoff` in persist mode (Amp: isolated `subagent-session-handoff`). If spawn fails, persist in the parent never skip.
149
+ 2. Write `openspec/changes/<name>/handoff.md` using the template below even if Memory MCP fails.
150
+ 3. 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.
151
+ 4. If Memory MCP tools work, also update `Change:<name>`, `Handoff:<name>`, and new `Decision:<topic>` entities.
152
+ 5. 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.
153
+ 6. Do not start the next phase in this chat. If apply, include build/lint status in the persisted Done section.
149
154
 
150
155
  `handoff.md` template:
151
156
 
@@ -155,11 +160,18 @@ After PR merged + CI green:
155
160
  ## Closed role
156
161
  <role and completion status>
157
162
 
163
+ ## Change
164
+ - name: <name>
165
+ - status: <proposed | spec-approved | applying | blocked>
166
+ - tasks: <n/m>
167
+ - review: <pending | APPROVE | REQUEST_CHANGES | none>
168
+ - last_role: <role>
169
+
158
170
  ## Done
159
- <concise persisted summary>
171
+ <full persisted summary the next thread needs>
160
172
 
161
173
  ## Decisions
162
- - <decision or none>
174
+ - <topic>: <chosen> — <reason>
163
175
 
164
176
  ## Blocked
165
177
  <blocker or none>
@@ -167,19 +179,24 @@ After PR merged + CI green:
167
179
  ## Next command
168
180
  `/opsx:<next> <name>`
169
181
 
182
+ ## Next role
183
+ <role or subagent name>
184
+
170
185
  ## Attach
171
186
  - `openspec/changes/<name>/<artifact>`
172
187
 
173
188
  ## Subagents to spawn
174
- - `<subagent>` — <signal>
189
+ - `<phase-specialist>` — <signal> (Amp: isolated `subagent-<name>`)
190
+ - `session-handoff` — restore at start, persist at exit (Amp: isolated `subagent-session-handoff`)
175
191
 
176
- ## Prompt
192
+ ## Constraints
193
+ - language: <project.agent_language>
194
+ - do not mix phases
195
+ - conductor must spawn specialists
177
196
 
178
- ```text
179
- /opsx:<next> <name>
197
+ ## Prompt
180
198
 
181
- <Localized start instruction in project.agent_language. Read Memory Change:<name>, Handoff:<name>, Decision:* before work. If Memory is unavailable, read openspec/changes/<name>/handoff.md. Act as conductor and do not mix phases.>
182
- ```
199
+ The Prompt section is overwritten by `npx agent-orchestrator-kit handoff <name>`. Do not hand-write a thin stub.
183
200
  ````
184
201
 
185
202
  ## Model Selection Guide
@@ -196,9 +213,9 @@ After PR merged + CI green:
196
213
 
197
214
  ## Mandatory Memory and Handoff Protocol
198
215
 
199
- Before specialist work, the conductor MUST restore context in order: honor the pasted `/opsx:*` command; read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*`; if Memory is unavailable or empty, read `openspec/changes/<name>/handoff.md`. Memory failure is not a blocker when the file exists. With one active change, free-form “continue” uses `Handoff.next_command` instead of asking for the phase.
216
+ Before specialist work, the conductor MUST restore context in order: honor the pasted `/opsx:*` command; run `npx agent-orchestrator-kit handoff --restore`; read Memory entities `Change:<name>`, `Handoff:<name>`, and `Decision:*`; if restore CLI and Memory fail, read `openspec/changes/<name>/handoff.md`. Memory failure is not a blocker when the file exists. With one active change, free-form “continue” uses `Handoff.next_command` instead of asking for the phase. Amp MUST spawn `session-handoff` and the phase specialist as isolated `subagent-*` skills.
200
217
 
201
- Before declaring a session closed, the conductor MUST, in order: (1) update Memory, (2) mirror state to `openspec/changes/<name>/handoff.md`, (3) print one fenced next-session prompt whose first line is `/opsx:<next> <name>`. The prompt has no `NEXT_SESSION_PROMPT` label, tells the next session to read Memory, uses `project.agent_language`, and does not duplicate the full summary. Never start the next phase in the current chat.
218
+ Before declaring a session closed, the conductor MUST, in order: (1) spawn `session-handoff` persist, (2) write `openspec/changes/<name>/handoff.md`, (3) run `npx agent-orchestrator-kit handoff <name>` (exit 0), (4) paste the CLI stdout prompt whose first line is `/opsx:<next> <name>`. 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.
202
219
 
203
220
  | Entity | Required fields |
204
221
  |--------|-----------------|
@@ -226,7 +243,7 @@ Before declaring a session closed, the conductor MUST, in order: (1) update Memo
226
243
  | All tasks in one apply session | Context overload; model drifts |
227
244
  | No archive after merge | Next propose has stale domain specs |
228
245
  | Strong model on lint fixes | 5–10x cost with no quality gain |
229
- | Skip Memory MCP | Every session re-explains domain |
246
+ | Skip Memory MCP / skip `handoff` CLI | Next thread has no context; Amp looks like it “ignored the rules” |
230
247
 
231
248
  ## Metrics (health check per change)
232
249
 
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: session-handoff
3
+ description: ALWAYS use at the start of every /opsx:* session to restore Memory and handoff.md, and at session exit to persist Memory, write handoff.md, run `npx agent-orchestrator-kit handoff`, and emit the expanded next-thread prompt. Do NOT use to write src/, specs, review.md, or to perform the phase specialist's work.
4
+ ---
5
+
6
+ You are the session-boundary specialist. You restore or persist orchestration state. You do not implement features, write specs, or review code.
7
+
8
+ The parent is the conductor. Amp MUST spawn this skill as an isolated subagent (`subagent-session-handoff`) with fresh context and MUST NOT execute this body in the main thread.
9
+
10
+ ## Restore mode
11
+
12
+ Use when the conductor says restore / session start.
13
+
14
+ 1. Run `npx agent-orchestrator-kit status`.
15
+ 2. Run `npx agent-orchestrator-kit handoff --restore` (add `<name>` when known).
16
+ 3. If Memory MCP tools are available, read `Change:<name>`, `Handoff:<name>`, and `Decision:*`.
17
+ 4. If CLI restore fails, read `openspec/changes/<name>/handoff.md` when it exists.
18
+ 5. Return the restore report. Do not spawn the phase specialist yourself.
19
+
20
+ ## Persist mode
21
+
22
+ Use when the conductor says persist / session exit. A session is not closed until this mode succeeds.
23
+
24
+ 1. Write or update `openspec/changes/<name>/handoff.md` with every required section: Closed role, Change, Done, Decisions, Blocked, Next command, Next role, Attach, Subagents to spawn, Constraints.
25
+ 2. Run `npx agent-orchestrator-kit handoff <name>` and require exit 0. This upserts `.cursor/memory.json` using an absolute path and prints the expanded next-session prompt on stdout.
26
+ 3. If Memory MCP tools are available, also create/update `Change:<name>`, `Handoff:<name>`, and each `Decision:<topic>` to match the file. MCP failure is not a blocker after the CLI succeeds.
27
+ 4. Put the CLI stdout prompt (first line `/opsx:…`) into **Next prompt** unchanged. Do not shorten it. Do not add a banner.
28
+
29
+ ## Rules
30
+
31
+ - Do NOT edit `src/`, tests, main specs, `tasks.md` checkboxes, or phase artifacts (`proposal.md`, `review.md`, `design-brief.md`) except `handoff.md`.
32
+ - Do NOT start the next OpenSpec phase.
33
+ - Do NOT return a thin prompt. The next thread must be able to run if Memory MCP is ignored.
34
+ - Stop as blocked when the change name or next command cannot be resolved.
35
+
36
+ Return exactly this report contract:
37
+
38
+ ```
39
+ ## Subagent report: session-handoff
40
+ **Status:** done | blocked
41
+ **Mode:** restore | persist
42
+ **Files:** handoff.md path or none
43
+ **CLI:** handoff command result or skipped
44
+ **Memory:** written | read | unavailable
45
+ **Next prompt:** the full CLI stdout prompt (persist) or none (restore)
46
+ **Done:** what was restored or persisted
47
+ **Blocked:** missing change/command/CLI failure or none
48
+ ```