@muggleai/works 5.26.0-staging.206 → 5.26.0-staging.208

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 (56) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  5. package/dist/plugin/.codex-mcp.json +1 -1
  6. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  7. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  8. package/dist/plugin/.mcp.json +1 -1
  9. package/dist/plugin/hooks/README.md +2 -1
  10. package/dist/plugin/hooks/codex-hooks.json +2 -2
  11. package/dist/plugin/hooks/hooks.json +1 -1
  12. package/dist/plugin/scripts/guardrail-watch-follow-through-gate.sh +48 -0
  13. package/dist/plugin/scripts/guardrails.mjs +282 -32
  14. package/dist/plugin/scripts/pr-watch-arm.sh +64 -37
  15. package/dist/plugin/scripts/pr-watch-due.sh +31 -0
  16. package/dist/plugin/scripts/pr-watch-events.sh +20 -6
  17. package/dist/plugin/scripts/pr-watch-loop.sh +21 -2
  18. package/dist/plugin/scripts/pr-watch-verdict.mjs +197 -0
  19. package/dist/plugin/skills/_shared/ci-check-to-command.md +2 -1
  20. package/dist/plugin/skills/do/fix-ci.md +24 -8
  21. package/dist/plugin/skills/do/resolve-conflicts.md +7 -3
  22. package/dist/plugin/skills/muggle-pr-followup/SKILL.md +1 -1
  23. package/dist/plugin/skills/muggle-pr-followup/arm-watcher.md +5 -3
  24. package/dist/plugin/skills/muggle-pr-followup/blocked-tick.md +2 -0
  25. package/dist/plugin/skills/muggle-pr-followup/contract.md +40 -25
  26. package/dist/plugin/skills/muggle-pr-followup/state-schemas.md +22 -8
  27. package/dist/plugin/skills/muggle-preferences/preference-gates/autoInstallWatchService.md +1 -1
  28. package/dist/plugin/skills/muggle-upgrade/SKILL.md +1 -1
  29. package/dist/release-manifest.json +3 -3
  30. package/package.json +1 -1
  31. package/plugin/.claude-plugin/plugin.json +1 -1
  32. package/plugin/.codex-mcp.json +1 -1
  33. package/plugin/.codex-plugin/plugin.json +1 -1
  34. package/plugin/.cursor-plugin/plugin.json +1 -1
  35. package/plugin/.mcp.json +1 -1
  36. package/plugin/hooks/README.md +2 -1
  37. package/plugin/hooks/codex-hooks.json +2 -2
  38. package/plugin/hooks/hooks.json +1 -1
  39. package/plugin/scripts/guardrail-watch-follow-through-gate.sh +48 -0
  40. package/plugin/scripts/guardrails.mjs +282 -32
  41. package/plugin/scripts/pr-watch-arm.sh +64 -37
  42. package/plugin/scripts/pr-watch-due.sh +31 -0
  43. package/plugin/scripts/pr-watch-events.sh +20 -6
  44. package/plugin/scripts/pr-watch-loop.sh +21 -2
  45. package/plugin/scripts/pr-watch-verdict.mjs +197 -0
  46. package/plugin/skills/_shared/ci-check-to-command.md +2 -1
  47. package/plugin/skills/do/fix-ci.md +24 -8
  48. package/plugin/skills/do/resolve-conflicts.md +7 -3
  49. package/plugin/skills/muggle-pr-followup/SKILL.md +1 -1
  50. package/plugin/skills/muggle-pr-followup/arm-watcher.md +5 -3
  51. package/plugin/skills/muggle-pr-followup/blocked-tick.md +2 -0
  52. package/plugin/skills/muggle-pr-followup/contract.md +40 -25
  53. package/plugin/skills/muggle-pr-followup/state-schemas.md +22 -8
  54. package/plugin/skills/muggle-preferences/preference-gates/autoInstallWatchService.md +1 -1
  55. package/plugin/skills/muggle-upgrade/SKILL.md +1 -1
  56. /package/dist/{chunk-HGN35NEP.js → chunk-HOKMW4AL.js} +0 -0
@@ -95,6 +95,7 @@ Keyed by `"<owner>/<repo>#<n>"`. One key per PR in the slot.
95
95
  "pushed_shas": ["<sha>", ...],
96
96
  "ci_fix_attempts": { "<sha>": <int> },
97
97
  "ci_escalated_shas": ["<sha>", ...],
98
+ "ci_rerun_shas": ["<sha>", ...],
98
99
  "conflict_resolve_attempts": { "<head-sha>..<base-tip-sha>": <int> },
