@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.
- package/README.md +8 -18
- package/dist/cli/index.d.ts +62 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +345 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/info.d.ts +22 -0
- package/dist/cli/info.d.ts.map +1 -0
- package/dist/cli/info.js +100 -0
- package/dist/cli/info.js.map +1 -0
- package/dist/cli/logs.d.ts +15 -0
- package/dist/cli/logs.d.ts.map +1 -0
- package/dist/cli/logs.js +102 -0
- package/dist/cli/logs.js.map +1 -0
- package/dist/cli/print-token.d.ts +18 -0
- package/dist/cli/print-token.d.ts.map +1 -0
- package/dist/cli/print-token.js +60 -0
- package/dist/cli/print-token.js.map +1 -0
- package/dist/cli/serve.d.ts +28 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +405 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/status.d.ts +49 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +155 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/sync-skills.d.ts +58 -0
- package/dist/cli/sync-skills.d.ts.map +1 -0
- package/dist/cli/sync-skills.js +266 -0
- package/dist/cli/sync-skills.js.map +1 -0
- package/dist/cli/telemetry.d.ts +10 -0
- package/dist/cli/telemetry.d.ts.map +1 -0
- package/dist/cli/telemetry.js +161 -0
- package/dist/cli/telemetry.js.map +1 -0
- package/dist/cli/toggle.d.ts +26 -0
- package/dist/cli/toggle.d.ts.map +1 -0
- package/dist/cli/toggle.js +185 -0
- package/dist/cli/toggle.js.map +1 -0
- package/dist/http/async-dispatch.d.ts +44 -0
- package/dist/http/async-dispatch.d.ts.map +1 -0
- package/dist/http/async-dispatch.js +175 -0
- package/dist/http/async-dispatch.js.map +1 -0
- package/dist/http/auth.d.ts +20 -0
- package/dist/http/auth.d.ts.map +1 -0
- package/dist/http/auth.js +56 -0
- package/dist/http/auth.js.map +1 -0
- package/dist/http/canonicalize-file-paths.d.ts +8 -0
- package/dist/http/canonicalize-file-paths.d.ts.map +1 -0
- package/dist/http/canonicalize-file-paths.js +43 -0
- package/dist/http/canonicalize-file-paths.js.map +1 -0
- package/dist/http/cwd-validator.d.ts +11 -0
- package/dist/http/cwd-validator.d.ts.map +1 -0
- package/dist/http/cwd-validator.js +130 -0
- package/dist/http/cwd-validator.js.map +1 -0
- package/dist/http/errors.d.ts +4 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +9 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/execution-context.d.ts +18 -0
- package/dist/http/execution-context.d.ts.map +1 -0
- package/dist/http/execution-context.js +61 -0
- package/dist/http/execution-context.js.map +1 -0
- package/dist/http/handler-deps.d.ts +19 -0
- package/dist/http/handler-deps.d.ts.map +1 -0
- package/dist/http/handler-deps.js +2 -0
- package/dist/http/handler-deps.js.map +1 -0
- package/dist/http/handlers/control/batch-slice.d.ts +4 -0
- package/dist/http/handlers/control/batch-slice.d.ts.map +1 -0
- package/dist/http/handlers/control/batch-slice.js +40 -0
- package/dist/http/handlers/control/batch-slice.js.map +1 -0
- package/dist/http/handlers/control/batch.d.ts +23 -0
- package/dist/http/handlers/control/batch.d.ts.map +1 -0
- package/dist/http/handlers/control/batch.js +332 -0
- package/dist/http/handlers/control/batch.js.map +1 -0
- package/dist/http/handlers/control/context-blocks.d.ts +22 -0
- package/dist/http/handlers/control/context-blocks.d.ts.map +1 -0
- package/dist/http/handlers/control/context-blocks.js +111 -0
- package/dist/http/handlers/control/context-blocks.js.map +1 -0
- package/dist/http/handlers/introspection/health.d.ts +20 -0
- package/dist/http/handlers/introspection/health.d.ts.map +1 -0
- package/dist/http/handlers/introspection/health.js +18 -0
- package/dist/http/handlers/introspection/health.js.map +1 -0
- package/dist/http/handlers/introspection/status.d.ts +26 -0
- package/dist/http/handlers/introspection/status.d.ts.map +1 -0
- package/dist/http/handlers/introspection/status.js +136 -0
- package/dist/http/handlers/introspection/status.js.map +1 -0
- package/dist/http/handlers/tools/audit.d.ts +4 -0
- package/dist/http/handlers/tools/audit.d.ts.map +1 -0
- package/dist/http/handlers/tools/audit.js +43 -0
- package/dist/http/handlers/tools/audit.js.map +1 -0
- package/dist/http/handlers/tools/debug.d.ts +4 -0
- package/dist/http/handlers/tools/debug.d.ts.map +1 -0
- package/dist/http/handlers/tools/debug.js +43 -0
- package/dist/http/handlers/tools/debug.js.map +1 -0
- package/dist/http/handlers/tools/delegate.d.ts +4 -0
- package/dist/http/handlers/tools/delegate.d.ts.map +1 -0
- package/dist/http/handlers/tools/delegate.js +43 -0
- package/dist/http/handlers/tools/delegate.js.map +1 -0
- package/dist/http/handlers/tools/execute-plan.d.ts +4 -0
- package/dist/http/handlers/tools/execute-plan.d.ts.map +1 -0
- package/dist/http/handlers/tools/execute-plan.js +45 -0
- package/dist/http/handlers/tools/execute-plan.js.map +1 -0
- package/dist/http/handlers/tools/investigate.d.ts +4 -0
- package/dist/http/handlers/tools/investigate.d.ts.map +1 -0
- package/dist/http/handlers/tools/investigate.js +64 -0
- package/dist/http/handlers/tools/investigate.js.map +1 -0
- package/dist/http/handlers/tools/journal-recall.d.ts +4 -0
- package/dist/http/handlers/tools/journal-recall.d.ts.map +1 -0
- package/dist/http/handlers/tools/journal-recall.js +40 -0
- package/dist/http/handlers/tools/journal-recall.js.map +1 -0
- package/dist/http/handlers/tools/journal-record.d.ts +8 -0
- package/dist/http/handlers/tools/journal-record.d.ts.map +1 -0
- package/dist/http/handlers/tools/journal-record.js +40 -0
- package/dist/http/handlers/tools/journal-record.js.map +1 -0
- package/dist/http/handlers/tools/research.d.ts +4 -0
- package/dist/http/handlers/tools/research.d.ts.map +1 -0
- package/dist/http/handlers/tools/research.js +64 -0
- package/dist/http/handlers/tools/research.js.map +1 -0
- package/dist/http/handlers/tools/retry.d.ts +4 -0
- package/dist/http/handlers/tools/retry.d.ts.map +1 -0
- package/dist/http/handlers/tools/retry.js +73 -0
- package/dist/http/handlers/tools/retry.js.map +1 -0
- package/dist/http/handlers/tools/review.d.ts +4 -0
- package/dist/http/handlers/tools/review.d.ts.map +1 -0
- package/dist/http/handlers/tools/review.js +43 -0
- package/dist/http/handlers/tools/review.js.map +1 -0
- package/dist/http/journal-lock.d.ts +4 -0
- package/dist/http/journal-lock.d.ts.map +1 -0
- package/dist/http/journal-lock.js +34 -0
- package/dist/http/journal-lock.js.map +1 -0
- package/dist/http/middleware/body-reader.d.ts +16 -0
- package/dist/http/middleware/body-reader.d.ts.map +1 -0
- package/dist/http/middleware/body-reader.js +44 -0
- package/dist/http/middleware/body-reader.js.map +1 -0
- package/dist/http/middleware/caller-identity.d.ts +16 -0
- package/dist/http/middleware/caller-identity.d.ts.map +1 -0
- package/dist/http/middleware/caller-identity.js +16 -0
- package/dist/http/middleware/caller-identity.js.map +1 -0
- package/dist/http/middleware/decompress.d.ts +14 -0
- package/dist/http/middleware/decompress.d.ts.map +1 -0
- package/dist/http/middleware/decompress.js +51 -0
- package/dist/http/middleware/decompress.js.map +1 -0
- package/dist/http/project-registry.d.ts +54 -0
- package/dist/http/project-registry.d.ts.map +1 -0
- package/dist/http/project-registry.js +130 -0
- package/dist/http/project-registry.js.map +1 -0
- package/dist/http/request-observability.d.ts +8 -0
- package/dist/http/request-observability.d.ts.map +1 -0
- package/dist/http/request-observability.js +20 -0
- package/dist/http/request-observability.js.map +1 -0
- package/dist/http/request-pipeline.d.ts +16 -0
- package/dist/http/request-pipeline.d.ts.map +1 -0
- package/dist/http/request-pipeline.js +144 -0
- package/dist/http/request-pipeline.js.map +1 -0
- package/dist/http/server.d.ts +17 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +300 -0
- package/dist/http/server.js.map +1 -0
- package/dist/http/types.d.ts +20 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +2 -0
- package/dist/http/types.js.map +1 -0
- package/dist/skill-install/disabled-state.d.ts +35 -0
- package/dist/skill-install/disabled-state.d.ts.map +1 -0
- package/dist/skill-install/disabled-state.js +96 -0
- package/dist/skill-install/disabled-state.js.map +1 -0
- package/dist/skill-install/discover.d.ts +29 -0
- package/dist/skill-install/discover.d.ts.map +1 -0
- package/dist/skill-install/discover.js +104 -0
- package/dist/skill-install/discover.js.map +1 -0
- package/dist/skill-install/include-utils.d.ts +27 -0
- package/dist/skill-install/include-utils.d.ts.map +1 -0
- package/dist/skill-install/include-utils.js +90 -0
- package/dist/skill-install/include-utils.js.map +1 -0
- package/dist/skill-install/manifest.d.ts +82 -0
- package/dist/skill-install/manifest.d.ts.map +1 -0
- package/dist/skill-install/manifest.js +215 -0
- package/dist/skill-install/manifest.js.map +1 -0
- package/dist/skill-install/skill-installer-common.d.ts +26 -0
- package/dist/skill-install/skill-installer-common.d.ts.map +1 -0
- package/dist/skill-install/skill-installer-common.js +139 -0
- package/dist/skill-install/skill-installer-common.js.map +1 -0
- package/dist/skill-install/skill-installers/claude-code.d.ts +43 -0
- package/dist/skill-install/skill-installers/claude-code.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/claude-code.js +65 -0
- package/dist/skill-install/skill-installers/claude-code.js.map +1 -0
- package/dist/skill-install/skill-installers/codex-cli.d.ts +27 -0
- package/dist/skill-install/skill-installers/codex-cli.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/codex-cli.js +84 -0
- package/dist/skill-install/skill-installers/codex-cli.js.map +1 -0
- package/dist/skill-install/skill-installers/cursor.d.ts +72 -0
- package/dist/skill-install/skill-installers/cursor.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/cursor.js +81 -0
- package/dist/skill-install/skill-installers/cursor.js.map +1 -0
- package/dist/skill-install/skill-installers/gemini-cli.d.ts +50 -0
- package/dist/skill-install/skill-installers/gemini-cli.d.ts.map +1 -0
- package/dist/skill-install/skill-installers/gemini-cli.js +72 -0
- package/dist/skill-install/skill-installers/gemini-cli.js.map +1 -0
- package/dist/skill-install/skill-manifest-sync.d.ts +11 -0
- package/dist/skill-install/skill-manifest-sync.d.ts.map +1 -0
- package/dist/skill-install/skill-manifest-sync.js +65 -0
- package/dist/skill-install/skill-manifest-sync.js.map +1 -0
- package/dist/skills/_shared/auth.md +41 -0
- package/dist/skills/_shared/error-handling.md +31 -0
- package/dist/skills/_shared/polling.md +88 -0
- package/dist/skills/_shared/response-shape.md +55 -0
- package/dist/skills/_shared/review-policy.md +15 -0
- package/dist/skills/mma-audit/SKILL.md +270 -0
- package/dist/skills/mma-context-blocks/SKILL.md +148 -0
- package/dist/skills/mma-debug/SKILL.md +208 -0
- package/dist/skills/mma-delegate/SKILL.md +216 -0
- package/dist/skills/mma-execute-plan/SKILL.md +214 -0
- package/dist/skills/mma-explore/SKILL.md +190 -0
- package/dist/skills/mma-investigate/SKILL.md +258 -0
- package/dist/skills/mma-journal-recall/SKILL.md +242 -0
- package/dist/skills/mma-journal-record/SKILL.md +202 -0
- package/dist/skills/mma-research/SKILL.md +223 -0
- package/dist/skills/mma-retry/SKILL.md +221 -0
- package/dist/skills/mma-review/SKILL.md +209 -0
- package/dist/skills/multi-model-agent/SKILL.md +206 -0
- package/dist/telemetry/consent.d.ts +4 -0
- package/dist/telemetry/consent.d.ts.map +1 -0
- package/dist/telemetry/consent.js +40 -0
- package/dist/telemetry/consent.js.map +1 -0
- package/dist/telemetry/flusher.d.ts +19 -0
- package/dist/telemetry/flusher.d.ts.map +1 -0
- package/dist/telemetry/flusher.js +277 -0
- package/dist/telemetry/flusher.js.map +1 -0
- package/dist/telemetry/generation.d.ts +9 -0
- package/dist/telemetry/generation.d.ts.map +1 -0
- package/dist/telemetry/generation.js +33 -0
- package/dist/telemetry/generation.js.map +1 -0
- package/dist/telemetry/identity.d.ts +9 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +35 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/install-id.d.ts +13 -0
- package/dist/telemetry/install-id.d.ts.map +1 -0
- package/dist/telemetry/install-id.js +49 -0
- package/dist/telemetry/install-id.js.map +1 -0
- package/dist/telemetry/install-meta.d.ts +10 -0
- package/dist/telemetry/install-meta.d.ts.map +1 -0
- package/dist/telemetry/install-meta.js +15 -0
- package/dist/telemetry/install-meta.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +287 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/recorder.d.ts +39 -0
- package/dist/telemetry/recorder.d.ts.map +1 -0
- package/dist/telemetry/recorder.js +173 -0
- package/dist/telemetry/recorder.js.map +1 -0
- package/package.json +43 -24
- package/scripts/postinstall.js +36 -0
- package/bin/mmagent.mjs +0 -47
- package/postinstall.mjs +0 -8
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mma-debug
|
|
3
|
+
description: >-
|
|
4
|
+
Use when a test fails, a build breaks, or behavior is unexpected AND narrowing
|
|
5
|
+
the root cause requires reading files, reproducing the failure, or tracing
|
|
6
|
+
across multiple modules — the worker investigates so the main agent stays on
|
|
7
|
+
the hypothesis
|
|
8
|
+
when_to_use: >-
|
|
9
|
+
A failure has surfaced (test/build/runtime) AND you need investigation work —
|
|
10
|
+
read files, reproduce, trace — OR a methodology skill
|
|
11
|
+
(superpowers:systematic-debugging) points at the investigation step. Delegate
|
|
12
|
+
the read/reproduce/trace; the main agent stays on the hypothesis and the fix.
|
|
13
|
+
version: 5.0.3
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# mma-debug
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
Submit a problem, context, and hypothesis to a worker for focused debugging. Unlike `mma-audit` and `mma-review`, all `filePaths` are investigated TOGETHER in a single task (not parallelized per file) — debugging needs cross-file reasoning.
|
|
21
|
+
|
|
22
|
+
**Core principle:** The hypothesis is judgment (your job). Reading files and reproducing the failure is labor (the worker's job). Pass the hypothesis as input; receive structured findings.
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
**Use when:**
|
|
27
|
+
- A test fails / build breaks / runtime behavior is unexpected
|
|
28
|
+
- The root cause likely spans 2+ files
|
|
29
|
+
- You have a hypothesis to test (or want the worker to suggest one)
|
|
30
|
+
- A methodology skill (`superpowers:systematic-debugging`) routed here
|
|
31
|
+
|
|
32
|
+
**Don't use when:**
|
|
33
|
+
- The error message points at one file you can read in 30 seconds → just `Read`
|
|
34
|
+
- You don't know what's broken yet → use `mma-investigate` first to map the area
|
|
35
|
+
- You already know the fix → skip debug, dispatch `mma-delegate` with the fix
|
|
36
|
+
|
|
37
|
+
## Endpoint
|
|
38
|
+
|
|
39
|
+
`POST /debug?cwd=<abs-path>`
|
|
40
|
+
|
|
41
|
+
@include _shared/auth.md
|
|
42
|
+
|
|
43
|
+
## Request body
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"problem": "POST /login returns 500 when password contains special characters",
|
|
48
|
+
"context": "Regression introduced in commit abc123; only affects production config",
|
|
49
|
+
"hypothesis": "The bcrypt binding fails on non-ASCII input in the Docker image",
|
|
50
|
+
"subtype": "default",
|
|
51
|
+
"filePaths": [
|
|
52
|
+
"/project/src/auth/login.ts",
|
|
53
|
+
"/project/src/auth/password.ts"
|
|
54
|
+
],
|
|
55
|
+
"contextBlockIds": []
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Field | Type | Required | Notes |
|
|
60
|
+
|---|---|---|---|
|
|
61
|
+
| `problem` | string | yes | What is broken (one sentence; concrete symptom) |
|
|
62
|
+
| `context` | string | no | Background — what changed recently, what works, what doesn't |
|
|
63
|
+
| `hypothesis` | string | no | Your initial theory; worker tests it first, then explores |
|
|
64
|
+
| `subtype` | `'default'` | no (defaults to `'default'`) | Reserved for future criteria sets; only `default` is wired today. |
|
|
65
|
+
| `filePaths` | string[] | no | All files investigated together (cross-file reasoning) |
|
|
66
|
+
| `contextBlockIds` | string[] | no | IDs from `mma-context-blocks` (e.g. error logs, traces) |
|
|
67
|
+
|
|
68
|
+
> Worker tier for `mma-debug` is hardcoded to `complex` and is not caller-configurable. Sending `agentType` is rejected with HTTP 400.
|
|
69
|
+
|
|
70
|
+
## Full example
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
BATCH=$(curl -f --show-error -s -X POST \
|
|
74
|
+
-H "X-MMA-Client: $MMA_CLIENT" \
|
|
75
|
+
-H "X-MMA-Main-Model: $MMA_MAIN_MODEL" \
|
|
76
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
77
|
+
-H "Content-Type: application/json" \
|
|
78
|
+
-d '{"problem":"Tests fail on CI only","hypothesis":"Missing env var","filePaths":["/project/src/config.ts"]}' \
|
|
79
|
+
"http://localhost:$PORT/debug?cwd=/project")
|
|
80
|
+
BATCH_ID=$(echo "$BATCH" | jq -r '.batchId')
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
@include _shared/polling.md
|
|
84
|
+
|
|
85
|
+
@include _shared/response-shape.md
|
|
86
|
+
|
|
87
|
+
## Reading the findings
|
|
88
|
+
|
|
89
|
+
The main agent reads `completed` + `message` + `findings` — the findings are the answer. For
|
|
90
|
+
read-only routes, `filesChanged` is always `[]` and `commitSha` is always `null`.
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"completed": true,
|
|
95
|
+
"message": "Investigation complete; 1 finding.",
|
|
96
|
+
"findings": [
|
|
97
|
+
{ "id": "F1", "severity": "high", "category": "root-cause",
|
|
98
|
+
"claim": "bcrypt binding fails on non-ASCII input in the Docker image.",
|
|
99
|
+
"evidence": "Worker reproduced the failure with `pass='café'`; strace shows EINVAL on encode call.",
|
|
100
|
+
"suggestion": "Normalize input to NFC form before calling bcrypt.",
|
|
101
|
+
"source": "implementer" }
|
|
102
|
+
],
|
|
103
|
+
"filesChanged": [],
|
|
104
|
+
"commitSha": null,
|
|
105
|
+
"summary": "...",
|
|
106
|
+
"telemetry": { ... }
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Finding shape
|
|
111
|
+
|
|
112
|
+
Every finding has this shape:
|
|
113
|
+
|
|
114
|
+
| Field | Type | Notes |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `id` | string | Worker-assigned, e.g. `F1`, `F2`. Stable across chain. |
|
|
117
|
+
| `severity` | `'critical' \| 'high' \| 'medium' \| 'low'` | 4-tier. |
|
|
118
|
+
| `category` | string | Topical bucket, e.g. `root-cause`, `reproduction`. |
|
|
119
|
+
| `claim` | string | One-sentence summary. |
|
|
120
|
+
| `evidence` | string ≥20 chars | Verbatim from source when grounded. |
|
|
121
|
+
| `suggestion?` | string | Optional fix recommendation. |
|
|
122
|
+
| `source` | `'implementer' \| 'reviewer'` | Who produced the finding. |
|
|
123
|
+
|
|
124
|
+
`annotatorConfidence` and `evidenceGrounded` are retired — they were v4 fields with no producers.
|
|
125
|
+
|
|
126
|
+
### Recommended rendering by the main agent
|
|
127
|
+
|
|
128
|
+
1. Show ALL findings — never silently drop. Severity and grounding are soft
|
|
129
|
+
signals, not gates.
|
|
130
|
+
2. Default sort: severity (critical → low), then `id` ascending.
|
|
131
|
+
3. `severity` is the authoritative value — use it directly.
|
|
132
|
+
4. Mark findings with `evidence` shorter than 30 chars as "low-evidence"
|
|
133
|
+
(lighter color or `(low evidence)` annotation). User decides what to do.
|
|
134
|
+
5. Severity-tier counts feed the dashboard.
|
|
135
|
+
|
|
136
|
+
## Best practices
|
|
137
|
+
|
|
138
|
+
This skill is one step in the larger flow described in `multi-model-agent` → "Best practices". Recipes that involve `mma-debug`:
|
|
139
|
+
|
|
140
|
+
- **Recipe B — Debug-fix-review.** `mma-debug` → `mma-delegate` (apply fix) → `mma-review` with the acceptance criteria in the brief. Strict order. Register the failing test output / reproduction log as a context block before the debug call; reuse it on the review call.
|
|
141
|
+
|
|
142
|
+
Anti-pattern alert: **`inline-labor-leakage`** (AP2). If you're about to read 3+ files in main context to "understand the bug," that's the labor we delegate — call `mma-debug` with the hypothesis instead.
|
|
143
|
+
|
|
144
|
+
## Common pitfalls
|
|
145
|
+
|
|
146
|
+
❌ **Vague `problem`**
|
|
147
|
+
> "The login is broken"
|
|
148
|
+
|
|
149
|
+
Worker has no symptom to chase. **Fix:** specific reproducer — `"POST /login with body {user:'a@b.c', pass:'café'} returns 500 with 'invalid character' in stderr"`.
|
|
150
|
+
|
|
151
|
+
❌ **No `hypothesis`**
|
|
152
|
+
The worker explores blindly, often investigates the wrong area first. **Fix:** even a weak hypothesis ("might be encoding-related") narrows the search space.
|
|
153
|
+
|
|
154
|
+
❌ **Splitting one bug across multiple `mma-debug` calls**
|
|
155
|
+
Debug intentionally bundles `filePaths` for cross-file reasoning. Splitting defeats this. **Fix:** one call with all suspect files; if you really have N independent failures, use `mma-delegate` with N tasks.
|
|
156
|
+
|
|
157
|
+
❌ **Treating `mma-debug` as the fix step**
|
|
158
|
+
Debug investigates and proposes; it doesn't necessarily write the fix. **Fix:** if the worker identifies a fix, dispatch `mma-delegate` to implement it (or write it inline if you understand it).
|
|
159
|
+
|
|
160
|
+
❌ **Skipping when an error message looks self-explanatory**
|
|
161
|
+
Often the obvious cause isn't the real one. **Fix:** a 30-second debug pass costs less than a wrong fix that breaks something else.
|
|
162
|
+
|
|
163
|
+
## Terminal context block
|
|
164
|
+
|
|
165
|
+
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).
|
|
166
|
+
|
|
167
|
+
Use it for delta follow-ups — feed prior results' block ids into a later call's `contextBlockIds`, filtering out nulls:
|
|
168
|
+
|
|
169
|
+
contextBlockIds: priorResults.map(r => r.contextBlockId).filter((id) => id !== null)
|
|
170
|
+
|
|
171
|
+
**Use cases:**
|
|
172
|
+
- Pass debug findings to a downstream `mma-delegate` fix step
|
|
173
|
+
- Feed the root-cause analysis into a follow-up `mma-review` with acceptance criteria in the brief
|
|
174
|
+
- Carry debug context forward through the debug → fix → review chain
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
|
|
178
|
+
## Outcome semantics
|
|
179
|
+
|
|
180
|
+
Every task result carries outcome fields that describe the debugging investigation's conclusion status:
|
|
181
|
+
|
|
182
|
+
| Field | Type | Meaning |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| `findingsOutcome` | `'found' \| 'clean' \| 'not_applicable'` | Answers the question: did the investigation identify a root cause? |
|
|
185
|
+
| `findingsOutcomeReason` | `string \| null` | When `findingsOutcome` is set, this explains why (e.g. "Root cause identified with high confidence: bcrypt binding fails on non-ASCII input" or "No evidence supports the hypothesis; root cause remains unknown"). |
|
|
186
|
+
| `outcomeInferred` | `boolean` | `true` if the system inferred the outcome from findings count; `false` if the investigator explicitly stated it. |
|
|
187
|
+
| `outcomeMalformed` | `boolean` | `true` if the outcome line was malformed and had to be repaired; `false` otherwise. |
|
|
188
|
+
|
|
189
|
+
### Enum values
|
|
190
|
+
|
|
191
|
+
- **`found`** — the investigation identified one or more root-cause hypotheses (findings) with supporting evidence. This indicates the problem has a diagnosed cause.
|
|
192
|
+
- **`clean`** — the investigation completed but found zero root causes. This is rare for debug and indicates the failure remains unexplained despite thorough investigation.
|
|
193
|
+
- **`not_applicable`** — the investigation could not proceed (e.g., inability to reproduce the failure, missing context, or out of scope). This is the "unable to diagnose" state.
|
|
194
|
+
|
|
195
|
+
### Empty findings ≠ failure
|
|
196
|
+
|
|
197
|
+
A crucial semantic: **empty findings does NOT mean `completed: false` or a failed debug session.** An investigation that proceeds thoroughly and produces zero root-cause candidates is a valid `completed: true` outcome; it means "I looked hard and found nothing." For debug, this often surfaces a `not_applicable` outcome instead (root cause is elsewhere), but zero findings is still a success.
|
|
198
|
+
|
|
199
|
+
### Per-route legal outcomes
|
|
200
|
+
|
|
201
|
+
The legal outcomes for this route are: `['found', 'not_applicable']`
|
|
202
|
+
|
|
203
|
+
- **`found`** — one or more root-cause hypotheses were identified across the investigation criteria.
|
|
204
|
+
- **`not_applicable`** — the failure could not be diagnosed (reproduction failed, wrong area, or scope issue).
|
|
205
|
+
|
|
206
|
+
The outcome `clean` (zero findings + success) is not legal for `mma-debug` because a debug session always either identifies a root cause or cannot proceed.
|
|
207
|
+
|
|
208
|
+
@include _shared/error-handling.md
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mma-delegate
|
|
3
|
+
description: >-
|
|
4
|
+
Use when you have one or more ad-hoc implementation or research tasks WITHOUT
|
|
5
|
+
a plan file on disk and you want them to run on cheap workers in parallel
|
|
6
|
+
instead of consuming main-context tokens
|
|
7
|
+
when_to_use: >-
|
|
8
|
+
You have ad-hoc implementation or research tasks (no plan file on disk) AND
|
|
9
|
+
mmagent is running. Prefer this over inline Agent dispatches or
|
|
10
|
+
superpowers:dispatching-parallel-agents — workers are cheaper, parallel-safe,
|
|
11
|
+
and keep main context free. If a plan file exists → use mma-execute-plan. If
|
|
12
|
+
the task is audit / review / verify / debug / investigate → use the matching
|
|
13
|
+
specialized skill.
|
|
14
|
+
version: 5.0.3
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# mma-delegate
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
Dispatch one or more ad-hoc tasks to workers concurrently. Each task is an independent instruction with optional file scope, acceptance criteria, and context blocks.
|
|
22
|
+
|
|
23
|
+
**Core principle:** Workers run on cheap providers; the main agent consumes only the structured per-task report. Parallelize freely as long as tasks don't write the same files.
|
|
24
|
+
|
|
25
|
+
## When to Use
|
|
26
|
+
|
|
27
|
+
**Use when:**
|
|
28
|
+
- 2+ unrelated implementation tasks (parallel speedup)
|
|
29
|
+
- A research task you'd otherwise spend tokens reading and grepping
|
|
30
|
+
- A focused refactor that fits in one prompt
|
|
31
|
+
- The task does NOT match audit / review / verify / debug / investigate (those have specialized skills)
|
|
32
|
+
|
|
33
|
+
**Don't use when:**
|
|
34
|
+
- A plan file exists on disk → `mma-execute-plan` (descriptors auto-match plan headings)
|
|
35
|
+
- Two tasks write the same file → dispatch sequentially, not in one batch (workers race)
|
|
36
|
+
- The work needs to read across many files for synthesis only → `mma-investigate` is cheaper (read-only)
|
|
37
|
+
|
|
38
|
+
## Endpoint
|
|
39
|
+
|
|
40
|
+
`POST /delegate?cwd=<abs-path>`
|
|
41
|
+
|
|
42
|
+
@include _shared/auth.md
|
|
43
|
+
|
|
44
|
+
## Request body
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"tasks": [
|
|
49
|
+
{
|
|
50
|
+
"prompt": "Add input validation to the login handler",
|
|
51
|
+
"agentType": "standard",
|
|
52
|
+
"filePaths": ["/project/src/auth/login.ts"],
|
|
53
|
+
"done": "All inputs validated; unit tests pass",
|
|
54
|
+
"contextBlockIds": ["cb_abc123"]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
| Field | Type | Required | Notes |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `tasks` | array | yes | At least one task |
|
|
63
|
+
| `tasks[].prompt` | string | yes | The task instruction |
|
|
64
|
+
| `tasks[].agentType` | `"standard"` / `"complex"` | no | Worker tier. Default `"standard"`. Pick `"complex"` when the task is ambiguous, security-sensitive, touches many files, or a prior standard run came back with `filesWritten: 0` / hit `incompleteReason: "turn_cap"`. |
|
|
65
|
+
| `tasks[].filePaths` | string[] | no | Files the worker focuses on |
|
|
66
|
+
| `tasks[].done` | string | no | Acceptance criteria |
|
|
67
|
+
| `tasks[].contextBlockIds` | string[] | no | IDs from `mma-context-blocks` |
|
|
68
|
+
| `tasks[].reviewPolicy` | `"full"` / `"quality_only"` / `"diff_only"` / `"none"` | no | See review-policy snippet below. Default `"full"` |
|
|
69
|
+
|
|
70
|
+
@include _shared/review-policy.md
|
|
71
|
+
|
|
72
|
+
## Full example
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
BATCH=$(curl -f --show-error -s -X POST \
|
|
76
|
+
-H "X-MMA-Client: $MMA_CLIENT" \
|
|
77
|
+
-H "X-MMA-Main-Model: $MMA_MAIN_MODEL" \
|
|
78
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
79
|
+
-H "Content-Type: application/json" \
|
|
80
|
+
-d '{"tasks":[{"prompt":"Refactor utils.ts to remove dead code","filePaths":["/project/src/utils.ts"]}]}' \
|
|
81
|
+
"http://localhost:$PORT/delegate?cwd=/project")
|
|
82
|
+
BATCH_ID=$(echo "$BATCH" | jq -r '.batchId')
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
@include _shared/polling.md
|
|
86
|
+
|
|
87
|
+
## Response shapes
|
|
88
|
+
|
|
89
|
+
### POST /delegate?cwd=<abs> — dispatch response (202)
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{ "batchId": "<uuid>", "statusUrl": "/batch/<uuid>" }
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use `batchId` to poll. `statusUrl` is a convenience pointer.
|
|
96
|
+
|
|
97
|
+
### GET /batch/:id — polling response
|
|
98
|
+
|
|
99
|
+
The HTTP status is the state discriminator:
|
|
100
|
+
|
|
101
|
+
| Status | Meaning |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `202 text/plain` | Still pending — body is the running headline string |
|
|
104
|
+
| `200 application/json` | Terminal — body is the batch envelope below |
|
|
105
|
+
| `404` / `401` / `5xx` | Error — see Error response below; stop polling |
|
|
106
|
+
|
|
107
|
+
### GET /batch/:id?taskIndex=N — single task slice
|
|
108
|
+
|
|
109
|
+
Same envelope. `results` contains exactly the task at index `N`. Returns `404 unknown_task_index` if `N` is out of range.
|
|
110
|
+
|
|
111
|
+
### Reading the task result
|
|
112
|
+
|
|
113
|
+
Each task result is the per-task wire object (`ComposePayload`):
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"completed": true,
|
|
118
|
+
"message": "Task completed; tests passed; one file changed.",
|
|
119
|
+
"findings": [
|
|
120
|
+
{
|
|
121
|
+
"id": "F1",
|
|
122
|
+
"severity": "high",
|
|
123
|
+
"category": "correctness",
|
|
124
|
+
"claim": "The function does not handle empty input",
|
|
125
|
+
"evidence": "function foo() { ... } // no null check",
|
|
126
|
+
"suggestion": "Add an explicit null guard at the top",
|
|
127
|
+
"source": "reviewer"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"summary": "Refactored utils.ts — removed 3 dead branches, added JSDoc",
|
|
131
|
+
"filesChanged": ["/project/src/utils.ts"],
|
|
132
|
+
"commitSha": "abc123def",
|
|
133
|
+
"blockId": null,
|
|
134
|
+
"telemetry": {
|
|
135
|
+
"totalDurationMs": 12400,
|
|
136
|
+
"totalCostUSD": 0.08,
|
|
137
|
+
"workerSelfAssessment": "done",
|
|
138
|
+
"reviewVerdict": "approved",
|
|
139
|
+
"commitOutcome": "committed",
|
|
140
|
+
"stopReason": "normal",
|
|
141
|
+
"haltedStage": null,
|
|
142
|
+
"stages": [
|
|
143
|
+
{ "name": "prepare", "outcome": "advance", "durationMs": 2, "costUSD": 0 },
|
|
144
|
+
{ "name": "register-block", "outcome": "skip", "comment": "register-block does not apply to route=delegate", "durationMs": 0, "costUSD": 0 },
|
|
145
|
+
{ "name": "implement", "outcome": "advance", "durationMs": 8900, "costUSD": 0.05 },
|
|
146
|
+
{ "name": "review", "outcome": "advance", "durationMs": 2100, "costUSD": 0.02 },
|
|
147
|
+
{ "name": "rework", "outcome": "skip", "comment": "rework skipped because review approved", "durationMs": 0, "costUSD": 0 },
|
|
148
|
+
{ "name": "commit", "outcome": "advance", "durationMs": 340, "costUSD": 0 },
|
|
149
|
+
{ "name": "annotate", "outcome": "advance", "durationMs": 890, "costUSD": 0.01 },
|
|
150
|
+
{ "name": "compose", "outcome": "advance", "durationMs": 68, "costUSD": 0 },
|
|
151
|
+
{ "name": "terminal", "outcome": "advance", "durationMs": 100, "costUSD": 0 }
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Top-level fields to read for the main-agent verdict:**
|
|
158
|
+
|
|
159
|
+
| Field | When `true` / populated |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `completed: true` | Task succeeded. `message` is the summary; `findings` are post-review issues (if any). |
|
|
162
|
+
| `completed: false` | Task did not complete. `message` names the blocking gate or finding; `findings` carry any discovered issues. |
|
|
163
|
+
| `findings` | Issues surfaced by the worker or reviewer. `severity` = `critical` \| `high` \| `medium` \| `low`. `source` = `implementer` \| `reviewer`. |
|
|
164
|
+
| `filesChanged` | File paths modified (empty for read-only routes). |
|
|
165
|
+
| `commitSha` | Git SHA of the committed diff; `null` for read-only routes or when commit was skipped. |
|
|
166
|
+
|
|
167
|
+
`blockId` is not used for the delegate route — it is always `null`, as is `contextBlockId` (write routes register no terminal block). To carry inputs forward, register them explicitly via `mma-context-blocks` and pass `contextBlockIds`.
|
|
168
|
+
|
|
169
|
+
**The stages array** (always 9 rows) is the canonical telemetry log. `outcome` is one of:
|
|
170
|
+
- `advance` — stage ran and produced its payload
|
|
171
|
+
- `skip` — stage did not run; `comment` explains why
|
|
172
|
+
- `halt` — stage stopped the chain; `comment` is the failure message
|
|
173
|
+
- `not_run` — stage was not reached because a prior stage halted
|
|
174
|
+
|
|
175
|
+
Use `telemetry.haltedStage` to find the first halt; `telemetry.stopReason` to find why.
|
|
176
|
+
|
|
177
|
+
### Error response (4xx / 5xx)
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"error": "<code>",
|
|
182
|
+
"message": "<human-readable>",
|
|
183
|
+
"details": { /* optional structured context, e.g. fieldErrors for 400 */ }
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`details` is optional and present only when the server has structured additional context.
|
|
188
|
+
|
|
189
|
+
## Best practices
|
|
190
|
+
|
|
191
|
+
This skill is one step in the larger flow described in `multi-model-agent` → "Best practices". Recipes that involve `mma-delegate`:
|
|
192
|
+
|
|
193
|
+
- **Recipe A (the fix step).** Between audit rounds, `mma-delegate` applies the fix when the change is more than 1-2 lines. Register the spec/audit findings as a context block; pass via `contextBlockIds`.
|
|
194
|
+
- **Recipe B (the apply-fix step).** After `mma-debug` returns a hypothesis, `mma-delegate` applies the fix. Same context block carries forward to a follow-up `mma-review` if you want acceptance-criteria checking.
|
|
195
|
+
|
|
196
|
+
Anti-pattern alert: **`inline-labor-leakage`** (AP2). If you're reading 3+ files or grepping in main context before dispatching, you're paying flagship-model tokens for labor. Pass the file paths to `mma-delegate` and let the worker read.
|
|
197
|
+
|
|
198
|
+
## Common pitfalls
|
|
199
|
+
|
|
200
|
+
❌ **Two tasks writing the same file in one batch**
|
|
201
|
+
> tasks: [{prompt:"add JWT to login.ts"}, {prompt:"add logging to login.ts"}]
|
|
202
|
+
|
|
203
|
+
Workers run concurrently and race on the file. **Fix:** dispatch sequentially, or merge into one prompt.
|
|
204
|
+
|
|
205
|
+
❌ **Two tasks writing the same file in one batch**
|
|
206
|
+
N tasks × 50KB = N transmissions. **Fix:** register the doc once via `mma-context-blocks`, pass the `contextBlockIds` to each task.
|
|
207
|
+
|
|
208
|
+
❌ **Reading the worker's diff inline before review**
|
|
209
|
+
The reviewer sees the full diff with the original prompt as context. Reading inline burns main-context tokens for no quality gain.
|
|
210
|
+
|
|
211
|
+
## Terminal context block
|
|
212
|
+
|
|
213
|
+
Write-route tasks (delegate / execute-plan / retry) do NOT register a terminal context block — their durable record is the commit (`commitSha` + changed files). The per-task result's `contextBlockId` is always `null` for these routes. Read routes (audit / review / debug / investigate / research) return a non-null `contextBlockId`; see those skills for the delta-follow-up recipe.
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@include _shared/error-handling.md
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mma-execute-plan
|
|
3
|
+
description: >-
|
|
4
|
+
Use when a plan or spec file exists on disk (any markdown with numbered task
|
|
5
|
+
headings — docs/superpowers/plans/*.md, a TODO list, a spec doc) and you need
|
|
6
|
+
to implement one or more tasks from it on cheap workers in parallel
|
|
7
|
+
when_to_use: >-
|
|
8
|
+
A plan file exists on disk AND you need to implement one or more tasks from it
|
|
9
|
+
AND mmagent is running. Prefer this over inline Agent dispatches or
|
|
10
|
+
superpowers:subagent-driven-development / superpowers:executing-plans —
|
|
11
|
+
workers are cheaper and don't pollute main context. Task descriptors must
|
|
12
|
+
match plan headings verbatim.
|
|
13
|
+
version: 5.0.3
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# mma-execute-plan
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
Dispatch named tasks from a plan file to workers. Each `taskDescriptors` string must match a heading in the plan verbatim (e.g. `"1. Setup database schema"`). All tasks run in parallel; duplicate descriptors are rejected.
|
|
21
|
+
|
|
22
|
+
**Core principle:** The plan IS the prompt. Workers re-read the plan file in-process and find their named task — you don't need to inline the task body.
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
**Use when:**
|
|
27
|
+
- A plan/spec markdown exists with numbered task headings
|
|
28
|
+
- You want to dispatch a subset (or all) of those tasks
|
|
29
|
+
- Tasks are mostly independent (parallel-safe)
|
|
30
|
+
|
|
31
|
+
**Don't use when:**
|
|
32
|
+
- No plan file → `mma-delegate` (pass the prompt directly)
|
|
33
|
+
- Tasks form a hard linear sequence (later tasks depend on earlier ones' outputs) → dispatch in order, one batch each
|
|
34
|
+
- The "plan" is in conversation only, not on disk → write it to disk first, or use `mma-delegate`
|
|
35
|
+
|
|
36
|
+
## Endpoint
|
|
37
|
+
|
|
38
|
+
`POST /execute-plan?cwd=<abs-path>`
|
|
39
|
+
|
|
40
|
+
@include _shared/auth.md
|
|
41
|
+
|
|
42
|
+
## Request body
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"taskDescriptors": [
|
|
47
|
+
"1. Add input validation to login handler",
|
|
48
|
+
"2. Write unit tests for the auth module"
|
|
49
|
+
],
|
|
50
|
+
"filePaths": [
|
|
51
|
+
"/project/docs/plan.md"
|
|
52
|
+
],
|
|
53
|
+
"contextBlockIds": []
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| Field | Type | Required | Notes |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| `taskDescriptors` | string[] | yes | At least one; must be unique; each string matches a plan heading verbatim |
|
|
60
|
+
| `filePaths` | string[] | yes | EXACTLY one entry: the plan markdown file. Source files belong in `contextBlockIds` (registered via `mma-context-blocks`) so workers can grep them on demand without re-inlining into every worker prompt |
|
|
61
|
+
| `contextBlockIds` | string[] | no | IDs from `mma-context-blocks` — the right place for source files referenced by the plan |
|
|
62
|
+
| `perTaskReviewPolicy` | `Record<string, 'full'\|'quality_only'\|'diff_only'\|'none'>` | no | Per-task-index review policy override. Key = task index as string (`"0"`, `"1"`, ...). Default per task: `"full"` |
|
|
63
|
+
| `cwd` | string | no | Override the `?cwd=` query param value at the body level (rare; usually pass via query) |
|
|
64
|
+
|
|
65
|
+
@include _shared/review-policy.md
|
|
66
|
+
|
|
67
|
+
> **No `agentType` here.** Worker tier is hardcoded to `standard` for every plan task; sending `agentType` (top-level or per-task) is rejected with HTTP 400. For tasks that need `complex` tier, dispatch via `mma-delegate` with the plan task as the prompt and `agentType: "complex"`.
|
|
68
|
+
|
|
69
|
+
## Full example
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
BATCH=$(curl -f --show-error -s -X POST \
|
|
73
|
+
-H "X-MMA-Client: $MMA_CLIENT" \
|
|
74
|
+
-H "X-MMA-Main-Model: $MMA_MAIN_MODEL" \
|
|
75
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
76
|
+
-H "Content-Type: application/json" \
|
|
77
|
+
-d '{"taskDescriptors":["3. Migrate database schema"],"filePaths":["/project/docs/plan.md"]}' \
|
|
78
|
+
"http://localhost:$PORT/execute-plan?cwd=/project")
|
|
79
|
+
BATCH_ID=$(echo "$BATCH" | jq -r '.batchId')
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
@include _shared/polling.md
|
|
83
|
+
|
|
84
|
+
## Response shapes
|
|
85
|
+
|
|
86
|
+
### POST /execute-plan?cwd=<abs> — dispatch response (202)
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{ "batchId": "<uuid>", "statusUrl": "/batch/<uuid>" }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Use `batchId` to poll. `statusUrl` is a convenience pointer.
|
|
93
|
+
|
|
94
|
+
### GET /batch/:id — polling response
|
|
95
|
+
|
|
96
|
+
The HTTP status is the state discriminator:
|
|
97
|
+
|
|
98
|
+
| Status | Meaning |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `202 text/plain` | Still pending — body is the running headline string |
|
|
101
|
+
| `200 application/json` | Terminal — body is the batch envelope below |
|
|
102
|
+
| `404` / `401` / `5xx` | Error — see Error response below; stop polling |
|
|
103
|
+
|
|
104
|
+
### GET /batch/:id?taskIndex=N — single task slice
|
|
105
|
+
|
|
106
|
+
Same envelope. `results` contains exactly the task at index `N`. Returns `404 unknown_task_index` if `N` is out of range.
|
|
107
|
+
|
|
108
|
+
### Reading the task result
|
|
109
|
+
|
|
110
|
+
Each task result is the per-task wire object (`ComposePayload`):
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"completed": true,
|
|
115
|
+
"message": "Task completed; tests passed; one file changed.",
|
|
116
|
+
"findings": [
|
|
117
|
+
{
|
|
118
|
+
"id": "F1",
|
|
119
|
+
"severity": "high",
|
|
120
|
+
"category": "correctness",
|
|
121
|
+
"claim": "The function does not handle empty input",
|
|
122
|
+
"evidence": "function foo() { ... } // no null check",
|
|
123
|
+
"suggestion": "Add an explicit null guard at the top",
|
|
124
|
+
"source": "reviewer"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"summary": "Refactored utils.ts — removed 3 dead branches, added JSDoc",
|
|
128
|
+
"filesChanged": ["/project/src/utils.ts"],
|
|
129
|
+
"commitSha": "abc123def",
|
|
130
|
+
"blockId": null,
|
|
131
|
+
"telemetry": {
|
|
132
|
+
"totalDurationMs": 12400,
|
|
133
|
+
"totalCostUSD": 0.08,
|
|
134
|
+
"workerSelfAssessment": "done",
|
|
135
|
+
"reviewVerdict": "approved",
|
|
136
|
+
"commitOutcome": "committed",
|
|
137
|
+
"stopReason": "normal",
|
|
138
|
+
"haltedStage": null,
|
|
139
|
+
"stages": [
|
|
140
|
+
{ "name": "prepare", "outcome": "advance", "durationMs": 2, "costUSD": 0 },
|
|
141
|
+
{ "name": "register-block", "outcome": "skip", "comment": "register-block does not apply to route=execute-plan", "durationMs": 0, "costUSD": 0 },
|
|
142
|
+
{ "name": "implement", "outcome": "advance", "durationMs": 8900, "costUSD": 0.05 },
|
|
143
|
+
{ "name": "review", "outcome": "advance", "durationMs": 2100, "costUSD": 0.02 },
|
|
144
|
+
{ "name": "rework", "outcome": "skip", "comment": "rework skipped because review approved", "durationMs": 0, "costUSD": 0 },
|
|
145
|
+
{ "name": "commit", "outcome": "advance", "durationMs": 340, "costUSD": 0 },
|
|
146
|
+
{ "name": "annotate", "outcome": "advance", "durationMs": 890, "costUSD": 0.01 },
|
|
147
|
+
{ "name": "compose", "outcome": "advance", "durationMs": 68, "costUSD": 0 },
|
|
148
|
+
{ "name": "terminal", "outcome": "advance", "durationMs": 100, "costUSD": 0 }
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Top-level fields to read for the main-agent verdict:**
|
|
155
|
+
|
|
156
|
+
| Field | When `true` / populated |
|
|
157
|
+
|---|---|
|
|
158
|
+
| `completed: true` | Task succeeded. `message` is the summary; `findings` are post-review issues (if any). |
|
|
159
|
+
| `completed: false` | Task did not complete. `message` names the blocking gate or finding; `findings` carry any discovered issues. |
|
|
160
|
+
| `findings` | Issues surfaced by the worker or reviewer. `severity` = `critical` \| `high` \| `medium` \| `low`. `source` = `implementer` \| `reviewer`. |
|
|
161
|
+
| `filesChanged` | File paths modified (empty for read-only routes). |
|
|
162
|
+
| `commitSha` | Git SHA of the committed diff; `null` for read-only routes or when commit was skipped. |
|
|
163
|
+
| `blockId` | Always `null` (execute-plan is a write route; `contextBlockId` is `null` too — no terminal block). |
|
|
164
|
+
|
|
165
|
+
**The stages array** (always 9 rows) is the canonical telemetry log. `outcome` is one of:
|
|
166
|
+
- `advance` — stage ran and produced its payload
|
|
167
|
+
- `skip` — stage did not run; `comment` explains why
|
|
168
|
+
- `halt` — stage stopped the chain; `comment` is the failure message
|
|
169
|
+
- `not_run` — stage was not reached because a prior stage halted
|
|
170
|
+
|
|
171
|
+
Use `telemetry.haltedStage` to find the first halt; `telemetry.stopReason` to find why.
|
|
172
|
+
|
|
173
|
+
### Error response (4xx / 5xx)
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"error": "<code>",
|
|
178
|
+
"message": "<human-readable>",
|
|
179
|
+
"details": { /* optional structured context, e.g. fieldErrors for 400 */ }
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`details` is optional and present only when the server has structured additional context.
|
|
184
|
+
|
|
185
|
+
## Best practices
|
|
186
|
+
|
|
187
|
+
This skill is one step in the larger flow described in `multi-model-agent` → "Best practices". Recipes that involve `mma-execute-plan`:
|
|
188
|
+
|
|
189
|
+
- **Recipe C — Investigate-plan-execute.** `mma-investigate` → write the plan → `mma-execute-plan` → `mma-retry` on failed indices. Register the plan file as a context block before the execute-plan call so it isn't re-inlined into every worker's prompt; retry inherits the same configuration.
|
|
190
|
+
- **Recipe D — Plan-execute-retry (entry point).** `mma-execute-plan` is the producer of the `batchId` that `mma-retry` consumes. When this batch returns mixed `done` / `failed`, the next call is `mma-retry` with failed indices, NOT a re-dispatch.
|
|
191
|
+
|
|
192
|
+
Anti-pattern alert: **`full-batch-redispatch`** (AP4). When the batch returns mixed `done` / `failed`, do NOT re-run the whole task list — use `mma-retry` with the failed indices only. Re-running the whole list re-charges every successful task.
|
|
193
|
+
|
|
194
|
+
## Common pitfalls
|
|
195
|
+
|
|
196
|
+
❌ **Task descriptor doesn't match plan heading verbatim**
|
|
197
|
+
> taskDescriptors: ["Migrate db schema"] ← plan heading is "3. Migrate database schema"
|
|
198
|
+
|
|
199
|
+
Worker rejects with "no matching task" or matches the wrong one. **Fix:** copy the heading from the plan, including the leading number.
|
|
200
|
+
|
|
201
|
+
❌ **Forgetting the plan file in `filePaths`**
|
|
202
|
+
> filePaths: ["/project/src/db/schema.sql"] ← no plan file
|
|
203
|
+
|
|
204
|
+
Worker can't read the task body. **Fix:** always include the plan path: `filePaths: ["/project/docs/plan.md", "/project/src/db/schema.sql"]`.
|
|
205
|
+
|
|
206
|
+
❌ **Dispatching dependent tasks in one batch**
|
|
207
|
+
Task 5 depends on Task 4's output → workers race; Task 5 might run before Task 4 finishes. **Fix:** dispatch Task 4, wait for terminal, then dispatch Task 5.
|
|
208
|
+
|
|
209
|
+
## Terminal context block
|
|
210
|
+
|
|
211
|
+
Write-route tasks (delegate / execute-plan / retry) do NOT register a terminal context block — their durable record is the commit (`commitSha` + changed files). The per-task result's `contextBlockId` is always `null` for these routes. Read routes (audit / review / debug / investigate / research) return a non-null `contextBlockId`; see those skills for the delta-follow-up recipe.
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@include _shared/error-handling.md
|