@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,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Multi-perspective code review of pending changes on the current branch. Spawns three momentum reviewer skills in parallel — security, QA, architecture — and consolidates findings into a single Critical/Important/Minor report. Use before completing a phase or opening a PR.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# review-code
|
|
6
|
+
|
|
7
|
+
### 1. Determine review scope
|
|
8
|
+
|
|
9
|
+
Default: the diff between the current branch and `main`. Run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git diff main...HEAD --stat
|
|
13
|
+
git diff main...HEAD
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
User arguments override the default:
|
|
17
|
+
- `staged` → `git diff --cached`
|
|
18
|
+
- `working` → `git diff` (unstaged)
|
|
19
|
+
- `<commit-sha>` → `git diff <commit-sha>...HEAD`
|
|
20
|
+
- `<file-path>` → restrict to that path within default scope
|
|
21
|
+
|
|
22
|
+
If no diff exists, report "no changes to review" and stop.
|
|
23
|
+
|
|
24
|
+
### 2. Read project rules
|
|
25
|
+
|
|
26
|
+
Before dispatching reviewers, read:
|
|
27
|
+
- `AGENTS.md` (primary instructions)
|
|
28
|
+
- `specs/status.md` (current phase context)
|
|
29
|
+
|
|
30
|
+
This ensures each reviewer scores the diff against THIS project's rules, not generic best practices alone.
|
|
31
|
+
|
|
32
|
+
### 3. Dispatch three reviewer skills in parallel
|
|
33
|
+
|
|
34
|
+
Use Antigravity's native parallel subagent fan-out to spawn three reviewer subagents IN A SINGLE TURN, each loaded with one of the momentum reviewer skills installed at `.agents/skills/`:
|
|
35
|
+
|
|
36
|
+
- `momentum-reviewer-security` (OWASP/STRIDE lens)
|
|
37
|
+
- `momentum-reviewer-qa` (test coverage / edge cases / regressions)
|
|
38
|
+
- `momentum-reviewer-architecture` (rule compliance / pattern consistency)
|
|
39
|
+
|
|
40
|
+
Each subagent gets the diff + relevant project rules excerpt as input.
|
|
41
|
+
|
|
42
|
+
### 4. Consolidate findings
|
|
43
|
+
|
|
44
|
+
When all three return, merge findings into one report ordered:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
## Code Review
|
|
48
|
+
|
|
49
|
+
### Critical (N)
|
|
50
|
+
- [security] <finding> (file:line)
|
|
51
|
+
- [arch] <finding> (file:line)
|
|
52
|
+
|
|
53
|
+
### Important (N)
|
|
54
|
+
- [qa] <finding> (file:line)
|
|
55
|
+
|
|
56
|
+
### Minor (N)
|
|
57
|
+
- [arch] <finding> (file:line)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Tag each finding with reviewer (`[security]`, `[qa]`, `[arch]`). De-duplicate findings raised by multiple reviewers; tag with all sources (`[security][arch]`). Surface conflicts (Critical vs Minor from different reviewers) and note the disagreement.
|
|
61
|
+
|
|
62
|
+
### 5. Surface to user via the task.md artifact
|
|
63
|
+
|
|
64
|
+
Update the active `task.md` artifact with each Critical and Important finding as a task entry. Then ask:
|
|
65
|
+
|
|
66
|
+
> "Which findings should I act on now? Options:
|
|
67
|
+
> 1. All Critical
|
|
68
|
+
> 2. All Critical + Important
|
|
69
|
+
> 3. Specific items (list IDs)
|
|
70
|
+
> 4. None — log all to backlog only
|
|
71
|
+
> 5. Cancel"
|
|
72
|
+
|
|
73
|
+
### 6. Act + verify
|
|
74
|
+
|
|
75
|
+
For findings the user acts on: implement each as a separate commit. For deferred findings: file each via `/track` at appropriate priority (Critical → P0/P1, Important → P1/P2, Minor → P2/P3).
|
|
76
|
+
|
|
77
|
+
After fixes, per Rule 12 (Verify Before Claim): run the relevant verification command (test, lint, typecheck) BEFORE marking done. Append the verification evidence to the active `walkthrough.md` artifact.
|
|
78
|
+
|
|
79
|
+
## Constraints
|
|
80
|
+
|
|
81
|
+
- Reviewer skills are READ-ONLY — they cannot modify the codebase.
|
|
82
|
+
- Dispatch all three reviewers in ONE turn using parallel fan-out — do not sequence them.
|
|
83
|
+
- The review NEVER auto-fixes findings. The user always decides what to act on.
|
|
84
|
+
- If a reviewer's output is malformed (missing severity headers), re-dispatch THAT single reviewer with a stricter format reminder. Do not silently reformat.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Read-only context fetch from one ecosystem member repo. Returns a structured summary, writes a scout artifact to .momentum/runs/. Use when you need to understand another repo's state before planning cross-repo work.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# scout
|
|
6
|
+
|
|
7
|
+
### 1. Resolve target
|
|
8
|
+
|
|
9
|
+
Identify the ecosystem member to scout from the user's input (member id or path). Look up `ecosystem.json` to confirm the member exists. If the user did not specify a target, ask for one and stop until they answer.
|
|
10
|
+
|
|
11
|
+
### 2. Read the target's status
|
|
12
|
+
|
|
13
|
+
From the target repo, read these in order (skip silently if any is missing):
|
|
14
|
+
|
|
15
|
+
1. `specs/status.md`
|
|
16
|
+
2. `specs/backlog/backlog.md` (just the open P0/P1 lines)
|
|
17
|
+
3. `specs/phases/<active-phase>/tasks.md` (just the in-flight rows)
|
|
18
|
+
4. `AGENTS.md` (only if the user asked about rules)
|
|
19
|
+
|
|
20
|
+
### 3. Synthesize the scout result
|
|
21
|
+
|
|
22
|
+
Produce a structured summary with these sections in this order:
|
|
23
|
+
|
|
24
|
+
- **Repo**: <member id>
|
|
25
|
+
- **Active phase**: <phase name> + status
|
|
26
|
+
- **Blockers / P0s**: bullet list or "(none)"
|
|
27
|
+
- **Recent decisions**: top 3 history entries by recency
|
|
28
|
+
- **Relevance to current task**: 1–2 sentences explaining how the scouted state affects what we're trying to do
|
|
29
|
+
|
|
30
|
+
### 4. Write the scout artifact
|
|
31
|
+
|
|
32
|
+
Append a scout entry to `.momentum/runs/scout-<NNN>.md` with the same structured summary so the result is durable across sessions.
|
|
33
|
+
|
|
34
|
+
### 5. Return to user
|
|
35
|
+
|
|
36
|
+
Present the synthesis as the response. Do not propose follow-up work — scout is read-only. If follow-up is needed, the user invokes `/handoff` or `/dispatch` next.
|
|
37
|
+
|
|
38
|
+
## Constraints
|
|
39
|
+
|
|
40
|
+
- READ-ONLY. Do not modify any files in the target repo.
|
|
41
|
+
- Do not invoke other slash commands as a side effect.
|
|
42
|
+
- Stay under ~500 tokens in the response unless the user asks for a deeper read.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Sustained parallel multi-project feature delivery. Spawns one supervisor agent per impacted repo via Antigravity's Agent Manager, each pinned to that repo's cwd. The user's session becomes the conductor. Use for cross-repo features with dependency ordering.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# swarm
|
|
6
|
+
|
|
7
|
+
> Phase 18 / v0.20.4 — Antigravity parity of the Phase 17 + 17.5 swarm
|
|
8
|
+
> surface that originally shipped Claude Code only. All 13 subcommands
|
|
9
|
+
> work through the Antigravity `adapter.spawn(directive)` dispatch
|
|
10
|
+
> (`adapters/antigravity/adapter.js`), which shells `agy` via the Agent
|
|
11
|
+
> Manager primitive.
|
|
12
|
+
|
|
13
|
+
A **swarm** is a declared cross-repo work unit driven from ONE user session. Your session becomes the **conductor**. The conductor spawns one **supervisor** Antigravity session per impacted repo via the Agent Manager, each pinned to that repo's working directory. Each supervisor BECOMES the `swarm-supervisor` skill (loaded from `.agents/skills/swarm-supervisor/SKILL.md`) and runs momentum's normal `/start-phase` → implement → `/sync-docs` → `/complete-phase` loop INSIDE its repo.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
## When to use
|
|
18
|
+
|
|
19
|
+
- A feature spans **two or more momentum-installed repos** AND has dependency ordering (frontend depends on backend depends on shared-types).
|
|
20
|
+
- The user wants ONE session driving the whole feature, not three serial sessions.
|
|
21
|
+
- An initiative exists or is about to exist at `<eco>/initiatives/<slug>.md`.
|
|
22
|
+
|
|
23
|
+
Do NOT use `/swarm` for:
|
|
24
|
+
- Read-only cross-repo audits — use `/dispatch`.
|
|
25
|
+
- Single-repo phases — use `/start-phase` directly.
|
|
26
|
+
- Pure context transfer — use `/handoff`.
|
|
27
|
+
|
|
28
|
+
## Antigravity specifics
|
|
29
|
+
|
|
30
|
+
- **Supervisor skill**: `.agents/skills/swarm-supervisor/SKILL.md`. Each supervisor BECOMES this skill on spawn.
|
|
31
|
+
- **Spawn dispatch**: the CLI floor (`momentum swarm start --spawn …`) dispatches each spawn directive through `adapters/antigravity/adapter.js::spawn()`. The adapter shells `agy` with the supervisor skill as the persona and the directive's `repoPath` as the cwd, exploiting Antigravity's native `parallelSubagents: true` capability.
|
|
32
|
+
- **Hook integration**: `.agents/hooks.json` PreToolUse matchers (`run_command|view_file|.*write.*|apply_patch`) 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
|
+
### 1. `/swarm start <slug> --initiative <slug> --repos r1,r2,... --phase <phase-slug> [--mode checkpoint|autopilot]`
|
|
39
|
+
|
|
40
|
+
Plan + spawn Wave 1.
|
|
41
|
+
|
|
42
|
+
Compute the wave plan in-process (no spawn yet) by calling the CLI floor in dry-run:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
momentum swarm start <slug> --initiative <slug> --repos r1,r2,... --phase <phase-slug> --mode <mode> --json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Read the JSON. Render the wave plan to the user and WAIT for approval. After approval, run with `--spawn`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
momentum swarm start <slug> --initiative <slug> --repos ... --phase <phase-slug> --mode <mode> --spawn
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`bin/swarm.js` dispatches each directive through `adapters/antigravity/adapter.js::spawn()`, which shells `agy` with the supervisor skill loaded and the repo path as cwd. If `agy` 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.
|
|
55
|
+
|
|
56
|
+
### 2. `/swarm status <swarm-id>`
|
|
57
|
+
|
|
58
|
+
Render the materialized board cache. Read-only — no manifest mutation. Conductor reads ONLY `board.json` (~3KB).
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
momentum swarm status <swarm-id>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Default output is a rendered ANSI table. Pass `--json` for machine-readable.
|
|
65
|
+
|
|
66
|
+
### 3. `/swarm tell <swarm-id> <repo> "<text>"`
|
|
67
|
+
|
|
68
|
+
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.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
momentum swarm tell <swarm-id> <repo> "<text>"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 4. `/swarm broadcast <swarm-id> "<text>"`
|
|
75
|
+
|
|
76
|
+
Push context to every supervisor in the swarm.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
momentum swarm broadcast <swarm-id> "<text>"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Use sparingly — broadcast costs each supervisor a context-fetch turn.
|
|
83
|
+
|
|
84
|
+
### 5. `/swarm verify <swarm-id>`
|
|
85
|
+
|
|
86
|
+
Run the contract verifier + manifest+brief drift check. Read-only. Exits non-zero if any drift surfaces.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
momentum swarm verify <swarm-id>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 6. `/swarm complete <swarm-id>`
|
|
93
|
+
|
|
94
|
+
Synthesize the cross-repo changeset and finalize the swarm.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
momentum swarm complete <swarm-id>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 7. `/swarm resume <swarm-id> [--session <id>]`
|
|
101
|
+
|
|
102
|
+
Re-attach the current session to an existing swarm; renews leases this session owns.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
momentum swarm resume <swarm-id> [--session <id>]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 8. `/swarm cancel <swarm-id> [--reason "<text>"]`
|
|
109
|
+
|
|
110
|
+
Graceful halt. Halts every supervisor, marks the swarm `cancelled` in the manifest, preserves all artifacts for forensics. **Confirm with the user before running.**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
momentum swarm cancel <swarm-id> --reason "<text>"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 9. `/swarm budget <swarm-id> <repo> +N | -N`
|
|
117
|
+
|
|
118
|
+
Adjust the per-repo token budget.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
momentum swarm budget <swarm-id> <repo> +100000
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 10. `/swarm claim <swarm-id> <repo> [--session <id>] [--lease-hours 24]`
|
|
125
|
+
|
|
126
|
+
> Phase 17.5 / v0.20.2 — multi-session ownership primitive.
|
|
127
|
+
|
|
128
|
+
Claim ownership of `<repo>` inside `<swarm-id>` for the current session.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
momentum swarm claim <swarm-id> <repo> [--session <id>] [--lease-hours 24]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 11. `/swarm release <swarm-id> <repo> [--session <id>]`
|
|
135
|
+
|
|
136
|
+
> Phase 17.5 / v0.20.2 — multi-session ownership primitive.
|
|
137
|
+
|
|
138
|
+
Release the current session's ownership of `<repo>`. Idempotent.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
momentum swarm release <swarm-id> <repo> [--session <id>]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 12. `/swarm focus <swarm-id> <repo> [--session <id>] [--expires-min 60]`
|
|
145
|
+
|
|
146
|
+
> Phase 17.5 / v0.20.2 — split one repo off the swarm into a side-session.
|
|
147
|
+
|
|
148
|
+
Issue a single-use focus token and hand control to a second Antigravity session.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
momentum swarm focus <swarm-id> <repo> [--session <id>] [--expires-min 60]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 13. `/swarm join <swarm-id> [--token <token>] [--claim <repo>] [--session <id>]`
|
|
155
|
+
|
|
156
|
+
> Phase 17.5 / v0.20.2 — register a session with an existing swarm.
|
|
157
|
+
|
|
158
|
+
Attach the current Antigravity session to `<swarm-id>` as a co-conductor.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
momentum swarm join <swarm-id> [--token <token>] [--claim <repo>] [--session <id>]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 14. `/swarm absorb <target-swarm-id> <source-swarm-id> [--yes] [--session <id>]`
|
|
165
|
+
|
|
166
|
+
> Phase 17.5 / v0.20.2 — converge two swarms back into one.
|
|
167
|
+
|
|
168
|
+
Merge `<source-swarm-id>` into `<target-swarm-id>`.
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
momentum swarm absorb <target-swarm-id> <source-swarm-id> [--yes] [--session <id>]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 15. `/swarm inbox list|write|resolve <swarm-id> …`
|
|
175
|
+
|
|
176
|
+
Supervisor → conductor questions.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
momentum swarm inbox list <swarm-id>
|
|
180
|
+
momentum swarm inbox write <swarm-id> --repo <r> --slug <s> --question "<text>"
|
|
181
|
+
momentum swarm inbox resolve <swarm-id> <id> --answer "<text>"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 16. `/swarm preview-merge <swarm-id>`
|
|
185
|
+
|
|
186
|
+
Dry-run `git merge --no-commit --no-ff` for every supervisor branch against `main`. Always aborts.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
momentum swarm preview-merge <swarm-id>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Tracking contract
|
|
193
|
+
|
|
194
|
+
- **Auto every time:** `manifest.json` writes via the conductor library; `board.json` regenerated on each write.
|
|
195
|
+
- **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.
|
|
196
|
+
- **Native artifacts**: keep `task.md` synced with `tasks.md` and `implementation_plan.md` with `plan.md` — same pattern as standalone phase work.
|
|
197
|
+
|
|
198
|
+
## Errors
|
|
199
|
+
|
|
200
|
+
- Ecosystem root not found → suggest `--ecosystem <path>` or running from inside an ecosystem.
|
|
201
|
+
- Repo arg not a member → list valid members and abort.
|
|
202
|
+
- Initiative does not exist → suggest `momentum ecosystem initiative create <slug>` and abort.
|
|
203
|
+
- `agy` CLI not on PATH → degrade to dry-run + manual spawn instructions.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Claude Code adapter for momentum.
|
|
4
|
+
//
|
|
5
|
+
// Two responsibilities:
|
|
6
|
+
//
|
|
7
|
+
// 1. Declare destinations — where overlay subdirs (commands, agent-rules,
|
|
8
|
+
// scripts) land in the target project. The CLI uses these for both core
|
|
9
|
+
// copies AND any adapter overlay files placed at:
|
|
10
|
+
// adapters/claude-code/commands/ → .claude/commands/
|
|
11
|
+
// adapters/claude-code/agent-rules/ → .agent/rules/
|
|
12
|
+
// adapters/claude-code/scripts/ → scripts/
|
|
13
|
+
//
|
|
14
|
+
// 2. runInstall / runUpgrade — anything that isn't a plain file copy
|
|
15
|
+
// (currently: wiring `.claude/settings.json` for hooks).
|
|
16
|
+
//
|
|
17
|
+
// Overlay contract (Phase 6 / FEAT-012): a given filename lives in EITHER
|
|
18
|
+
// `core/<sub>/` OR `adapters/claude-code/<sub>/`, never both. The CLI errors
|
|
19
|
+
// before any writes if a duplicate is detected.
|
|
20
|
+
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const { spawnSync } = require('child_process');
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
displayName: 'Claude Code',
|
|
27
|
+
|
|
28
|
+
destinations: {
|
|
29
|
+
commands: ['.claude', 'commands'],
|
|
30
|
+
'agent-rules': ['.agent', 'rules'],
|
|
31
|
+
scripts: ['scripts'],
|
|
32
|
+
engines: ['.agent', 'engines'],
|
|
33
|
+
// Phase 16 Rework: uniform contract — declared but unused on Claude
|
|
34
|
+
// Code (no overlay content shipped). Claude Code has no per-project
|
|
35
|
+
// workflows/skills/subagent file-discovery surface today; the
|
|
36
|
+
// destinations are reserved for cross-adapter contract consistency.
|
|
37
|
+
workflows: ['.claude', 'workflows'],
|
|
38
|
+
skills: ['.claude', 'skills'],
|
|
39
|
+
agents: ['.claude', 'agents'],
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
primaryInstruction: {
|
|
43
|
+
source: ['core', 'specs-templates', 'CLAUDE.md'],
|
|
44
|
+
sourceBase: 'package',
|
|
45
|
+
destination: ['CLAUDE.md'],
|
|
46
|
+
label: 'CLAUDE.md',
|
|
47
|
+
markerAware: true,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
configFiles: [
|
|
51
|
+
{
|
|
52
|
+
source: ['settings.json'],
|
|
53
|
+
destination: ['.claude', 'settings.json'],
|
|
54
|
+
label: '.claude/settings.json',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
|
|
58
|
+
capabilities: {
|
|
59
|
+
hooks: true,
|
|
60
|
+
slashCommands: true,
|
|
61
|
+
subagents: true,
|
|
62
|
+
parallelSubagents: true,
|
|
63
|
+
sessionStartHook: true,
|
|
64
|
+
skills: false,
|
|
65
|
+
browser: false,
|
|
66
|
+
computerUse: false,
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
roadmap: {},
|
|
70
|
+
|
|
71
|
+
runInstall(targetDir, adapterDir, helpers) {
|
|
72
|
+
const { copyFile, fileExists, recordManaged } = helpers;
|
|
73
|
+
|
|
74
|
+
// .claude/settings.json
|
|
75
|
+
console.log('→ Configuring Claude Code hooks...');
|
|
76
|
+
const settingsDest = path.join(targetDir, '.claude', 'settings.json');
|
|
77
|
+
// Record as adapter-managed regardless of whether we write it, so the
|
|
78
|
+
// lock file is complete and orphan cleanup never drops it (Phase 20).
|
|
79
|
+
if (recordManaged) recordManaged(settingsDest);
|
|
80
|
+
if (!fileExists(settingsDest)) {
|
|
81
|
+
copyFile(path.join(adapterDir, 'settings.json'), settingsDest);
|
|
82
|
+
} else {
|
|
83
|
+
console.log(' ⚠️ .claude/settings.json already exists.');
|
|
84
|
+
console.log(` Merge hooks manually from: ${path.join(adapterDir, 'settings.json')}`);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
runUpgrade(targetDir, adapterDir, helpers) {
|
|
89
|
+
const { copyFile, fileExists, recordManaged, dryRun } = helpers;
|
|
90
|
+
|
|
91
|
+
// .claude/settings.json
|
|
92
|
+
console.log('→ Upgrading Claude Code hooks...');
|
|
93
|
+
const src = path.join(adapterDir, 'settings.json');
|
|
94
|
+
const dest = path.join(targetDir, '.claude', 'settings.json');
|
|
95
|
+
if (recordManaged) recordManaged(dest); // managed even when identical-skip
|
|
96
|
+
|
|
97
|
+
if (fileExists(dest)) {
|
|
98
|
+
const srcContent = fs.readFileSync(src, 'utf8');
|
|
99
|
+
const destContent = fs.readFileSync(dest, 'utf8');
|
|
100
|
+
if (srcContent !== destContent) {
|
|
101
|
+
if (dryRun) {
|
|
102
|
+
console.log(' ✋ would upgrade: .claude/settings.json');
|
|
103
|
+
} else {
|
|
104
|
+
fs.copyFileSync(dest, dest + '.bak');
|
|
105
|
+
copyFile(src, dest);
|
|
106
|
+
console.log(` ↑ upgraded: .claude/settings.json (original saved as .bak)`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// identical — silent skip
|
|
110
|
+
} else {
|
|
111
|
+
copyFile(src, dest);
|
|
112
|
+
console.log(` ${dryRun ? '✋ would add: ' : '+ added: '} .claude/settings.json`);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// Phase 18 — adapter.spawn(directive) contract.
|
|
117
|
+
// Launch ONE Claude Code background session for this directive via
|
|
118
|
+
// `claude --bg --cwd <repoPath>`. Pipes the supervisor recipe + brief
|
|
119
|
+
// pointer over stdin. Returns the canonical per-repo result shape.
|
|
120
|
+
// See `bin/momentum.js` for the directive contract.
|
|
121
|
+
spawn(directive) {
|
|
122
|
+
if (!directive || directive.platform !== 'claude-code') {
|
|
123
|
+
return {
|
|
124
|
+
repoId: directive && directive.repoId,
|
|
125
|
+
status: -1,
|
|
126
|
+
detail: `non-claude-code platform: ${directive && directive.platform}`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const claudeBin = process.env.CLAUDE_CODE_BIN || 'claude';
|
|
130
|
+
const args = ['--bg', '--cwd', directive.repoPath];
|
|
131
|
+
const prompt = [
|
|
132
|
+
`You are a swarm supervisor. Recipe: ${directive.recipePath}`,
|
|
133
|
+
`Read the recipe and the brief at specs/phases/${directive.phaseSlug}/overview.md.`,
|
|
134
|
+
`Begin the boot sequence.`,
|
|
135
|
+
].join('\n');
|
|
136
|
+
const r = spawnSync(claudeBin, args, {
|
|
137
|
+
input: prompt,
|
|
138
|
+
env: Object.assign({}, process.env, directive.env),
|
|
139
|
+
encoding: 'utf8',
|
|
140
|
+
timeout: 5000,
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
repoId: directive.repoId,
|
|
144
|
+
status: r.status == null ? -1 : r.status,
|
|
145
|
+
detail: (r.error && r.error.message) || (r.stderr || '').slice(0, 200),
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Pick up a pending handoff in this repo. Reads `.momentum/inbox/handoff-NNN.md`, parses the structured context block, marks the inbox file as read, and emits a `[NOTE]` in the receiving repo's active phase history.
|
|
2
|
+
|
|
3
|
+
> **Three doors, one library.** This is the slash-command door for Claude Code. The CLI door is `momentum continue [--handoff <id>]`. The auto-greet door fires via the SessionStart hook when you open a fresh session with pending handoffs. All three call `core/orchestration/continue.js`.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- The SessionStart auto-greet hook printed a "1 pending handoff" banner and you typed `y`.
|
|
8
|
+
- You know there's a pending handoff from another repo and want to start with that context.
|
|
9
|
+
- You want to list pending handoffs and pick one explicitly.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
/continue pick up the OLDEST pending handoff
|
|
15
|
+
/continue <id> pick up handoff-<id> specifically
|
|
16
|
+
/continue list list pending handoffs without picking
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
### Step 1 — List or pick
|
|
22
|
+
|
|
23
|
+
If `list`, run:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const orchestration = require('<momentum-root>/core/orchestration');
|
|
27
|
+
const pending = orchestration.continueHandoff.listPending('<this repo>');
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Render: `▸ N pending handoff(s):` then `▸ <id> from <fromRepo>: <summary>`. Stop.
|
|
31
|
+
|
|
32
|
+
Otherwise, pick:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
const block = await orchestration.continueHandoff.continueHandoff({
|
|
36
|
+
repo: '<this repo absolute path>',
|
|
37
|
+
handoffId: '<id-if-specified>', // omit for oldest
|
|
38
|
+
ecosystem: { rootPath: '<ecosystem root>', memberId: '<this repo member id>' },
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This parses the inbox file, moves it to `.momentum/inbox/read/`, and emits a `[NOTE]` in this repo's active phase history (handoff pickup IS a meaningful event worth tracking).
|
|
43
|
+
|
|
44
|
+
### Step 2 — Act on the block
|
|
45
|
+
|
|
46
|
+
Narrate it to the user:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
▸ picking up handoff-NNN from <fromRepo>
|
|
50
|
+
|
|
51
|
+
Summary: <summary>
|
|
52
|
+
|
|
53
|
+
Decisions:
|
|
54
|
+
- <decision 1>
|
|
55
|
+
- <decision 2>
|
|
56
|
+
|
|
57
|
+
Files touched (in originating session):
|
|
58
|
+
- <file 1>
|
|
59
|
+
- <file 2>
|
|
60
|
+
|
|
61
|
+
Verification:
|
|
62
|
+
$ <command 1>
|
|
63
|
+
|
|
64
|
+
Open questions:
|
|
65
|
+
? <question 1>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Then proceed with the work the handoff describes — the user shouldn't have to re-explain anything.
|
|
69
|
+
|
|
70
|
+
### Step 3 — Don't surprise the user
|
|
71
|
+
|
|
72
|
+
If the handoff is large (>30 lines of decisions/files), summarise + offer "want me to read the full block? [y/n]" before diving in. Otherwise just proceed.
|
|
73
|
+
|
|
74
|
+
## Tracking contract
|
|
75
|
+
|
|
76
|
+
- **Auto every time:** inbox file moved to `read/` + `[NOTE]` in receiving repo's active phase history referencing the picked-up handoff.
|
|
77
|
+
|
|
78
|
+
## Errors
|
|
79
|
+
|
|
80
|
+
- No pending handoffs → "no pending handoffs in this repo" and stop. NOT an error.
|
|
81
|
+
- Specified handoff id not found → error with list of pending ids.
|
|
82
|
+
- Inbox file is malformed → error pointing at the file with a hint to inspect.
|