99
100
  "conflict_escalated_keys": ["<head-sha>..<base-tip-sha>", ...],
100
101
  "catch_up_rebases": <int>,
@@ -118,12 +119,15 @@ Keyed by `"<owner>/<repo>#<n>"`. One key per PR in the slot.
118
119
  - `cycles_completed`: incremented each time `/muggle-do` completes an address-reviews invocation (regardless of actionable/ambiguous/mixed).
119
120
  - `escalated_review_ids`: review ids classified as ambiguous by `/muggle-do`. The watcher excludes these from the actionable set (both body-only reviews and the threads they own) so the same ambiguous review is never re-dispatched.
120
121
  - `pushed_shas`: every SHA `/muggle-do` has pushed for this PR. Append-only. Used by the resolve-reminder stage to recognize threads addressed by the loop.
121
- - `ci_fix_attempts`: per-SHA count of fix-ci cycles `/muggle-do` has run. The watcher stops dispatching fix-ci for a SHA once its count reaches 3. Keyed by head SHA.
122
- - `ci_escalated_shas`: head SHAs whose CI the fix-ci stage gave up on (attempts exhausted or only out-of-scope checks). The watcher excludes these from CI dispatch so a hopeless SHA is never re-fixed.
123
- - `conflict_resolve_attempts`: count of rebase cycles `/muggle-do` has run (behind-only or conflicting — both rebase onto the base). The watcher stops dispatching once a key's count reaches 2. Keyed by `rebase_key` — `"<head_sha>..<base_tip_sha>"`, the head paired with the base branch tip it was measured against.
124
- - `conflict_escalated_keys`: `rebase_key`s whose rebase `/muggle-do` gave up on (attempts exhausted, or a conflict under `autoResolveConflicts=never`). The watcher excludes these from rebase dispatch so a hopeless pairing is never re-attempted.
122
+ - `ci_fix_attempts`: per-SHA count of fix-ci cycles `/muggle-do` has run, incremented when a cycle starts — so a cycle that only re-runs a noisy check, or escalates without a push, still counts. The watcher stops dispatching fix-ci for a SHA once its count reaches 3. Keyed by head SHA. A count of 1 or more is the only evidence that floors a red head at arm time or releases the turn-end gate.
123
+ - `ci_escalated_shas`: head SHAs whose CI the fix-ci stage gave up on (attempts exhausted, only out-of-scope checks, or a noisy check red again after its re-run). Suppresses CI dispatch **only while `ci_fix_attempts[sha] >= 1`**; an entry with no attempt behind it is ignored and fix-ci dispatches anyway.
124
+ - `ci_rerun_shas`: heads on which fix-ci already re-ran its non-deterministic checks once. A noisy check red again on a listed head escalates instead of re-running a second time.
125
+ - `conflict_resolve_attempts`: count of rebase cycles `/muggle-do` has run (behind-only or conflicting — both rebase onto the base), incremented when a cycle starts. The watcher stops dispatching once a key's count reaches 2. Keyed by `rebase_key` — `"<head_sha>..<base_tip_sha>"`, the head paired with the base branch tip it was measured against. A count of 1 or more is the only evidence that floors a stale branch at arm time or releases the turn-end gate.
126
+ - `conflict_escalated_keys`: `rebase_key`s whose rebase `/muggle-do` gave up on (attempts exhausted, or a conflict under `autoResolveConflicts=never`). Suppresses rebase dispatch **only while `conflict_resolve_attempts[key] >= 1`**; an entry with no attempt behind it is ignored and the rebase dispatches anyway.
125
127
  - `catch_up_rebases`: how many rebases this PR has been dispatched for across its whole life. A plain counter, deliberately unkeyed: the two fields above key on `rebase_key`, which changes on every base advance and so hands an active base an unlimited supply of fresh budgets. Nothing resets this one, which makes it the only cap that binds. Capped by [`../muggle-preferences/preference-gates/maxCatchUpRebases.md`](../muggle-preferences/preference-gates/maxCatchUpRebases.md) — 20 by default, `never` for unbounded. Incremented by the rebase cycle on every push, whatever the outcome.
126
- - `rebase_budget_exhausted`: set once `catch_up_rebases` reaches the cap. The watcher then stops dispatching rebases for the PR entirely and blocks with reason `rebase_budget_exhausted` rather than idling, so the owner is told the branch is waiting on them. Cleared by raising the preference.
128
+ - `rebase_budget_exhausted`: set by the tick once `catch_up_rebases` reaches the cap, recording why the watch blocks with reason `rebase_budget_exhausted`. The verdict judges exhaustion from the counter and the cap, never from this flag, so raising the preference resumes rebases at once.
129
+
130
+ The escalation sets and attempt counters are written by the `/muggle-do` cycles that ran, and only by them. The dispatch decision that reads them lives in [`../../scripts/pr-watch-verdict.mjs`](../../scripts/pr-watch-verdict.mjs) ([`contract.md`](contract.md) Step 6), not in prose.
127
131
 
