@muggleai/works 4.10.0 → 4.10.1

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 (187) 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/rebase-before-e2e.md +15 -0
  30. package/dist/plugin/skills/_shared/telemetry-emit.md +15 -0
  31. package/dist/plugin/skills/_shared/use-worktrees.md +53 -0
  32. package/dist/plugin/skills/do/e2e-acceptance.md +63 -18
  33. package/dist/plugin/skills/do/impact-analysis.md +45 -5
  34. package/dist/plugin/skills/do/open-prs.md +13 -4
  35. package/dist/plugin/skills/do/pr-followup.md +225 -0
  36. package/dist/plugin/skills/do/pre-flight.md +18 -11
  37. package/dist/plugin/skills/m/SKILL.md +8 -0
  38. package/dist/plugin/skills/mdo/SKILL.md +8 -0
  39. package/dist/plugin/skills/mfeedback/SKILL.md +8 -0
  40. package/dist/plugin/skills/mimport/SKILL.md +8 -0
  41. package/dist/plugin/skills/mpr/SKILL.md +8 -0
  42. package/dist/plugin/skills/mprefs/SKILL.md +8 -0
  43. package/dist/plugin/skills/mregen/SKILL.md +8 -0
  44. package/dist/plugin/skills/mrelease/SKILL.md +8 -0
  45. package/dist/plugin/skills/mrepair/SKILL.md +8 -0
  46. package/dist/plugin/skills/mstatus/SKILL.md +8 -0
  47. package/dist/plugin/skills/mtest/SKILL.md +8 -0
  48. package/dist/plugin/skills/mtestlocal/SKILL.md +8 -0
  49. package/dist/plugin/skills/mtestprep/SKILL.md +8 -0
  50. package/dist/plugin/skills/muggle/SKILL.md +9 -6
  51. package/dist/plugin/skills/muggle-do/SKILL.md +22 -4
  52. package/dist/plugin/skills/muggle-do-pr-followup/SKILL.md +37 -0
  53. package/dist/plugin/skills/muggle-do-task/SKILL.md +134 -0
  54. package/dist/plugin/skills/muggle-feedback/SKILL.md +38 -0
  55. package/dist/plugin/skills/muggle-feedback/ops/delete.md +49 -0
  56. package/dist/plugin/skills/muggle-feedback/ops/list.md +65 -0
  57. package/dist/plugin/skills/muggle-feedback/ops/submit.md +117 -0
  58. package/dist/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +68 -43
  59. package/dist/plugin/skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md +86 -0
  60. package/dist/plugin/skills/muggle-preferences/SKILL.md +16 -108
  61. package/dist/plugin/skills/muggle-preferences/ops/change-one.md +10 -0
  62. package/dist/plugin/skills/muggle-preferences/ops/configure.md +49 -0
  63. package/dist/plugin/skills/muggle-preferences/ops/list.md +9 -0
  64. package/dist/plugin/skills/muggle-preferences/ops/reset.md +6 -0
  65. package/dist/plugin/skills/muggle-preferences/ops/set.md +10 -0
  66. package/dist/plugin/skills/muggle-preferences/preference-gates/README.md +1 -1
  67. package/dist/plugin/skills/muggle-preferences/preference-gates/autoCleanup.md +11 -0
  68. package/dist/plugin/skills/muggle-preferences/preference-gates/autoCreatePR.md +13 -0
  69. package/dist/plugin/skills/muggle-preferences/preference-gates/autoDetectChanges.md +3 -3
  70. package/dist/plugin/skills/muggle-preferences/preference-gates/autoE2ETest.md +11 -0
  71. package/dist/plugin/skills/muggle-preferences/preference-gates/autoLogin.md +1 -1
  72. package/dist/plugin/skills/muggle-preferences/preference-gates/autoPublishLocalResults.md +2 -2
  73. package/dist/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +11 -0
  74. package/dist/plugin/skills/muggle-preferences/preference-gates/autoSelectLocalHost.md +19 -0
  75. package/dist/plugin/skills/muggle-preferences/preference-gates/autoSelectProject.md +1 -2
  76. package/dist/plugin/skills/muggle-preferences/preference-gates/autoUseWorktree.md +11 -0
  77. package/dist/plugin/skills/muggle-preferences/preference-gates/checkForUpdates.md +4 -4
  78. package/dist/plugin/skills/muggle-preferences/preference-gates/defaultExecutionMode.md +1 -1
  79. package/dist/plugin/skills/muggle-preferences/preference-gates/openTestResultsAfterRun.md +1 -1
  80. package/dist/plugin/skills/muggle-preferences/preference-gates/postPRVisualWalkthrough.md +8 -25
  81. package/dist/plugin/skills/muggle-preferences/preference-gates/showElectronBrowser.md +1 -1
  82. package/dist/plugin/skills/muggle-preferences/preference-gates/suggestRelatedTestCases.md +4 -4
  83. package/dist/plugin/skills/muggle-preferences/preference-gates/suggestRelatedUseCases.md +4 -4
  84. package/dist/plugin/skills/muggle-repair/SKILL.md +4 -2
  85. package/dist/plugin/skills/muggle-status/SKILL.md +8 -5
  86. package/dist/plugin/skills/muggle-test/SKILL.md +110 -86
  87. package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +73 -66
  88. package/dist/plugin/skills/muggle-test-import/SKILL.md +28 -23
  89. package/dist/plugin/skills/muggle-test-prepare/SKILL.md +79 -18
  90. package/dist/plugin/skills/muggle-test-regenerate-missing/SKILL.md +34 -18
  91. package/dist/plugin/skills/muggle-test-regenerate-missing/evals/evals.json +9 -9
  92. package/dist/plugin/skills/muggle-upgrade/SKILL.md +4 -2
  93. package/dist/plugin/skills/muggle-works-npm-release/SKILL.md +6 -4
  94. package/dist/plugin/skills/mupgrade/SKILL.md +8 -0
  95. package/dist/release-manifest.json +4 -4
  96. package/dist/{src-GD3YFCCW.js → src-2G7ENRGI.js} +1 -1
  97. package/package.json +9 -7
  98. package/plugin/.claude-plugin/plugin.json +1 -1
  99. package/plugin/.cursor-plugin/plugin.json +1 -1
  100. package/plugin/README.md +4 -2
  101. package/plugin/agents/acceptance-tester.md +24 -10
  102. package/plugin/commands/m.md +7 -0
  103. package/plugin/commands/mdo.md +7 -0
  104. package/plugin/commands/mfeedback.md +7 -0
  105. package/plugin/commands/mimport.md +7 -0
  106. package/plugin/commands/mpr.md +7 -0
  107. package/plugin/commands/mprefs.md +7 -0
  108. package/plugin/commands/mregen.md +7 -0
  109. package/plugin/commands/mrelease.md +7 -0
  110. package/plugin/commands/mrepair.md +7 -0
  111. package/plugin/commands/mstatus.md +7 -0
  112. package/plugin/commands/mtest.md +7 -0
  113. package/plugin/commands/mtestlocal.md +7 -0
  114. package/plugin/commands/mtestprep.md +7 -0
  115. package/plugin/commands/mupgrade.md +7 -0
  116. package/plugin/scripts/ensure-electron-app.sh +35 -8
  117. package/plugin/skills/_aliases.json +18 -0
  118. package/plugin/skills/_shared/dev-server-readiness.md +231 -0
  119. package/plugin/skills/_shared/failure-mode-handling.md +244 -0
  120. package/plugin/skills/_shared/post-merge-cleanup.md +10 -0
  121. package/plugin/skills/_shared/rebase-before-e2e.md +15 -0
  122. package/plugin/skills/_shared/telemetry-emit.md +15 -0
  123. package/plugin/skills/_shared/use-worktrees.md +53 -0
  124. package/plugin/skills/do/e2e-acceptance.md +63 -18
  125. package/plugin/skills/do/impact-analysis.md +45 -5
  126. package/plugin/skills/do/open-prs.md +13 -4
  127. package/plugin/skills/do/pr-followup.md +225 -0
  128. package/plugin/skills/do/pre-flight.md +18 -11
  129. package/plugin/skills/m/SKILL.md +8 -0
  130. package/plugin/skills/mdo/SKILL.md +8 -0
  131. package/plugin/skills/mfeedback/SKILL.md +8 -0
  132. package/plugin/skills/mimport/SKILL.md +8 -0
  133. package/plugin/skills/mpr/SKILL.md +8 -0
  134. package/plugin/skills/mprefs/SKILL.md +8 -0
  135. package/plugin/skills/mregen/SKILL.md +8 -0
  136. package/plugin/skills/mrelease/SKILL.md +8 -0
  137. package/plugin/skills/mrepair/SKILL.md +8 -0
  138. package/plugin/skills/mstatus/SKILL.md +8 -0
  139. package/plugin/skills/mtest/SKILL.md +8 -0
  140. package/plugin/skills/mtestlocal/SKILL.md +8 -0
  141. package/plugin/skills/mtestprep/SKILL.md +8 -0
  142. package/plugin/skills/muggle/SKILL.md +9 -6
  143. package/plugin/skills/muggle-do/SKILL.md +22 -4
  144. package/plugin/skills/muggle-do-pr-followup/SKILL.md +37 -0
  145. package/plugin/skills/muggle-do-task/SKILL.md +134 -0
  146. package/plugin/skills/muggle-feedback/SKILL.md +38 -0
  147. package/plugin/skills/muggle-feedback/ops/delete.md +49 -0
  148. package/plugin/skills/muggle-feedback/ops/list.md +65 -0
  149. package/plugin/skills/muggle-feedback/ops/submit.md +117 -0
  150. package/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +68 -43
  151. package/plugin/skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md +86 -0
  152. package/plugin/skills/muggle-preferences/SKILL.md +16 -108
  153. package/plugin/skills/muggle-preferences/ops/change-one.md +10 -0
  154. package/plugin/skills/muggle-preferences/ops/configure.md +49 -0
  155. package/plugin/skills/muggle-preferences/ops/list.md +9 -0
  156. package/plugin/skills/muggle-preferences/ops/reset.md +6 -0
  157. package/plugin/skills/muggle-preferences/ops/set.md +10 -0
  158. package/plugin/skills/muggle-preferences/preference-gates/README.md +1 -1
  159. package/plugin/skills/muggle-preferences/preference-gates/autoCleanup.md +11 -0
  160. package/plugin/skills/muggle-preferences/preference-gates/autoCreatePR.md +13 -0
  161. package/plugin/skills/muggle-preferences/preference-gates/autoDetectChanges.md +3 -3
  162. package/plugin/skills/muggle-preferences/preference-gates/autoE2ETest.md +11 -0
  163. package/plugin/skills/muggle-preferences/preference-gates/autoLogin.md +1 -1
  164. package/plugin/skills/muggle-preferences/preference-gates/autoPublishLocalResults.md +2 -2
  165. package/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +11 -0
  166. package/plugin/skills/muggle-preferences/preference-gates/autoSelectLocalHost.md +19 -0
  167. package/plugin/skills/muggle-preferences/preference-gates/autoSelectProject.md +1 -2
  168. package/plugin/skills/muggle-preferences/preference-gates/autoUseWorktree.md +11 -0
  169. package/plugin/skills/muggle-preferences/preference-gates/checkForUpdates.md +4 -4
  170. package/plugin/skills/muggle-preferences/preference-gates/defaultExecutionMode.md +1 -1
  171. package/plugin/skills/muggle-preferences/preference-gates/openTestResultsAfterRun.md +1 -1
  172. package/plugin/skills/muggle-preferences/preference-gates/postPRVisualWalkthrough.md +8 -25
  173. package/plugin/skills/muggle-preferences/preference-gates/showElectronBrowser.md +1 -1
  174. package/plugin/skills/muggle-preferences/preference-gates/suggestRelatedTestCases.md +4 -4
  175. package/plugin/skills/muggle-preferences/preference-gates/suggestRelatedUseCases.md +4 -4
  176. package/plugin/skills/muggle-repair/SKILL.md +4 -2
  177. package/plugin/skills/muggle-status/SKILL.md +8 -5
  178. package/plugin/skills/muggle-test/SKILL.md +110 -86
  179. package/plugin/skills/muggle-test-feature-local/SKILL.md +73 -66
  180. package/plugin/skills/muggle-test-import/SKILL.md +28 -23
  181. package/plugin/skills/muggle-test-prepare/SKILL.md +79 -18
  182. package/plugin/skills/muggle-test-regenerate-missing/SKILL.md +34 -18
  183. package/plugin/skills/muggle-test-regenerate-missing/evals/evals.json +9 -9
  184. package/plugin/skills/muggle-upgrade/SKILL.md +4 -2
  185. package/plugin/skills/muggle-works-npm-release/SKILL.md +6 -4
  186. package/plugin/skills/mupgrade/SKILL.md +8 -0
  187. package/scripts/postinstall.mjs +11 -1
