@muggleai/works 5.26.0-staging.222 → 5.26.0-staging.224

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 (74) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/{chunk-32I7VRZ7.js → chunk-ORX3TIFC.js} +25 -1
  3. package/dist/{chunk-OC6K3BQ6.js → chunk-U43SO3SZ.js} +2 -2
  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 +5 -1
  12. package/dist/plugin/hooks/hooks.json +16 -16
  13. package/dist/plugin/scripts/guardrail-build-followthrough-gate.sh +1 -1
  14. package/dist/plugin/scripts/guardrail-build-router.sh +1 -1
  15. package/dist/plugin/scripts/guardrail-capability-claim.sh +1 -1
  16. package/dist/plugin/scripts/guardrail-classify-gate.sh +1 -1
  17. package/dist/plugin/scripts/guardrail-comment-reply-gate.sh +1 -1
  18. package/dist/plugin/scripts/guardrail-debug-path-gate.sh +1 -1
  19. package/dist/plugin/scripts/guardrail-e2e-gate.sh +1 -1
  20. package/dist/plugin/scripts/guardrail-lib.sh +6 -0
  21. package/dist/plugin/scripts/guardrail-offer-ran.sh +1 -1
  22. package/dist/plugin/scripts/guardrail-pr-opened.sh +1 -1
  23. package/dist/plugin/scripts/guardrail-pr-terminal.sh +1 -1
  24. package/dist/plugin/scripts/guardrail-record-comment-replies.sh +1 -1
  25. package/dist/plugin/scripts/guardrail-record-delegation.sh +1 -1
  26. package/dist/plugin/scripts/guardrail-record-stage-read.sh +1 -1
  27. package/dist/plugin/scripts/guardrail-record-stage-signals.sh +1 -1
  28. package/dist/plugin/scripts/guardrail-record-tests.sh +1 -1
  29. package/dist/plugin/scripts/guardrail-report-format.sh +1 -1
  30. package/dist/plugin/scripts/guardrail-resolve-gate.sh +1 -1
  31. package/dist/plugin/scripts/guardrail-skill-stages.sh +1 -1
  32. package/dist/plugin/scripts/guardrail-stage-gate.sh +1 -1
  33. package/dist/plugin/scripts/guardrail-terminal-gate.sh +1 -1
  34. package/dist/plugin/scripts/guardrail-walkthrough-gate.sh +1 -1
  35. package/dist/plugin/scripts/guardrail-walkthrough-heading.sh +1 -1
  36. package/dist/plugin/scripts/guardrail-watch-follow-through-gate.sh +1 -1
  37. package/dist/plugin/scripts/guardrail-watch-gate.sh +1 -1
  38. package/dist/plugin/scripts/hook-entry.sh +23 -0
  39. package/dist/release-manifest.json +3 -3
  40. package/dist/{src-ZAGX3JLC.js → src-V72RTJZL.js} +1 -1
  41. package/package.json +1 -1
  42. package/plugin/.claude-plugin/plugin.json +1 -1
  43. package/plugin/.codex-mcp.json +1 -1
  44. package/plugin/.codex-plugin/plugin.json +1 -1
  45. package/plugin/.cursor-plugin/plugin.json +1 -1
  46. package/plugin/.mcp.json +1 -1
  47. package/plugin/hooks/README.md +5 -1
  48. package/plugin/hooks/hooks.json +16 -16
  49. package/plugin/scripts/guardrail-build-followthrough-gate.sh +1 -1
  50. package/plugin/scripts/guardrail-build-router.sh +1 -1
  51. package/plugin/scripts/guardrail-capability-claim.sh +1 -1
  52. package/plugin/scripts/guardrail-classify-gate.sh +1 -1
  53. package/plugin/scripts/guardrail-comment-reply-gate.sh +1 -1
  54. package/plugin/scripts/guardrail-debug-path-gate.sh +1 -1
  55. package/plugin/scripts/guardrail-e2e-gate.sh +1 -1
  56. package/plugin/scripts/guardrail-lib.sh +6 -0
  57. package/plugin/scripts/guardrail-offer-ran.sh +1 -1
  58. package/plugin/scripts/guardrail-pr-opened.sh +1 -1
  59. package/plugin/scripts/guardrail-pr-terminal.sh +1 -1
  60. package/plugin/scripts/guardrail-record-comment-replies.sh +1 -1
  61. package/plugin/scripts/guardrail-record-delegation.sh +1 -1
  62. package/plugin/scripts/guardrail-record-stage-read.sh +1 -1
  63. package/plugin/scripts/guardrail-record-stage-signals.sh +1 -1
  64. package/plugin/scripts/guardrail-record-tests.sh +1 -1
  65. package/plugin/scripts/guardrail-report-format.sh +1 -1
  66. package/plugin/scripts/guardrail-resolve-gate.sh +1 -1
  67. package/plugin/scripts/guardrail-skill-stages.sh +1 -1
  68. package/plugin/scripts/guardrail-stage-gate.sh +1 -1
  69. package/plugin/scripts/guardrail-terminal-gate.sh +1 -1
  70. package/plugin/scripts/guardrail-walkthrough-gate.sh +1 -1
  71. package/plugin/scripts/guardrail-walkthrough-heading.sh +1 -1
  72. package/plugin/scripts/guardrail-watch-follow-through-gate.sh +1 -1
  73. package/plugin/scripts/guardrail-watch-gate.sh +1 -1
  74. package/plugin/scripts/hook-entry.sh +23 -0
@@ -9,7 +9,7 @@
9
9
  "name": "muggleai",
10
10
  "source": "./plugin",
11
11
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
12
- "version": "5.26.0-staging.222"
12
+ "version": "5.26.0-staging.224"
13
13
  }
14
14
  ]
15
15
  }
@@ -983,6 +983,18 @@ var DisplayResolution = /* @__PURE__ */ ((DisplayResolution2) => {
983
983
  DisplayResolution2["R_1024x0768"] = "R_1024x0768";
984
984
  DisplayResolution2["R_0390x0844"] = "R_0390x0844";
985
985
  DisplayResolution2["R_1920x1080"] = "R_1920x1080";
986
+ DisplayResolution2["R_0360x0800"] = "R_0360x0800";
987
+ DisplayResolution2["R_0393x0852"] = "R_0393x0852";
988
+ DisplayResolution2["R_0430x0932"] = "R_0430x0932";
989
+ DisplayResolution2["R_0768x1024"] = "R_0768x1024";
990
+ DisplayResolution2["R_0820x1180"] = "R_0820x1180";
991
+ DisplayResolution2["R_1024x1366"] = "R_1024x1366";
992
+ DisplayResolution2["R_1440x0900"] = "R_1440x0900";
993
+ DisplayResolution2["R_1512x0982"] = "R_1512x0982";
994
+ DisplayResolution2["R_1728x1117"] = "R_1728x1117";
995
+ DisplayResolution2["R_1366x0768"] = "R_1366x0768";
996
+ DisplayResolution2["R_1536x0864"] = "R_1536x0864";
997
+ DisplayResolution2["R_2560x1440"] = "R_2560x1440";
986
998
  return DisplayResolution2;
987
999
  })(DisplayResolution || {});
988
1000
 
