@muggleai/works 4.10.1 → 4.11.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 (40) hide show
  1. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  2. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  3. package/dist/plugin/skills/_shared/pr-followup-helpers.md +151 -0
  4. package/dist/plugin/skills/do/build.md +51 -0
  5. package/dist/plugin/skills/do/e2e-acceptance.md +2 -2
  6. package/dist/plugin/skills/do/impact-analysis.md +2 -2
  7. package/dist/plugin/skills/do/open-prs.md +67 -78
  8. package/dist/plugin/skills/do/pre-flight.md +3 -3
  9. package/dist/plugin/skills/do/requirements.md +2 -2
  10. package/dist/plugin/skills/do/unit-tests.md +2 -2
  11. package/dist/plugin/skills/muggle-do/SKILL.md +34 -77
  12. package/dist/plugin/skills/muggle-feedback/SKILL.md +2 -1
  13. package/dist/plugin/skills/muggle-feedback/ops/submit.md +16 -3
  14. package/dist/plugin/skills/muggle-pr-followup/SKILL.md +59 -0
  15. package/dist/plugin/skills/muggle-pr-followup/contract.md +190 -0
  16. package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +14 -0
  17. package/dist/release-manifest.json +4 -4
  18. package/package.json +6 -6
  19. package/plugin/.claude-plugin/plugin.json +1 -1
  20. package/plugin/.cursor-plugin/plugin.json +1 -1
  21. package/plugin/skills/_shared/pr-followup-helpers.md +151 -0
  22. package/plugin/skills/do/build.md +51 -0
  23. package/plugin/skills/do/e2e-acceptance.md +2 -2
  24. package/plugin/skills/do/impact-analysis.md +2 -2
  25. package/plugin/skills/do/open-prs.md +67 -78
  26. package/plugin/skills/do/pre-flight.md +3 -3
  27. package/plugin/skills/do/requirements.md +2 -2
  28. package/plugin/skills/do/unit-tests.md +2 -2
  29. package/plugin/skills/muggle-do/SKILL.md +34 -77
  30. package/plugin/skills/muggle-feedback/SKILL.md +2 -1
  31. package/plugin/skills/muggle-feedback/ops/submit.md +16 -3
  32. package/plugin/skills/muggle-pr-followup/SKILL.md +59 -0
  33. package/plugin/skills/muggle-pr-followup/contract.md +190 -0
  34. package/plugin/skills/muggle-test-feature-local/SKILL.md +14 -0
  35. package/dist/plugin/skills/do/pr-followup.md +0 -225
  36. package/dist/plugin/skills/do/validate-code.md +0 -38
  37. package/dist/plugin/skills/muggle-do-pr-followup/SKILL.md +0 -37
  38. package/plugin/skills/do/pr-followup.md +0 -225
  39. package/plugin/skills/do/validate-code.md +0 -38
  40. package/plugin/skills/muggle-do-pr-followup/SKILL.md +0 -37
@@ -8,108 +8,65 @@ disable-model-invocation: true
8
8
 
9
9
  > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle-do"`.
10
10
 
11
- Muggle Test Do runs a battle-tested autonomous dev cycle: **pre-flight → requirements → impact analysis → validate code → unit tests → E2E acceptance → open PR**.
11
+ Runs an autonomous dev cycle from requirements to PR. **Fire and review:** the user answers one pre-flight questionnaire, then walks away.
12
12
 
13
- The design goal is **fire and review**: the user answers one consolidated pre-flight questionnaire, then walks away. Every subsequent stage runs unattended until completion or a genuine blocker.
14
-
15
- For maintenance tasks, use the dedicated skills:
13
+ For maintenance, use the dedicated skills:
16
14
 
17
15
  - `/muggle:muggle-status`
18
16
  - `/muggle:muggle-repair`
19
17
  - `/muggle:muggle-upgrade`
20
18
 
