@patchstack/connect 0.5.9 → 0.5.10
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/AGENT-INSTALL.md +61 -0
- package/README.md +62 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/AGENT-INSTALL.md
CHANGED
|
@@ -94,6 +94,66 @@ This is a request, not a mechanism: nothing in the install depends on it. Do it
|
|
|
94
94
|
|
|
95
95
|
**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.
|
|
96
96
|
|
|
97
|
+
## When your tool will not run this CLI
|
|
98
|
+
|
|
99
|
+
Some coding tools refuse to execute a third-party command until the person approves it. In Claude Code,
|
|
100
|
+
auto mode's classifier can decline `npx @patchstack/connect setup` and the installed `patchstack-connect`
|
|
101
|
+
binary on that ground instead of prompting. The command is not the problem; the approval is missing.
|
|
102
|
+
Handle it in this order:
|
|
103
|
+
|
|
104
|
+
1. **Stop at the refused command.** Do not route around the refusal: do not call the Patchstack API
|
|
105
|
+
yourself, do not wrap the command in a `package.json` script so a later install runs it, and do not add
|
|
106
|
+
the `postinstall` / `prebuild` hooks first so the next install provisions the site. Each of those runs
|
|
107
|
+
the command the tool declined, with the person's decision taken away from them. Leave `package.json`
|
|
108
|
+
and the source tree as they were.
|
|
109
|
+
|
|
110
|
+
2. **Hand the person the ways forward, with the exact text.** Say what the command does in plain words —
|
|
111
|
+
it registers the site with Patchstack, writes two small config files, adds the "Report a vulnerability"
|
|
112
|
+
line to the page, and adds the protection files and build steps described above — then give them:
|
|
113
|
+
|
|
114
|
+
- **Run it themselves, in this session.** In Claude Code a line that starts with `!` runs in their shell
|
|
115
|
+
and its output lands in the conversation: `! npx @patchstack/connect setup`. Other tools have a
|
|
116
|
+
terminal beside the chat; the command is the same without the `!`.
|
|
117
|
+
- **Approve it once.** In Claude Code, `/permissions` → **Recently denied** → `r` retries the command
|
|
118
|
+
with a manual approval; or `Shift+Tab` switches to Manual mode, and the tool prompts them when you
|
|
119
|
+
try again.
|
|
120
|
+
- **Allow it for good, then ask you to run it again.** For Claude Code these rules pre-approve every
|
|
121
|
+
`npx @patchstack/connect …` command and nothing else. They go in `.claude/settings.json` (shared with
|
|
122
|
+
the repository), `.claude/settings.local.json` (this person only), or through `/permissions`:
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"permissions": {
|
|
127
|
+
"allow": [
|
|
128
|
+
"Bash(npx @patchstack/connect *)",
|
|
129
|
+
"Bash(npx --yes @patchstack/connect *)"
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Other tools keep their own allowlists; the README section "If your coding tool blocks the command"
|
|
136
|
+
shows the Gemini CLI and OpenCode forms.
|
|
137
|
+
|
|
138
|
+
3. **Write the command as `npx @patchstack/connect <command>`.** A rule matches the command text as
|
|
139
|
+
written. `./node_modules/.bin/patchstack-connect setup`, `PATCHSTACK_ENVIRONMENT=sandbox npx …` and
|
|
140
|
+
`npx --yes patchstack-connect setup` are different texts, and the rules above do not cover them. On a
|
|
141
|
+
developer's machine the sandbox label is not needed anyway: a scan there reports `local` on its own.
|
|
142
|
+
|
|
143
|
+
4. **Resume from the output.** `setup` prints the same checklist, dashboard link and outcome block whoever
|
|
144
|
+
ran it, and re-running it changes nothing that is already done. If the person ran it, relay the
|
|
145
|
+
dashboard link and the outcome block from their output as they are. If your tool still will not run
|
|
146
|
+
`guide` or `status` for you, verify from the files instead of guessing: `siteUuid` in
|
|
147
|
+
`.patchstackrc.json` means the site is provisioned; `patchstack-connect scan` and
|
|
148
|
+
`patchstack-connect mark-build` in the `package.json` scripts mean the hooks are wired;
|
|
149
|
+
`patchstack-widget.js` in the root shell means the widget is in place; `.patchstackrc.local.json` in
|
|
150
|
+
`.gitignore` means the credential stays out of the commit. Never construct a dashboard link yourself —
|
|
151
|
+
it comes from `setup`, `status` or `claim` output.
|
|
152
|
+
|
|
153
|
+
5. **`claim` and `login` are the same shape.** Both print a link the person opens. If your tool will not
|
|
154
|
+
run them, the person runs `npx @patchstack/connect claim` (or `login`) themselves and you relay the
|
|
155
|
+
link from their output.
|
|
156
|
+
|
|
97
157
|
## Manual setup
|
|
98
158
|
|
|
99
159
|
1. **First scan** — provisions a Patchstack site automatically, writes the UUID to `.patchstackrc.json`, and installs the disclosure widget's `<script>` tag into the root HTML shell (`index.html`, `public/index.html`, or `src/app.html`) when one exists — or, when the root shell is JSX, the production marker instead. No signup, dashboard step, or UUID is needed up front:
|
|
@@ -197,6 +257,7 @@ It is server-only. Never put it in the widget tag, client bundles, or public env
|
|
|
197
257
|
- The CLI never opens the dashboard link and never asks for Patchstack credentials.
|
|
198
258
|
- Label hosted workspace scans with `PATCHSTACK_ENVIRONMENT=sandbox` in that process only. Leave production builds unset (a platform's own tier or production branch name, or the hosted builder the project belongs to, makes the build report `production`; a developer machine or a CI runner this does not know reports `local`) and never commit a sandbox label into files shared with production.
|
|
199
259
|
- If a step fails, stop and report it. Don't proceed with placeholders.
|
|
260
|
+
- If your tool refuses to execute the CLI, stop and hand the command to the person — see "When your tool will not run this CLI". Never work around a permission refusal.
|
|
200
261
|
- CI never has the credential in a file: `.patchstackrc.local.json` is git-ignored by design, so set `PATCHSTACK_API_KEY` as an env var there (and `PATCHSTACK_SITE_UUID` too where `.patchstackrc.json` is also absent). Precedence for the site UUID and settings: CLI flag → env var → `.patchstackrc.json`. For the API key: env var → `.patchstackrc.local.json` → `.patchstackrc.json` (where installs made before the split still hold it). `login` is interactive and refuses to run in CI, so CI always takes its credential from the environment.
|
|
201
262
|
|
|
202
263
|
## Which build a rule belongs to
|
package/README.md
CHANGED
|
@@ -10,6 +10,68 @@ Copy this request into a coding assistant, or run the same command yourself:
|
|
|
10
10
|
|
|
11
11
|
`setup` is state-aware and idempotent: it scans dependencies, provisions or reuses the site, manages the disclosure widget, installs and verifies the runtime guard, adds a dependency-install scan, wires the existing build command without replacing it, and prints the remaining setup status. It never runs the project build. `guide` provides the same project-specific status without changing files.
|
|
12
12
|
|
|
13
|
+
### If your coding tool blocks the command
|
|
14
|
+
|
|
15
|
+
Some tools will not run a third-party command until you approve it. Claude Code's auto mode, for example,
|
|
16
|
+
can decline `npx @patchstack/connect setup` instead of prompting you, and the assistant then stops and asks
|
|
17
|
+
you how to proceed. Any of these works:
|
|
18
|
+
|
|
19
|
+
- **Run it yourself, in the same session.** In Claude Code, a line that starts with `!` runs in your shell
|
|
20
|
+
and its output lands in the conversation, so the assistant carries on from it:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
! npx @patchstack/connect setup
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Elsewhere, run the same command without the `!` in a terminal and tell the assistant it is done. `setup`
|
|
27
|
+
is idempotent, so a partial earlier attempt does no harm.
|
|
28
|
+
|
|
29
|
+
- **Approve it once.** In Claude Code, open `/permissions`, pick the **Recently denied** tab and press `r`
|
|
30
|
+
to retry the command with a manual approval — or press `Shift+Tab` to switch to Manual mode and approve
|
|
31
|
+
the prompt when the assistant tries again.
|
|
32
|
+
|
|
33
|
+
- **Allow it, then ask again.** Claude Code resolves explicit allow rules before its classifier. These two
|
|
34
|
+
rules cover every `npx @patchstack/connect …` command (`setup`, `guide`, `status`, `claim`) and nothing
|
|
35
|
+
else. Put them in `.claude/settings.json` to share them with the repository, in
|
|
36
|
+
`.claude/settings.local.json` to keep them to yourself, or add them through `/permissions`:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"permissions": {
|
|
41
|
+
"allow": [
|
|
42
|
+
"Bash(npx @patchstack/connect *)",
|
|
43
|
+
"Bash(npx --yes @patchstack/connect *)"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
A rule matches the command text as written, so use the plain `npx @patchstack/connect …` form: a leading
|
|
50
|
+
`PATCHSTACK_ENVIRONMENT=sandbox`, a path such as `./node_modules/.bin/patchstack-connect`, or the bare
|
|
51
|
+
`patchstack-connect` binary name is a different text and is not covered. On your own machine the sandbox
|
|
52
|
+
label is not needed — a scan there reports `local` by itself. Rules in a project's `.claude/settings.json`
|
|
53
|
+
apply once you have accepted that folder's trust dialog. If auto mode still declines the command with the
|
|
54
|
+
rules in place, use one of the first two options.
|
|
55
|
+
|
|
56
|
+
Other tools keep their own allowlists. Gemini CLI reads policy files from `~/.gemini/policies/`:
|
|
57
|
+
|
|
58
|
+
```toml
|
|
59
|
+
[[rule]]
|
|
60
|
+
toolName = "run_shell_command"
|
|
61
|
+
commandPrefix = "npx @patchstack/connect"
|
|
62
|
+
decision = "allow"
|
|
63
|
+
priority = 100
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
OpenCode takes the pattern in `opencode.json` (project root, or `~/.config/opencode/opencode.json`):
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{ "permission": { "bash": { "npx @patchstack/connect *": "allow" } } }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Codex CLI asks according to `approval_policy` in `~/.codex/config.toml`: approve the command when it
|
|
73
|
+
asks, or run it yourself.
|
|
74
|
+
|
|
13
75
|
## Quick start (zero configuration)
|
|
14
76
|
|
|
15
77
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -5855,6 +5855,8 @@ function renderGuideChecklist(state, useColor) {
|
|
|
5855
5855
|
lines.push(detail("Run \u2192 npx @patchstack/connect scan"));
|
|
5856
5856
|
lines.push(detail("Reads the lockfile, registers the project, writes .patchstackrc.json,"));
|
|
5857
5857
|
lines.push(detail("and prints a dashboard link. The CLI prints the link but never opens it."));
|
|
5858
|
+
lines.push(detail("If your tool refuses to run this command, hand it to the person instead of working"));
|
|
5859
|
+
lines.push(detail('around it \u2014 see "When your tool will not run this CLI" in the reference guide.'));
|
|
5858
5860
|
}
|
|
5859
5861
|
if (state.installScanWired) {
|
|
5860
5862
|
lines.push(done("Dependency-install scan wired (postinstall)"));
|