@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
@@ -0,0 +1,150 @@
1
+ # PR follow-up helpers
2
+
3
+ Generic operational guidance for running a PR-comment follow-up loop on GitHub: reviewer allow-list resolution, reply routing across the different comment endpoints, and a classification rule for reviewer comments with worked examples and a borderline test. Caller-agnostic — any loop that picks one comment per tick and decides what to do with it can drive off this doc.
4
+
5
+ The classification produces an **action shape** (in-place change, deep-cycle through the caller's implementation pipeline, reply only, escalate, etc.) — the caller maps each shape to its specific routing (which stage to dispatch, which terminal-message template to use, which reply endpoint to hit).
6
+
7
+ ## Resolving the reviewer allow-list
8
+
9
+ Stage 8 only acts on comments authored by users in the **allow-list** = (requested reviewers ∪ CODEOWNERS) − bots − PR author. Re-resolve every tick (decision 9 in the design doc).
10
+
11
+ ### Step 1: requested reviewers
12
+
13
+ ```bash
14
+ gh pr view <number> --repo <owner>/<repo> --json reviewRequests,author
15
+ ```
16
+
17
+ `reviewRequests` is an array of `{ login? , slug? }`. User reviewers have `login`; team reviewers have `slug` (and `name`). Expand teams to member logins:
18
+
19
+ ```bash
20
+ gh api orgs/<org>/teams/<slug>/members --jq '.[].login'
21
+ ```
22
+
23
+ Record `prAuthor = author.login` for the exclusion step.
24
+
25
+ ### Step 2: CODEOWNERS
26
+
27
+ Look for the file in this order — first hit wins:
28
+
29
+ 1. `.github/CODEOWNERS`
30
+ 2. `CODEOWNERS`
31
+ 3. `docs/CODEOWNERS`
32
+
33
+ Read from the PR's **head branch** (not master), because a PR that adds CODEOWNERS should be allowed to take effect once merged but is informational while open. In practice this means:
34
+
35
+ ```bash
36
+ gh api repos/<owner>/<repo>/contents/.github/CODEOWNERS?ref=<head_sha> --jq '.content' | base64 -d
37
+ ```
38
+
39
+ Parse line-by-line:
40
+
41
+ - Skip blank lines and lines starting with `#`.
42
+ - Each line is `<pattern> <owner1> <owner2> ...`.
43
+ - Owners are either `@user` or `@org/team`. Strip the leading `@`.
44
+ - For our purposes we don't need to match `<pattern>` against changed files — CODEOWNERS membership for the *repo* is enough. Collect the union of all owners across all lines.
45
+
46
+ Expand `@org/team` to member logins via the orgs/teams/members endpoint (same as Step 1).
47
+
48
+ If no CODEOWNERS file exists in any of the three locations, the CODEOWNERS contribution is empty. Don't fail.
49
+
50
+ ### Step 3: filter
51
+
52
+ Allow-list = (requested reviewers ∪ CODEOWNERS) − `{prAuthor}` − bot logins.
53
+
54
+ Bot logins are any login matching:
55
+
56
+ - Ends with `[bot]` (e.g. `dependabot[bot]`)
57
+ - Exact match in the standard list: `dependabot`, `github-actions`, `renovate`, `mergify`
58
+
59
+ A comment author not in the allow-list is silently ignored — do not reply, do not address.
60
+
61
+ ## Reply routing
62
+
63
+ GitHub's PR APIs are not uniform across comment types. Route by parent type.
64
+
65
+ ### Line-level review comment
66
+
67
+ A comment attached to a specific file:line that belongs to a review thread. This is the **most common** path.
68
+
69
+ ```bash
70
+ gh api \
71
+ --method POST \
72
+ -H "Accept: application/vnd.github+json" \
73
+ /repos/<owner>/<repo>/pulls/<number>/comments/<comment_id>/replies \
74
+ -f body="Done in $(git rev-parse --short HEAD) — renamed \`fooBar\` to \`foo_bar\`."
75
+ ```
76
+
77
+ The reply lands in the same review thread. The reply itself becomes a new line-level comment with `in_reply_to_id = <comment_id>`.
78
+
79
+ ### Review body (CHANGES_REQUESTED with no inline comments)
80
+
81
+ A reviewer left a summary review with `state: CHANGES_REQUESTED` and a body, but **no** inline comments. GitHub has no "reply to review body" endpoint — post a top-level PR comment that references the review:
82
+
83
+ ```bash
84
+ gh pr comment <number> --repo <owner>/<repo> --body "Re: review #<review_id> — done in $(git rev-parse --short HEAD)."
85
+ ```
86
+
87
+ ### Failing CI check
88
+
89
+ No reply. The fix commit IS the response. Include the failing check name in the commit subject so the connection is obvious in `git log`:
90
+
91
+ ```
92
+ fix(ci): typecheck — narrow type of foo
93
+ fix(ci): lint — remove unused import
94
+ ```
95
+
96
+ ### Never
97
+
98
+ - Never post a top-level comment in reply to a line-level comment. It loses thread context and pollutes the PR conversation tab.
99
+ - Never `gh pr review --comment` for replies — that endpoint is for *new* reviews, not replies.
100
+ - Never reply twice to the same comment. The cursor in `last_seen.json` is the only re-entry guard; advance it after every reply.
101
+
102
+ ## Classify
103
+
104
+ Classify the **review as a unit**, not individual comments.
105
+
106
+ | Class | Signal | Action |
107
+ | :---- | :----- | :----- |
108
+ | **actionable** | Review names at least one concrete change or asks an answerable question. Soft phrasing counts when there's a concrete referent. | Treat as amended requirements; run the caller's implementation cycle; reply with one summary referencing the new SHA. |
109
+ | **ambiguous** | No actionable signal — pure vibes, contradictory, or depends on knowledge the loop can't access. | Escalate once with two interpretations; pause the PR. |
110
+
111
+ Default to **actionable**. CI catches wrong attempts; reviewers correct on the next round. Escalation is a round-trip with an absent user — reserve it.
112
+
113
+ Reply summary shape:
114
+
115
+ - **actionable**: `Addressed review <review_id> in <sha> — cycle ran clean (or: with <N> failures, see walkthrough).`
116
+ - **ambiguous**: no bot reply.
117
+
118
+ ### Worked examples — Actionable reviews
119
+
120
+ | Review (summarized) | Why actionable |
121
+ | :------------------ | :------------- |
122
+ | 3 comments: "rename `fooBar` to `foo_bar`", "use `const` here", "fix this typo" | Three concrete edits |
123
+ | 1 comment: "could the procedure be simpler?" | Soft-phrased but the intent is clear — simplify; pick the best interpretation, run the cycle, reply with what was changed |
124
+ | Review body: "Mostly looks good. Two things: extract the validation into a helper, and add a null check before the lookup." Plus 0 line comments. | Two concrete directives in the body |
125
+ | 4 comments: "why this approach?", "is this called from X?", "does this need to handle empty array?", "what's the perf here?" | All questions but each is answerable; cycle dispatches an "answer + maybe-fix" pass and the reply summary captures each answer |
126
+ | 1 comment: "rewrite this module — the architecture doesn't match the spec" | Substantive rebuild, but the direction is clear: redo the module per the spec |
127
+ | 1 comment: "I'd lean toward the bar.ts pattern" | Concrete referent (bar.ts) — apply that pattern |
128
+
129
+ The single review goes through one full cycle regardless of comment count.
130
+
131
+ ### Worked examples — Ambiguous reviews
132
+
133
+ | Review (summarized) | Why ambiguous |
134
+ | :------------------ | :------------ |
135
+ | 1 comment: "👀" / "hmm" / ":thinking:" | No signal at all |
136
+ | 1 comment: "this is wrong" with no target or direction | Asserts a problem but doesn't propose a fix |
137
+ | 2 comments: "use X" + "but actually don't use X" | Self-contradicting — can't reconcile without the reviewer |
138
+ | 1 comment: "we discussed this offline — please address" | References context the loop doesn't have |
139
+ | 1 comment: "won't this break the prod migration we did last week?" | Implicit change request gated on knowledge the loop can't access |
140
+ | Mixed: 2 concrete directives + 1 comment "but also, rethink the whole approach" | The "rethink the whole approach" subverts the other two; escalate to confirm scope |
141
+
142
+ Escalate per the caller's escalation procedure (write the review id to the cursor's escalated set, emit one terminal message with both interpretations, pause the PR until the user resolves).
143
+
144
+ ### Borderline rule
145
+
146
+ If you can paraphrase the review's intent as **"do X"** with X being a concrete change (one or several) — it's actionable. Pick the best interpretation and dispatch the cycle.
147
+
148
+ If you can paraphrase it only as **"the reviewer is dissatisfied but I can't tell with what"** — it's ambiguous.
149
+
150
+ When the review mixes both ("3 concrete directives + 1 dissatisfaction"), the safer move is usually to action the concrete directives and ask about the dissatisfaction in the reply summary. Pure ambiguity means *nothing* in the review is actionable.
@@ -0,0 +1,15 @@
1
+ # Rebase Onto the Default Branch Before Dev Server / E2E
2
+
3
+ Gated by [`autoRebase`](../muggle-preferences/preference-gates/autoRebase.md). Follow the standard procedure in [`preference-gates/README.md`](../muggle-preferences/preference-gates/README.md).
4
+
5
+ **Fire only when `behind > 0`:**
6
+
7
+ ```bash
8
+ git fetch origin
9
+ default=$(git symbolic-ref refs/remotes/origin/HEAD --short | sed 's|origin/||')
10
+ behind=$(git rev-list --count "HEAD..origin/${default}")
11
+ ```
12
+
13
+ Pass `{behind}` and `{default}` to the picker prompts. On `always`, run `git rebase origin/${default}`; stop and report on conflicts — never auto-resolve.
14
+
15
+ Stale branches produce false failures and false greens — that's why this gate exists.
@@ -0,0 +1,15 @@
1
+ # Skill Telemetry — Shared Convention
2
+
3
+ At the start of every `muggle-*` skill, call `muggle-local-telemetry-skill-emit` once. Fire-and-forget — never await, never let a telemetry failure block the skill.
4
+
5
+ **Args:**
6
+
7
+ - `skillName`: this skill's name (e.g. `"muggle-test"`)
8
+ - `trigger`: one of
9
+ - `"user-slash"` — user typed `/<skill-name>` (the common case; default this)
10
+ - `"claude-proactive"` — Claude matched on the skill's description, not a slash command
11
+ - `"nested-skill"` — invoked from another skill via the `Skill` tool
12
+
13
+ ## Failure-mode events
14
+
15
+ Skills that run replays or generations also emit structured failure-mode events through a separate tool — `muggle-local-telemetry-event-emit`. Don't reinvent the schema or sink in the skill; follow [`failure-mode-handling.md`](./failure-mode-handling.md), which defines the bucket taxonomies, the AI-classify → user-pick contract, and the exact event shape.
@@ -0,0 +1,53 @@
1
+ # Worktrees for Dev Work
2
+
3
+ Use this for feature development, local validation, and PR iteration.
4
+
5
+ ## Core guidance
6
+
7
+ - **One worktree per branch.** Never switch branches inside a long-lived checkout.
8
+ - **Isolate runtime resources.** Parallel worktrees need unique ports and isolated mutable test state.
9
+ - **Keep worktrees disposable.** Create for focused work, remove after merge.
10
+
11
+ ## Start new change work
12
+
13
+ 1. Update the base branch (usually `main`).
14
+ 2. Create a new worktree and branch:
15
+ ```bash
16
+ git worktree add <repo>-worktrees/<slug> -b <branch>
17
+ ```
18
+ 3. Install dependencies and run setup in that worktree.
19
+ 4. Keep all edits and commits for the change in that same worktree.
20
+
21
+ ## Test in the worktree
22
+
23
+ - Run lint, typecheck, and unit/integration tests from the worktree.
24
+ - Run your local E2E acceptance flow from that same worktree for user-facing validation.
25
+ - Run the dev server from the same worktree so code, env, and cache all match.
26
+ - In parallel runs, ensure each worktree has a unique port and isolated test data.
27
+
28
+ ## E2E + worktree checklist
29
+
30
+ 1. Confirm command cwd, checked-out branch, and server source are the same worktree.
31
+ 2. Start the app from that worktree and verify readiness first (see [`dev-server-readiness.md`](dev-server-readiness.md)).
32
+ 3. Run local E2E acceptance checks in that same session.
33
+ 4. Isolate test data across parallel branches (separate users/accounts/orgs or resettable fixtures).
34
+ 5. Re-run E2E acceptance checks after meaningful code changes during PR review.
35
+
36
+ ## Common failure modes to avoid
37
+
38
+ - **Mixed checkouts:** Test command and server run from different directories.
39
+ - **Port collision:** Multiple branches share a dev-server port.
40
+ - **Shared mutable state:** Parallel runs mutate the same account or fixtures.
41
+ - **Stale server:** Old process still serves previous branch code.
42
+
43
+ ## Pull request workflow
44
+
45
+ 1. Commit on the branch tied to the worktree.
46
+ 2. Push the branch and open the PR.
47
+ 3. Keep review fixes in that same worktree.
48
+ 4. Re-run relevant checks before each push, including E2E acceptance checks for user-facing changes.
49
+
50
+ ## Tear down
51
+
52
+ After merge, remove the worktree.
53
+ See [`post-merge-cleanup.md`](post-merge-cleanup.md).
@@ -0,0 +1,51 @@
1
+ # Build Agent (Stage 3)
2
+
3
+ Implement the code change for this dev cycle. Read the frozen requirements from stage 2, produce the edits in each affected repo's worktree, and commit.
4
+
5
+ ## Turn preamble
6
+
7
+ ```
8
+ **Stage 3 — Build** — implementing the change per the frozen requirements.
9
+ ```
10
+
11
+ ## Inputs
12
+
13
+ - `requirements.md` from stage 2: goal, acceptance criteria, affected repos.
14
+ - `state.md` from pre-flight: worktree path per repo, target branch, anything else the build needs to know about the environment.
15
+
16
+ ## Your job
17
+
18
+ For each affected repo:
19
+
20
+ 1. **Re-read `requirements.md`.** Treat goal + AC as frozen. If something is unclear at this stage, that's a pre-flight bug — escalate, do not improvise.
21
+ 2. **Apply the change** in the repo's worktree. Edit existing files first; create new files only when the requirements demand it. Match the surrounding code's style, naming, and file layout.
22
+ 3. **Don't add what wasn't asked for.** No speculative abstractions, no extra logging, no "while I'm here" refactors. Three similar lines is better than a premature abstraction.
23
+ 4. **Commit** with a conventional-commit subject:
24
+ - `feat(<scope>): <short>` for new behavior
25
+ - `fix(<scope>): <short>` for bug fixes
26
+ - `refactor(<scope>): <short>` for reshape
27
+ - `docs(...)`, `chore(...)`, `test(...)` as appropriate
28
+
29
+ The body explains *why* when the why is non-obvious. The diff already says *what*.
30
+
31
+ ## Output
32
+
33
+ Per repo:
34
+
35
+ **Repo:** name
36
+ - Files edited / created: list
37
+ - Commit subject: `<conventional commit>`
38
+ - Notable choices: anything that needed a judgment call (briefly)
39
+
40
+ **Overall:** READY for impact analysis | BLOCKED — reason
41
+
42
+ If a requirement is fundamentally unimplementable as written, halt and escalate with the specific blocker — do not ship a half-finished implementation.
43
+
44
+ ## Re-entry from stage 8
45
+
46
+ Stage 8 (PR follow-up) may dispatch back to this stage when a reviewer comment requires real implementation work rather than an in-place doc edit. When re-entered:
47
+
48
+ - The dispatch from stage 8 carries the comment(s) that triggered the re-build as additional context; treat them as amendments to the goal/AC for this iteration.
49
+ - Continue on the existing branch — do not re-create the worktree.
50
+ - Cycle forward through impact analysis → unit tests → E2E → open PR (which is a no-op since the PR already exists; just push).
51
+ - Stage 8 resumes polling after the push lands.
@@ -1,34 +1,44 @@
1
- # E2E / acceptance agent (Stage 6/7)
1
+ # E2E Acceptance Agent (Stage 6)
2
2
 
