From 93231adedd59806da95c59689b4a5ef953fd7b66 Mon Sep 17 00:00:00 2001 From: Mario Tarosso Date: Thu, 17 Sep 2026 08:21:59 +0100 Subject: [PATCH] Give an agent a supported path when its tool will not run setup Some coding tools refuse to execute a third-party command until the person approves it, and the shipped docs said nothing about that case. The agent now finds one: stop at the refused command, hand the person the exact command and the permission rules that cover it, and resume from their output. The recommended Claude Code rules are the two `npx @patchstack/connect` forms and nothing broader; a test fails if a doc recommends any other Bash rule shape. A synthetic `restricted-cli` persona runs the flow under exactly those rules. Co-Authored-By: Claude Fable 5.1 --- AGENT-INSTALL.md | 61 +++++++++++++++ GETTING-STARTED.md | 3 +- README.md | 62 +++++++++++++++ field-test/README.md | 6 +- field-test/personas/restricted-cli.md | 62 +++++++++++++++ src/guide.ts | 2 + tests/guide.test.ts | 25 +++++- tests/permission-handoff.test.ts | 108 ++++++++++++++++++++++++++ 8 files changed, 326 insertions(+), 3 deletions(-) create mode 100644 field-test/personas/restricted-cli.md create mode 100644 tests/permission-handoff.test.ts diff --git a/AGENT-INSTALL.md b/AGENT-INSTALL.md index 47adc578..f9b67588 100644 --- a/AGENT-INSTALL.md +++ b/AGENT-INSTALL.md @@ -94,6 +94,66 @@ This is a request, not a mechanism: nothing in the install depends on it. Do it **Then tell them to deploy.** Setup changes source files, and the deployed site keeps serving its previous build until the next deploy — so visitors get no widget, and on a server-rendered root no production marker, until the user deploys (or hits Publish) again. Say it as a reminder; do not deploy anything yourself. +## When your tool will not run this CLI + +Some coding tools refuse to execute a third-party command until the person approves it. In Claude Code, +auto mode's classifier can decline `npx @patchstack/connect setup` and the installed `patchstack-connect` +binary on that ground instead of prompting. The command is not the problem; the approval is missing. +Handle it in this order: + +1. **Stop at the refused command.** Do not route around the refusal: do not call the Patchstack API + yourself, do not wrap the command in a `package.json` script so a later install runs it, and do not add + the `postinstall` / `prebuild` hooks first so the next install provisions the site. Each of those runs + the command the tool declined, with the person's decision taken away from them. Leave `package.json` + and the source tree as they were. + +2. **Hand the person the ways forward, with the exact text.** Say what the command does in plain words — + it registers the site with Patchstack, writes two small config files, adds the "Report a vulnerability" + line to the page, and adds the protection files and build steps described above — then give them: + + - **Run it themselves, in this session.** In Claude Code a line that starts with `!` runs in their shell + and its output lands in the conversation: `! npx @patchstack/connect setup`. Other tools have a + terminal beside the chat; the command is the same without the `!`. + - **Approve it once.** In Claude Code, `/permissions` → **Recently denied** → `r` retries the command + with a manual approval; or `Shift+Tab` switches to Manual mode, and the tool prompts them when you + try again. + - **Allow it for good, then ask you to run it again.** For Claude Code these rules pre-approve every + `npx @patchstack/connect …` command and nothing else. They go in `.claude/settings.json` (shared with + the repository), `.claude/settings.local.json` (this person only), or through `/permissions`: + + ```json + { + "permissions": { + "allow": [ + "Bash(npx @patchstack/connect *)", + "Bash(npx --yes @patchstack/connect *)" + ] + } + } + ``` + + Other tools keep their own allowlists; the README section "If your coding tool blocks the command" + shows the Gemini CLI and OpenCode forms. + +3. **Write the command as `npx @patchstack/connect `.** A rule matches the command text as + written. `./node_modules/.bin/patchstack-connect setup`, `PATCHSTACK_ENVIRONMENT=sandbox npx …` and + `npx --yes patchstack-connect setup` are different texts, and the rules above do not cover them. On a + developer's machine the sandbox label is not needed anyway: a scan there reports `local` on its own. + +4. **Resume from the output.** `setup` prints the same checklist, dashboard link and outcome block whoever + ran it, and re-running it changes nothing that is already done. If the person ran it, relay the + dashboard link and the outcome block from their output as they are. If your tool still will not run + `guide` or `status` for you, verify from the files instead of guessing: `siteUuid` in + `.patchstackrc.json` means the site is provisioned; `patchstack-connect scan` and + `patchstack-connect mark-build` in the `package.json` scripts mean the hooks are wired; + `patchstack-widget.js` in the root shell means the widget is in place; `.patchstackrc.local.json` in + `.gitignore` means the credential stays out of the commit. Never construct a dashboard link yourself — + it comes from `setup`, `status` or `claim` output. + +5. **`claim` and `login` are the same shape.** Both print a link the person opens. If your tool will not + run them, the person runs `npx @patchstack/connect claim` (or `login`) themselves and you relay the + link from their output. + ## Manual setup 1. **First scan** — provisions a Patchstack site automatically, writes the UUID to `.patchstackrc.json`, and installs the disclosure widget's `