@muggleai/works 4.10.0 → 4.11.0

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 (197) hide show
  1. package/README.md +3 -3
  2. package/dist/{chunk-RK6XKSZK.js → chunk-Q7WNEMN4.js} +109 -43
  3. package/dist/{chunk-UVXOHXY2.js → chunk-ZKRHFTIC.js} +832 -89
  4. package/dist/cli.js +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  7. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  8. package/dist/plugin/README.md +4 -2
  9. package/dist/plugin/agents/acceptance-tester.md +24 -10
  10. package/dist/plugin/commands/m.md +7 -0
  11. package/dist/plugin/commands/mdo.md +7 -0
  12. package/dist/plugin/commands/mfeedback.md +7 -0
  13. package/dist/plugin/commands/mimport.md +7 -0
  14. package/dist/plugin/commands/mpr.md +7 -0
  15. package/dist/plugin/commands/mprefs.md +7 -0
  16. package/dist/plugin/commands/mregen.md +7 -0
  17. package/dist/plugin/commands/mrelease.md +7 -0
  18. package/dist/plugin/commands/mrepair.md +7 -0
  19. package/dist/plugin/commands/mstatus.md +7 -0
  20. package/dist/plugin/commands/mtest.md +7 -0
  21. package/dist/plugin/commands/mtestlocal.md +7 -0
  22. package/dist/plugin/commands/mtestprep.md +7 -0
  23. package/dist/plugin/commands/mupgrade.md +7 -0
  24. package/dist/plugin/scripts/ensure-electron-app.sh +35 -8
  25. package/dist/plugin/skills/_aliases.json +18 -0
  26. package/dist/plugin/skills/_shared/dev-server-readiness.md +231 -0
  27. package/dist/plugin/skills/_shared/failure-mode-handling.md +244 -0
  28. package/dist/plugin/skills/_shared/post-merge-cleanup.md +10 -0
  29. package/dist/plugin/skills/_shared/pr-followup-helpers.md +150 -0
  30. package/dist/plugin/skills/_shared/rebase-before-e2e.md +15 -0
  31. package/dist/plugin/skills/_shared/telemetry-emit.md +15 -0
  32. package/dist/plugin/skills/_shared/use-worktrees.md +53 -0
  33. package/dist/plugin/skills/do/build.md +51 -0
  34. package/dist/plugin/skills/do/e2e-acceptance.md +64 -19
  35. package/dist/plugin/skills/do/impact-analysis.md +47 -7
  36. package/dist/plugin/skills/do/open-prs.md +72 -74
  37. package/dist/plugin/skills/do/pre-flight.md +21 -14
  38. package/dist/plugin/skills/do/requirements.md +2 -2
  39. package/dist/plugin/skills/do/unit-tests.md +2 -2
  40. package/dist/plugin/skills/m/SKILL.md +8 -0
  41. package/dist/plugin/skills/mdo/SKILL.md +8 -0
  42. package/dist/plugin/skills/mfeedback/SKILL.md +8 -0
  43. package/dist/plugin/skills/mimport/SKILL.md +8 -0
  44. package/dist/plugin/skills/mpr/SKILL.md +8 -0
  45. package/dist/plugin/skills/mprefs/SKILL.md +8 -0
  46. package/dist/plugin/skills/mregen/SKILL.md +8 -0
  47. package/dist/plugin/skills/mrelease/SKILL.md +8 -0
  48. package/dist/plugin/skills/mrepair/SKILL.md +8 -0
  49. package/dist/plugin/skills/mstatus/SKILL.md +8 -0
  50. package/dist/plugin/skills/mtest/SKILL.md +8 -0
  51. package/dist/plugin/skills/mtestlocal/SKILL.md +8 -0
  52. package/dist/plugin/skills/mtestprep/SKILL.md +8 -0
  53. package/dist/plugin/skills/muggle/SKILL.md +9 -6
  54. package/dist/plugin/skills/muggle-do/SKILL.md +36 -61
  55. package/dist/plugin/skills/muggle-do-task/SKILL.md +134 -0
  56. package/dist/plugin/skills/muggle-feedback/SKILL.md +39 -0
  57. package/dist/plugin/skills/muggle-feedback/ops/delete.md +49 -0
  58. package/dist/plugin/skills/muggle-feedback/ops/list.md +65 -0
  59. package/dist/plugin/skills/muggle-feedback/ops/submit.md +130 -0
  60. package/dist/plugin/skills/muggle-pr-followup/SKILL.md +59 -0
  61. package/dist/plugin/skills/muggle-pr-followup/contract.md +191 -0
  62. package/dist/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +68 -43
  63. package/dist/plugin/skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md +86 -0
  64. package/dist/plugin/skills/muggle-preferences/SKILL.md +16 -108
  65. package/dist/plugin/skills/muggle-preferences/ops/change-one.md +10 -0
  66. package/dist/plugin/skills/muggle-preferences/ops/configure.md +49 -0
  67. package/dist/plugin/skills/muggle-preferences/ops/list.md +9 -0
  68. package/dist/plugin/skills/muggle-preferences/ops/reset.md +6 -0
  69. package/dist/plugin/skills/muggle-preferences/ops/set.md +10 -0
  70. package/dist/plugin/skills/muggle-preferences/preference-gates/README.md +1 -1
  71. package/dist/plugin/skills/muggle-preferences/preference-gates/autoCleanup.md +11 -0
  72. package/dist/plugin/skills/muggle-preferences/preference-gates/autoCreatePR.md +13 -0
  73. package/dist/plugin/skills/muggle-preferences/preference-gates/autoDetectChanges.md +3 -3
  74. package/dist/plugin/skills/muggle-preferences/preference-gates/autoE2ETest.md +11 -0
  75. package/dist/plugin/skills/muggle-preferences/preference-gates/autoLogin.md +1 -1
  76. package/dist/plugin/skills/muggle-preferences/preference-gates/autoPublishLocalResults.md +2 -2
  77. package/dist/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +11 -0
  78. package/dist/plugin/skills/muggle-preferences/preference-gates/autoSelectLocalHost.md +19 -0
  79. package/dist/plugin/skills/muggle-preferences/preference-gates/autoSelectProject.md +1 -2
  80. package/dist/plugin/skills/muggle-preferences/preference-gates/autoUseWorktree.md +11 -0
  81. package/dist/plugin/skills/muggle-preferences/preference-gates/checkForUpdates.md +4 -4
  82. package/dist/plugin/skills/muggle-preferences/preference-gates/defaultExecutionMode.md +1 -1
  83. package/dist/plugin/skills/muggle-preferences/preference-gates/openTestResultsAfterRun.md +1 -1
  84. package/dist/plugin/skills/muggle-preferences/preference-gates/postPRVisualWalkthrough.md +8 -25
  85. package/dist/plugin/skills/muggle-preferences/preference-gates/showElectronBrowser.md +1 -1
  86. package/dist/plugin/skills/muggle-preferences/preference-gates/suggestRelatedTestCases.md +4 -4
  87. package/dist/plugin/skills/muggle-preferences/preference-gates/suggestRelatedUseCases.md +4 -4
  88. package/dist/plugin/skills/muggle-repair/SKILL.md +4 -2
  89. package/dist/plugin/skills/muggle-status/SKILL.md +8 -5
  90. package/dist/plugin/skills/muggle-test/SKILL.md +110 -86
  91. package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +83 -62
  92. package/dist/plugin/skills/muggle-test-import/SKILL.md +28 -23
  93. package/dist/plugin/skills/muggle-test-prepare/SKILL.md +79 -18
  94. package/dist/plugin/skills/muggle-test-regenerate-missing/SKILL.md +34 -18
  95. package/dist/plugin/skills/muggle-test-regenerate-missing/evals/evals.json +9 -9
  96. package/dist/plugin/skills/muggle-upgrade/SKILL.md +4 -2
  97. package/dist/plugin/skills/muggle-works-npm-release/SKILL.md +6 -4
  98. package/dist/plugin/skills/mupgrade/SKILL.md +8 -0
  99. package/dist/release-manifest.json +4 -4
  100. package/dist/{src-GD3YFCCW.js → src-2G7ENRGI.js} +1 -1
  101. package/package.json +9 -7
  102. package/plugin/.claude-plugin/plugin.json +1 -1
  103. package/plugin/.cursor-plugin/plugin.json +1 -1
  104. package/plugin/README.md +4 -2
  105. package/plugin/agents/acceptance-tester.md +24 -10
  106. package/plugin/commands/m.md +7 -0
  107. package/plugin/commands/mdo.md +7 -0
  108. package/plugin/commands/mfeedback.md +7 -0
  109. package/plugin/commands/mimport.md +7 -0
  110. package/plugin/commands/mpr.md +7 -0
  111. package/plugin/commands/mprefs.md +7 -0
  112. package/plugin/commands/mregen.md +7 -0
  113. package/plugin/commands/mrelease.md +7 -0
  114. package/plugin/commands/mrepair.md +7 -0
  115. package/plugin/commands/mstatus.md +7 -0
  116. package/plugin/commands/mtest.md +7 -0
  117. package/plugin/commands/mtestlocal.md +7 -0
  118. package/plugin/commands/mtestprep.md +7 -0
  119. package/plugin/commands/mupgrade.md +7 -0
  120. package/plugin/scripts/ensure-electron-app.sh +35 -8
  121. package/plugin/skills/_aliases.json +18 -0
  122. package/plugin/skills/_shared/dev-server-readiness.md +231 -0
  123. package/plugin/skills/_shared/failure-mode-handling.md +244 -0
  124. package/plugin/skills/_shared/post-merge-cleanup.md +10 -0
  125. package/plugin/skills/_shared/pr-followup-helpers.md +150 -0
  126. package/plugin/skills/_shared/rebase-before-e2e.md +15 -0
  127. package/plugin/skills/_shared/telemetry-emit.md +15 -0
  128. package/plugin/skills/_shared/use-worktrees.md +53 -0
  129. package/plugin/skills/do/build.md +51 -0
  130. package/plugin/skills/do/e2e-acceptance.md +64 -19
  131. package/plugin/skills/do/impact-analysis.md +47 -7
  132. package/plugin/skills/do/open-prs.md +72 -74
  133. package/plugin/skills/do/pre-flight.md +21 -14
  134. package/plugin/skills/do/requirements.md +2 -2
  135. package/plugin/skills/do/unit-tests.md +2 -2
  136. package/plugin/skills/m/SKILL.md +8 -0
  137. package/plugin/skills/mdo/SKILL.md +8 -0
  138. package/plugin/skills/mfeedback/SKILL.md +8 -0
  139. package/plugin/skills/mimport/SKILL.md +8 -0
  140. package/plugin/skills/mpr/SKILL.md +8 -0
  141. package/plugin/skills/mprefs/SKILL.md +8 -0
  142. package/plugin/skills/mregen/SKILL.md +8 -0
  143. package/plugin/skills/mrelease/SKILL.md +8 -0
  144. package/plugin/skills/mrepair/SKILL.md +8 -0
  145. package/plugin/skills/mstatus/SKILL.md +8 -0
  146. package/plugin/skills/mtest/SKILL.md +8 -0
  147. package/plugin/skills/mtestlocal/SKILL.md +8 -0
  148. package/plugin/skills/mtestprep/SKILL.md +8 -0
  149. package/plugin/skills/muggle/SKILL.md +9 -6
  150. package/plugin/skills/muggle-do/SKILL.md +36 -61
  151. package/plugin/skills/muggle-do-task/SKILL.md +134 -0
  152. package/plugin/skills/muggle-feedback/SKILL.md +39 -0
  153. package/plugin/skills/muggle-feedback/ops/delete.md +49 -0
  154. package/plugin/skills/muggle-feedback/ops/list.md +65 -0
  155. package/plugin/skills/muggle-feedback/ops/submit.md +130 -0
  156. package/plugin/skills/muggle-pr-followup/SKILL.md +59 -0
  157. package/plugin/skills/muggle-pr-followup/contract.md +191 -0
  158. package/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +68 -43
  159. package/plugin/skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md +86 -0
  160. package/plugin/skills/muggle-preferences/SKILL.md +16 -108
  161. package/plugin/skills/muggle-preferences/ops/change-one.md +10 -0
  162. package/plugin/skills/muggle-preferences/ops/configure.md +49 -0
  163. package/plugin/skills/muggle-preferences/ops/list.md +9 -0
  164. package/plugin/skills/muggle-preferences/ops/reset.md +6 -0
  165. package/plugin/skills/muggle-preferences/ops/set.md +10 -0
  166. package/plugin/skills/muggle-preferences/preference-gates/README.md +1 -1
  167. package/plugin/skills/muggle-preferences/preference-gates/autoCleanup.md +11 -0
  168. package/plugin/skills/muggle-preferences/preference-gates/autoCreatePR.md +13 -0
  169. package/plugin/skills/muggle-preferences/preference-gates/autoDetectChanges.md +3 -3
  170. package/plugin/skills/muggle-preferences/preference-gates/autoE2ETest.md +11 -0
  171. package/plugin/skills/muggle-preferences/preference-gates/autoLogin.md +1 -1
  172. package/plugin/skills/muggle-preferences/preference-gates/autoPublishLocalResults.md +2 -2
  173. package/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +11 -0
  174. package/plugin/skills/muggle-preferences/preference-gates/autoSelectLocalHost.md +19 -0
  175. package/plugin/skills/muggle-preferences/preference-gates/autoSelectProject.md +1 -2
  176. package/plugin/skills/muggle-preferences/preference-gates/autoUseWorktree.md +11 -0
  177. package/plugin/skills/muggle-preferences/preference-gates/checkForUpdates.md +4 -4
  178. package/plugin/skills/muggle-preferences/preference-gates/defaultExecutionMode.md +1 -1
  179. package/plugin/skills/muggle-preferences/preference-gates/openTestResultsAfterRun.md +1 -1
  180. package/plugin/skills/muggle-preferences/preference-gates/postPRVisualWalkthrough.md +8 -25
  181. package/plugin/skills/muggle-preferences/preference-gates/showElectronBrowser.md +1 -1
  182. package/plugin/skills/muggle-preferences/preference-gates/suggestRelatedTestCases.md +4 -4
  183. package/plugin/skills/muggle-preferences/preference-gates/suggestRelatedUseCases.md +4 -4
  184. package/plugin/skills/muggle-repair/SKILL.md +4 -2
  185. package/plugin/skills/muggle-status/SKILL.md +8 -5
  186. package/plugin/skills/muggle-test/SKILL.md +110 -86
  187. package/plugin/skills/muggle-test-feature-local/SKILL.md +83 -62
  188. package/plugin/skills/muggle-test-import/SKILL.md +28 -23
  189. package/plugin/skills/muggle-test-prepare/SKILL.md +79 -18
  190. package/plugin/skills/muggle-test-regenerate-missing/SKILL.md +34 -18
  191. package/plugin/skills/muggle-test-regenerate-missing/evals/evals.json +9 -9
  192. package/plugin/skills/muggle-upgrade/SKILL.md +4 -2
  193. package/plugin/skills/muggle-works-npm-release/SKILL.md +6 -4
  194. package/plugin/skills/mupgrade/SKILL.md +8 -0
  195. package/scripts/postinstall.mjs +11 -1
  196. package/dist/plugin/skills/do/validate-code.md +0 -38
  197. package/plugin/skills/do/validate-code.md +0 -38