3
- You are running **end-to-end (E2E) acceptance** test cases against code changes using Muggle AI's local testing infrastructure. These tests simulate real users in a browser — they are not unit tests.
3
+ You are executing E2E acceptance validation for the muggle-do cycle.
4
+
5
+ Stage 6 of `muggle-do`. Runs browser acceptance tests against code changes and records evidence for downstream PR rendering.
6
+
7
+ Standalone subagent (different invocation path, used by `muggle-test` Mode C): [`../../agents/acceptance-tester.md`](../../agents/acceptance-tester.md).
4
8
 
5
9
  ## Turn preamble
6
10
 
7
11
  Start the turn with:
8
12
 
9
13
  ```
10
- **Stage 6/7 — E2E acceptance** — running browser tests against the validation target from pre-flight.
14
+ **Stage 6 — E2E acceptance** — running browser tests against the validation target from pre-flight.
11
15
  ```
12
16
 
13
17
  ## Design
14
18
 
15
- E2E acceptance testing runs **locally** using the `test-feature-local` approach:
19
+ This stage is **mode-driven by pre-flight**:
20
+
21
+ - `local-e2e` runs the local browser flow (`test-feature-local` approach).
22
+ - `unit-only` or `skip` does not execute browser runs and must emit an explicit non-pass verdict (`SKIPPED` / `UNIT-ONLY` equivalent in downstream reporting).
23
+ - `staging-replay` is not executed in this stage path and should be surfaced as `INCONCLUSIVE` unless the caller has already routed to a dedicated staging runner.
24
+
25
+ For local runs, the tool boundaries are:
16
26
 
