@limina-labs/momentum 0.30.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/adapters/antigravity/adapter.js +196 -0
  4. package/adapters/antigravity/hooks.json +39 -0
  5. package/adapters/antigravity/instructions/AGENTS.md +638 -0
  6. package/adapters/antigravity/instructions/header.md +3 -0
  7. package/adapters/antigravity/instructions/surfaces.md +153 -0
  8. package/adapters/antigravity/instructions/vars.json +1 -0
  9. package/adapters/antigravity/scripts/antigravity-hook-adapter.sh +147 -0
  10. package/adapters/antigravity/skills/momentum-orient/SKILL.md +29 -0
  11. package/adapters/antigravity/skills/momentum-reviewer-architecture/SKILL.md +39 -0
  12. package/adapters/antigravity/skills/momentum-reviewer-qa/SKILL.md +38 -0
  13. package/adapters/antigravity/skills/momentum-reviewer-security/SKILL.md +42 -0
  14. package/adapters/antigravity/skills/swarm-supervisor/SKILL.md +75 -0
  15. package/adapters/antigravity/workflows/continue.md +39 -0
  16. package/adapters/antigravity/workflows/dispatch.md +49 -0
  17. package/adapters/antigravity/workflows/handoff.md +38 -0
  18. package/adapters/antigravity/workflows/review-code.md +84 -0
  19. package/adapters/antigravity/workflows/scout.md +42 -0
  20. package/adapters/antigravity/workflows/swarm.md +203 -0
  21. package/adapters/claude-code/adapter.js +148 -0
  22. package/adapters/claude-code/commands/continue.md +82 -0
  23. package/adapters/claude-code/commands/dispatch.md +154 -0
  24. package/adapters/claude-code/commands/handoff.md +85 -0
  25. package/adapters/claude-code/commands/review-code.md +194 -0
  26. package/adapters/claude-code/commands/scout.md +119 -0
  27. package/adapters/claude-code/commands/swarm.md +242 -0
  28. package/adapters/claude-code/instructions/header.md +3 -0
  29. package/adapters/claude-code/instructions/vars.json +1 -0
  30. package/adapters/claude-code/settings.json +36 -0
  31. package/adapters/codex/adapter.js +225 -0
  32. package/adapters/codex/agents/momentum-reviewer-architecture.toml +57 -0
  33. package/adapters/codex/agents/momentum-reviewer-qa.toml +52 -0
  34. package/adapters/codex/agents/momentum-reviewer-security.toml +57 -0
  35. package/adapters/codex/agents/swarm-supervisor.toml +76 -0
  36. package/adapters/codex/commands/continue.md +40 -0
  37. package/adapters/codex/commands/dispatch.md +111 -0
  38. package/adapters/codex/commands/handoff.md +57 -0
  39. package/adapters/codex/commands/scout.md +90 -0
  40. package/adapters/codex/commands/swarm.md +334 -0
  41. package/adapters/codex/hooks.json +36 -0
  42. package/adapters/codex/instructions/AGENTS.md +691 -0
  43. package/adapters/codex/instructions/header.md +3 -0
  44. package/adapters/codex/instructions/surfaces.md +206 -0
  45. package/adapters/codex/instructions/vars.json +1 -0
  46. package/adapters/codex/skills/momentum-orient/SKILL.md +29 -0
  47. package/adapters/opencode/adapter.js +224 -0
  48. package/adapters/opencode/agents/momentum-reviewer-architecture.md +54 -0
  49. package/adapters/opencode/agents/momentum-reviewer-qa.md +48 -0
  50. package/adapters/opencode/agents/momentum-reviewer-security.md +48 -0
  51. package/adapters/opencode/agents/swarm-supervisor.md +51 -0
  52. package/adapters/opencode/commands/continue.md +40 -0
  53. package/adapters/opencode/commands/dispatch.md +111 -0
  54. package/adapters/opencode/commands/handoff.md +57 -0
  55. package/adapters/opencode/commands/review-code.md +194 -0
  56. package/adapters/opencode/commands/scout.md +90 -0
  57. package/adapters/opencode/commands/swarm.md +334 -0
  58. package/adapters/opencode/instructions/AGENTS.md +604 -0
  59. package/adapters/opencode/instructions/header.md +3 -0
  60. package/adapters/opencode/instructions/surfaces.md +119 -0
  61. package/adapters/opencode/instructions/vars.json +1 -0
  62. package/adapters/opencode/plugins/momentum.js +219 -0
  63. package/adapters/opencode/skills/momentum-lanes/SKILL.md +30 -0
  64. package/adapters/opencode/skills/momentum-orient/SKILL.md +29 -0
  65. package/adapters/opencode/skills/momentum-track/SKILL.md +28 -0
  66. package/adapters/opencode/skills/momentum-validate/SKILL.md +31 -0
  67. package/bin/antigravity.js +112 -0
  68. package/bin/ecosystem.js +1302 -0
  69. package/bin/lanes.js +300 -0
  70. package/bin/momentum.js +1857 -0
  71. package/bin/okf.js +72 -0
  72. package/bin/orchestration-commands.js +305 -0
  73. package/bin/state-commands.js +218 -0
  74. package/bin/swarm.js +1104 -0
  75. package/bin/waves.js +147 -0
  76. package/core/adapter-capabilities.md +112 -0
  77. package/core/adapter-parity-matrix.md +170 -0
  78. package/core/commands/brainstorm-idea.md +98 -0
  79. package/core/commands/brainstorm-phase.md +129 -0
  80. package/core/commands/complete-phase.md +130 -0
  81. package/core/commands/ecosystem.md +161 -0
  82. package/core/commands/hotfix.md +64 -0
  83. package/core/commands/initiative.md +119 -0
  84. package/core/commands/lanes.md +94 -0
  85. package/core/commands/log.md +45 -0
  86. package/core/commands/migrate.md +70 -0
  87. package/core/commands/review.md +31 -0
  88. package/core/commands/session.md +79 -0
  89. package/core/commands/start-phase.md +161 -0
  90. package/core/commands/start-project.md +142 -0
  91. package/core/commands/sync-docs.md +81 -0
  92. package/core/commands/systematic-debug.md +46 -0
  93. package/core/commands/track.md +54 -0
  94. package/core/commands/validate.md +96 -0
  95. package/core/ecosystem/layout.md +128 -0
  96. package/core/ecosystem/lib/index.js +245 -0
  97. package/core/ecosystem/lib/initiative.js +258 -0
  98. package/core/ecosystem/lib/pointer.js +198 -0
  99. package/core/ecosystem/lib/state.js +295 -0
  100. package/core/ecosystem/schema/ecosystem.schema.json +85 -0
  101. package/core/ecosystem/schema/initiative.schema.json +61 -0
  102. package/core/ecosystem/scripts/session-append.sh +167 -0
  103. package/core/ecosystem/templates/ecosystem-agents.md +79 -0
  104. package/core/ecosystem/templates/ecosystem-claude.md +79 -0
  105. package/core/ecosystem/templates/ecosystem-settings-claude.json +14 -0
  106. package/core/ecosystem/templates/initiative-template.md +50 -0
  107. package/core/engines/subagent-dispatch.md +80 -0
  108. package/core/git-hooks/commit-msg +14 -0
  109. package/core/git-hooks/contract.js +176 -0
  110. package/core/git-hooks/pre-push +15 -0
  111. package/core/git-hooks/run-check.js +160 -0
  112. package/core/instructions/legacy-project-md-hashes.json +12 -0
  113. package/core/instructions/navigation.md +14 -0
  114. package/core/instructions/rules-body.md +454 -0
  115. package/core/lanes/lib/board.js +161 -0
  116. package/core/lanes/lib/land.js +301 -0
  117. package/core/lanes/lib/signals.js +207 -0
  118. package/core/lanes/lib/state.js +325 -0
  119. package/core/lib/frontmatter.js +163 -0
  120. package/core/lib/okf-migrate.js +374 -0
  121. package/core/lib/okf-types.js +61 -0
  122. package/core/lifecycle-contract.md +59 -0
  123. package/core/orchestration/capability-routing.js +120 -0
  124. package/core/orchestration/continue.js +102 -0
  125. package/core/orchestration/dispatch.js +366 -0
  126. package/core/orchestration/events.js +197 -0
  127. package/core/orchestration/handoff.js +317 -0
  128. package/core/orchestration/index.js +50 -0
  129. package/core/orchestration/run-artifact.js +93 -0
  130. package/core/orchestration/scout.js +327 -0
  131. package/core/orchestration/session-log.js +123 -0
  132. package/core/orchestration/tracking.js +180 -0
  133. package/core/orchestration/types.js +131 -0
  134. package/core/scripts/brainstorm-gate.sh +157 -0
  135. package/core/scripts/check-history-reminder.sh +110 -0
  136. package/core/scripts/sessionstart-handoff.sh +180 -0
  137. package/core/specs-templates/CLAUDE.md +484 -0
  138. package/core/specs-templates/README.md +32 -0
  139. package/core/specs-templates/specs/README.md +30 -0
  140. package/core/specs-templates/specs/adhoc/README.md +31 -0
  141. package/core/specs-templates/specs/adhoc/_TEMPLATE.md +29 -0
  142. package/core/specs-templates/specs/architecture/ecosystem.md +214 -0
  143. package/core/specs-templates/specs/backlog/backlog.md +46 -0
  144. package/core/specs-templates/specs/backlog/details/.gitkeep +0 -0
  145. package/core/specs-templates/specs/changelog/.gitkeep +0 -0
  146. package/core/specs-templates/specs/decisions/0000-template.md +33 -0
  147. package/core/specs-templates/specs/decisions/README.md +29 -0
  148. package/core/specs-templates/specs/decisions/impact-map.md +14 -0
  149. package/core/specs-templates/specs/decisions/index.md +4 -0
  150. package/core/specs-templates/specs/index.md +16 -0
  151. package/core/specs-templates/specs/phases/README.md +41 -0
  152. package/core/specs-templates/specs/phases/index.md +6 -0
  153. package/core/specs-templates/specs/planning/roadmap.md +23 -0
  154. package/core/specs-templates/specs/status.md +70 -0
  155. package/core/specs-templates/specs/vision/principles.md +16 -0
  156. package/core/specs-templates/specs/vision/project-charter.md +35 -0
  157. package/core/specs-templates/specs/vision/success-criteria.md +19 -0
  158. package/core/swarm/absorb.js +294 -0
  159. package/core/swarm/conductor.js +499 -0
  160. package/core/swarm/focus.js +151 -0
  161. package/core/swarm/inbox.js +222 -0
  162. package/core/swarm/join.js +138 -0
  163. package/core/swarm/lib/board.js +178 -0
  164. package/core/swarm/lib/brief.js +157 -0
  165. package/core/swarm/lib/git-sha-cache.js +71 -0
  166. package/core/swarm/lib/incremental-log.js +117 -0
  167. package/core/swarm/lib/manifest.js +578 -0
  168. package/core/swarm/lib/pre-merge.js +112 -0
  169. package/core/swarm/lib/saga.js +146 -0
  170. package/core/swarm/lib/sessions.js +83 -0
  171. package/core/swarm/lib/tokens.js +255 -0
  172. package/core/swarm/lib/wave-ordering.js +55 -0
  173. package/core/swarm/schema/board.schema.json +54 -0
  174. package/core/swarm/schema/contract.schema.json +56 -0
  175. package/core/swarm/schema/dispatch-run.schema.json +70 -0
  176. package/core/swarm/schema/manifest.schema.json +234 -0
  177. package/core/swarm/schema/signal.schema.json +61 -0
  178. package/core/swarm/signals.js +296 -0
  179. package/core/swarm/supervise.md +81 -0
  180. package/core/waves/lib/plan-graph.js +175 -0
  181. package/core/waves/lib/waves.js +83 -0
  182. package/package.json +46 -0
