@zhixuan92/multi-model-agent 5.0.2 → 5.0.3

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 (255) hide show
  1. package/README.md +8 -18
  2. package/dist/cli/index.d.ts +62 -0
  3. package/dist/cli/index.d.ts.map +1 -0
  4. package/dist/cli/index.js +345 -0
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/cli/info.d.ts +22 -0
  7. package/dist/cli/info.d.ts.map +1 -0
  8. package/dist/cli/info.js +100 -0
  9. package/dist/cli/info.js.map +1 -0
  10. package/dist/cli/logs.d.ts +15 -0
  11. package/dist/cli/logs.d.ts.map +1 -0
  12. package/dist/cli/logs.js +102 -0
  13. package/dist/cli/logs.js.map +1 -0
  14. package/dist/cli/print-token.d.ts +18 -0
  15. package/dist/cli/print-token.d.ts.map +1 -0
  16. package/dist/cli/print-token.js +60 -0
  17. package/dist/cli/print-token.js.map +1 -0
  18. package/dist/cli/serve.d.ts +28 -0
  19. package/dist/cli/serve.d.ts.map +1 -0
  20. package/dist/cli/serve.js +405 -0
  21. package/dist/cli/serve.js.map +1 -0
  22. package/dist/cli/status.d.ts +49 -0
  23. package/dist/cli/status.d.ts.map +1 -0
  24. package/dist/cli/status.js +155 -0
  25. package/dist/cli/status.js.map +1 -0
  26. package/dist/cli/sync-skills.d.ts +58 -0
  27. package/dist/cli/sync-skills.d.ts.map +1 -0
  28. package/dist/cli/sync-skills.js +266 -0
  29. package/dist/cli/sync-skills.js.map +1 -0
  30. package/dist/cli/telemetry.d.ts +10 -0
  31. package/dist/cli/telemetry.d.ts.map +1 -0
  32. package/dist/cli/telemetry.js +161 -0
  33. package/dist/cli/telemetry.js.map +1 -0
  34. package/dist/cli/toggle.d.ts +26 -0
  35. package/dist/cli/toggle.d.ts.map +1 -0
  36. package/dist/cli/toggle.js +185 -0
  37. package/dist/cli/toggle.js.map +1 -0
  38. package/dist/http/async-dispatch.d.ts +44 -0
  39. package/dist/http/async-dispatch.d.ts.map +1 -0
  40. package/dist/http/async-dispatch.js +175 -0
  41. package/dist/http/async-dispatch.js.map +1 -0
  42. package/dist/http/auth.d.ts +20 -0
  43. package/dist/http/auth.d.ts.map +1 -0
  44. package/dist/http/auth.js +56 -0
  45. package/dist/http/auth.js.map +1 -0
  46. package/dist/http/canonicalize-file-paths.d.ts +8 -0
  47. package/dist/http/canonicalize-file-paths.d.ts.map +1 -0
  48. package/dist/http/canonicalize-file-paths.js +43 -0
  49. package/dist/http/canonicalize-file-paths.js.map +1 -0
  50. package/dist/http/cwd-validator.d.ts +11 -0
  51. package/dist/http/cwd-validator.d.ts.map +1 -0
  52. package/dist/http/cwd-validator.js +130 -0
  53. package/dist/http/cwd-validator.js.map +1 -0
  54. package/dist/http/errors.d.ts +4 -0
  55. package/dist/http/errors.d.ts.map +1 -0
  56. package/dist/http/errors.js +9 -0
  57. package/dist/http/errors.js.map +1 -0
  58. package/dist/http/execution-context.d.ts +18 -0
  59. package/dist/http/execution-context.d.ts.map +1 -0
  60. package/dist/http/execution-context.js +61 -0
  61. package/dist/http/execution-context.js.map +1 -0
  62. package/dist/http/handler-deps.d.ts +19 -0
  63. package/dist/http/handler-deps.d.ts.map +1 -0
  64. package/dist/http/handler-deps.js +2 -0
  65. package/dist/http/handler-deps.js.map +1 -0
  66. package/dist/http/handlers/control/batch-slice.d.ts +4 -0
  67. package/dist/http/handlers/control/batch-slice.d.ts.map +1 -0
  68. package/dist/http/handlers/control/batch-slice.js +40 -0
  69. package/dist/http/handlers/control/batch-slice.js.map +1 -0
  70. package/dist/http/handlers/control/batch.d.ts +23 -0
  71. package/dist/http/handlers/control/batch.d.ts.map +1 -0
  72. package/dist/http/handlers/control/batch.js +332 -0
  73. package/dist/http/handlers/control/batch.js.map +1 -0
  74. package/dist/http/handlers/control/context-blocks.d.ts +22 -0
  75. package/dist/http/handlers/control/context-blocks.d.ts.map +1 -0
  76. package/dist/http/handlers/control/context-blocks.js +111 -0
  77. package/dist/http/handlers/control/context-blocks.js.map +1 -0
  78. package/dist/http/handlers/introspection/health.d.ts +20 -0
  79. package/dist/http/handlers/introspection/health.d.ts.map +1 -0
  80. package/dist/http/handlers/introspection/health.js +18 -0
  81. package/dist/http/handlers/introspection/health.js.map +1 -0
  82. package/dist/http/handlers/introspection/status.d.ts +26 -0
  83. package/dist/http/handlers/introspection/status.d.ts.map +1 -0
  84. package/dist/http/handlers/introspection/status.js +136 -0
  85. package/dist/http/handlers/introspection/status.js.map +1 -0
  86. package/dist/http/handlers/tools/audit.d.ts +4 -0
  87. package/dist/http/handlers/tools/audit.d.ts.map +1 -0
  88. package/dist/http/handlers/tools/audit.js +43 -0
  89. package/dist/http/handlers/tools/audit.js.map +1 -0
  90. package/dist/http/handlers/tools/debug.d.ts +4 -0
  91. package/dist/http/handlers/tools/debug.d.ts.map +1 -0
  92. package/dist/http/handlers/tools/debug.js +43 -0
  93. package/dist/http/handlers/tools/debug.js.map +1 -0
  94. package/dist/http/handlers/tools/delegate.d.ts +4 -0
  95. package/dist/http/handlers/tools/delegate.d.ts.map +1 -0
  96. package/dist/http/handlers/tools/delegate.js +43 -0
  97. package/dist/http/handlers/tools/delegate.js.map +1 -0
  98. package/dist/http/handlers/tools/execute-plan.d.ts +4 -0
  99. package/dist/http/handlers/tools/execute-plan.d.ts.map +1 -0
  100. package/dist/http/handlers/tools/execute-plan.js +45 -0
  101. package/dist/http/handlers/tools/execute-plan.js.map +1 -0
  102. package/dist/http/handlers/tools/investigate.d.ts +4 -0
  103. package/dist/http/handlers/tools/investigate.d.ts.map +1 -0
  104. package/dist/http/handlers/tools/investigate.js +64 -0
  105. package/dist/http/handlers/tools/investigate.js.map +1 -0
  106. package/dist/http/handlers/tools/journal-recall.d.ts +4 -0
  107. package/dist/http/handlers/tools/journal-recall.d.ts.map +1 -0
  108. package/dist/http/handlers/tools/journal-recall.js +40 -0
  109. package/dist/http/handlers/tools/journal-recall.js.map +1 -0
  110. package/dist/http/handlers/tools/journal-record.d.ts +8 -0
  111. package/dist/http/handlers/tools/journal-record.d.ts.map +1 -0
  112. package/dist/http/handlers/tools/journal-record.js +40 -0
  113. package/dist/http/handlers/tools/journal-record.js.map +1 -0
  114. package/dist/http/handlers/tools/research.d.ts +4 -0
  115. package/dist/http/handlers/tools/research.d.ts.map +1 -0
  116. package/dist/http/handlers/tools/research.js +64 -0
  117. package/dist/http/handlers/tools/research.js.map +1 -0
  118. package/dist/http/handlers/tools/retry.d.ts +4 -0
  119. package/dist/http/handlers/tools/retry.d.ts.map +1 -0
  120. package/dist/http/handlers/tools/retry.js +73 -0
  121. package/dist/http/handlers/tools/retry.js.map +1 -0
  122. package/dist/http/handlers/tools/review.d.ts +4 -0
  123. package/dist/http/handlers/tools/review.d.ts.map +1 -0
  124. package/dist/http/handlers/tools/review.js +43 -0
  125. package/dist/http/handlers/tools/review.js.map +1 -0
  126. package/dist/http/journal-lock.d.ts +4 -0
  127. package/dist/http/journal-lock.d.ts.map +1 -0
  128. package/dist/http/journal-lock.js +34 -0
  129. package/dist/http/journal-lock.js.map +1 -0
  130. package/dist/http/middleware/body-reader.d.ts +16 -0
  131. package/dist/http/middleware/body-reader.d.ts.map +1 -0
  132. package/dist/http/middleware/body-reader.js +44 -0
  133. package/dist/http/middleware/body-reader.js.map +1 -0
  134. package/dist/http/middleware/caller-identity.d.ts +16 -0
  135. package/dist/http/middleware/caller-identity.d.ts.map +1 -0
  136. package/dist/http/middleware/caller-identity.js +16 -0
  137. package/dist/http/middleware/caller-identity.js.map +1 -0
  138. package/dist/http/middleware/decompress.d.ts +14 -0
  139. package/dist/http/middleware/decompress.d.ts.map +1 -0
  140. package/dist/http/middleware/decompress.js +51 -0
  141. package/dist/http/middleware/decompress.js.map +1 -0
  142. package/dist/http/project-registry.d.ts +54 -0
  143. package/dist/http/project-registry.d.ts.map +1 -0
  144. package/dist/http/project-registry.js +130 -0
  145. package/dist/http/project-registry.js.map +1 -0
  146. package/dist/http/request-observability.d.ts +8 -0
  147. package/dist/http/request-observability.d.ts.map +1 -0
  148. package/dist/http/request-observability.js +20 -0
  149. package/dist/http/request-observability.js.map +1 -0
  150. package/dist/http/request-pipeline.d.ts +16 -0
  151. package/dist/http/request-pipeline.d.ts.map +1 -0
  152. package/dist/http/request-pipeline.js +144 -0
  153. package/dist/http/request-pipeline.js.map +1 -0
  154. package/dist/http/server.d.ts +17 -0
  155. package/dist/http/server.d.ts.map +1 -0
  156. package/dist/http/server.js +300 -0
  157. package/dist/http/server.js.map +1 -0
  158. package/dist/http/types.d.ts +20 -0
  159. package/dist/http/types.d.ts.map +1 -0
  160. package/dist/http/types.js +2 -0
  161. package/dist/http/types.js.map +1 -0
  162. package/dist/skill-install/disabled-state.d.ts +35 -0
  163. package/dist/skill-install/disabled-state.d.ts.map +1 -0
  164. package/dist/skill-install/disabled-state.js +96 -0
  165. package/dist/skill-install/disabled-state.js.map +1 -0
  166. package/dist/skill-install/discover.d.ts +29 -0
  167. package/dist/skill-install/discover.d.ts.map +1 -0
  168. package/dist/skill-install/discover.js +104 -0
  169. package/dist/skill-install/discover.js.map +1 -0
  170. package/dist/skill-install/include-utils.d.ts +27 -0
  171. package/dist/skill-install/include-utils.d.ts.map +1 -0
  172. package/dist/skill-install/include-utils.js +90 -0
  173. package/dist/skill-install/include-utils.js.map +1 -0
  174. package/dist/skill-install/manifest.d.ts +82 -0
  175. package/dist/skill-install/manifest.d.ts.map +1 -0
  176. package/dist/skill-install/manifest.js +215 -0
  177. package/dist/skill-install/manifest.js.map +1 -0
  178. package/dist/skill-install/skill-installer-common.d.ts +26 -0
  179. package/dist/skill-install/skill-installer-common.d.ts.map +1 -0
  180. package/dist/skill-install/skill-installer-common.js +139 -0
  181. package/dist/skill-install/skill-installer-common.js.map +1 -0
  182. package/dist/skill-install/skill-installers/claude-code.d.ts +43 -0
  183. package/dist/skill-install/skill-installers/claude-code.d.ts.map +1 -0
  184. package/dist/skill-install/skill-installers/claude-code.js +65 -0
  185. package/dist/skill-install/skill-installers/claude-code.js.map +1 -0
  186. package/dist/skill-install/skill-installers/codex-cli.d.ts +27 -0
  187. package/dist/skill-install/skill-installers/codex-cli.d.ts.map +1 -0
  188. package/dist/skill-install/skill-installers/codex-cli.js +84 -0
  189. package/dist/skill-install/skill-installers/codex-cli.js.map +1 -0
  190. package/dist/skill-install/skill-installers/cursor.d.ts +72 -0
  191. package/dist/skill-install/skill-installers/cursor.d.ts.map +1 -0
  192. package/dist/skill-install/skill-installers/cursor.js +81 -0
  193. package/dist/skill-install/skill-installers/cursor.js.map +1 -0
  194. package/dist/skill-install/skill-installers/gemini-cli.d.ts +50 -0
  195. package/dist/skill-install/skill-installers/gemini-cli.d.ts.map +1 -0
  196. package/dist/skill-install/skill-installers/gemini-cli.js +72 -0
  197. package/dist/skill-install/skill-installers/gemini-cli.js.map +1 -0
  198. package/dist/skill-install/skill-manifest-sync.d.ts +11 -0
  199. package/dist/skill-install/skill-manifest-sync.d.ts.map +1 -0
  200. package/dist/skill-install/skill-manifest-sync.js +65 -0
  201. package/dist/skill-install/skill-manifest-sync.js.map +1 -0
  202. package/dist/skills/_shared/auth.md +41 -0
  203. package/dist/skills/_shared/error-handling.md +31 -0
  204. package/dist/skills/_shared/polling.md +88 -0
  205. package/dist/skills/_shared/response-shape.md +55 -0
  206. package/dist/skills/_shared/review-policy.md +15 -0
  207. package/dist/skills/mma-audit/SKILL.md +270 -0
  208. package/dist/skills/mma-context-blocks/SKILL.md +148 -0
  209. package/dist/skills/mma-debug/SKILL.md +208 -0
  210. package/dist/skills/mma-delegate/SKILL.md +216 -0
  211. package/dist/skills/mma-execute-plan/SKILL.md +214 -0
  212. package/dist/skills/mma-explore/SKILL.md +190 -0
  213. package/dist/skills/mma-investigate/SKILL.md +258 -0
  214. package/dist/skills/mma-journal-recall/SKILL.md +242 -0
  215. package/dist/skills/mma-journal-record/SKILL.md +202 -0
  216. package/dist/skills/mma-research/SKILL.md +223 -0
  217. package/dist/skills/mma-retry/SKILL.md +221 -0
  218. package/dist/skills/mma-review/SKILL.md +209 -0
  219. package/dist/skills/multi-model-agent/SKILL.md +206 -0
  220. package/dist/telemetry/consent.d.ts +4 -0
  221. package/dist/telemetry/consent.d.ts.map +1 -0
  222. package/dist/telemetry/consent.js +40 -0
  223. package/dist/telemetry/consent.js.map +1 -0
  224. package/dist/telemetry/flusher.d.ts +19 -0
  225. package/dist/telemetry/flusher.d.ts.map +1 -0
  226. package/dist/telemetry/flusher.js +277 -0
  227. package/dist/telemetry/flusher.js.map +1 -0
  228. package/dist/telemetry/generation.d.ts +9 -0
  229. package/dist/telemetry/generation.d.ts.map +1 -0
  230. package/dist/telemetry/generation.js +33 -0
  231. package/dist/telemetry/generation.js.map +1 -0
  232. package/dist/telemetry/identity.d.ts +9 -0
  233. package/dist/telemetry/identity.d.ts.map +1 -0
  234. package/dist/telemetry/identity.js +35 -0
  235. package/dist/telemetry/identity.js.map +1 -0
  236. package/dist/telemetry/install-id.d.ts +13 -0
  237. package/dist/telemetry/install-id.d.ts.map +1 -0
  238. package/dist/telemetry/install-id.js +49 -0
  239. package/dist/telemetry/install-id.js.map +1 -0
  240. package/dist/telemetry/install-meta.d.ts +10 -0
  241. package/dist/telemetry/install-meta.d.ts.map +1 -0
  242. package/dist/telemetry/install-meta.js +15 -0
  243. package/dist/telemetry/install-meta.js.map +1 -0
  244. package/dist/telemetry/queue.d.ts +35 -0
  245. package/dist/telemetry/queue.d.ts.map +1 -0
  246. package/dist/telemetry/queue.js +287 -0
  247. package/dist/telemetry/queue.js.map +1 -0
  248. package/dist/telemetry/recorder.d.ts +39 -0
  249. package/dist/telemetry/recorder.d.ts.map +1 -0
  250. package/dist/telemetry/recorder.js +173 -0
  251. package/dist/telemetry/recorder.js.map +1 -0
  252. package/package.json +43 -24
  253. package/scripts/postinstall.js +36 -0
  254. package/bin/mmagent.mjs +0 -47
  255. package/postinstall.mjs +0 -8