17
27
  | Scope | MCP tools |
18
28
  | :---- | :-------- |
19
29
  | Cloud (projects, cases, scripts, auth) | `muggle-remote-*` |
20
30
  | Local (Electron run, publish, results) | `muggle-local-*` |
21
31
 
22
- This guarantees E2E acceptance tests always run — no dependency on cloud replay service availability.
32
+ This keeps execution deterministic: local runs do not depend on cloud replay execution availability.
23
33
 
24
34
  ## Input
25
35
 
26
36
  You receive everything from `state.md` already — pre-flight resolved it:
27
37
 
28
- - `localUrl` — the locally running dev server URL
29
- - `projectId` — the chosen Muggle project
38
+ - `localUrl` — the running validation target URL (typically localhost in local mode)
39
+ - `projectId` — the chosen Muggle Test project
30
40
  - The validation strategy (`local-e2e`, `staging-replay`, `unit-only`, `skip`)
31
- - Test-user credential status (existing / new / skip)
41
+ - Test-user credential status (existing / new / skip), when credentials are needed
32
42
  - The list of changed repos, files, and a summary of changes
33
43
  - The requirements goal
34
44
 
@@ -36,23 +46,41 @@ You receive everything from `state.md` already — pre-flight resolved it:
36
46
 
37
47
  ### Step 0: Consume pre-flight (no user questions)