@@ -5,7 +5,9 @@ description: Run a real-browser end-to-end (E2E) acceptance test against localho
5
5
 
6
6
  # Muggle Test Feature Local
7
7
 
8
- **Goal:** Run or generate an end-to-end test against a **local URL** using Muggle's Electron browser.
8
+ > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle-test-feature-local"`.
9
+
10
+ **Goal:** Run or generate an end-to-end test against a **local URL** using Muggle Test's Electron browser.
9
11
 
10
12
  | Scope | MCP tools |
11
13
  | :---- | :-------- |
@@ -15,11 +17,23 @@ description: Run a real-browser end-to-end (E2E) acceptance test against localho
15
17
 
16
18
  The local URL only changes where the browser opens; it does not change the remote project or test definitions.
17
19
 
20
+ ## Branch hygiene
21
+
22
+ Three gates apply, each per the standard procedure in [`preference-gates/README.md`](../muggle-preferences/preference-gates/README.md):
23
+
24
+ - `autoUseWorktree` at pre-flight (see [`_shared/use-worktrees.md`](../_shared/use-worktrees.md)).
25
+ - `autoRebase` before Step 7 (Execute) when `behind > 0` (see [`_shared/rebase-before-e2e.md`](../_shared/rebase-before-e2e.md)).
26
+ - `autoCleanup` after the PR is merged (see [`_shared/post-merge-cleanup.md`](../_shared/post-merge-cleanup.md)).
27
+
28
+ ## Local environment prerequisites
29
+
30
+ Before any workflow step, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md). Halt on what it surfaces.
31
+
18
32
  ## UX Guidelines — Minimize Typing