@@ -3002,7 +3014,19 @@ var DISPLAY_PARAMS_BY_RESOLUTION = {
3002
3014
  ["R_0800x0600" /* R_0800x0600 */]: { browserWindowWidth: 800, browserWindowHeight: 600 },
3003
3015
  ["R_1024x0768" /* R_1024x0768 */]: { browserWindowWidth: 1024, browserWindowHeight: 768 },
3004
3016
  ["R_0390x0844" /* R_0390x0844 */]: { browserWindowWidth: 390, browserWindowHeight: 844 },
3005
- ["R_1920x1080" /* R_1920x1080 */]: { browserWindowWidth: 1920, browserWindowHeight: 1080 }
3017
+ ["R_1920x1080" /* R_1920x1080 */]: { browserWindowWidth: 1920, browserWindowHeight: 1080 },
3018
+ ["R_0360x0800" /* R_0360x0800 */]: { browserWindowWidth: 360, browserWindowHeight: 800 },
3019
+ ["R_0393x0852" /* R_0393x0852 */]: { browserWindowWidth: 393, browserWindowHeight: 852 },
3020
+ ["R_0430x0932" /* R_0430x0932 */]: { browserWindowWidth: 430, browserWindowHeight: 932 },
3021
+ ["R_0768x1024" /* R_0768x1024 */]: { browserWindowWidth: 768, browserWindowHeight: 1024 },
3022
+ ["R_0820x1180" /* R_0820x1180 */]: { browserWindowWidth: 820, browserWindowHeight: 1180 },
3023
+ ["R_1024x1366" /* R_1024x1366 */]: { browserWindowWidth: 1024, browserWindowHeight: 1366 },
3024
+ ["R_1440x0900" /* R_1440x0900 */]: { browserWindowWidth: 1440, browserWindowHeight: 900 },
3025
+ ["R_1512x0982" /* R_1512x0982 */]: { browserWindowWidth: 1512, browserWindowHeight: 982 },
3026
+ ["R_1728x1117" /* R_1728x1117 */]: { browserWindowWidth: 1728, browserWindowHeight: 1117 },
3027
+ ["R_1366x0768" /* R_1366x0768 */]: { browserWindowWidth: 1366, browserWindowHeight: 768 },
3028
+ ["R_1536x0864" /* R_1536x0864 */]: { browserWindowWidth: 1536, browserWindowHeight: 864 },
3029
+ ["R_2560x1440" /* R_2560x1440 */]: { browserWindowWidth: 2560, browserWindowHeight: 1440 }
3006
3030
  };
3007
3031
  var DEFAULT_DISPLAY_RESOLUTION = "R_1920x1080" /* R_1920x1080 */;
3008
3032
 
@@ -1,4 +1,4 @@
1
- import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir2, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, resolveElectronAppExecutablePath, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, getActiveElectronAppReleaseStream, buildToolInputJsonSchema, toolRequiresAuth, getCallerCredentials, parseElectronAppDirName, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, ElectronAppReleaseStream, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, buildLlmSourcePlan, describeLlmSourceStatus, resolveLlmSourceStatus, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, evaluateCheckoutFreshness, runGitCommand, BLOCKING_FRESHNESS_VERDICTS, claimServiceStack, BUSY_EXIT_CODE, checkServiceStack, releaseServiceStack, readServiceStackStatus, resolvePreferences, OnboardingBlanketChoice, PreferenceKey, applyLlmSourceSelection, LlmSource, getDataDir, DEFAULT_LOCAL_LLM_BASE_URL, isValidLocalBaseUrl } from './chunk-32I7VRZ7.js';
1
+ import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir2, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, resolveElectronAppExecutablePath, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, getActiveElectronAppReleaseStream, buildToolInputJsonSchema, toolRequiresAuth, getCallerCredentials, parseElectronAppDirName, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, ElectronAppReleaseStream, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, buildLlmSourcePlan, describeLlmSourceStatus, resolveLlmSourceStatus, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, evaluateCheckoutFreshness, runGitCommand, BLOCKING_FRESHNESS_VERDICTS, claimServiceStack, BUSY_EXIT_CODE, checkServiceStack, releaseServiceStack, readServiceStackStatus, resolvePreferences, OnboardingBlanketChoice, PreferenceKey, applyLlmSourceSelection, LlmSource, getDataDir, DEFAULT_LOCAL_LLM_BASE_URL, isValidLocalBaseUrl } from './chunk-ORX3TIFC.js';
2
2
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
4
  import { v4 } from 'uuid';