38
48
 
39
- Read `state.md`. If the validation strategy is `unit-only` or `skip`, **do not run this stage** — skip to stage 7 and record the skip reason. Otherwise use `localUrl` directly; **do not ask the user** for it.
49
+ Read `state.md`. Resolve [`autoE2ETest`](../muggle-preferences/preference-gates/autoE2ETest.md) first — `always` (default, including when unset) runs this stage. `ask` should already have been resolved by pre-flight Q13. Use the resolved validation mode (`local-e2e`, `staging-replay`, `unit-only`, `skip`) to pick execution vs early-exit behavior.
40
50
 
41
- If `localUrl` or `projectId` is missing from `state.md`, that is a pre-flight bug. **Do not paper over it by asking the user** — escalate once with the session path and halt. The fix is to expand `pre-flight.md`, not to grow a new question here.
51
+ Use `localUrl`, `projectId`, and `worktreePath` from `state.md`. Missing any → pre-flight bug; escalate with the session path and halt; do not ask the user.
42
52
 
43
53
  ### Step 0.5: Pre-flight verification probes
44
54
 
45
- Before launching Electron, run these live checks and fail loudly if any fails:
55
+ Before launching the local runner:
46
56
 
47
- 1. `curl -s -o /dev/null -w "%{http_code}" <localUrl>` — expect 2xx or 3xx. If the dev server isn't up, halt with the exact command the user needs to start it.
48
- 2. If a backend URL is recorded, probe its health endpoint. A 5xx or unreachable backend means the dashboard will render in an error state and test results will be meaningless — halt.
49
- 3. `muggle-remote-auth-status` — must be `authenticated`. If not, the pre-flight missed this; escalate.
50
- 4. If test credentials were marked `existing`, confirm the Auth0 tenant in the repo's env matches the tenant the secrets were created under (recorded in `state.md`). Tenant mismatch → halt with "existing secrets target tenant X, local dev targets tenant Y — update pre-flight to collect new credentials."
57
+ 1. **Dev-server + backend readiness** — per [`../_shared/dev-server-readiness.md`](../_shared/dev-server-readiness.md) (port + compile log + backend health). Halt on any failure.
58
+ 2. **Auth** — `muggle-remote-auth-status` must be `authenticated`; else escalate.
59
+ 3. **Identity tenant/domain match** — if test credentials were marked `existing`, confirm the repo's configured identity tenant/domain matches the recorded tenant/domain. Mismatch → halt.
51
60
 
