passport-bridge 0.16.2 → 0.16.3

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.
package/README.md CHANGED
@@ -46,34 +46,34 @@ passport run github_search_issues '{"query":"SSO"}'
46
46
 
47
47
  ## Commands
48
48
 
49
- | Command | Purpose |
50
- | --- | --- |
51
- | `init [--yes] [--move-keys] [--no-open] [--cloud <origin>] [--skip-apps\|--skip-agents\|--skip-guard] [--verbose] [--json]` | Set up Passport for this computer's agents in one pass. Every step asks first, can be skipped, and is safe to run again. |
52
- | `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active. |
53
- | `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
54
- | `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
55
- | `status` | Workspace, member, agent, and app connection states, plus Autopilot presets, team floors, and how old this computer's copy of your rules is. |
56
- | `doctor` | Check Node, credential-file safety, HTTPS policy, `/healthz`, auth, serverInfo, and CLI protocol. Exit 1 on a failed check, with the full report. |
57
- | `ready` | Readiness preflight for automation; gate on its `ready` field and exit code. |
58
- | `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog. |
59
- | `describe <tool>` | One exact definition with its full parameter schema. |
60
- | `run <tool> [json]` | Run a tool through Passport governance. |
61
- | `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
62
- | `resources [uri] [--out <file>]` | List or read MCP resources. |
63
- | `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
64
- | `scan [--path <dir>] [--verbose] [--check]` | Find keys your agents can reach on this computer and what each can do. Local only, no account. `--check` scans files only (not the shell environment) and exits 5 on a high or medium key. |
65
- | `discover` | Scan local MCP configuration and submit a privacy-minimized fleet report. Exit 5 on a managed-policy violation. |
66
- | `hook` | Records the CLIs agents run and, with `--guard`, decides each one before it runs from your Autopilot rules (`install`, `uninstall`, `status`). |
67
- | `wait <approval-id> [--timeout <s>]` | Wait for a person to decide an approval request (default 100 seconds). |
68
- | `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on. |
69
- | `sessions [--status running\|idle\|ended]` | Your agents' recent sessions with what Passport decided. |
70
- | `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo). |
71
- | `setup --org <pek_key> [--yes] [--clients <list>]` | Set up every agent on this computer for your company without asking anything (MDM and scripts). See [Company rollout](#company-rollout). |
72
- | `setup` | Install and maintain assigned team workflows as managed skills. |
73
- | `session` | Run NDJSON commands over one authenticated MCP session. |
74
- | `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
75
- | `completion <bash\|zsh\|fish>` | Print a completion script. Offline. |
76
- | `help [command]`, `version` | Help; package version and local profile context. |
49
+ | Command | Purpose |
50
+ | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
51
+ | `init [--yes] [--move-keys] [--no-open] [--cloud <origin>] [--skip-apps\|--skip-agents\|--skip-guard] [--verbose] [--json]` | Set up Passport for this computer's agents in one pass. Every step asks first, can be skipped, and is safe to run again. |
52
+ | `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active. |
53
+ | `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
54
+ | `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
55
+ | `status` | Workspace, member, agent, and app connection states, plus Autopilot presets, team floors, and how old this computer's copy of your rules is. |
56
+ | `doctor` | Check Node, credential-file safety, HTTPS policy, `/healthz`, auth, serverInfo, and CLI protocol. Exit 1 on a failed check, with the full report. |
57
+ | `ready` | Readiness preflight for automation; gate on its `ready` field and exit code. |
58
+ | `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog. |
59
+ | `describe <tool>` | One exact definition with its full parameter schema. |
60
+ | `run <tool> [json]` | Run a tool through Passport governance. |
61
+ | `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
62
+ | `resources [uri] [--out <file>]` | List or read MCP resources. |
63
+ | `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
64
+ | `scan [--path <dir>] [--verbose] [--check]` | Find keys your agents can reach on this computer and what each can do. Local only, no account. `--check` scans files only (not the shell environment) and exits 5 on a high or medium key. |
65
+ | `discover` | Scan local MCP configuration and submit a privacy-minimized fleet report. Exit 5 on a managed-policy violation. |
66
+ | `hook` | Records the CLIs agents run and, with `--guard`, decides each one before it runs from your Autopilot rules (`install`, `uninstall`, `status`). |
67
+ | `wait <approval-id> [--timeout <s>]` | Wait for a person to decide an approval request (default 100 seconds). |
68
+ | `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on. |
69
+ | `sessions [--status running\|idle\|ended]` | Your agents' recent sessions with what Passport decided. |
70
+ | `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo). |
71
+ | `setup --org <pek_key> [--yes] [--clients <list>]` | Set up every agent on this computer for your company without asking anything (MDM and scripts). See [Company rollout](#company-rollout). |
72
+ | `setup` | Install and maintain assigned team workflows as managed skills. |
73
+ | `session` | Run NDJSON commands over one authenticated MCP session. |
74
+ | `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
75
+ | `completion <bash\|zsh\|fish>` | Print a completion script. Offline. |
76
+ | `help [command]`, `version` | Help; package version and local profile context. |
77
77
 
78
78
  Global options: `--profile <name>`, `--json`, `--timeout <seconds>` (default 30), `--quiet`, `--caller <id>`.
79
79
 
@@ -137,7 +137,7 @@ Eight steps, each reusing the command that owns it:
137
137
  4. **Keys**: for each CLI sign-in on this computer, the same question as `passport keys move`: `Store your Railway account token in Passport and sign the Railway CLI out on this computer? [y/n]`. It has no default: Enter asks again (`Type y or n.`). `--yes` never moves a key: the step prints `Keys stayed on this computer. Run passport keys move to move them.` Add `--move-keys` to move every key it finds unasked; the closing summary then says which (`Moved your Railway key into Passport and signed that CLI out on this computer.`). Quiet when there's nothing to move.
138
138
  5. **Environments**: the environments Passport has placed for your apps, each with its kind: `Found 3 environments: production (Railway), preview (Vercel), qa (Railway)`. Anything Passport can't place counts as Production; change it any time in Rules. With no app connected yet it says `Environments appear once an app is connected.`
139
139
  6. **Agents**: Passport's one MCP URL with this workspace as its hint (`https://passportmcp.com/mcp?ws=<workspace>`), with each agent's own browser sign-in; a server that doesn't serve `/mcp` yet (read from its OAuth protected-resource metadata) gets the workspace's own URL (`https://<host>/w/<workspace>/mcp`). An existing entry at either URL for this workspace counts as set up, so no token lands in a config file. Claude Code and Codex through their own CLIs (`claude mcp add --transport http --scope user`, `codex mcp add --url`), Cursor through `~/.cursor/mcp.json`, VS Code through `code --add-mcp` or its user `mcp.json`. Claude Desktop connects through Settings → Connectors, so init prints that step.
140
- 7. **Guard**: asks `Apply your Autopilot rules before each shell command in <agents>? [Y/n]`, then runs `passport hook install --guard` for Claude Code, Codex, and Cursor (Codex: blocks only), pointing at a stable copy of the CLI in `$PASSPORT_HOME/cli/<version>/` (never npm's cache), or at a global `passport-bridge` of the same version or newer. Once the new copy is in place, older copies are deleted unless a hook still runs them.
140
+ 7. **Guard**: asks `Apply your Autopilot rules before each shell command in <agents>? [Y/n]`, then runs `passport hook install --guard` for Claude Code, Codex, and Cursor (Codex: blocks only), pointing at the launcher `$PASSPORT_HOME/cli/bin/passport` (`passport.cmd` on Windows), which runs a stable copy of the CLI in `$PASSPORT_HOME/cli/<version>/` (never npm's cache), or at a global `passport-bridge` of the same version or newer. An upgrade rewrites the launcher and the `cli/current` link in one rename each, so hooks follow without being edited; the launcher runs the recorded node, or the node on PATH once that one is removed. A hook from an older init that names a version folder is replaced where it stands, next to your other hooks. Once the new copy is in place, older copies are deleted unless a hook still runs them.
141
141
  8. **Autopilot**: how much agents can do on their own, per environment:
142
142
 
143
143
  ```
@@ -152,15 +152,15 @@ Eight steps, each reusing the command that owns it:
152
152
 
153
153
  What changes on disk, and how to undo it:
154
154
 
155
- | Where | What | Undo |
156
- | --- | --- | --- |
157
- | `~/.passport/credentials.json` | A `cli@<workspace>` profile, as `passport login` writes | `passport logout` |
158
- | `~/.passport/cli/` | A copy of this CLI and `bin/passport` launchers | Delete the folder (after removing the hooks) |
159
- | `~/.claude.json` | A `passport` MCP server entry, via `claude mcp add` | `claude mcp remove --scope user passport` |
160
- | `~/.codex/config.toml` | `[mcp_servers.passport]`, via `codex mcp add` | `codex mcp remove passport` |
161
- | `~/.cursor/mcp.json` | `mcpServers.passport` | Delete that entry |
162
- | VS Code user `mcp.json` | `servers.passport` | `MCP: List Servers`, then remove it |
163
- | `~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.cursor/hooks.json` | Passport's audit and guard hooks | `passport hook uninstall --client <agent> --apply` |
155
+ | Where | What | Undo |
156
+ | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | -------------------------------------------------- |
157
+ | `~/.passport/credentials.json` | A `cli@<workspace>` profile, as `passport login` writes | `passport logout` |
158
+ | `~/.passport/cli/` | A copy of this CLI, the `bin/passport` launchers hooks run, and a `current` link | Delete the folder (after removing the hooks) |
159
+ | `~/.claude.json` | A `passport` MCP server entry, via `claude mcp add` | `claude mcp remove --scope user passport` |
160
+ | `~/.codex/config.toml` | `[mcp_servers.passport]`, via `codex mcp add` | `codex mcp remove passport` |
161
+ | `~/.cursor/mcp.json` | `mcpServers.passport` | Delete that entry |
162
+ | VS Code user `mcp.json` | `servers.passport` | `MCP: List Servers`, then remove it |
163
+ | `~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.cursor/hooks.json` | Passport's audit and guard hooks | `passport hook uninstall --client <agent> --apply` |
164
164
 
165
165
  Before editing a file it didn't create, init says which file and keeps one copy of the original as `<file>.passport-backup`. It changes only Passport's own entries, writes atomically, refuses a malformed file with one line, and leaves an existing Passport entry alone unless it points at npm's cache or a file that's gone. Ctrl-C at any point stops cleanly; run init again to pick up where it left off. A question only takes keys typed after it appears, so an Enter pressed during a pause never answers it. Any wait longer than a moment shows what it's for in the step's row (`Sign in Checking your sign-in…`); off a terminal nothing extra prints. If Passport can't be reached, init says `Couldn't reach Passport at <origin>. Check your connection, then run passport init again.` and exits 1. Without a terminal, `init` needs `--yes` (exit 6 otherwise), and `--json` needs `--yes`. It never edits your shell profile: it prints the one `PATH` line to add if you want `passport` everywhere.
166
166
 
@@ -212,20 +212,20 @@ Two hooks per agent. `passport hook` runs after each shell command and records t
212
212
  - **Ask** or **deny** when any recognized command needs it. The strictest part of a compound command wins and names itself. `--help` and `--dry-run` never ask.
213
213
  - Each reason names its cause in one line: `Passport: railway redeploy changes Production. Approve to run it.`, or `Blocked by Passport: Team rule, no deletes in Production. Ask an admin to run it, or request an exception in Passport.`
214
214
 
215
- **Everyday commands** (`src/cliHookLocal.ts`, tables in `src/localCommands.ts`, `localTools.ts`, `localFiles.ts`, `localGit.ts`, `localNetwork.ts`). Local commands are placed by what they touch on this computer. The project folder (the git root, else the agent's folder; never `/` or the home folder) is Development: reads such as `ls`, `rg`, `git status`, test runners, linters, builds, and type checks are Reads; `git commit`, formatters with `--write`, package scripts, and `mv`/`cp` are Changes; `rm`, `git clean -fd`, and `git reset --hard` are Deletes. Package installs (`npm install`, `pip install`, `brew install`) are Changes in Other apps. `git push` to the default branch (origin's HEAD, else `main`/`master`) is a Change in Production, to any other branch a Change in Development; deleting a remote branch (`--delete`, `:branch`) is a Delete in Other apps because teammates share it. Temporary folders (`/tmp`, `$TMPDIR`) count as Development; deleting one whole is Irreversible. Outside the project: deleting the home folder, `/`, system paths, or the whole project is Irreversible; other writes are Changes and deletes are Deletes in Other apps; writes to keys, shell startup files, or an agent's own settings are Deletes, and reads of them are no decision. `curl`/`wget` GETs are Reads and anything that sends data is a Change, in Other apps (Development for localhost). docker `ps`/`logs` read, `run`/`build`/`compose up` change, `rm`/`prune` delete. `sudo` never runs silently. Symlinks are resolved before deciding, `cd` is followed through `&&`, `;`, and subshells, and redirects are writes where they land. The server keeps a generated copy of the tables (`node scripts/generate-local-commands.mjs`) for `rules test` on the web. Allowed project work and reads are counted on the machine ("Answered for you") rather than recorded one by one; installs, pushes, and anything that asks or blocks are recorded like vendor commands, with the environment kind and never a path.
215
+ **Everyday commands** (`src/cliHookLocal.ts`, tables in `src/localCommands.ts`, `localTools.ts`, `localFiles.ts`, `localGit.ts`, `localNetwork.ts`). Local commands are placed by what they touch on this computer. The project folder (the git root, else the agent's folder; never `/` or the home folder) is Development: reads such as `ls`, `rg`, `git status`, test runners, linters, builds, and type checks are Reads; `git commit`, formatters with `--write`, package scripts, and `mv`/`cp` are Changes; `rm`, `git clean -fd`, and `git reset --hard` are Deletes. Package installs (`npm install`, `pip install`, `brew install`) are Changes in Other apps. `git push` to the default branch (origin's HEAD, else `main`/`master`) is a Change in Production, to any other branch a Change in Development; deleting a remote branch (`--delete`, `:branch`) is a Delete in Other apps because teammates share it. Temporary folders (`/tmp`, `$TMPDIR`) count as Development; deleting one whole is Irreversible. Outside the project: deleting the home folder, `/`, system paths, or the whole project is Irreversible; other writes are Changes and deletes are Deletes in Other apps; writes to keys, shell startup files, or an agent's own settings are Deletes, and reads of them are no decision. `curl`/`wget` GETs are Reads and anything that sends data is a Change, in Other apps (Development for localhost). docker `ps`/`logs` read, `run`/`build`/`compose up` change, `rm`/`prune` delete. `sudo` never runs silently. The project's own code run directly (`node scripts/check.mjs`, `npx tsx scripts/x.ts`, `bash scripts/ci.sh`, `./scripts/ci.sh`, `make test`) is a Change in Development, like a package script; Passport can't read inside it, so it is never allowed and never recorded as opaque. `tsx --test` and `./node_modules/.bin/<tool>` are their tools, `bash -lc '…'` and `sh -c '…'` are read as the line inside, and Codex's `apply_patch <<'PATCH'` is a change to the files the patch names. A checkout an agent keeps for itself (`~/.codex/worktrees/…`, `~/.cursor/worktrees/…`) is the project, not the agent's settings. Symlinks are resolved before deciding, `cd` is followed through `&&`, `;`, and subshells, and redirects are writes where they land. The server keeps a generated copy of the tables (`node scripts/generate-local-commands.mjs`) for `rules test` on the web. Allowed project work and reads are counted on the machine ("Answered for you") rather than recorded one by one; installs, pushes, and anything that asks or blocks are recorded like vendor commands, with the environment kind and never a path.
216
216
 
217
217
  The environment comes from each vendor's own flags (`src/cliHookEnvironment.ts`): Railway `-e/--environment`, Wrangler and Sentry `-e/--env`, Vercel `--prod`/`--target` (a deploy without either is a preview), Supabase `--local`/`--linked`/`--project-ref` (`db reset` is local unless `--linked`), Stripe `--live` (test mode otherwise), `git push <remote> <branch>`, `psql` hosts (`localhost` is Development), fly and Heroku `-a/--app`, kubectl `--context`/`-n`, helm `--kube-context`/`-n`, AWS `--profile`, gcloud `--project`, plus any flags the server adds. Names follow Passport's rules (`prod|production|live|main` → Production, `stag|qa|uat|preview` → Staging, `dev|local|test|sandbox|feature|branch` → Development), and the workspace's own placement of a name wins. Anything else, or no flag at all (a linked project the hook can't see), counts as Production, and the reason says `Environment unknown, treated as Production.`
218
218
 
219
- **Attended or unattended** (`src/cliHookMode.ts`). With a person at the keyboard, an ask is the agent's own prompt with Passport's reason. With nobody there, the guard asks Passport instead (`POST /api/my/cli/decide`, inside the hook's budget): the server knows grants already given this session, every rule, and the workspace's environments. An allow from it runs the command (for example, a retry after approval); an ask becomes an approval request on the web and the person's phone, and the agent reads `` Waiting for approval from Ramish. Run `passport wait <id>` to wait, or continue with other work. `` If Passport can't answer in time, the local decision stands and the reason adds `Passport couldn't be reached, so this computer decided.` Signals, strongest first:
219
+ **Attended or unattended** (`src/cliHookMode.ts`). With a person at the keyboard, an ask is the agent's own prompt with Passport's reason. With nobody there, the guard asks Passport instead (`POST /api/my/cli/decide`, inside the hook's budget): the server knows grants already given this session, every rule, and the workspace's environments. An allow from it runs the command (for example, a retry after approval); an ask becomes an approval request on the web and the person's phone, and the agent reads ``Waiting for approval from Ramish. Run `passport wait <id>` to wait, or continue with other work.`` If Passport can't answer in time, the local decision stands and the reason adds `Passport couldn't be reached, so this computer decided.` Signals, strongest first:
220
220
 
221
- | Signal | Means |
222
- | --- | --- |
223
- | `PASSPORT_HOOK_MODE=attended\|unattended` | Override |
224
- | Claude Code `CLAUDE_CODE_SESSION_ATTENDED` (`1`/`0`), passed to every hook | Attended / unattended |
225
- | Hook input `permission_mode` `dontAsk` or `bypassPermissions` (Claude Code, Codex) | Unattended: prompts are suppressed |
226
- | Cursor `is_background_agent: true` | Unattended: background and cloud agents |
227
- | `CLAUDE_CODE_ENTRYPOINT` `sdk-cli` (`claude -p`), `sdk-ts`, `sdk-py`, `claude-code-github-action` | Unattended (older Claude Code builds) |
228
- | `CI`, `GITHUB_ACTIONS`, `GITLAB_CI`, `BUILDKITE`, `CIRCLECI`, `JENKINS_URL`, `TF_BUILD` | Unattended |
221
+ | Signal | Means |
222
+ | ------------------------------------------------------------------------------------------------- | --------------------------------------- |
223
+ | `PASSPORT_HOOK_MODE=attended\|unattended` | Override |
224
+ | Claude Code `CLAUDE_CODE_SESSION_ATTENDED` (`1`/`0`), passed to every hook | Attended / unattended |
225
+ | Hook input `permission_mode` `dontAsk` or `bypassPermissions` (Claude Code, Codex) | Unattended: prompts are suppressed |
226
+ | Cursor `is_background_agent: true` | Unattended: background and cloud agents |
227
+ | `CLAUDE_CODE_ENTRYPOINT` `sdk-cli` (`claude -p`), `sdk-ts`, `sdk-py`, `claude-code-github-action` | Unattended (older Claude Code builds) |
228
+ | `CI`, `GITHUB_ACTIONS`, `GITLAB_CI`, `BUILDKITE`, `CIRCLECI`, `JENKINS_URL`, `TF_BUILD` | Unattended |
229
229
 
230
230
  Codex has no field for `codex exec`; its prompt-free modes count as unattended, where an ask blocks for now with the waiting line.
231
231
 
@@ -236,7 +236,7 @@ The guard decides from local data inside `HOOK_BUDGET_MS` (1.5 s) and prints fir
236
236
  An ask becomes one Activity row. In Claude Code, with the audit hook registered, the guard parks its report in `$PASSPORT_HOME/hook-pending/` (`src/cliHookPending.ts`, mode 600, claimed by atomic rename). The audit hook for the same tool-use id sends the run with `decision: "ask", ran: true` ("asked first, then ran"). An ask nobody claims within 30 minutes (no agent fires a hook for a declined prompt) is sent by the next hook run as `ran: false` ("asked first, not run"). An allow the server gave is parked the same way, so the run's row says `Approved earlier this session`. Cursor has no tool-use id to match, so its asks are sent at once as their own "asked first" row. Denies are always sent at once; asks and blocks the server decided are recorded by the server.
237
237
 
238
238
  - Claude Code: `PreToolUse`, plus `PostToolUse` and `PostToolUseFailure` (failed or interrupted calls, recorded as ran with a non-zero exit), in `~/.claude/settings.json` (`CLAUDE_CONFIG_DIR` honored).
239
- - Codex: the same events in `~/.codex/hooks.json` (`CODEX_HOME` honored). Codex supports deny only (ask fails the hook, and its allow rewrites commands), so the guard only blocks there. Trust the hooks in Codex's `/hooks`.
239
+ - Codex: the same events in `~/.codex/hooks.json` (`CODEX_HOME` honored). Codex sends every shell command as `tool_name: "Bash"` with the model's raw command string in `tool_input.command` (never shell-wrapped), so it is read exactly like Claude Code's; its `apply_patch` tool is a file edit, not a shell command, and isn't recorded. Codex supports deny only (ask fails the hook, and its allow rewrites commands), so the guard only blocks there. Trust the hooks in Codex's `/hooks`.
240
240
  - Cursor: `beforeShellExecution`/`afterShellExecution` in `~/.cursor/hooks.json`. Cursor also imports Claude Code's hooks by default; that imported copy records nothing when Passport's own Cursor entry exists, so rows aren't doubled.
241
241
 
242
242
  `src/cliPolicy.ts` caches the member's CLI policy (`GET /api/my/cli-policy`) at `$PASSPORT_HOME/cli-policy/<profile>.json` (mode 600). Servers with Autopilot send version 2 (`src/cliPolicyV2.ts`: presets, floors, CLI rules, irreversible and delete verbs, environment flags, placed environments); older servers send version 1, and then the guard keeps its earlier shape: ask or deny before destructive verbs, never allow, no server call, and reports without the Autopilot fields. `passport login` and `passport status` refresh it and `passport logout` removes it. A 404 or error keeps the previous copy; with no copy the guard asks before every destructive verb. `PASSPORT_HOOK_DISABLED=1` turns both hooks off.
@@ -392,43 +392,43 @@ const actions = await client.actions(); // or client.actions(delegationId)
392
392
 
393
393
  With `--json`, stdout is exactly one JSON value; hints and warnings go to stderr.
394
394
 
395
- | Command | JSON value |
396
- | --- | --- |
397
- | `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,next}` (`workspaceName` after browser sign-in) |
398
- | `profiles` | `{profiles:[{name,active,client?}],active?}` |
399
- | `use` | `{profile,active:true}` |
400
- | `logout` | `{profile,removed,revoked}` |
401
- | `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next?}` |
402
- | `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId` |
403
- | `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}` |
404
- | `sessions` | `{sessions:[{id,client,folder,status,startedAt,lastActivityAt,counts,environments,waiting}],nextCursor}` |
405
- | `undo` | `{actionId,status,message,steps:[{label,ok,detail?}],option,undoActionId?}`; without `--yes` off a terminal, `{actionId,status:"preview",preview,next}`; pending, blocked, and declined are errors |
406
- | `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure |
407
- | `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
408
- | `search` | Gateway payload with `results` or `catalog`, and `note` |
409
- | `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases |
410
- | `run` | Full governed MCP tool result, including `structuredContent` |
411
- | `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
412
- | `resources`, `prompts` | MCP list, read, or get result |
413
- | `discover` | `{snapshot,report,compliant}` |
414
- | `scan` | `{version:1,findings:[{id,provider,kind,label,severity,location,locations,blastRadius}],agents,unreadable,checked}` |
415
- | `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
416
- | `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
417
- | `completion` | `{shell,script}` |
418
- | `help` | `{command,help}` |
419
- | `version` | `{version,profileCount,profileSelected,selectionSource,next,endpoint?,profile?}` |
395
+ | Command | JSON value |
396
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
397
+ | `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,next}` (`workspaceName` after browser sign-in) |
398
+ | `profiles` | `{profiles:[{name,active,client?}],active?}` |
399
+ | `use` | `{profile,active:true}` |
400
+ | `logout` | `{profile,removed,revoked}` |
401
+ | `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next?}` |
402
+ | `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId` |
403
+ | `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}` |
404
+ | `sessions` | `{sessions:[{id,client,folder,status,startedAt,lastActivityAt,counts,environments,waiting}],nextCursor}` |
405
+ | `undo` | `{actionId,status,message,steps:[{label,ok,detail?}],option,undoActionId?}`; without `--yes` off a terminal, `{actionId,status:"preview",preview,next}`; pending, blocked, and declined are errors |
406
+ | `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure |
407
+ | `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
408
+ | `search` | Gateway payload with `results` or `catalog`, and `note` |
409
+ | `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases |
410
+ | `run` | Full governed MCP tool result, including `structuredContent` |
411
+ | `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
412
+ | `resources`, `prompts` | MCP list, read, or get result |
413
+ | `discover` | `{snapshot,report,compliant}` |
414
+ | `scan` | `{version:1,findings:[{id,provider,kind,label,severity,location,locations,blastRadius}],agents,unreadable,checked}` |
415
+ | `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
416
+ | `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
417
+ | `completion` | `{shell,script}` |
418
+ | `help` | `{command,help}` |
419
+ | `version` | `{version,profileCount,profileSelected,selectionSource,next,endpoint?,profile?}` |
420
420
 
421
421
  Errors: `{"error":"...","cause":"blocked","exitCode":5,"app":"github"}`, optionally with `approvalId`, `hint`, `profiles`, `next` (`argv` plus description), `remediation`, `retry`, `requiredInput`, or `connectUrl`.
422
422
 
423
- | Exit | Meaning |
424
- | ---: | --- |
425
- | 0 | Success |
426
- | 1 | Network, timeout, server, or unsupported-content error. When Passport can't be reached: `Passport couldn't be reached at <host>. Check your connection and try again.` |
427
- | 2 | Missing, expired, or revoked authentication |
428
- | 3 | App needs member sign-in |
429
- | 4 | Approval pending (including `wait` still waiting at its timeout) |
430
- | 5 | Policy, guardrail, selection, or approval denial (including a declined or expired approval in `wait`) |
431
- | 6 | Invalid usage or unknown tool/app |
423
+ | Exit | Meaning |
424
+ | ---: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
425
+ | 0 | Success |
426
+ | 1 | Network, timeout, server, or unsupported-content error. When Passport can't be reached: `Passport couldn't be reached at <host>. Check your connection and try again.` |
427
+ | 2 | Missing, expired, or revoked authentication |
428
+ | 3 | App needs member sign-in |
429
+ | 4 | Approval pending (including `wait` still waiting at its timeout) |
430
+ | 5 | Policy, guardrail, selection, or approval denial (including a declined or expired approval in `wait`) |
431
+ | 6 | Invalid usage or unknown tool/app |
432
432
 
433
433
  ## MCP stdio bridge
434
434
 
package/dist/cliHook.d.ts CHANGED
@@ -18,6 +18,7 @@ import { type ParsedArgs } from "./cliArgs.js";
18
18
  import { type CliFinding } from "./cliHookClassify.js";
19
19
  import { type DecidedFinding, type GuardDecision } from "./cliHookGuard.js";
20
20
  import { type HookInput } from "./cliHookInput.js";
21
+ export { opaqueKind, opaqueProgram } from "./cliHookOpaque.js";
21
22
  import { type CommandResult, type Env, type Runtime } from "./cliSupport.js";
22
23
  /** Claude Code, Codex, and Cursor fail open on a slow hook, so the budget is ours. */
23
24
  export declare const HOOK_BUDGET_MS = 1500;
@@ -33,6 +34,9 @@ export type CliHookReport = {
33
34
  findings: ReportedFinding[];
34
35
  opaque: boolean;
35
36
  opaqueKinds?: string[];
37
+ /** The program of each part Passport couldn't check: its first word only
38
+ * (`python`, `make`, `npx`), never a script name or an argument. */
39
+ opaquePrograms?: string[];
36
40
  /** What the guard answered before the command ran. "allow" only with a v2
37
41
  * (Autopilot) policy; the server works out the cause and class itself. */
38
42
  decision?: "allow" | "ask" | "deny";
@@ -84,8 +88,6 @@ type ShellEvent = {
84
88
  /** Keep the shape of the verb, never its arguments: anything that could carry a
85
89
  * path, an endpoint, or a value is dropped rather than truncated. */
86
90
  export declare function safeVerb(raw: string | null): string;
87
- /** Why a command could not be read. Never what it was. */
88
- export declare function opaqueKind(finding: CliFinding): string;
89
91
  /**
90
92
  * Which agent sent this. An installed hook names its client with `--client`;
91
93
  * Cursor is also recognised by its own event names and version field, which
package/dist/cliHook.js CHANGED
@@ -22,7 +22,8 @@ import { decideGuard, guardMachineOf } from "./cliHookGuard.js";
22
22
  import { detectMode } from "./cliHookMode.js";
23
23
  import { readInput } from "./cliHookInput.js";
24
24
  import { hookViaPlugin } from "./hookPlugin.js";
25
- import { INTERPRETERS } from "./cliHookParse.js";
25
+ import { opaqueParts } from "./cliHookOpaque.js";
26
+ export { opaqueKind, opaqueProgram } from "./cliHookOpaque.js";
26
27
  import { hasExpired, holdAsk, takeAsk, takeExpired } from "./cliHookPending.js";
27
28
  import { claimStaleRefresh, readCliPolicy } from "./cliPolicy.js";
28
29
  import { readCreds } from "./credentials.js";
@@ -70,19 +71,6 @@ export function safeVerb(raw) {
70
71
  .slice(0, 4);
71
72
  return tokens.join(" ").slice(0, 80).trim() || "invoke";
72
73
  }
73
- /** Why a command could not be read. Never what it was. */
74
- export function opaqueKind(finding) {
75
- const via = finding.via[finding.via.length - 1] ?? "";
76
- if (finding.vendor === "psql")
77
- return "sql";
78
- if (via === "make" || via === "just" || via === "task")
79
- return "task-runner";
80
- if (via === "source" || via.endsWith("<script>") || INTERPRETERS.has(via))
81
- return "script";
82
- if (via === "npx" || via === "bunx")
83
- return "package-runner";
84
- return "unknown";
85
- }
86
74
  function isCursorEvent(input) {
87
75
  return input.hook_event_name === "beforeShellExecution" || input.hook_event_name === "afterShellExecution";
88
76
  }
@@ -172,13 +160,14 @@ export function buildReport(input, findings, env, declared, decided = [], local
172
160
  const governed = reportable(summary.governed, decided, local);
173
161
  if (!governed.length && !summary.opaque)
174
162
  return null;
175
- const kinds = [...new Set(summary.unknown.map(opaqueKind))].slice(0, MAX_OPAQUE_KINDS);
163
+ const { kinds, programs } = opaqueParts(summary.unknown, MAX_OPAQUE_KINDS);
176
164
  return {
177
165
  ...context(input, env, declared),
178
166
  ...outcomeOfInput(input),
179
167
  findings: governed,
180
168
  opaque: summary.opaque,
181
- ...(summary.opaque && kinds.length ? { opaqueKinds: kinds } : {})
169
+ ...(summary.opaque && kinds.length ? { opaqueKinds: kinds } : {}),
170
+ ...(summary.opaque && programs.length ? { opaquePrograms: programs } : {})
182
171
  };
183
172
  }
184
173
  /** What the guard answered, and for which findings. The audit row that
@@ -32,6 +32,13 @@ export declare function isPassportGuardCommand(command: unknown): boolean;
32
32
  export declare function hookCommand(env: Env, exists?: (path: string) => boolean, client?: HookClient, kind?: Kind, invocation?: string): string;
33
33
  /** A shell-safe `node <entry>` prefix for a hook command. */
34
34
  export declare function nodeInvocation(node: string, entry: string): string;
35
+ /** What hooks run for a stable install: its version-independent launcher, so
36
+ * an upgrade moves every hook; a global npm install by its own path. */
37
+ export declare function stableInvocation(stable: {
38
+ node: string;
39
+ entry: string;
40
+ launcher?: string;
41
+ }): string;
35
42
  /** The Passport audit command registered in Claude Code settings, if any. */
36
43
  export declare function registeredHookCommand(settings: Settings): string | null;
37
44
  /** Add Passport's audit entry to Claude Code's Bash matcher, touching nothing else. */
@@ -21,6 +21,8 @@ import { readCliPolicy } from "./cliPolicy.js";
21
21
  import { coveredByPlugin, pluginInstalled } from "./hookPlugin.js";
22
22
  import { syncNative } from "./nativeSync.js";
23
23
  import { readCreds } from "./credentials.js";
24
+ import { credentialDir } from "./credentialStorage.js";
25
+ import { launcherPath } from "./initInstall.js";
24
26
  import { failure, selectStoredProfile } from "./cliSupport.js";
25
27
  export const HOOK_CLIENTS = ["claude-code", "codex", "cursor"];
26
28
  const SETTINGS_MAX_BYTES = 1024 * 1024;
@@ -115,8 +117,17 @@ function ownInvocation() {
115
117
  const entry = process.argv[1];
116
118
  return entry ? `${quoted(process.execPath)} ${quoted(entry)}` : null;
117
119
  }
118
- /** `passport` when the CLI is on PATH, otherwise this exact process. */
120
+ /** Passport's own launcher (`passport init` writes it), when it is there. */
121
+ function installedLauncher(exists) {
122
+ const launcher = launcherPath(join(credentialDir(), "cli", "bin"), process.platform);
123
+ return exists(launcher) ? launcher : null;
124
+ }
125
+ /** The launcher `passport init` installed, else `passport` when the CLI is on
126
+ * PATH, otherwise this exact process. */
119
127
  function passportInvocation(env, exists) {
128
+ const launcher = installedLauncher(exists);
129
+ if (launcher)
130
+ return quoted(launcher);
120
131
  if (onPath("passport", env, exists))
121
132
  return "passport";
122
133
  return ownInvocation() ?? "passport";
@@ -131,6 +142,11 @@ export function hookCommand(env, exists = executable, client, kind = "audit", in
131
142
  export function nodeInvocation(node, entry) {
132
143
  return `${quoted(node)} ${quoted(entry)}`;
133
144
  }
145
+ /** What hooks run for a stable install: its version-independent launcher, so
146
+ * an upgrade moves every hook; a global npm install by its own path. */
147
+ export function stableInvocation(stable) {
148
+ return stable.launcher ? quoted(stable.launcher) : nodeInvocation(stable.node, stable.entry);
149
+ }
134
150
  /** Write through a symlinked settings file (dotfile managers) to its target. */
135
151
  function writablePath(path) {
136
152
  try {
@@ -237,19 +253,26 @@ function withEntry(spec, settings, slot, command) {
237
253
  const hooks = { ...hooksOf(settings) };
238
254
  const list = [...listOf(settings, event)];
239
255
  if (spec.format === "cursor") {
256
+ const at = list.findIndex((entry) => ours(entry?.command));
240
257
  const kept = list.filter((entry) => !ours(entry?.command));
241
- hooks[event] = [...kept, { command, timeout: HOOK_TIMEOUT_SECONDS }];
258
+ const fresh = { command, timeout: HOOK_TIMEOUT_SECONDS };
259
+ hooks[event] = at === -1 ? [...kept, fresh] : [...kept.slice(0, at), fresh, ...kept.slice(at)];
242
260
  const version = typeof settings.version === "number" ? settings.version : 1;
243
261
  return { ...settings, version, hooks };
244
262
  }
245
263
  const entry = { type: "command", command, timeout: HOOK_TIMEOUT_SECONDS };
246
264
  const groups = list;
247
- const index = groups.findIndex((group) => group && group.matcher === "Bash");
265
+ // An older Passport entry (another version's path) is replaced where it stands.
266
+ const owner = groups.findIndex((group) => group && Array.isArray(group.hooks) && group.hooks.some((candidate) => ours(candidate?.command)));
267
+ const index = owner !== -1 ? owner : groups.findIndex((group) => group && group.matcher === "Bash");
248
268
  if (index === -1)
249
269
  groups.push({ matcher: "Bash", hooks: [entry] });
250
270
  else {
251
271
  const existing = Array.isArray(groups[index].hooks) ? groups[index].hooks : [];
252
- groups[index] = { ...groups[index], hooks: [...existing.filter((candidate) => !ours(candidate?.command)), entry] };
272
+ const at = existing.findIndex((candidate) => ours(candidate?.command));
273
+ const kept = existing.filter((candidate) => !ours(candidate?.command));
274
+ const hooks = at === -1 ? [...kept, entry] : [...kept.slice(0, at), entry, ...kept.slice(at)];
275
+ groups[index] = { ...groups[index], hooks };
253
276
  }
254
277
  hooks[event] = groups;
255
278
  return { ...settings, hooks };
@@ -36,6 +36,9 @@ export type LocalMachine = {
36
36
  temp: string[];
37
37
  /** Extra folders whose contents are keys or agent settings. */
38
38
  sensitive: string[];
39
+ /** Folders where agents keep their own checkouts of a project (Codex and
40
+ * Cursor worktrees). A project inside one is a project, not agent settings. */
41
+ worktrees?: string[];
39
42
  fs: LocalFs;
40
43
  };
41
44
  export declare const NODE_FS: LocalFs;
@@ -18,6 +18,7 @@ import { lstatSync, readFileSync, realpathSync, statSync } from "node:fs";
18
18
  import { homedir, tmpdir } from "node:os";
19
19
  import { posix } from "node:path";
20
20
  import { classifyArgv, classifyNestedText } from "./cliHookClassify.js";
21
+ import { heredocBodies, projectCode } from "./cliHookLocalCode.js";
21
22
  import { splitCommands } from "./cliHookParse.js";
22
23
  import { VENDORS } from "./cliHookVendors.js";
23
24
  import { databasePrefix } from "./envDatabase.js";
@@ -192,11 +193,27 @@ export function localMachine(cwd, env = process.env, fs = NODE_FS) {
192
193
  else if (!tooBroad(working, home))
193
194
  projectRoot = working;
194
195
  }
195
- return { cwd: working, projectRoot, home, temp, sensitive, fs };
196
+ const worktrees = [
197
+ posix.join(home, ".codex", "worktrees"),
198
+ posix.join(home, ".cursor", "worktrees"),
199
+ ...[env.CODEX_HOME, env.PASSPORT_CURSOR_HOME]
200
+ .filter((value) => typeof value === "string" && value.startsWith("/"))
201
+ .map((value) => posix.join(canonical(value, fs), "worktrees"))
202
+ ];
203
+ return { cwd: working, projectRoot, home, temp, sensitive, worktrees, fs };
204
+ }
205
+ /** A git checkout an agent made for itself (`~/.codex/worktrees/<id>/<repo>`):
206
+ * its own files are the project, even though the folder above holds settings. */
207
+ function agentWorktree(projectRoot, machine) {
208
+ if (!projectRoot)
209
+ return false;
210
+ return (machine.worktrees ?? []).some((folder) => projectRoot !== folder && within(projectRoot, folder));
196
211
  }
197
212
  /** Where a resolved, canonical path lands. */
198
213
  export function placeOfPath(path, machine) {
199
214
  const { home, projectRoot } = machine;
215
+ if (agentWorktree(projectRoot, machine) && within(path, projectRoot))
216
+ return projectPlace(path, projectRoot);
200
217
  if (SENSITIVE_ABSOLUTE.some((folder) => within(path, folder)))
201
218
  return "sensitive";
202
219
  if (machine.sensitive.some((folder) => within(path, folder)))
@@ -207,13 +224,8 @@ export function placeOfPath(path, machine) {
207
224
  return "root";
208
225
  if (within(home, path))
209
226
  return "home";
210
- if (projectRoot && within(path, projectRoot)) {
211
- if (SENSITIVE_IN_PROJECT.some((entry) => within(path, posix.join(projectRoot, entry))))
212
- return "sensitive";
213
- if (path === projectRoot || path === posix.join(projectRoot, ".git"))
214
- return "project-root";
215
- return "project";
216
- }
227
+ if (projectRoot && within(path, projectRoot))
228
+ return projectPlace(path, projectRoot);
217
229
  // Home is personal even when it sits in a temporary folder (sandboxes).
218
230
  if (within(path, home))
219
231
  return "outside";
@@ -225,6 +237,13 @@ export function placeOfPath(path, machine) {
225
237
  return "system";
226
238
  return "outside";
227
239
  }
240
+ function projectPlace(path, projectRoot) {
241
+ if (SENSITIVE_IN_PROJECT.some((entry) => within(path, posix.join(projectRoot, entry))))
242
+ return "sensitive";
243
+ if (path === projectRoot || path === posix.join(projectRoot, ".git"))
244
+ return "project-root";
245
+ return "project";
246
+ }
228
247
  const EVERYTHING = new Set(["*", "**", ".*", "*.*", ".??*", ".[!.]*"]);
229
248
  /** The path a word names, relative to `cwd`; null when it can't be known. */
230
249
  export function resolveWord(word, cwd, machine) {
@@ -392,6 +411,24 @@ function vendorFindings(shape, outcome, walk, depth, cwd) {
392
411
  if (!plain)
393
412
  walk.complete = false;
394
413
  }
414
+ /** The project's own code (`cliHookLocalCode.ts`): a script, a shell's quoted
415
+ * line, a patch. True when it was placed; the vendor map then has nothing to add. */
416
+ function ownCode(shape, at, machine, walk) {
417
+ const code = projectCode(shape.words, contextAt(at.cwd, machine), at.heredocs);
418
+ if (!code)
419
+ return false;
420
+ if ("line" in code) {
421
+ const inner = classifyLine(code.line, { ...machine, cwd: at.cwd }, at.depth + 1);
422
+ walk.findings.push(...inner.findings);
423
+ if (!inner.complete)
424
+ walk.complete = false;
425
+ return true;
426
+ }
427
+ walk.findings.push(...code.actions.map(localFinding));
428
+ if (!code.complete)
429
+ walk.complete = false;
430
+ return true;
431
+ }
395
432
  /**
396
433
  * Classify a whole command line run in `machine.cwd`. Vendor commands get the
397
434
  * vendor map's findings; everyday commands get local findings; anything else
@@ -402,6 +439,7 @@ export function classifyLine(command, machine, depth = 0) {
402
439
  if (depth > 4)
403
440
  return { findings: [], complete: false };
404
441
  const { shapes, nested, flags } = splitCommands(command);
442
+ const heredocs = heredocBodies(nested);
405
443
  if (flags.braces || flags.processSubstitution || flags.heredoc || nested.length)
406
444
  walk.complete = false;
407
445
  const cwdAt = [machine.cwd];
@@ -440,6 +478,8 @@ export function classifyLine(command, machine, depth = 0) {
440
478
  cwdAt[shape.depth] = nextDirectory(outcome.target, cwd, machine);
441
479
  continue;
442
480
  }
481
+ if (outcome.kind === "unknown" && ownCode(shape, { cwd, depth, heredocs }, machine, walk))
482
+ continue;
443
483
  vendorFindings(shape, outcome, walk, depth, cwd);
444
484
  }
445
485
  for (const sub of nested) {
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The project's own code, run directly: the everyday commands a coding agent
3
+ * runs instead of `npm run` (Codex does this most).
4
+ *
5
+ * - `bash -lc '…'` and `sh -c '…'`: the quoted line, classified like any other.
6
+ * - `node scripts/check.mjs`, `npx tsx scripts/x.ts`, `bash scripts/ci.sh`,
7
+ * `./scripts/ci.sh`: a script file inside the project. Development work, the
8
+ * same as `npm run <script>`. Passport can't see what the script does, so the
9
+ * line stays incomplete: the guard never allows it, the agent's own prompt
10
+ * applies. It is not "opaque" in Activity either: it is the project's work.
11
+ * - `make test`, `just lint`: a target from the project's own task file, the
12
+ * same way.
13
+ * - `./node_modules/.bin/eslint .`: the tool itself.
14
+ * - `apply_patch <<'PATCH'` (Codex's patch format through the shell): a change
15
+ * to the files the patch names, placed like any other write.
16
+ *
17
+ * Anything else returns null and the caller's rules apply unchanged.
18
+ */
19
+ import { type CommandContext, type LocalAction, type ShellWord } from "./localCommands.js";
20
+ export type CodeFindings = {
21
+ actions: LocalAction[];
22
+ complete: boolean;
23
+ } | {
24
+ line: string;
25
+ } | null;
26
+ /**
27
+ * What a command the everyday table didn't recognize does, when it runs the
28
+ * project's own code. `heredocs` are the bodies this line feeds, by program.
29
+ */
30
+ export declare function projectCode(words: ShellWord[], ctx: CommandContext, heredocs: Map<string, string>): CodeFindings;
31
+ /** Bodies of the heredocs a line feeds, keyed by the program that reads them. */
32
+ export declare function heredocBodies(nested: Array<{
33
+ kind: string;
34
+ text: string;
35
+ target?: string;
36
+ }>): Map<string, string>;
@@ -0,0 +1,211 @@
1
+ /**
2
+ * The project's own code, run directly: the everyday commands a coding agent
3
+ * runs instead of `npm run` (Codex does this most).
4
+ *
5
+ * - `bash -lc '…'` and `sh -c '…'`: the quoted line, classified like any other.
6
+ * - `node scripts/check.mjs`, `npx tsx scripts/x.ts`, `bash scripts/ci.sh`,
7
+ * `./scripts/ci.sh`: a script file inside the project. Development work, the
8
+ * same as `npm run <script>`. Passport can't see what the script does, so the
9
+ * line stays incomplete: the guard never allows it, the agent's own prompt
10
+ * applies. It is not "opaque" in Activity either: it is the project's work.
11
+ * - `make test`, `just lint`: a target from the project's own task file, the
12
+ * same way.
13
+ * - `./node_modules/.bin/eslint .`: the tool itself.
14
+ * - `apply_patch <<'PATCH'` (Codex's patch format through the shell): a change
15
+ * to the files the patch names, placed like any other write.
16
+ *
17
+ * Anything else returns null and the caller's rules apply unchanged.
18
+ */
19
+ import { posix } from "node:path";
20
+ import { classifyLocalCommand, unwrap } from "./localCommands.js";
21
+ const SCRIPT_RUNNERS = new Set([
22
+ "node",
23
+ "tsx",
24
+ "ts-node",
25
+ "bun",
26
+ "deno",
27
+ "python",
28
+ "python3",
29
+ "ruby",
30
+ "perl",
31
+ "bash",
32
+ "sh",
33
+ "zsh",
34
+ "dash"
35
+ ]);
36
+ const SHELLS = new Set(["bash", "sh", "zsh", "dash", "ksh"]);
37
+ /** Interpreter flags that take a value: the script is the word after it. */
38
+ const VALUE_FLAGS = new Set([
39
+ "-r",
40
+ "--require",
41
+ "--import",
42
+ "--loader",
43
+ "--experimental-loader",
44
+ "-C",
45
+ "--conditions",
46
+ "--env-file",
47
+ "--tsconfig",
48
+ "-W",
49
+ "-X",
50
+ "-o"
51
+ ]);
52
+ /** Interpreter flags whose code is inline: not a project file. */
53
+ const INLINE = /^(-e|-p|--eval|--print|-c|-m|-|-i|--interactive)$/;
54
+ const PACKAGE_RUNNER_FLAGS = /^(-y|--yes|-q|--quiet|--no-install|--prefer-offline|--silent|-s)$/;
55
+ const PATCH_PROGRAMS = new Set(["apply_patch", "applypatch"]);
56
+ const TASK_RUNNERS = new Set(["make", "just", "task"]);
57
+ function plain(word) {
58
+ return Boolean(word && word.text && !word.expands && !word.glob);
59
+ }
60
+ /** `npx tsx x.ts`, `pnpm exec tsx x.ts`, `npm exec -- tsx x.ts` → `tsx x.ts`. */
61
+ function withoutPackageRunner(words) {
62
+ const program = words[0]?.text;
63
+ let rest = null;
64
+ if (program === "npx" || program === "bunx" || program === "pnpx")
65
+ rest = words.slice(1);
66
+ else if ((program === "pnpm" || program === "yarn") && words[1]?.text === "exec")
67
+ rest = words.slice(2);
68
+ else if (program === "npm" && (words[1]?.text === "exec" || words[1]?.text === "x"))
69
+ rest = words.slice(2);
70
+ if (!rest)
71
+ return words;
72
+ const start = rest.findIndex((word) => !PACKAGE_RUNNER_FLAGS.test(word.text) && word.text !== "--");
73
+ return start === -1 ? [] : rest.slice(start);
74
+ }
75
+ /** `bash -lc 'line'`: the line, when nothing else follows it. */
76
+ function shellLine(words) {
77
+ if (!SHELLS.has(words[0]?.text ?? ""))
78
+ return null;
79
+ for (let index = 1; index < words.length; index++) {
80
+ const text = words[index].text;
81
+ if (!text.startsWith("-"))
82
+ return null;
83
+ if (text === "-o" || text === "+o") {
84
+ index++;
85
+ continue;
86
+ }
87
+ if (!/^-[a-zA-Z]*c[a-zA-Z]*$/.test(text))
88
+ continue;
89
+ const line = words[index + 1];
90
+ return plain(line) && index + 2 === words.length ? line.text : null;
91
+ }
92
+ return null;
93
+ }
94
+ /** The script a runner was given, when it's a plain word. */
95
+ function scriptOperand(words) {
96
+ for (let index = 1; index < words.length; index++) {
97
+ const word = words[index];
98
+ if (INLINE.test(word.text))
99
+ return null;
100
+ if (word.text === "run" && (words[0].text === "deno" || words[0].text === "bun"))
101
+ continue;
102
+ if (word.text.startsWith("-")) {
103
+ if (VALUE_FLAGS.has(word.text))
104
+ index++;
105
+ continue;
106
+ }
107
+ return plain(word) ? word : null;
108
+ }
109
+ return null;
110
+ }
111
+ function runScript(program) {
112
+ return {
113
+ vendor: program,
114
+ verb: "run script",
115
+ actionClass: "change",
116
+ environment: "development",
117
+ touches: "this project"
118
+ };
119
+ }
120
+ /** The files a patch adds, updates, moves to, or deletes. */
121
+ function patchedFiles(body) {
122
+ const written = [];
123
+ const deleted = [];
124
+ for (const line of body.split("\n")) {
125
+ const match = /^\*\*\* (Add File|Update File|Delete File|Move to): (.+)$/.exec(line.trim());
126
+ if (!match)
127
+ continue;
128
+ const file = { text: match[2].trim() };
129
+ (match[1] === "Delete File" ? deleted : written).push(file);
130
+ }
131
+ return written.length || deleted.length ? { written, deleted } : null;
132
+ }
133
+ function patch(body, ctx) {
134
+ const files = body === undefined ? null : patchedFiles(body);
135
+ if (!files)
136
+ return null;
137
+ const actions = [];
138
+ for (const [program, words] of [
139
+ ["tee", files.written],
140
+ ["rm", files.deleted]
141
+ ]) {
142
+ if (!words.length)
143
+ continue;
144
+ const outcome = classifyLocalCommand([{ text: program }, ...words], ctx);
145
+ if (outcome.kind !== "local")
146
+ return null;
147
+ actions.push(...outcome.actions.map((action) => ({
148
+ ...action,
149
+ vendor: "apply_patch",
150
+ verb: program === "rm" ? "delete" : "patch"
151
+ })));
152
+ }
153
+ return { actions, complete: false };
154
+ }
155
+ /**
156
+ * What a command the everyday table didn't recognize does, when it runs the
157
+ * project's own code. `heredocs` are the bodies this line feeds, by program.
158
+ */
159
+ export function projectCode(words, ctx, heredocs) {
160
+ const unwrapped = unwrap(words);
161
+ if (unwrapped.reason || unwrapped.sudo || !unwrapped.words.length)
162
+ return null;
163
+ const argv = withoutPackageRunner(unwrapped.words);
164
+ const head = argv[0];
165
+ if (!plain(head))
166
+ return null;
167
+ if (PATCH_PROGRAMS.has(head.text))
168
+ return patch(heredocs.get(head.text), ctx);
169
+ const line = shellLine(argv);
170
+ if (line !== null)
171
+ return { line };
172
+ if (head.text.includes("/")) {
173
+ const place = ctx.place(head);
174
+ if (place !== "project")
175
+ return null;
176
+ const segments = head.text.split("/");
177
+ const name = segments[segments.length - 1];
178
+ // A tool the project installed: `./node_modules/.bin/eslint .` is `eslint .`.
179
+ if (segments.length >= 3 &&
180
+ segments[segments.length - 2] === ".bin" &&
181
+ segments[segments.length - 3] === "node_modules") {
182
+ const outcome = classifyLocalCommand([{ text: name }, ...argv.slice(1)], ctx);
183
+ return outcome.kind === "local" ? { actions: outcome.actions, complete: true } : null;
184
+ }
185
+ if (ctx.isVendor(name))
186
+ return null;
187
+ return { actions: [runScript("script")], complete: false };
188
+ }
189
+ // `make test` in the project: a target from its own Makefile.
190
+ if (TASK_RUNNERS.has(head.text)) {
191
+ const elsewhere = argv.some((word) => /^(-C|-f|--directory|--file|--makefile|--justfile|--taskfile|-d|--dir)(=|$)/.test(word.text));
192
+ return !elsewhere && (ctx.here === "project" || ctx.here === "project-root")
193
+ ? { actions: [{ ...runScript(head.text), verb: "run target" }], complete: false }
194
+ : null;
195
+ }
196
+ if (!SCRIPT_RUNNERS.has(head.text))
197
+ return null;
198
+ const script = scriptOperand(argv);
199
+ if (!script || ctx.place(script) !== "project")
200
+ return null;
201
+ return { actions: [runScript(head.text)], complete: false };
202
+ }
203
+ /** Bodies of the heredocs a line feeds, keyed by the program that reads them. */
204
+ export function heredocBodies(nested) {
205
+ const bodies = new Map();
206
+ for (const sub of nested) {
207
+ if (sub.kind === "heredoc" && sub.target)
208
+ bodies.set(posix.basename(sub.target), sub.text);
209
+ }
210
+ return bodies;
211
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What a hook report says about the parts of a command Passport couldn't
3
+ * check: why (its kind) and the program that ran it (its first word). Never
4
+ * a script name, an argument, or anything else the command said.
5
+ */
6
+ import type { CliFinding } from "./cliHookClassify.js";
7
+ /** Why a command could not be read. Never what it was. */
8
+ export declare function opaqueKind(finding: CliFinding): string;
9
+ /** The program an opaque part ran, as its first word: `python` for
10
+ * `python deploy.py`, `bash` for `bash ./x.sh`. Null when it isn't a plain name. */
11
+ export declare function opaqueProgram(finding: CliFinding): string | null;
12
+ /** The distinct kinds and programs of a command's opaque parts, up to `max` each. */
13
+ export declare function opaqueParts(unknown: readonly CliFinding[], max: number): {
14
+ kinds: string[];
15
+ programs: string[];
16
+ };
@@ -0,0 +1,29 @@
1
+ import { INTERPRETERS } from "./cliHookParse.js";
2
+ const PROGRAM_NAME = /^[a-z0-9._-]{1,40}$/;
3
+ /** Why a command could not be read. Never what it was. */
4
+ export function opaqueKind(finding) {
5
+ const via = finding.via[finding.via.length - 1] ?? "";
6
+ if (finding.vendor === "psql")
7
+ return "sql";
8
+ if (via === "make" || via === "just" || via === "task")
9
+ return "task-runner";
10
+ if (via === "source" || via.endsWith("<script>") || INTERPRETERS.has(via))
11
+ return "script";
12
+ if (via === "npx" || via === "bunx")
13
+ return "package-runner";
14
+ return "unknown";
15
+ }
16
+ /** The program an opaque part ran, as its first word: `python` for
17
+ * `python deploy.py`, `bash` for `bash ./x.sh`. Null when it isn't a plain name. */
18
+ export function opaqueProgram(finding) {
19
+ const program = (finding.via[finding.via.length - 1] ?? "").split(" ")[0]?.toLowerCase() ?? "";
20
+ return PROGRAM_NAME.test(program) ? program : null;
21
+ }
22
+ /** The distinct kinds and programs of a command's opaque parts, up to `max` each. */
23
+ export function opaqueParts(unknown, max) {
24
+ const programs = unknown.map(opaqueProgram).filter((program) => Boolean(program));
25
+ return {
26
+ kinds: [...new Set(unknown.map(opaqueKind))].slice(0, max),
27
+ programs: [...new Set(programs)].slice(0, max)
28
+ };
29
+ }
@@ -17,7 +17,7 @@ import { syncNative } from "./nativeSync.js";
17
17
  import { homedir } from "node:os";
18
18
  import { dirname, join } from "node:path";
19
19
  import { value } from "./cliArgs.js";
20
- import { HOOK_CLIENTS, applyGuardInstall, registeredEntries, nodeInvocation, planGuardInstall } from "./cliHookInstall.js";
20
+ import { HOOK_CLIENTS, applyGuardInstall, registeredEntries, stableInvocation, planGuardInstall } from "./cliHookInstall.js";
21
21
  import { CliFailure, cloudOrigin, failure } from "./cliSupport.js";
22
22
  import { AGENT_NAMES, AGENT_ORDER, applyAgent, backupOnce, claudeCodeConfigPath, claudeDesktopConfigPath, codexConfigFile, cursorConfigPath, detectAgents, needsWork, planAgent, vscodeConfigPath } from "./initAgents.js";
23
23
  import { copyVersionsIn, ensureStableCommand, pruneCopies } from "./initInstall.js";
@@ -129,7 +129,7 @@ function addHooks(line, context, stable, installProblem) {
129
129
  line.message ??= installProblem;
130
130
  return;
131
131
  }
132
- const invocation = nodeInvocation(stable.node, stable.entry);
132
+ const invocation = stableInvocation(stable);
133
133
  try {
134
134
  const plan = planGuardInstall(line.agent, env, invocation);
135
135
  if (!plan.changes.length) {
@@ -7,6 +7,9 @@ export type StableCommand = {
7
7
  source: "global" | "installed";
8
8
  /** Folder holding the `passport` shim, when this is Passport's own copy. */
9
9
  binDir?: string;
10
+ /** The version-independent launcher in `binDir` that hooks run. Upgrades
11
+ * rewrite it in place, so hooks follow without being edited. */
12
+ launcher?: string;
10
13
  /** Whether `passport` already resolves on PATH (outside npm's cache). */
11
14
  onPath: boolean;
12
15
  };
@@ -37,6 +40,15 @@ export declare function resolveStableNode(context: InstallContext): string | und
37
40
  * only where two versions conflict.
38
41
  */
39
42
  export declare function copyPackageClosure(packageRoot: string, target: string): number;
43
+ /**
44
+ * One launcher's text. It runs the recorded node when that still exists, else
45
+ * whichever node the shell finds, so removing an nvm version doesn't break
46
+ * hooks. The last line keeps the exact `exec '<node>' '<entry>' "$@"` (or
47
+ * `"<node>" "<entry>" %*`) form the Passport plugin reads.
48
+ */
49
+ export declare function launcherText(node: string, entry: string, platform: NodeJS.Platform): string;
50
+ /** The launcher hooks run: `passport` (or `passport.cmd`) in `binDir`. */
51
+ export declare function launcherPath(binDir: string, platform: NodeJS.Platform): string;
40
52
  export declare class StableInstallError extends Error {
41
53
  }
42
54
  /**
@@ -4,20 +4,25 @@
4
4
  * `npx passport-bridge@latest init` runs from npm's cache, which npm may clear at
5
5
  * any time. A hook that points there breaks silently. So init copies the running
6
6
  * package once into `$PASSPORT_HOME/cli/<version>/` (with its dependencies) and
7
- * registers `"<node>" "<that copy>/dist/passport.js"`, both absolute, so hooks
8
- * do not depend on the agent's PATH. A global `passport` from npm
9
- * that is the same version or newer is used instead of a copy.
7
+ * registers the launcher `$PASSPORT_HOME/cli/bin/passport` (`passport.cmd` on
8
+ * Windows), an absolute path, so hooks do not depend on the agent's PATH. The
9
+ * launcher names the version, so an upgrade rewrites it (and the `cli/current`
10
+ * link) and every hook follows without being edited. It runs the recorded node,
11
+ * or the node on PATH once that one is gone. A global `passport` from npm that
12
+ * is the same version or newer is used instead of a copy.
10
13
  *
11
14
  * Every write is atomic: the copy is built in a temporary folder and renamed
12
15
  * into place, so Ctrl-C never leaves a half-installed version behind.
13
16
  */
14
17
  import { randomBytes } from "node:crypto";
15
- import { accessSync, chmodSync, constants, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
18
+ import { accessSync, chmodSync, constants, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
16
19
  import { spawnSync } from "node:child_process";
17
20
  import { basename, delimiter, dirname, join, relative, resolve, sep } from "node:path";
18
21
  import { credentialDir, ensurePrivateDirectory } from "./credentialStorage.js";
19
22
  import { ONE_LINER_MIN_NODE } from "./nodeVersion.js";
20
23
  const INSTALL_MARKER = ".passport-install.json";
24
+ /** `cli/current`: a link to the installed version (POSIX), read by the plugin. */
25
+ const CURRENT = "current";
21
26
  /** npm's cache and the one-off folders npx and pnpm dlx run from. */
22
27
  export function isEphemeralPath(path) {
23
28
  const normalized = path.split(sep).join("/");
@@ -236,7 +241,42 @@ export function copyPackageClosure(packageRoot, target) {
236
241
  function quoteSh(value) {
237
242
  return `'${value.replace(/'/g, `'\\''`)}'`;
238
243
  }
239
- /** Version-independent `passport` and `passport-bridge` launchers for PATH. */
244
+ /**
245
+ * One launcher's text. It runs the recorded node when that still exists, else
246
+ * whichever node the shell finds, so removing an nvm version doesn't break
247
+ * hooks. The last line keeps the exact `exec '<node>' '<entry>' "$@"` (or
248
+ * `"<node>" "<entry>" %*`) form the Passport plugin reads.
249
+ */
250
+ export function launcherText(node, entry, platform) {
251
+ if (platform === "win32") {
252
+ return [
253
+ "@echo off",
254
+ `if not exist "${node}" goto fallback`,
255
+ `"${node}" "${entry}" %*`,
256
+ "exit /b %ERRORLEVEL%",
257
+ ":fallback",
258
+ `node "${entry}" %*`,
259
+ ""
260
+ ].join("\r\n");
261
+ }
262
+ return [
263
+ "#!/bin/sh",
264
+ "# Passport CLI launcher. Upgrades rewrite this file; agent hooks run it.",
265
+ `if [ ! -x ${quoteSh(node)} ]; then`,
266
+ ` for candidate in "$(command -v node 2>/dev/null)" /opt/homebrew/bin/node /usr/local/bin/node; do`,
267
+ ` if [ -n "$candidate" ] && [ -x "$candidate" ]; then exec "$candidate" ${quoteSh(entry)} "$@"; fi`,
268
+ " done",
269
+ "fi",
270
+ `exec ${quoteSh(node)} ${quoteSh(entry)} "$@"`,
271
+ ""
272
+ ].join("\n");
273
+ }
274
+ /** The launcher hooks run: `passport` (or `passport.cmd`) in `binDir`. */
275
+ export function launcherPath(binDir, platform) {
276
+ return join(binDir, platform === "win32" ? "passport.cmd" : "passport");
277
+ }
278
+ /** Version-independent `passport` and `passport-bridge` launchers. Each is
279
+ * replaced with one rename, so a hook never runs a half-written file. */
240
280
  function writeShims(binDir, node, versionDir, platform) {
241
281
  mkdirSync(binDir, { recursive: true, mode: 0o700 });
242
282
  const shims = [
@@ -245,9 +285,7 @@ function writeShims(binDir, node, versionDir, platform) {
245
285
  ];
246
286
  for (const [name, entry] of shims) {
247
287
  const file = join(binDir, platform === "win32" ? `${name}.cmd` : name);
248
- const body = platform === "win32"
249
- ? `@echo off\r\n"${node}" "${entry}" %*\r\n`
250
- : `#!/bin/sh\nexec ${quoteSh(node)} ${quoteSh(entry)} "$@"\n`;
288
+ const body = launcherText(node, entry, platform);
251
289
  try {
252
290
  if (readFileSync(file, "utf8") === body)
253
291
  continue;
@@ -261,6 +299,37 @@ function writeShims(binDir, node, versionDir, platform) {
261
299
  renameSync(temporary, file);
262
300
  }
263
301
  }
302
+ /** `cli/current` → the installed version, swapped with one rename. POSIX only:
303
+ * Windows has the launcher alone. Best effort; the launcher is what hooks run. */
304
+ function pointCurrent(root, version, platform) {
305
+ if (platform === "win32")
306
+ return;
307
+ const link = join(root, CURRENT);
308
+ try {
309
+ if (lstatSync(link).isSymbolicLink() && readlinkSync(link) === version)
310
+ return;
311
+ }
312
+ catch {
313
+ /* not there yet */
314
+ }
315
+ const temporary = join(root, `.current-${randomBytes(6).toString("hex")}.tmp`);
316
+ try {
317
+ symlinkSync(version, temporary);
318
+ renameSync(temporary, link);
319
+ }
320
+ catch {
321
+ rmSync(temporary, { force: true });
322
+ }
323
+ }
324
+ /** The version `cli/current` points at, if any. */
325
+ function currentVersion() {
326
+ try {
327
+ return readlinkSync(join(cliRoot(), CURRENT));
328
+ }
329
+ catch {
330
+ return undefined;
331
+ }
332
+ }
264
333
  export class StableInstallError extends Error {
265
334
  }
266
335
  /**
@@ -301,7 +370,16 @@ export function ensureStableCommand(context) {
301
370
  }
302
371
  const binDir = join(root, "bin");
303
372
  writeShims(binDir, node, versionDir, context.platform);
304
- return { node, entry: join(versionDir, "dist", "passport.js"), version, source: "installed", binDir, onPath };
373
+ pointCurrent(root, version, context.platform);
374
+ return {
375
+ node,
376
+ entry: join(versionDir, "dist", "passport.js"),
377
+ version,
378
+ source: "installed",
379
+ binDir,
380
+ launcher: launcherPath(binDir, context.platform),
381
+ onPath
382
+ };
305
383
  }
306
384
  /** The versions of Passport's own copies that these commands run. */
307
385
  export function copyVersionsIn(commands) {
@@ -326,6 +404,9 @@ export function copyVersionsIn(commands) {
326
404
  */
327
405
  export function pruneCopies(keep) {
328
406
  const kept = new Set(keep);
407
+ const linked = currentVersion();
408
+ if (linked)
409
+ kept.add(linked);
329
410
  const removed = [];
330
411
  let entries;
331
412
  try {
@@ -335,7 +416,7 @@ export function pruneCopies(keep) {
335
416
  return removed;
336
417
  }
337
418
  for (const entry of entries) {
338
- if (entry === "bin" || entry.startsWith(".") || kept.has(entry))
419
+ if (entry === "bin" || entry === CURRENT || entry.startsWith(".") || kept.has(entry))
339
420
  continue;
340
421
  const directory = join(cliRoot(), entry);
341
422
  if (!existsSync(join(directory, INSTALL_MARKER)))
@@ -357,7 +438,7 @@ export function isOtherPassportInstall(path, version) {
357
438
  if (rel.startsWith("..") || rel === "")
358
439
  return false;
359
440
  const [installed] = rel.split(sep);
360
- return installed !== version && installed !== "bin";
441
+ return installed !== version && installed !== "bin" && installed !== CURRENT;
361
442
  }
362
443
  /** One line a person can paste to put `passport` on PATH. Printed, never run. */
363
444
  export function pathLine(binDir, env, home, platform) {
@@ -4,7 +4,7 @@
4
4
  * destructive production actions ask first.
5
5
  */
6
6
  import { bool } from "./cliArgs.js";
7
- import { HOOK_CLIENTS, applyGuardInstall, nodeInvocation, planGuardInstall, registeredEntries } from "./cliHookInstall.js";
7
+ import { HOOK_CLIENTS, applyGuardInstall, stableInvocation, planGuardInstall, registeredEntries } from "./cliHookInstall.js";
8
8
  import { CliFailure, readBoundedJson, safeApiError } from "./cliSupport.js";
9
9
  import { AGENT_NAMES, applyAgent, backupOnce, detectAgents, displayHome, editsExistingFile, needsWork, planAgent } from "./initAgents.js";
10
10
  import { copyVersionsIn, ensureStableCommand, pruneCopies } from "./initInstall.js";
@@ -209,7 +209,7 @@ async function guardSetup(s) {
209
209
  return;
210
210
  }
211
211
  s.stable = stable;
212
- const invocation = nodeInvocation(stable.node, stable.entry);
212
+ const invocation = stableInvocation(stable);
213
213
  const plans = [];
214
214
  const problems = [];
215
215
  for (const client of clients) {
@@ -241,8 +241,9 @@ function interpreter(program, words, ctx) {
241
241
  return local(fromVerdict(args[1], answer, ctx.here));
242
242
  return unknown(`python -m ${args[1]} not recognized`);
243
243
  }
244
- if (program === "node" && args[0] === "--test")
245
- return local(fromVerdict("node", R("test"), ctx.here));
244
+ // `node --test` and `tsx --test` run the project's own test files.
245
+ if ((program === "node" || program === "tsx") && args[0] === "--test")
246
+ return local(fromVerdict(program, R("test"), ctx.here));
246
247
  if (program === "node" && (args[0] === "--check" || args[0] === "-c"))
247
248
  return local(fromVerdict("node", R("check"), ctx.here));
248
249
  return unknown(`${program} runs code Passport can't see`);
@@ -257,6 +258,8 @@ function packageRunner(words, ctx) {
257
258
  const tool = basename(name);
258
259
  if (ctx.isVendor(tool) || /^@(railway|sentry|stripe)\//.test(name) || /^(vercel|wrangler|supabase)$/.test(tool))
259
260
  return { kind: "vendor" };
261
+ if (tool === "tsx")
262
+ return interpreter(tool, words.slice(index + 1), ctx);
260
263
  return toolCommand(tool, words.slice(index + 1), ctx);
261
264
  }
262
265
  function toolCommand(program, words, ctx) {
@@ -409,7 +412,7 @@ const PROGRAMS = {
409
412
  : toolCommand(program, rest, ctx),
410
413
  ...each(["docker", "podman", "docker-compose"], (program, rest, ctx) => docker(program, rest, ctx)),
411
414
  ...each(["kill", "pkill", "killall"], (program, rest) => processControl(program, rest)),
412
- ...each(["node", "python", "python3", "ruby", "perl"], (program, rest, ctx) => interpreter(program, rest, ctx)),
415
+ ...each(["node", "tsx", "python", "python3", "ruby", "perl"], (program, rest, ctx) => interpreter(program, rest, ctx)),
413
416
  deno: (program, rest, ctx) => rest[0] && !rest[0].text.startsWith("-") ? toolCommand(program, rest, ctx) : interpreter(program, rest, ctx),
414
417
  ...each(["env", "printenv"], () => unknown("prints the environment")),
415
418
  ...each(["dd", "mkfs", "diskutil", "fdisk"], (program) => unknown(`${program} writes disks`))
@@ -4,4 +4,4 @@
4
4
  * the version, then runs `npm run set-version -- <version>` in the plugin repo
5
5
  * and pushes (docs/RELEASING.md). `pluginPin.test.ts` fails when it drifts.
6
6
  */
7
- export declare const PLUGIN_PIN = "0.16.2";
7
+ export declare const PLUGIN_PIN = "0.16.3";
package/dist/pluginPin.js CHANGED
@@ -4,4 +4,4 @@
4
4
  * the version, then runs `npm run set-version -- <version>` in the plugin repo
5
5
  * and pushes (docs/RELEASING.md). `pluginPin.test.ts` fails when it drifts.
6
6
  */
7
- export const PLUGIN_PIN = "0.16.2";
7
+ export const PLUGIN_PIN = "0.16.3";
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.16.2";
1
+ export declare const VERSION = "0.16.3";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Keep in lockstep with bridge/package.json.
2
- export const VERSION = "0.16.2";
2
+ export const VERSION = "0.16.3";
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "passport-bridge",
9
- "version": "0.16.2",
9
+ "version": "0.16.3",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "1.30.0"
@@ -1359,9 +1359,9 @@
1359
1359
  }
1360
1360
  },
1361
1361
  "node_modules/proxy-addr": {
1362
- "version": "2.0.7",
1363
- "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
1364
- "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
1362
+ "version": "2.0.8",
1363
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
1364
+ "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
1365
1365
  "license": "MIT",
1366
1366
  "dependencies": {
1367
1367
  "forwarded": "0.2.0",
@@ -1369,6 +1369,10 @@
1369
1369
  },
1370
1370
  "engines": {
1371
1371
  "node": ">= 0.10"
1372
+ },
1373
+ "funding": {
1374
+ "type": "opencollective",
1375
+ "url": "https://opencollective.com/express"
1372
1376
  }
1373
1377
  },
1374
1378
  "node_modules/qs": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Passport CLI for governed terminal and CI agents, plus the local stdio-to-cloud MCP bridge.",
5
5
  "license": "MIT",
6
6
  "repository": {