@@ -1054,7 +1054,7 @@ async function resolveGsScreenshotUrls(report, opts) {
1054
1054
  if (gsUrls.length === 0) {
1055
1055
  return report;
1056
1056
  }
1057
- const mcps = await import('./src-ZAGX3JLC.js');
1057
+ const mcps = await import('./src-V72RTJZL.js');
1058
1058
  const credentials = await mcps.getCallerCredentialsAsync();
1059
1059
  if (!credentials.bearerToken && !credentials.apiKey) {
1060
1060
  stderrWrite(
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './chunk-OC6K3BQ6.js';
3
- import './chunk-32I7VRZ7.js';
2
+ import { runCli } from './chunk-U43SO3SZ.js';
3
+ import './chunk-ORX3TIFC.js';
4
4
 
5
5
  // src/cli/main.ts
6
6
  runCli().catch((error) => {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-OC6K3BQ6.js';
2
- export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-32I7VRZ7.js';
1
+ export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-U43SO3SZ.js';
2
+ export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-ORX3TIFC.js';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
4
- "version": "5.26.0-staging.222",
4
+ "version": "5.26.0-staging.224",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.26.0-staging.222",
7
+ "@muggleai/works@5.26.0-staging.224",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.26.0-staging.222",
3
+ "version": "5.26.0-staging.224",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
5
  "author": {
6
6
  "name": "Muggle AI",
@@ -2,7 +2,7 @@
2
2
  "name": "muggle",
3
3
  "displayName": "Muggle AI",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
- "version": "5.26.0-staging.222",
5
+ "version": "5.26.0-staging.224",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.26.0-staging.222",
7
+ "@muggleai/works@5.26.0-staging.224",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -28,6 +28,8 @@ A recorder that *clears* an obligation — a walkthrough posted, a failure diagn
28
28
 
29
29
  Each guardrail is a bash gate script in `../scripts/` holding a `guardrail_wants` pre-filter and the `guardrails.mjs` subcommand it feeds; the bundled `../scripts/guardrails.mjs` holds the decision logic (built from `src/guardrails/`, vitest-covered). The busy events — a shell command before and after it runs, and every turn end — register one `guardrail-dispatch.sh` command listing their gates, which reads the payload once, asks every gate's pre-filter in that one process, and starts Node once (`guardrails.mjs run <gates...>`) for just the gates that could fire, merging their responses. Rarer events call a gate script directly. Per-session state in `~/.muggle-ai/guardrails/<session_id>.json` tracks what fired. Any *failure* degrades to `{}` (allow) — a gate blocks only by an explicit, tested decision, never by accident; `guardrail-lib.sh` is the one place that falls back, and `run` isolates gates from each other.
30
30
 
31
+ Every `hooks.json` command enters through `../scripts/hook-entry.sh`, with the hook's script and arguments set as positional parameters first: `set -- guardrail-dispatch.sh guardrail-e2e-gate.sh …; . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh"`. Claude Code runs a hook command through Git Bash on Windows and through `/bin/sh` elsewhere. Inside Git Bash the entry sources the script into that same shell, so a hook costs the one Git Bash start Claude Code makes rather than a second `bash` with its own MSYS runtime init — measured at 0.3–1.2 s per firing on a loaded box. Anywhere else `/bin/sh` may be dash, so the entry is POSIX sh and hands the script to a bash of its own, as `bash "<script>"` did. A gate script tells it is the hook's own script — not one `guardrail-dispatch.sh` sourced for its pre-filter — through `guardrail_is_hook_script`, which reads the script path the entry records, or `$0` when bash ran the script.
32
+
31
33
  Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event starts no process at all. A pre-filter reads only the payload fields its subcommand judges (`guardrail_fields_match`: the command, the tool's name, the path read, the prompt), never the whole payload — a tool's output or a read file's contents would otherwise start Node whenever they merely mention a trigger. The PreToolUse deny gates go one step further: Claude Code's `if` rules (`Bash(*gh *)`, `Bash(*glab *)` and their `PowerShell` twins) launch them only for a command naming `gh` or `glab`, so every other shell call starts no hook process. A rule's leading `*` is load-bearing: it is what reaches a `gh` inside `bash -c "…"`. A gate that has spent its block budget stamps a `<gate>Released` flag, which its wrapper then pre-filters on — without it a released gate keeps cold-starting Node on every remaining turn end to answer `{}`, and the walkthrough gate keeps queuing provider scans to do it. That pre-filter is a second, looser copy of what `guardrails.mjs` matches, and it is the one place a guardrail can fail *silently*: a payload it drops — a skip marker, a reopen line, a comment edit — reaches no recorder, and the gate keeps demanding an action the user already took. Over-matching is free; under-matching is a dead escape hatch. `src/test/guardrails/hook-prefilter.test.ts` pins every payload each subcommand acts on against the wrapper guarding it, and derives the skip-marker tokens from source so a new marker is covered the moment it exists.
32
34
 
33
35
  ## Guardrails
@@ -58,12 +60,13 @@ Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event
58
60
 
59
61
  ## Codex
60
62
 
61
- Codex runs Claude Code-format plugin hooks, from `codex-hooks.json` rather than `hooks.json` — the Codex plugin manifest (`../.codex-plugin/plugin.json`) names it. `scripts/build-codex-hooks.mjs` generates it from `hooks.json` on every build, and `pnpm run verify:plugin` fails when the committed copy drifts, so `hooks.json` stays the one manifest to edit. The generated copy differs in four ways, each written down rather than guessed at runtime:
63
+ Codex runs Claude Code-format plugin hooks, from `codex-hooks.json` rather than `hooks.json` — the Codex plugin manifest (`../.codex-plugin/plugin.json`) names it. `scripts/build-codex-hooks.mjs` generates it from `hooks.json` on every build, and `pnpm run verify:plugin` fails when the committed copy drifts, so `hooks.json` stays the one manifest to edit. The generated copy differs in five ways, each written down rather than guessed at runtime:
62
64
 
63
65
  - **Host stamp.** Codex exports `CLAUDE_PLUGIN_ROOT` to plugin hooks for compatibility, so nothing in the environment tells a guardrail it is not in Claude Code. Every command runs under `env MUGGLE_HOOK_HOST=codex`, and the guardrails word their instructions for Codex (`$muggle:muggle-test`, not `/muggle:muggle-test`).
64
66
  - **Tool names.** A matcher naming a Claude Code tool becomes the Codex tool that plays its part — `AskUserQuestion` → `request_user_input` — and a group whose tools Codex lacks is dropped: Codex reports every shell call as `Bash`, opens files and skills through the shell, and delivers a background command's output as that command's own `Bash` event, so `PowerShell`, `Read`, `Skill` and `Monitor` never fire. An MCP tool reaches a Codex hook as `mcp__muggle__<tool>` with every character outside `[A-Za-z0-9_]` turned into `_` (`mcp__muggle__muggle_local_execute_replay`), so the MCP matchers are respelled; the wrappers' pre-filters and the guardrails' own tool checks accept either spelling.
65
67
  - **Windows.** Codex runs `commandWindows` through the session shell — PowerShell, or cmd.exe as a fallback — so every hook also gets one that starts with a bare `node` (both shells parse it alike; a quoted path there is a PowerShell syntax error) and hands the same script to Git Bash through `../scripts/codex-hook-windows.mjs`. It looks for Git Bash beside `git.exe`, then in the default install paths; `MUGGLE_HOOK_BASH` names one it would not find. With no Git Bash the launcher prints `{}` and succeeds — the same allow-by-default every guardrail falls back to.
66
68
  - **No `if` rules.** Codex has no counterpart to Claude Code's `if`, so the rule is dropped and the identical commands its variants leave collapse into one: under Codex the deny gates run on every shell call and their in-shell pre-filters decide.
69
+ - **No hook entry.** Codex starts every command as a process — `env` stamps the host, and on Windows the `node` launcher hands the script to Git Bash — so there is no shell to source into, and each Codex command names its script directly: `bash "<script>" <args>`.
67
70
 
68
71
  What Codex sends differs too, and the guardrails read either shape: a shell result arrives as the bare output string (normalized to `tool_response.output` in `hookInput.ts`), with no exit code; the Stop payload carries the closing message as `last_assistant_message`, which the capability-claim gate judges in place of the transcript, whose format is not Claude Code's; and a stage file opened with `cat` or `sed -n` counts as read, since there is no `Read` tool. With no structured question in Codex's default mode, a turn that closes on a question to the user is the post-merge offer there — under Codex only.
69
72
 
@@ -97,6 +100,7 @@ Every hook here fires on every tool call, prompt or turn end in every open sessi
97
100
  | Cap | Limit |
98
101
  | :-- | :-- |
99
102
  | Hook commands an irrelevant event launches per busy slot (PostToolUse on `Bash` and `Read`, Stop, UserPromptSubmit) | 1 (PreToolUse on `Bash`: 0, its `if` rules launch nothing for a command naming neither `gh` nor `glab`) |
103
+ | A hook's own `bash` launch inside Git Bash, where `hook-entry.sh` runs the script in place | 0 (elsewhere 1 per command) |
100
104
  | Programs started beyond each hook's own launch on an irrelevant event | 0 (Stop: 1, a transcript `tail` until the capability-claim gate has nudged; bash cannot seek) |
101
105
  | `node`, `gh`, `python` on that path | 0 |
102
106
  | Median wall time of one irrelevant firing, Linux/macOS | 100 ms |
@@ -6,13 +6,13 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/ensure-electron-app.sh\"",
9
+ "command": "set -- ensure-electron-app.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
10
10
  "async": false,
11
11
  "timeout": 5
12
12
  },
13
13
  {
14
14
  "type": "command",
15
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/reconcile-stale-watchers.sh\"",
15
+ "command": "set -- reconcile-stale-watchers.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
16
16
  "async": false,
17
17
  "timeout": 5
18
18
  }
@@ -26,28 +26,28 @@
26
26
  {
27
27
  "type": "command",
28
28
  "if": "Bash(*gh *)",
29
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
29
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
30
30
  "async": false,
31
31
  "timeout": 1
32
32
  },
33
33
  {
34
34
  "type": "command",
35
35
  "if": "Bash(*glab *)",
36
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
36
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
37
37
  "async": false,
38
38
  "timeout": 1
39
39
  },
40
40
  {
41
41
  "type": "command",
42
42
  "if": "PowerShell(*gh *)",
43
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
43
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
44
44
  "async": false,
45
45
  "timeout": 1
46
46
  },
47
47
  {
48
48
  "type": "command",
49
49
  "if": "PowerShell(*glab *)",
50
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
50
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
51
51
  "async": false,
52
52
  "timeout": 1
53
53
  }
@@ -58,7 +58,7 @@
58
58
  "hooks": [
59
59
  {
60
60
  "type": "command",
61
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-classify-gate.sh\"",
61
+ "command": "set -- guardrail-classify-gate.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
62
62
  "async": false,
63
63
  "timeout": 1
64
64
  }
@@ -71,7 +71,7 @@
71
71
  "hooks": [
72
72
  {
73
73
  "type": "command",
74
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-pr-opened.sh guardrail-record-tests.sh guardrail-pr-terminal.sh guardrail-record-stage-signals.sh guardrail-record-comment-replies.sh guardrail-record-stage-read.sh",
74
+ "command": "set -- guardrail-dispatch.sh guardrail-pr-opened.sh guardrail-record-tests.sh guardrail-pr-terminal.sh guardrail-record-stage-signals.sh guardrail-record-comment-replies.sh guardrail-record-stage-read.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
75
75
  "async": false,
76
76
  "timeout": 1
77
77
  }
@@ -82,7 +82,7 @@
82
82
  "hooks": [
83
83
  {
84
84
  "type": "command",
85
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-record-tests.sh\"",
85
+ "command": "set -- guardrail-record-tests.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
86
86
  "async": false,
87
87
  "timeout": 1
88
88
  }
@@ -93,7 +93,7 @@
93
93
  "hooks": [
94
94
  {
95
95
  "type": "command",
96
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-record-stage-signals.sh\"",
96
+ "command": "set -- guardrail-record-stage-signals.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
97
97
  "async": false,
98
98
  "timeout": 1
99
99
  }
@@ -104,7 +104,7 @@
104
104
  "hooks": [
105
105
  {
106
106
  "type": "command",
107
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-skill-stages.sh\"",
107
+ "command": "set -- guardrail-skill-stages.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
108
108
  "async": false,
109
109
  "timeout": 1
110
110
  }
@@ -115,7 +115,7 @@
115
115
  "hooks": [
116
116
  {
117
117
  "type": "command",
118
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-skill-stages.sh\"",
118
+ "command": "set -- guardrail-skill-stages.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
119
119
  "async": false,
120
120
  "timeout": 1
121
121
  }
@@ -126,7 +126,7 @@
126
126
  "hooks": [
127
127
  {
128
128
  "type": "command",
129
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-record-stage-read.sh\"",
129
+ "command": "set -- guardrail-record-stage-read.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
130
130
  "async": false,
131
131
  "timeout": 1
132
132
  }
@@ -137,7 +137,7 @@
137
137
  "hooks": [
138
138
  {
139
139
  "type": "command",
140
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-offer-ran.sh guardrail-record-delegation.sh",
140
+ "command": "set -- guardrail-dispatch.sh guardrail-offer-ran.sh guardrail-record-delegation.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
141
141
  "async": false,
142
142
  "timeout": 1
143
143
  }
@@ -149,7 +149,7 @@
149
149
  "hooks": [
150
150
  {
151
151
  "type": "command",
152
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh",
152
+ "command": "set -- guardrail-dispatch.sh guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
153
153
  "async": false,
154
154
  "timeout": 1
155
155
  }
@@ -161,7 +161,7 @@
161
161
  "hooks": [
162
162
  {
163
163
  "type": "command",
164
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-build-router.sh\"",
164
+ "command": "set -- guardrail-build-router.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
165
165
  "async": false,
166
166
  "timeout": 1
167
167
  }
@@ -29,6 +29,6 @@ guardrail_wants() {
29
29
  && ! guardrail_state_has '"buildSkipped": true'
30
30
  }
31
31
 
32
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
32
+ if guardrail_is_hook_script; then
33
33
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
34
34
  fi
@@ -30,6 +30,6 @@ guardrail_wants() {
30
30
  guardrail_fields_match prompt '(implement|build|add|create|write|fix|refactor|wire up|hook up|make|change the|conflict|merged|passing|green)'
31
31
  }
32
32
 
33
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
33
+ if guardrail_is_hook_script; then
34
34
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
35
35
  fi
@@ -49,6 +49,6 @@ guardrail_wants() {
49
49
  return "$matched"
50
50
  }
51
51
 
52
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
52
+ if guardrail_is_hook_script; then
53
53
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
54
54
  fi
@@ -24,6 +24,6 @@ guardrail_wants() {
24
24
  guardrail_payload_matches 'muggle[-_]local[-_](execute[-_]test[-_]generation|execute[-_]replay)'
25
25
  }
26
26
 
27
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
27
+ if guardrail_is_hook_script; then
28
28
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
29
29
  fi
@@ -26,6 +26,6 @@ guardrail_wants() {
26
26
  fi
27
27
  }
28
28
 
29
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
29
+ if guardrail_is_hook_script; then
30
30
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
31
31
  fi
@@ -27,6 +27,6 @@ guardrail_wants() {
27
27
  && ! guardrail_state_has '"debugSkipped": true'
28
28
  }
29
29
 
30
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
30
+ if guardrail_is_hook_script; then
31
31
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
32
32
  fi
@@ -28,6 +28,6 @@ guardrail_wants() {
28
28
  && ! guardrail_state_has '"e2eRun": true'
29
29
  }
30
30
 
31
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
31
+ if guardrail_is_hook_script; then
32
32
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
33
33
  fi
@@ -108,6 +108,12 @@ guardrail_state_has() {
108
108
  [[ $GUARDRAIL_STATE == *"$1"* ]]
109
109
  }
110
110
 
111
+ # Whether the gate script calling this is the hook's own script — run by bash, or sourced by hook-entry.sh into the
112
+ # shell Claude Code started — rather than a gate guardrail-dispatch.sh sourced only to read its pre-filter.
113
+ guardrail_is_hook_script() {
114
+ [[ ${BASH_SOURCE[1]} == "${MUGGLE_HOOK_SCRIPT:-$0}" ]]
115
+ }
116
+
111
117
  # Runs guardrails.mjs on the payload. Never blocks a turn: any failure degrades to {}.
112
118
  guardrail_run_node() {
113
119
  local root="${CLAUDE_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-}}"
@@ -22,6 +22,6 @@ guardrail_wants() {
22
22
  && ! guardrail_state_has '"terminalPending": []'
23
23
  }
24
24
 
25
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
25
+ if guardrail_is_hook_script; then
26
26
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
27
27
  fi
@@ -21,6 +21,6 @@ guardrail_wants() {
21
21
  guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(create|ready)|glab[[:space:]]+mr[[:space:]]+(create|update)'
22
22
  }
23
23
 
24
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
24
+ if guardrail_is_hook_script; then
25
25
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
26
26
  fi
@@ -25,6 +25,6 @@ guardrail_wants() {
25
25
  guardrail_payload_matches '(merged|closed|reopened) pull request|TERMINAL pr='
26
26
  }
27
27
 
28
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
28
+ if guardrail_is_hook_script; then
29
29
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
30
30
  fi
@@ -28,6 +28,6 @@ guardrail_wants() {
28
28
  guardrail_payload_matches 'reviewThreads|merge_requests/[0-9]+/discussions|comments/[0-9]+/replies|discussions/[A-Za-z0-9_-]+/notes|MUGGLE_[A-Z0-9_]+_SKIP'
29
29
  }
30
30
 
31
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
31
+ if guardrail_is_hook_script; then
32
32
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
33
33
  fi
@@ -20,6 +20,6 @@ guardrail_wants() {
20
20
  guardrail_payload_matches 'acceptance-tester'
21
21
  }
22
22
 
23
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
23
+ if guardrail_is_hook_script; then
24
24
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
25
25
  fi
@@ -29,6 +29,6 @@ guardrail_wants() {
29
29
  guardrail_fields_match cwd file_path command 'skills.*\.md'
30
30
  }
31
31
 
32
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
32
+ if guardrail_is_hook_script; then
33
33
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
34
34
  fi
@@ -23,6 +23,6 @@ guardrail_wants() {
23
23
  guardrail_payload_matches 'MUGGLE_[A-Z0-9_]+_SKIP|muggle.*(telemetry[-_]event[-_]emit|user[-_]feedback[-_]create)'
24
24
  }
25
25
 
26
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
26
+ if guardrail_is_hook_script; then
27
27
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
28
28
  fi
@@ -35,6 +35,6 @@ guardrail_wants() {
35
35
  || guardrail_fields_match tool_name 'muggle.*(execute|test[-_]generation|replay)'
36
36
  }
37
37
 
38
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
38
+ if guardrail_is_hook_script; then
39
39
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
40
40
  fi
@@ -27,6 +27,6 @@ guardrail_wants() {
27
27
  guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
28
28
  }
29
29
 
30
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
30
+ if guardrail_is_hook_script; then
31
31
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
32
32
  fi
@@ -22,6 +22,6 @@ guardrail_wants() {
22
22
  guardrail_payload_matches 'resolveReviewThread|resolved=(true|false)'
23
23
  }
24
24
 
25
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
25
+ if guardrail_is_hook_script; then
26
26
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
27
27
  fi
@@ -41,6 +41,6 @@ guardrail_wants() {
41
41
  return 1
42
42
  }
43
43
 
44
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
44
+ if guardrail_is_hook_script; then
45
45
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
46
46
  fi
@@ -29,6 +29,6 @@ guardrail_wants() {
29
29
  && ! guardrail_state_has '"stageSkipped": true'
30
30
  }
31
31
 
32
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
32
+ if guardrail_is_hook_script; then
33
33
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
34
34
  fi
@@ -26,6 +26,6 @@ guardrail_wants() {
26
26
  && ! guardrail_state_has '"terminalPending": []'
27
27
  }
28
28
 
29
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
29
+ if guardrail_is_hook_script; then
30
30
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
31
31
  fi
@@ -32,6 +32,6 @@ guardrail_wants() {
32
32
  guardrail_state_has '"e2eSkipDeclaration": {' && ! guardrail_state_has '"e2eSkipSettledOnPrs": true'
33
33
  }
34
34
 
35
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
35
+ if guardrail_is_hook_script; then
36
36
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
37
37
  fi
@@ -24,6 +24,6 @@ guardrail_wants() {
24
24
  guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
25
25
  }
26
26
 
27
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
27
+ if guardrail_is_hook_script; then
28
28
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
29
29
  fi
@@ -43,6 +43,6 @@ guardrail_wants() {
43
43
  return 1
44
44
  }
45
45
 
46
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
46
+ if guardrail_is_hook_script; then
47
47
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
48
48
  fi
@@ -25,6 +25,6 @@ guardrail_wants() {
25
25
  && ! guardrail_state_has '"watchSkipped": true'
26
26
  }
27
27
 
28
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
28
+ if guardrail_is_hook_script; then
29
29
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
30
30
  fi
@@ -0,0 +1,23 @@
1
+ # Entry for every hooks.json command, sourced with the hook's script and its arguments as the positional parameters:
2
+ #
3
+ # set -- guardrail-dispatch.sh guardrail-e2e-gate.sh ...; . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh"
4
+ #
5
+ # Claude Code runs a hook command through Git Bash on Windows, where each process start costs 50 ms healthy and
6
+ # seconds under load, so there the script is sourced into that same shell rather than handed to a second bash.
7
+ # Everywhere else the command runs under /bin/sh, which may not be bash, so the script gets a bash of its own.
8
+ # POSIX sh throughout, since that /bin/sh parses this file. The arguments travel through `set --` because a dot
9
+ # command taking arguments is a bash extension dash does not have.
10
+
11
+ hook_entry_script="${CLAUDE_PLUGIN_ROOT}/scripts/$1"
12
+ shift
13
+ case ${OSTYPE:-} in
14
+ msys* | cygwin*)
15
+ # guardrail-lib.sh compares this against BASH_SOURCE to tell the hook's own script from a gate
16
+ # guardrail-dispatch.sh sources only to read its pre-filter; bash running a script tells it through $0.
17
+ MUGGLE_HOOK_SCRIPT=$hook_entry_script
18
+ . "$hook_entry_script"
19
+ ;;
20
+ *)
21
+ exec bash "$hook_entry_script" "$@"
22
+ ;;
23
+ esac
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "release": "5.18.0",
3
- "buildId": "run-222-1",
4
- "commitSha": "d13e8ee01e89518a04d0e13dc4b54acdaf8f8b5f",
5
- "buildTime": "2026-10-26T22:26:04Z",
3
+ "buildId": "run-224-1",
4
+ "commitSha": "1ddd76e1eb53a44d47c3d9c3966eb2d1ee2c8be5",
5
+ "buildTime": "2026-10-26T22:56:28Z",
6
6
  "serviceName": "muggle-ai-works-mcp"
7
7
  }
@@ -1 +1 @@
1
- export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, BUSY_EXIT_CODE, CheckoutFreshnessVerdict, DEFAULT_LOCAL_LLM_BASE_URL, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, LLM_CREDENTIALS_FILE_MODE, LLM_CREDENTIALS_FILE_NAME, LLM_SOURCE_HEADER, LLM_SOURCE_OPTIONS, LLM_SOURCE_OWNED_ENV_NAMES, LLM_SOURCE_PROMPT, LLM_SOURCE_SCOPE_NOTE, LlmSource, MASKED_API_KEY_PREFIX, MASKED_API_KEY_VISIBLE_CHARS, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, StackCheckVerdict, StackClaimVerdict, StackPortAction, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyLlmSourceSelection, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildLlmSourcePlan, buildOnboardingPlan, buildToolInputJsonSchema, calculateFileChecksum, checkServiceStack, claimServiceStack, completeOnboarding, createApiKeyWithToken, createChildLogger, decideStackClaim, decideStackRelease, decideStackRenewal, deleteApiKeyData, deleteCredentials, describeLlmSourceStatus, e2e_exports as e2e, evaluateCheckoutFreshness, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir2 as getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLlmSourceOption, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, isValidLocalBaseUrl, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, maskLlmApiKey, mcp_exports as mcp, needsConflict, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, portOfUrl, e2e_exports as qa, readPreferencesMetadata, readRunView, readServiceStackStatus, reconcileProjectPreferences, recordOnboardingSkip, releaseServiceStack, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveLlmSourceStatus, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toDisplayRef, toolRequiresAuth, validatePreference, verifyFileChecksum, writeLlmEnvBlock, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-32I7VRZ7.js';
1
+ export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, BUSY_EXIT_CODE, CheckoutFreshnessVerdict, DEFAULT_LOCAL_LLM_BASE_URL, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, LLM_CREDENTIALS_FILE_MODE, LLM_CREDENTIALS_FILE_NAME, LLM_SOURCE_HEADER, LLM_SOURCE_OPTIONS, LLM_SOURCE_OWNED_ENV_NAMES, LLM_SOURCE_PROMPT, LLM_SOURCE_SCOPE_NOTE, LlmSource, MASKED_API_KEY_PREFIX, MASKED_API_KEY_VISIBLE_CHARS, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, StackCheckVerdict, StackClaimVerdict, StackPortAction, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyLlmSourceSelection, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildLlmSourcePlan, buildOnboardingPlan, buildToolInputJsonSchema, calculateFileChecksum, checkServiceStack, claimServiceStack, completeOnboarding, createApiKeyWithToken, createChildLogger, decideStackClaim, decideStackRelease, decideStackRenewal, deleteApiKeyData, deleteCredentials, describeLlmSourceStatus, e2e_exports as e2e, evaluateCheckoutFreshness, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir2 as getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLlmSourceOption, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, isValidLocalBaseUrl, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, maskLlmApiKey, mcp_exports as mcp, needsConflict, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, portOfUrl, e2e_exports as qa, readPreferencesMetadata, readRunView, readServiceStackStatus, reconcileProjectPreferences, recordOnboardingSkip, releaseServiceStack, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveLlmSourceStatus, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toDisplayRef, toolRequiresAuth, validatePreference, verifyFileChecksum, writeLlmEnvBlock, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-ORX3TIFC.js';
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": "5.26.0-staging.222",
4
+ "version": "5.26.0-staging.224",
5
5
  "description": "13 years of Microsoft hyperscale engineering, packaged as a harness for your AI coding agent.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
4
- "version": "5.26.0-staging.222",
4
+ "version": "5.26.0-staging.224",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.26.0-staging.222",
7
+ "@muggleai/works@5.26.0-staging.224",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.26.0-staging.222",
3
+ "version": "5.26.0-staging.224",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
5
  "author": {
6
6
  "name": "Muggle AI",
@@ -2,7 +2,7 @@
2
2
  "name": "muggle",
3
3
  "displayName": "Muggle AI",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
- "version": "5.26.0-staging.222",
5
+ "version": "5.26.0-staging.224",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
package/plugin/.mcp.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.26.0-staging.222",
7
+ "@muggleai/works@5.26.0-staging.224",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -28,6 +28,8 @@ A recorder that *clears* an obligation — a walkthrough posted, a failure diagn
28
28
 
29
29
  Each guardrail is a bash gate script in `../scripts/` holding a `guardrail_wants` pre-filter and the `guardrails.mjs` subcommand it feeds; the bundled `../scripts/guardrails.mjs` holds the decision logic (built from `src/guardrails/`, vitest-covered). The busy events — a shell command before and after it runs, and every turn end — register one `guardrail-dispatch.sh` command listing their gates, which reads the payload once, asks every gate's pre-filter in that one process, and starts Node once (`guardrails.mjs run <gates...>`) for just the gates that could fire, merging their responses. Rarer events call a gate script directly. Per-session state in `~/.muggle-ai/guardrails/<session_id>.json` tracks what fired. Any *failure* degrades to `{}` (allow) — a gate blocks only by an explicit, tested decision, never by accident; `guardrail-lib.sh` is the one place that falls back, and `run` isolates gates from each other.
30
30
 
31
+ Every `hooks.json` command enters through `../scripts/hook-entry.sh`, with the hook's script and arguments set as positional parameters first: `set -- guardrail-dispatch.sh guardrail-e2e-gate.sh …; . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh"`. Claude Code runs a hook command through Git Bash on Windows and through `/bin/sh` elsewhere. Inside Git Bash the entry sources the script into that same shell, so a hook costs the one Git Bash start Claude Code makes rather than a second `bash` with its own MSYS runtime init — measured at 0.3–1.2 s per firing on a loaded box. Anywhere else `/bin/sh` may be dash, so the entry is POSIX sh and hands the script to a bash of its own, as `bash "<script>"` did. A gate script tells it is the hook's own script — not one `guardrail-dispatch.sh` sourced for its pre-filter — through `guardrail_is_hook_script`, which reads the script path the entry records, or `$0` when bash ran the script.
32
+
31
33
  Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event starts no process at all. A pre-filter reads only the payload fields its subcommand judges (`guardrail_fields_match`: the command, the tool's name, the path read, the prompt), never the whole payload — a tool's output or a read file's contents would otherwise start Node whenever they merely mention a trigger. The PreToolUse deny gates go one step further: Claude Code's `if` rules (`Bash(*gh *)`, `Bash(*glab *)` and their `PowerShell` twins) launch them only for a command naming `gh` or `glab`, so every other shell call starts no hook process. A rule's leading `*` is load-bearing: it is what reaches a `gh` inside `bash -c "…"`. A gate that has spent its block budget stamps a `<gate>Released` flag, which its wrapper then pre-filters on — without it a released gate keeps cold-starting Node on every remaining turn end to answer `{}`, and the walkthrough gate keeps queuing provider scans to do it. That pre-filter is a second, looser copy of what `guardrails.mjs` matches, and it is the one place a guardrail can fail *silently*: a payload it drops — a skip marker, a reopen line, a comment edit — reaches no recorder, and the gate keeps demanding an action the user already took. Over-matching is free; under-matching is a dead escape hatch. `src/test/guardrails/hook-prefilter.test.ts` pins every payload each subcommand acts on against the wrapper guarding it, and derives the skip-marker tokens from source so a new marker is covered the moment it exists.
32
34
 
33
35
  ## Guardrails
@@ -58,12 +60,13 @@ Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event
58
60
 
59
61
  ## Codex
60
62
 
61
- Codex runs Claude Code-format plugin hooks, from `codex-hooks.json` rather than `hooks.json` — the Codex plugin manifest (`../.codex-plugin/plugin.json`) names it. `scripts/build-codex-hooks.mjs` generates it from `hooks.json` on every build, and `pnpm run verify:plugin` fails when the committed copy drifts, so `hooks.json` stays the one manifest to edit. The generated copy differs in four ways, each written down rather than guessed at runtime:
63
+ Codex runs Claude Code-format plugin hooks, from `codex-hooks.json` rather than `hooks.json` — the Codex plugin manifest (`../.codex-plugin/plugin.json`) names it. `scripts/build-codex-hooks.mjs` generates it from `hooks.json` on every build, and `pnpm run verify:plugin` fails when the committed copy drifts, so `hooks.json` stays the one manifest to edit. The generated copy differs in five ways, each written down rather than guessed at runtime:
62
64
 
63
65
  - **Host stamp.** Codex exports `CLAUDE_PLUGIN_ROOT` to plugin hooks for compatibility, so nothing in the environment tells a guardrail it is not in Claude Code. Every command runs under `env MUGGLE_HOOK_HOST=codex`, and the guardrails word their instructions for Codex (`$muggle:muggle-test`, not `/muggle:muggle-test`).
64
66
  - **Tool names.** A matcher naming a Claude Code tool becomes the Codex tool that plays its part — `AskUserQuestion` → `request_user_input` — and a group whose tools Codex lacks is dropped: Codex reports every shell call as `Bash`, opens files and skills through the shell, and delivers a background command's output as that command's own `Bash` event, so `PowerShell`, `Read`, `Skill` and `Monitor` never fire. An MCP tool reaches a Codex hook as `mcp__muggle__<tool>` with every character outside `[A-Za-z0-9_]` turned into `_` (`mcp__muggle__muggle_local_execute_replay`), so the MCP matchers are respelled; the wrappers' pre-filters and the guardrails' own tool checks accept either spelling.
65
67
  - **Windows.** Codex runs `commandWindows` through the session shell — PowerShell, or cmd.exe as a fallback — so every hook also gets one that starts with a bare `node` (both shells parse it alike; a quoted path there is a PowerShell syntax error) and hands the same script to Git Bash through `../scripts/codex-hook-windows.mjs`. It looks for Git Bash beside `git.exe`, then in the default install paths; `MUGGLE_HOOK_BASH` names one it would not find. With no Git Bash the launcher prints `{}` and succeeds — the same allow-by-default every guardrail falls back to.
66
68
  - **No `if` rules.** Codex has no counterpart to Claude Code's `if`, so the rule is dropped and the identical commands its variants leave collapse into one: under Codex the deny gates run on every shell call and their in-shell pre-filters decide.
69
+ - **No hook entry.** Codex starts every command as a process — `env` stamps the host, and on Windows the `node` launcher hands the script to Git Bash — so there is no shell to source into, and each Codex command names its script directly: `bash "<script>" <args>`.
67
70
 
68
71
  What Codex sends differs too, and the guardrails read either shape: a shell result arrives as the bare output string (normalized to `tool_response.output` in `hookInput.ts`), with no exit code; the Stop payload carries the closing message as `last_assistant_message`, which the capability-claim gate judges in place of the transcript, whose format is not Claude Code's; and a stage file opened with `cat` or `sed -n` counts as read, since there is no `Read` tool. With no structured question in Codex's default mode, a turn that closes on a question to the user is the post-merge offer there — under Codex only.
69
72
 
@@ -97,6 +100,7 @@ Every hook here fires on every tool call, prompt or turn end in every open sessi
97
100
  | Cap | Limit |
98
101
  | :-- | :-- |
99
102
  | Hook commands an irrelevant event launches per busy slot (PostToolUse on `Bash` and `Read`, Stop, UserPromptSubmit) | 1 (PreToolUse on `Bash`: 0, its `if` rules launch nothing for a command naming neither `gh` nor `glab`) |
103
+ | A hook's own `bash` launch inside Git Bash, where `hook-entry.sh` runs the script in place | 0 (elsewhere 1 per command) |
100
104
  | Programs started beyond each hook's own launch on an irrelevant event | 0 (Stop: 1, a transcript `tail` until the capability-claim gate has nudged; bash cannot seek) |
101
105
  | `node`, `gh`, `python` on that path | 0 |
102
106
  | Median wall time of one irrelevant firing, Linux/macOS | 100 ms |
@@ -6,13 +6,13 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/ensure-electron-app.sh\"",
9
+ "command": "set -- ensure-electron-app.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
10
10
  "async": false,
11
11
  "timeout": 5
12
12
  },
13
13
  {
14
14
  "type": "command",
15
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/reconcile-stale-watchers.sh\"",
15
+ "command": "set -- reconcile-stale-watchers.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
16
16
  "async": false,
17
17
  "timeout": 5
18
18
  }
@@ -26,28 +26,28 @@
26
26
  {
27
27
  "type": "command",
28
28
  "if": "Bash(*gh *)",
29
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
29
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
30
30
  "async": false,
31
31
  "timeout": 1
32
32
  },
33
33
  {
34
34
  "type": "command",
35
35
  "if": "Bash(*glab *)",
36
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
36
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
37
37
  "async": false,
38
38
  "timeout": 1
39
39
  },
40
40
  {
41
41
  "type": "command",
42
42
  "if": "PowerShell(*gh *)",
43
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
43
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
44
44
  "async": false,
45
45
  "timeout": 1
46
46
  },
47
47
  {
48
48
  "type": "command",
49
49
  "if": "PowerShell(*glab *)",
50
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh",
50
+ "command": "set -- guardrail-dispatch.sh guardrail-report-format.sh guardrail-resolve-gate.sh guardrail-walkthrough-heading.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
51
51
  "async": false,
52
52
  "timeout": 1
53
53
  }
@@ -58,7 +58,7 @@
58
58
  "hooks": [
59
59
  {
60
60
  "type": "command",
61
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-classify-gate.sh\"",
61
+ "command": "set -- guardrail-classify-gate.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
62
62
  "async": false,
63
63
  "timeout": 1
64
64
  }
@@ -71,7 +71,7 @@
71
71
  "hooks": [
72
72
  {
73
73
  "type": "command",
74
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-pr-opened.sh guardrail-record-tests.sh guardrail-pr-terminal.sh guardrail-record-stage-signals.sh guardrail-record-comment-replies.sh guardrail-record-stage-read.sh",
74
+ "command": "set -- guardrail-dispatch.sh guardrail-pr-opened.sh guardrail-record-tests.sh guardrail-pr-terminal.sh guardrail-record-stage-signals.sh guardrail-record-comment-replies.sh guardrail-record-stage-read.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
75
75
  "async": false,
76
76
  "timeout": 1
77
77
  }
@@ -82,7 +82,7 @@
82
82
  "hooks": [
83
83
  {
84
84
  "type": "command",
85
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-record-tests.sh\"",
85
+ "command": "set -- guardrail-record-tests.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
86
86
  "async": false,
87
87
  "timeout": 1
88
88
  }
@@ -93,7 +93,7 @@
93
93
  "hooks": [
94
94
  {
95
95
  "type": "command",
96
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-record-stage-signals.sh\"",
96
+ "command": "set -- guardrail-record-stage-signals.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
97
97
  "async": false,
98
98
  "timeout": 1
99
99
  }
@@ -104,7 +104,7 @@
104
104
  "hooks": [
105
105
  {
106
106
  "type": "command",
107
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-skill-stages.sh\"",
107
+ "command": "set -- guardrail-skill-stages.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
108
108
  "async": false,
109
109
  "timeout": 1
110
110
  }
@@ -115,7 +115,7 @@
115
115
  "hooks": [
116
116
  {
117
117
  "type": "command",
118
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-skill-stages.sh\"",
118
+ "command": "set -- guardrail-skill-stages.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
119
119
  "async": false,
120
120
  "timeout": 1
121
121
  }
@@ -126,7 +126,7 @@
126
126
  "hooks": [
127
127
  {
128
128
  "type": "command",
129
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-record-stage-read.sh\"",
129
+ "command": "set -- guardrail-record-stage-read.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
130
130
  "async": false,
131
131
  "timeout": 1
132
132
  }
@@ -137,7 +137,7 @@
137
137
  "hooks": [
138
138
  {
139
139
  "type": "command",
140
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-offer-ran.sh guardrail-record-delegation.sh",
140
+ "command": "set -- guardrail-dispatch.sh guardrail-offer-ran.sh guardrail-record-delegation.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
141
141
  "async": false,
142
142
  "timeout": 1
143
143
  }
@@ -149,7 +149,7 @@
149
149
  "hooks": [
150
150
  {
151
151
  "type": "command",
152
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh",
152
+ "command": "set -- guardrail-dispatch.sh guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
153
153
  "async": false,
154
154
  "timeout": 1
155
155
  }
@@ -161,7 +161,7 @@
161
161
  "hooks": [
162
162
  {
163
163
  "type": "command",
164
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-build-router.sh\"",
164
+ "command": "set -- guardrail-build-router.sh; . \"${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh\"",
165
165
  "async": false,
166
166
  "timeout": 1
167
167
  }
@@ -29,6 +29,6 @@ guardrail_wants() {
29
29
  && ! guardrail_state_has '"buildSkipped": true'
30
30
  }
31
31
 
32
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
32
+ if guardrail_is_hook_script; then
33
33
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
34
34
  fi
@@ -30,6 +30,6 @@ guardrail_wants() {
30
30
  guardrail_fields_match prompt '(implement|build|add|create|write|fix|refactor|wire up|hook up|make|change the|conflict|merged|passing|green)'
31
31
  }
32
32
 
33
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
33
+ if guardrail_is_hook_script; then
34
34
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
35
35
  fi
@@ -49,6 +49,6 @@ guardrail_wants() {
49
49
  return "$matched"
50
50
  }
51
51
 
52
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
52
+ if guardrail_is_hook_script; then
53
53
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
54
54
  fi
@@ -24,6 +24,6 @@ guardrail_wants() {
24
24
  guardrail_payload_matches 'muggle[-_]local[-_](execute[-_]test[-_]generation|execute[-_]replay)'
25
25
  }
26
26
 
27
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
27
+ if guardrail_is_hook_script; then
28
28
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
29
29
  fi
@@ -26,6 +26,6 @@ guardrail_wants() {
26
26
  fi
27
27
  }
28
28
 
29
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
29
+ if guardrail_is_hook_script; then
30
30
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
31
31
  fi
@@ -27,6 +27,6 @@ guardrail_wants() {
27
27
  && ! guardrail_state_has '"debugSkipped": true'
28
28
  }
29
29
 
30
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
30
+ if guardrail_is_hook_script; then
31
31
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
32
32
  fi
@@ -28,6 +28,6 @@ guardrail_wants() {
28
28
  && ! guardrail_state_has '"e2eRun": true'
29
29
  }
30
30
 
31
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
31
+ if guardrail_is_hook_script; then
32
32
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
33
33
  fi
@@ -108,6 +108,12 @@ guardrail_state_has() {
108
108
  [[ $GUARDRAIL_STATE == *"$1"* ]]
109
109
  }
110
110
 
111
+ # Whether the gate script calling this is the hook's own script — run by bash, or sourced by hook-entry.sh into the
112
+ # shell Claude Code started — rather than a gate guardrail-dispatch.sh sourced only to read its pre-filter.
113
+ guardrail_is_hook_script() {
114
+ [[ ${BASH_SOURCE[1]} == "${MUGGLE_HOOK_SCRIPT:-$0}" ]]
115
+ }
116
+
111
117
  # Runs guardrails.mjs on the payload. Never blocks a turn: any failure degrades to {}.
112
118
  guardrail_run_node() {
113
119
  local root="${CLAUDE_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-}}"
@@ -22,6 +22,6 @@ guardrail_wants() {
22
22
  && ! guardrail_state_has '"terminalPending": []'
23
23
  }
24
24
 
25
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
25
+ if guardrail_is_hook_script; then
26
26
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
27
27
  fi
@@ -21,6 +21,6 @@ guardrail_wants() {
21
21
  guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(create|ready)|glab[[:space:]]+mr[[:space:]]+(create|update)'
22
22
  }
23
23
 
24
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
24
+ if guardrail_is_hook_script; then
25
25
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
26
26
  fi
@@ -25,6 +25,6 @@ guardrail_wants() {
25
25
  guardrail_payload_matches '(merged|closed|reopened) pull request|TERMINAL pr='
26
26
  }
27
27
 
28
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
28
+ if guardrail_is_hook_script; then
29
29
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
30
30
  fi
@@ -28,6 +28,6 @@ guardrail_wants() {
28
28
  guardrail_payload_matches 'reviewThreads|merge_requests/[0-9]+/discussions|comments/[0-9]+/replies|discussions/[A-Za-z0-9_-]+/notes|MUGGLE_[A-Z0-9_]+_SKIP'
29
29
  }
30
30
 
31
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
31
+ if guardrail_is_hook_script; then
32
32
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
33
33
  fi
@@ -20,6 +20,6 @@ guardrail_wants() {
20
20
  guardrail_payload_matches 'acceptance-tester'
21
21
  }
22
22
 
23
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
23
+ if guardrail_is_hook_script; then
24
24
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
25
25
  fi
@@ -29,6 +29,6 @@ guardrail_wants() {
29
29
  guardrail_fields_match cwd file_path command 'skills.*\.md'
30
30
  }
31
31
 
32
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
32
+ if guardrail_is_hook_script; then
33
33
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
34
34
  fi
@@ -23,6 +23,6 @@ guardrail_wants() {
23
23
  guardrail_payload_matches 'MUGGLE_[A-Z0-9_]+_SKIP|muggle.*(telemetry[-_]event[-_]emit|user[-_]feedback[-_]create)'
24
24
  }
25
25
 
26
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
26
+ if guardrail_is_hook_script; then
27
27
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
28
28
  fi
@@ -35,6 +35,6 @@ guardrail_wants() {
35
35
  || guardrail_fields_match tool_name 'muggle.*(execute|test[-_]generation|replay)'
36
36
  }
37
37
 
38
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
38
+ if guardrail_is_hook_script; then
39
39
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
40
40
  fi
@@ -27,6 +27,6 @@ guardrail_wants() {
27
27
  guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
28
28
  }
29
29
 
30
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
30
+ if guardrail_is_hook_script; then
31
31
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
32
32
  fi
@@ -22,6 +22,6 @@ guardrail_wants() {
22
22
  guardrail_payload_matches 'resolveReviewThread|resolved=(true|false)'
23
23
  }
24
24
 
25
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
25
+ if guardrail_is_hook_script; then
26
26
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
27
27
  fi
@@ -41,6 +41,6 @@ guardrail_wants() {
41
41
  return 1
42
42
  }
43
43
 
44
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
44
+ if guardrail_is_hook_script; then
45
45
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
46
46
  fi
@@ -29,6 +29,6 @@ guardrail_wants() {
29
29
  && ! guardrail_state_has '"stageSkipped": true'
30
30
  }
31
31
 
32
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
32
+ if guardrail_is_hook_script; then
33
33
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
34
34
  fi
@@ -26,6 +26,6 @@ guardrail_wants() {
26
26
  && ! guardrail_state_has '"terminalPending": []'
27
27
  }
28
28
 
29
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
29
+ if guardrail_is_hook_script; then
30
30
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
31
31
  fi
@@ -32,6 +32,6 @@ guardrail_wants() {
32
32
  guardrail_state_has '"e2eSkipDeclaration": {' && ! guardrail_state_has '"e2eSkipSettledOnPrs": true'
33
33
  }
34
34
 
35
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
35
+ if guardrail_is_hook_script; then
36
36
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
37
37
  fi
@@ -24,6 +24,6 @@ guardrail_wants() {
24
24
  guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
25
25
  }
26
26
 
27
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
27
+ if guardrail_is_hook_script; then
28
28
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
29
29
  fi
@@ -43,6 +43,6 @@ guardrail_wants() {
43
43
  return 1
44
44
  }
45
45
 
46
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
46
+ if guardrail_is_hook_script; then
47
47
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
48
48
  fi
@@ -25,6 +25,6 @@ guardrail_wants() {
25
25
  && ! guardrail_state_has '"watchSkipped": true'
26
26
  }
27
27
 
28
- if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
28
+ if guardrail_is_hook_script; then
29
29
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
30
30
  fi
@@ -0,0 +1,23 @@
1
+ # Entry for every hooks.json command, sourced with the hook's script and its arguments as the positional parameters:
2
+ #
3
+ # set -- guardrail-dispatch.sh guardrail-e2e-gate.sh ...; . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-entry.sh"
4
+ #
5
+ # Claude Code runs a hook command through Git Bash on Windows, where each process start costs 50 ms healthy and
6
+ # seconds under load, so there the script is sourced into that same shell rather than handed to a second bash.
7
+ # Everywhere else the command runs under /bin/sh, which may not be bash, so the script gets a bash of its own.
8
+ # POSIX sh throughout, since that /bin/sh parses this file. The arguments travel through `set --` because a dot
9
+ # command taking arguments is a bash extension dash does not have.
10
+
11
+ hook_entry_script="${CLAUDE_PLUGIN_ROOT}/scripts/$1"
12
+ shift
13
+ case ${OSTYPE:-} in
14
+ msys* | cygwin*)
15
+ # guardrail-lib.sh compares this against BASH_SOURCE to tell the hook's own script from a gate
16
+ # guardrail-dispatch.sh sources only to read its pre-filter; bash running a script tells it through $0.
17
+ MUGGLE_HOOK_SCRIPT=$hook_entry_script
18
+ . "$hook_entry_script"
19
+ ;;
20
+ *)
21
+ exec bash "$hook_entry_script" "$@"
22
+ ;;
23
+ esac