128
132
  Both are keyed on the pair, not the head alone, because whether a branch conflicts depends on both sides. Under a head-only key, a base that moves produces a genuinely new conflict against an unchanged head — and the stale entry suppresses it permanently, because nothing can change the head while the branch sits blocked. Pairing re-arms the budget whenever either side moves. Legacy entries written before this change are bare SHAs with no `..`; readers ignore them, which un-wedges any slot they had blocked.
129
133
 
@@ -213,14 +217,24 @@ The watch loop's comparison floor — plain `KEY=VALUE` lines, one file per slot
213
217
  - `REV` — highest submitted-review id already handled
214
218
  - `COM` — highest thread-comment id already handled
215
219
  - `THREADS` — semicolon-joined ids of threads already known unresolved
216
- - `CIRED` — head SHA whose settled-red CI the drain already handled; empty when the checks are green, still pending, or unseen. The CI floor is a SHA rather than a monotonic id because the check rollup flips green↔red and resets on each push — keying on the head SHA fires the loop once per red head and re-arms on the next push ([`arm-watcher.md`](arm-watcher.md)).
217
- - `REBASED` — the `rebase_key` (`<head_sha>..<base_tip_sha>`) whose behind/conflicting state the drain already handled; empty when the branch is current with its base or unseen. Keyed on the pair, not a monotonic id, because staleness depends on both sides — the loop fires once per newly-due pair and re-arms when the head or the base moves. Same key [`contract.md`](contract.md) Step 5 dedups rebase dispatch on; the monitor only signals a due rebase, the tick applies the `conflict_resolve_attempts` budget.
220
+ - `CIRED` — head SHA whose settled-red CI a fix-ci cycle already attempted (`ci_fix_attempts[sha] >= 1`); empty when the checks are green, still pending, unseen, or red with no attempt — the last so the loop reports it. The CI floor is a SHA rather than a monotonic id because the check rollup flips green↔red and resets on each push — keying on the head SHA fires the loop once per red head and re-arms on the next push ([`arm-watcher.md`](arm-watcher.md)).
221
+ - `REBASED` — the `rebase_key` (`<head_sha>..<base_tip_sha>`) whose behind/conflicting state a rebase cycle already attempted (`conflict_resolve_attempts[key] >= 1`); empty when the branch is current with its base, unseen, or stale with no attempt. Keyed on the pair, not a monotonic id, because staleness depends on both sides — the loop fires once per newly-due pair and re-arms when the head or the base moves. Same key [`contract.md`](contract.md) Steps 5–6 dedup rebase dispatch on; the monitor only signals a due rebase, the tick's verdict applies the budgets.
218
222
  - `BLOCKED_CIDIGEST` — the head's `ci_digest` at the moment a block was flagged (the same signature `blocked.fingerprint.ci_digest` carries); empty whenever the watch is not blocked. Non-empty arms the loop's blocked-resume probe: while set, the loop wakes on any move of the live digest away from this value, so a block resumes on a green pass, a rerun, or an external deploy check — not only on red. Written by [`blocked-tick.md`](blocked-tick.md) when a block is flagged and cleared to empty when it resumes.
219
223
 
