@muggleai/works 5.26.0-staging.198 → 5.26.0-staging.199

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 (39) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/{chunk-SLU7LHVJ.js → chunk-IL5E5YGY.js} +1 -1
  3. package/dist/{chunk-U5ZA3VTZ.js → chunk-MKQYUSIW.js} +1430 -23
  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/.codex-mcp.json +1 -1
  8. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  9. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  10. package/dist/plugin/.mcp.json +1 -1
  11. package/dist/plugin/hooks/README.md +1 -1
  12. package/dist/plugin/scripts/guardrail-walkthrough-gate.sh +15 -12
  13. package/dist/plugin/scripts/guardrails.mjs +134 -91
  14. package/dist/plugin/scripts/pr-watch-arm.sh +8 -1
  15. package/dist/plugin/skills/do/open-prs/forward.md +1 -1
  16. package/dist/plugin/skills/muggle-pr-followup/arm-watcher.md +2 -0
  17. package/dist/plugin/skills/muggle-pr-followup/reconcile.md +4 -2
  18. package/dist/plugin/skills/muggle-pr-followup/state-schemas.md +15 -0
  19. package/dist/plugin/skills/muggle-pr-followup/stop.md +1 -1
  20. package/dist/release-manifest.json +3 -3
  21. package/dist/{src-3HZTU2TJ.js → src-UVZTYRQY.js} +1 -1
  22. package/package.json +2 -1
  23. package/plugin/.claude-plugin/plugin.json +1 -1
  24. package/plugin/.codex-mcp.json +1 -1
  25. package/plugin/.codex-plugin/plugin.json +1 -1
  26. package/plugin/.cursor-plugin/plugin.json +1 -1
  27. package/plugin/.mcp.json +1 -1
  28. package/plugin/hooks/README.md +1 -1
  29. package/plugin/scripts/guardrail-walkthrough-gate.sh +15 -12
  30. package/plugin/scripts/guardrails.mjs +134 -91
  31. package/plugin/scripts/pr-watch-arm.sh +8 -1
  32. package/plugin/skills/do/open-prs/forward.md +1 -1
  33. package/plugin/skills/muggle-pr-followup/arm-watcher.md +2 -0
  34. package/plugin/skills/muggle-pr-followup/reconcile.md +4 -2
  35. package/plugin/skills/muggle-pr-followup/state-schemas.md +15 -0
  36. package/plugin/skills/muggle-pr-followup/stop.md +1 -1
  37. package/scripts/muggle-watch/README.md +45 -0
  38. package/scripts/muggle-watch/install-muggle-watch.ps1 +92 -0
  39. package/scripts/muggle-watch/muggle-watch-hidden.vbs +39 -0
