session-peer 0.2.1 → 0.3.1

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/docs/guide.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [English](guide.md) | [한국어](guide.ko.md) | [日本語](guide.ja.md) | [简体中文](guide.zh-CN.md)
6
6
 
7
- This guide covers 0.2.1, a reliability and hardening update to 0.2.0 ([changes](../PARITY.md#021-reliability-and-hardening)). [Public 0.2.0 release evidence](../VALIDATION.md#public-020--2026-09-28-kst) records the previous publication. References to 0.1.0 below describe the older release.
7
+ This guide covers 0.3.1 ([reliability fixes](../PARITY.md#031-reliability-fixes)). Version 0.3.0 introduced multi-host SSH, sender context and return routes, update checks and the optional `sp` shorthand ([0.3.0 changes](../PARITY.md#030-remote-usability-and-maintenance)). [Public 0.3.0 release evidence](../VALIDATION.md#public-030--2026-10-03-kst) records the previous publication. References to 0.1.0 below describe the older release.
8
8
 
9
9
  ## Contents
10
10
 
@@ -24,7 +24,7 @@ This guide covers 0.2.1, a reliability and hardening update to 0.2.0 ([changes](
24
24
  **Find and message running Claude Code and Codex sessions, locally or over SSH.**
25
25
  This TypeScript client runs on Node.js without Python.
26
26
 
27
- This guide describes **0.2.1**. The npm package and CLI command are both **`session-peer`**. This
27
+ This guide describes **0.3.1**. The npm package and CLI command are both **`session-peer`**. This
28
28
  project does not provide a Relay server or hosted service.
29
29
 
30
30
  ## Quick start
@@ -33,8 +33,9 @@ Use Node **22.13+ within 22.x or 24.x**. Check which `session-peer` your PATH
33
33
  selects if the Python CLI is already installed; both packages use that command.
34
34
 
35
35
  ```sh
36
- npm install --global --ignore-scripts session-peer@0.2.1
37
- session-peer --version # session-peer 0.2.1 (typescript)
36
+ npm view session-peer@0.3.1 version dist.integrity
37
+ npm install --global --ignore-scripts session-peer@0.3.1
38
+ session-peer --version # session-peer 0.3.1 (typescript)
38
39
  session-peer list --agent claude --json
39
40
  session-peer send --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
40
41
  ```
@@ -101,7 +102,7 @@ submits nothing. JSON adds sanitized `codexHomeResolution` and, when supplied by
101
102
  native queue output, `queueId`; neither confirms consumption. See the
102
103
  [selection contract](../PARITY.md#source-codex-home-selection--17--020).
103
104
  Published **0.1.0** still requires an explicit live home and has no inactive opt-in.
104
- On SSH, use the same 0.2.1 build on both ends.
105
+ On SSH, both ends need the same TypeScript client version (0.3.1).
105
106
 
106
107
  ## Requirements
107
108
 
@@ -125,11 +126,11 @@ npm run build
125
126
  node dist/cli.js --version
126
127
  npm pack --ignore-scripts
127
128
  # Optional global install: first check which session-peer your PATH selects.
128
- npm install --global --ignore-scripts ./session-peer-0.2.1.tgz
129
+ npm install --global --ignore-scripts ./session-peer-0.3.1.tgz
129
130
  session-peer --version
130
131
  ```
131
132
 
132
- Expected: `session-peer 0.2.1 (typescript)`. Keep the `./...tgz` path to
133
+ Expected: `session-peer 0.3.1 (typescript)`. Keep the `./...tgz` path to
133
134
  select the locally built artifact. Check the checkout version before using
134
135
  these commands for a later release.
135
136
 
@@ -149,7 +150,7 @@ On Windows PowerShell, inspect competing commands with
149
150
  npm ci --ignore-scripts
150
151
  npm run build
151
152
  npm pack --ignore-scripts
152
- npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.2.1.tgz
153
+ npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.3.1.tgz
153
154
  & "$env:TEMP\session-peer-ts-source\node_modules\.bin\session-peer.cmd" --version
154
155
  # Later: npm uninstall --prefix "$env:TEMP\session-peer-ts-source" session-peer
155
156
  ```
@@ -182,27 +183,179 @@ The default remote command is `session-peer` on remote PATH. An absolute
182
183
  the TypeScript marker and exact version; a different implementation is refused.
183
184
  SSH uses BatchMode and StrictHostKeyChecking. It never accepts new host keys,
184
185
  installs a remote runtime or invokes Python as a fallback. Messages travel in a
185
- JSON stdin request, not remote shell arguments. Arbitrary `--ssh-opt`, IPv6
186
- literals and Tailscale canonical-name enrichment are not supported; use an SSH
187
- alias/hostname. Forward access does not establish reverse access.
186
+ JSON stdin request, not remote shell arguments. Forward access does not
187
+ establish reverse access. Since 0.3.0, Tailscale is used only as a routing
188
+ hint; see [Replies](#replies).
188
189
 
189
190
  For a Windows SSH destination, add `--remote-platform win32` and select a
190
191
  Windows `--remote-bin 'C:\absolute\path\session-peer.cmd'` if needed. A previously
191
192
  authenticated OpenSSH control socket can be selected with
192
- `--ssh-control-path /absolute/local/socket`; this does not bypass host-key
193
- verification or grant a new login. For local Windows Codex commands, use a full
193
+ `--ssh-control-path /absolute/local/socket` with exactly one `--host`; this
194
+ does not bypass host-key verification or grant a new login. For local Windows Codex commands, use a full
194
195
  `C:\Users\...\.codex` path for `--codex-home`. The Python CLI, if present,
195
196
  is not removed or replaced by this client.
196
197
 
198
+ ### Several hosts and connection options
199
+
200
+ Since 0.3.0 (not in 0.2.1 or earlier), the CLI accepts repeated `--host` and a constrained
201
+ `--ssh-opt`:
202
+
203
+ ```sh
204
+ session-peer list --host alpha --host user@[2001:db8::1] \
205
+ --ssh-opt=-p --ssh-opt=2222 --ssh-opt=-i --ssh-opt="$HOME/.ssh/id_ed25519" --json
206
+ ```
207
+
208
+ - One `--host` returns one object, as before. Repeated `--host` returns a JSON
209
+ array in the same order; every element has `schemaVersion`, `ok`, `host` and
210
+ `command`. If any host fails, the exit code is 1. Text output prints one
211
+ `Host: <host>` block per destination.
212
+ - All hosts and options are validated before any `ssh` process starts. One bad
213
+ value refuses the whole command with `submitted:false`. Every `--host VALUE`
214
+ or `--host=VALUE` before `--` is collected first, so with two or more of them
215
+ any refusal, including an unknown option or a missing value, is an array with
216
+ one element per host. With fewer, it is one flat object.
217
+ - The same destination twice is `duplicate_ssh_host`. This check compares the
218
+ destination text only (user, case-insensitive host name, canonical IPv6). Two
219
+ aliases or addresses for the same machine are not detected.
220
+ - `--ssh-jump USER@HOST[:PORT]` (once, POSIX clients) routes every `ssh` call
221
+ for every `--host` through one jump host. The user is required, IPv6 needs
222
+ brackets (`hop@[2001:db8::1]:22`), and `%`, `$`, quotes, spaces and other
223
+ shell characters are refused (`invalid_ssh_jump`). Instead of `-J`, the CLI
224
+ builds a fixed `ProxyCommand`. The hop runs `ssh` with `BatchMode=yes`,
225
+ `StrictHostKeyChecking=yes`, `UpdateHostKeys=no`, `ConnectTimeout=10`,
226
+ `ConnectionAttempts=1`, `ProxyCommand=none`, `ProxyJump=none`,
227
+ `ControlPath=none`, `ForwardAgent=no`, `ClearAllForwardings=yes` and
228
+ `PermitLocalCommand=no`, then `-W [target]:port`. The outer `ssh` also gets
229
+ `ControlMaster=no`, `ControlPath=none` and `ProxyUseFdpass=no`, so a
230
+ configured control master cannot bypass the hop. `ProxyCommand` runs through
231
+ your login shell (`$SHELL`). It was verified with sh, bash and zsh; other
232
+ login shells (for example fish or csh) are unverified. The hop needs its own
233
+ known_hosts entry. `--ssh-opt` values, including `-4`/`-6`, apply to the
234
+ target only and are not passed to the hop; the
235
+ hop otherwise uses your ssh config for that host. Only one hop is supported.
236
+ `--ssh-jump` conflicts with `--ssh-control-path` (`conflicting_ssh_jump`) and
237
+ is refused on Windows clients (`ssh_jump_unsupported_platform`) until
238
+ Win32-OpenSSH's `ProxyCommand` handling is verified. Results add `sshJump`.
239
+ - Timeouts are bounded. On POSIX each `ssh` starts detached: in a new session
240
+ and process group with no controlling terminal. Cleanup covers that group
241
+ only; a descendant that leaves it with `setsid()` is out of scope, and there
242
+ is no PID scanning. At
243
+ a timeout or output overflow the whole group is killed, including a jump
244
+ `ProxyCommand` or any other descendant still holding the output pipes, and the
245
+ call returns shortly after. Ctrl-C, SIGTERM or SIGHUP to the CLI also kills the
246
+ group before the CLI exits. On Windows only the direct child is killed, so
247
+ descendants may linger, but the call still returns at the deadline. A preflight
248
+ timeout is a refusal (`ssh_preflight_timeout`); a request timeout is `unknown`
249
+ and is never retried.
250
+ - Each destination gets one preflight and at most one request, in order. A
251
+ refused or `unknown` host does not stop the next host and is never retried or
252
+ resent elsewhere. Check each element before acting on it.
253
+ - `--ssh-opt` accepts only `-p PORT`, `-l USER`, `-i IDENTITY_FILE`,
254
+ `-o Port=…`, `-o User=…`, `-o IdentityFile=…`, `-o IdentitiesOnly=yes|no`,
255
+ `-4` and `-6`. Everything else, including `ProxyCommand`, `LocalCommand`,
256
+ `-F`, `Include`, `-J`/`ProxyJump` and any `BatchMode`/`StrictHostKeyChecking`
257
+ change, is refused (`unsupported_ssh_option`). Use `--ssh-jump` instead of
258
+ `-J`: OpenSSH's own `-J` hop does not receive the command-line `BatchMode` or
259
+ `StrictHostKeyChecking`.
260
+ - IPv6 literals may be bare (`2001:db8::1`) or bracketed (`[2001:db8::1]`,
261
+ `user@[2001:db8::1]`); zone IDs are refused.
262
+ - Results add `sshUser` and `sshUserSource`: `explicit` for `USER@HOST` or
263
+ `-l USER`, `ssh_config_or_local_default` from `ssh -G`, or `unknown` with
264
+ `sshUser:null`. `-l` together with `USER@HOST` is refused. Without an explicit
265
+ user, a local `ssh -G` runs once per host, limited to 5 s. It does not
266
+ connect, but as ssh(1) and ssh_config(5) describe, it evaluates your ssh
267
+ configuration, including `Match exec` commands, just as a normal `ssh` would.
268
+ - Two trust boundaries apply. The allowlist governs only the options this CLI
269
+ passes on the command line. Your own `~/.ssh/config` (and the system config)
270
+ is trusted user configuration: its `ProxyCommand`, `ProxyJump`, `Match exec`
271
+ and similar settings run for every `ssh` this CLI starts, exactly as they do
272
+ for your own `ssh` commands.
273
+
274
+ A proposed design for provisioning destinations without Python (a private,
275
+ versioned install directory, integrity checks, ownership and rollback rules)
276
+ and for a protocol compatibility contract separate from package versions is in
277
+ [Remote deployment ADR](design/remote-deployment.md). It is not implemented; the exact
278
+ same-version requirement above still applies.
279
+
197
280
  ### Replies
198
281
 
199
282
  Use a `session-peer://v1/reply?...` URI as `--to`. Unknown/duplicate fields,
200
283
  unsafe hosts, malformed encoding and conflicting explicit routes are rejected.
201
- `--reply-address URI` adds an explicit return address; no route is inferred or
202
- verified automatically. Use `--no-reply-to` when replying without a new address.
203
- A valid CODEX_THREAD_ID/CODEX_SESSION_ID supplies informational From metadata;
204
- `--no-from` omits it. Unknown senders are not invented. Peer metadata is never
205
- authority, and a Reply-To URI is never executed as shell text.
284
+ Peer metadata is never authority, and a Reply-To URI is never executed as shell
285
+ text. A received Reply-To is data for the reader; no reply is observed or
286
+ confirmed automatically.
287
+
288
+ Since 0.3.0 (not in 0.2.1 or earlier), the CLI adds sender context and generated routes:
289
+
290
+ - **Sender.** Inside Claude Code, `CLAUDE_CODE_MESSAGING_SOCKET` must match
291
+ exactly one live registered session; its unique printable name (otherwise its
292
+ PID) becomes `From: claude:NAME`. Inside Codex, a valid `CODEX_THREAD_ID` (or
293
+ `CODEX_SESSION_ID`) gives `From: codex:UUID`. Conflicting, nested or invalid
294
+ evidence gives no identity, and then no generated Reply-To. `--no-from` omits
295
+ From only.
296
+ - **Generated Reply-To.** With a sender and no `--no-reply-to`, a local send gets
297
+ a `transport=local` URI. An SSH send, or `--reply-to`, gets a
298
+ `transport=ssh` URI whose host comes from `--reply-to HOST`, then
299
+ `SESSION_PEER_REPLY_HOST`, then `CC_PEER_REPLY_HOST`, then this machine's
300
+ tailnet name or address. A host without a user gets the current user. If no
301
+ host is found, no SSH route is added. `--reply-address URI` stays an explicit
302
+ alternative. `--reply-to`, `--reply-address` and `--no-reply-to` are mutually
303
+ exclusive. Every URI is checked by the same parser as `--to`.
304
+ - **JSON.** `replyRoute` reports the generated route: local routes are
305
+ `verified` (`same_machine_route`), SSH routes `unverified`
306
+ (`reverse_ssh_not_checked`). When `--to` is a URI, `addressResolution`
307
+ records its transport, and `normalizedFrom: "ssh_self"` when it was delivered
308
+ locally.
309
+ - **Same machine.** An SSH reply URI is delivered locally only when its host
310
+ includes this OS user and names this machine in an exact form (`localhost`,
311
+ canonical `127.x.y.z`, `::1`, `::ffff:127.x.y.z`, the host name or the
312
+ Tailscale self node; never a non-canonical numeric such as `127.1` or
313
+ `0177.0.0.1`, nor an IPv4-compatible address such as `::7f00:1`), and no `--host` or SSH option (including `--ssh-jump`) was given. A
314
+ different or missing user stays SSH.
315
+ - **Tailscale.** `tailscale status --json` (3 s bound) is a routing hint only.
316
+ A peer whose `Online` is the boolean `true` (with MagicDNS on) keeps your SSH
317
+ alias as the destination and adds `HostName=<MagicDNS name>`. It also adds
318
+ `HostKeyAlias=<original name>`, unless the same `ssh -G` that reads the user
319
+ shows a `HostKeyAlias` already set in your ssh config (that one is kept), or
320
+ that lookup fails (nothing is overridden). The result `host` is then the
321
+ MagicDNS name, and `sshHost` is the alias you gave. A peer whose `Online` is
322
+ the boolean `false`, even with MagicDNS off, or an ambiguous name, is refused
323
+ before SSH (`tailscale_peer_offline`, `tailscale_destination_ambiguous`). Any
324
+ other `Online` value, MagicDNS off, an unknown name, a stopped or missing
325
+ Tailscale, or `SESSION_PEER_TAILSCALE=off` means ordinary SSH.
326
+ - **Return route.** `doctor --check-return-route [--reply-to USER@HOST]` runs
327
+ `ssh … USER@HOST 'exit 0'` from the diagnosed machine (the `--host`
328
+ destination, or this one). It uses batch mode, no password or
329
+ keyboard-interactive prompts, strict host keys, no host-key updates, no
330
+ control socket and a 5 s connect timeout. The 8 s deadline applies to that
331
+ final `ssh` command only; the Tailscale status (3 s) and `ssh -G` (5 s)
332
+ lookups before it have their own limits. `exit 0` is a no-op in POSIX shells,
333
+ cmd.exe and PowerShell, so the return host may be any OpenSSH server with one
334
+ of those default shells (only POSIX return hosts have fixture coverage).
335
+ `returnRoute` is `verified` or `failed` with a reason
336
+ (`return_host_unavailable`, `return_host_is_receiver`,
337
+ `ssh_executable_missing`, `authentication_failed`, `host_key_failed`,
338
+ `timeout`, `transport_failed`, `remote_command_failed`). Locally, this user
339
+ on this machine is a local route without SSH. With `--host`, a loopback
340
+ return host that might name a machine is refused before SSH, without DNS:
341
+ `localhost`, `*.localhost`, canonical 127.0.0.0/8 and 0.0.0.0/8, `::1`,
342
+ `::`, their `::ffff:` mapped forms, IPv4-compatible IPv6 (`::a.b.c.d`), and
343
+ every non-canonical numeric (leading zeros, fewer than four parts, hex or
344
+ octal parts, single integers, overflow such as `127.1`, `0177.0.0.1`,
345
+ `2130706433` or `4294967296`), because resolvers disagree on those. It is
346
+ refused
347
+ (`invalid_return_route`), because the destination would read it as itself.
348
+ On the destination, a return host that is a known name of the destination
349
+ itself (for any user) or an unprovable numeric form fails as
350
+ `return_host_is_receiver` and is never reported as a verified local route.
351
+ "Known name" means only an exact match with the OS host name or the Tailscale
352
+ self names and addresses; other DNS or LAN aliases of a machine are not
353
+ detected. Likewise a remote send never advertises a loopback or non-canonical
354
+ numeric reply host (`invalid_reply_host`). It is never run automatically, never retried, and forward
355
+ reachability never implies it. Like every `ssh` this CLI starts, the probe
356
+ and its `ssh -G` user lookup use your trusted ssh configuration on the
357
+ probing machine, including `ProxyCommand` and `Match exec` (see the trust
358
+ boundaries above). The command-line allowlist does not apply to that file.
206
359
 
207
360
  ## What success means
208
361
 
@@ -258,12 +411,13 @@ separate approval. Licensed under [MIT](../LICENSE).
258
411
 
259
412
  ## Package release
260
413
 
261
- Version 0.2.0 was published and verified on 2026-09-28 KST; see the
262
- [public release record](../VALIDATION.md#public-020--2026-09-28-kst). Check the
263
- exact version and current tags before installing:
414
+ Version 0.2.1 was published and verified on 2026-09-29 KST and 0.2.0 on
415
+ 2026-09-28 KST; see the [0.2.1 public release record](../VALIDATION.md#public-021--2026-09-29-kst).
416
+ Later releases add their own dated records. Check the exact version and current
417
+ tags before installing:
264
418
 
265
419
  ```sh
266
- npm view session-peer@0.2.0 version dist.integrity
420
+ npm view session-peer@0.3.1 version dist.integrity
267
421
  npm view session-peer dist-tags
268
422
  ```
269
423
 
@@ -299,7 +453,79 @@ inbox readiness means a live process advertises a pipe; it does not prove the
299
453
  pipe exists or accepts connections. `capabilities` explicitly excludes
300
454
  wake/wait/ACK and consumption confirmation. Optional TS skill metadata checks
301
455
  never install anything. See [diagnostic boundaries](../PARITY.md#source-read-only-doctor--18--020).
302
- SSH requires the same source build on both ends.
456
+ SSH requires the same TypeScript client version on both ends.
457
+ ### Update checks and notices (0.3.0, #22)
458
+
459
+ ```sh
460
+ session-peer update --check --json
461
+ session-peer update --check --channel preview --output-format text
462
+ ```
463
+
464
+ This command was added in 0.3.0; 0.2.1 and earlier do not have it. `update --check` makes one
465
+ request (3-second timeout, no retries) for the npm dist-tags of `session-peer`
466
+ and reports `current`, `latest`, `channel` (`latest` by default, or `preview`),
467
+ `source: "npm_registry"`, `status` (`update_available`, `up_to_date` or `ahead`),
468
+ `managedBy`, `updateCommand` and `guidance`. A command is given only when the
469
+ installation's owner is positively identified from the running CLI's path:
470
+ an npm global prefix whose own `session-peer` launcher points at this package
471
+ (default, Homebrew, nvm, nvm-windows and fnm prefixes), for example
472
+ `npm install --global --ignore-scripts session-peer@0.3.1`; a pnpm, Yarn or Bun
473
+ global store whose manifest declares `session-peer`; Volta; or the npx cache.
474
+ Project installs (`npm_project`, `pnpm_project`), source checkouts (`source`)
475
+ and anything else (`unknown`) get `updateCommand: null` and a `guidance`
476
+ sentence instead, so no command can modify an unrelated current directory.
477
+ Only npm versions are reported. Python `session-peer` releases are a separate
478
+ stream and are never compared. Registry failures exit 1 with
479
+ `registry_timeout`, `registry_unreachable`, `registry_http_error`,
480
+ `registry_response_invalid` or `dist_tag_missing`; response bodies are never printed.
481
+
482
+ `update` without `--check` does not modify anything: it refuses with
483
+ `self_update_unsupported` (exit 2) and returns `managedBy`, `updateCommand`,
484
+ `guidance` and `checkCommand`. `update` itself is local only: it rejects
485
+ `--host` and is refused over the SSH wire. Remote hosts, Python installations
486
+ and the separately managed `session-peer-ts` skill are never updated; the
487
+ result lists local TS skill metadata (`skills`, same contract as `doctor`) with
488
+ `skillsManagedBy: "separate"`.
489
+
490
+ Cached notices on `list`, `send` and `doctor` are **off by default** because
491
+ this CLI is mainly run by agents and scripts that should not make unrequested
492
+ network calls. Set `SESSION_PEER_UPDATE_NOTICE=1` to opt in. Then a fresh cache
493
+ (24 hours) that shows a newer stable npm version adds a `clientUpdate` object to
494
+ JSON results, or one line on stderr for text output. A missing, invalid or
495
+ expired cache starts one detached refresh and never delays or changes the
496
+ command's result or exit code; a failed refresh waits 1 hour before the next
497
+ attempt. Cache writes are single-flight and fail closed: every write, from a
498
+ background refresh or an explicit check, happens only while holding
499
+ `npm-update.lock`, and only over an older record. Nothing ever takes over or
500
+ removes a lock it did not create. If a refresh crashes, or an I/O error keeps it
501
+ from releasing the lock, the lock stays behind: background refreshes stop, and
502
+ `update --check` reports `cache: "skipped_stale_lock"`. Delete `npm-update.lock` by hand when no
503
+ session-peer process is running.
504
+
505
+ `--no-update-notice` and `SESSION_PEER_NO_UPDATE_NOTICE=1` suppress these
506
+ background notices and refreshes. An explicit `update --check` is an intended
507
+ request: it always contacts the registry and, for the `latest` channel, writes
508
+ the cache when the lock is free (`cache` reports `written`, `skipped_locked`,
509
+ `skipped_stale_lock`, `skipped_newer` or `failed`). Notices belong to the local client. With `--host` the client
510
+ adds `clientUpdate` (or the stderr line) to its own top-level output, including
511
+ results obtained over SSH. When repeated `--host` produces a JSON array, the
512
+ array and its elements keep their exact shape and no `clientUpdate` is added;
513
+ text output still gets the single stderr line. Each invocation refreshes at most
514
+ once, regardless of the number of hosts. A single-host result that failed
515
+ (for example a refused SSH preflight) can still carry the advisory, but parse
516
+ errors and local refusals never do, and the advisory never changes status, exit
517
+ code or retry decisions. A `clientUpdate` sent back by a remote host is
518
+ discarded. The receiver in `--stdio-request` mode never reads,
519
+ refreshes or produces a notice.
520
+
521
+ The cache is `npm-update.json` in `SESSION_PEER_CACHE_DIR` (absolute), otherwise
522
+ `$XDG_CACHE_HOME/session-peer`, `~/Library/Caches/session-peer` (macOS),
523
+ `~/.cache/session-peer` (Linux) or `%LOCALAPPDATA%\session-peer\Cache`
524
+ (Windows). It is written atomically with mode 0600 in a 0700 directory and
525
+ holds only public version data. `SESSION_PEER_UPDATE_REGISTRY` selects a mirror
526
+ (HTTPS, or HTTP on loopback only; no credentials). npm configuration and
527
+ `.npmrc` are not read. See [update boundaries](../PARITY.md#source-update-checks--22).
528
+
303
529
  ## Agent skill: explicit installation
304
530
 
305
531
  The separate `session-peer-ts` companion skill is tracked in [companion PR #14](https://github.com/abruption/session-peer-skill/pull/14); it is not a new npm or skill-tag release. It supports the published 0.1.0 baseline, detects the TypeScript implementation marker, and checks help before using development capabilities. The Python `session-peer` skill remains separate.
@@ -322,3 +548,8 @@ agent/scope. Restart the agent if its catalog is cached. Runtime and skill
322
548
  lifecycles are independent: npm `--ignore-scripts` works, no postinstall invokes
323
549
  Skills CLI, and installing this skill does not overwrite the Python skill or
324
550
  install a runtime. See [compatibility and validation](../PARITY.md#source-ts-skill-guidance--25--020).
551
+
552
+ ## Optional sp shorthand
553
+
554
+ Optional `sp` shorthand ships with 0.3.0 and later (not 0.2.1 or earlier) and is
555
+ never enabled automatically. See [explicit activation and collisions](shorthand.md).
@@ -4,7 +4,7 @@
4
4
 
5
5
  [English](guide.md) | [한국어](guide.ko.md) | [日本語](guide.ja.md) | [简体中文](guide.zh-CN.md)
6
6
 
7
- 这是 0.2.1 详细指南。0.2.1 是 0.2.0 的可靠性与加固更新([变更](../PARITY.md#021-reliability-and-hardening))。上一次发布记录见 [0.2.0 公开发布证据](../VALIDATION.md#public-020--2026-09-28-kst);下文 0.1.0 的说明用于旧版本对比。
7
+ 这是 0.3.1 详细指南([可靠性修复](../PARITY.md#031-reliability-fixes))。0.3.0 新增了多主机 SSH、发送者信息与回复路由、更新检查以及可选的 `sp` 简写([0.3.0 变更](../PARITY.md#030-remote-usability-and-maintenance))。上一次发布记录见 [0.3.0 公开发布证据](../VALIDATION.md#public-030--2026-10-03-kst);下文 0.1.0 的说明用于旧版本对比。
8
8
 
9
9
  ## 目录
10
10
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  向正在运行的 **Claude Code 和 Codex 会话**发送消息,支持本机和跨机器 SSH。这是运行于 Node.js 的 TypeScript 客户端,不需要 Python。
23
23
 
24
- **这是 0.2.1 使用指南。**包名为 `session-peer`,CLI 命令为 **`session-peer`**。本项目不提供 Relay 服务器或托管服务。
24
+ **这是 0.3.1 使用指南。**包名为 `session-peer`,CLI 命令为 **`session-peer`**。本项目不提供 Relay 服务器或托管服务。
25
25
 
26
26
  ## 功能与边界
27
27
 
@@ -38,7 +38,7 @@
38
38
 
39
39
  构建后,`node dist/cli.js list --json` 合并列出 Claude/Codex,`list --agent codex --json` 查找已知 home。公开 npm **0.1.0** 仍要求显式 agent,以及 Codex 列表所需的 home;0.2.0 也支持显式命令格式。
40
40
 
41
- 范围仅限默认 `~/.codex`、`CODEX_HOME`、macOS Orca 下的直接账户 home,以及 JSON 数组 `SESSION_PEER_CODEX_HOMES`。`--codex-home` 固定 Codex 列表并绕过无关配置错误;`--agent claude` 完全跳过 Codex 探索。同一 home 的别名合并,不同 home 的相同 UUID 保留。发送时使用每行的 `codexHome`。可选 home 缺失不是错误;显式 home 缺失或无效会保留成功读取的行,并返回退出码 1。列表不会选择 writer 或提交消息。[列表契约](../PARITY.md#source-unified-listing-contract--16--020)说明排序、诊断、`--all` 和 SSH 行为。0.2.0的 Codex 发送在省略 `--codex-home` 时选择唯一且稳定的 live writer;显式 home 仍会检查所有已知竞争 home。非活动队列提交需要已保存的线程、所有候选均确认非活动,以及 `--codex-home HOME --allow-inactive-codex-home`,不会执行 wake/resume。Dry-run 不提交。JSON 新增诊断 `codexHomeResolution`,且仅在原生输出提供时包含 `queueId`;两者均不代表消费确认。请参阅[选择契约](../PARITY.md#source-codex-home-selection--17--020)。公开 **0.1.0** 仍需要显式 live home,且没有非活动许可选项。SSH 两端请使用同一0.2.1 构建。
41
+ 范围仅限默认 `~/.codex`、`CODEX_HOME`、macOS Orca 下的直接账户 home,以及 JSON 数组 `SESSION_PEER_CODEX_HOMES`。`--codex-home` 固定 Codex 列表并绕过无关配置错误;`--agent claude` 完全跳过 Codex 探索。同一 home 的别名合并,不同 home 的相同 UUID 保留。发送时使用每行的 `codexHome`。可选 home 缺失不是错误;显式 home 缺失或无效会保留成功读取的行,并返回退出码 1。列表不会选择 writer 或提交消息。[列表契约](../PARITY.md#source-unified-listing-contract--16--020)说明排序、诊断、`--all` 和 SSH 行为。0.2.0的 Codex 发送在省略 `--codex-home` 时选择唯一且稳定的 live writer;显式 home 仍会检查所有已知竞争 home。非活动队列提交需要已保存的线程、所有候选均确认非活动,以及 `--codex-home HOME --allow-inactive-codex-home`,不会执行 wake/resume。Dry-run 不提交。JSON 新增诊断 `codexHomeResolution`,且仅在原生输出提供时包含 `queueId`;两者均不代表消费确认。请参阅[选择契约](../PARITY.md#source-codex-home-selection--17--020)。公开 **0.1.0** 仍需要显式 live home,且没有非活动许可选项。SSH 两端需要相同的 TypeScript 客户端版本(0.3.1)。
42
42
 
43
43
  ### 0.2.0 CLI 易用性
44
44
 
@@ -58,14 +58,15 @@ macOS、Linux 或 Windows native;Node **22.x 中的 22.13 及以上,或 24.x
58
58
 
59
59
  ## 安装
60
60
 
61
- 已验证的稳定版可在 Node 22.x 的 22.13 及以上或 24.x 上安装。Python CLI 也使用同一个命令名;若已有安装,请先检查 PATH。
61
+ 使用 Node 22.x 的 22.13 及以上或 24.x,并确认要安装的确切版本是否已发布。Python CLI 也使用同一个命令名;若已有安装,请先检查 PATH。
62
62
 
63
63
  ```sh
64
- npm install --global --ignore-scripts session-peer@0.2.1
64
+ npm view session-peer@0.3.1 version dist.integrity
65
+ npm install --global --ignore-scripts session-peer@0.3.1
65
66
  session-peer --version
66
67
  ```
67
68
 
68
- 预期输出:`session-peer 0.2.1 (typescript)`。
69
+ 预期输出:`session-peer 0.3.1 (typescript)`。
69
70
 
70
71
  1. 用 `session-peer list --agent claude --json` 查找目标并选择准确 PID。
71
72
  2. 用 `session-peer send --to CLAUDE_PID --message 'Please reply after checking.' --dry-run --json` 验证,不提交。
@@ -84,7 +85,7 @@ npm run build
84
85
  node dist/cli.js --version
85
86
  npm pack --ignore-scripts
86
87
  # 可选:全局安装前先检查 PATH 选择的现有命令
87
- npm install --global --ignore-scripts ./session-peer-0.2.1.tgz
88
+ npm install --global --ignore-scripts ./session-peer-0.3.1.tgz
88
89
  session-peer --version
89
90
  ```
90
91
 
@@ -94,7 +95,7 @@ session-peer --version
94
95
 
95
96
  安装前后用 `type -a session-peer` 和 `command -v session-peer` 检查实际执行项。其他实现也可能提供同名命令;请选择 PATH 上的一种,或显式运行 `node /absolute/path/dist/cli.js`。不要用 `--force` 覆盖其他管理器的文件。本包不会自动安装、删除或调整 Python 包、技能或服务。卸载使用 `npm uninstall --global session-peer`,随后再次检查 PATH。
96
97
 
97
- 在 Windows PowerShell 中用 `Get-Command session-peer -All` 检查已有命令。为了不替换 Python CLI,可先执行 `npm ci --ignore-scripts`、`npm run build`、`npm pack --ignore-scripts`,再用 `npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.2.1.tgz` 安装到隔离目录。以 `& "$env:TEMP\session-peer-ts-source\node_modules\.bin\session-peer.cmd" --version` 验证,并可用 `npm uninstall --prefix "$env:TEMP\session-peer-ts-source" session-peer` 卸载。
98
+ 在 Windows PowerShell 中用 `Get-Command session-peer -All` 检查已有命令。为了不替换 Python CLI,可先执行 `npm ci --ignore-scripts`、`npm run build`、`npm pack --ignore-scripts`,再用 `npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.3.1.tgz` 安装到隔离目录。以 `& "$env:TEMP\session-peer-ts-source\node_modules\.bin\session-peer.cmd" --version` 验证,并可用 `npm uninstall --prefix "$env:TEMP\session-peer-ts-source" session-peer` 卸载。
98
99
 
99
100
  ## 使用
100
101
 
@@ -114,13 +115,44 @@ session-peer send --host user@machine --remote-bin /absolute/path/session-peer \
114
115
  --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
115
116
  ```
116
117
 
117
- 默认远程命令是 PATH 中的 `session-peer`。绝对路径 `--remote-bin` 也可选择使用受支持 Node 的包装器。握手检查 TypeScript 标记及精确版本,不同实现会被拒绝。SSH 使用 BatchMode 和 StrictHostKeyChecking,不自动接受新主机密钥、不安装远程运行时,也不会退回 Python。消息通过 JSON stdin 传输,不放进远程 shell 参数。不支持任意 `--ssh-opt`、IPv6 字面量或 Tailscale 规范名补全,请使用 SSH 别名 / 主机名。正向访问不意味着反向访问已配置。
118
+ 默认远程命令是 PATH 中的 `session-peer`。绝对路径 `--remote-bin` 也可选择使用受支持 Node 的包装器。握手检查 TypeScript 标记及精确版本,不同实现会被拒绝。SSH 使用 BatchMode 和 StrictHostKeyChecking,不自动接受新主机密钥、不安装远程运行时,也不会退回 Python。消息通过 JSON stdin 传输,不放进远程 shell 参数。正向访问不意味着反向访问已配置。自 0.3.0 起 Tailscale 只用作路由提示,见[回复](#回复)。
118
119
 
119
- 对于 Windows SSH 目标,请指定 `--remote-platform win32`;若远端 PATH 中没有命令,再使用 `--remote-bin 'C:\absolute\path\session-peer.cmd'`。可用 `--ssh-control-path /local/absolute/socket` 选择已认证的 OpenSSH 控制套接字;这不会跳过主机密钥验证或授予新登录。Windows 本机的 Codex home 使用完整 `C:\Users\...\.codex` 路径。已有 Python CLI 不会被自动删除或替换。
120
+ 对于 Windows SSH 目标,请指定 `--remote-platform win32`;若远端 PATH 中没有命令,再使用 `--remote-bin 'C:\absolute\path\session-peer.cmd'`。仅有一个 `--host` 时,可用 `--ssh-control-path /local/absolute/socket` 选择已认证的 OpenSSH 控制套接字;这不会跳过主机密钥验证或授予新登录。Windows 本机的 Codex home 使用完整 `C:\Users\...\.codex` 路径。已有 Python CLI 不会被自动删除或替换。
121
+
122
+ ### 多主机与连接选项
123
+
124
+ 自 0.3.0 起(0.2.1 及更早版本没有)接受重复的 `--host` 和受限的 `--ssh-opt`:
125
+
126
+ ```sh
127
+ session-peer list --host alpha --host user@[2001:db8::1] \
128
+ --ssh-opt=-p --ssh-opt=2222 --ssh-opt=-i --ssh-opt="$HOME/.ssh/id_ed25519" --json
129
+ ```
130
+
131
+ - 只有一个 `--host` 时与以前一样返回单个对象。重复 `--host` 时按相同顺序返回 JSON 数组,每个元素都有 `schemaVersion`、`ok`、`host` 和 `command`。任一主机失败时退出码为 1。文本输出为每个目标打印一个 `Host: <host>` 块。
132
+ - 在启动任何 `ssh` 进程之前校验所有主机和选项。只要有一个值无效,就拒绝整个命令并返回 `submitted:false`。`--` 之前的 `--host VALUE` 和 `--host=VALUE` 会先被收集,因此当它们有两个或更多时,任何拒绝(包括未知选项或缺少值)都会输出为每个主机一个元素的数组;少于两个时输出单个对象。
133
+ - 重复指定同一目标会返回 `duplicate_ssh_host`。该检查只比较目标文本(用户、不区分大小写的主机名、规范化的 IPv6),无法识别指向同一台机器的不同别名或地址。
134
+ - `--ssh-jump USER@HOST[:PORT]`(只能指定一次,限 POSIX 客户端)让所有 `--host` 的每次 `ssh` 调用都经过同一台跳板机。必须指定用户,IPv6 需要方括号(`hop@[2001:db8::1]:22`),`%`、`$`、引号、空格等 shell 字符会被拒绝(`invalid_ssh_jump`)。CLI 不使用 `-J`,而是构造一个固定的 `ProxyCommand`:跳板段的 `ssh` 以 `BatchMode=yes`、`StrictHostKeyChecking=yes`、`UpdateHostKeys=no`、`ConnectTimeout=10`、`ConnectionAttempts=1`、`ProxyCommand=none`、`ProxyJump=none`、`ControlPath=none`、`ForwardAgent=no`、`ClearAllForwardings=yes`、`PermitLocalCommand=no` 运行,再通过 `-W [目标]:端口` 连接。外层 `ssh` 也会设置 `ControlMaster=no`、`ControlPath=none` 和 `ProxyUseFdpass=no`,因此已配置的控制主连接无法绕过跳板机。`ProxyCommand` 通过你的登录 shell(`$SHELL`)运行,已在 sh、bash 和 zsh 中验证,其他登录 shell(如 fish、csh)未验证。跳板机也需要自己的 known_hosts 条目。`--ssh-opt` 的值(包括 `-4`/`-6`)只作用于目标,不会传给跳板机;除此之外,跳板段遵循你的 SSH 配置中该主机的设置。只支持一级跳板。它与 `--ssh-control-path` 冲突(`conflicting_ssh_jump`),在验证 Win32-OpenSSH 的 `ProxyCommand` 处理之前,Windows 客户端会拒绝它(`ssh_jump_unsupported_platform`)。结果新增 `sshJump`。
135
+ - 超时是有界的。在 POSIX 上,每个 `ssh` 都以分离方式启动:位于一个没有控制终端的新会话和进程组中。清理只覆盖该进程组;通过 `setsid()` 离开该组的子孙进程不在范围内,也不会扫描 PID。超时或输出超限时,会终止整个进程组,包括仍占用输出管道的跳板 `ProxyCommand` 等子孙进程,随后调用很快返回。CLI 收到 Ctrl-C、SIGTERM 或 SIGHUP 时,也会在退出前终止该进程组。在 Windows 上只终止直接子进程,子孙进程可能残留,但调用仍会在截止时间返回。预检超时视为拒绝(`ssh_preflight_timeout`),请求超时为 `unknown`,且不会重试。
136
+ - 每个目标按顺序只进行一次预检和最多一次请求。被拒绝或 `unknown` 的主机不会阻止下一个主机,也不会重试或改发到其他目标。请逐个检查元素后再采取行动。
137
+ - `--ssh-opt` 只接受 `-p PORT`、`-l USER`、`-i IDENTITY_FILE`、`-o Port=…`、`-o User=…`、`-o IdentityFile=…`、`-o IdentitiesOnly=yes|no`、`-4` 和 `-6`。其他选项一律拒绝(`unsupported_ssh_option`),包括 `ProxyCommand`、`LocalCommand`、`-F`、`Include`、`-J`/`ProxyJump` 以及对 `BatchMode`/`StrictHostKeyChecking` 的修改。请用 `--ssh-jump` 代替 `-J`:OpenSSH 自带的 `-J` 跳板连接不会获得命令行中的 `BatchMode` 和 `StrictHostKeyChecking`。
138
+ - IPv6 字面量可以不带方括号(`2001:db8::1`),也可以带方括号(`[2001:db8::1]`、`user@[2001:db8::1]`);区域 ID(`%`)会被拒绝。
139
+ - 结果新增 `sshUser` 和 `sshUserSource`:`USER@HOST` 或 `-l USER` 为 `explicit`;通过 `ssh -G` 得到的为 `ssh_config_or_local_default`;无法确定时为 `sshUser:null` 和 `unknown`。同时使用 `-l` 和 `USER@HOST` 会被拒绝。没有显式用户时,会为每个主机在本地运行一次 `ssh -G`(最长 5 秒)。它不建立连接,但如 ssh(1) 和 ssh_config(5) 所述,会像普通 `ssh` 一样解析 SSH 配置,包括执行 `Match exec` 命令。
140
+ - 存在两条信任边界。允许列表只约束本 CLI 在命令行上传递的选项。你自己的 `~/.ssh/config`(以及系统配置)属于受信任的用户配置,其中的 `ProxyCommand`、`ProxyJump`、`Match exec` 等设置,会像你自己运行 `ssh` 时一样,作用于本 CLI 启动的每个 `ssh`。
141
+
142
+ 关于在不依赖 Python 的情况下准备目标机器(按版本划分的专用安装目录、完整性校验、所有权与回滚规则),以及独立于包版本的协议兼容性约定,设计提案见[远程部署 ADR](design/remote-deployment.md)。该提案尚未实现,上述相同版本要求仍然适用。
120
143
 
121
144
  ### 回复
122
145
 
123
- 可将 `session-peer://v1/reply?...` URI 用作 `--to`。未知 / 重复字段、不安全主机、错误编码及与显式路由的冲突都会被拒绝。`--reply-address URI` 添加显式回信地址,不自动推断或验证回程。回复时不附加新地址可用 `--no-reply-to`。有效的 CODEX_THREAD_ID / CODEX_SESSION_ID 可提供参考性 From 信息,`--no-from` 可省略;不会虚构未知发送者。peer 元数据不是授权,Reply-To URI 也不会作为 shell 文本执行。
146
+ 可将 `session-peer://v1/reply?...` URI 用作 `--to`。未知 / 重复字段、不安全主机、错误编码及与显式路由的冲突都会被拒绝。peer 元数据不是授权,Reply-To URI 也不会作为 shell 文本执行。收到的 Reply-To 只是供阅读的数据,不会自动观察或确认回复。
147
+
148
+ 自 0.3.0 起(0.2.1 及更早版本没有)新增发送者信息和自动生成的回复路由:
149
+
150
+ - **发送者。** 在 Claude Code 中,`CLAUDE_CODE_MESSAGING_SOCKET` 必须恰好匹配一个已注册且存活的会话;该会话唯一且可打印的名称(否则用 PID)成为 `From: claude:NAME`。在 Codex 中,有效的 `CODEX_THREAD_ID`(或 `CODEX_SESSION_ID`)成为 `From: codex:UUID`。证据冲突、嵌套或无效时不确定发送者,此时也不生成回复路由。`--no-from` 只省略 From。
151
+ - **自动 Reply-To。** 有发送者且未指定 `--no-reply-to` 时,本机发送附加 `transport=local` 的 URI;SSH 发送或指定 `--reply-to` 时附加 `transport=ssh` 的 URI,主机依次取 `--reply-to HOST`、`SESSION_PEER_REPLY_HOST`、`CC_PEER_REPLY_HOST`、本机的 tailnet 名称或地址。不含用户的主机会加上当前用户。找不到主机时不附加 SSH 路由。`--reply-address URI` 仍是显式的替代方式。`--reply-to`、`--reply-address` 和 `--no-reply-to` 互斥。所有 URI 都用与 `--to` 相同的解析器校验。
152
+ - **JSON。** `replyRoute` 报告生成的路由:本机路由为 `verified`(`same_machine_route`),SSH 路由为 `unverified`(`reverse_ssh_not_checked`)。`--to` 为 URI 时,`addressResolution` 记录其传输方式;若改为本机投递,还会记录 `normalizedFrom: "ssh_self"`。
153
+ - **同一台机器。** 只有当 SSH 回复 URI 的主机包含当前操作系统用户、以精确形式指向本机(精确的 `localhost`、规范的 `127.x.y.z`、`::1`、`::ffff:127.x.y.z`、主机名或 Tailscale 自身节点;`127.1`、`0177.0.0.1` 等非规范数字形式以及 `::7f00:1` 等 IPv4 兼容地址都不算),且未给出 `--host` 或 SSH 选项(包括 `--ssh-jump`)时,才改为本机投递。用户不同或缺失时仍走 SSH。
154
+ - **Tailscale。** `tailscale status --json`(限时 3 秒)只作为路由提示。`Online` 为布尔值 `true` 的节点(MagicDNS 开启)保留你给出的 SSH 别名作为目标,并添加 `HostName=<MagicDNS 名称>`;同时添加 `HostKeyAlias=<原名称>`,但如果查询用户的同一次 `ssh -G` 显示 SSH 配置中已设置 `HostKeyAlias`,则保留该值,查询失败时也不覆盖任何设置。此时结果中的 `host` 为 MagicDNS 名称,`sshHost` 为你给出的别名。`Online` 为布尔值 `false` 的节点(即使 MagicDNS 关闭)或有歧义的名称在 SSH 之前被拒绝(`tailscale_peer_offline`、`tailscale_destination_ambiguous`)。其他 `Online` 值、MagicDNS 关闭、未知名称、已停止或未安装的 Tailscale,以及 `SESSION_PEER_TAILSCALE=off`,都按普通 SSH 处理。
155
+ - **回程路由检查。** `doctor --check-return-route [--reply-to USER@HOST]` 在被诊断的机器(`--host` 目标或本机)上执行 `ssh … USER@HOST 'exit 0'`:batch 模式、禁止密码和键盘交互提示、严格主机密钥、不更新主机密钥、不使用控制套接字、连接超时 5 秒。8 秒时限只作用于最后这条 `ssh` 命令;此前的 Tailscale 状态查询(3 秒)和 `ssh -G` 查询(5 秒)各有自己的时限。`exit 0` 在 POSIX shell、cmd.exe 和 PowerShell 中都是空操作,因此回程主机可以是以其中任一为默认 shell 的 OpenSSH 服务器(只有 POSIX 回程主机有夹具覆盖)。`returnRoute` 为 `verified` 或 `failed`,并附原因(`return_host_unavailable`、`return_host_is_receiver`、`ssh_executable_missing`、`authentication_failed`、`host_key_failed`、`timeout`、`transport_failed`、`remote_command_failed`)。本机检查时,同一台机器的当前用户按本机路由处理,不启动 SSH。使用 `--host` 时,可能指向某台机器自身的回程主机(不经 DNS 判断:`localhost`、`*.localhost`、规范形式的 127.0.0.0/8 和 0.0.0.0/8、`::1`、`::`、它们的 `::ffff:` 映射形式、IPv4 兼容 IPv6(`::a.b.c.d`),以及各解析器解释不一的所有非规范数字形式:前导零、少于四段、十六进制或八进制段、单个整数、`127.1`、`0177.0.0.1`、`2130706433`、`4294967296` 等越界值)会被目标机器理解为它自己,因此在 SSH 之前被拒绝(`invalid_return_route`)。在目标机器上,若回程主机是目标机器自身的已知名称(无论用户)或无法证明的数字形式,则以 `return_host_is_receiver` 失败,绝不报告为已验证的本机路由。“已知名称”仅指与操作系统主机名或 Tailscale 自身节点的名称、地址完全一致;其他 DNS 或局域网别名无法识别。远程发送同样不会公布回环或非规范数字形式的回复主机(`invalid_reply_host`)。该检查从不自动运行、从不重试,正向可达也绝不代表回程可达。与本 CLI 启动的其他 `ssh` 一样,该检查及其 `ssh -G` 用户查询会使用执行检查的机器上受信任的 SSH 配置(包括 `ProxyCommand` 和 `Match exec`,见上文的信任边界)。命令行允许列表不适用于该配置文件。
124
156
 
125
157
  ## 成功含义与安全性
126
158
 
@@ -152,11 +184,12 @@ Python 只用作开发时的兼容性基准(v1.0.2,`47c23713d0a2a3c11ebde618
152
184
 
153
185
  ## npm 版本
154
186
 
155
- 0.2.0 已于 2026-09-28 KST 公开并验证。请参阅[公开记录](../VALIDATION.md#public-020--2026-09-28-kst),
187
+ 0.2.1 已于 2026-09-29 KST、0.2.0 已于 2026-09-28 KST 公开并验证。请参阅
188
+ [0.2.1 公开记录](../VALIDATION.md#public-021--2026-09-29-kst)(之后的版本各自追加带日期的记录),
156
189
  安装前核对准确版本与当前标签。
157
190
 
158
191
  ```sh
159
- npm view session-peer@0.2.0 version dist.integrity
192
+ npm view session-peer@0.3.1 version dist.integrity
160
193
  npm view session-peer dist-tags
161
194
  ```
162
195
 
@@ -181,7 +214,60 @@ session-peer doctor --host user@host --json
181
214
  不会执行 Codex、连接 inbox、获取 writer 锁或提交消息。Windows 就绪状态只表示
182
215
  存活进程公布了 pipe,并不证明 pipe 存在或可以连接。`capabilities` 明确将
183
216
  wake/wait/ACK 和消费确认标为不支持。可选的 TS 技能元数据检查也不会安装任何内容。
184
- 参见[诊断边界](../PARITY.md#source-read-only-doctor--18--020)。SSH 两端需要相同的源码构建。
217
+ 参见[诊断边界](../PARITY.md#source-read-only-doctor--18--020)。SSH 两端需要相同的 TypeScript 客户端版本。
218
+ ### 更新检查与提示(0.3.0,#22)
219
+
220
+ ```sh
221
+ session-peer update --check --json
222
+ session-peer update --check --channel preview --output-format text
223
+ ```
224
+
225
+ 此命令在 0.3.0 中加入,0.2.1 及更早版本没有。`update --check` 只请求一次 `session-peer` 的 npm
226
+ dist-tag(3 秒超时,不重试),并报告 `current`、`latest`、`channel`(默认 `latest`,
227
+ 或 `preview`)、`source: "npm_registry"`、`status`(`update_available`、`up_to_date`、
228
+ `ahead`)、`managedBy`、`updateCommand` 和 `guidance`。只有根据当前 CLI 路径能确切识别
229
+ 安装的管理方时才给出命令:其自身 `session-peer` 启动器指向本包的 npm 全局 prefix
230
+ (默认、Homebrew、nvm、nvm-windows、fnm,例如
231
+ `npm install --global --ignore-scripts session-peer@0.3.1`),清单中声明了
232
+ `session-peer` 的 pnpm、Yarn、Bun 全局存储,Volta,或 npx 缓存。项目安装
233
+ (`npm_project`、`pnpm_project`)、源码检出(`source`)以及其他情况(`unknown`)只返回
234
+ `updateCommand: null` 和一句 `guidance`,因此不会给出可能修改无关当前目录的命令。它只报告
235
+ npm 版本,Python 版 `session-peer` 的发布是独立的版本序列,从不与之比较。注册表失败时
236
+ 退出码为 1,错误为 `registry_timeout`、`registry_unreachable`、`registry_http_error`、
237
+ `registry_response_invalid` 或 `dist_tag_missing`,不会输出响应正文。
238
+
239
+ 不带 `--check` 的 `update` 不会修改任何内容:它以 `self_update_unsupported`(退出码 2)
240
+ 拒绝,并返回 `managedBy`、`updateCommand`、`guidance` 和 `checkCommand`。`update` 本身
241
+ 仅限本地:拒绝 `--host`,也拒绝经由 SSH wire 的请求。远程主机、Python 安装和单独管理的
242
+ `session-peer-ts` 技能都不会被更新;结果会列出本地 TS 技能元数据(`skills`,与 `doctor`
243
+ 相同的约定)以及 `skillsManagedBy: "separate"`。
244
+
245
+ `list`、`send`、`doctor` 的缓存提示**默认关闭**,因为此 CLI 主要由代理和脚本调用,
246
+ 不应发起未经请求的网络访问。设置 `SESSION_PEER_UPDATE_NOTICE=1` 开启后,若 24 小时内的
247
+ 缓存显示有更新的 npm 稳定版,JSON 结果会增加 `clientUpdate` 对象,文本输出则在 stderr
248
+ 写一行。缓存缺失、无效或过期时会启动一个分离的刷新进程,不会延迟或改变命令结果与退出码;
249
+ 刷新失败后 1 小时内不再尝试。缓存写入是单次执行的,并在失败时保持关闭:无论是后台刷新还是
250
+ 显式检查,写入都只在持有 `npm-update.lock` 时进行,且只覆盖更旧的记录。任何调用都不会接管或
251
+ 删除不是自己创建的锁。若刷新异常退出,或因 I/O 错误未能释放锁而留下锁,后台刷新会停止,`update --check` 会报告
252
+ `cache: "skipped_stale_lock"`。请在没有 session-peer 进程运行时手动删除 `npm-update.lock`。
253
+
254
+ `--no-update-notice` 和 `SESSION_PEER_NO_UPDATE_NOTICE=1` 会抑制这些后台提示和刷新。
255
+ 显式的 `update --check` 是有意的请求,总会访问注册表;对 `latest` 通道,在锁空闲时写入缓存
256
+ (`cache` 为 `written`、`skipped_locked`、`skipped_stale_lock`、`skipped_newer` 或 `failed`)。提示
257
+ 属于本地客户端:使用 `--host` 时,客户端会在自身的顶层输出(包括经由 SSH 获得的结果)中
258
+ 加入 `clientUpdate`(或 stderr 中的一行)。重复 `--host` 产生 JSON 数组时,数组及其元素保持原样,
259
+ 不加入 `clientUpdate`;文本输出仍在 stderr 写一行。无论主机数量多少,每次调用最多刷新一次。失败的单主机结果(例如被拒绝的 SSH 预检)也可能带有提示,
260
+ 但解析错误和本地拒绝不会带;提示从不改变状态、退出码或重试判断。远程主机返回的 `clientUpdate`
261
+ 会被丢弃。`--stdio-request` 模式的接收端从不读取或刷新
262
+ 缓存,也不会产生提示。
263
+
264
+ 缓存文件为 `SESSION_PEER_CACHE_DIR`(绝对路径)下的 `npm-update.json`,否则依次为
265
+ `$XDG_CACHE_HOME/session-peer`、`~/Library/Caches/session-peer`(macOS)、
266
+ `~/.cache/session-peer`(Linux)或 `%LOCALAPPDATA%\session-peer\Cache`(Windows)。
267
+ 以 0600 权限原子写入 0700 目录,仅包含公开的版本信息。`SESSION_PEER_UPDATE_REGISTRY`
268
+ 可指定镜像(HTTPS,或仅限 loopback 的 HTTP;不允许凭据)。不会读取 npm 配置或 `.npmrc`。
269
+ 参见[更新边界](../PARITY.md#source-update-checks--22)。
270
+
185
271
  ## 显式安装代理技能
186
272
 
187
273
  独立的 `session-peer-ts` 技能在配套 PR 中管理,不代表新 npm 或技能标签发布。它支持已发布的 0.1.0 基础功能,通过 TypeScript 标识和帮助检查开发功能。Python 的 `session-peer` 技能仍独立保留。
@@ -202,3 +288,8 @@ npx -y skills@1.7.0 remove session-peer-ts --agent codex --yes
202
288
  如果代理缓存了技能目录,请重启代理。运行时和技能独立管理:npm `--ignore-scripts` 可正常使用,
203
289
  postinstall 不会调用 Skills CLI,安装此技能不会覆盖 Python 技能或安装运行时。
204
290
  参见[兼容性和验证](../PARITY.md#source-ts-skill-guidance--25--020)。
291
+
292
+ ## 可选 sp 简写
293
+
294
+ 可选的 `sp` 简写包含在 0.3.0 及更高版本中(0.2.1 及更早版本没有),不会自动启用。
295
+ 请参阅[显式启用、冲突与停用(英文)](shorthand.md)。