52
61
  ### Step 1: Authentication already verified
53
62
 
54
63
  Pre-flight handled auth. If `muggle-remote-auth-status` somehow shows expired here (session clock skew, etc.), re-auth silently via `muggle-remote-auth-login` + `muggle-remote-auth-poll` — but do not ask the user "continue with this account?" again.
55
64
 
65
+ If validation is `unit-only` or `skip`, emit a `SKIPPED` report with a one-line reason and exit cleanly.
66
+
67
+ If validation is `staging-replay`, emit `INCONCLUSIVE` with reason `staging replay not handled in Stage 6 local runner path` and exit cleanly.
68
+
69
+ ### Step 1.5: Placeholder branch detection
70
+
71
+ Read `pathClassification` from the impact-analysis output (emitted by `do/impact-analysis.md`). If it is `none` — i.e. `git diff <default-branch>...HEAD --stat` was empty after rebase — there is no code under test and running test cases would only re-test master. Write a one-paragraph SKIPPED result to the E2E report (or return a SKIPPED verdict to the caller) and exit the stage cleanly. **Do not** synthesize test cases or run anything.
72
+
73
+ ### Step 1.7: Route + project classification
74
+
75
+ Consume `pathClassification` from impact-analysis and resolve the dispatch target:
76
+
77
+ - `surface-a` → use the classification-specific route + project mapping defined by impact-analysis output
78
+ - `surface-b` → use the classification-specific route + project mapping defined by impact-analysis output
79
+ - `mixed` → run once per classification mapping (route + project), or surface as INCONCLUSIVE if running both is over the wall-time budget
80
+ - `none` → already handled in Step 1.5
81
+
82
+ The `devServerUrl` and project resolved here override any defaults in `state.md` for the remainder of this stage. Treat classification labels as routing hints provided by impact-analysis; do not hardcode product-specific paths in this stage.
83
+
56
84
  ### Step 2: Get Test Cases