21
- ## Preferences
22
-
23
- Gates run per [`preference-gates/README.md`](../muggle-preferences/preference-gates/README.md).
24
-
25
- | Preference | Stage | Decision it gates |
26
- |------------|-------|-------------------|
27
- | `autoUseWorktree` | 1 (pre-flight) | Create a worktree (see [`_shared/use-worktrees.md`](../_shared/use-worktrees.md)) |
28
- | `autoE2ETest` | 6 (e2e-acceptance) | Run E2E every cycle (default `always`), or fold the question into pre-flight |
29
- | `autoRebase` | 6 (e2e-acceptance) | Rebase onto `origin/<default>` (see [`_shared/rebase-before-e2e.md`](../_shared/rebase-before-e2e.md)) |
30
- | `autoCreatePR` | 7 (open-prs) | Push the branch and open the PR (see [`do/open-prs.md`](../do/open-prs.md)) |
31
- | `autoCleanup` | 7 (post-merge) | Run cleanup sequence (see [`_shared/post-merge-cleanup.md`](../_shared/post-merge-cleanup.md)) |
32
-
33
- ## Input routing
34
-
35
- Treat `$ARGUMENTS` as the user command:
36
-
37
- - Empty / `help` / `menu` / `?` → show menu and session selector.
38
- - Anything else → infer intent:
39
- - **Task automation** (user wants to perform an action on a website — post something, fill a form, click through a flow) → invoke `muggle:muggle-do-task` skill with the full prompt as arguments.
40
- - **Feature development** (user wants to build, implement, fix, or refactor code) → treat as a new task description and start/resume a dev-cycle session.
41
-
42
- When in doubt, ask one question: "Do you want me to run this as a browser automation task, or implement it as a code change?"
43
-
44
- ## The seven stages
19
+ ## The pipeline
45
20
 
46
21
  | # | Stage | File | User-facing? |
47
22
  | :- | :---- | :--- | :----------- |
48
- | 1 | Pre-flight | [../do/pre-flight.md](../do/pre-flight.md) | **Yes — single consolidated turn** |
23
+ | 1 | Pre-flight | [../do/pre-flight.md](../do/pre-flight.md) | **Yes — one consolidated turn** |
49
24
  | 2 | Requirements | [../do/requirements.md](../do/requirements.md) | No |
50
- | 3 | Impact analysis | [../do/impact-analysis.md](../do/impact-analysis.md) | No |
51
- | 4 | Validate code | [../do/validate-code.md](../do/validate-code.md) | No |
25
+ | 3 | Build | [../do/build.md](../do/build.md) | No |
26
+ | 4 | Impact analysis | [../do/impact-analysis.md](../do/impact-analysis.md) | No |
52
27
  | 5 | Unit tests | [../do/unit-tests.md](../do/unit-tests.md) | No |
53
28
  | 6 | E2E acceptance | [../do/e2e-acceptance.md](../do/e2e-acceptance.md) | No |
54
29
  | 7 | Open PR | [../do/open-prs.md](../do/open-prs.md) | No |
30
+ | 8 | PR follow-up | [../muggle-pr-followup/SKILL.md](../muggle-pr-followup/SKILL.md) (generic) — invoked with muggle-do's cycle declaration | **Yes — only on ambiguous reviews** |
55
31
 
56
- **Stage 1 (pre-flight) is the ONLY stage that talks to the user.** Stages 2–7 run silently to completion. If a later stage hits a genuine blocker that the pre-flight didn't cover, escalate with a single terminal message — do not open a second round of questions.
57
-
58
- ## Front-loading (stage 1 non-negotiable)
32
+ Stage 1 talks to the user once. Stages 2–7 run silently. Stage 7 dispatches **one Stage-8 follow-up loop per PR** it opens (not one per session); each loop polls its own PR independently for new submitted reviews. When a review lands, the loop cycles back through Stage 3 (Build) → 4 → 5 → 6 → fresh visual walkthrough → push to the existing branch, then resumes polling for the next round. Each loop may escalate once on an ambiguous review.
59
33
 
60
- All ambiguity — task scope, repo selection, validation strategy, localhost URL, backend health, Muggle Test project, test-user credentials, branch name, PR target — is resolved in a **single** pre-flight turn. See `pre-flight.md` for the exact questionnaire.
34
+ **Each stage's file is the single source of truth for that stage** — definition, contract, inputs/outputs, preference gates, output format. Read each stage file directly for its rules. This file is only the orchestration spine.
61
35
 
62
- **Red-flag behaviors (do not do):**
63
-
64
- - Asking a clarifying question mid-cycle because "I didn't think of that at pre-flight."
65
- - Starting a dev server mid-cycle and discovering the port is wrong.
66
- - Reaching the E2E stage before knowing how the user wants it validated.
67
- - Asking the user to "pick one" across multiple turns instead of one turn.
68
-
69
- If any of these happen, the pre-flight was incomplete — treat it as a skill bug, not a user bug, and expand `pre-flight.md` to cover the missed case after the run.
70
-
71
- ## Session model
36
+ ## Preferences
72
37
 
73
- Every run writes to `.muggle-do/sessions/<slug>/`:
38
+ | Preference | Stage | Decision it gates |
39
+ |------------|-------|-------------------|
40
+ | `autoE2ETest` | 6 (E2E acceptance) | Run E2E every cycle (default `always`), or fold the question into pre-flight |
74
41
 
