@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.
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/adapters/antigravity/adapter.js +196 -0
- package/adapters/antigravity/hooks.json +39 -0
- package/adapters/antigravity/instructions/AGENTS.md +638 -0
- package/adapters/antigravity/instructions/header.md +3 -0
- package/adapters/antigravity/instructions/surfaces.md +153 -0
- package/adapters/antigravity/instructions/vars.json +1 -0
- package/adapters/antigravity/scripts/antigravity-hook-adapter.sh +147 -0
- package/adapters/antigravity/skills/momentum-orient/SKILL.md +29 -0
- package/adapters/antigravity/skills/momentum-reviewer-architecture/SKILL.md +39 -0
- package/adapters/antigravity/skills/momentum-reviewer-qa/SKILL.md +38 -0
- package/adapters/antigravity/skills/momentum-reviewer-security/SKILL.md +42 -0
- package/adapters/antigravity/skills/swarm-supervisor/SKILL.md +75 -0
- package/adapters/antigravity/workflows/continue.md +39 -0
- package/adapters/antigravity/workflows/dispatch.md +49 -0
- package/adapters/antigravity/workflows/handoff.md +38 -0
- package/adapters/antigravity/workflows/review-code.md +84 -0
- package/adapters/antigravity/workflows/scout.md +42 -0
- package/adapters/antigravity/workflows/swarm.md +203 -0
- package/adapters/claude-code/adapter.js +148 -0
- package/adapters/claude-code/commands/continue.md +82 -0
- package/adapters/claude-code/commands/dispatch.md +154 -0
- package/adapters/claude-code/commands/handoff.md +85 -0
- package/adapters/claude-code/commands/review-code.md +194 -0
- package/adapters/claude-code/commands/scout.md +119 -0
- package/adapters/claude-code/commands/swarm.md +242 -0
- package/adapters/claude-code/instructions/header.md +3 -0
- package/adapters/claude-code/instructions/vars.json +1 -0
- package/adapters/claude-code/settings.json +36 -0
- package/adapters/codex/adapter.js +225 -0
- package/adapters/codex/agents/momentum-reviewer-architecture.toml +57 -0
- package/adapters/codex/agents/momentum-reviewer-qa.toml +52 -0
- package/adapters/codex/agents/momentum-reviewer-security.toml +57 -0
- package/adapters/codex/agents/swarm-supervisor.toml +76 -0
- package/adapters/codex/commands/continue.md +40 -0
- package/adapters/codex/commands/dispatch.md +111 -0
- package/adapters/codex/commands/handoff.md +57 -0
- package/adapters/codex/commands/scout.md +90 -0
- package/adapters/codex/commands/swarm.md +334 -0
- package/adapters/codex/hooks.json +36 -0
- package/adapters/codex/instructions/AGENTS.md +691 -0
- package/adapters/codex/instructions/header.md +3 -0
- package/adapters/codex/instructions/surfaces.md +206 -0
- package/adapters/codex/instructions/vars.json +1 -0
- package/adapters/codex/skills/momentum-orient/SKILL.md +29 -0
- package/adapters/opencode/adapter.js +224 -0
- package/adapters/opencode/agents/momentum-reviewer-architecture.md +54 -0
- package/adapters/opencode/agents/momentum-reviewer-qa.md +48 -0
- package/adapters/opencode/agents/momentum-reviewer-security.md +48 -0
- package/adapters/opencode/agents/swarm-supervisor.md +51 -0
- package/adapters/opencode/commands/continue.md +40 -0
- package/adapters/opencode/commands/dispatch.md +111 -0
- package/adapters/opencode/commands/handoff.md +57 -0
- package/adapters/opencode/commands/review-code.md +194 -0
- package/adapters/opencode/commands/scout.md +90 -0
- package/adapters/opencode/commands/swarm.md +334 -0
- package/adapters/opencode/instructions/AGENTS.md +604 -0
- package/adapters/opencode/instructions/header.md +3 -0
- package/adapters/opencode/instructions/surfaces.md +119 -0
- package/adapters/opencode/instructions/vars.json +1 -0
- package/adapters/opencode/plugins/momentum.js +219 -0
- package/adapters/opencode/skills/momentum-lanes/SKILL.md +30 -0
- package/adapters/opencode/skills/momentum-orient/SKILL.md +29 -0
- package/adapters/opencode/skills/momentum-track/SKILL.md +28 -0
- package/adapters/opencode/skills/momentum-validate/SKILL.md +31 -0
- package/bin/antigravity.js +112 -0
- package/bin/ecosystem.js +1302 -0
- package/bin/lanes.js +300 -0
- package/bin/momentum.js +1857 -0
- package/bin/okf.js +72 -0
- package/bin/orchestration-commands.js +305 -0
- package/bin/state-commands.js +218 -0
- package/bin/swarm.js +1104 -0
- package/bin/waves.js +147 -0
- package/core/adapter-capabilities.md +112 -0
- package/core/adapter-parity-matrix.md +170 -0
- package/core/commands/brainstorm-idea.md +98 -0
- package/core/commands/brainstorm-phase.md +129 -0
- package/core/commands/complete-phase.md +130 -0
- package/core/commands/ecosystem.md +161 -0
- package/core/commands/hotfix.md +64 -0
- package/core/commands/initiative.md +119 -0
- package/core/commands/lanes.md +94 -0
- package/core/commands/log.md +45 -0
- package/core/commands/migrate.md +70 -0
- package/core/commands/review.md +31 -0
- package/core/commands/session.md +79 -0
- package/core/commands/start-phase.md +161 -0
- package/core/commands/start-project.md +142 -0
- package/core/commands/sync-docs.md +81 -0
- package/core/commands/systematic-debug.md +46 -0
- package/core/commands/track.md +54 -0
- package/core/commands/validate.md +96 -0
- package/core/ecosystem/layout.md +128 -0
- package/core/ecosystem/lib/index.js +245 -0
- package/core/ecosystem/lib/initiative.js +258 -0
- package/core/ecosystem/lib/pointer.js +198 -0
- package/core/ecosystem/lib/state.js +295 -0
- package/core/ecosystem/schema/ecosystem.schema.json +85 -0
- package/core/ecosystem/schema/initiative.schema.json +61 -0
- package/core/ecosystem/scripts/session-append.sh +167 -0
- package/core/ecosystem/templates/ecosystem-agents.md +79 -0
- package/core/ecosystem/templates/ecosystem-claude.md +79 -0
- package/core/ecosystem/templates/ecosystem-settings-claude.json +14 -0
- package/core/ecosystem/templates/initiative-template.md +50 -0
- package/core/engines/subagent-dispatch.md +80 -0
- package/core/git-hooks/commit-msg +14 -0
- package/core/git-hooks/contract.js +176 -0
- package/core/git-hooks/pre-push +15 -0
- package/core/git-hooks/run-check.js +160 -0
- package/core/instructions/legacy-project-md-hashes.json +12 -0
- package/core/instructions/navigation.md +14 -0
- package/core/instructions/rules-body.md +454 -0
- package/core/lanes/lib/board.js +161 -0
- package/core/lanes/lib/land.js +301 -0
- package/core/lanes/lib/signals.js +207 -0
- package/core/lanes/lib/state.js +325 -0
- package/core/lib/frontmatter.js +163 -0
- package/core/lib/okf-migrate.js +374 -0
- package/core/lib/okf-types.js +61 -0
- package/core/lifecycle-contract.md +59 -0
- package/core/orchestration/capability-routing.js +120 -0
- package/core/orchestration/continue.js +102 -0
- package/core/orchestration/dispatch.js +366 -0
- package/core/orchestration/events.js +197 -0
- package/core/orchestration/handoff.js +317 -0
- package/core/orchestration/index.js +50 -0
- package/core/orchestration/run-artifact.js +93 -0
- package/core/orchestration/scout.js +327 -0
- package/core/orchestration/session-log.js +123 -0
- package/core/orchestration/tracking.js +180 -0
- package/core/orchestration/types.js +131 -0
- package/core/scripts/brainstorm-gate.sh +157 -0
- package/core/scripts/check-history-reminder.sh +110 -0
- package/core/scripts/sessionstart-handoff.sh +180 -0
- package/core/specs-templates/CLAUDE.md +484 -0
- package/core/specs-templates/README.md +32 -0
- package/core/specs-templates/specs/README.md +30 -0
- package/core/specs-templates/specs/adhoc/README.md +31 -0
- package/core/specs-templates/specs/adhoc/_TEMPLATE.md +29 -0
- package/core/specs-templates/specs/architecture/ecosystem.md +214 -0
- package/core/specs-templates/specs/backlog/backlog.md +46 -0
- package/core/specs-templates/specs/backlog/details/.gitkeep +0 -0
- package/core/specs-templates/specs/changelog/.gitkeep +0 -0
- package/core/specs-templates/specs/decisions/0000-template.md +33 -0
- package/core/specs-templates/specs/decisions/README.md +29 -0
- package/core/specs-templates/specs/decisions/impact-map.md +14 -0
- package/core/specs-templates/specs/decisions/index.md +4 -0
- package/core/specs-templates/specs/index.md +16 -0
- package/core/specs-templates/specs/phases/README.md +41 -0
- package/core/specs-templates/specs/phases/index.md +6 -0
- package/core/specs-templates/specs/planning/roadmap.md +23 -0
- package/core/specs-templates/specs/status.md +70 -0
- package/core/specs-templates/specs/vision/principles.md +16 -0
- package/core/specs-templates/specs/vision/project-charter.md +35 -0
- package/core/specs-templates/specs/vision/success-criteria.md +19 -0
- package/core/swarm/absorb.js +294 -0
- package/core/swarm/conductor.js +499 -0
- package/core/swarm/focus.js +151 -0
- package/core/swarm/inbox.js +222 -0
- package/core/swarm/join.js +138 -0
- package/core/swarm/lib/board.js +178 -0
- package/core/swarm/lib/brief.js +157 -0
- package/core/swarm/lib/git-sha-cache.js +71 -0
- package/core/swarm/lib/incremental-log.js +117 -0
- package/core/swarm/lib/manifest.js +578 -0
- package/core/swarm/lib/pre-merge.js +112 -0
- package/core/swarm/lib/saga.js +146 -0
- package/core/swarm/lib/sessions.js +83 -0
- package/core/swarm/lib/tokens.js +255 -0
- package/core/swarm/lib/wave-ordering.js +55 -0
- package/core/swarm/schema/board.schema.json +54 -0
- package/core/swarm/schema/contract.schema.json +56 -0
- package/core/swarm/schema/dispatch-run.schema.json +70 -0
- package/core/swarm/schema/manifest.schema.json +234 -0
- package/core/swarm/schema/signal.schema.json +61 -0
- package/core/swarm/signals.js +296 -0
- package/core/swarm/supervise.md +81 -0
- package/core/waves/lib/plan-graph.js +175 -0
- package/core/waves/lib/waves.js +83 -0
- package/package.json +46 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
Swarm — sustained parallel multi-project feature delivery (Phase 18, Codex parity).
|
|
2
|
+
|
|
3
|
+
A **swarm** is a declared cross-repo work unit driven from ONE user session. The user's session becomes the **conductor**. The conductor spawns one **supervisor** Codex session per impacted repo, each pinned to that repo's working directory (cwd) via the MCP cwd shim (see AGENTS.md → `## MCP cwd shim — Codex configuration`). Each supervisor runs momentum's normal `/start-phase` → implement → `/sync-docs` → `/complete-phase` loop INSIDE its repo. The conductor coordinates waves (computed from `ecosystem.json` dependency edges), surfaces inbox decisions, broadcasts cross-cutting concerns, and synthesizes per-repo retrospectives at fan-in.
|
|
4
|
+
|
|
5
|
+
> Phase 18 / v0.20.4 — Codex parity of the Phase 17 / 17.5 swarm surface that originally shipped Claude Code only. All 13 subcommands work through the Codex `adapter.spawn(directive)` dispatch (`adapters/codex/adapter.js`).
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
| Layer | Owns | Reads |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Conductor (this user session) | `<eco>/swarms/<id>/manifest.json` + `board.json` + `contracts/` + `inbox/` + `signals/` + `changes/` | Per-supervisor `dispatch-run-<id>.json` (status) |
|
|
12
|
+
| Supervisor (per repo, fresh Codex session pinned to repo cwd) | `<repo>/specs/phases/phase-N-<slug>/*` + `<repo>/.momentum/runs/dispatch-run-<id>.json` | Its phase brief + contract + history.md tail |
|
|
13
|
+
|
|
14
|
+
Agents are stateless across turns; **state lives in files**. A swarm survives session boundaries the same way a phase does — every state-changing action writes to disk; `/swarm resume` reconstitutes from disk.
|
|
15
|
+
|
|
16
|
+
## When to use
|
|
17
|
+
|
|
18
|
+
- A feature spans **two or more momentum-installed repos** AND has dependency ordering (frontend depends on backend depends on shared-types).
|
|
19
|
+
- The user wants ONE Codex session driving the whole feature, not three serial sessions.
|
|
20
|
+
- An initiative exists or is about to exist at `<eco>/initiatives/<slug>.md`.
|
|
21
|
+
|
|
22
|
+
Do NOT use `/swarm` for:
|
|
23
|
+
- Read-only cross-repo audits — use `/dispatch`.
|
|
24
|
+
- Single-repo phases — use `/start-phase` directly.
|
|
25
|
+
- Pure context transfer — use `/handoff`.
|
|
26
|
+
|
|
27
|
+
## Codex specifics
|
|
28
|
+
|
|
29
|
+
- **Supervisor declaration**: `.codex/agents/swarm-supervisor.toml` (Codex subagent). Each supervisor reads `core/swarm/supervise.md` end-to-end on boot.
|
|
30
|
+
- **cwd pinning**: per-supervisor cwd is honored via the MCP filesystem server (`## MCP cwd shim — Codex configuration` in AGENTS.md). Without the shim, every supervisor would see the conductor's cwd — a hard supervise.md invariant violation.
|
|
31
|
+
- **Spawn dispatch**: the CLI floor (`momentum swarm start --spawn …`) dispatches each spawn directive through `adapters/codex/adapter.js::spawn()`. The adapter shells `codex --cwd <repoPath>` with the supervisor TOML as the agent declaration.
|
|
32
|
+
- **Hook integration**: `apply_patch|Bash` matchers in `.codex/hooks.json` apply uniformly inside each supervisor. The brainstorm gate keeps supervisors from drifting into spec edits during phase implementation.
|
|
33
|
+
|
|
34
|
+
## Subcommands
|
|
35
|
+
|
|
36
|
+
The slash command form mirrors the CLI: `/swarm <sub> [args]`. The CLI floor is `momentum swarm <sub> [args]` — pick whichever door fits the moment. Both produce the same on-disk artifacts.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### `/swarm start <slug> --initiative <slug> --repos r1,r2,... --phase <phase-slug> [--mode checkpoint|autopilot]`
|
|
41
|
+
|
|
42
|
+
Plan + spawn Wave 1.
|
|
43
|
+
|
|
44
|
+
**Step 1 — Present the plan and ask for approval.**
|
|
45
|
+
|
|
46
|
+
Compute the wave plan in-process (no spawn yet) by calling the CLI floor in dry-run:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
momentum swarm start <slug> --initiative <slug> --repos r1,r2,... --phase <phase-slug> --mode <mode> --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Read the JSON. Render the wave plan to the user:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
▸ Swarm <NNNN-slug> — planned (not yet spawning)
|
|
56
|
+
Initiative: <slug>
|
|
57
|
+
Mode: <mode>
|
|
58
|
+
Waves:
|
|
59
|
+
Wave 1: <r1>, <r2>
|
|
60
|
+
Wave 2: <r3>
|
|
61
|
+
Wave 3: <r4>
|
|
62
|
+
Token budget: 300k per supervisor (override with /swarm budget)
|
|
63
|
+
Lease: 24h per repo, renewed each turn
|
|
64
|
+
|
|
65
|
+
Proceed?
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
WAIT for user approval. If `mode = autopilot`, plan approval is the only checkpoint until completion. If `mode = checkpoint`, you'll also pause between waves.
|
|
69
|
+
|
|
70
|
+
**Step 2 — Spawn Wave 1 supervisors via the Codex adapter.**
|
|
71
|
+
|
|
72
|
+
After approval, run:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
momentum swarm start <slug> --initiative <slug> --repos ... --phase <phase-slug> --mode <mode> --spawn
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`bin/swarm.js` dispatches each directive through `adapters/codex/adapter.js::spawn()`, which shells `codex --cwd <repoPath>` with the supervisor TOML as the subagent declaration. If `codex` is not on PATH, the CLI surfaces the spawn directives and exits non-zero — degrade by reporting the directives to the user (they can launch sessions manually) and continue with conductor polling on the existing manifest.
|
|
79
|
+
|
|
80
|
+
**Step 3 — Begin the conductor poll loop.**
|
|
81
|
+
|
|
82
|
+
See `/swarm status` (next subcommand). On every conductor turn:
|
|
83
|
+
|
|
84
|
+
1. Read `<eco>/swarms/<id>/board.json` (≈3KB).
|
|
85
|
+
2. Read `<eco>/swarms/<id>/inbox/INDEX.md`.
|
|
86
|
+
3. If `inbox_count > 0`, surface each pending item; resolve interactively.
|
|
87
|
+
4. If a supervisor reports `done: true` for the active wave's last repo, run the wave checkpoint flow (`/swarm verify`).
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### `/swarm status <swarm-id>`
|
|
92
|
+
|
|
93
|
+
Render the materialized board cache. Read-only — no manifest mutation. Strategy A from the indexing design: conductor reads ONLY `board.json` (~3KB).
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
momentum swarm status <swarm-id>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Default output is a rendered ANSI table. Pass `--json` for machine-readable.
|
|
100
|
+
|
|
101
|
+
Surface:
|
|
102
|
+
- Per-repo: wave, status, tasks N/M, tokens used/budget, commits, current task.
|
|
103
|
+
- `inbox_count` warning at the bottom if > 0.
|
|
104
|
+
- Recent activity tail (last 10 audit events).
|
|
105
|
+
|
|
106
|
+
When inboxes are pending, prompt: "Run `/swarm verify <id>` to surface the questions, or `/swarm tell <id> <repo> '...'` to push context to a specific supervisor."
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### `/swarm tell <swarm-id> <repo> "<text>"`
|
|
111
|
+
|
|
112
|
+
Push a one-shot context note to a specific supervisor. The text lands at `specs/phases/<phase-slug>/swarm-context.md` inside the target repo — supervisors read this file at the top of every turn.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
momentum swarm tell <swarm-id> <repo> "<text>"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Use when one supervisor needs context the others don't (e.g., "the auth contract was just updated to v3 — your contract.json target should bump to match"). For cross-cutting context, use `/swarm broadcast`.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### `/swarm broadcast <swarm-id> "<text>"`
|
|
123
|
+
|
|
124
|
+
Push context to every supervisor in the swarm. Appends `## broadcast @ <ts>` blocks to each repo's `swarm-context.md`.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
momentum swarm broadcast <swarm-id> "<text>"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Use sparingly — broadcast costs each supervisor a context-fetch turn. Prefer `/swarm tell` for repo-specific notes.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### `/swarm verify <swarm-id>`
|
|
135
|
+
|
|
136
|
+
Run the contract verifier + manifest+brief drift check. Read-only. Exits non-zero if any drift surfaces; meant as the pre-/swarm-complete gate.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
momentum swarm verify <swarm-id>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Checks:
|
|
143
|
+
- Manifest schema validates.
|
|
144
|
+
- Initiative back-reference exists at `<eco>/initiatives/`.
|
|
145
|
+
- Every supervisor brief carries the matching swarm frontmatter (swarm, wave, initiative).
|
|
146
|
+
- Every `contracts/*.contract.json` has surface/owner/consumers/version/content_hash.
|
|
147
|
+
|
|
148
|
+
Pending inbox items are advisory, not failures.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### `/swarm complete <swarm-id>`
|
|
153
|
+
|
|
154
|
+
Synthesize the cross-repo changeset and finalize the swarm. Writes `<eco>/changes/<swarm-id>.md` summarizing per-repo contributions (wave, branch, phase slug, tasks done, commits). Flips manifest status to `complete` once every repo reports complete; otherwise leaves the manifest status as-is and reports partial completion.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
momentum swarm complete <swarm-id>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Run AFTER `/swarm verify` shows OK.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### `/swarm resume <swarm-id> [--session <id>]`
|
|
165
|
+
|
|
166
|
+
Re-attach the current session to an existing swarm — reconstitutes the conductor state from `<eco>/swarms/<id>/manifest.json` + `board.json` and renews any leases the session owns.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
momentum swarm resume <swarm-id> [--session <id>]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Use when:
|
|
173
|
+
- The conductor session was killed mid-swarm.
|
|
174
|
+
- A user wants to take over a swarm from a previous session (combine with `/swarm join` for explicit handoff).
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### `/swarm cancel <swarm-id> [--reason "<text>"]`
|
|
179
|
+
|
|
180
|
+
Graceful halt. Halts every supervisor, marks the swarm `cancelled` in the manifest, preserves all artifacts for forensics.
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
momentum swarm cancel <swarm-id> --reason "<text>"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Confirm with the user before running.** Cancel is reversible only via `/swarm resume` re-attaching to a frozen state — you cannot un-cancel a wave that was mid-flight if commits have been pushed and force-overwrites would be needed.
|
|
187
|
+
|
|
188
|
+
After cancel:
|
|
189
|
+
1. All queued/running/blocked repos move to `cancelled`.
|
|
190
|
+
2. All queued/running waves move to `cancelled`.
|
|
191
|
+
3. Branches remain — supervisors do NOT force-push or delete.
|
|
192
|
+
4. Audit log gains a `cancel` entry with the reason.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### `/swarm budget <swarm-id> <repo> +N | -N`
|
|
197
|
+
|
|
198
|
+
Adjust the per-repo token budget. Tokens are advisory — the conductor reports a `budget` audit entry and the supervisor uses the budget to scope subsequent turns.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
momentum swarm budget <swarm-id> <repo> +100000
|
|
202
|
+
momentum swarm budget <swarm-id> <repo> -50000
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
### `/swarm claim <swarm-id> <repo> [--session <id>] [--lease-hours 24]`
|
|
208
|
+
|
|
209
|
+
> Phase 17.5 / v0.20.2 — multi-session ownership primitive.
|
|
210
|
+
|
|
211
|
+
Claim ownership of `<repo>` inside `<swarm-id>` for the current session. The conductor library uses this whenever a session needs authority to write to a repo's manifest entry — `/swarm focus`, `/swarm join`, and a co-conductor taking a wave all compose `claim` under the hood.
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
momentum swarm claim <swarm-id> <repo> [--session <id>] [--lease-hours 24]
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Claim succeeds when:
|
|
218
|
+
- the repo is `_unclaimed` or `_focusing` (sentinel — anyone may claim), OR
|
|
219
|
+
- the current owner's `lease_expires_at` is in the past (takeover; audit logs both `claim` and `lease-takeover`).
|
|
220
|
+
|
|
221
|
+
Claim is rejected when the current owner's lease is still valid; the CLI writes a `claim-request` signal so the existing owner sees the request on their next conductor poll. Exit code 1 on rejection.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
### `/swarm release <swarm-id> <repo> [--session <id>]`
|
|
226
|
+
|
|
227
|
+
> Phase 17.5 / v0.20.2 — multi-session ownership primitive.
|
|
228
|
+
|
|
229
|
+
Release the current session's ownership of `<repo>`. Sets `owner = _unclaimed`, clears the lease, and audit-logs `release`. Idempotent — releasing an already-unclaimed repo is a no-op.
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
momentum swarm release <swarm-id> <repo> [--session <id>]
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Only the current owner may release.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### `/swarm focus <swarm-id> <repo> [--session <id>] [--expires-min 60]`
|
|
240
|
+
|
|
241
|
+
> Phase 17.5 / v0.20.2 — split one repo off the swarm into a side-session.
|
|
242
|
+
|
|
243
|
+
Issue a single-use focus token for `<repo>` and hand control to a second Codex session. Use when one repo needs sustained one-on-one attention without halting the rest of the swarm.
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
momentum swarm focus <swarm-id> <repo> [--session <id>] [--expires-min 60]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Behavior:
|
|
250
|
+
1. Asserts the caller currently owns `<repo>` (rejected with exit 1 if not).
|
|
251
|
+
2. Issues an opaque focus token at `<eco>/swarms/<id>/tokens/<token>.json` (single-use, 1-hour default expiry).
|
|
252
|
+
3. Flips `repos[<repo>].owner` to the `_focusing` sentinel — anyone with the token may claim.
|
|
253
|
+
4. Writes a `focus-request` signal carrying the token + repo.
|
|
254
|
+
5. Audit-logs `focus`.
|
|
255
|
+
6. Prints a spawn directive — run a second `codex --cwd <eco>` session in a separate terminal, then inside that session call `momentum swarm join <swarm-id> --token <token>`.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### `/swarm join <swarm-id> [--token <token>] [--claim <repo>] [--session <id>]`
|
|
260
|
+
|
|
261
|
+
> Phase 17.5 / v0.20.2 — register a session with an existing swarm.
|
|
262
|
+
|
|
263
|
+
Attach the current Codex session to `<swarm-id>` as a co-conductor. Adds the session to `sessions[]` (idempotent — touch on re-join), auto-renews any repos the session already owns, and optionally consumes a transfer token or claims a specific repo.
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
momentum swarm join <swarm-id> [--token <token>] [--claim <repo>] [--session <id>]
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Three shapes:
|
|
270
|
+
|
|
271
|
+
| Form | Result |
|
|
272
|
+
|---|---|
|
|
273
|
+
| `join <id>` | Registration only. Adds the session; renews any owned leases. |
|
|
274
|
+
| `join <id> --token <token>` | Consumes the token. If `kind=focus`, claims the token's `target_repo` automatically. |
|
|
275
|
+
| `join <id> --claim <repo>` | Explicit claim — bound by the same lease rules as `/swarm claim`. |
|
|
276
|
+
|
|
277
|
+
Exit codes: 0 on success, 1 if the swarm doesn't exist, the token is missing/expired, or the claim is rejected.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
### `/swarm absorb <target-swarm-id> <source-swarm-id> [--yes] [--session <id>]`
|
|
282
|
+
|
|
283
|
+
> Phase 17.5 / v0.20.2 — converge two swarms back into one.
|
|
284
|
+
|
|
285
|
+
Merge `<source-swarm-id>` into `<target-swarm-id>` (the caller's swarm). Use to reunite after a `/swarm focus` split, or to absorb work from a peer swarm that's now done.
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
momentum swarm absorb <target-swarm-id> <source-swarm-id> [--yes] [--session <id>]
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Behavior:
|
|
292
|
+
1. Loads both manifests. If either is missing → exit 1.
|
|
293
|
+
2. Detects contract conflicts: for every shared `surface` in both swarms' `contracts`, the `owner` must match and the `content_hash` must match. Mismatches abort cleanly — both swarms left untouched.
|
|
294
|
+
3. Without `--yes`, prints a dry-run plan. Re-run with `--yes` to proceed.
|
|
295
|
+
4. On commit: union of repos (target wins on overlap); waves recomputed; sessions[] union; contracts union; audit[] concat+sort; inbox merge.
|
|
296
|
+
5. Archives the source swarm directory to `<eco>/swarms/.absorbed/<source-id>/`.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
### `/swarm inbox list|write|resolve <swarm-id> …`
|
|
301
|
+
|
|
302
|
+
Supervisor → conductor questions. Supervisors write inbox items; the conductor resolves them on its turn.
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
momentum swarm inbox list <swarm-id>
|
|
306
|
+
momentum swarm inbox write <swarm-id> --repo <r> --slug <s> --question "<text>"
|
|
307
|
+
momentum swarm inbox resolve <swarm-id> <id> --answer "<text>"
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
### `/swarm preview-merge <swarm-id>`
|
|
313
|
+
|
|
314
|
+
Dry-run `git merge --no-commit --no-ff` for every supervisor branch against `main`. Always aborts; useful before approving a fan-in.
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
momentum swarm preview-merge <swarm-id>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Tracking contract
|
|
323
|
+
|
|
324
|
+
- **Auto every time:** `manifest.json` writes via the conductor library; `board.json` regenerated on each write.
|
|
325
|
+
- **Auto only when meaningful:** `[SWARM]` entry in each supervisor's repo `history.md` after wave completion; `[NOTE]` in the originating session log on wave transitions.
|
|
326
|
+
- **Never:** silent overwrites of supervisor branches. Cancel preserves; resume reconstitutes.
|
|
327
|
+
|
|
328
|
+
## Errors
|
|
329
|
+
|
|
330
|
+
- Ecosystem root not found → suggest `--ecosystem <path>` or running from inside an ecosystem.
|
|
331
|
+
- Repo arg not a member → list valid members and abort.
|
|
332
|
+
- Initiative does not exist → suggest `momentum ecosystem initiative create <slug>` and abort.
|
|
333
|
+
- `codex` CLI not on PATH → degrade to dry-run + manual spawn instructions.
|
|
334
|
+
- MCP cwd shim not configured → supervisors see the conductor's cwd. See AGENTS.md → `## MCP cwd shim — Codex configuration` for setup.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "apply_patch|Bash",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash scripts/brainstorm-gate.sh"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PostToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "apply_patch|Bash",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "bash scripts/check-history-reminder.sh"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"SessionStart": [
|
|
26
|
+
{
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "bash scripts/sessionstart-handoff.sh"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|