send-to-paseo 1.3.0

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 ADDED
@@ -0,0 +1,879 @@
1
+ # send-to-paseo
2
+
3
+ A Paseo plugin that runs a small local HTTP bridge so a browser extension can
4
+ send work from a pull request to the right workspace and agent — creating a
5
+ worktree checked out to the PR if none exists.
6
+
7
+ ![The Send to Paseo composer open on a live github.com pull request — rails/rails #58627, state Open, merging Shopify:actionpack-singleton-class-attrs into rails:main — with the button anchored in GitHub's own PR header action row beside Code, and the popover below it showing the resolved target workspace, the target picker, the typed instruction "Fix the flaky test in this PR", the Provider and Mode selects, and the Cmd-Enter / Esc footer with Send enabled](https://raw.githubusercontent.com/tomgrin10/send-to-paseo/main/docs/screenshots/hero-github-pr-popover.png)
8
+
9
+ The extension never talks to the Paseo daemon. It talks only to this bridge,
10
+ which speaks the frozen API in [the repository contract](https://github.com/tomgrin10/send-to-paseo/blob/main/CONTRACT.md) and reaches
11
+ Paseo through the supported SDK.
12
+
13
+ - Bridge: `http://127.0.0.1:7788`, loopback only, bearer token required.
14
+ - Surface: **Send to Paseo** in the Paseo sidebar — status, token, agent destination,
15
+ new-agent defaults, recent sends.
16
+ - Verified behaviour, with real command output, is recorded in the
17
+ [repository](https://github.com/tomgrin10/send-to-paseo/blob/main/plugin/VERIFICATION.md).
18
+
19
+ ---
20
+
21
+ ## Requirements
22
+
23
+ Two external commands, one required and one optional. **Nothing here is fatal
24
+ except `git`** — with no `gh` at all you can still open the popover, pick a
25
+ workspace and start an agent, because Paseo checks the pull request out itself
26
+ through its own forge credentials. `gh` only supplies metadata.
27
+
28
+ | | Required? | Minimum verified | What it is used for | What breaks without it |
29
+ | --- | --- | --- | --- | --- |
30
+ | **Paseo** | yes | `0.9.0` | Everything. The surface uses Paseo 0.9's configured-host discovery and host-targeted client APIs. | The plugin does not load. |
31
+ | **`git`** | yes | `2.51.2` | Reading the branch a workspace is on, and the repository's `origin`. Paseo itself needs it to create a worktree. | Creating a worktree fails with a message naming `git`. Workspace branches read as unknown, so nothing is ranked as an exact or stack match — everything falls back to "create". |
32
+ | **`gh`** | **no** | `2.98.0` | PR title, head and base branch names, and stack discovery (`gh pr list` rebuilds the whole Graphite stack, including its merged and closed members). | Sending still works. You lose the PR title, the branch names, exact/stack candidate ranking, and the `Title:`/`Branch:` lines in the agent's prompt. Stack detection is lost **entirely**, local git ancestry included: that check proves "this branch is an ancestor of a branch in the stack", and without `gh` there is no stack and no PR head branch to compare against. The bridge says so in the target picker, in the agent's prompt and in the log. |
33
+
34
+ Node is not a separate requirement: the plugin runs inside the Paseo daemon's
35
+ own Node runtime.
36
+
37
+ ### Install commands
38
+
39
+ ```sh
40
+ # macOS
41
+ xcode-select --install # git
42
+ brew install gh # optional
43
+
44
+ # Debian / Ubuntu
45
+ sudo apt install git
46
+ sudo apt install gh # optional; see cli.github.com for other distros
47
+
48
+ # Fedora / RHEL
49
+ sudo dnf install git
50
+ sudo dnf install gh # optional
51
+ ```
52
+
53
+ Then, if you installed `gh`:
54
+
55
+ ```sh
56
+ gh auth login # optional, but this is what makes titles and stacks work
57
+ gh auth status # should print the account and no error
58
+ ```
59
+
60
+ ### Where the plugin looks for them
61
+
62
+ This matters more than it sounds. A Paseo plugin runs in a daemon subprocess,
63
+ and the daemon is normally started by the desktop app rather than by your shell.
64
+ `/Applications/Paseo.app` itself is launched with
65
+
66
+ ```
67
+ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
68
+ ```
69
+
70
+ — no `/opt/homebrew/bin`. Paseo enriched `PATH` for plugin subprocesses in the
71
+ original `0.7.0` measurement, but the plugin does
72
+ not rely on that. Every lookup searches, in order:
73
+
74
+ 1. `SEND_TO_PASEO_GH_PATH` / `SEND_TO_PASEO_GIT_PATH`, if set;
75
+ 2. every directory on the subprocess's `PATH`;
76
+ 3. a short list of well-known install locations — `/opt/homebrew/bin`,
77
+ `/usr/local/bin`, `/usr/bin`, `/bin`, `/opt/local/bin`, `~/.local/bin`,
78
+ `/home/linuxbrew/.linuxbrew/bin`, `/snap/bin`, `/usr/local/git/bin`.
79
+
80
+ Set `SEND_TO_PASEO_BIN_DIRS` to replace step 3 with your own colon-separated
81
+ list if your tools live somewhere else entirely.
82
+
83
+ Nothing is ever spawned through a shell. `gh` is a shell *function* in some
84
+ people's `zsh`, so the plugin resolves the executable itself and calls it with an
85
+ argv array.
86
+
87
+ ### Dependency self-check
88
+
89
+ Every plugin start logs one line per command, plus the `PATH` it actually got:
90
+
91
+ ```
92
+ [send-to-paseo] dependency git: ok — git version 2.51.2 at /opt/homebrew/bin/git
93
+ [send-to-paseo] dependency gh: ok — gh version 2.98.0 (2026-08-20) at /opt/homebrew/bin/gh
94
+ [send-to-paseo] plugin subprocess PATH=~/.local/bin:...:/opt/homebrew/bin:...
95
+ ```
96
+
97
+ ```sh
98
+ paseo plugin logs send-to-paseo
99
+ ```
100
+
101
+ The same information is on the **Requirements** card in the Paseo surface, which
102
+ is the place to look first if you have never opened a log file.
103
+
104
+ ---
105
+
106
+ ## Install
107
+
108
+ Plugins are trusted, unsandboxed code: this one runs an HTTP server that can
109
+ start agents which execute arbitrary code on the daemon machine. Read the source
110
+ before installing it.
111
+
112
+ One command from npm. No clone or build step:
113
+
114
+ ```sh
115
+ paseo plugin install npm:send-to-paseo@1.3.0
116
+ paseo plugin ls # expect: send-to-paseo running yes
117
+ paseo plugin logs send-to-paseo
118
+ ```
119
+
120
+ The same release is available directly from Git with
121
+ `paseo plugin add tomgrin10/send-to-paseo --path plugin --ref v1.3.0`.
122
+ `pluginsEnabled` must already be `true` in the daemon's `config.json`.
123
+
124
+ There is nothing to install because the plugin imports nothing at runtime that
125
+ the Paseo host does not already provide — see
126
+ [No runtime dependencies, ever](#no-runtime-dependencies-ever). To upgrade a
127
+ Git-managed install, run `paseo plugin update send-to-paseo`; for a checkout,
128
+ run `paseo plugin reload send-to-paseo`.
129
+
130
+ ### From a checkout (contributors)
131
+
132
+ Installing from a directory is the loop to use while editing, because
133
+ `paseo plugin reload` picks up changes in place:
134
+
135
+ ```sh
136
+ git clone https://github.com/tomgrin10/send-to-paseo.git
137
+ cd send-to-paseo/plugin
138
+ npm install # devDependencies only — for `npm run typecheck`
139
+ npm run verify
140
+ paseo plugin add /absolute/path/to/send-to-paseo/plugin
141
+ paseo plugin ls # expect: send-to-paseo running yes
142
+ ```
143
+
144
+ After editing the source:
145
+
146
+ ```sh
147
+ npm run verify
148
+ paseo plugin reload send-to-paseo
149
+ ```
150
+
151
+ Never restart the daemon to pick up plugin changes — that kills running agents.
152
+
153
+ ### No runtime dependencies, ever
154
+
155
+ `paseo plugin add` compiles the plugin **with no packages installed** — there is
156
+ no `npm install` step in that path, and the daemon's bundler can only resolve the
157
+ specifiers the host provides at runtime:
158
+
159
+ ```
160
+ @getpaseo/plugin @getpaseo/plugin/client @getpaseo/plugin/server
161
+ @getpaseo/plugin/client/react-native
162
+ zod react react/jsx-runtime react-native @tanstack/react-query
163
+ node:* (built-ins, in the server bundle)
164
+ ```
165
+
166
+ Everything in `plugin/package.json` is therefore a **devDependency**, present only
167
+ so `npm run typecheck` works for contributors.
168
+
169
+ > **Nothing may be added to `dependencies`.** A runtime import of anything outside
170
+ > the list above fails `paseo plugin add` for every user with
171
+ > `Build failed: Could not resolve "<pkg>"`, while still working perfectly on any
172
+ > machine that has run `npm install` — so it will not be caught locally. Imports
173
+ > from `@getpaseo/client` and `@getpaseo/protocol` must stay `import type` (erased
174
+ > at build time) or be reimplemented locally; the one runtime use of the Paseo SDK
175
+ > goes through the assembled-specifier `require` in `server/daemon.ts`, precisely
176
+ > so the bundler cannot see it. Before changing an import, read
177
+ > [`VERIFICATION.md`](VERIFICATION.md) §18, which includes the exact
178
+ > no-`node_modules` build command that proves an install still works.
179
+
180
+ ### Pairing
181
+
182
+ 1. Open **Send to Paseo** in the Paseo sidebar.
183
+ 2. Under **Pairing token**, press **Copy** (or **Reveal** and copy by hand).
184
+ 3. Paste it into the extension's options page. Simple setup already uses the Primary Paseo
185
+ machine's loopback bridge URL.
186
+
187
+ **Regenerate** issues a new token and immediately invalidates the old one, so any
188
+ paired extension has to be re-paired.
189
+
190
+ ---
191
+
192
+ ## Configuration
193
+
194
+ All of it lives in the Paseo surface; there is no config file to hunt for.
195
+
196
+ | Setting | Default | Notes |
197
+ | --- | --- | --- |
198
+ | Port | `7788` | Saving rebinds the listener straight away. Bind address is always `127.0.0.1`. |
199
+ | Private bridge address (`externalBridgeUrl`) | none | Optional HTTPS origin for a reverse proxy such as Tailscale Serve. Saving explicitly allowlists only that origin's Host header; the listener remains loopback-only. |
200
+ | Paseo host discovery | automatic | Paseo 0.9 supplies every configured host and live status, including offline hosts. “Check Paseo access” always calls `getPaseoClient(serverId)` for that exact row. |
201
+ | Additional browser routes | none | Connections imported from `stp1_…` codes. These remain necessary only because host discovery exposes neither a private bridge URL nor its token; the Primary plugin resolves and sends through these bridges. |
202
+ | Pairing token | generated on first run | 32 random bytes, base64url. |
203
+ | Agent destination | `New agent` | Start a fresh agent, or reuse the best non-archived root agent in an existing target workspace. A create target and a workspace with no eligible root still start a new agent. |
204
+ | Default model | the daemon's own default | `provider/model`, e.g. `claude/claude-opus-5`. A send may override it per request. |
205
+ | Agent profile | none | One of your saved Paseo profiles (`daemon.agentProfiles`), followed by id. |
206
+ | Default permission mode | follow Paseo | A mode id, e.g. `auto`. Mode ids are per provider. |
207
+
208
+ State is stored at `$PASEO_HOME/plugin-data/send-to-paseo/settings.json`, written
209
+ `0600` inside a `0700` directory. It holds the token, the port, the default
210
+ model, the followed profile id, the default mode, the paired flag, the last 20
211
+ sends, the declared `externalBridgeUrl`, connected Additional Paseo machines with their server IDs
212
+ and tokens, two optional advanced allowlists —
213
+ `allowedExtensionIds` and `allowedHosts` (see [Security model](#security-model))
214
+ — and `daemonPassword`.
215
+
216
+ ### A daemon that requires a password
217
+
218
+ A daemon whose `listen` is not loopback turns on `daemon.auth.password`, and it
219
+ then refuses an unauthenticated connection outright. Without the password the
220
+ plugin lists no providers and no modes, reports the daemon unreachable, and
221
+ every send fails. Measured against a daemon on `0.0.0.0:6767`:
222
+
223
+ | Probe | Result |
224
+ | --- | --- |
225
+ | `GET /api/health` | `200` — unauthenticated, so liveness is decided here |
226
+ | `GET /api/status` | `401 Unauthorized` |
227
+ | SDK WebSocket, no password | closed with `Password required` |
228
+
229
+ `daemon.auth.password` in Paseo's `config.json` is a **bcrypt hash**, so the
230
+ plaintext cannot be derived from it and has to be supplied. Four sources, in
231
+ order:
232
+
233
+ 1. `SEND_TO_PASEO_DAEMON_PASSWORD`
234
+ 2. `PASEO_PASSWORD` — the standard Paseo variable, the same one the `paseo` CLI reads
235
+ 3. `~/paseo-hub/secrets/daemon-password` — the shared Paseo VM secret convention
236
+ 4. `"daemonPassword": "…"` in the plugin's own `settings.json`
237
+
238
+ **Prefer the VM secret file where that convention exists; use plugin settings
239
+ elsewhere.** The plugin subprocess inherits the daemon's environment, which is
240
+ fixed at daemon start, so a new env var would need a daemon restart — and that
241
+ kills running agents. Either file is picked up by
242
+ `paseo plugin reload send-to-paseo`. Surrounding whitespace in the VM secret
243
+ file is ignored.
244
+
245
+ The plugin-owned settings file is `0600` and has no password UI. The VM secret
246
+ file is read but never modified. Password values are never logged, echoed into
247
+ an error, or included in a status payload.
248
+
249
+ Note that on such a daemon the `paseo` CLI needs the password too, so
250
+ `PASEO_PASSWORD` has to be set in your shell before `paseo plugin reload` will
251
+ work at all.
252
+
253
+ `defaultProfileId`, `defaultModeId`, `externalBridgeUrl`, `additionalMachines` and `allowedHosts` are read with schema
254
+ defaults, so a `settings.json` written before those fields existed still
255
+ validates. That matters more than it looks: a failed parse regenerates the file,
256
+ and the file holds the pairing token — an upgrade must not silently unpair the
257
+ extension.
258
+
259
+ ### Connect Primary and Additional Paseo machines
260
+
261
+ The **Paseo machines** card is populated automatically from the app's configured hosts. It keeps
262
+ offline hosts visible and correlates a saved browser route only by exact `serverId`; labels and URLs
263
+ are never treated as identity. The per-row access check reacquires
264
+ `getPaseoClient(serverId)` for every action, as required when Paseo replaces a connection, and
265
+ unknown/disconnected errors are shown without falling back to the selected or local host.
266
+
267
+ Automatic discovery is not browser routing. Host summaries intentionally contain no URL or
268
+ credential, and the host-targeted API is client-side. The connection code below is therefore kept
269
+ only to authorize the Primary plugin's server-side bridge to proxy extension requests.
270
+
271
+ The listener is loopback-only, by design. Use these exact roles:
272
+
273
+ - **Browser machine:** runs Chrome.
274
+ - **Primary Paseo machine:** sits beside Chrome; its plugin is the only bridge the extension uses.
275
+ - **Additional Paseo machine:** a dev VM or other Paseo installation reached by the Primary plugin.
276
+
277
+ On the Additional Paseo machine, open **Share this Paseo machine**, press **Enable private
278
+ access**, then **Copy connection code**. On the Primary Paseo machine, paste it into **Paseo
279
+ machines** and press **Connect additional machine**. The code bundles the `serverId`, private URL,
280
+ machine name and token; it is a secret. The Primary plugin checks the other bridge's identity,
281
+ name and contract before resolving or sending, and never follows that machine's own routes, which
282
+ prevents routing loops.
283
+ The ping and operation share one end-to-end deadline: 9 seconds for resolve and 55 seconds for
284
+ send. Those budgets sit just inside the extension's 10-second and 60-second limits. A slow
285
+ worktree creation therefore has time to finish without the Primary falsely reporting HTTP 503
286
+ after the Additional machine has already started the agent.
287
+
288
+ The button runs Tailscale Serve on the machine where it is pressed. Serve proxies a private
289
+ tailnet HTTPS URL to the loopback port and survives the terminal closing.
290
+
291
+ <details>
292
+ <summary>Advanced: configure private access manually</summary>
293
+
294
+ If the automatic button cannot find Tailscale, run this **on the Additional Paseo machine**:
295
+
296
+ ```sh
297
+ # on this Paseo machine; --bg survives the terminal closing
298
+ tailscale serve --bg 7788
299
+ ```
300
+
301
+ Copy the printed `https://…ts.net` origin into **Private bridge address** in the same plugin
302
+ surface and save it. Then copy the connection code and paste it on the Primary Paseo machine.
303
+ The first Serve command may ask you to enable tailnet HTTPS. Use
304
+ `tailscale serve off` to disable it. Use Serve, not Funnel: Funnel is public.
305
+ Use the URL Serve prints, not a cloud `.internal` hostname or a `100.x` address
306
+ over plain HTTP.
307
+
308
+ The URL field accepts only an HTTPS origin, with no credentials, path, query or fragment. Saving it
309
+ updates the exact Host-header allowlist immediately; it does not rebind the bridge or create a proxy.
310
+
311
+ </details>
312
+
313
+ <details>
314
+ <summary>Advanced: connect Chrome directly</summary>
315
+
316
+ The extension retains its prior direct mode. Each machine then needs a URL, its own token, and an
317
+ exact Chrome permission. An SSH tunnel is a temporary fallback:
318
+
319
+ ```sh
320
+ # on the machine running the browser
321
+ ssh -L 7789:127.0.0.1:7788 devbox
322
+ ```
323
+
324
+ The extension then adds a direct connection pointing at `http://127.0.0.1:7789` and pastes
325
+ **this** machine's pairing token. Nothing needs configuring in the plugin: the `Host`
326
+ check accepts any loopback hostname regardless of port, so the tunnel's local
327
+ port does not have to match the port the bridge bound.
328
+
329
+ For setups with more than one proxy name, `allowedHosts` remains a
330
+ file-only compatibility escape hatch:
331
+
332
+ ```json
333
+ { "allowedHosts": ["devbox.example.ts.net:443"] }
334
+ ```
335
+
336
+ Those are additional exact `host:port` matches, empty by default. Prefer the
337
+ single declared private bridge address for normal use.
338
+
339
+ </details>
340
+
341
+ ### Permission mode, and the profile it can come from
342
+
343
+ The plugin used to send `config: { provider }` and nothing else, which made
344
+ Claude's provider fall back to `modeId: "default"` — the app's **"Always Ask"** —
345
+ so every agent it started came up in the strictest mode no matter what the user's
346
+ own default was.
347
+
348
+ When a send creates an agent, the mode is resolved in this order, with **every candidate
349
+ validated against the chosen provider's advertised modes** before it is accepted:
350
+
351
+ 1. `modeId` on the `/v1/send` request (the popover's explicit choice);
352
+ 2. the `modeId` of the followed Paseo agent profile;
353
+ 3. the plugin's own **Default permission mode** setting;
354
+ 4. the chosen provider's `defaultModeId` from the daemon;
355
+ 5. nothing — the field is omitted and Paseo applies its own default.
356
+
357
+ A candidate the provider does not advertise is skipped, logged, and the chain
358
+ continues:
359
+
360
+ ```
361
+ [send-to-paseo] mode "bypassPermissions" from the plugin's default mode setting
362
+ is not offered by codex; trying the next option
363
+ ```
364
+
365
+ That is deliberate: mode ids belong to a provider (`bypassPermissions` is Claude's,
366
+ `full-access` is Codex's), so a stored id becomes meaningless the moment the user
367
+ picks a different provider. A stale id must cost the send its preferred mode, not
368
+ the send. The same holds for a profile that has been deleted in Paseo — it is
369
+ ignored with a log line, and the send goes through.
370
+
371
+ **Profiles are followed live, by id.** There is no `profile` parameter on agent
372
+ creation; applying a profile is a field-by-field copy. So the plugin stores only
373
+ the id and re-reads `provider`, `model`, `modeId` and `thinkingOptionId` on every
374
+ send. Edit the profile in Paseo and the next send follows it — there is nothing to
375
+ re-copy here.
376
+
377
+ Two precedence rules worth stating outright:
378
+
379
+ - **An explicit `provider` on the request always beats the profile's provider.**
380
+ Picking "Codex" in the popover is a visible choice and is never silently
381
+ overridden by a profile that names Claude.
382
+ - **`thinkingOptionId` is copied from the profile only when the send actually
383
+ landed on that profile's own `provider/model`.** Thinking options are per model,
384
+ so carrying one across a model change would be a guess.
385
+
386
+ ### Environment
387
+
388
+ | Variable | Effect |
389
+ | --- | --- |
390
+ | `SEND_TO_PASEO_DRY_RUN=1` | `POST /v1/send` resolves and validates everything but creates or messages nothing, returning the same `200` shape with `"dryRun": true`. New-agent paths use synthetic ids; main-agent paths identify the real unchanged agent. |
391
+ | `SEND_TO_PASEO_DAEMON_PASSWORD` | Password for a daemon that requires one. Checked before `PASEO_PASSWORD`, the VM secret file and `daemonPassword` in settings.json. See [A daemon that requires a password](#a-daemon-that-requires-a-password). |
392
+ | `SEND_TO_PASEO_GH_PATH` | Absolute path to the `gh` binary, if it is somewhere unusual. Checked before `PATH`. |
393
+ | `SEND_TO_PASEO_GIT_PATH` | Same for `git`. |
394
+ | `SEND_TO_PASEO_BIN_DIRS` | Colon-separated directories that **replace** the built-in well-known-location list (see [Requirements](#where-the-plugin-looks-for-them)). Set it to a nonexistent path to switch the probe off entirely, which is how `check-deps.mjs` simulates a machine with nothing installed. |
395
+ | `PASEO_HOME`, `PASEO_DAEMON_URL`, `PASEO_PASSWORD` | Standard Paseo variables; all three are honoured. |
396
+
397
+ The plugin subprocess inherits the daemon's environment, so `SEND_TO_PASEO_DRY_RUN`
398
+ has to be exported for the daemon, which means it only takes effect at the next
399
+ daemon start.
400
+
401
+ ### If the port is taken
402
+
403
+ The bridge does not start, the reason lands in the surface's status line and in
404
+ `paseo plugin logs send-to-paseo`, and the rest of the plugin keeps working:
405
+
406
+ ```
407
+ [send-to-paseo] Port 7788 is already in use, so the Send to Paseo bridge did not
408
+ start. Pick another port in Paseo -> Send to Paseo.
409
+ ```
410
+
411
+ Note that `test/mock-bridge.mjs` in this repository uses port **7799**; don't
412
+ configure the bridge onto it.
413
+
414
+ ---
415
+
416
+ ## Troubleshooting
417
+
418
+ Keyed on the text you will actually see — in the extension's popover, on the
419
+ **Requirements** card, or in `paseo plugin logs send-to-paseo`.
420
+
421
+ | What you see | What it means | Fix |
422
+ | --- | --- | --- |
423
+ | Target picker reads `Create worktree for PR #942 (gh not installed)` | `gh` is not on this machine. Sending still works; the title and branches are missing. | `brew install gh`, then `paseo plugin reload send-to-paseo` |
424
+ | Target picker reads `… (gh not signed in — run gh auth login)` | `gh` is installed but has no GitHub credential. | `gh auth login` |
425
+ | Target picker reads `… (gh cannot see this repo)` | `gh`'s account has no access to the repository — private repo, or SAML not authorised. Paseo may still have access, so the send is not blocked. | `gh auth status`, then authorise the org or switch account |
426
+ | Target picker reads `… (github.com unreachable)` | No route to github.com from the daemon machine. | Check the network or the proxy, then reopen the popover |
427
+ | No PR title anywhere, everything ranks as "same project" | Any of the above. | Check the **Requirements** card in the Paseo surface |
428
+ | A workspace on a **merged** stack branch still ranks as "same project" | Either the merged PR fell outside the 200 most recent merged/closed PRs (the log says so), or the branch is already contained in trunk — a true merge commit — and the trunk guard declined it. See "Merged and closed branches" below. | Nothing to fix; pick the workspace manually. The create option is still correct |
429
+ | `git was not found on this machine, and Paseo needs it to check a pull request out into a worktree.` | Genuinely fatal for the create path. | `xcode-select --install`, or `sudo apt install git` |
430
+ | `Pull request acmegizmos/gizmo-poc#942 does not exist on GitHub.` | `gh` read the repository fine and there is no such PR. This is the one `gh` answer that is an error rather than a degradation. | Check the number |
431
+ | `acmegizmos/gizmo-poc is not a project in Paseo.` | Paseo has no project for this repository. | `paseo project add /path/to/repo` |
432
+ | `The Paseo daemon is not reachable from the plugin.` | The plugin is up but the daemon socket is not answering. | Start Paseo, or `paseo daemon start` |
433
+ | `The Paseo daemon requires a password and the plugin does not have it.` | The daemon has `daemon.auth.password` set, which any non-loopback `listen` turns on. | Set `SEND_TO_PASEO_DAEMON_PASSWORD`, `~/paseo-hub/secrets/daemon-password`, or `daemonPassword` in the plugin settings, then reload the plugin. See [A daemon that requires a password](#a-daemon-that-requires-a-password) |
434
+ | `The GitHub CLI (gh) did not answer in time…` | A `gh` call hit its timeout (15 s for a PR read, 12 s for either stack list, 8 s for `gh repo view`). | Retry; if it persists, check `gh auth status` and the network |
435
+ | `dependency gh: missing (optional)` in the log, but `gh` works in your terminal | The daemon's `PATH` and your shell's `PATH` differ, and `gh` is installed somewhere the well-known list does not cover. | Compare against the `plugin subprocess PATH=` line in the same log, then set `SEND_TO_PASEO_GH_PATH` |
436
+ | `Port 7788 is already in use…` | Something else has the port. | Change the port on the surface |
437
+
438
+ Reproduce any of the dependency cases without touching your real setup:
439
+
440
+ ```sh
441
+ cd plugin && node check-deps.mjs
442
+ ```
443
+
444
+ It doctors `PATH`, builds fake `gh` executables in a temp directory, and asserts
445
+ the resulting messages. It never reads or writes `~/.config/gh`.
446
+
447
+ ---
448
+
449
+ ## Endpoints
450
+
451
+ Full request and response schemas, error codes and CORS rules are in
452
+ [`../CONTRACT.md`](../CONTRACT.md), which is frozen. This is the summary.
453
+
454
+ | Method | Path | Auth | Purpose |
455
+ | --- | --- | --- | --- |
456
+ | `GET` | `/v1/ping` | optional | Health, version, daemon reachability. With a valid token it also validates that token and returns the provider and mode lists. |
457
+ | `POST` | `/v1/resolve` | bearer | PR metadata, the Paseo project, ranked workspace candidates, provider/mode defaults, dispatch preference, and optional main-agent previews. Creates nothing. |
458
+ | `POST` | `/v1/send` | bearer | Ensures the workspace, then starts a new agent or messages the selected main agent. The only mutating endpoint. |
459
+
460
+ `/v1/ping` is the only endpoint where auth is optional, and it is not ignored:
461
+
462
+ | `Authorization` | Response |
463
+ | --- | --- |
464
+ | absent | `200`, `paired: false`, `providers: []`, `modes: []` — the liveness check, so the options page can tell "bridge down" from "bad token" |
465
+ | present and valid | `200`, `paired: true`, the full `providers` and `modes` lists (same payload as `/v1/resolve`) |
466
+ | present and invalid | `401 unauthorized` |
467
+
468
+ That is what lets the extension's options page actually validate a pasted token and populate
469
+ its default-model picker without needing a PR. The `forbidden_origin` and `forbidden_host`
470
+ checks apply to `/v1/ping` too, so it is not a bypass.
471
+
472
+ ```sh
473
+ TOKEN=... # from the Paseo surface
474
+
475
+ curl -s http://127.0.0.1:7788/v1/ping
476
+
477
+ curl -s -X POST http://127.0.0.1:7788/v1/resolve \
478
+ -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
479
+ -d '{"forge":"github","owner":"acmegizmos","repo":"gizmo-poc","number":942,
480
+ "stackPrNumbers":[948,947]}'
481
+
482
+ curl -s -X POST http://127.0.0.1:7788/v1/send \
483
+ -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
484
+ -d '{"forge":"github","owner":"acmegizmos","repo":"gizmo-poc","number":942,
485
+ "prompt":"Fix merge conflicts","target":{"kind":"create"},
486
+ "modeId":"auto"}'
487
+ ```
488
+
489
+ For a new-agent send, `/v1/resolve` reports the mode it would actually use, so the popover can
490
+ preselect what will happen rather than guess. In main-agent mode the popover hides model/mode
491
+ controls because they cannot change an existing agent:
492
+
493
+ ```sh
494
+ $ curl -s -X POST http://127.0.0.1:7788/v1/resolve \
495
+ -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
496
+ -d '{"forge":"github","owner":"acmegizmos","repo":"gizmo-poc","number":942}' \
497
+ | jq '{resolvedModeId, modes: (.modes | map(select(.provider=="claude")) | map(.id))}'
498
+ {
499
+ "resolvedModeId": "auto",
500
+ "modes": ["plan", "default", "acceptEdits", "auto", "bypassPermissions"]
501
+ }
502
+ ```
503
+
504
+ ### The resolution ladder
505
+
506
+ `/v1/resolve` walks exactly the ladder CONTRACT.md specifies.
507
+
508
+ 1. **`owner/repo` → Paseo project.** `remote:github.com/{owner}/{repo}` is the
509
+ fast path. Otherwise a project whose `origin` remote parses to the same
510
+ repository wins, which covers SSH remotes and renamed repos. No match →
511
+ `404 project_not_found`.
512
+ 2. **PR number → head branch**, via `gh pr view --json
513
+ number,title,headRefName,baseRefName,state,url`. Cached for 60 s.
514
+
515
+ **Degrades, never fails.** If `gh` is missing, unauthenticated, blocked from
516
+ the repository, offline or slow, the bridge substitutes a placeholder — the
517
+ number and the canonical URL, with `headBranch` and `baseBranch` left *empty
518
+ rather than guessed* — records why, and carries on. Steps 3 and 5 then have
519
+ nothing to match on, so every workspace ranks 3 and the default becomes
520
+ "create a worktree", which is exactly right: Paseo checks the PR out from its
521
+ number through `checkoutSource: { kind: "change_request" }` and never calls
522
+ `gh`. The reason is visible in the create candidate's label, in the agent's
523
+ opening prompt, and in `paseo plugin logs send-to-paseo`.
524
+
525
+ The single exception is a `gh` that successfully reports the pull request does
526
+ not exist: that is a real answer, so it is a real `404 pr_not_found`.
527
+ 3. **The stack → its branches**, from GitHub itself. A Graphite stack is a real
528
+ `base` → `head` chain: PR #943's `baseRefName` *is* PR #942's `headRefName`.
529
+ So one `gh pr list --state open --json number,headRefName,baseRefName` (60 s
530
+ cache) rebuilds the repo's PR graph, and a breadth-first walk from this PR
531
+ gives the whole stack in both directions — downstack ancestors and upstack
532
+ descendants — plus the hop distance to each.
533
+
534
+ This replaced trusting the `stackPrNumbers` the extension scraped from the
535
+ page. Graphite's stack panel collapses long stacks ("3 of 9, 2 hidden"), so a
536
+ scrape could silently omit the very sibling the user's workspace was on.
537
+ Those numbers are still honoured for members the graph did not find — a
538
+ closed or merged stack PR — which is normally none and costs nothing. On
539
+ github.com the extension deliberately sends `[]`, so there are no hints at
540
+ all there.
541
+
542
+ Strictly best-effort throughout: a failed lookup is logged and drops the
543
+ rank-2 entries; it never fails the request.
544
+
545
+ **Merged and closed branches (added 2026-09-02).** A workspace parked on a
546
+ branch whose PR has merged is still a workspace in that stack, and the
547
+ open-PR graph cannot see it at all. Two more passes cover it, each reached
548
+ only when the previous one left a project workspace unexplained *and* nothing
549
+ already matched — an exact branch match or an open sibling settles the
550
+ default, and a merged branch can never outrank either, so paying for the
551
+ wider lookups then would change nothing. Measured against the live bridge on
552
+ a 38-workspace project: 0.94s for a PR whose stack already had an open
553
+ sibling workspace, 1.6s for a PR that matched nothing at all, 0.01s once the
554
+ lists are cached.
555
+
556
+ - **Pass 2 — merged and closed PRs.** One more `gh pr list --state closed`
557
+ (200 rows, 5-minute cache). One call, not two: GitHub treats a merged PR as
558
+ closed, so `--state closed` returns MERGED rows as well, and each row's own
559
+ `state` field separates them. This recognises a workspace sitting directly
560
+ on a merged stack branch and reconnects a chain whose merged head branch
561
+ still exists. An open PR always wins over a merged one for the same head
562
+ branch. The 200-row cap is logged when hit, because on a busy repository
563
+ the symptom of truncation — an older merged stack branch going unrecognised
564
+ — is otherwise indistinguishable from the feature not working.
565
+ - **Pass 3 — local git ancestry, read-only, no network.** When the bottom PR
566
+ of a stack merges *and* its head branch is deleted, GitHub retargets the
567
+ child's base to trunk and the `base` → `head` edge that joined them is gone
568
+ from GitHub's data entirely — no widening of `gh pr list` can rebuild it.
569
+ The commits can: a stack branch below this PR is by definition an ancestor
570
+ of it, so `git branch -a --contains <branch>` in the project root,
571
+ intersected with the stack's branches (and their `origin/` forms), answers
572
+ the question offline. It can even recognise a stack branch that has no PR
573
+ at all, in which case the candidate carries no `stackPrNumber`.
574
+
575
+ **A trunk guard is mandatory here, not optional.** Every branch ever merged
576
+ into trunk is an ancestor of every branch cut from trunk since, so without
577
+ a guard a workspace parked on trunk — or on a branch merged a year ago —
578
+ would become a rank-2 stack candidate for *every* PR in the repository. A
579
+ branch already contained in trunk is therefore rejected, which leaves
580
+ exactly the branches carrying commits trunk does not have: a squash- or
581
+ rebase-merged stack branch whose child has not been restacked yet, and a
582
+ stack branch with no PR. Trunk itself comes from
583
+ `refs/remotes/origin/HEAD` (free, offline; present in 2 of 3 git projects
584
+ measured on the development machine) and falls back to `gh repo view`. With
585
+ no trunk name at all, pass 3 is skipped and says so in the log.
586
+
587
+ The cost of the guard is the true-merge-commit case: such a branch *is* an
588
+ ancestor of trunk and is indistinguishable from any other long-merged
589
+ branch, so pass 2 has to carry it — and does, whenever the head branch
590
+ still exists so the `base` → `head` edge survives. The combination "true
591
+ merge commit AND head branch deleted AND child retargeted" is covered by
592
+ neither, and falls back to the old behaviour: rank 3, default "create".
593
+
594
+ Widening also breaks an assumption the open-only graph could rely on. Trunk
595
+ cannot be a false edge among open PRs, because an edge requires one PR's base
596
+ to be another PR's *head* and nobody opens a PR whose head is `main`.
597
+ Merged PRs are different: measured in the public `vercel/turborepo`
598
+ repository, PR #13875 is MERGED with `headRefName: "main"` — a release
599
+ back-merge — and 13 open PRs are based on `main`, so admitting that one row
600
+ would fuse them all into a single false "stack". Two guards reject it: the
601
+ trunk name, and a fan-out backstop (a non-open head that four or more PRs are
602
+ based on). Both were measured to leave that PR with zero stack members.
603
+ Only non-open rows are filtered, so the open-PR behaviour is unchanged.
604
+
605
+ **Not `gt`.** The Graphite CLI answers "what is *my current* stack" from
606
+ local, per-worktree metadata relative to whatever branch is checked out where
607
+ it runs. This endpoint runs while the user is typing in a browser and must not
608
+ depend on, or disturb, any worktree — least of all the candidate workspaces,
609
+ each on its own branch. `gh` is read-only, needs no second credential, and is
610
+ optional — without it the only casualty is stack detection.
611
+ 4. **Project workspaces → branches.** The branch normally comes free from the
612
+ daemon's own workspace descriptor (`gitRuntime.currentBranch`). When that is
613
+ missing, `git -C <cwd> rev-parse --abbrev-ref HEAD` fills the gap, cached
614
+ against the mtime of the worktree's own `HEAD` file — the one inside
615
+ `.git/worktrees/<name>`, not the main repository's.
616
+ 5. **Rank.**
617
+
618
+ | rank | reason | meaning |
619
+ | --- | --- | --- |
620
+ | 1 | `exact` | workspace HEAD == the PR head branch |
621
+ | 2 | `stack` | workspace HEAD is another branch in this stack, whatever its own PR's state; carries `stackPrNumber` and, when that PR is not open, `stackPrState` |
622
+ | 3 | `project` | any other workspace in the project |
623
+ | 4 | `create` | the synthetic "create a worktree for this PR" option |
624
+
625
+ Candidates come back sorted ascending by rank and always include the `create`
626
+ entry. Rank-2 entries are ordered by PR state first — open before merged
627
+ before closed before "no PR at all" — then by hop distance, then by
628
+ `stackPrNumber`. State outranks distance because a live sibling is somewhere
629
+ work is still happening while a merged branch is history the stack has been
630
+ restacked past. Distances measured from GitHub's graph beat ones it could not
631
+ measure, and both beat membership inferred from local ancestry; each has its
632
+ own named constant so the three can never sort as one.
633
+
634
+ `defaultCandidateIndex` points at the rank-1 exact match, else the best
635
+ rank-2 stack match, else `create` — and is always a valid index, because
636
+ `candidates` always ends with the `create` entry. Rank 3 is never a default —
637
+ an unrelated workspace is a worse guess than a fresh worktree. Preferring
638
+ rank 2 supports one workspace per *stack*: opening PR #4 while the worktree
639
+ sits on PR #7's branch resolves to that workspace instead of proposing a
640
+ second checkout. That now holds when PR #7 has already merged, which is the
641
+ case that used to fall through to "create".
642
+
643
+ The extension always shows the picker and requires an explicit send; nothing
644
+ is ever created silently, whatever the default is.
645
+
646
+ ### Sending
647
+
648
+ When the chosen workspace is on a branch other than the PR's head branch, the
649
+ composed prompt says so explicitly and names the PR branch to check out. Silence
650
+ would leave the agent believing it is on the PR branch — and committing there.
651
+ When that branch's own pull request is merged or closed, the wording says that
652
+ too: "a different branch of the same stack" reads as a live sibling, and a merged
653
+ branch is behind by construction. Establishing the state reuses the resolve
654
+ path's caches, so it is normally a cache read rather than a `gh` call, and a null
655
+ answer just keeps the generic wording.
656
+
657
+ `target: {kind:"existing"}` stays in that exact workspace. With **New agent**, creation goes
658
+ through the workspace's own handle so it joins that workspace record. With **Main workspace
659
+ agent**, the plugin considers only non-archived root agents in the workspace: an exact `Main` or
660
+ `Main Agent` title wins, then an open Paseo tab, live status, and recent activity. A non-empty
661
+ `paseo.parent-agent-id` marks a delegated subagent and excludes it. The composed prompt is sent
662
+ with steering behavior so a running turn is preserved rather than interrupted.
663
+
664
+ `target: {kind:"create"}` asks Paseo for a worktree checked out to the PR — the
665
+ same request `paseo workspace create --isolation worktree --mode checkout-pr
666
+ --pr-number N --forge github --project <id>` sends:
667
+
668
+ ```ts
669
+ paseo.workspaces.create({
670
+ title: `PR #942: ...`,
671
+ source: {
672
+ kind: "worktree",
673
+ projectId,
674
+ action: "checkout",
675
+ checkoutSource: { kind: "change_request", forge: "github", number: 942 },
676
+ },
677
+ });
678
+ ```
679
+
680
+ > **The local branch name can differ from the PR head branch.** If a local branch
681
+ > of that name already exists, Paseo's `checkout-pr` creates a uniquely-named
682
+ > local branch (`…-rule-1`) tracking `origin/<PR head branch>`. The commit and
683
+ > upstream are the PR's, so the workspace does contain the PR. `/v1/send`
684
+ > reports the branch actually checked out, which is the truthful value to
685
+ > display.
686
+
687
+ When a send creates a new agent, it uses:
688
+
689
+ - `title`: `PR #942 · <first line of the message, ≤60 chars>`
690
+ - `labels`: `send-to-paseo/pr = "github:owner/repo#942"` and
691
+ `send-to-paseo/origin = "graphite"`
692
+ - `prompt`: the CONTRACT.md context header, then a blank line, then the user's
693
+ text verbatim
694
+ - `deepLink`: built by the plugin's local, protocol-compatible `buildAgentDeepLink`, giving
695
+ `paseo://h/<serverId>/agent/<agentId>`.
696
+ - `dryRun`: always present, `false` on a real send.
697
+
698
+ If main-agent mode finds no eligible root, it follows that same creation path. A successful reuse
699
+ instead returns `agentCreated: false`, `dispatch: "main"`, and the existing agent's title and deep
700
+ link. New-agent and fallback paths return `agentCreated: true`, `dispatch: "new"`.
701
+
702
+ `prompt` is validated as 1..16000 **Unicode code points after trim**, so an emoji counts once.
703
+ The 64 KiB byte cap on the body is independent and is applied first, so a prompt inside the
704
+ code-point limit whose body exceeds 64 KiB gets `payload_too_large`, not `bad_request`.
705
+
706
+ #### `pageUrl`
707
+
708
+ When a request carries `pageUrl`, exactly one `Page: <pageUrl>` line is appended
709
+ after the `PR:` line. With `pageUrl` absent the header is byte-for-byte the
710
+ contract's example. This is now pinned in CONTRACT.md's "Prompt composition"
711
+ block, so it is spec rather than interpretation.
712
+
713
+ #### On a sibling branch of the stack
714
+
715
+ ```
716
+ Workspace branch: giz-1132-retire-legacy-cache-flag (NOT this PR's branch)
717
+ Note: this worktree is on a different branch of the same stack. If your change belongs to PR #942, check out giz-1133-widget-backed-inventory-audit-rule first.
718
+ ```
719
+
720
+ When the bridge also established that the sibling branch's own pull request is
721
+ merged or closed, those two lines say so — "a different branch of the same
722
+ stack" reads as a live sibling, and a merged branch is behind by construction
723
+ because the stack has been restacked past it:
724
+
725
+ ```
726
+ Workspace branch: giz-1132-retire-legacy-cache-flag (NOT this PR's branch; its own pull request is already merged)
727
+ Note: this worktree is on a branch of this stack whose pull request has already been merged, so it may be behind the rest of the stack. If your change belongs to PR #942, check out giz-1133-widget-backed-inventory-audit-rule first.
728
+ ```
729
+
730
+ The advice is the same in every variant; only the description of where the agent
731
+ is standing changes. When the state cannot be established, the generic wording
732
+ is used — never wrong, only less specific.
733
+
734
+ #### With no `gh`
735
+
736
+ The `Title:` and `Branch:` lines are **omitted rather than filled with
737
+ placeholders**, and one `Note:` line explains why. Telling an agent it is on a
738
+ branch nobody verified is how a commit lands on the wrong branch, so nothing is
739
+ guessed. The "check out `<PR branch>` first" line is dropped for the same reason:
740
+ without `gh` there is no known PR branch to name.
741
+
742
+ ```
743
+ [Sent from Graphite — github/acmegizmos/gizmo-poc PR #942]
744
+ PR: https://github.com/acmegizmos/gizmo-poc/pull/942
745
+ Workspace branch: giz-1132-retire-legacy-cache-flag
746
+ Note: the pull request title and branch names are missing from this header because gh not installed. Read them from the PR URL above if you need them.
747
+
748
+ <the user's message verbatim>
749
+ ```
750
+
751
+ Prompt text is plugin behaviour, not wire shape — the extension never parses the
752
+ composed prompt — so `contract` stays at 1.
753
+
754
+ ---
755
+
756
+ ## Security model
757
+
758
+ The bridge can start agents that run arbitrary code on this machine, so it is
759
+ treated as a privilege boundary rather than a convenience.
760
+
761
+ 1. **Loopback only.** `server.listen(port, "127.0.0.1")`. Never `0.0.0.0`.
762
+ 2. **Bearer token on everything except `GET /v1/ping`.** 32 random bytes,
763
+ base64url, compared with `timingSafeEqual`, stored `0600`, rotatable from the
764
+ surface.
765
+ 3. **Page origins are refused outright.** If an `Origin` header is present and
766
+ does not start with `chrome-extension://`, the request gets
767
+ `403 forbidden_origin` — on the CORS preflight *and* on the real request, and
768
+ on `/v1/ping` too, so the unauthenticated endpoint is not a bypass. This
769
+ matters because CORS only stops a page from *reading* a response; the request
770
+ would otherwise still fire and cause the side effect. Requiring an
771
+ `Authorization` header forces a preflight, and failing that preflight means
772
+ the browser never sends the real request. Set `allowedExtensionIds` in
773
+ `settings.json` to pin specific extension IDs.
774
+ 4. **`Host` must have a loopback hostname or match the declared external HTTPS
775
+ origin** — `127.0.0.1`, `localhost`, `::1`, or the origin saved as
776
+ **Private bridge address**. Anything else gets `403 forbidden_host`. This closes DNS rebinding, where a
777
+ hostile page resolves a name it controls to `127.0.0.1`: the request then
778
+ arrives carrying `Host: evil.com` and `Origin: https://evil.com`, and rule 3
779
+ and this rule both refuse it.
780
+
781
+ The **port is not checked**. It used to be pinned to the port the listener
782
+ bound, which refused the supported way to reach a bridge on another machine —
783
+ an `ssh -L 7789:127.0.0.1:7788` tunnel makes the browser send
784
+ `Host: 127.0.0.1:7789` while this bridge is on 7788. Pinning the port never
785
+ added anything on top of the hostname test, because the hostname is what a
786
+ rebinding attack cannot control. `allowedHosts` in `settings.json` can add
787
+ further exact non-loopback `host:port` values for advanced reverse proxies;
788
+ it is empty by default and not settable from the extension.
789
+ 5. **CORS echo on success only.** The request's own `chrome-extension://` origin,
790
+ `GET, POST, OPTIONS`, `Authorization, Content-Type`, `Max-Age: 600`. No
791
+ `Access-Control-Allow-Credentials`, ever. `Vary: Origin` on every response,
792
+ allowed or not, so no cache can mix them up.
793
+ 6. **Requests with no `Origin` at all are allowed** (so `curl` works) but still
794
+ need the bearer token.
795
+ 7. **Body cap** of 64 KiB → `413 payload_too_large`. Oversized uploads are
796
+ drained up to a bounded ceiling so the caller gets a real response instead of
797
+ a connection reset.
798
+ 8. **Rate limit** of 60 requests per 10 s → `429 rate_limited` with `Retry-After`.
799
+ Keyed on the `Origin` header when there is one and on the remote address
800
+ otherwise, so a `curl` flood from the CLI cannot consume the extension's
801
+ budget. `GET /v1/ping` is counted, not exempt: the limit is defence-in-depth
802
+ on an endpoint that is already loopback-only and token-gated, so keeping the
803
+ total bounded beats carving out one unauthenticated path. 60 is sized for the
804
+ extension's uncached `contract`-mismatch gate, which re-pings before every
805
+ resolve and send — 4 requests per completed send, so ~15 sends per window. The
806
+ window is pruned lazily on each request rather than on a timer, because a live
807
+ timer in this subprocess is what hangs plugin teardown.
808
+ 9. **Nothing sensitive is logged.** Not the token, not prompt bodies, not agent
809
+ titles (which contain the user's first line). Refused-origin log lines
810
+ deliberately do not echo the origin, so a hostile page cannot write
811
+ attacker-controlled text into the user's log.
812
+ 10. **No shell, ever.** `gh` and `git` are located as real executables and run
813
+ with `execFile` and an argv array. `gh` is a shell *function* in some setups,
814
+ so going through a shell would run something other than the program; and
815
+ `owner`/`repo` are additionally constrained to `^[A-Za-z0-9._-]+$` before
816
+ they reach argv.
817
+ 11. **Errors are curated.** Only the codes in CONTRACT.md's table cross the wire.
818
+ Anything unexpected becomes `500 internal` with a generic sentence, and the
819
+ detail goes to the plugin log, so daemon internals and filesystem paths never
820
+ reach a browser extension.
821
+
822
+ Two paths outside the frozen table, both staying inside its code set: an unknown
823
+ endpoint and a wrong method on a known endpoint both return
824
+ `400 bad_request` with a descriptive message.
825
+
826
+ ---
827
+
828
+ ## Layout
829
+
830
+ Paseo 0.9 uses separate runtime entries and directory boundaries. Client code,
831
+ server code and shared contracts compile into their matching bundles.
832
+
833
+ ```
834
+ paseo-plugin.json id and Paseo >=0.9.0 requirement
835
+ index.client.tsx client contribution wiring
836
+ index.server.ts RPC handlers and bridge lifecycle
837
+ client/settings.tsx the Paseo surface
838
+ client/hosts.ts discovered-host correlation and explicit client checks
839
+ server/bridge.ts HTTP server, security checks and routing
840
+ server/resolve.ts PR -> project -> workspace resolution and ranking
841
+ server/main-agent.ts paginated root-agent discovery and deterministic selection
842
+ server/send.ts workspace ensure + agent create/reuse + prompt composition
843
+ server/deps.ts binary lookup, spawn wrapper, dependency self-check
844
+ server/gh.ts gh calls and their graceful degradation, cached
845
+ server/git.ts read-only branch, remote, trunk and ancestry reads
846
+ server/daemon.ts short-lived Paseo SDK connections, daemon identity
847
+ server/daemon-password.ts password source precedence and VM secret-file reader
848
+ server/settings.ts token, port, default model, recent sends
849
+ server/target.ts fail-closed surface RPC host targeting
850
+ shared/contracts.ts Zod schemas, error taxonomy, formatting, RPC contracts
851
+ shared/host-target.ts pure serverId target assertion
852
+ check-deps.mjs standalone dependency-degradation checks (not bundled)
853
+ ```
854
+
855
+ ### Three traps this plugin is built around
856
+
857
+ **A listening HTTP server wedges plugin reload.** The socket keeps the subprocess
858
+ event loop alive, Paseo's "Stopping plugin" step never returns, and
859
+ `paseo plugin reload` hangs forever. Teardown therefore calls `server.close()`
860
+ **and** `server.closeAllConnections()`, destroys every tracked socket (idle
861
+ keep-alive sockets otherwise hold the listener open), and awaits the close with a
862
+ grace timeout. There are no `setInterval`s anywhere in the plugin.
863
+
864
+ **Crossing a runtime directory is a compile error.** `index.client.tsx` imports
865
+ only `client/` and `shared/`; `index.server.ts` imports only `server/` and
866
+ `shared/`. The server entry can therefore own bridge startup and return its
867
+ cleanup directly, without the old mixed-entry teardown handoff.
868
+
869
+ **A runtime import the host does not provide breaks the install, not the build.**
870
+ `npm run typecheck` passes, `paseo plugin reload` from a checkout passes, and
871
+ `paseo plugin add tomgrin10/send-to-paseo` fails for everyone — because only the
872
+ git path compiles with no `node_modules`. See
873
+ [No runtime dependencies, ever](#no-runtime-dependencies-ever); this is why
874
+ `buildAgentDeepLink` lives in `shared/contracts.ts` rather than being imported
875
+ from `@getpaseo/protocol`, and why `server/daemon.ts` reaches the SDK through an
876
+ assembled specifier.
877
+
878
+ The listener cleanup and no-runtime-dependency rules are demonstrated in
879
+ [`VERIFICATION.md`](VERIFICATION.md) §3, §10 and §18.