220
- Written whole-file by the orchestrating session — the review/comment/CI/rebase floors seeded at arm time (`REV`/`COM` to the **drain's own observed max**, `CIRED`/`REBASED` to what the drain handled) and advanced after every cycle to the **handled wave's snapshot** (the max review-id and comment-id the cycle read at the start of handling, captured before replies were posted); `BLOCKED_CIDIGEST` is set and cleared by the blocked-tick flag/resume path, and every arm re-seeds it from `last_seen.blocked.fingerprint.ci_digest` so a rollover or respawn keeps the resume probe live. **Never** derived from a fresh fetch taken after the drain or after replies land: a later fetch includes ids that arrived in the handling window and were never read, and marking them seen swallows them ([`arm-watcher.md`](arm-watcher.md)). The advance also never moves any floor past an unresolved thread the cycle left unaddressed. Read by the watch loop each iteration; the loop never writes it. A stale watermark makes the next reported event the loop's own reply.
224
+ Written whole-file by the orchestrating session — the review/comment/CI/rebase floors seeded at arm time (`REV`/`COM` to the **drain's own observed max**, `CIRED`/`REBASED` to the red head and stale key a cycle already attempted) and advanced after every cycle to the **handled wave's snapshot** (the max review-id and comment-id the cycle read at the start of handling, captured before replies were posted); `BLOCKED_CIDIGEST` is set and cleared by the blocked-tick flag/resume path, and every arm re-seeds it from `last_seen.blocked.fingerprint.ci_digest` so a rollover or respawn keeps the resume probe live. **Never** derived from a fresh fetch taken after the drain or after replies land: a later fetch includes ids that arrived in the handling window and were never read, and marking them seen swallows them ([`arm-watcher.md`](arm-watcher.md)). The advance also never moves any floor past an unresolved thread the cycle left unaddressed. Read by the watch loop each iteration; the loop never writes it. A stale watermark makes the next reported event the loop's own reply.
221
225
 
222
226
  **Never `source` this file, and quote or extract values.** `THREADS` holds bare semicolons: sourced unquoted, the shell splits the line at the first `;` and silently drops every id after it — the loop then re-reports known threads as new. The watch loop must extract values verbatim (e.g. `grep '^THREADS=' | cut -d= -f2- | tr -d '"\r'`), tolerating quotes and CRLF; writers should quote the value anyway.
223
227
 
228
+ ## `watch-due.env`
229
+
230
+ The work the watch last saw due on its PR, for the owning session's turn-end gate — plain `KEY="value"` lines, one file per slot:
231
+
232
+ - `HEAD` — the head SHA the observation was made on.
233
+ - `REBASE_DUE` — the `rebase_key` found behind or conflicting with the base; empty when the branch is current.
234
+ - `CI_RED_HEAD` — the head whose checks settled red; empty when CI is green or still pending.
235
+
236
+ The file is **empty** when nothing is due. Written by [`../../scripts/pr-watch-arm.sh`](../../scripts/pr-watch-arm.sh) from the drain's read and rewritten by the loop whenever what is due changes; the session never writes it. The follow-through Stop gate ([`../../hooks/README.md`](../../hooks/README.md)) blocks the turn end while a non-empty record in a slot this session owns names work with no matching attempt in `last_seen.json`: a `REBASE_DUE` key with no `conflict_resolve_attempts` entry (under `autoRebase=always`, budget left), or a `CI_RED_HEAD` with no `ci_fix_attempts` entry. A later tick's `prs.json` naming another head supersedes the record.
237
+
224
238
  ## `watch.pid`
225
239
 
226
240
  A single line: the process id of the watch loop that currently owns this slot. Written once by the loop itself on start (`echo "$$" > watch.pid`); read by two parties, never rewritten in place:
@@ -1,6 +1,6 @@
1
1
  # `autoInstallWatchService`
2
2
 
3
- Controls whether Muggle runs Muggle Watch, a per-user scheduled task that every two minutes resumes the owner session of a dead PR watcher, moves idle sessions onto the newest install, and alerts on red CI and stale branches. Acted on without a prompt by every global install or upgrade (postinstall) and by `muggle init`; the picker fires only from `/muggle-upgrade`. Where the task already exists only `never` counts: any other value lets an upgrade refresh it in place. Windows only for now; elsewhere `always` prints the crontab line to add instead.
3
+ Controls whether Muggle runs Muggle Watch, a per-user scheduled job that every two minutes resumes the owner session of a dead PR watcher, moves idle sessions onto the newest install, and alerts on red CI and stale branches. It runs under Task Scheduler on Windows, launchd on macOS, and a systemd user timer on Linux (cron where there is none). Acted on without a prompt by every global install or upgrade (postinstall) and by `muggle init`; the picker fires only from `/muggle-upgrade`. Where the job already exists only `never` counts: any other value lets an upgrade refresh it in place.
4
4
 
5
5
  **Picker 1** — header `Muggle Watch`, question `"Run Muggle Watch in the background? It brings back dead PR watchers and moves idle sessions onto the newest install."`
6
6
  - `Install it` — `Run muggle watch install now, and refresh it on every upgrade.` → `always`
@@ -70,4 +70,4 @@ If the upgrade fails at any step, report the error and suggest running `/muggle:
70
70
 
71
71
  | Preference | Gate |
72
72
  | :--------- | :--- |
73
- | `autoInstallWatchService` | Step 5 — run Muggle Watch as a scheduled task; postinstall acts on `always`/`never`, `ask` asks here, default `ask` |
73
+ | `autoInstallWatchService` | Step 5 — run Muggle Watch as a scheduled job on any OS; postinstall acts on `always`/`never`, `ask` asks here, default `ask` |
File without changes