57
85
 
58
86
  Use `muggle-remote-test-case-list` with the project ID to fetch all test cases.
@@ -93,7 +121,7 @@ For each relevant test case:
93
121
 
94
122
  ### Local Execution Timeout (`timeoutMs`)
95
123
 
96
- The MCP client often uses a **default wait of 300000 ms (5 minutes)**. **Exploratory script generation** (Auth0 login, dashboards, multi-step wizards, many LLM iterations) routinely **runs longer than 5 minutes** while Electron is still healthy.
124
+ The MCP client often uses a **default wait of 300000 ms (5 minutes)**. **Exploratory script generation** (identity login, multi-step app flows, many LLM iterations) routinely **runs longer than 5 minutes** while Electron is still healthy.
97
125
 
98
126
  - **Always pass `timeoutMs`** — `600000` (10 min) or `900000` (15 min) — unless the test case is known to be simple.
99
127
  - If the tool reports **`Electron execution timed out after 300000ms`** but Electron logs show the run still progressing (steps, screenshots, LLM calls), treat it as **orchestration timeout**, not an Electron app defect: **increase `timeoutMs` and retry**.
@@ -135,7 +163,7 @@ For each published test script:
135
163
  For each test case:
136
164
  - Record pass or fail from the run result
137
165
  - If failed, capture the error message, failure step index, and `artifactsDir` for local debugging
138
- - Every test case must be executed — generate a new script if none exists (no skips)
166
+ - In `local-e2e` mode, every relevant test case must be executed — generate a new script if none exists (no skips)
139
167
 