@@ -1,106 +1,104 @@
1
- # PR Creation Agent (Stage 7/7)
1
+ # PR Creation Agent (Stage 7 — Open PR)
2
2
 
3
- You are creating pull requests for each repository that has changes after a successful dev cycle run.
3
+ Open a pull request for each repo that has changes. If an E2E walkthrough report is available from the previous stage, attach it. Honor preference gates. Hand off to stage 8 once done.
4
4
 
5
5
  ## Turn preamble
6
6
 
7
- Start the turn with:
8
-
9
7
  ```
10
- **Stage 7/7 — Open PR** — rendering the visual walkthrough and pushing the PR.
8
+ **Stage 7 — Open PR** — pushing the branch and opening the PR.
11
9
  ```
12
10
 
13
- ## Non-negotiable: visual walkthrough is required
14
-
15
- **You MUST invoke `muggle-pr-visual-walkthrough` (Mode B) to render the E2E section of the PR body.** Hand-writing the PR body with a text summary and `gh pr create` is a stage failure — reviewers rely on the dashboard links and per-step screenshots the walkthrough produces.
16
-
17
- If the E2E stage was skipped (validation was `unit-only` or `skip`), you may omit the walkthrough section — but mark the PR title with `[UNVERIFIED]` or `[UNIT-ONLY]` accordingly, and record the reason in the PR body under `## Validation`.
11
+ ## Inputs
18
12
 