@@ -0,0 +1,190 @@
1
+ ---
2
+ name: mma-explore
3
+ description: >-
4
+ Use when about to brainstorm or plan and need a divergent landscape scan —
5
+ orchestrates parallel internal-codebase investigation + external multi-source
6
+ research + prior-learnings recall from the project journal, then synthesises
7
+ 3–5 distinct directions. Not for "where is X" single-answer questions (use
8
+ mma-investigate).
9
+ when_to_use: >-
10
+ You are about to brainstorm or plan and need a broad landscape scan before
11
+ narrowing. The question is exploratory ("what are our options", "what
12
+ approaches exist", "survey how others handle"). The skill instructs you to fan
13
+ out mma-investigate (internal), mma-research (external), and
14
+ mma-journal-recall (prior learnings/decisions) in parallel and synthesise the
15
+ results yourself. DO NOT use for convergent single-answer questions — those
16
+ are mma-investigate.
17
+ version: 5.0.3
18
+ ---
19
+
20
+ # mma-explore
21
+
22
+ ## Overview
23
+
24
+ Codebase + external sources + prior learnings, synthesised into 3–5 distinct
25
+ directions. Three delegated calls run in parallel — `mma-investigate` (internal
26
+ codebase), `mma-research` (external sources), and `mma-journal-recall` (what
27
+ this project already learned/decided, from the `.mmagent/journal/` graph) —
28
+ and **you** synthesise their results into the final output.
29
+
30
+ **Core principle:** Exploration is divergent (survey, enumerate, compare).
31
+ Synthesis turns raw threads into ranked, citable directions. The three legs
32
+ are delegated; the synthesis is your judgment work and stays in main context.
33
+ The journal leg is what keeps you from re-proposing a direction the project
34
+ already tried and dropped — it grounds the scan in your own history, not just
35
+ the code and the outside world.
36
+
37
+ ## When to Use
38
+
39
+ First decision — output shape:
40
+ - Want **one** synthesised answer with citations? → use `mma-investigate` (don't continue here)
41
+ - Want **multiple** distinct directions to weigh (3–5 threads + cross-thread synthesis)? → continue here
42
+
43
+ Internal-vs-external is not your decision; explore always runs both.
44
+
45
+ ```dot
46
+ digraph when_to_use {
47
+ "Exploratory question?" [shape=diamond];
48
+ "Convergent single-answer?" [shape=diamond];
49
+ "About to brainstorm/plan?" [shape=diamond];
50
+ "mma-explore" [shape=box];
51
+ "mma-investigate" [shape=box];
52
+ "Inline search (1–2 queries)" [shape=box];
53
+
54
+ "Exploratory question?" -> "Convergent single-answer?";
55
+ "Convergent single-answer?" -> "mma-investigate" [label="yes"];
56
+ "Convergent single-answer?" -> "About to brainstorm/plan?";
57
+ "About to brainstorm/plan?" -> "mma-explore" [label="yes"];
58
+ "About to brainstorm/plan?" -> "Inline search (1–2 queries)" [label="no — narrow enough"];
59
+ }
60
+ ```
61
+
62
+ ## How to run
63
+
64
+ Dispatch ALL THREE in ONE message (parallel tool use):
65
+
66
+ 1. `mma-investigate` — internal codebase research
67
+ - You MAY skip this only if the question is unambiguously greenfield (no
68
+ codebase touch-points exist). When in doubt, run it.
69
+ 2. `mma-research` — external multi-source research
70
+ 3. `mma-journal-recall` — prior learnings/decisions from the project journal
71
+ - Always run it. If the project has no journal yet (or nothing relevant),
72
+ it returns zero findings — a valid result you handle with the
73
+ `(no prior learning)` sentinel. Never skip it to "save a call": a
74
+ superseded prior decision is exactly the signal you most want before
75
+ brainstorming.
76
+
77
+ Wait for all legs to return. Do NOT proceed to synthesis until you have every
78
+ result (or have decided to skip investigate as greenfield).
79
+
80
+ ## Endpoint
81
+
82
+ This is a main-agent skill — there is no dedicated `/explore` HTTP endpoint.
83
+ Behind the scenes, you dispatch the three delegated tools `mma-investigate`
84
+ (`POST /investigate`), `mma-research` (`POST /research`), and
85
+ `mma-journal-recall` (`POST /journal-recall`) yourself.
86
+
87
+ ## Request body
88
+
89
+ (Not applicable — this skill orchestrates three other skills.) See
90
+ [`mma-investigate`](../mma-investigate/SKILL.md),
91
+ [`mma-research`](../mma-research/SKILL.md), and
92
+ [`mma-journal-recall`](../mma-journal-recall/SKILL.md) for their request bodies.
93
+
94
+ ## Full example
95
+
96
+ The main agent (you) issues a single message with three parallel tool calls:
97
+
98
+ ```
99
+ [parallel tool use]
100
+ mma-investigate { question: "How does our streaming JSON parser handle backpressure?", filePaths: ["src/parsers/"] }
101
+ mma-research { researchQuestion: "State-of-the-art streaming JSON parsers with backpressure?", background: "We use a single-pass push parser." }
102
+ mma-journal-recall { query: "what have we learned about streaming-parser backpressure or buffering tradeoffs?" }
103
+ ```
104
+
105
+ ## Reading the leg results
106
+
107
+ All three legs (`mma-investigate`, `mma-research`, `mma-journal-recall`) return the v5 wire envelope (see `mma-investigate/SKILL.md` → "v5 wire shape"). Each sub-task result is a `ComposePayload` with the standard seven fields. The authoritative citation source is **`results[0].findings`** — an array of `{ id, severity, category, claim, evidence, suggestion, source }`.
108
+
109
+ Explore top-level orchestration aggregates sub-task results into a valid `ImplementPayload` (read-route shape) before the final `annotate` stage runs. Each sub-task follows the same v5 wire shape; the top-level result is a composition of those sub-tasks.
110
+
111
+ | Check | How |
112
+ |---|---|
113
+ | Did the leg succeed? | `results[0].completed === true` — findings may be zero on a read route; finding nothing wrong is a valid completion |
114
+ | Internal citation source | `results[0].findings[i].claim` plus a `file:LINE` token from `results[0].findings[i].evidence` (workers style them as `` `path:LINE` `` markdown-linked refs) |
115
+ | External citation source | `results[0].findings[i].claim` plus a source name / URL from `results[0].findings[i].evidence` |
116
+ | Prior-learning source | `results[0].findings[i].claim` plus a journal node id from `results[0].findings[i].evidence` (recall cites `` `.mmagent/journal/nodes/NNNN-…` `` or `node NNNN`). Watch the node's status: a **superseded** learning is a "we tried this and moved on" signal — surface it, don't bury it |
117
+ | Divergence axis | `results[0].findings[i].category` groups findings by criterion — pick across categories so threads don't collapse onto one axis |
118
+
119
+ Apply a sentinel only when `findings` is empty AND `results[0].message` contains no finding-level content — i.e., the worker genuinely returned nothing. Do NOT apply a sentinel just because `results[0].message` reads tersely or `results[0].telemetry.workerSelfAssessment === 'failed'` — a worker can say `'failed'` with usable partial findings.
120
+
121
+ ## Per-task report shape
122
+
123
+ Synthesis output (REQUIRED — your reply MUST contain these):
124
+
125
+ Produce **3–5 threads**. Each thread MUST have:
126
+
127
+ - A **title** and **one-paragraph summary**.
128
+ - One **internal citation** (from investigate) — `file/path.ts:LINE — claim`.
129
+ - Pick from `results[0].findings`: take `claim` as the citation claim and pull a `file:LINE` token out of `evidence`.
130
+ - Use the sentinel `(no internal anchor — fully greenfield)` ONLY when investigate was skipped, or `results[0].findings` is empty AND `results[0].message` contains no finding-level content. The top-level `message` alone is not evidence — see "Reading the leg results" above.
131
+ - One **external citation** (from research) — `<source> — claim`.
132
+ - Pick from `results[0].findings`: take `claim` as the citation claim and pull a source name / URL out of `evidence`.
133
+ - Use the sentinel `(no external source found)` only when `results[0].findings` is empty for the research leg.
134
+ - One **prior-learning citation** (from journal-recall) WHEN a relevant node exists — `(journal) node NNNN — claim`.
135
+ - Pick from the recall leg's `results[0].findings`: take `claim` as the citation and pull the node id out of `evidence`.
136
+ - If the cited node is **superseded**, say so inline (e.g. `(journal) node 0012 [superseded by 0013] — …`) so the thread carries the "we already moved past this" signal.
137
+ - Use the sentinel `(no prior learning)` when the recall leg returned no relevant node — most threads on a young project will use this, and that's fine.
138
+ - A **one-line divergence reason** — what makes this thread different from
139
+ the others. No two threads may share the same divergence axis.
140
+
141
+ If the recall leg surfaced a learning that **invalidates** a direction (a
142
+ superseded or dropped decision that maps onto a thread you'd otherwise
143
+ propose), do not silently omit it — keep the thread but mark it
144
+ `⚠ already explored — see (journal) node NNNN` and weight it down in the
145
+ recommendation. Prior learnings prune the search; they don't just decorate it.
146
+
147
+ End with `## Recommended next step` — one paragraph naming which thread to
148
+ pursue first and why. If a prior learning rules a thread in or out, cite it here.
149
+
150
+ ## Best practices
151
+
152
+ This skill is one step in the larger flow described in `multi-model-agent` →
153
+ "Best practices". Use this BEFORE `superpowers:brainstorming` when the
154
+ brainstorming would otherwise start cold — divergent threads ground the
155
+ brainstorming in real code + real prior art.
156
+
157
+ ## Common pitfalls
158
+
159
+ ❌ **Do not dump the two raw reports back to the user.** The synthesis IS the
160
+ output; the raw reports are inputs you reason over. **Fix:** synthesise into
161
+ 3–5 threads with citations from BOTH legs (or sentinels) and a recommended
162
+ next step.
163
+
164
+ ❌ **Skipping `mma-investigate` for convenience.** "Greenfield" must be
165
+ unambiguous. When in doubt, run it. **Fix:** only skip if the question is
166
+ unambiguously greenfield (no codebase touch-points).
167
+
168
+ ❌ **Inventing citations.** Every citation must trace back to one of the two
169
+ delegated reports or to a sentinel. **Fix:** if a thread has no usable
170
+ citation from a leg, use the sentinel — do not fabricate.
171
+
172
+ ❌ **Padding to hit 5 threads.** ONE thread with high-confidence citations is
173
+ better than 5 watery ones. **Fix:** stop at the natural number of distinct
174
+ directions in the data.
175
+
176
+ ## Failure handling
177
+
178
+ | Scenario | What to do |
179
+ |---|---|
180
+ | `mma-research` failed | Use `(no external source found)` sentinel on every external line. If `mma-investigate` also failed, do NOT synthesise — surface both errors to the user. |
181
+ | `mma-investigate` failed | Treat as greenfield — use `(no internal anchor — fully greenfield)` sentinel. |
182
+ | `mma-journal-recall` failed OR returned 0 findings | Use the `(no prior learning)` sentinel on every prior-learning line and continue — the journal leg is additive, never blocking. A young project with an empty journal hits this every time; it is not an error. |
183
+ | All three failed | Report all errors to the user. Do NOT fabricate threads. |
184
+ | Both investigate and research failed | Report both errors to the user. Do NOT fabricate threads. |
185
+ | Investigate returned `needsCallerClarification: true` | Pause — surface the clarification need to the user. Do NOT synthesise over an unfinished investigation. |
186
+ | Research returned 0 usable sources | Sentinel on external lines. Add a one-line note in synthesis preamble: *"External research returned no usable sources — threads anchor on internal findings only."* |
187
+ | Investigate headline reads "0 citations" / "confidence unparseable" but `results[0].findings.length > 0` | Known stage-sync noise — IGNORE the headline. The leg succeeded; read `results[0].findings` directly. |
188
+
189
+ See `superpowers:brainstorming` as the natural follow-up — convergent narrowing
190
+ on a chosen thread.
@@ -0,0 +1,258 @@
1
+ ---
2
+ name: mma-investigate
3
+ description: >-
4
+ Use when you need to answer a question about the codebase ("how does X work",
5
+ "where is Y called", "what does this directory do") and reading + grepping the
6
+ codebase yourself would consume main-context tokens
7
+ when_to_use: >-
8
+ A question about THIS codebase has surfaced — from the user, from a
9
+ methodology skill, or from your own next-step planning — AND mmagent is
10
+ running. Delegate the read/grep/synthesis to a worker so the main context
11
+ stays on judgment. Codebase only — does not perform web research or
12
+ git-history queries. OR you are about to read 3+ files / run any grep in main
13
+ context — that's the inline-labor-leakage anti-pattern (AP2); delegate to this
14
+ skill instead.
15
+ version: 5.0.3
16
+ ---
17
+
18
+ # mma-investigate
19
+
20
+ ## Overview
21
+
22
+ Answer a codebase question via a read-only mmagent worker. The worker greps and reads on its cheap budget; you read its synthesis on yours.
23
+
24
+ **Core principle:** Investigation is labor (read, grep, synthesize). Delegate it. The main agent stays on judgment — deciding what the answer means and what to do with it.
25
+
26
+ ## When to Use
27
+
28
+ ```dot
29
+ digraph when_to_use {
30
+ "Question about codebase?" [shape=diamond];
31
+ "About web / git history?" [shape=diamond];
32
+ "Already have the file in context?" [shape=diamond];
33
+ "mma-investigate" [shape=box];
34
+ "Read inline (1–2 reads)" [shape=box];
35
+ "WebSearch / git log" [shape=box];
36
+
37
+ "Question about codebase?" -> "About web / git history?";
38
+ "About web / git history?" -> "WebSearch / git log" [label="yes"];
39
+ "About web / git history?" -> "Already have the file in context?" [label="no"];
40
+ "Already have the file in context?" -> "Read inline (1–2 reads)" [label="yes"];
41
+ "Already have the file in context?" -> "mma-investigate" [label="no"];
42
+ }
43
+ ```
44
+
45
+ **Use when:**
46
+ - "How does X work in this codebase?"
47
+ - "Where is Y called from?"
48
+ - "What does this directory do?"
49
+ - The answer requires reading 3+ files or grepping
50
+ - Cross-cutting investigations (auth flow across modules, data lineage)
51
+
52
+ **Don't use when:**
53
+ - The answer is in 1–2 files you already have in context → just `Read`
54
+ - It's about web docs / external APIs → `WebSearch` / `WebFetch`
55
+ - It's about git history → `git log` / `git blame`
56
+ - You need to MODIFY code based on the finding → `mma-delegate` (research + edit)
57
+ - You want to consider multiple distinct directions, not converge on one answer → `mma-explore` (divergent ideation, codebase + web)
58
+
59
+ ## Endpoint
60
+
61
+ `POST /investigate?cwd=<abs-path>`
62
+
63
+ @include _shared/auth.md
64
+
65
+ ## Request body
66
+
67
+ ```json
68
+ {
69
+ "question": "How does the auth middleware handle token refresh?",
70
+ "subtype": "default",
71
+ "filePaths": ["/project/src/auth/"],
72
+ "contextBlockIds": []
73
+ }
74
+ ```
75
+
76
+ | Field | Type | Required | Notes |
77
+ |---|---|---|---|
78
+ | `question` | string | yes | Natural-language investigation question |
79
+ | `subtype` | `'default'` | no (defaults to `'default'`) | Reserved for future criteria sets; only `default` is wired today. |
80
+ | `filePaths` | string[] | no | Anchor paths the worker starts from. Worker may grep beyond. |
81
+ | `contextBlockIds` | string[] | no | IDs from `mma-context-blocks` — enables follow-up / delta investigation |
82
+ | `tools` | `'none' \| 'readonly'` | no | Default `'readonly'`. `'no-shell'` and `'full'` are rejected — investigation is read-only |
83
+
84
+ > Worker tier for `mma-investigate` is hardcoded to `complex` and is not caller-configurable. Sending `agentType` is rejected with HTTP 400.
85
+
86
+ **Anchor narrow questions with `filePaths`:**
87
+
88
+ ❌ `{ "question": "Where is parseConfig called?" }` — searches the whole repo
89
+ ✅ `{ "question": "Where is parseConfig called?", "filePaths": ["src/"] }` — bounded
90
+
91
+ **Why:** the worker greps and reads under a turn and wall-clock budget. Without anchors, broad questions exhaust those budgets before they finish.
92
+
93
+ ## Full example
94
+
95
+ ```bash
96
+ BATCH=$(curl -f --show-error -s -X POST \
97
+ -H "X-MMA-Client: $MMA_CLIENT" \
98
+ -H "X-MMA-Main-Model: $MMA_MAIN_MODEL" \
99
+ -H "Authorization: Bearer $TOKEN" \
100
+ -H "Content-Type: application/json" \
101
+ -d '{"question":"How does the auth middleware handle token refresh?"}' \
102
+ "http://localhost:$PORT/investigate?cwd=/project")
103
+ BATCH_ID=$(echo "$BATCH" | jq -r '.batchId')
104
+ ```
105
+
106
+ @include _shared/polling.md
107
+
108
+ @include _shared/response-shape.md
109
+
110
+ ## Per-task report shape
111
+
112
+ Each task carries an `investigation` field on its per-task report:
113
+
114
+ ```json
115
+ {
116
+ "investigation": {
117
+ "citations": [
118
+ { "file": "src/auth/refresh.ts", "lines": "45-72", "claim": "Refresh handler reads bearer." }
119
+ ],
120
+ "confidence": { "level": "high", "rationale": "All claims directly cited." },
121
+ "diagnostics": {
122
+ "malformedCitationLines": 0,
123
+ "missingRequiredSections": [],
124
+ "invalidRequiredSections": []
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ The authoritative success signals are `completed`, `message`, and `findings`. See "v5 wire shape" above for the full envelope.
131
+
132
+ ## v5 wire shape (read route)
133
+
134
+ Every task result is a `ComposePayload` — seven main-agent fields plus a telemetry block.
135
+ The main-agent fields are authoritative; the telemetry block is diagnostics.
136
+
137
+ ```json
138
+ {
139
+ "completed": true,
140
+ "message": "Investigation complete; 3 files analysed.",
141
+ "findings": [
142
+ {
143
+ "id": "F1",
144
+ "severity": "high",
145
+ "category": "correctness",
146
+ "claim": "The refresh handler reads bearer from Authorization header unconditionally.",
147
+ "evidence": "src/auth/refresh.ts:45-72 — verbatim substring from worker output.",
148
+ "suggestion": "Add a guard to handle missing Authorization header gracefully.",
149
+ "source": "implementer"
150
+ }
151
+ ],
152
+ "summary": "...",
153
+ "filesChanged": [],
154
+ "commitSha": null,
155
+ "blockId": null,
156
+ "telemetry": {
157
+ "totalDurationMs": 1234,
158
+ "totalCostUSD": 0.08,
159
+ "workerSelfAssessment": "done",
160
+ "reviewVerdict": null,
161
+ "commitOutcome": "not_applicable",
162
+ "stopReason": "normal",
163
+ "haltedStage": null,
164
+ "stages": [...]
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### Key fields
170
+
171
+ | Field | When populated | Notes |
172
+ |---|---|---|
173
+ | `completed` | always | `true` when at least one criterion succeeded; `false` on annotator transport failure OR unmet annotate preconditions (e.g. non-`done` worker self-assessment on a read route) |
174
+ | `message` | always | human-readable summary; names blocking gates or finding IDs on failure |
175
+ | `findings` | always | `source: 'implementer'` for investigate; findings are the deliverable on read routes |
176
+ | `workerSelfAssessment` | always | `'done'` or `'failed'` — never `done_with_concerns` |
177
+ | `blockId` | always `null` | investigate is a task route, not register-context-block |
178
+
179
+ ### No second review
180
+
181
+ The LLM-judge stage (`annotate`) runs once, after the worker's output. Its preconditions for read-route `completed: true`:
182
+
183
+ ```
184
+ gates.implement.outcome === 'advance'
185
+ && gates.implement.payload.workerSelfAssessment === 'done'
186
+ && (criteriaSucceeded.length > 0 || criteriaErrors.length === 0)
187
+ ```
188
+
189
+ Findings are the deliverable — a task that surfaces 5 issues is `completed: true`. Finding nothing wrong is also a valid completion.
190
+
191
+ ### `completed: false` — what it means
192
+
193
+ Only on annotator transport failure. The `message` names the blocking gate. Re-dispatch with tighter `filePaths` if the worker's citations were unusable.
194
+
195
+ ## Best practices
196
+
197
+ This skill is one step in the larger flow described in `multi-model-agent` → "Best practices". Recipes that involve `mma-investigate`:
198
+
199
+ - **Recipe C — Investigate-plan-execute.** `mma-investigate` → write the plan → `mma-execute-plan` → `mma-retry`. The investigation produces the synthesis you need to write the plan; the plan becomes a context block for execute-plan.
200
+
201
+ Anti-pattern alert: **`inline-labor-leakage`** (AP2). If you find yourself reading 3+ files or running any grep in main context, that's the trigger to delegate here instead. Main-context tokens cost ~10× more than worker tokens, and you only need the synthesis, not the raw reads.
202
+
203
+ ## Common pitfalls
204
+
205
+ ❌ **Asking for a fix instead of an answer**
206
+ > question: "Refactor the auth middleware to use JWT"
207
+
208
+ The investigator can't write — `tools: 'readonly'`. **Fix:** use `mma-delegate` for research-then-edit, or split: investigate first, then dispatch the edit.
209
+
210
+ ❌ **Inline-reading instead of delegating**
211
+ About to `Read` 3+ files just to answer one question? That's the wrong tradeoff — the worker reads on its cheap budget; you read its synthesis on yours.
212
+
213
+ ## Terminal context block
214
+
215
+ Every completed **read-route** task (audit / review / debug / investigate / research) auto-registers a reusable terminal context block containing its report (headline + findings). The block id is returned on each per-task result as **`contextBlockId`**. Write routes (delegate / execute-plan / retry) return `contextBlockId: null` — their record is the commit, not a block. This block is immutable, lives for the session duration, and counts against the project's `maxEntries` quota (default 500).
216
+
217
+ Use it for delta follow-ups — feed prior results' block ids into a later call's `contextBlockIds`, filtering out nulls:
218
+
219
+ contextBlockIds: priorResults.map(r => r.contextBlockId).filter((id) => id !== null)
220
+
221
+ **Use cases:**
222
+ - Pass investigation results to a downstream planning step
223
+ - Feed codebase findings into `mma-execute-plan` as shared context
224
+ - Carry investigation context forward through the investigate → plan → execute chain
225
+
226
+ The block is registered server-side at task completion; no caller action is needed to create it. Delete it explicitly via `DELETE /context-blocks/:id` when no longer needed, or let it expire on session teardown.
227
+
228
+ ## Outcome semantics
229
+
230
+ Every task result carries outcome fields that describe the investigation's conclusion status:
231
+
232
+ | Field | Type | Meaning |
233
+ |---|---|---|
234
+ | `findingsOutcome` | `'found' \| 'clean' \| 'not_applicable'` | Answers the question: did the investigation produce a substantive result? |
235
+ | `findingsOutcomeReason` | `string \| null` | When `findingsOutcome` is set, this explains why (e.g. "No candidate answers found after perspective 5" or "One clear path identified at high confidence"). |
236
+ | `outcomeInferred` | `boolean` | `true` if the system inferred the outcome from findings count; `false` if the worker explicitly stated it. |
237
+ | `outcomeMalformed` | `boolean` | `true` if the outcome line was malformed and had to be repaired; `false` otherwise. |
238
+
239
+ ### Enum values
240
+
241
+ - **`found`** — the investigation produced one or more candidate answers (findings) across one or more criteria. This is the success state for a question-answering route.
242
+ - **`clean`** — the investigation completed but produced zero findings. This is valid for issue-hunting routes but unusual for `mma-investigate`, where answering a question always produces at least one candidate.
243
+ - **`not_applicable`** — the investigation could not proceed (e.g., the question was out of scope, the codebase provided no data to work with, or the request preconditions failed). This is the "no answer possible" state.
244
+
245
+ ### Empty findings ≠ failure
246
+
247
+ A crucial semantic: **empty findings does NOT mean `completed: false` or a failed task.** The presence or absence of findings is orthogonal to task success. An investigation that searches thoroughly and produces zero candidate answers is a valid `completed: true` outcome; it simply answers the question with "I found no evidence for that in the codebase."
248
+
249
+ ### Per-route legal outcomes
250
+
251
+ The legal outcomes for this route are: `['found', 'not_applicable']`
252
+
253
+ - **`found`** — one or more candidate answers surfaced via the investigation criteria.
254
+ - **`not_applicable`** — the question was out of scope, unanswerable, or the codebase provided insufficient data.
255
+
256
+ The outcome `clean` (zero findings + success) is not legal for `mma-investigate` because an investigation answer is always produced in the `found` state or the task is `not_applicable`.
257
+
258
+ @include _shared/error-handling.md