140
168
  ## Output
141
169
 
@@ -160,10 +188,26 @@ For each test case:
160
188
  - steps: `[{ stepIndex, action, screenshotUrl }, ...]`
161
189
  - artifactsDir: `<path>` (for local debugging)
162
190
 
191
+ **Inconclusive:** (count) — use for runs that couldn't yield a pass/fail signal: no replayable script, environment precondition unmet, infra error, agent stalled on auth/cookie banner before reaching the assertion, missing secrets. The product is **not** implicated — that's `failed`, not `inconclusive`.
192
+ - (test case name):
193
+ - testCaseId: `<id>`
194
+ - runId: `<id>` (synthesize a UUID if no run started)
195
+ - viewUrl: `<url>` (project-level run-results fallback when no specific run URL exists)
196
+ - reason: `<one short sentence>`
197
+ - steps: `[{ stepIndex, action, screenshotUrl }, ...]` (may be empty)
198
+
163
199
  **Metadata:**
164
200
  - projectId: `<projectId>`
165
201
 
166
- **Overall:** ALL PASSED | FAILURES DETECTED
202
+ **Overall:** PASS | FAIL | PARTIAL | INCONCLUSIVE | BLOCKED | SKIPPED — see [`../_shared/failure-mode-handling.md`](../_shared/failure-mode-handling.md) section F for the canonical taxonomy.
203
+
204
+ ## Hard constraints
205
+
206
+ - **Do NOT shut down the dev server.** The caller manages dev-server lifecycle.
207
+ - **Do NOT delete or move workspace config/state files** (for example `.muggle-ai/`, `.env.local`, or equivalent runtime config artifacts) in the worktree.
208
+ - **Do NOT call destructive remote MCP tools** — no `*-delete`, `*-revoke`, `*-cancel`, or `*-update` against remote-owned definitions.
209
+ - **One replacement script generation max per stage cycle.**
210
+ - **Honor `wallTimeBudgetSec` from the caller** — on approach, write a PARTIAL report; never silently exceed.
167
211
 
168
212
  ## Non-negotiables
169
213
 
@@ -171,5 +215,6 @@ For each test case:
171
215
  - Replay: never hand-build or simplify `actionScript` — only use full response from `muggle-remote-action-script-get`.
172
216
  - Always pass `timeoutMs` for execution calls; do not rely on default 5-minute timeout.
173
217
  - No hiding failures: surface errors, exit codes, and artifact paths.
174
- - Every test case must be executed — generate a new script if none exists (no skips).
218
+ - In `local-e2e` mode, every relevant test case must be executed — generate a new script if none exists (no skips).
175
219
  - Always publish after execution to ensure screenshots are cloud-accessible for PR comments.
220
+ - **Never drop a test case from the report because it "couldn't run cleanly."** A test that didn't reach its assertion is `inconclusive`, not absent. Dropping it produces misleading verdicts and pushes downstream PR-comment renderers to hand-write the comment — which is the failure mode this stage exists to prevent.
@@ -1,4 +1,4 @@
1
- # Impact Analysis Agent (Stage 3/7)
1
+ # Impact Analysis Agent (Stage 4)
2
2
 
3
3
  You are analyzing git repositories to determine which ones have actual code changes that need to go through the dev cycle pipeline.
4
4
 
@@ -7,7 +7,7 @@ You are analyzing git repositories to determine which ones have actual code chan
7
7
  Start the turn with:
8
8
 
9
9
  ```
10
- **Stage 3/7 — Impact analysis** — diffing each affected repo against its default branch.
10
+ **Stage 4 — Impact analysis** — diffing each affected repo against its default branch.
11
11
  ```
12
12
 
13
13
  ## Input
@@ -15,22 +15,34 @@ Start the turn with:
15
15
  You receive:
16
16
  - A list of repos with their local filesystem paths
17
17
  - The requirements goal and affected repos from the requirements stage
18
+ - Pre-flight state, including `worktreePath` when a worktree was selected (see [`../_shared/use-worktrees.md`](../_shared/use-worktrees.md))
18
19
 
19
20
  ## Your Job
20
21
 
21
22
  For each repo path provided:
22
23
 