19
- Before calling `gh pr create`, self-check:
13
+ - Per-repo: name, path, branch.
14
+ - Requirements: goal, acceptance criteria.
15
+ - **Optional** E2E acceptance report from stage 6 — only present when validation ran. Produced by [`e2e-acceptance.md`](e2e-acceptance.md); schema is canonical in [`muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md) (Zod-validated by the CLI).
20
16
 
21
- - [ ] `muggle-pr-visual-walkthrough` was invoked (or the skip reason is recorded).
22
- - [ ] The `body` returned by the skill is embedded verbatim in the PR body.
23
- - [ ] If `comment` is non-null, it will be posted as a follow-up after the PR is created.
17
+ ## Per repo
24
18
 
25
- If you cannot check all three, **halt** — do not create the PR. Fix the upstream stage first.
19
+ 0. **`autoCreatePR` gate** — apply per [`../muggle-preferences/preference-gates/autoCreatePR.md`](../muggle-preferences/preference-gates/autoCreatePR.md). On skip, record the reason in `result.md` and move on.
26
20
 
27
- ## Input
21
+ 1. **Push:** `git push -u origin <branch>` in the repo directory.
28
22
 
29
- You receive:
30
- - Per-repo: repo name, path, branch name
31
- - Requirements: goal, acceptance criteria
32
- - E2E acceptance report: passed/failed test cases, each with:
33
- - `testCaseId`, `testScriptId`, `runId`, `projectId`
34
- - `viewUrl`: link to view run on muggle-ai.com
35
- - `steps`: array of `{ stepIndex, action, screenshotUrl }`
36
- - `failureStepIndex` and `error` (if failed)
37
- - `artifactsDir` (for local debugging)
38
- - `description` and `useCaseName` (optional but recommended) — test case one-liner and parent use case title; drive the grouped overview and the per-test collapsible headers in the rendered walkthrough. Prefer values already in the `e2e-acceptance.md` stage's conversation context; only call `muggle-remote-test-case-get` / `muggle-remote-use-case-get` for anything you don't already have.
23
+ 2. **Title** (under 70 chars):
24
+ - E2E report exists and has failures → `[E2E FAILING] <goal>`
25
+ - No E2E report at all (validation was `unit-only` or `skip`) → `[UNVERIFIED] <goal>` or `[UNIT-ONLY] <goal>` to match the validation strategy
26
+ - Otherwise → `<goal>`
39
27
 
40
- ## Your Job
28
+ 3. **Body** — assemble in order:
29
+ - `## Goal` — from requirements.
30
+ - `## Acceptance Criteria` — bulleted; omit section if empty.
31
+ - `## Changes` — summary of what changed in this repo.
32
+ - `## Validation` — one line: link to E2E report, or `unit-only`, or `skip — <reason>`.
33
+ - **If an E2E report exists,** invoke [`muggle-pr-visual-walkthrough`](../muggle-pr-visual-walkthrough/SKILL.md) Mode B to render the walkthrough block. Embed the returned `body` verbatim (it brings its own `## E2E Acceptance Results` heading). If no report, skip this block entirely.
41
34
 
42
- For each repo with changes:
43
-
44
- 1. **Push the branch** to origin: `git push -u origin <branch-name>` in the repo directory.
45
- 2. **Build the PR title:**
46
- - If E2E acceptance tests have failures: `[E2E FAILING] <goal>`
47
- - Otherwise: `<goal>`
48
- - Keep under 70 characters
49
- 3. **Render the E2E acceptance block** by invoking the shared `muggle-pr-visual-walkthrough` skill in **Mode B** (render-only for embedding). See "Rendering the E2E acceptance block via the shared skill" below. You receive `{body, comment}` where `body` is the E2E markdown block and `comment` is a non-null overflow comment only when the content exceeds the CLI's byte budget.
50
- 4. **Build the PR body** by concatenating, in order:
51
- - `## Goal` — the requirements goal
52
- - `## Acceptance Criteria` — bulleted list (omit section if empty)
53
- - `## Changes` — summary of what changed in this repo
54
- - The `body` field from the skill output (already contains its own `## E2E Acceptance Results` header — do not add another)
55
- 5. **Create the PR** using `gh pr create --title "..." --body "..." --head <branch>` in the repo directory.
56
- 6. **Capture the PR URL** and extract the PR number.
57
- 7. **Post the overflow `comment` only if it is non-null.** In the common case, `comment` is `null` and nothing is posted. Never post speculatively.
35
+ 4. **Create:** `gh pr create --title "..." --body "..." --head <branch>`. Capture the PR URL and number.
58
36
 
37
+ 5. **Overflow comment:** if the walkthrough skill returned a non-null `comment`, post it once:
59
38
  ```bash
60
- gh pr comment <PR#> --body "$(cat <<'EOF'
61
- <comment field contents>
62
- EOF
63
- )"
39
+ jq -r '.comment' /tmp/muggle-pr-section.json | gh pr comment <PR#> --body-file -
64
40
  ```
41
+ Never post when `comment` is `null`.
65
42
 
66
- ## Rendering the E2E acceptance block via the shared skill
67
-
68
- **Do not hand-write the `## E2E Acceptance Results` markdown, and do not call `muggle build-pr-section` directly from this stage.** The rendering workflow is owned by the shared **`muggle-pr-visual-walkthrough`** skill (see `plugin/skills/muggle-pr-visual-walkthrough/SKILL.md`), which wraps the CLI and enforces the `E2eReport` input contract with a Zod schema.
69
-
70
- ### Input — the `E2eReport` JSON
43
+ ## Stage 8 handoff
71
44
 
72
- The `e2e-acceptance.md` stage already produces an `E2eReport` with the exact shape the skill expects (`projectId` + `tests[]` with per-test `name`, `testCaseId`, `testScriptId`, `runId`, `viewUrl`, `status`, and `steps[]` of `{stepIndex, action, screenshotUrl}`; failed tests additionally have `failureStepIndex`, `error`, and optionally `artifactsDir`; every test may additionally carry `description` and `useCaseName` — optional but recommended — which drive the grouped overview and per-test collapsible headers in the rendered walkthrough). Pass it through unchanged — do not reshape it. The full schema is documented in the shared skill.
45
+ After every repo is processed, build the manifest and dispatch **one follow-up loop per opened PR**. The dispatches are the LAST action this stage takes — once they fire, the original session is free.
73
46
 
74
- ### Invocation — Mode B (render-only)
47
+ Write `.muggle-do/sessions/<slug>/prs.json` with one entry per **opened** PR (skip repos where `autoCreatePR` short-circuited or PR creation failed):
75
48
 
76
- Invoke `muggle-pr-visual-walkthrough` via the `Skill` tool with the `E2eReport` already in context. The skill will:
49
+ ```json
50
+ [{ "repo": "owner/repo", "number": 142, "url": "...", "head_sha": "...", "state": "open" }]
51
+ ```
77
52
 
78
- 1. Validate the `E2eReport` and call `muggle build-pr-section` (piping the JSON to stdin).
79
- 2. Parse the CLI's `{body, comment}` stdout.
80
- 3. **Return `{body, comment}` to this stage's conversation** without posting anything — because Mode B is render-only. `body` is the E2E markdown block; `comment` is a non-null overflow follow-up comment only when content exceeds the byte budget, otherwise `null`.
53
+ Seed `.muggle-do/sessions/<slug>/last_seen.json` keyed by `"<owner>/<repo>#<n>"` with the empty-cursor shape (full shape in [`../muggle-pr-followup/contract.md`](../muggle-pr-followup/contract.md)). Stage 7 only seeds; each per-PR loop owns advancing its own cursor.
54
+
55
+ Also seed `.muggle-do/sessions/<slug>/cycle.json` — the muggle-do implementation cycle declaration the follow-up loop will invoke on each actionable review:
56
+
57
+ ```json
58
+ {
59
+ "cycleName": "muggle-do dev cycle",
60
+ "steps": [
61
+ { "stage": 3, "file": "../do/build.md" },
62
+ { "stage": 4, "file": "../do/impact-analysis.md" },
63
+ { "stage": 5, "file": "../do/unit-tests.md" },
64
+ { "stage": 6, "file": "../do/e2e-acceptance.md" },
65
+ { "name": "post-walkthrough", "skill": "muggle-pr-visual-walkthrough", "mode": "A" }
66
+ ],
67
+ "pushHandler": "git push origin <branch>",
68
+ "useSubagent": false
69
+ }
70
+ ```
81
71
 
82
- Mode A (where the skill itself finds an existing PR and posts a `gh pr comment`) is **not used by `muggle-do`** — it's for interactive callers like `muggle-test` that are mid-development with a PR already open. `muggle-do` always creates new PRs, so it always uses Mode B.
72
+ For each entry in `prs.json`, dispatch its own loop as the final action:
73
+ ```
74
+ /loop 1m /muggle:muggle-pr-followup <slug> <pr-number>
75
+ ```
76
+ Resolve `<slug>` from the session directory's basename. One loop per PR — multi-repo sessions opening N PRs result in N independent loops, each tracking its own PR's review thread.
83
77
 
84
- ### After rendering
78
+ If `prs.json` is empty (all repos skipped, or all PR creations failed), **do not dispatch** — record the reason in `result.md` and exit.
85
79
 
86
- Back in this stage:
80
+ ## Self-check before exit
87
81
 
88
- - Embed `body` in the `gh pr create --body` body (see step 4 above).
89
- - Post the overflow `comment` as a follow-up **only when it is non-null** (see step 7 above).
90
- - If the CLI exited non-zero, the skill surfaces the stderr error — do not swallow it, surface it to the user.
82
+ - [ ] Every non-skipped repo got `gh pr create` to succeed.
83
+ - [ ] When an E2E report existed, the walkthrough block was rendered via Mode B (not hand-written).
84
+ - [ ] Overflow `comment` was posted only when non-null.
85
+ - [ ] `prs.json` and `last_seen.json` reflect the PRs actually opened.
86
+ - [ ] If `prs.json` is non-empty, the `/loop` dispatch was the last action.
91
87
 
92
- ### Notes on fit vs. overflow
88
+ ## Output
93
89
 
94
- - **Common case (fit):** the full evidence (summary, per-test rows, collapsible failure details) lives in the PR description, `comment` is `null`, no follow-up comment is posted.
95
- - **Overflow case:** the CLI detects the full body would exceed its byte budget; `body` contains the summary, per-test rows, and a pointer line; `comment` contains the overflow details. Post both.
96
- - You do not make the fit-vs-overflow decision — the CLI does. Never post the comment when it is `null`.
90
+ **PRs Created:** repo → URL
91
+ **Skipped:** repo → reason (when `autoCreatePR` short-circuited)
92
+ **Overflow comments posted:** repo → PR #
93
+ **Stage 8:** `Watching <N> PR(s) — one /loop 1m /muggle:muggle-pr-followup <slug> <pr#> per PR` | `No PRs to watch — stage 8 not dispatched`
94
+ **Errors:** repo → message
97
95
 
98
- ## Output
96
+ ## Post-merge cleanup
99
97
 
100
- **PRs Created:**
101
- - (repo name): (PR URL)
98
+ Gated by `autoCleanup`. Fires in a follow-up turn after merge — never from this stage. See [`../_shared/post-merge-cleanup.md`](../_shared/post-merge-cleanup.md).
102
99
 
103
- **E2E acceptance overflow comments posted:** (only include repos where an overflow comment was actually posted)
104
- - (repo name): comment posted to PR #(number)
100
+ Append one short reminder tied to the gate value:
105
101
 
106
- **Errors:** (any repos where PR creation or comment posting failed, with the error message)
102
+ - `always` → `Once merged, I'll run the cleanup sequence automatically.`
103
+ - `never` → omit.
104
+ - `ask` / absent → `Once merged, I'll check with you about cleanup.`
@@ -1,4 +1,4 @@
1
- # Pre-flight Agent (Stage 1/7)
1
+ # Pre-flight Agent (Stage 1)
2
2
 
3
3
  You are running the **only user-facing stage** of the muggle-do dev cycle. Your job is to consolidate every ambiguity — task scope, repos, validation strategy, environment, credentials, PR target — into a **single turn** so the rest of the cycle can run unattended.
4
4
 
@@ -9,7 +9,7 @@ You are running the **only user-facing stage** of the muggle-do dev cycle. Your
9
9
  Start the turn with:
10
10
 
11
11
  ```
12
- **Stage 1/7 — Pre-flight** — consolidating everything the cycle needs before going silent.
12
+ **Stage 1 — Pre-flight** — consolidating everything the cycle needs before going silent.
13
13
  ```
14
14
 
15
15
  ## Input
@@ -17,7 +17,7 @@ Start the turn with:
17
17
  You receive:
18
18
 
19
19
  - The user's task description (from `$ARGUMENTS`).
20
- - The list of configured repos (names + paths) from the Muggle config.
20
+ - The list of configured repos (names + paths) from the Muggle Test config.
21
21
  - Any session directory that already exists (resumption case).
22
22
 
23
23
  ## Silent detection (do this first — no user prompts)
@@ -26,31 +26,38 @@ Before asking anything, gather every fact you can resolve without the user:
26
26
 
27
27
  1. **Candidate repo(s).** Match keywords in the task description against configured repo names. If one repo is an obvious match, propose it as the default; if two or three are plausible, list them.
28
28
  2. **Current branch and default branch** for each candidate repo. Run `git -C <repo> symbolic-ref refs/remotes/origin/HEAD --short` and `git -C <repo> branch --show-current`. If the current branch is the default, the pre-flight must collect a new branch name.
29
- 3. **Running dev server.** Scan common dev ports — `lsof -iTCP -sTCP:LISTEN -nP | grep -E ':(3000|3001|3999|4200|5173|8080)'` — and hit `/` with `curl -s -o /dev/null -w "%{http_code}"` to confirm 2xx.
30
- 4. **Running backend.** If the repo's `.env.local` (or equivalent) declares a backend URL (e.g. `REACT_APP_BACKEND_BASE_URL=http://localhost:5050`), probe the health endpoint; note up/down.
31
- 5. **Muggle MCP auth.** Call `muggle-remote-auth-status`. If expired, you will ask to re-auth in the questionnaire.
32
- 6. **Candidate Muggle projects.** Call `muggle-remote-project-list` and rank by semantic match against the task description and the repo's dev URL.
33
- 7. **Existing test-user secrets.** For each candidate Muggle project, call `muggle-remote-secret-list` and note whether `managed_profile_email` / `managed_profile_password` exist.
29
+ 3. **Running dev server.** Detect listening ports and reconcile env-file URL/port using [`../_shared/dev-server-readiness.md`](../_shared/dev-server-readiness.md).
30
+ 4. **Running backend.** Probe backend health per [`../_shared/dev-server-readiness.md`](../_shared/dev-server-readiness.md) ("Backend health"). Note up/down.
31
+ 5. **Muggle Test MCP auth.** Call `muggle-remote-auth-status`. If expired, you will ask to re-auth in the questionnaire.
32
+ 6. **Candidate Muggle Test projects.** Call `muggle-remote-project-list` and rank by semantic match against the task description and the repo's dev URL.
33
+ 7. **Existing test-user secrets.** For each candidate Muggle Test project, call `muggle-remote-secret-list` and note whether `managed_profile_email` / `managed_profile_password` exist.
34
34
  8. **Auth0 tenant in use for local dev.** Grep the repo's env file for `*AUTH0_DOMAIN*`; record the tenant. This tells the user whether the staging-tenant test user will work or not.
35
+ 9. **Branch hygiene signals** for the `autoUseWorktree` and `autoRebase` gates (see [`../_shared/use-worktrees.md`](../_shared/use-worktrees.md), [`../_shared/rebase-before-e2e.md`](../_shared/rebase-before-e2e.md)):
36
+ - Is the current checkout already a worktree? `git -C <repo> rev-parse --is-inside-work-tree` plus `git -C <repo> worktree list`.
37
+ - How many commits behind `origin/<default>`? `git -C <repo> fetch origin && git -C <repo> rev-list --count "HEAD..origin/$(git -C <repo> symbolic-ref refs/remotes/origin/HEAD --short | sed 's|origin/||')"`.
38
+ 10. **`autoE2ETest` preference.** Read the session-context preferences line. Unset → treat as `always` (this gate's default — opposite of the system-wide `ask` default). `ask` → surface in Q13. `always` → no question; stage 6 runs.
35
39
 
36
40
  ## The consolidated questionnaire
37
41
 
38
- Present **one `AskQuestion`** (or the platform's structured-selection equivalent) that collects every remaining decision. Use detected values as defaults whenever possible. Questions to include, in this order:
42
+ Present **one `AskUserQuestion`** (or the platform's structured-selection equivalent) that collects every remaining decision. Use detected values as defaults whenever possible. Questions to include, in this order:
39
43
 
40
44
  1. **Task scope clarification** — only if the task description is genuinely ambiguous. Offer 2–3 interpretations as options plus "Other — type a clarification." If the task is unambiguous, omit.
41
45
  2. **Repo(s) to modify** — pre-selected with the best silent match. "Confirm <repo>" / "Change repo" / "Multi-repo (list them)".
42
46
  3. **Branch name** — default: `users/<user>/<slug>` derived from the task. "Use default" / "Use different name (type)".
43
47
  4. **Validation strategy** — the single most important question. Options:
44
- - **Local E2E** (Muggle Electron against a running localhost) — default if a dev server was detected.
48
+ - **Local E2E** (Muggle Test Electron against a running localhost) — default if a dev server was detected.
45
49
  - **Staging replay** — for changes already deployed to a preview URL.
46
50
  - **Unit tests only** — skip E2E, acceptable for pure refactors or backend-only changes.
47
51
  - **Skip validation** — explicit opt-out; the PR title gets `[UNVERIFIED]`.
48
52
  5. **Local URL** — only if validation is Local E2E. Default: the detected port. "Confirm `<detected>`" / "Type a different URL".
49
53
  6. **Backend reachable?** — only if validation is Local E2E and a backend URL is declared. If the health probe failed, ask "Start the backend now and I'll re-probe" / "Proceed anyway" / "Skip to unit tests only".
50
- 7. **Muggle project** — pre-selected with the best silent match. "Use <top match>" / "Use a different existing project (list)" / "Create new".
54
+ 7. **Muggle Test project** — pre-selected with the best silent match. "Use <top match>" / "Use a different existing project (list)" / "Create new".
51
55
  8. **Test-user credentials** — only if validation is Local E2E AND the Auth0 tenant in the repo differs from the tenant the managed secrets were created under. Options: "Reuse existing secrets (may fail if tenant mismatch — will surface failure)" / "Create new secrets for this tenant (provide email + password)" / "Switch to staging replay".
52
56
  9. **PR target branch** — default: the repo's default branch. "Use default" / "Target a different branch".
53
- 10. **Re-auth Muggle MCP?** — only if auth was missing/expired. "Log in now" / "Abort".
57
+ 10. **Re-auth Muggle Test MCP?** — only if auth was missing/expired. "Log in now" / "Abort".
58
+ 11. **Worktree for this change?** — gate: [`autoUseWorktree`](../muggle-preferences/preference-gates/autoUseWorktree.md). Options: create a sibling worktree, or work in the current checkout.
59
+ 12. **Rebase onto `origin/<default>` first?** — gate: [`autoRebase`](../muggle-preferences/preference-gates/autoRebase.md), only if `behind > 0`. Options: rebase before stage 6, or run as-is.
60
+ 13. **Run E2E at the end of every cycle?** — gate: [`autoE2ETest`](../muggle-preferences/preference-gates/autoE2ETest.md), only if step 10's silent detection resolved to `ask`. Options: always run stage 6, or ask each cycle.
54
61
 
55
62
  If fewer than two of the above need the user, still gather them in a single turn — never open a second round.
56
63
 
@@ -73,7 +80,7 @@ After the user answers, write **`state.md`** with every resolved value, verbatim
73
80
  - Validation: <strategy>
74
81
  - Local URL: <url or N/A>
75
82
  - Backend status: <up | down | N/A>
76
- - Muggle project: <name> (<uuid>)
83
+ - Muggle Test project: <name> (<uuid>)
77
84
  - Test credentials: <existing | new | skip>
78
85
  - PR target: <branch>
79
86
  - Auth status: <ok | re-authed | N/A>
@@ -87,7 +94,7 @@ Also initialize `iterations/001.md` with a header:
87
94
  ```markdown
88
95
  # Iteration 001 — <ISO-8601 timestamp>
89
96
 
90
- ### Stage 1/7 — Pre-flight (<timestamp>)
97
+ ### Stage 1 — Pre-flight (<timestamp>)
91
98
 
92
99
  <verbatim copy of pre-flight answers>
93
100
  ```
@@ -1,4 +1,4 @@
1
- # Requirements Analysis Agent (Stage 2/7)
1
+ # Requirements Analysis Agent (Stage 2)
2
2
 
3
3
  You are analyzing a user's task description to extract structured requirements for an autonomous development cycle.
4
4
 
@@ -7,7 +7,7 @@ You are analyzing a user's task description to extract structured requirements f
7
7
  Start the turn with:
8
8
 
9
9
  ```
10
- **Stage 2/7 — Requirements** — extracting structured goals from the pre-flight-clarified task.
10
+ **Stage 2 — Requirements** — extracting structured goals from the pre-flight-clarified task.
11
11
  ```
12
12
 
13
13
  Pre-flight already resolved ambiguity via the consolidated questionnaire. **Do not ask the user any questions here** — infer silently and record assumptions in Notes.
@@ -1,4 +1,4 @@
1
- # Unit Test Runner Agent (Stage 5/7)
1
+ # Unit Test Runner Agent (Stage 5)
2
2
 
3
3
  You are running unit tests for each repository that has changes in the dev cycle pipeline.
4
4
 
@@ -7,7 +7,7 @@ You are running unit tests for each repository that has changes in the dev cycle
7
7
  Start the turn with:
8
8
 
9
9
  ```
10
- **Stage 5/7 — Unit tests** — running each repo's test suite.
10
+ **Stage 5 — Unit tests** — running each repo's test suite.
11
11
  ```
12
12
 
13
13
  ## Input
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: m
3
+ description: Explicit short alias for the `muggle` skill (router/menu). ONLY invoke when the user explicitly types `m` or `/m` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # m — alias for muggle
7
+
8
+ Invoke the `muggle` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mdo
3
+ description: Explicit short alias for the `muggle-do-task` skill. ONLY invoke when the user explicitly types `mdo` or `/mdo` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mdo — alias for muggle-do-task
7
+
8
+ Invoke the `muggle-do-task` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mfeedback
3
+ description: Explicit short alias for the `muggle-feedback` skill. ONLY invoke when the user explicitly types `mfeedback` or `/mfeedback` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mfeedback — alias for muggle-feedback
7
+
8
+ Invoke the `muggle-feedback` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mimport
3
+ description: Explicit short alias for the `muggle-test-import` skill. ONLY invoke when the user explicitly types `mimport` or `/mimport` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mimport — alias for muggle-test-import
7
+
8
+ Invoke the `muggle-test-import` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mpr
3
+ description: Explicit short alias for the `muggle-pr-visual-walkthrough` skill. ONLY invoke when the user explicitly types `mpr` or `/mpr` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mpr — alias for muggle-pr-visual-walkthrough
7
+
8
+ Invoke the `muggle-pr-visual-walkthrough` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mprefs
3
+ description: Explicit short alias for the `muggle-preferences` skill. ONLY invoke when the user explicitly types `mprefs` or `/mprefs` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mprefs — alias for muggle-preferences
7
+
8
+ Invoke the `muggle-preferences` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mregen
3
+ description: Explicit short alias for the `muggle-test-regenerate-missing` skill. ONLY invoke when the user explicitly types `mregen` or `/mregen` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mregen — alias for muggle-test-regenerate-missing
7
+
8
+ Invoke the `muggle-test-regenerate-missing` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mrelease
3
+ description: Explicit short alias for the `muggle-works-npm-release` skill. ONLY invoke when the user explicitly types `mrelease` or `/mrelease` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mrelease — alias for muggle-works-npm-release
7
+
8
+ Invoke the `muggle-works-npm-release` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mrepair
3
+ description: Explicit short alias for the `muggle-repair` skill. ONLY invoke when the user explicitly types `mrepair` or `/mrepair` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mrepair — alias for muggle-repair
7
+
8
+ Invoke the `muggle-repair` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mstatus
3
+ description: Explicit short alias for the `muggle-status` skill. ONLY invoke when the user explicitly types `mstatus` or `/mstatus` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mstatus — alias for muggle-status
7
+
8
+ Invoke the `muggle-status` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mtest
3
+ description: Explicit short alias for the `muggle-test` skill. ONLY invoke when the user explicitly types `mtest` or `/mtest` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mtest — alias for muggle-test
7
+
8
+ Invoke the `muggle-test` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mtestlocal
3
+ description: Explicit short alias for the `muggle-test-feature-local` skill. ONLY invoke when the user explicitly types `mtestlocal` or `/mtestlocal` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mtestlocal — alias for muggle-test-feature-local
7
+
8
+ Invoke the `muggle-test-feature-local` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: mtestprep
3
+ description: Explicit short alias for the `muggle-test-prepare` skill. ONLY invoke when the user explicitly types `mtestprep` or `/mtestprep` — never auto-trigger from any other phrasing.
4
+ ---
5
+
6
+ # mtestprep — alias for muggle-test-prepare
7
+
8
+ Invoke the `muggle-test-prepare` skill via the Skill tool. Forward any user-provided arguments unchanged.
@@ -1,15 +1,17 @@
1
1
  ---
2
2
  name: muggle
3
- description: Muggle AI command router and menu. Use when user types "muggle" or asks for available Muggle commands.
3
+ description: Muggle AI command router and menu. Use when user types "muggle" or asks for available Muggle Test commands.
4
4
  ---
5
5
 
6
- # Muggle
6
+ # Muggle Test
7
7
 
8
- Use this as the top-level Muggle command router.
8
+ > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle"`.
9
+
10
+ Use this as the top-level Muggle Test command router.
9
11
 
10
12
  ## Preferences
11
13
 
12
- User preferences are injected by the SessionStart hook into a `Muggle Preferences` line in session context (key=value pairs). Resolution: defaults → `~/.muggle-ai/preferences.json` (global) → `<repo>/.muggle-ai/preferences.json` (project). Treat absent prefs as `ask`.
14
+ User preferences are injected by the SessionStart hook into a `Muggle Test Preferences` line in session context (key=value pairs). Resolution: defaults → `~/.muggle-ai/preferences.json` (global) → `<repo>/.muggle-ai/preferences.json` (project). Treat absent prefs as `ask`.
13
15
 
14
16
  This router skill itself does not gate any decision on a preference — it just routes user intent to a downstream skill. Each downstream skill consults its own preferences. For example, `checkForUpdates` is consulted by `muggle-status` (Check 4), not here.
15
17
 
@@ -17,7 +19,7 @@ If the user types "muggle" with no subcommand and you want to surface a contextu
17
19
 
18
20
  ## Menu
19
21
 
20
- When user asks for "muggle" with no specific subcommand, use `AskQuestion` to present these four options:
22
+ When user asks for "muggle" with no specific subcommand, use `AskUserQuestion` to present these four options:
21
23
 
22
24
  - "Test a feature — run E2E acceptance tests locally or remotely" → `muggle-test-feature-local` (local) or `muggle-test` (remote/change-driven)
23
25
  - "Build something — implement a feature with E2E acceptance tests and a visual PR" → `muggle-do`
@@ -35,5 +37,6 @@ If the user intent clearly matches one command, route directly — no menu neede
35
37
  - test localhost/validate single feature/test a feature → `muggle-test-feature-local`
36
38
  - build/implement from request/end-to-end → `muggle-do`
37
39
  - post results to PR/attach walkthrough/visual evidence on PR → `muggle-pr-visual-walkthrough`
40
+ - give feedback on a run/the test was wrong/step N didn't work/show my feedback/delete feedback → `muggle-feedback`
38
41
 
39
- If intent is ambiguous, use `AskQuestion` with the most likely options rather than asking the user to type a clarification.
42
+ If intent is ambiguous, use `AskUserQuestion` with the most likely options rather than asking the user to type a clarification.
@@ -4,94 +4,69 @@ description: Unified Muggle AI workflow entry point. Use when user types muggle
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
- # Muggle Do
7
+ # Muggle Test Do
8
8
 
9
- Muggle Do runs a battle-tested autonomous dev cycle: **pre-flight → requirements → impact analysis → validate code → unit tests → E2E acceptance → open PR**.
9
+ > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle-do"`.
10
10
 
11
- The design goal is **fire and review**: the user answers one consolidated pre-flight questionnaire, then walks away. Every subsequent stage runs unattended until completion or a genuine blocker.
11
+ Runs an autonomous dev cycle from requirements to PR. **Fire and review:** the user answers one pre-flight questionnaire, then walks away.
12
12
 
13
- For maintenance tasks, use the dedicated skills:
13
+ For maintenance, use the dedicated skills:
14
14
 
15
15
  - `/muggle:muggle-status`
16
16
  - `/muggle:muggle-repair`
17
17
  - `/muggle:muggle-upgrade`
18
18
 
19
- ## Input routing
20
-
21
- Treat `$ARGUMENTS` as the user command:
22
-
23
- - Empty / `help` / `menu` / `?` → show menu and session selector.
24
- - Anything else → treat as a new task description and start/resume a dev-cycle session.
25
-
26
- ## The seven stages
19
+ ## The pipeline
27
20
 
28
21
  | # | Stage | File | User-facing? |
29
22
  | :- | :---- | :--- | :----------- |
30
- | 1 | Pre-flight | [../do/pre-flight.md](../do/pre-flight.md) | **Yes — single consolidated turn** |
23
+ | 1 | Pre-flight | [../do/pre-flight.md](../do/pre-flight.md) | **Yes — one consolidated turn** |
31
24
  | 2 | Requirements | [../do/requirements.md](../do/requirements.md) | No |
32
- | 3 | Impact analysis | [../do/impact-analysis.md](../do/impact-analysis.md) | No |
33
- | 4 | Validate code | [../do/validate-code.md](../do/validate-code.md) | No |
25
+ | 3 | Build | [../do/build.md](../do/build.md) | No |
26
+ | 4 | Impact analysis | [../do/impact-analysis.md](../do/impact-analysis.md) | No |
34
27
  | 5 | Unit tests | [../do/unit-tests.md](../do/unit-tests.md) | No |
35
28
  | 6 | E2E acceptance | [../do/e2e-acceptance.md](../do/e2e-acceptance.md) | No |
36
29
  | 7 | Open PR | [../do/open-prs.md](../do/open-prs.md) | No |
30
+ | 8 | PR follow-up | [../muggle-pr-followup/SKILL.md](../muggle-pr-followup/SKILL.md) (generic) — invoked with muggle-do's cycle declaration | **Yes — only on ambiguous reviews** |
37
31
 
38
- **Stage 1 (pre-flight) is the ONLY stage that talks to the user.** Stages 2–7 run silently to completion. If a later stage hits a genuine blocker that the pre-flight didn't cover, escalate with a single terminal message — do not open a second round of questions.
39
-
40
- ## Front-loading (stage 1 non-negotiable)
41
-
42
- All ambiguity — task scope, repo selection, validation strategy, localhost URL, backend health, Muggle project, test-user credentials, branch name, PR target — is resolved in a **single** pre-flight turn. See `pre-flight.md` for the exact questionnaire.
32
+ Stage 1 talks to the user once. Stages 2–7 run silently. Stage 7 dispatches **one Stage-8 follow-up loop per PR** it opens (not one per session); each loop polls its own PR independently for new submitted reviews. When a review lands, the loop cycles back through Stage 3 (Build) → 4 → 5 → 6 → fresh visual walkthrough → push to the existing branch, then resumes polling for the next round. Each loop may escalate once on an ambiguous review.
43
33
 
44
- **Red-flag behaviors (do not do):**
34
+ **Each stage's file is the single source of truth for that stage** — definition, contract, inputs/outputs, preference gates, output format. Read each stage file directly for its rules. This file is only the orchestration spine.
45
35
 
46
- - Asking a clarifying question mid-cycle because "I didn't think of that at pre-flight."
47
- - Starting a dev server mid-cycle and discovering the port is wrong.
48
- - Reaching the E2E stage before knowing how the user wants it validated.
49
- - Asking the user to "pick one" across multiple turns instead of one turn.
36
+ ## Preferences
50
37
 
51
- If any of these happen, the pre-flight was incomplete — treat it as a skill bug, not a user bug, and expand `pre-flight.md` to cover the missed case after the run.
52
-
53
- ## Session model
38
+ | Preference | Stage | Decision it gates |
39
+ |------------|-------|-------------------|
40
+ | `autoE2ETest` | 6 (E2E acceptance) | Run E2E every cycle (default `always`), or fold the question into pre-flight |
54
41
 
55
- Every run writes to `.muggle-do/sessions/<slug>/`:
42
+ Other gates that fire during this cycle (`autoUseWorktree`, `autoRebase`, `autoCreatePR`, `autoCleanup`) are owned by the per-stage files; see each stage for its contract.
56
43
 
57
- - `state.md` — one-screen live status: current stage (N/7), last update timestamp, pre-flight answers verbatim, any blockers.
58
- - `iterations/<NNN>.md` — append-only log of stage transitions for iteration NNN: what ran, what was decided, what artifacts were produced.
59
- - `requirements.md` — frozen output of stage 2.
60
- - `result.md` — final summary written by stage 7 (PR URLs, E2E outcome, open issues).
61
-
62
- **On every stage transition, you MUST:**
44
+ ## Input routing
63
45
 
64
- 1. Append a dated entry to the active `iterations/<NNN>.md`: `### Stage N/7 — <name> (<timestamp>)` followed by the stage's output.
65
- 2. Rewrite `state.md` to reflect the new current stage and any relevant counters.
46
+ Treat `$ARGUMENTS` as the user command:
66
47
 
67
- If these files don't exist, create them — missing session files means the user lost visibility into the cycle, which is the exact failure mode this skill exists to prevent.
48
+ - Empty / `help` / `menu` / `?` → show menu and session selector.
49
+ - Anything else → infer intent:
50
+ - **Task automation** (perform an action on a website — post something, fill a form, click through a flow) → invoke `muggle:muggle-do-task` with the full prompt.
51
+ - **Feature development** (build / fix / refactor code) → start or resume a dev-cycle session.
68
52
 
69
- ## Turn preamble
53
+ When in doubt, ask one question: "Browser automation task, or code change?"
70
54
 
71
- Each stage turn MUST begin with one line in this form before any other output:
55
+ ## Session model
72
56
 
73
- ```
74
- **Stage N/7 — <stage name>** — <one-line intent>
75
- ```
57
+ Every run writes to `.muggle-do/sessions/<slug>/`. Stages own the files they produce:
76
58
 
77
- This is how the user can tell, at a glance, what phase the cycle is in without parsing a long response.
59
+ | File | Owned by | Purpose |
60
+ | :--- | :------- | :------ |
61
+ | `state.md` | Stage 1 (rewritten by every transition) | Current stage, pre-flight answers, blockers |
62
+ | `iterations/<NNN>.md` | Every stage | Append-only stage transition log |
63
+ | `requirements.md` | Stage 2 | Frozen requirements |
64
+ | `prs.json`, `last_seen.json`, `followup.log` | Stage 8 | See [`pr-followup.md`](../do/pr-followup.md) |
65
+ | `result.md` | Stage 7 (seeded), Stage 8 (finalized) | Per-PR final state |
78
66
 
79
67
  ## Guardrails
80
68
 
81
- - **No mid-cycle user questions.** Anything not covered by pre-flight is a skill bug; escalate once, do not loop.
82
- - **Do not skip unit tests before E2E acceptance tests.**
83
- - **Do not skip E2E acceptance tests due to missing scripts** — generate when needed.
84
- - **Do not hand-write the E2E block of the PR body.** The `open-prs.md` stage MUST invoke `muggle-pr-visual-walkthrough` Mode B to render the screenshots-and-steps section. Hand-writing it loses the dashboard links the user relies on for review.
85
- - **If the same stage fails 3 times in a row, escalate with details.**
86
- - **If total iterations reach 3 and E2E acceptance tests still fail**, continue to PR creation with `[E2E FAILING]` in the title; the visual walkthrough section makes the failures reviewable.
87
-
88
- ## Completion contract
89
-
90
- When stage 7 finishes, the final message to the user contains at minimum:
91
-
92
- - PR URL(s)
93
- - E2E status (passing / `[E2E FAILING]`)
94
- - Link to the run dashboard for each test case (via the walkthrough skill output)
95
- - Path to `result.md` for full details
96
-
97
- No other content. The user already read the walkthrough in the PR body — do not re-summarize it here.
69
+ - **Stage 1 is the only forward-pipeline user-facing stage.** Stages 2–7 don't ask questions mid-cycle. If a stage hits a blocker pre-flight didn't cover, treat as a pre-flight bug — escalate once and expand `pre-flight.md` after the run.
70
+ - **Stage 8 may escalate** once per ambiguous review comment, and may dispatch back to Stage 3 when needed — see [`pr-followup.md`](../do/pr-followup.md).
71
+ - **If the same stage fails 3 times in a row, escalate** with details.
72
+ - **If 3 cycle iterations reach E2E with failures**, ship with `[E2E FAILING]` per [`open-prs.md`](../do/open-prs.md). The walkthrough section keeps the failures reviewable.