@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,154 @@
|
|
|
1
|
+
Parallel multi-project fan-out + synthesis. One sub-agent per listed project, each tailored to the user's intent: audit (read-only) or fix (writes allowed, on a feature branch). All results synthesised into a single answer. Writes one dispatch-NNN.md artifact and one session log line.
|
|
2
|
+
|
|
3
|
+
> **Three doors, one library.** This is the slash-command door for Claude Code. The CLI door is `momentum dispatch <r1> <r2> ... --prompt "<text>"` and the natural-language inference door fires when the user describes a multi-repo audit / alignment task. All three doors call `core/orchestration/dispatch.js` so the output shape is identical.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- "What breaks if I rename X across all repos?" — multi-project audit (sub-agents stay read-only by intent).
|
|
8
|
+
- "Get me the current state of A AND B so I can align a change." — pre-coordination context fetch (read-only by intent).
|
|
9
|
+
- "Where does Y come from across the stack?" — cross-cutting investigation (read-only by intent).
|
|
10
|
+
- "Fix the same typo in all three repos." — one-shot multi-project change (sub-agents write on feature branches; you review per repo).
|
|
11
|
+
- "Bump the lint config to v2 across the stack." — repeatable code-mod (writes allowed).
|
|
12
|
+
|
|
13
|
+
Do NOT use `/dispatch` for **sustained multi-step features that need wave ordering, contracts, or a persistent saga** — use [`/swarm`](/swarm/) instead. Do NOT use it when you want to TRANSFER control rather than fan it out — use `/handoff`. Do NOT use it for single-project tasks — use `/scout` or just work in that project directly.
|
|
14
|
+
|
|
15
|
+
## Inference guidance (read this in non-slash contexts too)
|
|
16
|
+
|
|
17
|
+
Treat ANY of these as a dispatch invocation even without an explicit `/dispatch`:
|
|
18
|
+
|
|
19
|
+
- "Audit X across repos A, B, C."
|
|
20
|
+
- "What's the state of A, B, and C right now?"
|
|
21
|
+
- "Find every place that does X across the ecosystem."
|
|
22
|
+
|
|
23
|
+
When inferring, narrate it: `▸ inferred: dispatch (multi-repo audit). Use /dispatch next time for predictable behavior.`
|
|
24
|
+
|
|
25
|
+
Do NOT use dispatch for single-repo questions — use `/scout`. Do NOT use dispatch when you want to TRANSFER control rather than just READ — use `/handoff`.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
/dispatch <repo1> <repo2> [repo3 ...] "<user intent>"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Repos are member ids from `ecosystem.json` (or relative/absolute paths).
|
|
34
|
+
|
|
35
|
+
## Steps
|
|
36
|
+
|
|
37
|
+
### Step 1 — Identify the targets + intent
|
|
38
|
+
|
|
39
|
+
Resolve each repo arg to an absolute path via the ecosystem manifest. Capture the user's high-level intent (the rest of the slash-command line).
|
|
40
|
+
|
|
41
|
+
### Step 2 — Capability-route the dispatch mode
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const orchestration = require('<momentum-root>/core/orchestration');
|
|
45
|
+
const adapter = orchestration.capabilityRouting.loadAdapter('<momentum-root>', 'claude-code');
|
|
46
|
+
const { mode, notes } = orchestration.capabilityRouting.chooseMode(adapter, 'dispatch');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Claude Code declares `parallelSubagents: true` — `mode='parallel'`, no notes. If you're on an adapter where `mode='sequential'`, narrate the note up front (`▸ <degraded-mode note>`) so the user knows what they're getting.
|
|
50
|
+
|
|
51
|
+
### Step 3 — Fan out sub-agents (parallel on Claude Code)
|
|
52
|
+
|
|
53
|
+
For EACH target repo, in a SINGLE message use the Task tool to spawn a sub-agent with:
|
|
54
|
+
|
|
55
|
+
- Sub-agent system prompt: "You are a DISPATCH SUB-AGENT for momentum's quick-verb layer. You are working in `<repo>`. The user intent below is authoritative — if it asks to audit / investigate / report, return a structured JSON result without writing files. If it asks to fix / refactor / migrate, you may write code, but commit on a feature branch per Rule 6 (Git Lifecycle) and surface the branch name in your result so the originating session can review. When in doubt about whether to write, prefer reading and surface the proposed change in `findings` instead."
|
|
56
|
+
- Sub-agent task prompt: user intent + the specific repo.
|
|
57
|
+
- If the originating session is in read-only mode (the user passed `--read-only` to the CLI floor, or the recipe was invoked with the `--read-only` flag), prepend an explicit "READ-ONLY: do not write any files" line to the sub-agent system prompt regardless of intent.
|
|
58
|
+
- Expected return shape (sub-agent renders as a single JSON block):
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"repo": "<absolute path>",
|
|
63
|
+
"summary": "...one-paragraph answer focused on this repo...",
|
|
64
|
+
"filesRead": ["..."],
|
|
65
|
+
"filesWritten": ["..."],
|
|
66
|
+
"branch": "feat/short-desc",
|
|
67
|
+
"findings": [
|
|
68
|
+
{ "kind": "discovery", "title": "...", "detail": "...", "recommendedBacklogPriority": "P2", "recommendedBacklogType": "tech-debt" }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`filesWritten` + `branch` are present only when the sub-agent actually wrote (user intent was a fix/refactor/migrate). For pure audits, omit them. `findings` apply Rule 3 thresholds.
|
|
74
|
+
|
|
75
|
+
Sub-agents run concurrently because they are dispatched in the same message — Claude Code's Task tool runs each in its own context.
|
|
76
|
+
|
|
77
|
+
### Step 4 — Wait for all sub-agents, capture failures
|
|
78
|
+
|
|
79
|
+
If any sub-agent fails or returns no result, capture the failure with `{ repo, error: { message } }` and CONTINUE. Never abort the whole dispatch on a single sub-agent failure — the synthesis still proceeds with partial results.
|
|
80
|
+
|
|
81
|
+
### Step 5 — Synthesise
|
|
82
|
+
|
|
83
|
+
Read the per-repo results IN THIS AGENT'S CONTEXT and produce a synthesis paragraph that DIRECTLY ANSWERS the user's intent. Mention any failures explicitly in the synthesis (don't let them disappear).
|
|
84
|
+
|
|
85
|
+
### Step 6 — Record the run
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
orchestration.dispatch.record({
|
|
89
|
+
repos: [/* absolute paths */],
|
|
90
|
+
userIntent: '<user intent>',
|
|
91
|
+
mode,
|
|
92
|
+
modeNotes: notes,
|
|
93
|
+
perRepoResults: [/* per-repo entries */],
|
|
94
|
+
failures: [/* entries with .error */],
|
|
95
|
+
synthesis: '<your synthesised paragraph>',
|
|
96
|
+
originatingRepo: '<this repo absolute path>',
|
|
97
|
+
ecosystem: { rootPath: '<...>', memberId: '<...>' },
|
|
98
|
+
duration: <ms>,
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This writes `.momentum/runs/dispatch-NNN.md` (synthesis + collapsible per-repo blocks + failure manifest) and appends one line to the ecosystem session log.
|
|
103
|
+
|
|
104
|
+
### Step 7 — Hand findings to the tracking contract
|
|
105
|
+
|
|
106
|
+
For each finding from each per-repo result, call:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
orchestration.tracking.proposeDiscovery({
|
|
110
|
+
primitive: 'dispatch',
|
|
111
|
+
finding,
|
|
112
|
+
targetRepo: '<repo where the finding was identified>',
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Synthesis itself gets a `[NOTE]` in the ORIGINATING repo's active phase history when it answers a meaningful coordination question; pass through:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
orchestration.tracking.proposeHistoryNote({
|
|
120
|
+
primitive: 'dispatch',
|
|
121
|
+
originatingRepo,
|
|
122
|
+
message: '<one-line summary of what dispatch surfaced>',
|
|
123
|
+
runArtifactRef: '<.momentum/runs/dispatch-NNN.md>',
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Step 8 — Render the result
|
|
128
|
+
|
|
129
|
+
Output to the user:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
▸ Synthesis
|
|
133
|
+
<synthesis paragraph>
|
|
134
|
+
|
|
135
|
+
▸ Per-repo (expand to see detail)
|
|
136
|
+
▼ <repo1>: <one-line>
|
|
137
|
+
▼ <repo2>: <one-line>
|
|
138
|
+
...
|
|
139
|
+
|
|
140
|
+
→ logged to sessions/<today>.md
|
|
141
|
+
→ trace at .momentum/runs/dispatch-NNN.md
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Tracking contract
|
|
145
|
+
|
|
146
|
+
- **Auto every time:** session log line + dispatch-NNN.md artifact.
|
|
147
|
+
- **Auto only when meaningful:** per-repo `[DISCOVERY]` in each scouted repo's active phase history; `[NOTE]` in the originating repo's active phase history when the synthesis records a meaningful cross-repo state.
|
|
148
|
+
- **Never:** `[DISPATCH]` entry types or `backlog.md` entries without explicit user confirmation.
|
|
149
|
+
|
|
150
|
+
## Errors
|
|
151
|
+
|
|
152
|
+
- A repo arg doesn't resolve → emit a warning, skip it, continue with the rest.
|
|
153
|
+
- All repo args fail to resolve → abort with error.
|
|
154
|
+
- A sub-agent throws → captured in `failures[]`, synthesis still runs.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Cross-session control transfer with a structured context block. Writes `<toRepo>/.momentum/inbox/handoff-NNN.md` so a fresh agent session in that repo can pick up where you left off, and emits a `[DECISION]` in this 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 handoff <repo> [flags]` and the natural-language inference door fires when the user describes a control-transfer task ("now continue in X"). All three doors call `core/orchestration/handoff.js`.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- You finished work in repo A and want the next session in repo B to continue with full context.
|
|
8
|
+
- You hit a stopping point that requires switching repos and want decisions preserved.
|
|
9
|
+
- DO NOT use handoff for read-only context fetches — use `/scout` for that. DO NOT use handoff for multi-repo audits — use `/dispatch`.
|
|
10
|
+
|
|
11
|
+
## Inference guidance (read this in non-slash contexts too)
|
|
12
|
+
|
|
13
|
+
Treat ANY of these as a handoff invocation:
|
|
14
|
+
|
|
15
|
+
- "Now switch to <repo> and continue."
|
|
16
|
+
- "I'm done here — pick up in <other repo>."
|
|
17
|
+
- "Hand off the rest to <repo>."
|
|
18
|
+
|
|
19
|
+
When inferring, narrate it: `▸ inferred: handoff (control transfer). Use /handoff next time for predictable behavior.`
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
/handoff <repo> [optional one-line summary]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`<repo>` is a member id from `ecosystem.json` (or a path). The slash command will infer the context block from this session — recent edits, key decisions, files touched, suggested verification commands, any open questions.
|
|
28
|
+
|
|
29
|
+
## Steps
|
|
30
|
+
|
|
31
|
+
### Step 1 — Identify the target repo + summary
|
|
32
|
+
|
|
33
|
+
Resolve `<repo>` via `ecosystem.json`. If the user provided a summary line, use it. Otherwise, generate a one-line summary that captures what work remains to be picked up.
|
|
34
|
+
|
|
35
|
+
### Step 2 — Collect the context block
|
|
36
|
+
|
|
37
|
+
Pull together (inferred from THIS session's history):
|
|
38
|
+
|
|
39
|
+
- `decisions[]` — ADRs created, technology choices made, or other significant choices.
|
|
40
|
+
- `filesTouched[]` — the files edited in this session.
|
|
41
|
+
- `verificationCommands[]` — what to run to confirm the picked-up state (tests, lints, smoke commands).
|
|
42
|
+
- `openQuestions[]` — anything the receiving agent needs to resolve.
|
|
43
|
+
|
|
44
|
+
Keep it tight — the receiving agent will read this first.
|
|
45
|
+
|
|
46
|
+
### Step 3 — Write the handoff
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
const orchestration = require('<momentum-root>/core/orchestration');
|
|
50
|
+
const block = await orchestration.handoff.handoff({
|
|
51
|
+
fromRepo: '<this repo absolute path>',
|
|
52
|
+
toRepo: '<target repo absolute path>',
|
|
53
|
+
summary: '<one-line>',
|
|
54
|
+
decisions: [...],
|
|
55
|
+
filesTouched: [...],
|
|
56
|
+
verificationCommands: [...],
|
|
57
|
+
openQuestions: [...],
|
|
58
|
+
ecosystem: { rootPath: '<ecosystem root>', memberId: '<this repo member id>' },
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This writes `<toRepo>/.momentum/inbox/handoff-NNN.md`, appends one line to the ecosystem session log, AND emits a `[DECISION]` in this repo's active phase `history.md` (handoff IS a cross-repo decision).
|
|
63
|
+
|
|
64
|
+
### Step 4 — Tell the user
|
|
65
|
+
|
|
66
|
+
Output:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
▸ handoff written: <toRepo>/.momentum/inbox/handoff-NNN.md
|
|
70
|
+
▸ logged [DECISION] in <originating phase>/history.md
|
|
71
|
+
|
|
72
|
+
Next: open a fresh session in <toRepo>. The SessionStart hook will detect
|
|
73
|
+
the handoff and prompt "Read now? [y/skip]". Or run /continue (or
|
|
74
|
+
`momentum continue`) explicitly.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Tracking contract
|
|
78
|
+
|
|
79
|
+
- **Auto every time:** session log line + `.momentum/inbox/handoff-NNN.md` in receiving repo + `[DECISION]` entry in originating active phase history.
|
|
80
|
+
- **Never:** `[HANDOFF]` entry types. Use existing `[DECISION]`.
|
|
81
|
+
|
|
82
|
+
## Errors
|
|
83
|
+
|
|
84
|
+
- Target repo doesn't exist → report and stop.
|
|
85
|
+
- Target repo is the same as the originating repo → report (handoff to self is meaningless) and stop.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Run a multi-perspective code review of the pending changes on the current branch.
|
|
2
|
+
|
|
3
|
+
> **This command is Claude-Code-specific.** It uses the Task tool to dispatch
|
|
4
|
+
> role-based subagents in parallel. Equivalent functionality for other agents
|
|
5
|
+
> would live in their respective `adapters/<agent>/commands/` overlay (e.g.,
|
|
6
|
+
> Cursor would ship a prompt-based variant). Do not generalize this into
|
|
7
|
+
> `core/commands/` — generalization would lose the parallel-subagent value.
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
- Before `/sync-docs` and `/complete-phase` at the end of a phase
|
|
12
|
+
- After a non-trivial commit on a feature branch, before opening a PR
|
|
13
|
+
- Whenever you want a fresh, independent read on what was just built
|
|
14
|
+
|
|
15
|
+
This command does NOT modify code. It produces a consolidated review and asks
|
|
16
|
+
you which findings to act on.
|
|
17
|
+
|
|
18
|
+
## Steps
|
|
19
|
+
|
|
20
|
+
### Step 1 — Determine review scope
|
|
21
|
+
|
|
22
|
+
Default scope: the diff between the current branch and `main`. Run:
|
|
23
|
+
```bash
|
|
24
|
+
git diff main...HEAD --stat
|
|
25
|
+
git diff main...HEAD
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If the user passed an argument, honor it:
|
|
29
|
+
- `staged` → `git diff --cached`
|
|
30
|
+
- `working` → `git diff` (unstaged changes)
|
|
31
|
+
- `<commit-sha>` → `git diff <commit-sha>...HEAD`
|
|
32
|
+
- `<file-path>` → restrict review to that path within the default scope
|
|
33
|
+
|
|
34
|
+
If no diff exists, report "no changes to review" and stop.
|
|
35
|
+
|
|
36
|
+
### Step 2 — Read the rules of the project
|
|
37
|
+
|
|
38
|
+
Before dispatching reviewers, read:
|
|
39
|
+
- `CLAUDE.md` (rules and constraints — the complete rulebook)
|
|
40
|
+
- `specs/status.md` (current phase context)
|
|
41
|
+
|
|
42
|
+
This ensures every reviewer scores the diff against THIS project's rules,
|
|
43
|
+
not generic best practices alone.
|
|
44
|
+
|
|
45
|
+
### Step 3 — Dispatch reviewers in parallel
|
|
46
|
+
|
|
47
|
+
Use the Task tool to spawn three subagents in **a single message with three
|
|
48
|
+
parallel tool calls** (do NOT serialize). Each subagent gets the same diff
|
|
49
|
+
and the same rules context, but a different role.
|
|
50
|
+
|
|
51
|
+
#### Reviewer A — Security (OWASP / STRIDE)
|
|
52
|
+
|
|
53
|
+
Prompt template:
|
|
54
|
+
> You are reviewing a code diff for **security only**. Use the OWASP Top 10
|
|
55
|
+
> and STRIDE threat categories as your lens.
|
|
56
|
+
>
|
|
57
|
+
> Diff:
|
|
58
|
+
> ```
|
|
59
|
+
> <paste the diff from Step 1>
|
|
60
|
+
> ```
|
|
61
|
+
>
|
|
62
|
+
> Project rules excerpt:
|
|
63
|
+
> ```
|
|
64
|
+
> <paste the relevant constraints from CLAUDE.md — especially "No secrets in code">
|
|
65
|
+
> ```
|
|
66
|
+
>
|
|
67
|
+
> Return findings in this exact format:
|
|
68
|
+
>
|
|
69
|
+
> ```
|
|
70
|
+
> ## Security review
|
|
71
|
+
>
|
|
72
|
+
> ### Critical
|
|
73
|
+
> - [finding] (file:line) — [why it's critical]
|
|
74
|
+
>
|
|
75
|
+
> ### Important
|
|
76
|
+
> - [finding] (file:line) — [explanation]
|
|
77
|
+
>
|
|
78
|
+
> ### Minor
|
|
79
|
+
> - [finding] (file:line) — [explanation]
|
|
80
|
+
> ```
|
|
81
|
+
>
|
|
82
|
+
> If no findings at a severity level, write "(none)". Do NOT speculate beyond
|
|
83
|
+
> what the diff shows. Do NOT propose code fixes — only flag the issue.
|
|
84
|
+
|
|
85
|
+
#### Reviewer B — QA (test coverage, edge cases, regressions)
|
|
86
|
+
|
|
87
|
+
Prompt template:
|
|
88
|
+
> You are reviewing a code diff for **test coverage and edge cases only**.
|
|
89
|
+
>
|
|
90
|
+
> Diff:
|
|
91
|
+
> ```
|
|
92
|
+
> <paste the diff from Step 1>
|
|
93
|
+
> ```
|
|
94
|
+
>
|
|
95
|
+
> Project rules excerpt:
|
|
96
|
+
> ```
|
|
97
|
+
> <paste Rule 12 (Verify Before Claim) from CLAUDE.md>
|
|
98
|
+
> ```
|
|
99
|
+
>
|
|
100
|
+
> For each meaningful behavior change in the diff, ask:
|
|
101
|
+
> - Is there a test that exercises it?
|
|
102
|
+
> - What edge cases are uncovered (empty input, large input, concurrent
|
|
103
|
+
> access, error paths)?
|
|
104
|
+
> - Could this break an existing test or production path?
|
|
105
|
+
>
|
|
106
|
+
> Return findings in the same Critical/Important/Minor format as the security
|
|
107
|
+
> reviewer. "(none)" when applicable.
|
|
108
|
+
|
|
109
|
+
#### Reviewer C — Architecture (rule compliance, pattern consistency)
|
|
110
|
+
|
|
111
|
+
Prompt template:
|
|
112
|
+
> You are reviewing a code diff for **architectural fit and rule compliance**.
|
|
113
|
+
>
|
|
114
|
+
> Diff:
|
|
115
|
+
> ```
|
|
116
|
+
> <paste the diff from Step 1>
|
|
117
|
+
> ```
|
|
118
|
+
>
|
|
119
|
+
> Full rules:
|
|
120
|
+
> ```
|
|
121
|
+
> <paste CLAUDE.md (rules section)>
|
|
122
|
+
> ```
|
|
123
|
+
>
|
|
124
|
+
> For each change, ask:
|
|
125
|
+
> - Does it violate any of the 12 autonomous rules?
|
|
126
|
+
> - Does it match the patterns established elsewhere in the codebase?
|
|
127
|
+
> (Check 2-3 nearby files for convention.)
|
|
128
|
+
> - Does it create a hidden coupling, a leaky abstraction, or an
|
|
129
|
+
> adapter/contract violation?
|
|
130
|
+
> - Is it documented where rules say it should be (history.md, ADR, etc.)?
|
|
131
|
+
>
|
|
132
|
+
> Return findings in the Critical/Important/Minor format. "(none)" when
|
|
133
|
+
> applicable.
|
|
134
|
+
|
|
135
|
+
### Step 4 — Consolidate
|
|
136
|
+
|
|
137
|
+
Once all three subagents return:
|
|
138
|
+
|
|
139
|
+
1. Merge findings into a single report ordered:
|
|
140
|
+
```
|
|
141
|
+
## Code Review
|
|
142
|
+
|
|
143
|
+
### Critical (N)
|
|
144
|
+
- [security] finding (file:line)
|
|
145
|
+
- [arch] finding (file:line)
|
|
146
|
+
|
|
147
|
+
### Important (N)
|
|
148
|
+
- [qa] finding (file:line)
|
|
149
|
+
- [security] finding (file:line)
|
|
150
|
+
|
|
151
|
+
### Minor (N)
|
|
152
|
+
- [arch] finding (file:line)
|
|
153
|
+
```
|
|
154
|
+
2. Tag each finding with its reviewer (`[security]`, `[qa]`, `[arch]`).
|
|
155
|
+
3. De-duplicate findings that multiple reviewers raised — combine into one
|
|
156
|
+
line and tag with all reviewers (`[security][arch]`).
|
|
157
|
+
4. If a finding is at Critical and conflicts with a Minor finding from a
|
|
158
|
+
different reviewer, surface BOTH and note the disagreement.
|
|
159
|
+
|
|
160
|
+
### Step 5 — Present to user, ask what to act on
|
|
161
|
+
|
|
162
|
+
Show the consolidated report. Then ask:
|
|
163
|
+
> "Which findings should I act on now? Options:
|
|
164
|
+
> 1. All Critical
|
|
165
|
+
> 2. All Critical + Important
|
|
166
|
+
> 3. Specific items (list IDs)
|
|
167
|
+
> 4. None — log all findings to backlog only
|
|
168
|
+
> 5. Cancel"
|
|
169
|
+
|
|
170
|
+
For findings the user wants to act on now: implement them as separate commits
|
|
171
|
+
on the current branch (each commit ≤ one finding).
|
|
172
|
+
|
|
173
|
+
For findings the user wants to defer: add each as a backlog item via the
|
|
174
|
+
`/track` flow with appropriate priority (Critical → P0/P1, Important → P1/P2,
|
|
175
|
+
Minor → P2/P3).
|
|
176
|
+
|
|
177
|
+
### Step 6 — Honor Rule 12 on any fixes
|
|
178
|
+
|
|
179
|
+
If you implement any fix in Step 5, run the relevant verification (test,
|
|
180
|
+
lint, typecheck) BEFORE marking it done — per Rule 12 (Verify Before Claim).
|
|
181
|
+
|
|
182
|
+
## Constraints
|
|
183
|
+
|
|
184
|
+
- Subagents are **read-only**: they MUST NOT edit files, run code-modifying
|
|
185
|
+
commands, or commit. They return findings as text only.
|
|
186
|
+
- Dispatch all three subagents in a **single message with parallel tool
|
|
187
|
+
calls** — do not sequence them.
|
|
188
|
+
- The review NEVER auto-fixes findings. The user always decides what to act
|
|
189
|
+
on (Step 5).
|
|
190
|
+
- Findings tied to specific lines should include `file:line` so the user can
|
|
191
|
+
navigate quickly.
|
|
192
|
+
- If a reviewer's output is malformed (missing severity headers), re-dispatch
|
|
193
|
+
that single reviewer with a stricter format reminder. Do not silently
|
|
194
|
+
reformat — that hides reviewer mistakes.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Read-only context fetch from one ecosystem member repo. Returns a structured summary, writes a scout-NNN.md run artifact, and appends one line to the ecosystem session log.
|
|
2
|
+
|
|
3
|
+
> **Three doors, one library.** This is the slash-command door for Claude Code. The CLI door is `momentum scout <repo> "<prompt>"` and the natural-language inference door fires when the user describes a single-repo, read-only context-fetch task without naming a primitive (see "Inference guidance" below). All three doors call `core/orchestration/scout.js` so the output shape is identical.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- You're about to make a change in this repo but you need to know the current state of a related repo first (auth shape, API contract, schema, recent decisions).
|
|
8
|
+
- A user asks "what's the situation in `<repo>`?" — that's scout.
|
|
9
|
+
- You want a durable record of a context-fetch you just did, not just a chat message.
|
|
10
|
+
|
|
11
|
+
## Inference guidance (read this in non-slash contexts too)
|
|
12
|
+
|
|
13
|
+
Treat ANY of these as a scout invocation even without an explicit `/scout`:
|
|
14
|
+
|
|
15
|
+
- "What's the current X in repo Y?"
|
|
16
|
+
- "Before I make the change here, get me the latest state from `<sibling repo>`."
|
|
17
|
+
- "Read repo Y and tell me about its current Z."
|
|
18
|
+
|
|
19
|
+
When inferring, narrate it: `▸ inferred: scout (single repo, read-only). Use /scout next time for predictable behavior.`
|
|
20
|
+
|
|
21
|
+
Do NOT use scout for multi-repo questions — use `/dispatch`. Do NOT use scout when you're about to write into the target repo — use `/handoff`.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
/scout <repo> "<prompt>"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`<repo>` is either a member id from `ecosystem.json` or a relative/absolute path. `<prompt>` is the user's question.
|
|
30
|
+
|
|
31
|
+
## Steps
|
|
32
|
+
|
|
33
|
+
### Step 1 — Identify the target repo + prompt
|
|
34
|
+
|
|
35
|
+
Parse the user's invocation. If they said `/scout sapience auth endpoint shape` then:
|
|
36
|
+
|
|
37
|
+
- repo = `sapience`
|
|
38
|
+
- prompt = `auth endpoint shape`
|
|
39
|
+
|
|
40
|
+
Resolve `sapience` to an absolute path via the ecosystem manifest (`ecosystem.json` → `members[]`).
|
|
41
|
+
|
|
42
|
+
### Step 2 — Spawn a read-only sub-agent
|
|
43
|
+
|
|
44
|
+
Use the Task tool with a prompt that:
|
|
45
|
+
|
|
46
|
+
1. Tells the sub-agent: "you are a SCOUT for momentum's orchestration layer."
|
|
47
|
+
2. Provides the target repo path and the user's prompt.
|
|
48
|
+
3. Instructs the sub-agent to: read `specs/status.md`, recent files under `specs/architecture/` and `specs/phases/<active>/history.md`, and any keyword-matching files. NO writes.
|
|
49
|
+
4. Asks the sub-agent to return a structured JSON object:
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"summary": "...one-paragraph answer to the prompt...",
|
|
53
|
+
"filesRead": ["specs/status.md", "..."],
|
|
54
|
+
"findings": [
|
|
55
|
+
{ "kind": "discovery", "title": "...", "detail": "...", "recommendedBacklogPriority": "P2" }
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
`findings` should ONLY include real bugs, real tech debt, real enhancements — applying the same threshold as Rule 3 (Auto-Track Discoveries). DO NOT include orchestration metadata or anything that doesn't deserve a backlog entry.
|
|
60
|
+
|
|
61
|
+
### Step 3 — Record the run
|
|
62
|
+
|
|
63
|
+
Once the sub-agent returns:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const orchestration = require('<momentum-root>/core/orchestration');
|
|
67
|
+
const result = orchestration.scout.record({
|
|
68
|
+
repo: '<resolved repo path>',
|
|
69
|
+
prompt: '<user prompt>',
|
|
70
|
+
summary: '<sub-agent summary>',
|
|
71
|
+
filesRead: [/* ... */],
|
|
72
|
+
findings: [/* ... */],
|
|
73
|
+
ecosystem: { rootPath: '<ecosystem root>', memberId: '<this repo member id>' },
|
|
74
|
+
duration: <ms>,
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This writes `.momentum/runs/scout-NNN.md` in THIS repo (originating) and appends one line to the ecosystem session log. The library handles run-id allocation.
|
|
79
|
+
|
|
80
|
+
### Step 4 — Hand findings to the tracking contract
|
|
81
|
+
|
|
82
|
+
For each finding the sub-agent returned, call:
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
orchestration.tracking.proposeDiscovery({
|
|
86
|
+
primitive: 'scout',
|
|
87
|
+
finding,
|
|
88
|
+
targetRepo: '<scouted repo path>',
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The helper applies Rule 3 criteria. If `shouldWrite=true`, it appends a `[DISCOVERY]` entry to the scouted repo's active phase history. If `shouldWrite=false`, only the session log line above stays — no curated-layer write.
|
|
93
|
+
|
|
94
|
+
### Step 5 — Narrate the result
|
|
95
|
+
|
|
96
|
+
Output the summary, then the artifact path:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
▸ scout <repo>: <prompt>
|
|
100
|
+
▸ reading specs/status.md
|
|
101
|
+
▸ reading specs/architecture/...
|
|
102
|
+
▸ found: <finding summary> (one line per finding written by tracking)
|
|
103
|
+
|
|
104
|
+
<summary text>
|
|
105
|
+
|
|
106
|
+
→ logged to sessions/<today>.md
|
|
107
|
+
→ trace at <artifact path>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Tracking contract
|
|
111
|
+
|
|
112
|
+
- **Auto every time:** ecosystem session log line + scout-NNN.md artifact in THIS repo.
|
|
113
|
+
- **Auto only when meaningful:** `[DISCOVERY]` entry in the SCOUTED repo's active phase history, when the agent judges a finding worth backlog tracking (Rule 3 thresholds). NEVER write `[SCOUT]` entries — use existing entry types.
|
|
114
|
+
- **Never:** `backlog.md` entries without explicit user confirmation. Tracking helper proposes; user OKs.
|
|
115
|
+
|
|
116
|
+
## Errors
|
|
117
|
+
|
|
118
|
+
- Repo not found in ecosystem manifest → report and stop.
|
|
119
|
+
- Repo not in any ecosystem (this repo is standalone) → fall back to running scout in-process via CLI; suggest the user run `momentum scout <path> "<prompt>"` directly.
|