75
- - `state.md` — one-screen live status: current stage (N/7), last update timestamp, pre-flight answers verbatim, any blockers.
76
- - `iterations/<NNN>.md` — append-only log of stage transitions for iteration NNN: what ran, what was decided, what artifacts were produced.
77
- - `requirements.md` — frozen output of stage 2.
78
- - `result.md` — final summary written by stage 7 (PR URLs, E2E outcome, open issues).
42
+ Other gates that fire during this cycle (`autoUseWorktree`, `autoRebase`, `autoCreatePR`, `autoCleanup`) are owned by the per-stage files; see each stage for its contract.
79
43
 
80
- **On every stage transition, you MUST:**
44
+ ## Input routing
81
45
 
82
- 1. Append a dated entry to the active `iterations/<NNN>.md`: `### Stage N/7 — <name> (<timestamp>)` followed by the stage's output.
83
- 2. Rewrite `state.md` to reflect the new current stage and any relevant counters.
46
+ Treat `$ARGUMENTS` as the user command:
84
47
 
85
- If these files don't exist, create them — missing session files means the user lost visibility into the cycle, which is the exact failure mode this skill exists to prevent.
48
+ - Empty / `help` / `menu` / `?` → show menu and session selector.
49
+ - Anything else → infer intent:
50
+ - **Task automation** (perform an action on a website — post something, fill a form, click through a flow) → invoke `muggle:muggle-do-task` with the full prompt.
51
+ - **Feature development** (build / fix / refactor code) → start or resume a dev-cycle session.
86
52
 
87
- ## Turn preamble
53
+ When in doubt, ask one question: "Browser automation task, or code change?"
88
54
 
89
- Each stage turn MUST begin with one line in this form before any other output:
55
+ ## Session model
90
56
 
91
- ```
92
- **Stage N/7 — <stage name>** — <one-line intent>
93
- ```
57
+ Every run writes to `.muggle-do/sessions/<slug>/`. Stages own the files they produce:
94
58
 
95
- This is how the user can tell, at a glance, what phase the cycle is in without parsing a long response.
59
+ | File | Owned by | Purpose |
60
+ | :--- | :------- | :------ |
61
+ | `state.md` | Stage 1 (rewritten by every transition) | Current stage, pre-flight answers, blockers |
62
+ | `iterations/<NNN>.md` | Every stage | Append-only stage transition log |
63
+ | `requirements.md` | Stage 2 | Frozen requirements |
64
+ | `prs.json`, `last_seen.json`, `followup.log` | Stage 8 | See [`pr-followup.md`](../do/pr-followup.md) |
65
+ | `result.md` | Stage 7 (seeded), Stage 8 (finalized) | Per-PR final state |
96
66
 
97
67
  ## Guardrails
98
68
 
99
- - **No mid-cycle user questions.** Anything not covered by pre-flight is a skill bug; escalate once, do not loop.
100
- - **Do not skip unit tests before E2E acceptance tests.**
101
- - **Do not skip E2E acceptance tests due to missing scripts** — generate when needed.
102
- - **Do not hand-write the E2E block of the PR body.** The `open-prs.md` stage MUST invoke `muggle-pr-visual-walkthrough` Mode B to render the screenshots-and-steps section. Hand-writing it loses the dashboard links the user relies on for review.
103
- - **If the same stage fails 3 times in a row, escalate with details.**
104
- - **If total iterations reach 3 and E2E acceptance tests still fail**, continue to PR creation with `[E2E FAILING]` in the title; the visual walkthrough section makes the failures reviewable.
105
-
106
- ## Completion contract
107
-
108
- When stage 7 finishes, the final message to the user contains at minimum:
109
-
110
- - PR URL(s)
111
- - E2E status (passing / `[E2E FAILING]`)
112
- - Link to the run dashboard for each test case (via the walkthrough skill output)
113
- - Path to `result.md` for full details
114
-
115
- No other content. The user already read the walkthrough in the PR body — do not re-summarize it here.
69
+ - **Stage 1 is the only forward-pipeline user-facing stage.** Stages 2–7 don't ask questions mid-cycle. If a stage hits a blocker pre-flight didn't cover, treat as a pre-flight bug — escalate once and expand `pre-flight.md` after the run.
70
+ - **Stage 8 may escalate** once per ambiguous review comment, and may dispatch back to Stage 3 when needed — see [`pr-followup.md`](../do/pr-followup.md).
71
+ - **If the same stage fails 3 times in a row, escalate** with details.
72
+ - **If 3 cycle iterations reach E2E with failures**, ship with `[E2E FAILING]` per [`open-prs.md`](../do/open-prs.md). The walkthrough section keeps the failures reviewable.
@@ -32,7 +32,8 @@ If intent is ambiguous, use `AskUserQuestion` once with options **Submit / List
32
32
 
33
33
  ## Non-negotiables (all ops)