19
33
 
20
- **Every selection-based question MUST use the `AskQuestion` tool** (or the platform's equivalent structured selection tool). Never ask the user to "reply with a number" in a plain text message — always present clickable options.
34
+ **Every selection-based question MUST use the `AskUserQuestion` tool** (or the platform's equivalent structured selection tool). Never ask the user to "reply with a number" in a plain text message — always present clickable options.
21
35
 
22
- - **Selections** (project, use case, test case, script): Use `AskQuestion` with labeled options the user can click.
36
+ - **Selections** (project, use case, test case, script): Use `AskUserQuestion` with labeled options the user can click.
23
37
  - **Free-text inputs** (URLs, descriptions): Only use plain text prompts when there is no finite set of options. Even then, offer a detected/default value when possible.
24
38
 
25
39
  ## Preferences
@@ -29,10 +43,15 @@ Gates run per `preference-gates/README.md`.
29
43
  | Preference | Step | Decision it gates |
30
44
  |------------|------|-------------------|
31
45
  | `autoLogin` | 1 | Reuse saved credentials when auth is required |
32
- | `autoSelectProject` | 2 | Reuse last-used Muggle project for this repo |
46
+ | `autoSelectProject` | 2 | Reuse last-used Muggle Test project for this repo |
47
+ | `autoSelectLocalHost` | 4 | Reuse last-used local dev server URL for this repo |
48
+ | `autoUseWorktree` | 0 (pre-flight) | Isolate dev work in a worktree (see [`_shared/use-worktrees.md`](../_shared/use-worktrees.md)) |
49
+ | `autoRebase` | 0 (pre-flight) | Rebase onto `origin/<default>` before Step 7 (Execute) (see [`_shared/rebase-before-e2e.md`](../_shared/rebase-before-e2e.md)) |
33
50
  | `showElectronBrowser` | 7 | Show Electron browser window during local E2E tests |
34
- | `openTestResultsAfterRun` | 8 | Open results page on Muggle dashboard after run |
51
+ | `openTestResultsAfterRun` | 8 | Open results page on Muggle Test dashboard after run |
35
52
  | `postPRVisualWalkthrough` | 10 | Post visual walkthrough to PR after results |
53
+ | `autoCreatePR` | 10 (if no PR) | Auto-create the PR when posting the walkthrough has no PR to target |
54
+ | `autoCleanup` | post-merge | Run cleanup after the PR for this work is merged (see [`_shared/post-merge-cleanup.md`](../_shared/post-merge-cleanup.md)) |
36
55
 
37
56
  ## Workflow
38
57
 
@@ -40,15 +59,16 @@ Gates run per `preference-gates/README.md`.
40
59
 
41
60
  - `muggle-remote-auth-status`
42
61
  - If **authenticated**: gate `autoLogin` (per `preference-gates/README.md`):
43
- - Pro-action: proceed with saved session.
44
- - Skip-action: `muggle-remote-auth-login` with `forceNewSession: true`, then `muggle-remote-auth-poll`.
62
+ - `always` → proceed with saved session.
63
+ - `never` → `muggle-remote-auth-login` with `forceNewSession: true`, then `muggle-remote-auth-poll`.
64
+ - `ask` → run Picker 1 from `preference-gates/autoLogin.md` via `AskUserQuestion`; map the answer back to one of the actions above.
45
65
  - If **not signed in or expired**: call `muggle-remote-auth-login` then `muggle-remote-auth-poll`. Do not skip or assume auth.
46
66
 
47
67
  ### 2. Targets (user must confirm)
48
68
 
49
- The per-repo project cache lives at `<cwd>/.muggle-ai/last-project.json` (via the `muggle-local-last-project-get` / `muggle-local-last-project-set` MCP tools). Look for `Muggle Last Project: id=… url=… name="…"` in session context.
69
+ The per-repo project cache lives at `<cwd>/.muggle-ai/last-project.json` (via the `muggle-local-last-project-get` / `muggle-local-last-project-set` MCP tools). Look for `Muggle Test Last Project: id=… url=… name="…"` in session context.
50
70
 
51
- Gate `autoSelectProject` (per `preference-gates/README.md`). Cache: `Muggle Last Project` session line.
71
+ Gate `autoSelectProject` (per `preference-gates/README.md`). Cache: `Muggle Test Last Project` session line.
52
72
  - `always` + cache → use cached `projectId`, skip to use case selection. No cache → fall through to `ask`.
53
73
  - `never` → full project list; skip Picker 2.
54
74
  - `ask` → project list picker (see gate file for spec + Picker 2 override). Skip Picker 2 if "Create new project".
@@ -59,7 +79,7 @@ Ask the user to pick **project**, **use case**, and **test case** (do not infer)
59
79
  - `muggle-remote-use-case-list` (with `projectId`)
60
80
  - `muggle-remote-test-case-list-by-use-case` (with `useCaseId`)
61
81
 
62
- **Selection UI (mandatory):** Every selection MUST use `AskQuestion` with clickable options. Never ask the user to "reply with the number" in plain text.
82
+ **Selection UI (mandatory):** Every selection MUST use `AskUserQuestion` with clickable options. Never ask the user to "reply with the number" in plain text.
63
83
 
64
84
  **Project selection context:** A **project** groups all your test results, use cases, and test scripts on the Muggle AI dashboard. Include the project URL in each option label so the user can identify the right one.
65
85
 
@@ -69,18 +89,18 @@ Prompt for projects: "Pick the project to group this test into:"
69
89
 
70
90
  - Do **not** dump the full list by default.
71
91
  - Rank items by semantic relevance to the user's stated goal (title first, then description / user story / acceptance criteria).
72
- - Show only the **top 3-5** most relevant options via `AskQuestion`, plus these fixed tail options:
73
- - **"Show full list"** — present the complete list in a new `AskQuestion` call. **Skip this option** if the API returned zero rows.
92
+ - Show only the **top 3-5** most relevant options via `AskUserQuestion`, plus these fixed tail options:
93
+ - **"Show full list"** — present the complete list in a new `AskUserQuestion` call. **Skip this option** if the API returned zero rows.
74
94
  - **"Create new ..."** — never omitted. Label per step: "Create new project", "Create new use case", or "Create new test case".
75
95
 
76
96
  **Create new — tools and flow (use these MCP tools; preview before persist):**
77
97
 
78
98
  - **Project — Create new project:** Collect `projectName`, `description`, and `url` (may be the local app URL, e.g. `http://localhost:3999`). Call `muggle-remote-project-create`. Use the returned `projectId` and continue.
79
99
  - **Use case — Create new use case:** User provides a natural-language instruction (or you reuse their testing goal).
80
- 1. `muggle-remote-use-case-prompt-preview` with `projectId`, `instruction` — show preview; get confirmation via `AskQuestion`.
100
+ 1. `muggle-remote-use-case-prompt-preview` with `projectId`, `instruction` — show preview; get confirmation via `AskUserQuestion`.
81
101
  2. `muggle-remote-use-case-create-from-prompts` with `projectId` and `instructions: ["<the user's natural-language instruction>"]` — persist. Use the created use case id and continue to test-case selection.
82
102
  - **Test case — Create new test case** (requires a chosen `useCaseId`): User provides an instruction describing what to test.
83
- 1. `muggle-remote-test-case-generate-from-prompt` with `projectId`, `useCaseId`, `instruction` — **preview only** (server test-case prompt preview); show the returned draft(s); get confirmation via `AskQuestion`.
103
+ 1. `muggle-remote-test-case-generate-from-prompt` with `projectId`, `useCaseId`, `instruction` — **preview only** (server test-case prompt preview); show the returned draft(s); get confirmation via `AskUserQuestion`.
84
104
  2. Persist the accepted draft with `muggle-remote-test-case-create`, mapping preview fields into the required properties (`title`, `description`, `goal`, `expectedResult`, `url`, etc.). Then continue from **section 5** with that `testCaseId`.
85
105
 
86
106
  ### 3. Ensure Local Services Are Ready
@@ -94,13 +114,16 @@ Before detecting the local URL, verify that the services the user needs are actu
94
114
 
95
115
  This step is especially important when the user's app depends on sibling services (a backend API, an auth service, etc.) that may not be running yet. The prepare skill handles discovery, startup, and cleanup so this skill doesn't have to.
96
116
 
97
- ### 4. Local URL
117
+ **Compile-gate (do not skip)** — after `muggle-test-prepare` reports ready, run the two-stage readiness probe per [`_shared/dev-server-readiness.md`](../_shared/dev-server-readiness.md) before dispatching any test. Halt on any failure it surfaces; do not dispatch against a broken bundle.
98
118
 
99
- Try to auto-detect the dev server URL by checking running terminals or common ports (e.g., `lsof -iTCP -sTCP:LISTEN -nP | grep -E ':(3000|3001|4200|5173|8080)'`). If a likely URL is found, present it as a clickable default via `AskQuestion`:
100
- - Option 1: "http://localhost:3000" (or whatever was detected)
101
- - Option 2: "Other — let me type a URL"
119
+ ### 4. Local URL (gated by `autoSelectLocalHost`)
102
120
 
103
- If nothing detected, ask as free text: "Your local app should be running. What's the URL? (e.g., http://localhost:3000)"
121
+ Skill responsibilities (the rest is in `preference-gates/autoSelectLocalHost.md`):
122
+ - **Read the cache**: `Muggle Test Last Host: <url>` session-context line, or `muggle-local-last-host-get`. Pass as `{lastHost}` substitution.
123
+ - **Auto-detect a suggested URL**: `lsof -iTCP -sTCP:LISTEN -nP | grep -E ':(3000|3001|4200|5173|8080)'`. Pass as `{suggestedHost}`.
124
+ - **Save the cache**: call `muggle-local-last-host-set` after the user picks (the gate file requires this on every pick).
125
+
126
+ Gate `autoSelectLocalHost` per `preference-gates/README.md` + `preference-gates/autoSelectLocalHost.md`.
104
127
 
105
128
  Remind them: local URL is only the execution target, not tied to cloud project config.
106
129
 
@@ -108,7 +131,7 @@ Remind them: local URL is only the execution target, not tied to cloud project c
108
131
 
109
132
  `muggle-remote-test-script-list` with `testCaseId`.
110
133
 
111
- - **If any replayable/succeeded scripts exist:** use `AskQuestion` to present them as clickable options. Show: name, created/updated, step count per option. Include **"Generate new script"** as the last option.
134
+ - **If any replayable/succeeded scripts exist:** use `AskUserQuestion` to present them as clickable options. Show: name, created/updated, step count per option. Include **"Generate new script"** as the last option.
112
135
  - **If none:** go straight to generation (no need to ask replay vs generate).
113
136
 
114
137
  ### 6. Load data for the chosen path
@@ -154,69 +177,53 @@ The MCP client often uses a **default wait of 300000 ms (5 minutes)** for `muggl
154
177
  Call `muggle-local-execute-test-generation` or `muggle-local-execute-replay` directly. **Do not** ask the user to re-approve the Electron launch — the user choosing this skill in the first place is the approval.
155
178
 
156
179
  Gate `showElectronBrowser` (per `preference-gates/README.md`). Reuse choice within a session.
157
- - Pro-action: omit `showUi`.
158
- - Skip-action: pass `showUi: false`.
180
+ - `always` → omit `showUi`.
181
+ - `never` → pass `showUi: false`.
182
+ - `ask` → run Picker 1 from `preference-gates/showElectronBrowser.md` via `AskUserQuestion`; map the answer back to one of the actions above.
183
+
184
+ ### 8. Upload run to cloud (every completed run; open `viewUrl` gated by `openTestResultsAfterRun`)
159
185
 
160
- ### 8. After successful generation only (open `viewUrl` gated by `openTestResultsAfterRun`)
186
+ Upload pass-or-fail. Failed runs still need cloud-hosted screenshots and per-step actions for the PR walkthrough — without them reviewers see only a generic "failed" link. The `status` field in the upload payload tells the backend whether to promote the run's action script as the test case's canonical replay script (passed → promote; failed → record only).
161
187
 
162
188
  - `muggle-local-publish-test-script`
163
189
  - Gate `openTestResultsAfterRun` (per `preference-gates/README.md`):
164
- - Pro-action: open `viewUrl` automatically (`open "<viewUrl>"` on macOS or OS equivalent).
165
- - Skip-action: print the URL only.
190
+ - `always` → open `viewUrl` automatically (`open "<viewUrl>"` on macOS or OS equivalent).
191
+ - `never` → print the URL only.
192
+ - `ask` → run Picker 1 from `preference-gates/openTestResultsAfterRun.md` via `AskUserQuestion`; map the answer back to one of the actions above.
193
+
194
+ If publish rejects with `has no generated actionScript steps to publish` (true zero-step runs — Electron never produced an action), fall back to `muggle-remote-local-run-upload` directly with whatever data exists (`summaryStep`, `errorMessage`, empty `actionScript`). This still gets the failure summary and any goal-not-achievable verdict onto the dashboard so reviewers can see why the run failed. Capture the returned `actionScriptId` and `viewUrl` from this fallback path the same way you would from publish.
166
195
 
167
196
  ### 9. Report
168
197
 
169
198
  - `muggle-local-run-result-get` with the run id from execute.
170
199
  - Include: status, duration, pass/fail summary, per-step summary, artifact/screenshot paths, errors if failed, and script view URL when publishing ran.
171
200
 
172
- ### 10. Offer to post a visual walkthrough to the PR
173
-
174
- After reporting results, gather the required input and hand off to the shared **`muggle:muggle-pr-visual-walkthrough`** skill, which renders the walkthrough via `muggle build-pr-section` and posts it to the current branch's open PR.
175
-
176
- #### 10a: Gather per-step screenshots
201
+ ### 9a. Route failures through the failure-mode handler
177
202
 
178
- The shared skill takes an **`E2eReport` JSON** that includes per-step screenshot URLs. After step 8 has called `muggle-local-publish-test-script` and you have the `testScriptId`:
203
+ If the run's status is `failed` or any non-passing terminal state, follow [`_shared/failure-mode-handling.md`](../_shared/failure-mode-handling.md):
179
204
 
180
- 1. Call `muggle-remote-test-script-get` with the `testScriptId`.
181
- 2. Extract per step: `steps[].operation.action` and `steps[].operation.screenshotUrl`.
182
- 3. Build the `steps` array: `[{ stepIndex: 0, action: "...", screenshotUrl: "..." }, ...]`.
183
- 4. If the run failed, capture `failureStepIndex`, `error`, and the local `artifactsDir` from the run result in step 9.
184
- 5. Populate `description` (test case title/description) and `useCaseName` (parent use case title) on the report entry — optional but strongly recommended; they drive the grouped overview and the per-test collapsible headers. Prefer values already in your conversation context from earlier steps (e.g. the test case you just created or selected, or the use case you confirmed); only call `muggle-remote-test-case-get` / `muggle-remote-use-case-get` for anything you don't already have.
205
+ - **Replay-mode run failed** (the user picked an existing script in Step 5) → section B (buckets: `infra` / `stale-script` / `product-defect`).
206
+ - **Regen-mode run failed** (the user picked "Generate new script" or no script existed) → section C (buckets: `transient` / `infra` / `agent-course` / `product-uxux`).
185
207
 
186
- Assemble the `E2eReport`:
208
+ Steps:
209
+ 1. Read the run via `muggle-local-run-result-get` and extract signals per the heuristics in the shared doc.
210
+ 2. Emit `replay-failure-classified` or `regen-failure-classified` via `muggle-local-telemetry-event-emit` **before** asking the user.
211
+ 3. Present the recommended action via `AskUserQuestion` with the alternatives the shared doc lists for that bucket.
212
+ 4. After the user picks, emit the matching `*-resolved` event with `userAction`.
187
213
 
188
- ```json
189
- {
190
- "projectId": "<projectId from step 2 (Targets)>",
191
- "tests": [
192
- {
193
- "name": "<test case title>",
194
- "description": "<one-line description of what this test verifies (optional but recommended)>",
195
- "useCaseName": "<parent use case title (optional but recommended)>",
196
- "testCaseId": "<id>",
197
- "testScriptId": "<id from publish>",
198
- "runId": "<runId from execute>",
199
- "viewUrl": "<viewUrl from publish>",
200
- "status": "passed",
201
- "steps": [{ "stepIndex": 0, "action": "...", "screenshotUrl": "..." }]
202
- }
203
- ]
204
- }
205
- ```
214
+ If the user picks `muggle-feedback` from any bucket's options, invoke the `muggle-feedback` skill via the `Skill` tool, passing the just-finished `runId` so the submit flow opens with this run preloaded.
206
215
 
207
- See the `muggle:muggle-pr-visual-walkthrough` skill for the full schema including the failed-test shape.
216
+ Skip silently when the run passed cleanly — failure-mode events are by definition about failures.
208
217
 
209
- #### 10b: Detect the PR, then apply the `postPRVisualWalkthrough` gate
210
-
211
- Run `gh pr view --json number,title,url 2>/dev/null` first (mandatory). Then gate `postPRVisualWalkthrough` (per `preference-gates/README.md` + gate file):
212
- - **Case A (PR found)** — `always` → proceed to 10c; `never`/skip → stop.
213
- - **Case B (no PR)** — always run Picker 1 regardless of saved value; "Create a PR and post" → create PR then proceed to 10c; "Skip" → stop.
214
-
215
- #### 10c: Invoke the shared skill in Mode A
218
+ ### 10. Offer to post a visual walkthrough to the PR
216
219
 
217
- Invoke the `muggle:muggle-pr-visual-walkthrough` skill via the `Skill` tool. With the `E2eReport` in context, the skill renders the markdown block via the CLI, posts `body` as a comment to the PR, posts the overflow `comment` only if the CLI emitted one, and confirms the PR URL to the user.
220
+ After reporting results:
218
221
 
219
- Always use **Mode A** (post to existing PR) from this skill. Never hand-write the walkthrough markdown or call `gh pr comment` directly — delegate to `muggle:muggle-pr-visual-walkthrough`.
222
+ 1. Fire [`postPRVisualWalkthrough`](../muggle-preferences/preference-gates/postPRVisualWalkthrough.md). On skip → end.
223
+ 2. `gh pr view --json number,title,url 2>/dev/null` — find the PR.
224
+ 3. If no PR: fire [`autoCreatePR`](../muggle-preferences/preference-gates/autoCreatePR.md). On skip → end.
225
+ 4. Assemble the `E2eReport` — see [`../muggle-pr-visual-walkthrough/e2e-report-assembly.md`](../muggle-pr-visual-walkthrough/e2e-report-assembly.md).
226
+ 5. Invoke [`../muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A with the `E2eReport`.
220
227
 
221
228
  ## Non-negotiables
222
229
 
@@ -225,6 +232,6 @@ Always use **Mode A** (post to existing PR) from this skill. Never hand-write th
225
232
  - If replayable scripts exist, do not default to generation without user choice.
226
233
  - No hiding failures: surface errors and artifact paths.
227
234
  - Replay: never hand-built or simplified `actionScript` — only from `muggle-remote-action-script-get`.
228
- - Use `AskQuestion` for every selection — project, use case, test case, script. Never ask the user to type a number.
235
+ - Use `AskUserQuestion` for every selection — project, use case, test case, script. Never ask the user to type a number.
229
236
  - Project, use case, and test case selection lists must always include "Create new ...". Include "Show full list" whenever the API returned at least one row for that step; omit "Show full list" when the list is empty (offer "Create new ..." only). For creates, use preview tools (`muggle-remote-use-case-prompt-preview`, `muggle-remote-test-case-generate-from-prompt`) before persisting.
230
237
  - PR posting is always optional and always delegated to the `muggle:muggle-pr-visual-walkthrough` skill — never inline the walkthrough markdown or call `gh pr comment` directly from this skill.
@@ -4,19 +4,21 @@ description: >
4
4
  Bring existing tests and test artifacts INTO Muggle Test — from Playwright, Cypress, PRDs,
5
5
  Gherkin feature files, test plan docs, Notion exports, or any source.
6
6
  TRIGGER when: user wants to import/migrate/load/upload/add/convert existing test files or
7
- test docs into Muggle — e.g. "import my playwright tests", "migrate from cypress to muggle",
7
+ test docs into Muggle Test — e.g. "import my playwright tests", "migrate from cypress to muggle",
8
8
  "upload my PRD to muggle", "add my e2e specs to our muggle project", "load these test cases
9
9
  into muggle", "turn this feature file into muggle test cases", "create muggle test cases from
10
10
  my PRD", "track my specs in muggle", or any .spec.ts/.cy.js/.feature/.md file + muggle.
11
- DO NOT TRIGGER when: user wants to run/replay Muggle scripts, scan a site, generate new
11
+ DO NOT TRIGGER when: user wants to run/replay Muggle Test scripts, scan a site, generate new
12
12
  tests from scratch, or check existing test results.
13
13
  ---
14
14
 
15
15
  # Muggle Test Import
16
16
 
17
+ > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle-test-import"`.
18
+
17
19
  This skill migrates existing test artifacts into Muggle Test. It reads your source files,
18
20
  structures them into use cases and test cases, gets your approval, then creates everything
19
- in a Muggle project via the API.
21
+ in a Muggle Test project via the API.
20
22
 
21
23
  ## Preferences
22
24
 
@@ -25,7 +27,7 @@ Gates run per `preference-gates/README.md`.
25
27
  | Preference | Step | Decision it gates |
26
28
  |------------|------|-------------------|
27
29
  | `autoLogin` | 4 | Reuse saved credentials when auth is required |
28
- | `autoSelectProject` | 5 | Reuse last-used Muggle project for this repo |
30
+ | `autoSelectProject` | 5 | Reuse last-used Muggle Test project for this repo |
29
31
  | `suggestRelatedUseCases` | 8a | Suggest related use cases after import |
30
32
  | `suggestRelatedTestCases` | 8b | Suggest related test cases after import |
31
33
 
@@ -61,7 +63,7 @@ The extraction strategy depends on the file type. Choose the right path before r
61
63
 
62
64
  ### Path A — PRD / design documents (preferred for document sources)
63
65
 
64
- Muggle has a native PRD processing workflow that extracts use cases more accurately than
66
+ Muggle Test has a native PRD processing workflow that extracts use cases more accurately than
65
67
  manual parsing. Use this path for `.md`, `.txt`, `.pdf`, or any prose document.
66
68
 
67
69
  After authentication and project selection (Steps 4–5), come back and:
@@ -125,13 +127,13 @@ Found 3 use cases with 8 test cases:
125
127
  ✦ [HIGH] Checkout fails with invalid payment info
126
128
  ```
127
129
 
128
- Use `AskQuestion` to confirm:
130
+ Use `AskUserQuestion` to confirm:
129
131
  - "Looks good — proceed with import"
130
132
  - "I want to make changes first"
131
133
 
132
134
  If the user wants changes, incorporate feedback, then ask again. Only proceed after explicit approval.
133
135
 
134
- > For Path A (native PRD upload): present the use case/test case list that Muggle extracted
136
+ > For Path A (native PRD upload): present the use case/test case list that Muggle Test extracted
135
137
  > after the processing workflow completes, and ask the user to confirm before adding any
136
138
  > extra test cases manually.
137
139
 
@@ -142,8 +144,9 @@ If the user wants changes, incorporate feedback, then ask again. Only proceed af
142
144
  Call `muggle-remote-auth-status` first.
143
145
 
144
146
  If **already authenticated** → gate `autoLogin` (per `preference-gates/README.md`):
145
- - Pro-action: skip to Step 5.
146
- - Skip-action: `muggle-remote-auth-login` with `forceNewSession: true`, then `muggle-remote-auth-poll`.
147
+ - `always` → skip to Step 5.
148
+ - `never` → `muggle-remote-auth-login` with `forceNewSession: true`, then `muggle-remote-auth-poll`.
149
+ - `ask` → run Picker 1 from `preference-gates/autoLogin.md` via `AskUserQuestion`; map the answer back to one of the actions above.
147
150
 
148
151
  If **not authenticated**:
149
152
  1. Tell the user a browser window is about to open.
@@ -157,9 +160,9 @@ If **not authenticated**:
157
160
 
158
161
  A **project** is where all your imported use cases, test cases, and future test results are grouped on the Muggle AI dashboard.
159
162
 
160
- The per-repo project cache lives at `<cwd>/.muggle-ai/last-project.json` (via the `muggle-local-last-project-get` / `muggle-local-last-project-set` MCP tools). Look for `Muggle Last Project: id=… url=… name="…"` in session context.
163
+ The per-repo project cache lives at `<cwd>/.muggle-ai/last-project.json` (via the `muggle-local-last-project-get` / `muggle-local-last-project-set` MCP tools). Look for `Muggle Test Last Project: id=… url=… name="…"` in session context.
161
164
 
162
- Gate `autoSelectProject` (per `preference-gates/README.md`). Cache: `Muggle Last Project` session line.
165
+ Gate `autoSelectProject` (per `preference-gates/README.md`). Cache: `Muggle Test Last Project` session line.
163
166
  - `always` + cache → use cached `projectId`, skip to Step 6. No cache → fall through to `ask`.
164
167
  - `never` → full project list; skip Picker 2.
165
168
  - `ask` → project list picker (see gate file for spec + Picker 2 override). Skip Picker 2 if "Create new project".
@@ -167,7 +170,7 @@ Gate `autoSelectProject` (per `preference-gates/README.md`). Cache: `Muggle Last
167
170
  ### Logic
168
171
 
169
172
  1. Call `muggle-remote-project-list` (only when not satisfied by the `always` cache).
170
- 2. Use `AskQuestion` to present all projects as clickable options. Include the project URL in each label. Always include a "Create new project" option at the end.
173
+ 2. Use `AskUserQuestion` to present all projects as clickable options. Include the project URL in each label. Always include a "Create new project" option at the end.
171
174
 
172
175
  Prompt: `"Pick the project to import into:"`
173
176
 
@@ -184,12 +187,12 @@ Gate `autoSelectProject` (per `preference-gates/README.md`). Cache: `Muggle Last
184
187
 
185
188
  Import in two passes using bulk-preview. Show progress to the user as you go.
186
189
 
187
- Both passes use Muggle's async bulk-preview MCP tools, which route prompts through OpenAI's
190
+ Both passes use Muggle Test's async bulk-preview MCP tools, which route prompts through OpenAI's
188
191
  Batch API for roughly ~50% of normal LLM cost. The flow is always: **submit → poll → persist**.
189
192
 
190
193
  ### Path A — Native PRD upload (for document files)
191
194
 
192
- If the source is a PRD or design document, use Muggle's built-in processing pipeline:
195
+ If the source is a PRD or design document, use Muggle Test's built-in processing pipeline:
193
196
 
194
197
  1. Read the file and base64-encode its content:
195
198
  ```bash
@@ -273,7 +276,7 @@ Failed items:
273
276
 
274
277
  Proceed with the <N> successful items, or cancel to review?
275
278
  ```
276
- Use `AskQuestion` with options "Proceed with successful items" / "Cancel import". Only continue
279
+ Use `AskUserQuestion` with options "Proceed with successful items" / "Cancel import". Only continue
277
280
  if the user chooses to proceed.
278
281
 
279
282
  If you need to abort an in-flight job, call `muggle-remote-bulk-preview-job-cancel` — the
@@ -365,7 +368,7 @@ When all imports are done, print a clean summary. Include:
365
368
  - A link to the project overview
366
369
  - If any items failed during preview (partial status), list them so the user can retry
367
370
 
368
- Construct view URLs using the Muggle dashboard URL pattern:
371
+ Construct view URLs using the Muggle Test dashboard URL pattern:
369
372
  - Project test cases: `https://www.muggle-ai.com/muggleTestV0/dashboard/projects/<projectId>/testcases`
370
373
  - Use case within project: `https://www.muggle-ai.com/muggleTestV0/dashboard/projects/<projectId>/testcases?useCaseId=<useCaseId>`
371
374
 
@@ -401,14 +404,15 @@ Two preferences gate optional follow-ups: `suggestRelatedUseCases` and `suggestR
401
404
  The query is: "from the use cases already in this project, which ones are *not* in the import set but look related to it?" — surface them so the user can decide whether their import missed something the project already tracks.
402
405
 
403
406
  Gate `suggestRelatedUseCases` (per `preference-gates/README.md`):
404
- - Pro-action: run the query below.
405
- - Skip-action: skip.
407
+ - `always` → run the query below.
408
+ - `never` → skip.
409
+ - `ask` → run Picker 1 from `preference-gates/suggestRelatedUseCases.md` via `AskUserQuestion`; map the answer back to one of the actions above.
406
410
 
407
411
  When running the query:
408
412
  1. Call `muggle-remote-use-case-list` for the project.
409
413
  2. Filter out any use case whose `useCaseId` is in the set you just imported in Step 6 (Pass 1).
410
414
  3. Rank the remainder by semantic relevance to the imported titles/descriptions (substring overlap, shared keywords — best-effort, no LLM call needed).
411
- 4. Present the top 3-5 via `AskQuestion` with `allow_multiple: true`. Label each with `<title> — <one-line description>`.
415
+ 4. Present the top 3-5 via `AskUserQuestion` with `allow_multiple: true`. Label each with `<title> — <one-line description>`.
412
416
  5. For any the user selects, prompt to add follow-up test cases (treat each as a Pass 2 invocation: `muggle-remote-test-case-bulk-preview-submit` → poll → persist via `muggle-remote-test-case-create`).
413
417
  6. If the filtered list is empty (the import covers everything in the project), say so and skip.
414
418
 
@@ -417,12 +421,13 @@ When running the query:
417
421
  For each use case the user just created, surface other test cases already attached that the import didn't add — same idea, scoped to a single use case.
418
422
 
419
423
  Gate `suggestRelatedTestCases` (per `preference-gates/README.md`):
420
- - Pro-action: run the query below.
421
- - Skip-action: skip.
424
+ - `always` → run the query below.
425
+ - `never` → skip.
426
+ - `ask` → run Picker 1 from `preference-gates/suggestRelatedTestCases.md` via `AskUserQuestion`; map the answer back to one of the actions above.
422
427
 
423
428
  When running the query, for each use case in the import:
424
429
  1. Call `muggle-remote-test-case-list-by-use-case` with that `useCaseId`.
425
430
  2. Filter out any test case you just created in Pass 2 of Step 6.
426
- 3. Present the remainder via `AskQuestion` with `allow_multiple: true`, labeled `[<priority>] <title> — <goal>`.
427
- 4. For any the user selects: nothing to create (they already exist) — just confirm to the user that those tests are now part of their Muggle project alongside the imported ones.
431
+ 3. Present the remainder via `AskUserQuestion` with `allow_multiple: true`, labeled `[<priority>] <title> — <goal>`.
432
+ 4. For any the user selects: nothing to create (they already exist) — just confirm to the user that those tests are now part of their Muggle Test project alongside the imported ones.
428
433
  5. If a use case has no extra test cases, skip it silently.
@@ -5,6 +5,8 @@ description: "Make sure dev servers and sibling services are ready on the user's
5
5
 
6
6
  # Muggle Test Prepare
7
7
 
8
+ > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle-test-prepare"`.
9
+
8
10
  Make sure the local services a user needs for E2E acceptance testing are up and ready. Check what's already running, discover sibling service directories by folder name, and offer to start anything that's missing — always with the user in control.
9
11
 
10
12
  Some users start their own services (tmux scripts, docker-compose, a terminal per service). Others want help launching them. This skill handles both: it verifies readiness first, and only offers to start things when something is missing.
@@ -45,18 +47,30 @@ The `testing_scope` field records what the user is testing (from Step 1). The `e
45
47
 
46
48
  **On every invocation**, check this file first. If it exists with live PIDs (verify with `kill -0`), present the running services and ask:
47
49
 
48
- Use `AskQuestion`:
50
+ Use `AskUserQuestion`:
49
51
  - Option 1: "Keep them running — skip to testing"
50
52
  - Option 2: "Tear down and start fresh"
51
53
  - Option 3: "Add more services to the running set"
52
54
 
53
55
  Prune any dead PIDs silently (the process crashed on its own — no point asking about it).
54
56
 
57
+ ## Preferences
58
+
59
+ Gates run per [`preference-gates/README.md`](../muggle-preferences/preference-gates/README.md).
60
+
61
+ | Preference | Step | Decision it gates |
62
+ |------------|------|-------------------|
63
+ | `autoRebase` | 0 | Rebase onto `origin/<default>` before starting dev servers (see [`_shared/rebase-before-e2e.md`](../_shared/rebase-before-e2e.md)) |
64
+
55
65
  ## Workflow
56
66
 
67
+ ### Step 0: Rebase check (gated by `autoRebase`)
68
+
69
+ Fire per [`_shared/rebase-before-e2e.md`](../_shared/rebase-before-e2e.md) when `behind > 0`. Otherwise skip silently.
70
+
57
71
  ### Step 1: What Are You Testing?
58
72
 
59
- Before discovering services, understand the shape of the testing so you can scope correctly. Use `AskQuestion`:
73
+ Before discovering services, understand the shape of the testing so you can scope correctly. Use `AskUserQuestion`:
60
74
 
61
75
  > "What are you testing locally?"
62
76
 
@@ -72,7 +86,7 @@ Some services can't run on a developer's machine by design — they need product
72
86
 
73
87
  **If the user already volunteered this information** in their initial message (e.g., "the payment-gateway can't run locally"), acknowledge it and skip the question — don't re-ask what they already answered.
74
88
 
75
- Otherwise, use `AskQuestion`:
89
+ Otherwise, use `AskUserQuestion`:
76
90
 
77
91
  > "Are there any services in your stack that **can't** run locally? (e.g., needs production secrets, specific certificates, or cloud-only infra)"
78
92
 
@@ -98,7 +112,7 @@ Figure out which services need to be running. Start by listing folder names in t
98
112
  ls -d "$(dirname "$PWD")"/*/ | xargs -I{} basename {}
99
113
  ```
100
114
 
101
- Present folder names only (not contents) as candidates. Use `AskQuestion` with `multiSelect: true`:
115
+ Present folder names only (not contents) as candidates. Use `AskUserQuestion` with `multiSelect: true`:
102
116
 
103
117
  > "Which of these need to be running for your tests?"
104
118
 
@@ -112,7 +126,7 @@ If the user provides manual paths, verify they exist before continuing. If a pat
112
126
 
113
127
  **Immediately after the user selects services**, ask how they want to handle startup. This avoids making someone who prefers their own scripts wait through command detection before they get to say "I'll handle it."
114
128
 
115
- Use `AskQuestion`:
129
+ Use `AskUserQuestion`:
116
130
 
117
131
  > "How do you want to handle these?"
118
132
 
@@ -125,24 +139,53 @@ If the user picks **option 1**: proceed through Steps 4-7 as normal.
125
139
 
126
140
  ### Step 4: Check What's Already Running
127
141
 
128
- Before offering to start anything, check what's already listening on common dev ports:
129
-
130
- ```bash
131
- lsof -iTCP -sTCP:LISTEN -nP 2>/dev/null | grep -E ':(3000|3001|3002|4200|5173|5174|8080|8081|8000|8888|4000|9000)'
132
- ```
133
-
134
- Cross-reference against the selected service directories. If a selected service appears to already be running (match by port or by the process's working directory), report it as ready:
142
+ Run port detection and (when the app declares a backend URL) backend-health probe per [`_shared/dev-server-readiness.md`](../_shared/dev-server-readiness.md). Cross-reference hits against the selected service directories. If a selected service appears to already be running (match by port or by the process's working directory), report it as ready:
135
143
 
136
144
  > "**backend-api** is already listening on port 3001 (PID 54321) — looks good."
137
145
 
138
146
  If **all** required services are already running, report readiness and skip straight to Step 7. No need to go through Steps 5-6.
139
147
 
140
- If some are running and some aren't, acknowledge the running ones and continue to Step 5 only for the missing services. Use `AskQuestion` for any already-running service the user might want restarted:
148
+ If some are running and some aren't, acknowledge the running ones and continue to Step 5 only for the missing services. Use `AskUserQuestion` for any already-running service the user might want restarted:
141
149
  - Option 1: "It's fine, keep it"
142
150
  - Option 2: "Restart it"
143
151
 
144
152
  For services that are already running and the user wants to keep, add them to the PID tracking file so cleanup can find them later, but mark them as `external: true` so cleanup knows not to kill them (the user started them independently).
145
153
 
154
+ **Port already held** — when the user wants a port that is currently held by a process they did **not** select (typically a stale dev server from a sibling worktree). Surface the conflict via `AskUserQuestion`:
155
+
156
+ > "Port 3999 is held by PID 87421 (you didn't select this process). How do you want to proceed?"
157
+
158
+ - Option 1: "Use the next available port" (recommended — non-destructive)
159
+ - Option 2: "Force-kill PID 87421 and claim port 3999"
160
+ - Option 3: "Abort"
161
+
162
+ **Option 1 — next available port:** probe `3999 + N` for `N = 1, 2, 3, ...` until `Test-NetConnection`/`lsof -i :<port>` returns nothing listening. Record the new port (and the env file edit, if `PORT=` is set in `.env.local` etc.) so downstream steps use it. The dev server may need a restart to pick up the new value.
163
+
164
+ **Option 2 — force-kill (destructive):**
165
+ - **Windows PowerShell:** `Get-NetTCPConnection -LocalPort <port> -ErrorAction SilentlyContinue | ForEach-Object { try { Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue } catch { } }`
166
+ - **POSIX:** `lsof -ti:<port> 2>/dev/null | xargs -r kill -9`
167
+
168
+ Re-verify the port is free before continuing.
169
+
170
+ ### Step 4.5: Environment File Sanity
171
+
172
+ The env file is **per-repo** — don't hardcode `.env.local`. Detect it: scan `package.json` `scripts/*` for `.env*` literals and known port vars (`PORT=`, `VITE_PORT=`); check framework config (`next.config.*`, `vite.config.*`).
173
+
174
+ When a dependency on an env file exists:
175
+
176
+ 1. Check whether `<cwd>/<envfile>` exists. If yes, no-op.
177
+ 2. If absent, `git worktree list --porcelain` and check each sibling for the same filename.
178
+ 3. If found, surface via `AskUserQuestion`:
179
+
180
+ > "`<envfile>` is missing in this worktree but exists at `<sibling>/<envfile>`. Copy it before starting services?"
181
+
182
+ - Option 1: "Yes — copy from `<sibling>`"
183
+ - Option 2: "No — I'll provide it another way"
184
+
185
+ 4. If not found anywhere, report and ask how to proceed.
186
+
187
+ Skip silently when no env file is referenced. The point is to catch the common worktree-bootstrap miss, not to mandate any specific file.
188
+
146
189
  ### Step 5: Determine Start Commands
147
190
 
148
191
  For each required service that isn't already running, figure out how to start it. Propose the command so there's a shared understanding.
@@ -174,12 +217,33 @@ frontend ~/Github/frontend npm run dev
174
217
  ────────────────────────────────────────────────────────────────
175
218
  ```
176
219
 
177
- Use `AskQuestion`:
220
+ Use `AskUserQuestion`:
178
221
  - Option 1: "Looks good, start them"
179
222
  - Option 2: "I need to edit some commands"
180
223
 
181
224
  If the user needs edits, collect corrections and re-present.
182
225
 
226
+ ### Step 5.5: Fresh-Worktree Install Probe
227
+
228
+ Before launching `npm run dev` (or equivalent) in a Node service, check whether `node_modules/` is present and current. Stale or missing `node_modules/` causes silent runtime failures that look like the service is broken when actually the install is just missing.
229
+
230
+ For each Node service the user selected:
231
+
232
+ 1. If `<service-dir>/node_modules/` is missing entirely → install is required.
233
+ 2. If `<service-dir>/package-lock.json` is newer than `<service-dir>/node_modules/.package-lock.json` → install is stale.
234
+ 3. Otherwise → install is current, no action needed.
235
+
236
+ When install is required or stale, propose via `AskUserQuestion`:
237
+
238
+ > "`<service-name>` needs a fresh `npm install` before starting (node_modules is missing/stale). Run `npm install --prefer-offline --no-audit --no-fund` now?"
239
+
240
+ - Option 1: "Yes — install now"
241
+ - Option 2: "No — skip; I know it's fine"
242
+
243
+ **Never symlink `node_modules/` from a sibling worktree.** webpack's `resolve.symlinks: true` default rewrites paths to the shared real location; asset-identity tracking fails with `Can't handle conflicting asset info for sourceFilename`. Run a real per-worktree install.
244
+
245
+ For non-Node services (Go, Rust, Python), skip this probe — their build systems handle dependency caching differently.
246
+
183
247
  ### Step 6: Start Services
184
248
 
185
249
  For each service, launch in the background:
@@ -191,10 +255,7 @@ echo $!
191
255
 
192
256
  Capture the PID. Write all service entries to `/tmp/muggle-test-prepare.json`.
193
257
 
194
- **Startup verification** — after a short pause (~3-5 seconds per service), check:
195
-
196
- 1. PID is alive: `kill -0 <pid> 2>/dev/null`
197
- 2. Port is listening (if known): `lsof -iTCP:<port> -sTCP:LISTEN -nP 2>/dev/null`
258
+ **Startup verification** — first confirm the PID is alive (`kill -0 <pid> 2>/dev/null`), then run the two-stage readiness probe per [`_shared/dev-server-readiness.md`](../_shared/dev-server-readiness.md) against `/tmp/muggle-prepare-<service-name>.log`. Cap log-tail at 60s. Halt on whatever it surfaces; do not re-implement the ready-signal patterns here.
198
259
 
199
260
  If a service's PID dies immediately, read the last 20 lines of its log and show the user:
200
261