@@ -0,0 +1,94 @@
1
+ Work with lanes — concurrent workstreams in one repo (Rule 15 mechanism).
2
+
3
+ > **Which phase is yours (Rule 15):** the phase bound to your branch;
4
+ > `momentum lanes` shows every lane in flight. The board is the
5
+ > cross-lane overview — your branch is still the binding.
6
+
7
+ ## When to use
8
+
9
+ - The user asks "what's running?", "what else is in flight?", or wants to
10
+ start a second workstream without abandoning the first.
11
+ - You are about to start work that should NOT live on the current branch.
12
+ - A finished lane needs to be landed in order.
13
+
14
+ ## Subcommands
15
+
16
+ All state lives at `<git-common-dir>/momentum/lanes` — shared by every
17
+ worktree, untracked, no daemon. Run from anywhere inside the repo.
18
+
19
+ ### See the board
20
+
21
+ ```bash
22
+ momentum lanes # every lane: plan node, grade, status, age, ✉ unread, ⚠ overlaps
23
+ momentum lanes queue # landing order (FIFO of done lanes) + freshness flags
24
+ ```
25
+
26
+ The board footer always shows **queue pressure** (done-but-unlanded lanes
27
+ + oldest wait). Rising pressure means landings — the human-attention step
28
+ — are the bottleneck; surface it to the user rather than opening more lanes.
29
+
30
+ ### Plan waves first (N ideas → N lanes)
31
+
32
+ ```bash
33
+ momentum waves # phase-scale waves from overview.md frontmatter "deps"
34
+ momentum waves --tasks # group waves for the phase bound to your branch
35
+ ```
36
+
37
+ Dependencies are annotations in the plans themselves (`(deps: G0, G1)`
38
+ group-heading suffix; `deps:` frontmatter on each phase's overview.md —
39
+ OKF bundle, ADR-0005; legacy `specs/phases/index.json` still read as a
40
+ fallback until the project runs `momentum upgrade`).
41
+ Wave-1 nodes are safe to open as lanes NOW; later waves unblock as their
42
+ dependencies land.
43
+
44
+ ### Open a lane
45
+
46
+ ```bash
47
+ momentum lanes open <branch> [--grade phase|quick-task|spike] \
48
+ [--touches core/**,docs/] [--path <dir>] [--from <ref>] [--no-worktree]
49
+ ```
50
+
51
+ - Creates a git worktree at `../<repo>.lanes/<id>` by default (reuses an
52
+ existing checkout of the branch; `--no-worktree` for GitButler-style
53
+ virtual branches).
54
+ - The plan node and grade are inferred from the branch name (Rule 15:
55
+ `phase-*` ↔ phase directory; `fix/* chore/* feat/*` → ad-hoc
56
+ quick-task); spikes must be declared with `--grade spike`.
57
+ - Declare `--touches` honestly — overlap warnings (advisory) are how
58
+ parallel lanes avoid semantic collisions before any agent runs.
59
+ - Heed preflight warnings (non-executable committed scripts, node
60
+ version) — they are the fresh-worktree traps.
61
+
62
+ ### Signal another lane's session
63
+
64
+ ```bash
65
+ momentum lanes signal <id> <pause|resume|redirect|kill|message> [text]
66
+ momentum lanes inbox <id> [--ack <seq>|--ack-all]
67
+ ```
68
+
69
+ Check YOUR lane's inbox at natural checkpoints (group boundaries, before
70
+ landing) and ack what you've acted on.
71
+
72
+ ### Mark done and land
73
+
74
+ ```bash
75
+ momentum lanes done <id> # enter the landing queue
76
+ momentum lanes land <id> # validate: turn, freshness, graded gate
77
+ momentum lanes land <id> --execute# merge --no-ff into the CURRENT branch
78
+ momentum lanes close <id> [--rm-worktree]
79
+ ```
80
+
81
+ Landing follows the Rule 6 **Landing Order**: one lane at a time, run the
82
+ suite on the updated integration branch before the next landing,
83
+ remaining lanes rebase (they get an advisory inbox nudge automatically).
84
+ Gates are graded per Rule 14: a `spike` lands gate-exempt; a `quick-task`
85
+ needs its `specs/adhoc/<id>/record.md`; a `phase` needs a retrospective
86
+ with a non-empty `## Verification Evidence` section (Rule 12).
87
+ `land` never pushes — pushes to protected branches keep their own
88
+ approval gate.
89
+
90
+ ## Tracking
91
+
92
+ Opening/closing lanes is not itself phase history; the WORK inside a lane
93
+ follows the normal rules (Rule 2 tracking, Rule 8 history in the lane's
94
+ own phase, Rule 15 own-row/append-only discipline for shared files).
@@ -0,0 +1,45 @@
1
+ Record a manual entry in the active phase history file — or, when no phase is
2
+ active, in the ad-hoc work record (off-phase decisions are never dropped).
3
+
4
+ > **Which phase is yours (Rule 15):** the phase bound to your branch — branch
5
+ > `phase-N-shortname` ↔ `specs/phases/phase-N-shortname/`. `status.md`'s
6
+ > Active Phase table is the fallback (detached HEAD, no matching directory)
7
+ > and the cross-lane overview, not the binding.
8
+
9
+ ## Steps
10
+
11
+ 1. Resolve your phase from the current branch (`git branch --show-current`):
12
+ a `phase-*` branch with a matching `specs/phases/<branch>/` directory binds
13
+ to that phase. Fallback: the `specs/status.md` Active Phase table. A
14
+ non-phase branch (`fix/*`, `chore/*`, `feat/*`) is ad-hoc work — see below.
15
+ 2. Find the history file:
16
+ - **Phase lane**: `specs/phases/<phase-bound-to-your-branch>/history.md`
17
+ - **No active phase** (between phases, or `/hotfix` quick-task / spike work):
18
+ the `specs/adhoc/<id>/record.md` you are working in, else
19
+ `specs/adhoc/history.md` (create it from the same entry format if absent).
20
+ Off-phase work still captures its *why* (Rule 8) — it just lives here.
21
+ 3. Determine entry type from the message:
22
+ - Decision about technology/architecture → [DECISION]
23
+ - Phase scope added/removed → [SCOPE_CHANGE]
24
+ - Bug/tech debt/enhancement found → [DISCOVERY]
25
+ - New planned feature → [FEATURE]
26
+ - Architecture pattern changed → [ARCH_CHANGE]
27
+ - Evaluator defined or changed → [EVALUATOR]
28
+ - Anything else → [NOTE]
29
+ 4. Extract or infer topics (2-5 keywords)
30
+ 5. Identify affects-phases (check `status:` frontmatter in `specs/phases/*/overview.md`)
31
+ 6. Identify affects-specs (check `specs/decisions/impact-map.md`)
32
+ 7. Append the formatted entry to history.md (APPEND ONLY):
33
+
34
+ ```
35
+ ### [TYPE] YYYY-MM-DD — Short title (max 10 words)
36
+ Topics: topic-1, topic-2, topic-3
37
+ Affects-phases: phase-N-name (or "none")
38
+ Affects-specs: path/to/file.md#section (or "none")
39
+ Detail: One to three sentences describing what changed and why.
40
+
41
+ ---
42
+ ```
43
+
44
+ 8. If the entry introduces a topic not in the `specs/decisions/impact-map.md` table, add a row
45
+ 9. Confirm: "Logged [TYPE] entry to [phase or ad-hoc] history."
@@ -0,0 +1,70 @@
1
+ Onboard an existing project with a manual or outdated momentum-like structure into proper momentum format.
2
+
3
+ This command fills gaps without overwriting anything the project already has.
4
+
5
+ ## Steps
6
+
7
+ 1. **Detect existing structure** — scan for what momentum expects vs what is present:
8
+
9
+ | Item | Expected path | Present? |
10
+ |------|--------------|---------|
11
+ | Spec root | `specs/` | |
12
+ | Status file | `specs/status.md` | |
13
+ | Backlog | `specs/backlog/backlog.md` | |
14
+ | Bundle root | `specs/index.md` (OKF, `okf_version`) | |
15
+ | Decisions dir | `specs/decisions/` | |
16
+ | Planning dir | `specs/planning/` | |
17
+ | Changelog dir | `specs/changelog/` | |
18
+ | Hook script | `scripts/check-history-reminder.sh` | |
19
+ | Claude commands | `.claude/commands/` | |
20
+
21
+ For `.claude/commands/`, list which of the standard momentum commands are missing:
22
+ `brainstorm-idea`, `brainstorm-phase`, `start-project`, `start-phase`, `complete-phase`,
23
+ `log`, `sync-docs`, `track`, `migrate`, `validate`
24
+
25
+ 2. **Report gap summary** — present findings before making any changes:
26
+ ```
27
+ Found: 8 / Missing: 4 items
28
+ Will add:
29
+ - specs/backlog/details/ (.gitkeep)
30
+ - specs/index.md (OKF bundle root)
31
+ - .claude/commands/validate.md
32
+ - .claude/commands/migrate.md
33
+ Will skip (already exist):
34
+ - specs/status.md
35
+ - specs/backlog/backlog.md
36
+ ```
37
+ Ask the user to confirm before proceeding.
38
+
39
+ 3. **Fill gaps (skip-if-exists for all files)**:
40
+ - Copy any missing momentum template files from `specs-templates/` — never overwrite
41
+ files the project already has
42
+ - Add any missing momentum commands to `.claude/commands/` — skip ones already present
43
+ - Add `scripts/check-history-reminder.sh` if absent (and chmod +x)
44
+
45
+ 4. **Phase metadata reconciliation** (OKF bundle, ADR-0005):
46
+ - Run `momentum upgrade` — it migrates any legacy `specs/phases/index.json`
47
+ / `specs/decisions/impact-map.json` into frontmatter + `impact-map.md`,
48
+ sweeps `type:` frontmatter across `specs/**/*.md`, and generates the
49
+ bundle indexes
50
+ - For any `phase-*` directory whose `overview.md` still lacks `status:`
51
+ frontmatter, add:
52
+ ```yaml
53
+ ---
54
+ type: Phase
55
+ status: unknown
56
+ ---
57
+ ```
58
+ - Inform the user: "N phases marked status 'unknown' — update the
59
+ frontmatter manually to match actual state"
60
+ - Finish with `momentum okf check` and report any remaining violations
61
+
62
+ 5. **Report result**:
63
+ ```
64
+ ✓ Migration complete.
65
+ Added: 4 items
66
+ Skipped: 6 items (already existed — not overwritten)
67
+ Needs manual attention:
68
+ - 3 phases marked status 'unknown' in overview.md frontmatter — verify manually
69
+ - specs/status.md: already exists — verify Current Phase matches the phase frontmatter
70
+ ```
@@ -0,0 +1,31 @@
1
+ Review and groom the backlog between phases.
2
+
3
+ ## Steps
4
+
5
+ 1. Read `specs/status.md` and `specs/backlog/backlog.md`
6
+
7
+ 2. For each category, assess:
8
+ - Are priorities still accurate?
9
+ - Should items move to active/next phase?
10
+ - Are any items resolved or deprecated?
11
+ - Orphaned items without a phase?
12
+
13
+ 3. Check for dependencies:
14
+ - P0 bugs blocking progress
15
+ - Features depending on unresolved tech debt
16
+ - Items open 3+ months without progress
17
+
18
+ 4. Update `specs/backlog/backlog.md` with changes
19
+
20
+ 5. Update `specs/status.md` if blockers changed
21
+
22
+ 6. Commit:
23
+ ```bash
24
+ git add specs/
25
+ git commit -m "docs(backlog): grooming for Phase N"
26
+ ```
27
+
28
+ 7. Report:
29
+ - Total open items by type and priority
30
+ - P0/P1 items requiring attention
31
+ - Recommended actions
@@ -0,0 +1,79 @@
1
+ Append a manual narrative entry to today's ecosystem session log.
2
+
3
+ The session log auto-fills with structural events (commits, PR
4
+ opens/merges) via the PostToolUse hook in each registered member repo.
5
+ Use `/session log` for narrative entries — decisions, problems hit,
6
+ checkpoint notes — that don't correspond to a tool event.
7
+
8
+ ## Usage
9
+
10
+ ```
11
+ /session log "<message>"
12
+ ```
13
+
14
+ ## Steps
15
+
16
+ 1. Locate the ecosystem root via
17
+ `core/ecosystem/lib/index.js → findRoot(process.cwd())`.
18
+ If no ecosystem root exists, refuse with a clear message: "Not
19
+ inside an ecosystem. Run `momentum ecosystem init` first or `cd`
20
+ into a registered member repo."
21
+
22
+ 2. Determine the calling member id (when relevant): match
23
+ `realpath($PWD)` against each `manifest.members[].path`. If no
24
+ match, write the entry with a `[meta]` tag instead.
25
+
26
+ 3. Build the line:
27
+ ```
28
+ HH:MMZ [<member-id-or-meta>] note: <message>
29
+ ```
30
+
31
+ 4. If today's session file doesn't exist yet, prepend a header:
32
+ ```
33
+ # Session YYYY-MM-DD
34
+ Active initiative: <slug> (if .state/active-initiative is set)
35
+
36
+ ```
37
+
38
+ 5. Append the line to `<ecosystem-root>/sessions/$(date -u +%F).md`.
39
+
40
+ 6. Update `<ecosystem-root>/.state/last-session` to today's date.
41
+
42
+ 7. Print confirmation:
43
+ ```
44
+ Logged: HH:MMZ [<member-id>] note: <message>
45
+ ```
46
+
47
+ ## When to use vs auto-events
48
+
49
+ | Use `/session log` for… | Auto-events already cover… |
50
+ |---|---|
51
+ | "Decided to defer X to Tier 2" | `git commit` (the actual change record) |
52
+ | "Discovered the SQL was dropping scope filter" | `gh pr create/merge` |
53
+ | "Bumped Y version pin in lock to address Z" | future: deploy events (Group 3 v2) |
54
+ | "Switching context from sapience to frontend" | future: hook-detected directory changes |
55
+
56
+ ## Mechanism
57
+
58
+ `/session log` is a thin wrapper around the same
59
+ `core/ecosystem/scripts/session-append.sh` helper used by the
60
+ PostToolUse hook. From bash:
61
+
62
+ ```bash
63
+ $MOMENTUM_SCRIPTS/session-append.sh log "<message>" "<optional-context>"
64
+ ```
65
+
66
+ ## Idempotency / safety
67
+
68
+ - Multiple `/session log` calls in the same minute produce multiple
69
+ lines. Concurrent writes (a `/session log` plus a `git commit` hook
70
+ in another member repo at the same instant) are serialized via a
71
+ per-session-file `mkdir` lock (Phase 10 / BUG-004). ~5s acquisition
72
+ budget; on timeout the event is dropped rather than risking
73
+ corruption.
74
+ - The walk-up that locates the ecosystem root honors the
75
+ `MOMENTUM_MAX_PARENT_WALK` env var (default 5).
76
+ - Outside an ecosystem the helper silently no-ops, so harmless to
77
+ invoke speculatively.
78
+ - The session log is gitignore-free (committed) but `.state/` is not —
79
+ to share session history across machines, push the ecosystem repo.
@@ -0,0 +1,161 @@
1
+ Begin a new implementation phase.
2
+
3
+ After setup, **executes the plan end-to-end autonomously** — no per-group approval prompts, no "should I commit?" interruptions. The engine stops once: at the merge + release gate after the final group's verification passes. See the [Autonomous Execution Contract](#autonomous-execution-contract) below.
4
+
5
+ > **Which phase is yours (Rule 15):** the phase bound to your branch — branch
6
+ > `phase-N-shortname` ↔ `specs/phases/phase-N-shortname/`. `status.md`'s
7
+ > Active Phase table is the fallback and the cross-lane overview. Starting a
8
+ > phase while other lanes are active is normal — add your lane's row to the
9
+ > table; never replace or rewrite other lanes' rows.
10
+
11
+ ## Setup Steps (run once at phase start)
12
+
13
+ 1. Read current state:
14
+ - Read `specs/status.md`
15
+
16
+ 2. Check for blocking bugs (pre-phase bug check):
17
+ - Scan `specs/backlog/backlog.md` for P0/P1 items
18
+ - If P0 bugs exist → report to user, recommend fixing first
19
+ - If only P1 → continue but note them
20
+
21
+ 3. Create the phase directory if it doesn't exist:
22
+ ```
23
+ specs/phases/phase-N-shortname/
24
+ ├── overview.md ← Scope, goals, deliverables, acceptance criteria
25
+ ├── plan.md ← Implementation approach with group execution pattern
26
+ ├── tasks.md ← Granular checklist [ ] / [x]
27
+ └── history.md ← Append-only log
28
+ ```
29
+ Use `/brainstorm-phase` first if these files don't exist yet.
30
+
31
+ Note: if running `/start-phase` without `/brainstorm-phase` first, create
32
+ `history.md` now — an empty append-only log with the entry-types header table.
33
+
34
+ **Swarm-member briefs (Phase 17+)**: when `/start-phase` is invoked from
35
+ a swarm conductor (env vars `MOMENTUM_SWARM_ID` + `MOMENTUM_SWARM_WAVE`
36
+ + `MOMENTUM_SWARM_INITIATIVE` + `MOMENTUM_SWARM_SESSION` are set),
37
+ prepend a YAML frontmatter block to `overview.md` with these fields:
38
+ ```yaml
39
+ ---
40
+ swarm: <NNNN-slug>
41
+ wave: <integer>
42
+ initiative: <slug>
43
+ claimed_by_session: <uuid>
44
+ ---
45
+ ```
46
+ Solo (non-swarm) briefs omit the block entirely — they remain plain
47
+ markdown. See `core/swarm/lib/brief.js` for the canonical helper.
48
+
49
+ 4. Set phase metadata (OKF bundle, ADR-0005):
50
+ - Read the phase's `overview.md` and `tasks.md`
51
+ - Extract key topics: technology names, services, architectural concepts
52
+ - Add/update the frontmatter at the top of the phase's `overview.md`:
53
+ ```yaml
54
+ ---
55
+ type: Phase
56
+ status: in-progress
57
+ tags: [topic-1, topic-2]
58
+ ```
59
+ (add `deps: [phase-M-name]` when this phase depends on another
60
+ unfinished phase — `momentum waves` reads it)
61
+ - Refresh the bundle listings: `momentum okf index`
62
+
63
+ 5. Update `specs/phases/README.md`:
64
+ - Change phase status: `Not Started` → `In Progress`
65
+
66
+ 6. Update `specs/status.md`:
67
+ - Set "Current Phase" to the new phase (with other lanes active, the most
68
+ recently started lane; the Active Phase table is the full picture)
69
+ - Add this phase's row to the "Active Phase" table
70
+ (Phase | Branch | Status | Progress) — one row per active lane; touch
71
+ ONLY your own row (Rule 15)
72
+ - Clear/update blockers
73
+
74
+ 7. For monorepo only — identify relevant architecture specs:
75
+ - Check `specs/planning/release-plan.md` for this phase's deliverables
76
+ - List which specs in `specs/architecture/` are relevant
77
+ - Note them in the phase's `plan.md` under "Reference Specs"
78
+
79
+ 8. If this phase requires a locked evaluator (learning/optimization loop):
80
+ - Add "Lock [Evaluator]" as the FIRST task in `tasks.md`
81
+
82
+ 9. Create git branch and initial commit:
83
+ ```bash
84
+ git checkout main && git pull origin main
85
+ git checkout -b phase-N-shortname
86
+ git add specs/
87
+ git commit -m "docs: start Phase N - {phase name}"
88
+ git push -u origin phase-N-shortname
89
+ ```
90
+
91
+ 10. Update `specs/changelog/YYYY-MM.md` with phase start entry.
92
+
93
+ ## After Setup: Execute the Plan Autonomously
94
+
95
+ Once steps 1–10 complete, **proceed to implement the phase** per the [Autonomous Execution Contract](#autonomous-execution-contract). For each group in `plan.md` (in declared execution order):
96
+
97
+ 1. **Mark the group's first task `[/]`** in `tasks.md` (in-progress).
98
+ 2. **Implement the group's tasks.** Read, write code, add tests as the group requires.
99
+ 3. **Run the group's verification command** (per Rule 12 — Verify Before Claim). Read the actual output.
100
+ 4. **Mark tasks `[x]`** in `tasks.md` only if verification passed.
101
+ 5. **Append a history entry** to `history.md` per Rule 8 (one entry per group minimum, more if `[DECISION]`/`[DISCOVERY]` events happen).
102
+ 6. **Commit the group** with the per-group commit message declared in `plan.md`.
103
+ 7. **Push to the phase branch.**
104
+ 8. **Proceed to the next group.** Do NOT ask "ready for Group N+1?" — the answer is always yes.
105
+
106
+ After the final group's verification passes: **STOP.** Ask the user the single hard-stop question in the contract below.
107
+
108
+ ---
109
+
110
+ ## Autonomous Execution Contract
111
+
112
+ Once a phase plan is approved, this command executes the plan end-to-end without per-group approvals. The contract below defines what proceeds silently and where the engine MUST stop.
113
+
114
+ ### Hard stop — always
115
+
116
+ **Merge to staging/main + release.** After the final group's verification passes, STOP. Ask the user:
117
+
118
+ > "All groups complete and verified. Ready to merge `<phase-branch>` → staging (then main), tag `v<version>`, and run `npm publish --access public`. Approve to proceed?"
119
+
120
+ This is the only place the engine asks. Do NOT skip it.
121
+
122
+ ### Discretionary stop — rare, judgment-based
123
+
124
+ Interrupt only when continuing would cause real harm or a wrong result that's hard to undo. Examples:
125
+
126
+ - Destructive git operation not in the plan (force-push to main, `git reset --hard origin/...`, branch deletion of unmerged work)
127
+ - A discovery that invalidates the agreed plan (not just adds to it — `[DISCOVERY]` + backlog entry handles additions silently)
128
+ - A required external action the engine can't perform (paid API spend, credential setup, account configuration)
129
+ - Repeated unresolved failure on the same task (Phase 7b will codify a 3-strikes retry budget; before 7b, use judgment)
130
+
131
+ A discretionary stop is rare. The default is to proceed.
132
+
133
+ ### Pre-authorized actions — proceed silently
134
+
135
+ The engine does all of these without asking:
136
+
137
+ - Create the phase feature branch
138
+ - Commit per the conventional commit style and the per-group commit message in `plan.md`
139
+ - Push the phase branch to origin
140
+ - Run tests, lint, typecheck, build commands
141
+ - Update `specs/status.md`, the phase's `overview.md` frontmatter, `specs/phases/README.md`, the active phase's `tasks.md` and `history.md`
142
+ - Append to `specs/changelog/YYYY-MM.md`
143
+ - Create ADRs from discoveries (per Rule 8 / Rule 10)
144
+ - Add backlog entries from discoveries (per Rule 3)
145
+ - Read any file in the repo
146
+
147
+ ### Anti-patterns — DO NOT
148
+
149
+ | Anti-pattern | Correct behavior |
150
+ |---|---|
151
+ | Asking "should I commit Group N now?" after each group | Commit per the plan's per-group commit message. Do not ask. |
152
+ | Asking "should I push?" after the first commit | Push immediately after the first commit; thereafter on milestones. Do not ask. |
153
+ | Asking "ready for Group 1?" after Group 0 | Proceed to Group 1 immediately when Group 0 verification passes. |
154
+ | Pausing to summarize progress between groups | Update `tasks.md` and move on. Summaries are for the user when they ask. |
155
+ | Asking "ready for tests?" before Group N's verification step | Verification is part of Group N. Run it. |
156
+
157
+ ### Cross-references
158
+
159
+ - **Rule 6 (Git Lifecycle)**: pre-authorizes branch creation, commits, pushes to feature branch. The autonomy contract is the execution-time application of Rule 6.
160
+ - **Rule 8 (History)**: every group ends with a history append. Do this silently.
161
+ - **Rule 12 (Verify Before Claim)**: every group's last task is verification. Run the command, read the output, mark `[x]` only if passing.
@@ -0,0 +1,142 @@
1
+ Scaffold a new project from a clear idea.
2
+
3
+ Run this on a NEW or EMPTY repository when you know what you're building.
4
+ If you're still exploring the idea, run `/brainstorm-idea` first.
5
+
6
+ Turns a settled concept into a fully spec-driven project: vision, roadmap, Phase 0 ready to go. **Scaffolding happens only after you explicitly approve the plan.** See the [Brainstorm Gate Contract](#brainstorm-gate-contract) below.
7
+
8
+ ## Steps
9
+
10
+ 0. **Enter the brainstorm gate**:
11
+ ```bash
12
+ mkdir -p .momentum && touch .momentum/brainstorm-active
13
+ ```
14
+ From here until Step 8, do NOT call `Write`/`Edit`/`MultiEdit` on any path under `specs/`. The PreToolUse hook will block such calls.
15
+
16
+ 1. Confirm the idea is clear — ask if needed:
17
+ - What does this project build or do?
18
+ - What type of repository? (monorepo with architecture specs / standard library or package)
19
+ - What is the primary tech stack / language?
20
+ - Any hard constraints (performance, compliance, dependencies)?
21
+
22
+ 2. Determine repo type from answers:
23
+ - Monorepo → full architecture constitution in `specs/architecture/`
24
+ - Standard → implementation tracking only
25
+
26
+ 3. **Plan the scaffold in conversation only** — no file writes yet:
27
+ - Sketch the vision (charter, principles, success criteria) in chat
28
+ - For monorepo: sketch initial architecture (core abstractions, interfaces, contracts)
29
+ - Design the phase roadmap (natural phases, dependencies)
30
+ - Draft Phase 0 contents using the [Group Execution Pattern](#group-execution-pattern)
31
+ - List every file that scaffolding will create (paths only — content stays in chat)
32
+
33
+ 4. Present the scaffolding plan for approval:
34
+ - Show the proposed file list
35
+ - Show key sections of vision + Phase 0
36
+ - Ask: "Ready to scaffold? This will create N files. Approve to proceed."
37
+
38
+ 5. **On approval — exit the gate**:
39
+ ```bash
40
+ rm .momentum/brainstorm-active
41
+ ```
42
+
43
+ 6. Scaffold directory structure:
44
+ ```bash
45
+ mkdir -p docs specs/backlog/details specs/changelog specs/decisions \
46
+ specs/phases specs/planning specs/vision scripts \
47
+ .claude/commands .agent/rules
48
+ touch specs/backlog/details/.gitkeep
49
+ # monorepo only:
50
+ mkdir -p specs/architecture/adrs specs/benchmarks
51
+ ```
52
+
53
+ 7. Create all files in one batch:
54
+ - `specs/vision/project-charter.md` — problem, goals, non-goals, stakeholders
55
+ - `specs/vision/principles.md` — engineering principles
56
+ - `specs/vision/success-criteria.md` — measurable completion criteria
57
+ - For monorepo: `specs/architecture/` first-pass architecture doc
58
+ - `specs/planning/roadmap.md`
59
+ - `specs/phases/phase-0-shortname/{overview,plan,tasks,history}.md`
60
+ - `CLAUDE.md` (the primary instruction file — full rules included)
61
+ - `specs/index.md` (OKF bundle root), `specs/decisions/impact-map.md`
62
+ - `specs/status.md`, `specs/backlog/backlog.md`
63
+ - `specs/decisions/0000-template.md`, `specs/decisions/README.md`
64
+ - `specs/phases/README.md`, `specs/README.md`
65
+ - `specs/changelog/YYYY-MM.md`
66
+
67
+ 8. Initial git commit:
68
+ ```bash
69
+ git add .
70
+ git commit -m "feat: initialize spec-driven project — {project name}
71
+
72
+ - Vision, roadmap, Phase 0 brainstormed and ready
73
+ - Full spec-driven structure: specs/, CLAUDE.md, commands, hooks
74
+ - Ready for /start-phase"
75
+ ```
76
+
77
+ 9. Report to user:
78
+ - Summary of what was created
79
+ - Phase 0 goal and key deliverables
80
+ - Prompt: "Project scaffolded. Run `/start-phase` to begin Phase 0."
81
+
82
+ ---
83
+
84
+ ## Brainstorm Gate Contract
85
+
86
+ This command runs in two phases: **brainstorm** (conversational, no disk writes) and **commit** (writes files to disk on explicit approval).
87
+
88
+ ### Sentinel-driven enforcement
89
+
90
+ A file `.momentum/brainstorm-active` exists for the lifetime of the brainstorm phase. While it exists, the Claude Code `brainstorm-gate.sh` PreToolUse hook blocks any `Write`/`Edit`/`MultiEdit` call whose target lives under `specs/`. The hook is the safety net; the discipline below is the primary contract.
91
+
92
+ ### Sequence
93
+
94
+ 1. **Enter brainstorm** — `mkdir -p .momentum && touch .momentum/brainstorm-active`
95
+ 2. **Draft in conversation only** — vision sketch, architecture sketch, roadmap, Phase 0 plan all live in chat. NEVER call `Write`/`Edit`/`MultiEdit` on `specs/` paths during this phase.
96
+ 3. **Present for approval** — show the user the full draft including the list of files scaffolding will create. Ask: "Ready to scaffold? Approve to proceed."
97
+ 4. **Exit brainstorm on approval** — `rm .momentum/brainstorm-active`, then create all files in one batch and commit.
98
+
99
+ ### Red flags — STOP and stay in conversation
100
+
101
+ | If you find yourself thinking… | …STOP and stay in conversation |
102
+ |---|---|
103
+ | "I'll create the directory structure now so I can see it" | The conversation IS the plan. The hook will block any `specs/` write. |
104
+ | "The user said the project name; I'll start scaffolding" | Project name ≠ approval. Show the full plan, then ask. |
105
+ | "I'll write `specs/vision/project-charter.md` first while we figure out the rest" | All-or-nothing: every file goes in one batch on approval. Otherwise the project ends up half-scaffolded if the user changes their mind. |
106
+ | "It's an empty repo, no harm in writing early" | Scaffolding an empty repo creates a commitment to the structure. Approval first. |
107
+
108
+ ### Anti-rationalization counters
109
+
110
+ - "Faster to scaffold incrementally as we decide each piece" — no: incremental scaffolding makes "undo" expensive. Batch on approval.
111
+ - "The user obviously wants this, they ran the command" — they want a project scaffolded; they have not yet seen the proposed structure.
112
+ - "The roadmap is generic enough I can write it now" — even a generic roadmap is a commitment; show it first.
113
+
114
+ ---
115
+
116
+ ## Group Execution Pattern
117
+
118
+ Declare the execution order at the top of every plan.md:
119
+
120
+ ```
121
+ # Sequential: Group 0 → Group 1 → Group 2
122
+ # Parallel: (Groups 0 + 1 + 2 in parallel) → Group 3
123
+ # Mixed: Group 0 → (Groups 1 + 2 in parallel) → Group 3
124
+ ```
125
+
126
+ Every group header declares:
127
+ - `**Sequential.**` or `**Parallel with Groups X and Y.**`
128
+ - External dependencies (libraries, services, running processes)
129
+ - Commit message for the group
130
+
131
+ Standard layout:
132
+ - **Group 0** — contracts, types, migrations (sequential, blocks everything)
133
+ - **Middle groups** — independent feature areas (parallel candidates)
134
+ - **Second-to-last** — wiring and integration (sequential)
135
+ - **Last** — verification: tests, benchmarks, smoke tests (sequential)
136
+
137
+ ## Key Principles
138
+ - Idea should already be clear before running this — use `/brainstorm-idea` to get there
139
+ - Phase 0 scope should be achievable in a focused sprint
140
+ - Architecture sketch is a starting point, not a commitment
141
+ - Record all key decisions from the dialogue in Phase 0's `history.md`
142
+ - **Brainstorm Gate**: see the contract above. Scaffolding only after explicit approval.