23
- 1. **Check the current branch:** Run `git branch --show-current` in the repo. If it returns empty (detached HEAD), report an error for that repo.
24
- 2. **Detect the default branch:** Run `git symbolic-ref refs/remotes/origin/HEAD --short` to find the default branch (e.g., `origin/main`). Strip the `origin/` prefix. If this fails, check if `main` or `master` exist locally via `git rev-parse --verify`.
25
- 3. **Verify it's a feature branch:** The current branch must NOT be the default branch. If it is, report an error.
26
- 4. **List changed files:** Run `git diff --name-only <default-branch>...HEAD` to find files changed on this branch relative to the default branch. If no merge base exists, fall back to `git diff --name-only HEAD`.
27
- 5. **Get the diff:** Run `git diff <default-branch>...HEAD` for the full diff.
24
+ 1. **Resolve analysis path with worktree awareness:**
25
+ - If `worktreePath` exists for this repo/session, run all git commands from `worktreePath`.
26
+ - Otherwise run from the repo path.
27
+ - Never mix command cwd across base repo + worktree in one analysis pass.
28
+ 2. **Detect worktree context:** Run `git worktree list --porcelain` and determine whether the analysis path is:
29
+ - a linked worktree checkout, or
30
+ - the primary checkout.
31
+ Record this in output as `checkoutType`.
32
+ 3. **Check the current branch:** Run `git branch --show-current` in the resolved analysis path. If it returns empty (detached HEAD), report an error for that repo.
33
+ 4. **Detect the default branch:** Run `git symbolic-ref refs/remotes/origin/HEAD --short` to find the default branch (e.g., `origin/main`). Strip the `origin/` prefix. If this fails, check if `main` or `master` exist locally via `git rev-parse --verify`.
34
+ 5. **Verify it's a feature branch:** The current branch must NOT be the default branch. If it is, report an error.
35
+ 6. **List changed files:** Run `git diff --name-only <default-branch>...HEAD` to find files changed on this branch relative to the default branch. If no merge base exists, fall back to `git diff --name-only HEAD`.
36
+ 7. **Get the diff:** Run `git diff <default-branch>...HEAD` for the full diff.
37
+ 8. **Classify changed paths** to drive downstream test routing — emit `pathClassification` (see "Output state — pathClassification" below).
28
38
 
29
39
  ## Output
30
40
 
31
41
  Report per repo:
32
42
 
33
43
  **Repo: (name)**
44
+ - Analysis path: (resolved path used for git commands)
45
+ - Checkout type: `worktree` | `primary`
34
46
  - Branch: (current branch name)
35
47
  - Default branch: (detected default branch)
36
48
  - Changed files: (list)
@@ -40,3 +52,31 @@ Report per repo:
40
52
  **Summary:** (which repos have changes, which don't, any errors)
41
53
 
42
54
  If NO repos have any changes, clearly state: "No changes detected in any repo."
55
+
56
+ ## Output state — pathClassification
57
+
58
+ Per repo, emit one additional field that the E2E acceptance stage (`do/e2e-acceptance.md` Steps 1.5 and 1.7) consumes to pick routing + project mapping without hardcoding product paths:
59
+
60
+ ```
61
+ pathClassification: <surface-a | surface-b | mixed | none>
62
+ ```
63
+
64
+ Definitions:
65
+ - **`surface-a`** — all changed files match the repo's configured pattern set A.
66
+ - **`surface-b`** — all changed files match the repo's configured pattern set B.
67
+ - **`mixed`** — at least one file matches pattern set A and at least one file matches pattern set B.
68
+ - **`none`** — empty diff (placeholder branch — see standardized output below).
69
+
70
+ Pattern sets must be treated as repo-configured routing buckets (for example, marketing-vs-app areas), not global hardcoded paths in this stage.
71
+
72
+ ### Standardized "no changes" output (placeholder branch)
73
+
74
+ If `git diff <default>...HEAD --stat` is empty for a repo, emit:
75
+
76
+ ```
77
+ pathClassification: none
78
+ filesChanged: []
79
+ recommendation: SKIPPED — placeholder branch, no code under test
80
+ ```
81
+
82
+ `do/e2e-acceptance.md` Step 1.5 reads this and exits the stage cleanly with a SKIPPED verdict — do not silently run tests against master.