34
34
 
35
- - Use `AskUserQuestion` for every selection (project, test case, run, target type, confirm). Never ask the user to "reply with a number" in plain text.
35
+ - Use `AskUserQuestion` for every selection (project, test case, run, target type, which step(s), confirm). Step selection must be a clickable picker built from the rendered steps (see [`ops/submit.md`](ops/submit.md) §3b) — never ask the user to type a number.
36
+ - Always render the run's steps and summary (§2) **before** collecting feedback — users can only point at what they can see.
36
37
  - Convert step numbers between 1-based (rendered to user) and 0-based (wire format) at the boundary. Never expose 0-based indices to the user.
37
38
  - One MCP submit/delete call per feedback piece — never batch into a single call.
38
39
  - Surface the `feedbackAnalysisWorkflowRuntimeId` returned by submit so the user knows regeneration is running. Do not poll it from this skill.
@@ -55,6 +55,8 @@ Print:
55
55
 
56
56
  ## 3. Collect feedback (batch)
57
57
 
58
+ ### 3a. Pick the scope (entity type)
59
+
58
60
  Use `AskUserQuestion` to scope which targets:
59
61
 
60
62
  > "Where is the problem?"
@@ -63,10 +65,21 @@ Use `AskUserQuestion` to scope which targets:
63
65
  > - The whole script's outcome / summary
64
66
  > - Multiple steps **and** the whole outcome
65
67
 
66
- For each chosen target, prompt for the feedback paragraph in plain text. Keep prompts specific:
68
+ ### 3b. Pick the step(s) — clickable picker
69
+
70
+ When 3a includes any step-level scope, present the rendered steps as a **clickable `AskUserQuestion` picker** — never as a typed number.
71
+
72
+ - **Option format** — Label: `Step <n>: <action label> on <element text or id>` (≤80 chars). Description: the step's `briefExplanation` (≤120 chars).
73
+ - **Multi-select** — `multiSelect: true` for "Multiple steps" or "Multiple steps and the whole outcome"; `multiSelect: false` for "One specific step".
74
+ - **Long scripts (>10 steps)** — rank by keyword overlap with the user's prompt (label or briefExplanation); fall back to the first 10 if no match. Append **"Show all steps"** as a final option that re-asks with the full list — never silently truncate.
75
+
76
+ For each selected step, prompt in plain text:
77
+
78
+ > "What should step `<n>` have done instead?"
79
+
80
+ For the whole-script scope, prompt:
67
81
 
68
- - For a step: "What should step `<n>` have done instead?"
69
- - For the whole script: "What's wrong with the overall outcome?"
82
+ > "What's wrong with the overall outcome?"
70
83
 
71
84
  Validate each paragraph is non-empty (re-prompt if blank). Build an in-memory list of feedback pieces:
72
85
 
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: muggle-pr-followup
3
+ description: Generic per-PR follow-up loop. One polling tick per dispatch. Watches one PR for new submitted reviews; when an actionable review lands, invokes the caller's implementation cycle (build/test/walkthrough/push handler the caller declares), then resumes polling. Use as `/loop 1m /muggle:muggle-pr-followup <session-slug> <pr-number>`. Caller-agnostic — `muggle-do` is the first caller but not the last.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Muggle PR Follow-up
8
+
9
+ > Telemetry first step: see [`_shared/telemetry-emit.md`](../_shared/telemetry-emit.md). Use `skillName: "muggle-pr-followup"`.
10
+
11
+ A generic loop that babysits one open PR until it's merged or closed. Polls for submitted reviews; on an actionable review, dispatches the caller's implementation cycle to re-build, re-test, refresh the walkthrough, and push.
12
+
13
+ **Per-PR isolation.** One dispatch per PR, not per session. Multi-PR work runs N independent loops.
14
+
15
+ ## Input
16
+
17
+ `$ARGUMENTS = <session-slug> <pr-number>`. The session-slug is the directory basename under `.muggle-<caller>/sessions/` (e.g. `.muggle-do/sessions/`) that this loop reads its state from. The pr-number identifies which PR in that session's manifest this loop watches.
18
+
19
+ - Empty / `help` / `?` → list active `(slug, pr-number)` pairs across known callers, exit.
20
+ - One argument → ambiguous; list PRs under that slug, exit.
21
+ - Two arguments → resolve and run one tick.
22
+
23
+ ## Contract
24
+
25
+ The per-tick contract — termination check, allow-list resolution, review polling, classify, cycle dispatch, escalation, telemetry — lives in [`contract.md`](contract.md). Read it before driving a tick.
26
+
27
+ ## Caller-supplied implementation cycle
28
+
29
+ The skill itself is caller-agnostic. When an actionable review lands, it invokes the **implementation cycle** declared by the caller in the session's `cycle.json`:
30
+
31
+ ```json
32
+ {
33
+ "cycleName": "muggle-do dev cycle",
34
+ "steps": [
35
+ { "stage": 3, "file": "../do/build.md" },
36
+ { "stage": 4, "file": "../do/impact-analysis.md" },
37
+ { "stage": 5, "file": "../do/unit-tests.md" },
38
+ { "stage": 6, "file": "../do/e2e-acceptance.md" },
39
+ { "name": "post-walkthrough", "skill": "muggle-pr-visual-walkthrough", "mode": "A" }
40
+ ],
41
+ "pushHandler": "git push origin <branch>"
42
+ }
43
+ ```
44
+
45
+ The cycle's job: read the amended `requirements.md`, run each declared step, push to the existing branch. The cycle returns one of `pushed | escalated | failed`. The skill doesn't care what's inside the steps — it just iterates them, captures the outcome, and writes a reply summary referencing the new SHA.
46
+
47
+ Callers without a `cycle.json` are rejected with `no cycle declared — caller must seed cycle.json at dispatch time`.
48
+
49
+ ## Subagent dispatch (optional)
50
+
51
+ A caller may declare `"useSubagent": true` in `cycle.json`. When set, the implementation cycle runs as a separate Claude subagent rather than inline in the loop's tick — gives stronger isolation per PR but adds overhead per cycle. Default is inline (which is itself isolated per-tick via `/loop`).
52
+
53
+ ## Design adjustment escalation
54
+
55
+ When the implementation cycle reports back that the review requires not just code change but a **design adjustment** beyond what the current requirements support (e.g. the build stage discovers the requested change conflicts with a load-bearing assumption), the cycle returns `failed: design-adjustment`. The loop treats this like an ambiguous escalation but with a different terminal message that points at the design conflict and asks the user to decide.
56
+
57
+ ## Why a separate skill (and not e.g. inside the caller's own skill folder)
58
+
59
+ `/loop` dispatches via slash command; slash commands resolve to top-level skills under `plugin/skills/`. A per-tick loop driven by `/loop` therefore has to live as a top-level skill. Putting the loop's content directly inside a caller-specific folder would make `/loop`-dispatch impossible (or fragile via shell-only entry points). Keeping the loop generic and caller-agnostic is what lets `/loop` dispatch into it cleanly.
@@ -0,0 +1,190 @@
1
+ # PR follow-up per-tick contract
2
+
3
+ Caller-agnostic per-tick contract for the [muggle-pr-followup](SKILL.md) skill. One tick = one polling iteration scoped to one PR.
4
+
5
+ ## Turn preamble
6
+
7
+ ```
8
+ **PR follow-up** — polling <repo>#<pr-number>, tick #<K>.
9
+ ```
10
+
11
+ Resolve `<K>` from `idle_tick_count + cycles_completed` in this PR's state slot.
12
+
13
+ ## When this contract may break the caller's "no questions" rule
14
+
15
+ Most callers' forward pipelines never ask the user mid-cycle. This loop, however, may emit a single escalation message when a submitted review is ambiguous (see [classify](#step-6-classify-the-review) below). By the time the loop is polling, the user has walked away from the forward pipeline; forcing a guess on an ambiguous review is worse than pausing.
16
+
17
+ Escalation is the **only** user-facing path. Otherwise the cycle runs silently end to end.
18
+
19
+ ## Inputs
20
+
21
+ Read these from `.muggle-<caller>/sessions/<slug>/` (the caller's session dir):
22
+
23
+ - `state.md` — session metadata (for context when classifying reviews).
24
+ - `prs.json` — list of `{repo, number, url, head_sha, state, escalated?, cycling?}`. This loop touches only the entry whose `number` matches the dispatched PR number.
25
+ - `last_seen.json` — keyed by `"<owner>/<repo>#<n>"`. For this PR: `{reviewId, last_pushed_sha, idle_tick_count, cycles_completed, escalated_review_ids[]}`.
26
+ - `cycle.json` — caller's declared implementation cycle (see [SKILL.md](SKILL.md#caller-supplied-implementation-cycle)).
27
+
28
+ If any of these don't exist or the PR isn't in `prs.json`, the tick is a no-op — log an error to `followup.log` and exit.
29
+
30
+ ## Per-tick contract
31
+
32
+ ### Step 1: Refresh this PR's state
33
+
34
+ ```bash
35
+ gh pr view <number> --repo <repo> --json state,mergedAt,closedAt,headRefOid
36
+ ```
37
+
38
+ If `state` is `MERGED` or `CLOSED`, mark this entry terminal in `prs.json`. Update `head_sha` if it changed.
39
+
40
+ ### Step 2: Termination check
41
+
42
+ If this PR is terminal: write a per-PR section into `result.md` (URL, final state, `cycles_completed`, count escalated, final SHA), emit final telemetry, **do not schedule another tick**. Other PRs in the session have their own loops; they terminate independently.
43
+
44
+ ### Step 3: Resolve the reviewer allow-list (every tick)
45
+
46
+ ```bash
47
+ gh pr view <number> --repo <repo> --json reviewRequests,author
48
+ ```
49
+
50
+ Add requested reviewers. Add CODEOWNERS by parsing `.github/CODEOWNERS` (or `CODEOWNERS` / `docs/CODEOWNERS`) from the PR's head branch. Remove the PR author and any bot accounts (logins ending in `[bot]`, plus the standard list: `dependabot`, `github-actions`, `renovate`, `mergify`).
51
+
52
+ ### Step 4: Pull new submitted reviews
53
+
54
+ ```bash
55
+ gh api repos/<owner>/<repo>/pulls/<number>/reviews --paginate
56
+ ```
57
+
58
+ Filter to reviews where:
59
+
60
+ - `submitted_at` is non-null (skip drafts — `PENDING` reviews are still being composed).
61
+ - `id > last_seen.reviewId`.
62
+ - `user.login` is in the allow-list.
63
+ - `id` is not in `escalated_review_ids`.
64
+ - `state` is `CHANGES_REQUESTED` or `COMMENTED`, OR `APPROVED` with at least one line comment or a non-empty body.
65
+
66
+ ### Step 5: Pick the oldest new review
67
+
68
+ If no new review past the cursor: increment `idle_tick_count`, append a heartbeat line to `followup.log`, exit. Next tick fires in 1 min via `/loop`.
69
+
70
+ If one or more: take the oldest by `submitted_at`. Fetch its associated line comments (`gh api repos/<owner>/<repo>/pulls/<n>/comments` filtered by `pull_request_review_id`). Reset `idle_tick_count` to 0.
71
+
72
+ **At most one review per tick.** If two reviews land between ticks, the second waits.
73
+
74
+ ### Step 6: Classify the review
75
+
76
+ Apply the classify rule in [`../_shared/pr-followup-helpers.md`](../_shared/pr-followup-helpers.md). The rule applies to the **review as a unit**. Two outcomes:
77
+
78
+ - **Actionable** → continue to Step 7.
79
+ - **Ambiguous** → continue to Step 8.
80
+
81
+ ### Step 7: Dispatch the implementation cycle
82
+
83
+ When the review is actionable:
84
+
85
+ 1. **Pause polling** for this PR (set `cycling: true` on this PR's entry in `prs.json`).
86
+ 2. **Amend `requirements.md`** in the session dir with a new `## Amendment — review <review_id> by <login> (<timestamp>)` section pasting the review body and each comment (with `<file>:<line>` context).
87
+ 3. **Invoke the implementation cycle** declared in the caller's `cycle.json`. Iterate the `steps[]` in order. Each step is either a markdown file to follow, a skill to invoke, or a shell command (per the `cycle.json` schema in SKILL.md). When a step fails, the cycle returns `failed: <step-name>`; the loop escalates per Step 8 with the failure as the reason.
88
+ 4. **Push** via `cycle.json`'s `pushHandler`. Set `last_seen.last_pushed_sha` to the new HEAD.
89
+ 5. **Reply** per [helpers § Reply routing](../_shared/pr-followup-helpers.md#reply-routing) and [§ Classify](../_shared/pr-followup-helpers.md#classify) (reply shape). For each line comment in the review, derive `<attribution>` from `git diff <last_pushed_sha>..HEAD -- <comment.path>` near `comment.line` ±5 (fall back to `addressed indirectly — see walkthrough` if empty). `<status>` = `ran clean` or `had <N> failures, see walkthrough`. If the review is body-only (no line comments), post the top-level fallback shape; if both body and line comments, threaded replies cover it — no top-level.
90
+ 6. **Resume polling**: clear `cycling: true`, increment `cycles_completed`, advance `last_seen.reviewId` past this review.
91
+ 7. Emit per-cycle telemetry.
92
+
93
+ If the cycle returns `failed: design-adjustment` (the cycle discovered the review can't be implemented without rethinking the design itself, not just the code), escalate per Step 8 with a `design-adjustment` reason — the terminal message asks the user to confirm the design intent before retrying.
94
+
95
+ ### Step 8: Escalate
96
+
97
+ When the review is ambiguous, or the cycle failed:
98
+
99
+ 1. Add the review id to `last_seen.escalated_review_ids`.
100
+ 2. Append a `followup.log` entry describing the review and the reason.
101
+ 3. Pause this PR's loop by writing `escalated: true` against this PR's entry in `prs.json`.
102
+ 4. End the turn with a **single terminal message** to the user:
103
+
104
+ ```
105
+ **PR follow-up escalation — <repo>#<number> — review <review_id>**
106
+
107
+ <reviewer-login> submitted a review I can't act on coherently:
108
+
109
+ > <quoted review body, or "(no body)" if empty>
110
+
111
+ Comments:
112
+ - <file>:<line> — <quoted comment body>
113
+
114
+ [For ambiguous]
115
+ Best two interpretations:
116
+ 1. <one-line interpretation A>
117
+ 2. <one-line interpretation B>
118
+
119
+ [For cycle failure]
120
+ The implementation cycle failed at <step-name>: <reason>.
121
+
122
+ Reply on the review yourself, leave a follow-up comment, or tell me which way to go.
123
+ ```
124
+
125
+ The user clears the escalation by replying on GitHub (next tick sees a new submitted review past the cursor) or by giving a directive in this terminal session.
126
+
127
+ ### Step 9: Emit tick-summary telemetry and exit
128
+
129
+ Emit one tick event per `muggle-local-telemetry-skill-emit`. Exit the turn.
130
+
131
+ ## Reply routing
132
+
133
+ - **Threaded reply per line comment** (default): `POST /repos/{owner}/{repo}/pulls/{n}/comments/{comment_id}/replies`. Use for every line comment in the review so each thread can be resolved in GitHub's UI.
134
+ - **Top-level summary on a body-only review** (fallback): `gh pr comment <number> --body "..."` referencing the review id and the new SHA. Used only when the review has body content and zero line comments — GitHub has no "reply to a review body" endpoint.
135
+ - **Never post the same reply twice** — `last_seen.reviewId` is the only re-entry guard.
136
+ - **Never post a top-level summary alongside threaded replies** — duplication pollutes the Conversation tab.
137
+
138
+ ## Telemetry
139
+
140
+ **Per-cycle** (one event per actionable review handled):
141
+
142
+ ```json
143
+ {
144
+ "skill": "muggle-pr-followup",
145
+ "event": "cycle",
146
+ "caller": "<caller>",
147
+ "session_slug": "<slug>",
148
+ "repo": "<repo>",
149
+ "pr_number": <n>,
150
+ "review_id": <id>,
151
+ "outcome": "pushed|escalated|failed:<step>",
152
+ "comment_count": <count>,
153
+ "head_sha_before": "<sha>",
154
+ "head_sha_after": "<sha-or-null>"
155
+ }
156
+ ```
157
+
158
+ **Per-tick summary** (always one, even idle):
159
+
160
+ ```json
161
+ {
162
+ "skill": "muggle-pr-followup",
163
+ "event": "tick",
164
+ "session_slug": "<slug>",
165
+ "repo": "<repo>",
166
+ "pr_number": <n>,
167
+ "reviews_seen": <count>,
168
+ "review_picked": true|false,
169
+ "cycle_dispatched": true|false,
170
+ "tick_duration_ms": <ms>
171
+ }
172
+ ```
173
+
174
+ ## Output
175
+
176
+ This stage produces no console output beyond:
177
+ - The turn preamble (always).
178
+ - An escalation terminal message (only when escalating).
179
+ - The final `result.md` summary section for this PR (only on the terminating tick — written to disk, not printed).
180
+
181
+ ## Self-check before ending the turn
182
+
183
+ - [ ] `last_seen.json` advanced for any review handled.
184
+ - [ ] `prs.json` reflects current state (terminal marked; `escalated`/`cycling` flags consistent).
185
+ - [ ] `followup.log` has at minimum a heartbeat or per-review line for this tick.
186
+ - [ ] Telemetry events emitted (per-cycle when applicable + per-tick).
187
+ - [ ] If pushed, `last_pushed_sha` is set and `cycles_completed` incremented.
188
+ - [ ] If actionable, one threaded reply posted per line comment (or one top-level reply for body-only reviews) — never both, never zero.
189
+ - [ ] If escalated, `escalated_review_ids` contains the review id.
190
+ - [ ] If terminal, the loop is NOT continued.
@@ -215,6 +215,19 @@ If the user picks `muggle-feedback` from any bucket's options, invoke the `muggl
215
215
 
216
216
  Skip silently when the run passed cleanly — failure-mode events are by definition about failures.
217
217
 
218
+ ### 9b. Remind the user to guide the agent (every Electron invocation)
219
+
220
+ Fires after **every** Electron run, pass or fail. A run can technically pass while still containing steps the user would correct — a misclick, wrong element, or a summary that doesn't match intent. This is the user's chance to flag it before regeneration picks up elsewhere.
221
+
222
+ **Skip if 9a already routed the user into `muggle-feedback` for this run.** Otherwise ask via `AskUserQuestion`:
223
+
224
+ > "Did the agent miss or do anything wrong on this run? Your feedback regenerates the affected scripts."
225
+
226
+ - **Yes — give feedback** → invoke `muggle-feedback` via the `Skill` tool, passing the just-finished `runId` so the submit flow opens on this run's steps and summary.
227
+ - **No — looks good** → continue to Step 10.
228
+
229
+ Non-blocking — one click to dismiss. Do not re-ask for the same `runId` within a session.
230
+
218
231
  ### 10. Offer to post a visual walkthrough to the PR
219
232
 
220
233
  After reporting results:
@@ -231,6 +244,7 @@ After reporting results:
231
244
  - **Never prompt for Electron launch approval** before execution — invoking this skill is the approval. Just run.
232
245
  - If replayable scripts exist, do not default to generation without user choice.
233
246
  - No hiding failures: surface errors and artifact paths.
247
+ - **Always offer the agent-guidance reminder after every Electron run** (Step 9b) — pass or fail — unless 9a already routed the user into `muggle-feedback`. Never silently end a run without giving the user a one-click path to flag what was wrong.
234
248
  - Replay: never hand-built or simplified `actionScript` — only from `muggle-remote-action-script-get`.
235
249
  - Use `AskUserQuestion` for every selection — project, use case, test case, script. Never ask the user to type a number.
236
250
  - 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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release": "4.10.1",
3
- "buildId": "run-32-1",
4
- "commitSha": "8be7ac283bd1924e1d2e2df90f214a40d85a3038",
5
- "buildTime": "2026-05-13T18:34:37Z",
2
+ "release": "4.11.1",
3
+ "buildId": "run-34-1",
4
+ "commitSha": "09bc0bf650bd1c56171238fb0065ec3e584bb9fd",
5
+ "buildTime": "2026-05-19T19:57:13Z",
6
6
  "serviceName": "muggle-ai-works-mcp"
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@muggleai/works",
3
3
  "mcpName": "io.github.multiplex-ai/muggle",
4
- "version": "4.10.1",
4
+ "version": "4.11.1",
5
5
  "description": "Ship quality products with AI-powered E2E acceptance testing that validates your web app like a real user — from Claude Code and Cursor to PR.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -41,14 +41,14 @@
41
41
  "test:watch": "vitest"
42
42
  },
43
43
  "muggleConfig": {
44
- "electronAppVersion": "1.0.82",
44
+ "electronAppVersion": "1.0.87",
45
45
  "downloadBaseUrl": "https://github.com/multiplex-ai/muggle-ai-works/releases/download",
46
46
  "runtimeTargetDefault": "production",
47
47
  "checksums": {
48
- "darwin-arm64": "ceab8a6ea1982cff9385896d392519ef2b5545d3f99e1409eec247e888334b02",
49
- "darwin-x64": "423b23d98a2858c7e4d203133aab586bbc5014b7cd50a4aa7125803ccaf7deed",
50
- "win32-x64": "c231ae9ae512ab97d3ee7980309a807c31b9d8033daab47c50bc1d6f4c112e4f",
51
- "linux-x64": "0dd15add46ca7bed5ad8e4d4cb751c63506b9dbb2eec294d9039426baeba8c32"
48
+ "darwin-arm64": "df04c98269e22ae427bb863956215b3f20cbf2ff0b51c037647d6e734a7b7502",
49
+ "darwin-x64": "e9f5b8a61f4a9f47743aaabb27d6e4c462dca5aa922ba66ae04f0a0133b8a7eb",
50
+ "win32-x64": "75e552672757d280259637bdcbe0aae0eecc2417ed9a6e5bd49f42d3466f66cf",
51
+ "linux-x64": "2c8b64cf549f9a6682db959b17c5f04578d632d5bcdba1ac9efbb45d6a097802"
52
52
  }
53
53
  },
54
54
  "dependencies": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Run real-browser end-to-end (E2E) acceptance tests on your web app from any AI coding agent. Generate test scripts from plain English, replay them on localhost, capture screenshots, and validate user flows like signup, checkout, and dashboards. Works across Claude Code, Cursor, Codex, and Windsurf.",
4
- "version": "4.10.1",
4
+ "version": "4.11.1",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -2,7 +2,7 @@
2
2
  "name": "muggle",
3
3
  "displayName": "Muggle AI",
4
4
  "description": "Ship quality products with AI-powered end-to-end (E2E) acceptance testing that validates your web app like a real user — from Claude Code and Cursor to PR.",
5
- "version": "4.10.1",
5
+ "version": "4.11.1",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"