@@ -0,0 +1,92 @@
1
+ # Installs the MuggleWatch scheduled task for the current user (no elevation):
2
+ # every -IntervalMinutes it runs `muggle watch tick`, which snapshots Claude and
3
+ # Codex sessions, their processes and every PR-watch slot, alerts on dead or deaf
4
+ # watchers, red CI and stale branches, resumes the owner session of a registered
5
+ # slot whose watcher died, and fans plugin reloads out across sessions.
6
+ #
7
+ # The task runs the global @muggleai/works install, whose path survives
8
+ # `muggle upgrade`, so the service always runs the current release. Only the
9
+ # launcher shim is copied, to ~\.muggle-ai\watch\bin, so the task never points
10
+ # into a checkout or worktree that may be deleted.
11
+ [CmdletBinding()]
12
+ param(
13
+ [ValidateRange(1, 60)]
14
+ [int]$IntervalMinutes = 2,
15
+ [string]$TaskName = "MuggleWatch",
16
+ [string]$MuggleEntry,
17
+ [switch]$NoAutoReload,
18
+ [switch]$NoRecovery,
19
+ [switch]$Uninstall
20
+ )
21
+
22
+ $ErrorActionPreference = "Stop"
23
+
24
+ if ($Uninstall) {
25
+ if (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) {
26
+ Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
27
+ "task $TaskName removed; ledger kept at $(Join-Path $env:USERPROFILE '.muggle-ai\watch')"
28
+ } else {
29
+ "task $TaskName is not installed"
30
+ }
31
+ return
32
+ }
33
+
34
+ if (-not $MuggleEntry) {
35
+ $npmRoot = (& npm root -g 2>$null | Select-Object -First 1)
36
+ if ($npmRoot) { $MuggleEntry = Join-Path $npmRoot "@muggleai\works\bin\muggle.js" }
37
+ }
38
+ if (-not $MuggleEntry -or -not (Test-Path $MuggleEntry)) {
39
+ throw "No global @muggleai/works install found. Run 'npm install -g @muggleai/works', or pass -MuggleEntry <path to bin\muggle.js>."
40
+ }
41
+ $nodeCommand = Get-Command node -ErrorAction SilentlyContinue
42
+ if (-not $nodeCommand) { throw "node is not on PATH; the task needs it to run muggle." }
43
+ foreach ($requiredTool in @("claude", "gh")) {
44
+ if (-not (Get-Command $requiredTool -ErrorAction SilentlyContinue)) {
45
+ Write-Warning "$requiredTool is not on PATH — the watch will report without the data it provides."
46
+ }
47
+ }
48
+
49
+ $watchDir = Join-Path $env:USERPROFILE ".muggle-ai\watch"
50
+ $installDir = Join-Path $watchDir "bin"
51
+ New-Item -ItemType Directory -Force -Path $installDir | Out-Null
52
+ $installedLauncher = Join-Path $installDir "muggle-watch-hidden.vbs"
53
+ Copy-Item (Join-Path $PSScriptRoot "muggle-watch-hidden.vbs") $installedLauncher -Force
54
+
55
+ $tickFlags = @()
56
+ if ($NoAutoReload) { $tickFlags += "--no-auto-reload" }
57
+ if ($NoRecovery) { $tickFlags += "--no-recovery" }
58
+ $launcherArguments = @("`"$installedLauncher`"", "`"$($nodeCommand.Source)`"", "`"$MuggleEntry`"") + $tickFlags
59
+
60
+ # wscript.exe rather than node.exe is what keeps every run off the desktop — see
61
+ # the header of muggle-watch-hidden.vbs.
62
+ $taskAction = New-ScheduledTaskAction -Execute (Join-Path $env:SystemRoot "System32\wscript.exe") `
63
+ -Argument ($launcherArguments -join " ")
64
+ # Omitting RepetitionDuration is what makes the repetition indefinite; passing
65
+ # [TimeSpan]::MaxValue serializes to a duration Windows PowerShell 5.1 rejects.
66
+ $taskTrigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) `
67
+ -RepetitionInterval (New-TimeSpan -Minutes $IntervalMinutes)
68
+ # The battery switches matter on laptops: the defaults skip every run on battery.
69
+ $taskSettings = New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -StartWhenAvailable `
70
+ -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries `
71
+ -ExecutionTimeLimit (New-TimeSpan -Minutes 10)
72
+ # -Force replaces the task in place: unregistering first would leave a window with
73
+ # no watch at all, and no watch for good if the registration then failed.
74
+ Register-ScheduledTask -TaskName $TaskName -Action $taskAction -Trigger $taskTrigger `
75
+ -Settings $taskSettings -Force `
76
+ -Description "Muggle watch service: tracks agent sessions, processes and PR watchers (@muggleai/works)" | Out-Null
77
+
78
+ $statusFile = Join-Path $watchDir "status.json"
79
+ $previousSnapshotTime = if (Test-Path $statusFile) { (Get-Item $statusFile).LastWriteTime } else { [DateTime]::MinValue }
80
+ Start-ScheduledTask -TaskName $TaskName
81
+ $deadline = (Get-Date).AddSeconds(120)
82
+ while ((Get-Date) -lt $deadline) {
83
+ if ((Test-Path $statusFile) -and (Get-Item $statusFile).LastWriteTime -gt $previousSnapshotTime) { break }
84
+ Start-Sleep -Seconds 2
85
+ }
86
+ $taskInfo = Get-ScheduledTaskInfo -TaskName $TaskName
87
+ "task $TaskName registered every $IntervalMinutes min; state=$((Get-ScheduledTask -TaskName $TaskName).State) lastResult=$($taskInfo.LastTaskResult)"
88
+ if ((Test-Path $statusFile) -and (Get-Item $statusFile).LastWriteTime -gt $previousSnapshotTime) {
89
+ "first tick written: $statusFile — run 'muggle watch status' to read it"
90
+ } else {
91
+ Write-Warning "no tick finished within 120s; check $(Join-Path $watchDir 'tick.log')"
92
+ }
@@ -0,0 +1,39 @@
1
+ ' Console-free launcher for `muggle watch tick`, used as the MuggleWatch task action.
2
+ '
3
+ ' node.exe is a console-subsystem binary, so launching it straight from the task
4
+ ' paints a console window on every run. wscript.exe is GUI-subsystem, and the
5
+ ' child it starts with intWindowStyle 0 is created hidden.
6
+ '
7
+ ' Arguments: <node.exe> <muggle.js> [extra tick flags...]
8
+ '
9
+ ' Output is appended to tick.log beside this script's install dir, capped at
10
+ ' 1 MB by starting over, since the snapshot and events ledger are the record and
11
+ ' the log only needs the recent failures. The Run call waits, so the task's
12
+ ' IgnoreNew overlap guard and LastTaskResult describe the tick, not this shim.
13
+ Option Explicit
14
+
15
+ Const LOG_CAP_BYTES = 1048576
16
+
17
+ Dim fileSystem, windowsShell, watchDir, logPath, nodePath, muggleEntry, tickFlags, argumentIndex, tickExitCode
18
+ Set fileSystem = CreateObject("Scripting.FileSystemObject")
19
+ Set windowsShell = CreateObject("WScript.Shell")
20
+
21
+ If WScript.Arguments.Count < 2 Then WScript.Quit 2
22
+ nodePath = WScript.Arguments(0)
23
+ muggleEntry = WScript.Arguments(1)
24
+ tickFlags = ""
25
+ For argumentIndex = 2 To WScript.Arguments.Count - 1
26
+ tickFlags = tickFlags & " " & WScript.Arguments(argumentIndex)
27
+ Next
28
+
29
+ watchDir = fileSystem.GetParentFolderName(fileSystem.GetParentFolderName(WScript.ScriptFullName))
30
+ logPath = watchDir & "\tick.log"
31
+ If fileSystem.FileExists(logPath) Then
32
+ If fileSystem.GetFile(logPath).Size > LOG_CAP_BYTES Then fileSystem.DeleteFile logPath
33
+ End If
34
+
35
+ tickExitCode = windowsShell.Run( _
36
+ "cmd.exe /d /s /c """"" & nodePath & """ """ & muggleEntry & """ watch tick" & tickFlags & " >> """ & logPath & """ 2>&1""", _
37
+ 0, True)
38
+
39
+ WScript.Quit tickExitCode