@limina-labs/momentum 0.30.2

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 (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/adapters/antigravity/adapter.js +196 -0
  4. package/adapters/antigravity/hooks.json +39 -0
  5. package/adapters/antigravity/instructions/AGENTS.md +638 -0
  6. package/adapters/antigravity/instructions/header.md +3 -0
  7. package/adapters/antigravity/instructions/surfaces.md +153 -0
  8. package/adapters/antigravity/instructions/vars.json +1 -0
  9. package/adapters/antigravity/scripts/antigravity-hook-adapter.sh +147 -0
  10. package/adapters/antigravity/skills/momentum-orient/SKILL.md +29 -0
  11. package/adapters/antigravity/skills/momentum-reviewer-architecture/SKILL.md +39 -0
  12. package/adapters/antigravity/skills/momentum-reviewer-qa/SKILL.md +38 -0
  13. package/adapters/antigravity/skills/momentum-reviewer-security/SKILL.md +42 -0
  14. package/adapters/antigravity/skills/swarm-supervisor/SKILL.md +75 -0
  15. package/adapters/antigravity/workflows/continue.md +39 -0
  16. package/adapters/antigravity/workflows/dispatch.md +49 -0
  17. package/adapters/antigravity/workflows/handoff.md +38 -0
  18. package/adapters/antigravity/workflows/review-code.md +84 -0
  19. package/adapters/antigravity/workflows/scout.md +42 -0
  20. package/adapters/antigravity/workflows/swarm.md +203 -0
  21. package/adapters/claude-code/adapter.js +148 -0
  22. package/adapters/claude-code/commands/continue.md +82 -0
  23. package/adapters/claude-code/commands/dispatch.md +154 -0
  24. package/adapters/claude-code/commands/handoff.md +85 -0
  25. package/adapters/claude-code/commands/review-code.md +194 -0
  26. package/adapters/claude-code/commands/scout.md +119 -0
  27. package/adapters/claude-code/commands/swarm.md +242 -0
  28. package/adapters/claude-code/instructions/header.md +3 -0
  29. package/adapters/claude-code/instructions/vars.json +1 -0
  30. package/adapters/claude-code/settings.json +36 -0
  31. package/adapters/codex/adapter.js +225 -0
  32. package/adapters/codex/agents/momentum-reviewer-architecture.toml +57 -0
  33. package/adapters/codex/agents/momentum-reviewer-qa.toml +52 -0
  34. package/adapters/codex/agents/momentum-reviewer-security.toml +57 -0
  35. package/adapters/codex/agents/swarm-supervisor.toml +76 -0
  36. package/adapters/codex/commands/continue.md +40 -0
  37. package/adapters/codex/commands/dispatch.md +111 -0
  38. package/adapters/codex/commands/handoff.md +57 -0
  39. package/adapters/codex/commands/scout.md +90 -0
  40. package/adapters/codex/commands/swarm.md +334 -0
  41. package/adapters/codex/hooks.json +36 -0
  42. package/adapters/codex/instructions/AGENTS.md +691 -0
  43. package/adapters/codex/instructions/header.md +3 -0
  44. package/adapters/codex/instructions/surfaces.md +206 -0
  45. package/adapters/codex/instructions/vars.json +1 -0
  46. package/adapters/codex/skills/momentum-orient/SKILL.md +29 -0
  47. package/adapters/opencode/adapter.js +224 -0
  48. package/adapters/opencode/agents/momentum-reviewer-architecture.md +54 -0
  49. package/adapters/opencode/agents/momentum-reviewer-qa.md +48 -0
  50. package/adapters/opencode/agents/momentum-reviewer-security.md +48 -0
  51. package/adapters/opencode/agents/swarm-supervisor.md +51 -0
  52. package/adapters/opencode/commands/continue.md +40 -0
  53. package/adapters/opencode/commands/dispatch.md +111 -0
  54. package/adapters/opencode/commands/handoff.md +57 -0
  55. package/adapters/opencode/commands/review-code.md +194 -0
  56. package/adapters/opencode/commands/scout.md +90 -0
  57. package/adapters/opencode/commands/swarm.md +334 -0
  58. package/adapters/opencode/instructions/AGENTS.md +604 -0
  59. package/adapters/opencode/instructions/header.md +3 -0
  60. package/adapters/opencode/instructions/surfaces.md +119 -0
  61. package/adapters/opencode/instructions/vars.json +1 -0
  62. package/adapters/opencode/plugins/momentum.js +219 -0
  63. package/adapters/opencode/skills/momentum-lanes/SKILL.md +30 -0
  64. package/adapters/opencode/skills/momentum-orient/SKILL.md +29 -0
  65. package/adapters/opencode/skills/momentum-track/SKILL.md +28 -0
  66. package/adapters/opencode/skills/momentum-validate/SKILL.md +31 -0
  67. package/bin/antigravity.js +112 -0
  68. package/bin/ecosystem.js +1302 -0
  69. package/bin/lanes.js +300 -0
  70. package/bin/momentum.js +1857 -0
  71. package/bin/okf.js +72 -0
  72. package/bin/orchestration-commands.js +305 -0
  73. package/bin/state-commands.js +218 -0
  74. package/bin/swarm.js +1104 -0
  75. package/bin/waves.js +147 -0
  76. package/core/adapter-capabilities.md +112 -0
  77. package/core/adapter-parity-matrix.md +170 -0
  78. package/core/commands/brainstorm-idea.md +98 -0
  79. package/core/commands/brainstorm-phase.md +129 -0
  80. package/core/commands/complete-phase.md +130 -0
  81. package/core/commands/ecosystem.md +161 -0
  82. package/core/commands/hotfix.md +64 -0
  83. package/core/commands/initiative.md +119 -0
  84. package/core/commands/lanes.md +94 -0
  85. package/core/commands/log.md +45 -0
  86. package/core/commands/migrate.md +70 -0
  87. package/core/commands/review.md +31 -0
  88. package/core/commands/session.md +79 -0
  89. package/core/commands/start-phase.md +161 -0
  90. package/core/commands/start-project.md +142 -0
  91. package/core/commands/sync-docs.md +81 -0
  92. package/core/commands/systematic-debug.md +46 -0
  93. package/core/commands/track.md +54 -0
  94. package/core/commands/validate.md +96 -0
  95. package/core/ecosystem/layout.md +128 -0
  96. package/core/ecosystem/lib/index.js +245 -0
  97. package/core/ecosystem/lib/initiative.js +258 -0
  98. package/core/ecosystem/lib/pointer.js +198 -0
  99. package/core/ecosystem/lib/state.js +295 -0
  100. package/core/ecosystem/schema/ecosystem.schema.json +85 -0
  101. package/core/ecosystem/schema/initiative.schema.json +61 -0
  102. package/core/ecosystem/scripts/session-append.sh +167 -0
  103. package/core/ecosystem/templates/ecosystem-agents.md +79 -0
  104. package/core/ecosystem/templates/ecosystem-claude.md +79 -0
  105. package/core/ecosystem/templates/ecosystem-settings-claude.json +14 -0
  106. package/core/ecosystem/templates/initiative-template.md +50 -0
  107. package/core/engines/subagent-dispatch.md +80 -0
  108. package/core/git-hooks/commit-msg +14 -0
  109. package/core/git-hooks/contract.js +176 -0
  110. package/core/git-hooks/pre-push +15 -0
  111. package/core/git-hooks/run-check.js +160 -0
  112. package/core/instructions/legacy-project-md-hashes.json +12 -0
  113. package/core/instructions/navigation.md +14 -0
  114. package/core/instructions/rules-body.md +454 -0
  115. package/core/lanes/lib/board.js +161 -0
  116. package/core/lanes/lib/land.js +301 -0
  117. package/core/lanes/lib/signals.js +207 -0
  118. package/core/lanes/lib/state.js +325 -0
  119. package/core/lib/frontmatter.js +163 -0
  120. package/core/lib/okf-migrate.js +374 -0
  121. package/core/lib/okf-types.js +61 -0
  122. package/core/lifecycle-contract.md +59 -0
  123. package/core/orchestration/capability-routing.js +120 -0
  124. package/core/orchestration/continue.js +102 -0
  125. package/core/orchestration/dispatch.js +366 -0
  126. package/core/orchestration/events.js +197 -0
  127. package/core/orchestration/handoff.js +317 -0
  128. package/core/orchestration/index.js +50 -0
  129. package/core/orchestration/run-artifact.js +93 -0
  130. package/core/orchestration/scout.js +327 -0
  131. package/core/orchestration/session-log.js +123 -0
  132. package/core/orchestration/tracking.js +180 -0
  133. package/core/orchestration/types.js +131 -0
  134. package/core/scripts/brainstorm-gate.sh +157 -0
  135. package/core/scripts/check-history-reminder.sh +110 -0
  136. package/core/scripts/sessionstart-handoff.sh +180 -0
  137. package/core/specs-templates/CLAUDE.md +484 -0
  138. package/core/specs-templates/README.md +32 -0
  139. package/core/specs-templates/specs/README.md +30 -0
  140. package/core/specs-templates/specs/adhoc/README.md +31 -0
  141. package/core/specs-templates/specs/adhoc/_TEMPLATE.md +29 -0
  142. package/core/specs-templates/specs/architecture/ecosystem.md +214 -0
  143. package/core/specs-templates/specs/backlog/backlog.md +46 -0
  144. package/core/specs-templates/specs/backlog/details/.gitkeep +0 -0
  145. package/core/specs-templates/specs/changelog/.gitkeep +0 -0
  146. package/core/specs-templates/specs/decisions/0000-template.md +33 -0
  147. package/core/specs-templates/specs/decisions/README.md +29 -0
  148. package/core/specs-templates/specs/decisions/impact-map.md +14 -0
  149. package/core/specs-templates/specs/decisions/index.md +4 -0
  150. package/core/specs-templates/specs/index.md +16 -0
  151. package/core/specs-templates/specs/phases/README.md +41 -0
  152. package/core/specs-templates/specs/phases/index.md +6 -0
  153. package/core/specs-templates/specs/planning/roadmap.md +23 -0
  154. package/core/specs-templates/specs/status.md +70 -0
  155. package/core/specs-templates/specs/vision/principles.md +16 -0
  156. package/core/specs-templates/specs/vision/project-charter.md +35 -0
  157. package/core/specs-templates/specs/vision/success-criteria.md +19 -0
  158. package/core/swarm/absorb.js +294 -0
  159. package/core/swarm/conductor.js +499 -0
  160. package/core/swarm/focus.js +151 -0
  161. package/core/swarm/inbox.js +222 -0
  162. package/core/swarm/join.js +138 -0
  163. package/core/swarm/lib/board.js +178 -0
  164. package/core/swarm/lib/brief.js +157 -0
  165. package/core/swarm/lib/git-sha-cache.js +71 -0
  166. package/core/swarm/lib/incremental-log.js +117 -0
  167. package/core/swarm/lib/manifest.js +578 -0
  168. package/core/swarm/lib/pre-merge.js +112 -0
  169. package/core/swarm/lib/saga.js +146 -0
  170. package/core/swarm/lib/sessions.js +83 -0
  171. package/core/swarm/lib/tokens.js +255 -0
  172. package/core/swarm/lib/wave-ordering.js +55 -0
  173. package/core/swarm/schema/board.schema.json +54 -0
  174. package/core/swarm/schema/contract.schema.json +56 -0
  175. package/core/swarm/schema/dispatch-run.schema.json +70 -0
  176. package/core/swarm/schema/manifest.schema.json +234 -0
  177. package/core/swarm/schema/signal.schema.json +61 -0
  178. package/core/swarm/signals.js +296 -0
  179. package/core/swarm/supervise.md +81 -0
  180. package/core/waves/lib/plan-graph.js +175 -0
  181. package/core/waves/lib/waves.js +83 -0
  182. package/package.json +46 -0
@@ -0,0 +1,3 @@
1
+ # Project Rules: <Project Name>
2
+
3
+ > Codex configuration for this momentum-managed project.
@@ -0,0 +1,206 @@
1
+ ## Momentum Recipes — Codex Skills
2
+
3
+ Each momentum recipe ships as a native Codex skill at
4
+ `.agents/skills/<name>/SKILL.md` ([Codex skills
5
+ docs](https://developers.openai.com/codex/skills)). Codex auto-discovers
6
+ skills under `.agents/skills/` at session start across CLI, IDE, and
7
+ desktop app — so when the user invokes `/brainstorm-phase`, asks "run
8
+ brainstorm-phase", or types `$brainstorm-phase`, Codex routes directly
9
+ to that skill.
10
+
11
+ The shipped recipe set (one skill per recipe, all under
12
+ `.agents/skills/`):
13
+
14
+ | Recipe | What it does |
15
+ |---|---|
16
+ | brainstorm-idea | Explore an idea before scaffolding anything |
17
+ | brainstorm-phase | Plan the next implementation phase (gate-protected) |
18
+ | start-project | Scaffold a new spec-driven project |
19
+ | start-phase | Begin a planned phase (autonomous execution contract) |
20
+ | complete-phase | Verify, retro, release a finished phase |
21
+ | sync-docs | Propagate history entries to other spec docs |
22
+ | track | Track a backlog item (bug / feature / tech debt / enhancement) |
23
+ | review | Review and groom the backlog between phases |
24
+ | log | Append a manual narrative entry to the history of the phase bound to your branch (fallback: status.md) |
25
+ | migrate | Onboard an existing project into momentum |
26
+ | validate | Check spec structure health |
27
+ | ecosystem | Cross-repo ecosystem coordination |
28
+ | initiative | Manage cross-repo initiatives |
29
+ | session | Append a manual narrative entry to today's ecosystem session log |
30
+ | systematic-debug | Systematically isolate, reproduce, and resolve task execution failures |
31
+ | scout | Read-only context fetch from one ecosystem member repo |
32
+ | dispatch | Parallel multi-repo fan-out + synthesis |
33
+ | handoff | Cross-session control transfer with structured context block |
34
+ | continue | Pick up a pending handoff in this repo |
35
+ | review-code | Multi-perspective code review (uses momentum-reviewer-* subagents) |
36
+ | swarm | Sustained parallel multi-project feature delivery (uses swarm-supervisor subagent) |
37
+ | momentum-orient | Read `specs/status.md` before starting any work (Rule 1) |
38
+
39
+ Each `SKILL.md` declares `name` + `description` frontmatter and includes
40
+ the full recipe body. The recipes are platform-independent — they
41
+ describe what to do, not how Codex specifically should do it. When you
42
+ read a recipe that mentions "use the Task tool" (Claude Code
43
+ terminology), translate to Codex's equivalent: spawn the relevant
44
+ `momentum-reviewer-*` subagent (see below), or use natural-language
45
+ parallel fan-out.
46
+
47
+ > Legacy installs from momentum ≤ v0.20.0 shipped recipes as Markdown
48
+ > fragments under `.codex/commands/`. `momentum upgrade --agent codex`
49
+ > regenerates skills under `.agents/skills/` and removes the old
50
+ > lookup directory.
51
+
52
+ ## Codex Subagents
53
+
54
+ Momentum ships four subagents discoverable at `.codex/agents/`:
55
+
56
+ - `momentum-reviewer-security.toml` — OWASP/STRIDE-focused
57
+ - `momentum-reviewer-qa.toml` — test coverage + edge cases + regression risk
58
+ - `momentum-reviewer-architecture.toml` — rule compliance + pattern consistency
59
+ - `swarm-supervisor.toml` — Phase 18 / v0.20.4. Per-repo supervisor spawned by `/swarm start`. Drives one repo's phase to completion under a pinned cwd (see MCP cwd shim section below).
60
+
61
+ The three reviewers each declare `sandbox_mode = "read-only"` so they
62
+ cannot modify the codebase. The `review-code` recipe dispatches all
63
+ three in a single turn so Codex can fan them out in parallel (subject
64
+ to `agents.max_threads`, default 6). The swarm supervisor does not
65
+ declare a read-only sandbox — supervisors write code, that's the job.
66
+
67
+ To add a project-specific reviewer, drop another `*.toml` into
68
+ `.codex/agents/` with required keys `name`, `description`,
69
+ `developer_instructions`. Optionally set `sandbox_mode = "read-only"` if
70
+ the subagent shouldn't modify files.
71
+
72
+ ## Codex Hooks
73
+
74
+ Codex hook wiring lives in `.codex/hooks.json`. Momentum installs reusable
75
+ shell scripts to `scripts/` and references them from this file:
76
+
77
+ | Event | Matcher | Script | Purpose |
78
+ |---|---|---|---|
79
+ | `PreToolUse` | `apply_patch\|Bash` | `scripts/brainstorm-gate.sh` | Blocks writes to `specs/` while a `/brainstorm-*` session is active (sentinel `.momentum/brainstorm-active`). Exits 2 to block. |
80
+ | `PostToolUse` | `apply_patch\|Bash` | `scripts/check-history-reminder.sh` | Prompts for `history.md` append when meaningful edits land during phase work — resolved to the phase bound to the current branch (fallback: `status.md`) (Rule 8). |
81
+ | `SessionStart` | (none) | `scripts/sessionstart-handoff.sh` | Auto-greets with any pending handoff banner + ecosystem context. |
82
+
83
+ > Matcher uses `Bash` (not `shell`) because that's the canonical
84
+ > `tool_name` Codex emits for shell tool calls — see the [Codex hooks
85
+ > reference](https://developers.openai.com/codex/hooks).
86
+
87
+ ### Trust review
88
+
89
+ Hooks are **enabled by default** in current Codex CLI (`hooks` is `stable`
90
+ in `codex features list`). The first time momentum's hooks run in a fresh
91
+ project, Codex prompts you to review and trust them via `/hooks`. Trust is
92
+ recorded per-hash, so any change to the hook command requires re-approval.
93
+
94
+ If hooks don't appear to fire:
95
+
96
+ 1. Run `/hooks` inside Codex and confirm `brainstorm-gate.sh`,
97
+ `check-history-reminder.sh`, and `sessionstart-handoff.sh` are listed
98
+ and marked trusted.
99
+ 2. Run `codex doctor` and confirm `hooks` shows as `stable: true`.
100
+ 3. Only as a last resort, force-enable in `~/.codex/config.toml`:
101
+
102
+ ```toml
103
+ [features]
104
+ hooks = true
105
+ ```
106
+
107
+ The `brainstorm-gate.sh` script resolves the project root from
108
+ `CLAUDE_PROJECT_DIR` → `MOMENTUM_PROJECT_DIR` → `pwd`, so Codex's default
109
+ cwd-as-session-root behavior works without env-var configuration.
110
+
111
+ ## Codex Skills
112
+
113
+ All momentum recipes ship as Codex skills under `.agents/skills/<name>/SKILL.md`
114
+ (see the "Momentum Recipes — Codex Skills" section above for the full
115
+ shipped set). Each `SKILL.md` declares `name` + `description` frontmatter
116
+ per the [Codex skills format](https://developers.openai.com/codex/skills).
117
+
118
+ Add additional project-specific skills under
119
+ `.agents/skills/<name>/SKILL.md` following the same convention. Invoke
120
+ via the `/skills` picker or `$<skill-name>` mention.
121
+
122
+ ## Swarm — Lookup Pattern
123
+
124
+ Momentum's swarm primitive — sustained parallel multi-project feature
125
+ delivery — ships on Codex as of Phase 18 / v0.20.4. The swarm recipe
126
+ lives as a Codex skill at `.agents/skills/swarm/SKILL.md`; Codex
127
+ auto-discovers and routes `/swarm <sub>` to it.
128
+
129
+ The CLI floor is `momentum swarm <sub> [args]`. The slash command and
130
+ the CLI produce the same on-disk artifacts — pick whichever fits the
131
+ moment.
132
+
133
+ | Subcommand | What it does |
134
+ |---|---|
135
+ | `start` | Plan + spawn Wave 1. Presents wave plan for approval before any spawn. |
136
+ | `status` | Render the materialized board cache. Read-only. |
137
+ | `tell` | Push a one-shot context note to one supervisor (`swarm-context.md`). |
138
+ | `broadcast` | Push context to every supervisor in the swarm. |
139
+ | `verify` | Contract verifier + manifest+brief drift check. |
140
+ | `complete` | Synthesize the cross-repo changeset and finalize the swarm. |
141
+ | `resume` | Re-attach this session to a swarm; renews owned leases. |
142
+ | `cancel` | Graceful halt; preserves all artifacts for forensics. |
143
+ | `budget` | Adjust a per-repo token budget. |
144
+ | `claim` | Multi-session ownership primitive (Phase 17.5). |
145
+ | `release` | Release ownership; idempotent. |
146
+ | `focus` | Issue a single-use focus token to hand a repo to a side session. |
147
+ | `join` | Register a second session as co-conductor; optionally consume a token. |
148
+ | `absorb` | Converge two swarms back into one (forensic-preserving). |
149
+ | `inbox` | Supervisor → conductor questions (`list` / `write` / `resolve`). |
150
+ | `preview-merge` | Dry-run `git merge --no-commit` per supervisor branch. |
151
+
152
+ **Supervisor declaration**: `.codex/agents/swarm-supervisor.toml`. Each
153
+ supervisor reads `core/swarm/supervise.md` end-to-end on boot. The
154
+ conductor (this user session) dispatches spawns through
155
+ `adapters/codex/adapter.js::spawn(directive)` — which shells
156
+ `codex --cwd <repoPath>` with the supervisor TOML.
157
+
158
+ If `codex` CLI isn't on PATH, `momentum swarm start --spawn` degrades
159
+ to dry-run: it prints the spawn directives so the user can launch
160
+ sessions manually.
161
+
162
+ ## MCP cwd shim — Codex configuration
163
+
164
+ > Phase 18 / v0.20.4. Required for the swarm primitive to honor the
165
+ > per-repo cwd pin every supervisor needs.
166
+
167
+ Each supervisor must run with its `repoPath` as its working directory —
168
+ that's the hard invariant the supervise.md recipe is written against
169
+ (every "stay in repoPath, never cd out" guard in `swarm-supervisor.toml`).
170
+
171
+ Codex's CLI accepts `--cwd <path>` for each `codex` invocation, so the
172
+ conductor's spawn call honors cwd at process boundary. Inside a
173
+ supervisor session, momentum relies on Codex's MCP filesystem server to
174
+ keep file ops scoped to that cwd — which means you (the user) configure
175
+ the MCP filesystem server's `--root` to follow `$PWD`.
176
+
177
+ In `~/.codex/config.toml` add:
178
+
179
+ ```toml
180
+ [mcp_servers.filesystem]
181
+ command = "npx"
182
+ args = ["-y", "@modelcontextprotocol/server-filesystem", "${PWD}"]
183
+ ```
184
+
185
+ (See [Codex MCP servers](https://developers.openai.com/codex/mcp) for
186
+ the canonical form. `${PWD}` is interpolated by Codex at server-spawn
187
+ time, so each supervisor sees its own pinned `repoPath` as the
188
+ filesystem server root.)
189
+
190
+ **Verifying the shim**: inside a supervisor session, run:
191
+
192
+ ```bash
193
+ pwd
194
+ ls -la
195
+ ```
196
+
197
+ You should see `repoPath` and the repo's top-level contents, not the
198
+ ecosystem root. If you see the ecosystem root, the shim isn't applied —
199
+ exit and reconfigure before launching supervisors.
200
+
201
+ **If the doc-only shim doesn't hold on your Codex version**: file a
202
+ bug against momentum and fall back to running each supervisor in a
203
+ separate terminal with `cd <repoPath> && codex …` — a manual cwd pin.
204
+ This is the documented escalation point referenced in Phase 18 G1
205
+ plan.md; if the MCP shim is widely broken, momentum will ship a
206
+ minimal `core/swarm/mcp-cwd-server.js` in a follow-up.
@@ -0,0 +1 @@
1
+ { "TASK_TOOL": "the built-in **plan** tool", "TASK_TOOL_NAME": "The plan tool" }
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: momentum-orient
3
+ description: Read specs/status.md before starting any work in a momentum-managed project. Activates at the start of every new task to ensure the agent has current phase context. Codifies Rule 1 (Orient First).
4
+ ---
5
+
6
+ # momentum-orient
7
+
8
+ When this skill activates (at session start or when the user asks you to
9
+ work on something new), read these files in order before any other action:
10
+
11
+ 1. `specs/status.md` — current phase, blockers, P0 items, next actions
12
+ 2. `specs/backlog/backlog.md` — P0/P1 items that may block the current task
13
+ 3. `specs/phases/<active-phase>/tasks.md` — what's done / in flight / blocked
14
+ 4. `AGENTS.md` — project rules and constraints (the complete rulebook)
15
+
16
+ Then proceed with the user's request, framing any output in terms of:
17
+ - which phase is active
18
+ - whether the requested work belongs in the active phase or is a side track
19
+ - any existing tasks or history entries that already cover the request
20
+
21
+ This skill is shipped by the momentum toolkit. It codifies Rule 1 (Orient
22
+ First) from the project rules. See `AGENTS.md` for the full set of rules.
23
+
24
+ ## When NOT to apply this skill
25
+
26
+ - If the user's message is purely conversational ("what is X?") and doesn't
27
+ require touching the codebase, you don't need to orient.
28
+ - If you've already oriented this session and nothing on disk has changed
29
+ since, don't re-orient.
@@ -0,0 +1,224 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { spawnSync } = require('child_process');
6
+
7
+ // opencode adapter for momentum.
8
+ //
9
+ // opencode (https://opencode.ai) is a terminal-first AI coding agent with
10
+ // native project-level surfaces for every momentum concept: markdown
11
+ // commands (.opencode/commands/), JS plugins with blocking pre-tool hooks
12
+ // (.opencode/plugins/), markdown agents with per-agent permissions
13
+ // (.opencode/agents/), and skills (.opencode/skills/<name>/SKILL.md).
14
+ // AGENTS.md is its primary instruction surface. Every surface auto-loads
15
+ // from its directory — momentum ships NO opencode.json and never touches
16
+ // user-owned config.
17
+ //
18
+ // Recipes install via the standard overlay into .opencode/commands/ where
19
+ // each file IS a native slash command (filename → /<name>). runInstall then
20
+ // prepends a `description` frontmatter block (extracted from the recipe's
21
+ // first line, same heuristic as the Codex skills transform) so the TUI
22
+ // command picker shows what each recipe does.
23
+
24
+ module.exports = {
25
+ displayName: 'opencode',
26
+
27
+ destinations: {
28
+ commands: ['.opencode', 'commands'],
29
+ 'agent-rules': ['.agent', 'rules'],
30
+ scripts: ['scripts'],
31
+ engines: ['.agent', 'engines'],
32
+ // workflows declared but unused on opencode (no native workflow surface;
33
+ // recipes are commands)
34
+ workflows: ['.opencode', 'workflows'],
35
+ skills: ['.opencode', 'skills'],
36
+ agents: ['.opencode', 'agents'],
37
+ },
38
+
39
+ primaryInstruction: {
40
+ source: ['instructions', 'AGENTS.md'],
41
+ destination: ['AGENTS.md'],
42
+ label: 'AGENTS.md',
43
+ markerAware: true,
44
+ },
45
+
46
+ configFiles: [
47
+ {
48
+ source: ['plugins', 'momentum.js'],
49
+ destination: ['.opencode', 'plugins', 'momentum.js'],
50
+ label: '.opencode/plugins/momentum.js',
51
+ },
52
+ ],
53
+
54
+ capabilities: {
55
+ hooks: true, // live-validated: gate blocked a real specs/ edit; reminder stamp observed (G5 checks 2-3)
56
+ slashCommands: true, // live-validated: /validate executed the recipe in run-mode (G5 check 1)
57
+ subagents: true, // live-validated: all 4 agents discovered; supervisor selected via --agent (G5 checks 5-6)
58
+ parallelSubagents: true, // live-validated: two task-tool subagents with overlapping start/end timestamps (G5)
59
+ sessionStartHook: true, // live-validated post-phase: banner fired in a served session via the event bus (run-mode excluded — see roadmap)
60
+ skills: true, // live-validated: skill tool loaded momentum-orient; multi-adapter coexistence clean (G5 check 7)
61
+ browser: false,
62
+ computerUse: false,
63
+ planningMode: true, // built-in read-only Plan agent (Tab-cycle primary)
64
+ },
65
+
66
+ roadmap: {
67
+ sessionStartHook:
68
+ 'Flipped true on live serve-session evidence (fix/opencode-sessionstart-banner): session events ' +
69
+ 'reach plugins only via the generic `event` bus (a named "session.created" hook key never fires ' +
70
+ 'on 1.17.x), and the banner now rides that bus. Deliberately EXCLUDED from `opencode run` ' +
71
+ 'non-interactive mode: the event handler\'s mere presence hangs run-mode (reproduced on 1.17.13, ' +
72
+ 'upstream issue candidate), and a session-start banner is meaningless there. Evidence: ' +
73
+ 'specs/adhoc/fix-opencode-sessionstart-banner/record.md.',
74
+ },
75
+
76
+ runInstall(targetDir, adapterDir, helpers) {
77
+ const { copyFile, fileExists, recordManaged, dryRun } = helpers;
78
+
79
+ console.log('→ Configuring momentum plugin for opencode...');
80
+ const pluginDest = path.join(targetDir, '.opencode', 'plugins', 'momentum.js');
81
+ if (recordManaged) recordManaged(pluginDest); // managed regardless of write
82
+ if (!fileExists(pluginDest)) {
83
+ copyFile(path.join(adapterDir, 'plugins', 'momentum.js'), pluginDest);
84
+ } else {
85
+ console.log(' ⚠️ .opencode/plugins/momentum.js already exists.');
86
+ console.log(` Merge manually from: ${path.join(adapterDir, 'plugins', 'momentum.js')}`);
87
+ }
88
+
89
+ console.log('→ Adding command frontmatter for the opencode TUI picker...');
90
+ if (dryRun) console.log(' ✋ would add description frontmatter to .opencode/commands/*.md');
91
+ else ensureCommandFrontmatter(targetDir);
92
+ },
93
+
94
+ runUpgrade(targetDir, adapterDir, helpers) {
95
+ const { copyFile, fileExists, recordManaged, dryRun } = helpers;
96
+
97
+ console.log('→ Upgrading momentum plugin for opencode...');
98
+ const src = path.join(adapterDir, 'plugins', 'momentum.js');
99
+ const dest = path.join(targetDir, '.opencode', 'plugins', 'momentum.js');
100
+ if (recordManaged) recordManaged(dest); // managed even when identical-skip
101
+
102
+ if (fileExists(dest)) {
103
+ const srcContent = fs.readFileSync(src, 'utf8');
104
+ const destContent = fs.readFileSync(dest, 'utf8');
105
+ if (srcContent !== destContent) {
106
+ if (dryRun) {
107
+ console.log(' ✋ would upgrade: .opencode/plugins/momentum.js');
108
+ } else {
109
+ fs.copyFileSync(dest, dest + '.bak');
110
+ copyFile(src, dest);
111
+ console.log(' ↑ upgraded: .opencode/plugins/momentum.js (original saved as .bak)');
112
+ }
113
+ }
114
+ } else {
115
+ copyFile(src, dest);
116
+ console.log(` ${dryRun ? '✋ would add: ' : '+ added: '} .opencode/plugins/momentum.js`);
117
+ }
118
+
119
+ console.log('→ Refreshing command frontmatter...');
120
+ if (dryRun) console.log(' ✋ would refresh description frontmatter on .opencode/commands/*.md');
121
+ else {
122
+ ensureCommandFrontmatter(targetDir);
123
+ cleanupConvergedBackups(path.join(targetDir, '.opencode', 'commands'));
124
+ }
125
+ },
126
+
127
+ // adapter.spawn(directive) — Phase 18 contract. Shells `opencode run` in
128
+ // non-interactive mode with the supervisor agent; `--dir` pins the
129
+ // supervisor's working directory to its repo (no MCP cwd shim needed,
130
+ // unlike Codex). See `bin/momentum.js` for the directive contract.
131
+ spawn(directive) {
132
+ if (!directive || directive.platform !== 'opencode') {
133
+ return {
134
+ repoId: directive && directive.repoId,
135
+ status: -1,
136
+ detail: `non-opencode platform: ${directive && directive.platform}`,
137
+ };
138
+ }
139
+ const opencodeBin = process.env.OPENCODE_BIN || 'opencode';
140
+ const prompt = [
141
+ `You are a swarm supervisor. Recipe: ${directive.recipePath}`,
142
+ `Read the recipe and the brief at specs/phases/${directive.phaseSlug}/overview.md.`,
143
+ `Your repo: ${directive.repoId}. Your swarm: ${directive.swarmId} wave ${directive.wave}.`,
144
+ `Begin the boot sequence.`,
145
+ ].join('\n');
146
+ const args = ['run', '--dir', directive.repoPath, '--agent', 'swarm-supervisor', prompt];
147
+ const r = spawnSync(opencodeBin, args, {
148
+ env: Object.assign({}, process.env, directive.env),
149
+ encoding: 'utf8',
150
+ timeout: 5000,
151
+ });
152
+ return {
153
+ repoId: directive.repoId,
154
+ status: r.status == null ? -1 : r.status,
155
+ detail: (r.error && r.error.message) || (r.stderr || '').slice(0, 200),
156
+ };
157
+ },
158
+ };
159
+
160
+ // ─── Command frontmatter transform ───────────────────────────────────────────
161
+ //
162
+ // opencode registers every .opencode/commands/*.md file as a /<name> command
163
+ // as-is; the optional YAML frontmatter `description` is what the TUI's
164
+ // command picker displays. Recipes follow the house style where line 1 is a
165
+ // one-sentence "what it does", so reuse it (same heuristic as the Codex
166
+ // skills transform). Idempotent: files that already start with frontmatter
167
+ // are left untouched.
168
+ function ensureCommandFrontmatter(targetDir) {
169
+ const commandsDir = path.join(targetDir, '.opencode', 'commands');
170
+ if (!fs.existsSync(commandsDir)) {
171
+ console.log(' (no .opencode/commands/ to annotate — skipping)');
172
+ return;
173
+ }
174
+ let count = 0;
175
+ for (const file of fs.readdirSync(commandsDir)) {
176
+ if (!file.endsWith('.md')) continue;
177
+ const filePath = path.join(commandsDir, file);
178
+ const body = fs.readFileSync(filePath, 'utf8');
179
+ if (body.startsWith('---\n')) continue; // already has frontmatter
180
+ const description = extractRecipeDescription(body, file.replace(/\.md$/, ''));
181
+ const frontmatter = `---\ndescription: ${yamlQuote(description)}\n---\n\n`;
182
+ fs.writeFileSync(filePath, frontmatter + body);
183
+ count++;
184
+ }
185
+ console.log(` + description frontmatter added to ${count} command(s)`);
186
+ }
187
+
188
+ // First non-heading, non-blank, non-blockquote line of the recipe.
189
+ function extractRecipeDescription(body, name) {
190
+ for (const line of body.split('\n')) {
191
+ const trimmed = line.trim();
192
+ if (!trimmed) continue;
193
+ if (trimmed.startsWith('#') || trimmed.startsWith('>')) continue;
194
+ // Truncate to a single-sentence-ish length for the picker.
195
+ return trimmed.length > 200 ? `${trimmed.slice(0, 197)}...` : trimmed;
196
+ }
197
+ return `momentum ${name} recipe`;
198
+ }
199
+
200
+ function yamlQuote(s) {
201
+ return `"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
202
+ }
203
+
204
+ // The generic overlay upgrade sees the install-time frontmatter as drift from
205
+ // the pristine template, so it backs up each command before replacing it —
206
+ // then the transform above re-adds identical frontmatter, converging the file
207
+ // back to its pre-upgrade bytes. A `.bak` byte-identical to its base is that
208
+ // cycle's artifact, not a user modification — remove it. Real user edits
209
+ // leave a differing `.bak`, which is kept.
210
+ function cleanupConvergedBackups(dir) {
211
+ if (!fs.existsSync(dir)) return;
212
+ let removed = 0;
213
+ for (const f of fs.readdirSync(dir)) {
214
+ if (!f.endsWith('.bak')) continue;
215
+ const bakPath = path.join(dir, f);
216
+ const basePath = path.join(dir, f.slice(0, -'.bak'.length));
217
+ if (!fs.existsSync(basePath)) continue;
218
+ if (fs.readFileSync(bakPath, 'utf8') === fs.readFileSync(basePath, 'utf8')) {
219
+ fs.unlinkSync(bakPath);
220
+ removed++;
221
+ }
222
+ }
223
+ if (removed) console.log(` - ${removed} converged .bak backup(s) removed (frontmatter cycle)`);
224
+ }
@@ -0,0 +1,54 @@
1
+ ---
2
+ description: Review a code diff for architectural fit, rule compliance, and pattern consistency. Returns Critical/Important/Minor findings ONLY — does not modify code, does not refactor. Dispatched by the review-code recipe.
3
+ mode: subagent
4
+ permission:
5
+ edit: deny
6
+ bash:
7
+ "*": deny
8
+ "git diff*": allow
9
+ "git log*": allow
10
+ "git show*": allow
11
+ "git status*": allow
12
+ ---
13
+
14
+ You are an architecture-focused code reviewer dispatched by the momentum
15
+ toolkit. You will receive a code diff and the project's full rules
16
+ (AGENTS.md — the complete rulebook).
17
+
18
+ YOUR LENS: architectural fit, rule compliance, pattern consistency.
19
+
20
+ For each change, ask:
21
+ - Does it violate any of the 12 autonomous rules (orient first, update
22
+ tracking, auto-track discoveries, pre-phase bug check, phase boundary
23
+ awareness, git lifecycle, plan before implementing, record history,
24
+ doc sync protocol, architecture stability, evaluator discipline,
25
+ verify before claim)?
26
+ - Does it match the patterns established elsewhere in the codebase?
27
+ Read 2-3 nearby files for convention.
28
+ - Does it create hidden coupling, a leaky abstraction, or an
29
+ adapter/contract violation? (For momentum specifically: every
30
+ capability declaration uniform-boolean; overlay subdirs use the
31
+ destinations contract; adapter-specific code stays in adapters/,
32
+ generic in core/.)
33
+ - Is it documented where rules say it should be (history.md entry, ADR
34
+ for decisional changes, backlog entry for discovered issues)?
35
+ - Does the commit message convention match (feat / fix / docs / etc.)?
36
+
37
+ Output format — return EXACTLY this structure:
38
+
39
+ ```
40
+ ## Architecture review
41
+
42
+ ### Critical
43
+ - [finding] (file:line) — [why it's critical]
44
+
45
+ ### Important
46
+ - [finding] (file:line) — [explanation]
47
+
48
+ ### Minor
49
+ - [finding] (file:line) — [explanation]
50
+ ```
51
+
52
+ If no findings at a severity level, write "(none)". Do NOT speculate
53
+ beyond what the diff shows. Do NOT refactor yourself — flag the
54
+ issue. Do NOT modify any files.
@@ -0,0 +1,48 @@
1
+ ---
2
+ description: Review a code diff for test coverage, edge cases, and regression risk. Returns Critical/Important/Minor findings ONLY — does not modify code, does not write tests. Dispatched by the review-code recipe on the current branch's pending changes.
3
+ mode: subagent
4
+ permission:
5
+ edit: deny
6
+ bash:
7
+ "*": deny
8
+ "git diff*": allow
9
+ "git log*": allow
10
+ "git show*": allow
11
+ "git status*": allow
12
+ ---
13
+
14
+ You are a QA-focused code reviewer dispatched by the momentum toolkit.
15
+ You will receive a code diff and a project-rules excerpt (especially
16
+ Rule 12 — Verify Before Claim).
17
+
18
+ YOUR LENS: test coverage, edge cases, regression risk.
19
+
20
+ For each meaningful behavior change in the diff, ask:
21
+ - Is there a test that exercises it? If yes, does it test the happy
22
+ path AND at least one edge case?
23
+ - What edge cases are uncovered? Consider: empty input, large input,
24
+ concurrent access, error paths, network/IO failures, malformed data,
25
+ Unicode / non-ASCII, very long strings, off-by-one boundaries.
26
+ - Could this change break an existing test or production path? Look
27
+ for callers of any modified function.
28
+ - Does the change add a verification command, or rely on "should work
29
+ now" — Rule 12 territory.
30
+
31
+ Output format — return EXACTLY this structure:
32
+
33
+ ```
34
+ ## QA review
35
+
36
+ ### Critical
37
+ - [finding] (file:line) — [why it's critical]
38
+
39
+ ### Important
40
+ - [finding] (file:line) — [explanation]
41
+
42
+ ### Minor
43
+ - [finding] (file:line) — [explanation]
44
+ ```
45
+
46
+ If no findings at a severity level, write "(none)". Do NOT speculate
47
+ beyond what the diff shows. Do NOT write tests yourself — flag the
48
+ gap. Do NOT modify any files.
@@ -0,0 +1,48 @@
1
+ ---
2
+ description: Review a code diff through a security lens (OWASP Top 10, STRIDE threat categories). Returns Critical/Important/Minor findings ONLY — does not modify code, does not propose fixes. Dispatched by the review-code recipe on the current branch's pending changes.
3
+ mode: subagent
4
+ permission:
5
+ edit: deny
6
+ bash:
7
+ "*": deny
8
+ "git diff*": allow
9
+ "git log*": allow
10
+ "git show*": allow
11
+ "git status*": allow
12
+ ---
13
+
14
+ You are a security-focused code reviewer dispatched by the momentum
15
+ toolkit. You will receive a code diff and a project-rules excerpt.
16
+
17
+ YOUR LENS: OWASP Top 10 + STRIDE threat categories.
18
+
19
+ Things to look for:
20
+ - Hard-coded secrets, credentials, API keys
21
+ - SQL/NoSQL injection vectors, unparameterized queries
22
+ - XSS / SSRF / CSRF surfaces in any user-controlled input path
23
+ - Authentication / authorization gaps in newly added endpoints
24
+ - Insecure deserialization, prototype pollution
25
+ - Logging of sensitive data (PII, tokens)
26
+ - Race conditions / TOCTOU in security-relevant code paths
27
+ - Cryptographic anti-patterns (weak algorithms, fixed IVs, MD5/SHA1
28
+ for security, broken random sources)
29
+ - Dependency additions of known-vulnerable packages
30
+
31
+ Output format — return EXACTLY this structure:
32
+
33
+ ```
34
+ ## Security review
35
+
36
+ ### Critical
37
+ - [finding] (file:line) — [why it's critical]
38
+
39
+ ### Important
40
+ - [finding] (file:line) — [explanation]
41
+
42
+ ### Minor
43
+ - [finding] (file:line) — [explanation]
44
+ ```
45
+
46
+ If no findings at a severity level, write "(none)". Do NOT speculate
47
+ beyond what the diff shows. Do NOT propose code fixes — flag only.
48
+ Do NOT modify any files. Do NOT run any code-modifying commands.
@@ -0,0 +1,51 @@
1
+ ---
2
+ description: Drive a single repo through its phase as part of a swarm. Read the recipe at the path supplied in the spawn directive (typically core/swarm/supervise.md), read the brief at specs/phases/<phase-slug>/overview.md, and execute the boot sequence. State lives in files; the conductor reads board.json between turns. Dispatched by the conductor; not invoked directly by the user.
3
+ mode: all
4
+ ---
5
+
6
+ You are a swarm supervisor for one repo. The conductor (the user's
7
+ primary session) spawned you with a spawn directive containing:
8
+
9
+ - repoPath: your pinned cwd; never cd out of it
10
+ - phaseSlug: the phase you are driving (specs/phases/<slug>/)
11
+ - swarmId: the swarm you belong to (manifest at <eco>/swarms/<id>/)
12
+ - wave: your wave index (1-based)
13
+ - sessionId: the conductor's session id
14
+ - recipePath: absolute path to supervise.md — your operating recipe
15
+
16
+ Boot sequence:
17
+
18
+ 1. Read the recipe at `recipePath` end-to-end. Treat it as your
19
+ operating manual for this session.
20
+ 2. Read your brief at `specs/phases/<phase-slug>/overview.md`. The
21
+ brief's frontmatter (swarm, wave, initiative, claimed_by_session)
22
+ was populated by the conductor.
23
+ 3. Read `specs/status.md` per Rule 1 (orient first).
24
+ 4. Begin the normal momentum lifecycle inside this repo: /start-phase
25
+ → implement → /sync-docs → /complete-phase. Each phase command is
26
+ itself an opencode command — invoke it by name.
27
+
28
+ Operating constraints:
29
+
30
+ - Stay in `repoPath` (your session was spawned with `opencode run --dir
31
+ <repoPath>`, so your working directory is already pinned). Never `cd`
32
+ to a sibling repo. Cross-repo concerns go through the inbox primitive
33
+ at `<eco>/swarms/<swarm-id>/inbox/`.
34
+ - State lives in files. Append to `history.md` per Rule 8; the
35
+ conductor reads `board.json` between turns to render progress to the
36
+ user.
37
+ - The conductor may push context via `swarm-context.md` at
38
+ `specs/phases/<phase-slug>/swarm-context.md`. Read it at the top of
39
+ every turn.
40
+ - If you have a question only the conductor can answer, write it to
41
+ the swarm inbox via:
42
+
43
+ momentum swarm inbox write <swarm-id> --repo <your-repo-id> \
44
+ --slug <short-slug> --question "<text>"
45
+
46
+ Then wait for resolution before continuing — do NOT guess.
47
+ - When your phase is complete, run /complete-phase per the standard
48
+ recipe; the supervisor finishes after the phase is verified and
49
+ pushed.
50
+
51
+ You inherit every always-on rule from AGENTS.md (the complete rulebook).