@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,153 @@
1
+ ## Antigravity-native layout under `.agents/`
2
+
3
+ Momentum installs every Antigravity-discoverable asset under the ONE
4
+ canonical customization root, `.agents/`, at the project root (ADR-0006;
5
+ Antigravity accepts four root spellings, and `.agents/` is the one all
6
+ vendor examples and reference docs use):
7
+
8
+ | Path | Purpose |
9
+ |---|---|
10
+ | `.agents/workflows/` | Step-by-step workflow recipes — each `<name>.md` auto-registers as `/<name>` slash command. Includes all momentum phase + orchestration commands. |
11
+ | `.agents/engines/` | Execution engines (subagent dispatch playbook). |
12
+ | `.agents/skills/` | On-demand persona/capability skills — each `<name>/SKILL.md` is discovered by name+description and loads on activation. Momentum ships `momentum-orient` + three reviewers + `swarm-supervisor`. |
13
+ | `.agents/hooks.json` | Lifecycle hooks (five events: PreToolUse, PostToolUse, PreInvocation, PostInvocation, Stop). |
14
+
15
+ ## Workflows = momentum recipes (native slash commands)
16
+
17
+ When the user types `/<name>` (e.g. `/brainstorm-phase`, `/start-phase`,
18
+ `/sync-docs`, `/complete-phase`, `/dispatch`, `/handoff`, `/continue`,
19
+ `/review-code`), `agy` reads the matching workflow file from
20
+ `.agents/workflows/<name>.md` and follows its numbered steps.
21
+
22
+ Workflows ship in two layers:
23
+
24
+ 1. **Core workflows** — momentum's cross-adapter phase + ecosystem commands. Installed from `core/commands/*.md` to `.agentss/workflows/*.md`. Examples: `brainstorm-phase`, `start-phase`, `sync-docs`, `complete-phase`, `track`, `validate`, `ecosystem`, `initiative`, `session`, `systematic-debug`.
25
+ 2. **Antigravity-specific workflows** — orchestration primitives with native parallel subagent fan-out. Installed from `adapters/antigravity/workflows/*.md`. Examples: `scout`, `dispatch`, `handoff`, `continue`, `review-code`.
26
+
27
+ To add a project-specific workflow, drop a Markdown file into
28
+ `.agents/workflows/<name>.md` with YAML frontmatter:
29
+
30
+ ```markdown
31
+ ---
32
+ description: One-line summary used for auto-detection
33
+ ---
34
+
35
+ ### 1. First step
36
+ ...
37
+
38
+ ### 2. Second step
39
+ ...
40
+ ```
41
+
42
+ Max 12,000 characters per workflow file. Use `// run workflow: <name>`
43
+ to compose workflows.
44
+
45
+ ## Skills = personas the agent loads to BECOME
46
+
47
+ Momentum installs five skills at `.agents/skills/`:
48
+
49
+ - **`momentum-orient`** — Read `specs/status.md` first. Codifies Rule 1.
50
+ - **`momentum-reviewer-security`** — OWASP/STRIDE security review persona.
51
+ - **`momentum-reviewer-qa`** — Test coverage / edge cases / regression risk.
52
+ - **`momentum-reviewer-architecture`** — Rule compliance / pattern consistency.
53
+ - **`swarm-supervisor`** — Phase 18 / v0.20.4. Per-repo supervisor persona spawned by `/swarm start`. Drives one repo's phase to completion under a pinned cwd. See `## Swarm — Lookup Pattern` below.
54
+
55
+ The three reviewer skills are loaded by the `/review-code` workflow,
56
+ which dispatches them in parallel via Antigravity's native subagent
57
+ fan-out, then consolidates findings. The swarm-supervisor skill is
58
+ loaded by each Wave-N supervisor on spawn; it is not invoked directly
59
+ by the user.
60
+
61
+ Add project-specific skills under `.agents/skills/<name>/SKILL.md` with
62
+ YAML frontmatter (`name`, `description`).
63
+
64
+ ## Swarm — Lookup Pattern
65
+
66
+ > Phase 18 / v0.20.4 — Antigravity parity of the Phase 17 + 17.5
67
+ > swarm primitive.
68
+
69
+ Momentum's swarm primitive — sustained parallel multi-project feature
70
+ delivery — ships on Antigravity as of v0.20.4. The user-facing
71
+ workflow lives at `.agents/workflows/swarm.md`; `agy` auto-registers it
72
+ as `/swarm`. The per-repo supervisor persona lives at
73
+ `.agents/skills/swarm-supervisor/SKILL.md`.
74
+
75
+ The CLI floor is `momentum swarm <sub> [args]`. The slash command and
76
+ the CLI produce the same on-disk artifacts.
77
+
78
+ | Subcommand | What it does |
79
+ |---|---|
80
+ | `start` | Plan + spawn Wave 1. Presents wave plan for approval before any spawn. |
81
+ | `status` | Render the materialized board cache. Read-only. |
82
+ | `tell` | Push a one-shot context note to one supervisor (`swarm-context.md`). |
83
+ | `broadcast` | Push context to every supervisor in the swarm. |
84
+ | `verify` | Contract verifier + manifest+brief drift check. |
85
+ | `complete` | Synthesize the cross-repo changeset and finalize the swarm. |
86
+ | `resume` | Re-attach this session to a swarm; renews owned leases. |
87
+ | `cancel` | Graceful halt; preserves all artifacts for forensics. |
88
+ | `budget` | Adjust a per-repo token budget. |
89
+ | `claim` | Multi-session ownership primitive (Phase 17.5). |
90
+ | `release` | Release ownership; idempotent. |
91
+ | `focus` | Issue a single-use focus token to hand a repo to a side session. |
92
+ | `join` | Register a second session as co-conductor; optionally consume a token. |
93
+ | `absorb` | Converge two swarms back into one (forensic-preserving). |
94
+ | `inbox` | Supervisor → conductor questions (`list` / `write` / `resolve`). |
95
+ | `preview-merge` | Dry-run `git merge --no-commit` per supervisor branch. |
96
+
97
+ **Spawn dispatch**: the conductor (this user session) dispatches spawns
98
+ through `adapters/antigravity/adapter.js::spawn(directive)` — which
99
+ shells `agy` with the supervisor skill as the persona and the
100
+ directive's `repoPath` as the cwd. Each supervisor BECOMES the
101
+ `swarm-supervisor` skill on boot.
102
+
103
+ **`agy` not on PATH**: `momentum swarm start --spawn` degrades to
104
+ dry-run and prints spawn directives the user can launch manually.
105
+
106
+ ## Plugins — global momentum skills (opt-in)
107
+
108
+ Antigravity plugins bundle skills into one namespaced, enable/disable-able
109
+ unit (`plugins/<name>/plugin.json` + `skills/`). Momentum can pack its five
110
+ skills as a native plugin:
111
+
112
+ ```bash
113
+ momentum antigravity plugin-pack # → .agents/plugins/momentum/ (this project)
114
+ momentum antigravity plugin-pack --global # → ~/.gemini/config/plugins/momentum/ (all workspaces)
115
+ ```
116
+
117
+ The `--global` form is the explicit opt-in way to make momentum's skills
118
+ available in every Antigravity workspace on this machine; a per-project
119
+ momentum install always takes priority (workspace beats global in the
120
+ discovery order). Hooks are deliberately not packed — they are
121
+ project-relative and ship via `momentum init`/`upgrade` only. Momentum never
122
+ installs the `agy` binary itself; `momentum doctor` points at the official
123
+ installer when it is missing.
124
+
125
+ ## Antigravity Native Artifacts Integration
126
+
127
+ When in planning mode or executing a phase, keep Antigravity's native artifacts in sync with momentum's spec files:
128
+
129
+ - **Durable Checklist**: Map `specs/phases/phase-N-*/tasks.md` directly into your native `task.md` artifact. Update both simultaneously as work proceeds.
130
+ - **Implementation Alignment**: Ensure that the `implementation_plan.md` artifact mirrors the scope and groups declared in `specs/phases/phase-N-*/plan.md`.
131
+ - **Walkthrough Evidence**: Append the verification evidence gathered for `/complete-phase` into your native `walkthrough.md` artifact.
132
+
133
+ ## Hooks
134
+
135
+ Antigravity hook wiring lives in `.agents/hooks.json` (named-group schema,
136
+ five lifecycle events — there is NO SessionStart event on Antigravity).
137
+ Hook commands run with CWD = `.agents/`, so momentum wires them through the
138
+ boundary shim `scripts/antigravity-hook-adapter.sh` (ADR-0006), which
139
+ translates Antigravity's camelCase payloads and response contract and
140
+ delegates to the same shared scripts every adapter uses:
141
+
142
+ | Named hook | Event | Matcher | Behavior |
143
+ |---|---|---|---|
144
+ | `momentum-brainstorm-gate` | `PreToolUse` | `write_to_file\|run_command\|.*write.*\|.*edit.*\|.*replace.*` | Blocks writes to `specs/` while a `/brainstorm-*` session is active (sentinel `.momentum/brainstorm-active`) — responds `{"decision":"deny","reason":…}`. |
145
+ | `momentum-history-reminder` | `PostToolUse` | same write-family matcher | Runs `check-history-reminder.sh`; reminders are QUEUED (PostToolUse has no message channel) and injected on the next model invocation (Rule 8). |
146
+ | `momentum-session-context` | `PreInvocation` | (flat — no matcher) | At `invocationNum 0`, runs `sessionstart-handoff.sh` and injects the pending-handoff banner + ecosystem context as an `ephemeralMessage`; every invocation also drains queued reminders. |
147
+
148
+ ### Session-start fallback
149
+
150
+ Injection depends on the vendor hook runner. The handoff pickup hint also
151
+ lives in this AGENTS.md primary-instruction text as a belt-and-braces
152
+ fallback: if a `.momentum/inbox/handoff-NNN.md` file exists at session
153
+ start, read it and acknowledge before continuing.
@@ -0,0 +1 @@
1
+ { "TASK_TOOL": "the native **task list** artifact (task.md)", "TASK_TOOL_NAME": "The task-list artifact" }
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env bash
2
+ # antigravity-hook-adapter.sh — Antigravity 2.x payload/response boundary shim.
3
+ #
4
+ # Phase 22b (ADR-0006). Antigravity's hook contract differs from Claude
5
+ # Code/Codex in payload shape (camelCase protojson, toolCall.args.*), response
6
+ # channel (stdout decision JSON, ALWAYS exit 0), hook CWD (the directory
7
+ # containing hooks.json — i.e. .agents/), and event set (five events, no
8
+ # SessionStart; PreInvocation injectSteps is the session-start mechanism).
9
+ # Contract source: specs/phases/phase-22b-antigravity-2-adoption/evidence/
10
+ # fact-sheet.md §5 (locked live against agy 1.0.16).
11
+ #
12
+ # This shim translates at the boundary and delegates to the shared core
13
+ # scripts UNCHANGED, so Claude Code + Codex behavior stays byte-identical:
14
+ #
15
+ # pre-tool → brainstorm-gate.sh exit 2/stderr → {"decision":"deny",...}
16
+ # post-tool → check-history-reminder.sh stdout → queued (PostToolUse
17
+ # has no message channel), respond {}
18
+ # pre-invocation → sessionstart-handoff.sh at invocationNum 0 + drain the
19
+ # queue → {"injectSteps":[{"ephemeralMessage": ...}]}
20
+ #
21
+ # Every failure path fails OPEN (allow / {}), and the script always exits 0 —
22
+ # non-zero is treated as hook infrastructure failure by the vendor runner.
23
+
24
+ set -u
25
+
26
+ MODE="${1:-}"
27
+ INPUT=$(cat 2>/dev/null || true)
28
+
29
+ respond_neutral() {
30
+ case "$MODE" in
31
+ pre-tool) printf '{"decision":"allow"}' ;;
32
+ *) printf '{}' ;;
33
+ esac
34
+ exit 0
35
+ }
36
+
37
+ [ -n "$MODE" ] || respond_neutral
38
+ command -v python3 >/dev/null 2>&1 || respond_neutral
39
+
40
+ # ── Parse the camelCase payload once ────────────────────────────────────────
41
+ eval "$(printf '%s' "$INPUT" | python3 -c '
42
+ import sys, json, shlex
43
+ try:
44
+ d = json.load(sys.stdin)
45
+ except Exception:
46
+ d = {}
47
+ ws = (d.get("workspacePaths") or [""])[0] or ""
48
+ tc = d.get("toolCall") or {}
49
+ args = tc.get("args") or {}
50
+ path = args.get("TargetFile") or args.get("AbsolutePath") or args.get("FilePath") or ""
51
+ cmd = args.get("CommandLine") or ""
52
+ print("AG_ROOT=%s" % shlex.quote(ws))
53
+ print("AG_TOOL=%s" % shlex.quote(tc.get("name") or ""))
54
+ print("AG_PATH=%s" % shlex.quote(path))
55
+ print("AG_CMD=%s" % shlex.quote(cmd))
56
+ print("AG_INVOCATION=%s" % shlex.quote(str(d.get("invocationNum", ""))))
57
+ ' 2>/dev/null)" 2>/dev/null || respond_neutral
58
+
59
+ # Hook CWD is .agents/ — fall back to its parent when the payload lacks
60
+ # workspacePaths (fail-open if neither resolves to a directory).
61
+ if [ -z "${AG_ROOT:-}" ] || [ ! -d "${AG_ROOT:-}" ]; then
62
+ AG_ROOT=$(cd .. 2>/dev/null && pwd || true)
63
+ fi
64
+ [ -n "${AG_ROOT:-}" ] && [ -d "$AG_ROOT" ] || respond_neutral
65
+
66
+ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
67
+ NOTICES="$AG_ROOT/.momentum/antigravity-notices"
68
+
69
+ # Relativize the tool path against the project root — the shared scripts
70
+ # match relative patterns like specs/status.md.
71
+ rel_path="${AG_PATH:-}"
72
+ case "$rel_path" in
73
+ "$AG_ROOT"/*) rel_path="${rel_path#"$AG_ROOT"/}" ;;
74
+ esac
75
+
76
+ # Legacy-shape payload for the shared scripts. run_command maps to Bash so
77
+ # the reminder script's session-append branch (git commit detection) works.
78
+ legacy_payload() {
79
+ python3 -c '
80
+ import json, sys
81
+ tool, path, cmd = sys.argv[1], sys.argv[2], sys.argv[3]
82
+ if tool == "run_command":
83
+ tool = "Bash"
84
+ elif tool and any(k in tool for k in ("write", "edit", "replace")):
85
+ # Normalize the whole Antigravity write-tool family to the canonical
86
+ # name the shared scripts already match — keeps core scripts untouched
87
+ # (byte-identical for Claude Code/Codex, ADR-0006).
88
+ tool = "write_to_file"
89
+ ti = {}
90
+ if path:
91
+ ti["file_path"] = path
92
+ if cmd:
93
+ ti["command"] = cmd
94
+ print(json.dumps({"tool_name": tool, "tool_input": ti}))
95
+ ' "${AG_TOOL:-}" "$rel_path" "${AG_CMD:-}"
96
+ }
97
+
98
+ case "$MODE" in
99
+ pre-tool)
100
+ err=$( { legacy_payload | MOMENTUM_PROJECT_DIR="$AG_ROOT" \
101
+ bash "$SCRIPT_DIR/brainstorm-gate.sh" >/dev/null; } 2>&1 )
102
+ rc=$?
103
+ if [ "$rc" -eq 2 ]; then
104
+ printf '%s' "$err" | python3 -c \
105
+ 'import json,sys; print(json.dumps({"decision":"deny","reason":sys.stdin.read()[:1000]}))'
106
+ else
107
+ printf '{"decision":"allow"}'
108
+ fi
109
+ ;;
110
+
111
+ post-tool)
112
+ out=$( { legacy_payload | ( cd "$AG_ROOT" && \
113
+ bash "$SCRIPT_DIR/check-history-reminder.sh" ); } 2>/dev/null || true )
114
+ if [ -n "$out" ]; then
115
+ mkdir -p "$AG_ROOT/.momentum" 2>/dev/null || true
116
+ printf '%s\n' "$out" >> "$NOTICES" 2>/dev/null || true
117
+ fi
118
+ printf '{}'
119
+ ;;
120
+
121
+ pre-invocation)
122
+ banner=""
123
+ if [ "${AG_INVOCATION:-}" = "0" ]; then
124
+ # Banner mode: non-TTY stdin → the handoff script prints to stderr and
125
+ # exits 0 without the interactive prompt.
126
+ banner=$( ( cd "$AG_ROOT" && \
127
+ bash "$SCRIPT_DIR/sessionstart-handoff.sh" </dev/null ) 2>&1 >/dev/null || true )
128
+ fi
129
+ notices=""
130
+ if [ -s "$NOTICES" ]; then
131
+ notices=$(cat "$NOTICES" 2>/dev/null || true)
132
+ : > "$NOTICES" 2>/dev/null || true
133
+ fi
134
+ python3 -c '
135
+ import json, sys
136
+ banner, notices = sys.argv[1], sys.argv[2]
137
+ msg = "\n".join(x for x in (banner.strip(), notices.strip()) if x)
138
+ print(json.dumps({"injectSteps": [{"ephemeralMessage": msg}]}) if msg else "{}")
139
+ ' "$banner" "$notices"
140
+ ;;
141
+
142
+ *)
143
+ respond_neutral
144
+ ;;
145
+ esac
146
+
147
+ exit 0
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: momentum-orient
3
+ description: Read specs/status.md before starting any work in a momentum-managed project. Activates at the start of every new task to ensure the agent has current phase context. Codifies Rule 1 (Orient First).
4
+ ---
5
+
6
+ # momentum-orient
7
+
8
+ When this skill activates (at session start or when the user asks you to
9
+ work on something new), read these files in order before any other action:
10
+
11
+ 1. `specs/status.md` — current phase, blockers, P0 items, next actions
12
+ 2. `specs/backlog/backlog.md` — P0/P1 items that may block the current task
13
+ 3. `specs/phases/<active-phase>/tasks.md` — what's done / in flight / blocked
14
+ 4. `AGENTS.md` — project rules and constraints (the complete rulebook)
15
+
16
+ Then proceed with the user's request, framing any output in terms of:
17
+ - which phase is active
18
+ - whether the requested work belongs in the active phase or is a side track
19
+ - any existing tasks or history entries that already cover the request
20
+
21
+ This skill is shipped by the momentum toolkit. It codifies Rule 1 (Orient
22
+ First) from the project rules. See `AGENTS.md` for the full set of rules.
23
+
24
+ ## When NOT to apply this skill
25
+
26
+ - If the user's message is purely conversational ("what is X?") and doesn't
27
+ require touching the codebase, you don't need to orient.
28
+ - If you've already oriented this session and nothing on disk has changed
29
+ since, don't re-orient.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: momentum-reviewer-architecture
3
+ description: Review a code diff for architectural fit, rule compliance, and pattern consistency. Returns Critical/Important/Minor findings only — does not modify code, does not refactor. Loaded by the review-code workflow alongside the security and QA reviewers.
4
+ ---
5
+
6
+ # momentum-reviewer-architecture
7
+
8
+ You are an architecture-focused code reviewer dispatched by the momentum
9
+ toolkit. You will receive a code diff and the project's full rules
10
+ (AGENTS.md — the complete rulebook).
11
+
12
+ **YOUR LENS**: architectural fit, rule compliance, pattern consistency.
13
+
14
+ ## What to ask for each change
15
+
16
+ - Does it violate any of the 12 autonomous rules (orient first, update tracking, auto-track discoveries, pre-phase bug check, phase boundary awareness, git lifecycle, plan before implementing, record history, doc sync protocol, architecture stability, evaluator discipline, verify before claim)?
17
+ - Does it match the patterns established elsewhere in the codebase? Read 2-3 nearby files for convention.
18
+ - Does it create hidden coupling, a leaky abstraction, or an adapter/contract violation? (For momentum specifically: every capability declaration uniform-boolean; overlay subdirs use the destinations contract; adapter-specific code stays in adapters/, generic in core/.)
19
+ - Is it documented where rules say it should be (history.md entry, ADR for decisional changes, backlog entry for discovered issues)?
20
+ - Does the commit message convention match (feat / fix / docs / etc.)?
21
+
22
+ ## Output format — return EXACTLY this structure
23
+
24
+ ```
25
+ ## Architecture review
26
+
27
+ ### Critical
28
+ - [finding] (file:line) — [why it's critical]
29
+
30
+ ### Important
31
+ - [finding] (file:line) — [explanation]
32
+
33
+ ### Minor
34
+ - [finding] (file:line) — [explanation]
35
+ ```
36
+
37
+ If no findings at a severity level, write "(none)". Do NOT speculate
38
+ beyond what the diff shows. Do NOT refactor yourself — flag the issue.
39
+ Do NOT modify any files.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: momentum-reviewer-qa
3
+ description: Review a code diff for test coverage, edge cases, and regression risk. Returns Critical/Important/Minor findings only — does not modify code, does not write tests. Loaded by the review-code workflow alongside the security and architecture reviewers.
4
+ ---
5
+
6
+ # momentum-reviewer-qa
7
+
8
+ You are a QA-focused code reviewer dispatched by the momentum toolkit.
9
+ You will receive a code diff and a project-rules excerpt (especially
10
+ Rule 12 — Verify Before Claim).
11
+
12
+ **YOUR LENS**: test coverage, edge cases, regression risk.
13
+
14
+ ## What to ask for each meaningful behavior change
15
+
16
+ - Is there a test that exercises it? If yes, does it test the happy path AND at least one edge case?
17
+ - What edge cases are uncovered? Consider: empty input, large input, concurrent access, error paths, network/IO failures, malformed data, Unicode / non-ASCII, very long strings, off-by-one boundaries.
18
+ - Could this change break an existing test or production path? Look for callers of any modified function.
19
+ - Does the change add a verification command, or rely on "should work now" — Rule 12 territory.
20
+
21
+ ## Output format — return EXACTLY this structure
22
+
23
+ ```
24
+ ## QA review
25
+
26
+ ### Critical
27
+ - [finding] (file:line) — [why it's critical]
28
+
29
+ ### Important
30
+ - [finding] (file:line) — [explanation]
31
+
32
+ ### Minor
33
+ - [finding] (file:line) — [explanation]
34
+ ```
35
+
36
+ If no findings at a severity level, write "(none)". Do NOT speculate
37
+ beyond what the diff shows. Do NOT write tests yourself — flag the gap.
38
+ Do NOT modify any files.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: momentum-reviewer-security
3
+ description: Review a code diff through a security lens (OWASP Top 10, STRIDE threat categories). Returns Critical/Important/Minor findings only — does not modify code, does not propose fixes. Loaded by the review-code workflow alongside the QA and architecture reviewers.
4
+ ---
5
+
6
+ # momentum-reviewer-security
7
+
8
+ You are a security-focused code reviewer dispatched by the momentum
9
+ toolkit. You will receive a code diff and a project-rules excerpt.
10
+
11
+ **YOUR LENS**: OWASP Top 10 + STRIDE threat categories.
12
+
13
+ ## What to look for
14
+
15
+ - Hard-coded secrets, credentials, API keys
16
+ - SQL/NoSQL injection vectors, unparameterized queries
17
+ - XSS / SSRF / CSRF surfaces in any user-controlled input path
18
+ - Authentication / authorization gaps in newly added endpoints
19
+ - Insecure deserialization, prototype pollution
20
+ - Logging of sensitive data (PII, tokens)
21
+ - Race conditions / TOCTOU in security-relevant code paths
22
+ - Cryptographic anti-patterns (weak algorithms, fixed IVs, MD5/SHA1 for security, broken random sources)
23
+ - Dependency additions of known-vulnerable packages
24
+
25
+ ## Output format — return EXACTLY this structure
26
+
27
+ ```
28
+ ## Security review
29
+
30
+ ### Critical
31
+ - [finding] (file:line) — [why it's critical]
32
+
33
+ ### Important
34
+ - [finding] (file:line) — [explanation]
35
+
36
+ ### Minor
37
+ - [finding] (file:line) — [explanation]
38
+ ```
39
+
40
+ If no findings at a severity level, write "(none)". Do NOT speculate
41
+ beyond what the diff shows. Do NOT propose code fixes — flag only.
42
+ Do NOT modify any files. Do NOT run any code-modifying commands.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: swarm-supervisor
3
+ description: Drive a single repo through its phase as part of a swarm. Activates when spawned by the conductor (the user's primary session) with a spawn directive. State lives in files; the conductor reads board.json between turns. Loads on the swarm-supervisor invocation only — not invoked directly by the user.
4
+ ---
5
+
6
+ # swarm-supervisor
7
+
8
+ You are a swarm supervisor for one repo. The conductor (the user's primary
9
+ session) spawned you with a spawn directive containing:
10
+
11
+ - `repoPath`: your pinned cwd; never cd out of it
12
+ - `phaseSlug`: the phase you are driving (`specs/phases/<slug>/`)
13
+ - `swarmId`: the swarm you belong to (manifest at `<eco>/swarms/<id>/`)
14
+ - `wave`: your wave index (1-based)
15
+ - `sessionId`: the conductor's session id
16
+ - `recipePath`: absolute path to `supervise.md` — your operating recipe
17
+
18
+ ## Boot sequence
19
+
20
+ 1. **Read the recipe at `recipePath` end-to-end.** Treat it as your
21
+ operating manual for this session.
22
+ 2. **Read your brief** at `specs/phases/<phase-slug>/overview.md`. The
23
+ brief's frontmatter (`swarm`, `wave`, `initiative`,
24
+ `claimed_by_session`) was populated by the conductor.
25
+ 3. **Read `specs/status.md`** per Rule 1 (orient first).
26
+ 4. **Begin the normal momentum lifecycle inside this repo**: `/start-phase`
27
+ → implement → `/sync-docs` → `/complete-phase`. Each phase command is
28
+ a workflow at `.agents/workflows/<name>.md` — invoke them by name.
29
+
30
+ ## Operating constraints
31
+
32
+ - **Stay in `repoPath`.** Never `cd` to a sibling repo. Cross-repo
33
+ concerns go through the inbox primitive at
34
+ `<eco>/swarms/<swarm-id>/inbox/`.
35
+ - **State lives in files.** Append to `history.md` per Rule 8; the
36
+ conductor reads `board.json` between turns to render progress to the
37
+ user.
38
+ - **The conductor may push context** via `swarm-context.md` at
39
+ `specs/phases/<phase-slug>/swarm-context.md`. Read it at the top of
40
+ every turn.
41
+ - **If you have a question only the conductor can answer**, write it to
42
+ the swarm inbox via:
43
+
44
+ ```bash
45
+ momentum swarm inbox write <swarm-id> --repo <your-repo-id> \
46
+ --slug <short-slug> --question "<text>"
47
+ ```
48
+
49
+ Then wait for resolution before continuing — do NOT guess.
50
+ - **When your phase is complete**, run `/complete-phase` per the
51
+ standard workflow; the supervisor finishes after the phase is
52
+ verified and pushed.
53
+
54
+ ## Native artifacts integration
55
+
56
+ While supervising, keep Antigravity's native artifacts in sync with
57
+ momentum's spec files (same contract as standalone phase work):
58
+
59
+ - **Durable Checklist**: Map `specs/phases/phase-N-*/tasks.md` into
60
+ your native `task.md` artifact. Update both simultaneously.
61
+ - **Implementation Alignment**: Mirror `specs/phases/phase-N-*/plan.md`
62
+ into `implementation_plan.md`.
63
+ - **Walkthrough Evidence**: Append `/complete-phase` verification
64
+ evidence to `walkthrough.md`.
65
+
66
+ ## You are NOT the conductor
67
+
68
+ You do not own `<eco>/swarms/<id>/manifest.json`, `board.json`,
69
+ `contracts/`, or `inbox/INDEX.md`. The conductor session owns those
70
+ files. You own:
71
+
72
+ - `specs/phases/phase-N-<slug>/*` (your phase scope inside this repo)
73
+ - `.momentum/runs/dispatch-run-<id>.json` (your status emitter)
74
+
75
+ You inherit every always-on rule from `AGENTS.md` (the complete rulebook).
@@ -0,0 +1,39 @@
1
+ ---
2
+ description: Pick up a pending handoff in this repo. Reads .momentum/inbox/handoff-NNN.md, parses the structured context, acknowledges, moves the artifact to inbox/read/. Use when the user mentions a handoff or when the SessionStart hook indicates one is pending.
3
+ ---
4
+
5
+ # continue
6
+
7
+ ### 1. Find the handoff
8
+
9
+ List files in `.momentum/inbox/` matching `handoff-*.md`. If none, tell the user "no pending handoff" and stop.
10
+
11
+ If multiple, pick the oldest (lowest N) unless the user named a specific one.
12
+
13
+ ### 2. Read and parse
14
+
15
+ Read the chosen handoff file. Extract:
16
+
17
+ - **From**: source repo
18
+ - **Why**: the handoff reason
19
+ - **State at handoff**: phase + last action
20
+ - **What's next**: first action to take
21
+ - **References**: files to read first
22
+
23
+ ### 3. Acknowledge to user
24
+
25
+ Print a one-line acknowledgement: `picking up handoff-NNN from <source>` followed by the "What's next" content. Read the referenced files before proceeding.
26
+
27
+ ### 4. Move the artifact
28
+
29
+ Move the file from `.momentum/inbox/handoff-NNN.md` to `.momentum/inbox/read/handoff-NNN.md` so the next session doesn't re-pick-up the same handoff. Create the `read/` subdir if missing.
30
+
31
+ ### 5. Proceed with the work
32
+
33
+ Continue with the action described in "What's next". Honor the project's Rule 1 — read `specs/status.md` before any work, even after a handoff.
34
+
35
+ ## Constraints
36
+
37
+ - Never delete a handoff — move to `read/` for audit history.
38
+ - If the handoff references files that don't exist, surface the gap to the user; don't silently proceed.
39
+ - If the source repo's "What's next" conflicts with the active phase here, ask the user before acting.
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: Parallel multi-repo fan-out + synthesis. Spawns one subagent per listed repo with auto-tailored prompts, waits for all, synthesizes their findings into a single consolidated report. Use for cross-repo investigations or audits.
3
+ ---
4
+
5
+ # dispatch
6
+
7
+ ### 1. Resolve targets and the dispatch prompt
8
+
9
+ Identify the list of target ecosystem members (member ids or `--all` for every member) and the dispatch prompt from the user's input. If either is missing, ask for it and stop until they answer.
10
+
11
+ ### 2. Tailor the prompt per target
12
+
13
+ For each target, build a per-repo prompt that:
14
+
15
+ - States the dispatch question explicitly
16
+ - Tells the subagent to read `specs/status.md` + relevant rules first
17
+ - Asks for a structured response: findings, blockers, recommended action
18
+ - Names the repo so the subagent knows its context
19
+
20
+ ### 3. Fan out subagents in parallel
21
+
22
+ Use Antigravity's native parallel subagent capability to spawn one subagent per target in a single turn. Each subagent receives its tailored prompt and the target repo path as the working directory.
23
+
24
+ ### 4. Wait + collect
25
+
26
+ Wait until all subagents return. If any subagent errors or times out, record the failure but do not block the synthesis on the survivors.
27
+
28
+ ### 5. Synthesize
29
+
30
+ Produce a single consolidated report with these sections:
31
+
32
+ - **Mode**: parallel (N targets)
33
+ - **Findings**: per-target structured summary, with consistent fields per repo
34
+ - **Cross-cutting patterns**: themes that appeared in ≥2 targets
35
+ - **Recommended next action**: 1–3 concrete proposals, ranked
36
+
37
+ ### 6. Write the dispatch artifact
38
+
39
+ Append the full synthesis to `.momentum/runs/dispatch-<NNN>.md` so the result is durable across sessions.
40
+
41
+ ### 7. Return to user
42
+
43
+ Present the synthesis. Note any subagent failures explicitly. If the user wants to act on a finding, route them to `/initiative create` (for cross-repo work) or to file a per-repo backlog item.
44
+
45
+ ## Constraints
46
+
47
+ - Subagents are dispatched in PARALLEL, not sequentially.
48
+ - If only one target is given, suggest `/scout` instead and ask the user to confirm.
49
+ - Synthesis must clearly attribute findings to source repos (one repo can't speak for the others).
@@ -0,0 +1,38 @@
1
+ ---
2
+ description: Cross-session control transfer with a structured context block. Writes a handoff artifact to the target repo's .momentum/inbox/ so the receiving session can pick up where this one left off. Use when the work must continue in a different repo or after a session boundary.
3
+ ---
4
+
5
+ # handoff
6
+
7
+ ### 1. Resolve target
8
+
9
+ Identify the target repo (ecosystem member id or path) and the handoff summary from the user's input. The summary should be 1–3 sentences describing what the receiver should continue.
10
+
11
+ ### 2. Build the context block
12
+
13
+ Compose a handoff message with these sections:
14
+
15
+ - **From**: this repo id
16
+ - **To**: target repo id
17
+ - **Why**: 1–3 sentence summary (the user's input)
18
+ - **State at handoff**: active phase, last meaningful action, any open decisions
19
+ - **What's next**: what the receiver should do first
20
+ - **References**: file paths the receiver should read first (status.md, the active phase tasks.md, any open initiative)
21
+
22
+ ### 3. Write the handoff artifact
23
+
24
+ Write the composed handoff to `<target-repo>/.momentum/inbox/handoff-<NNN>.md` where N is the next sequential number. Create the inbox directory if missing.
25
+
26
+ ### 4. Log to session log
27
+
28
+ Append a one-line entry to the ecosystem session log noting `handoff: from <source> → <target>` so cross-repo coordination is visible.
29
+
30
+ ### 5. Confirm to user
31
+
32
+ Tell the user the handoff was written, name the artifact path, and remind them to acknowledge in the receiving session via `/continue`.
33
+
34
+ ## Constraints
35
+
36
+ - Handoffs are write-once — never overwrite an existing `handoff-<NNN>.md`. Increment N.
37
+ - The target repo's `.momentum/inbox/` must exist (create if missing).
38
+ - A handoff is NOT a synchronous transfer — the receiver picks it up on next session start (via the SessionStart hook) or by explicit `/continue`.