session-peer 0.2.0 → 0.2.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 ADDED
@@ -0,0 +1,324 @@
1
+ # User guide — session-peer (TypeScript)
2
+
3
+ [Back to README](../README.md)
4
+
5
+ [English](guide.md) | [한국어](guide.ko.md) | [日本語](guide.ja.md) | [简体中文](guide.zh-CN.md)
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.
8
+
9
+ ## Contents
10
+
11
+ - [Quick start](#quick-start)
12
+ - [What it does](#what-it-does)
13
+ - [Requirements](#requirements)
14
+ - [Build from source](#build-from-source)
15
+ - [Existing installations](#existing-installations)
16
+ - [Use](#use)
17
+ - [What success means](#what-success-means)
18
+ - [Development and verification](#development-and-verification)
19
+ - [Package release](#package-release)
20
+ - [Related project](#related-project)
21
+ - [Agent skill: explicit installation](#agent-skill-explicit-installation)
22
+
23
+
24
+ **Find and message running Claude Code and Codex sessions, locally or over SSH.**
25
+ This TypeScript client runs on Node.js without Python.
26
+
27
+ This guide describes **0.2.1**. The npm package and CLI command are both **`session-peer`**. This
28
+ project does not provide a Relay server or hosted service.
29
+
30
+ ## Quick start
31
+
32
+ Use Node **22.13+ within 22.x or 24.x**. Check which `session-peer` your PATH
33
+ selects if the Python CLI is already installed; both packages use that command.
34
+
35
+ ```sh
36
+ npm install --global --ignore-scripts session-peer@0.2.1
37
+ session-peer --version # session-peer 0.2.1 (typescript)
38
+ session-peer list --agent claude --json
39
+ session-peer send --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
40
+ ```
41
+
42
+ 1. List sessions and replace `CLAUDE_PID` with the exact PID you selected.
43
+ 2. Run the send command with `--dry-run`; nothing is submitted.
44
+ 3. When delivery is intended, run that command once without `--dry-run`.
45
+ 4. If acknowledgement matters, ask for an explicit reply in the message and
46
+ verify the receiver's TUI response separately. `posted` / `queued` confirms
47
+ submission only. See [What success means](#what-success-means).
48
+
49
+ ### CLI usability in 0.2.0
50
+
51
+ Version 0.2.0 adds `list --help`, `send --help`, `doctor --help` and explicit
52
+ `--output-format text`. Output selection remains required: use `--json` or
53
+ `--output-format json|text`. Parse errors use JSON; valid text requests render
54
+ operation results/errors as text. SSH always exchanges JSON internally.
55
+
56
+ `send --to TARGET "message" --json` accepts one positional body. Do not combine
57
+ it with `--message`/`-m`; omit the body or use `-` for stdin, and use `--` before
58
+ an option-looking positional body. Empty/whitespace bodies are refused before
59
+ adding the sender envelope. Claude names use exact Unicode 14.0.0 default full
60
+ casefold (no normalization/fuzzy matching); collisions require a PID. This
61
+ source behavior is not retroactively available in the published 0.1.0 package.
62
+
63
+
64
+ ## What it does
65
+
66
+ - Discover local Claude/Codex sessions and known Codex homes (0.2.0; see below).
67
+ - Validate a destination with `--dry-run`, then submit one message to its native
68
+ inbox or queue. Codex normally requires a unique, stable live writer.
69
+ - Use the same commands over SSH to an explicitly installed remote client.
70
+ - Accept structured Reply-To URIs as destinations and provide JSON results.
71
+ - Refuse ambiguous targets and uncertain ownership; never automatically retry
72
+ an uncertain submission.
73
+
74
+ Not implemented: Relay transport, MCP, wake/resume,
75
+ Antigravity or automatic updates. Unsupported commands fail explicitly; this is not a general orchestrator.
76
+
77
+ Planned client gaps are tracked in the [versioned compatibility matrix and npm migration guide](../PARITY.md); a plan is not an available feature. Relay server/hosted-service delivery remains outside this client's scope.
78
+
79
+ ### Unified listing in 0.2.0
80
+
81
+ After building this source, `node dist/cli.js list --json` combines Claude and
82
+ Codex; `list --agent codex --json` searches known homes. Published npm **0.1.0**
83
+ still requires an explicit agent and a home for Codex listing; the install and
84
+ explicit list/send forms also work with that older release.
85
+
86
+ Sources are default `~/.codex`, `CODEX_HOME`, immediate macOS Orca account homes,
87
+ and the JSON array `SESSION_PEER_CODEX_HOMES`. `--codex-home` pins Codex listing
88
+ and bypasses unrelated inventory errors; `--agent claude` skips Codex entirely.
89
+ Aliases are deduplicated, but the same UUID in different homes stays separate.
90
+ Use each row's `codexHome` when sending. Optional absent homes are not failures;
91
+ explicitly configured missing/invalid homes produce partial results and exit 1,
92
+ retaining readable rows. Listing never selects a writer or submits a message.
93
+ See the [source listing contract](../PARITY.md#source-unified-listing-contract--16--020)
94
+ for ordering, diagnostics, `--all` and SSH behavior.
95
+
96
+ Source Codex send now selects the unique stable live writer when `--codex-home`
97
+ is omitted. Explicit homes still check all known competitors. Inactive queueing
98
+ requires both `--codex-home HOME` and `--allow-inactive-codex-home`, a saved thread,
99
+ and verified inactive candidates; it never wakes or resumes a session. Dry-run
100
+ submits nothing. JSON adds sanitized `codexHomeResolution` and, when supplied by
101
+ native queue output, `queueId`; neither confirms consumption. See the
102
+ [selection contract](../PARITY.md#source-codex-home-selection--17--020).
103
+ 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
+
106
+ ## Requirements
107
+
108
+ macOS, Linux or native Windows; Node **22.13+ within 22.x or 24.x**. Node 26 is not supported.
109
+ The native flock dependency needs a matching prebuilt binary (x64/arm64); this
110
+ is not a pure-JavaScript package. Codex sends need `codex`; macOS/Linux also
111
+ need `lsof` and `ps`. Windows uses native lock and Restart Manager inspection.
112
+ Claude needs a live TUI with an accessible native inbox. SSH requires OpenSSH,
113
+ existing key/host trust and the **same client version** on the destination.
114
+
115
+ ## Build from source
116
+
117
+ To run a reviewed source checkout instead of the published npm package, build
118
+ it and optionally install its local tarball:
119
+
120
+ ```sh
121
+ git clone https://github.com/abruption/session-peer-ts.git
122
+ cd session-peer-ts
123
+ npm ci --ignore-scripts
124
+ npm run build
125
+ node dist/cli.js --version
126
+ npm pack --ignore-scripts
127
+ # Optional global install: first check which session-peer your PATH selects.
128
+ npm install --global --ignore-scripts ./session-peer-0.2.1.tgz
129
+ session-peer --version
130
+ ```
131
+
132
+ Expected: `session-peer 0.2.1 (typescript)`. Keep the `./...tgz` path to
133
+ select the locally built artifact. Check the checkout version before using
134
+ these commands for a later release.
135
+
136
+ ## Existing installations
137
+
138
+ Other implementations may also install `session-peer`. Check `type -a session-peer`
139
+ and `command -v session-peer` before and after installation. Choose one on PATH,
140
+ or call this build explicitly with `node /absolute/path/dist/cli.js`. Do not use
141
+ `--force` to overwrite another manager's files. No Python package, skill or service
142
+ is installed, removed or reconfigured automatically. To remove this npm install,
143
+ run `npm uninstall --global session-peer` and recheck PATH.
144
+
145
+ On Windows PowerShell, inspect competing commands with
146
+ `Get-Command session-peer -All`. To avoid replacing the Python CLI, use an isolated prefix:
147
+
148
+ ```powershell
149
+ npm ci --ignore-scripts
150
+ npm run build
151
+ npm pack --ignore-scripts
152
+ npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.2.1.tgz
153
+ & "$env:TEMP\session-peer-ts-source\node_modules\.bin\session-peer.cmd" --version
154
+ # Later: npm uninstall --prefix "$env:TEMP\session-peer-ts-source" session-peer
155
+ ```
156
+
157
+ ## Use
158
+
159
+ ```sh
160
+ session-peer list --agent claude --json
161
+ session-peer list --agent codex --codex-home "$HOME/.codex" --json
162
+ session-peer send --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
163
+ session-peer send --to codex:THREAD_UUID --codex-home "$HOME/.codex" --message 'Please review the API contract.' --dry-run --json
164
+ ```
165
+
166
+ Remove `--dry-run` only when delivery is intended. Omit `--message` or use
167
+ `--message -` for UTF-8 stdin. `--all` includes stale/archived records for listing;
168
+ it does not authorize sending. Claude accepts a PID, `claude:PID`, or an
169
+ unambiguous Unicode 14.0.0 casefolded name. Use a PID for collisions. Codex
170
+ send requires a full UUID; home selection follows the guards above; `--codex-bin` selects an executable.
171
+ Output requires `--json` or `--output-format json|text`.
172
+
173
+ ### Another machine over SSH
174
+
175
+ ```sh
176
+ session-peer send --host user@machine --remote-bin /absolute/path/session-peer \
177
+ --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
178
+ ```
179
+
180
+ The default remote command is `session-peer` on remote PATH. An absolute
181
+ `--remote-bin` can select a wrapper using supported Node. The handshake checks
182
+ the TypeScript marker and exact version; a different implementation is refused.
183
+ SSH uses BatchMode and StrictHostKeyChecking. It never accepts new host keys,
184
+ 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.
188
+
189
+ For a Windows SSH destination, add `--remote-platform win32` and select a
190
+ Windows `--remote-bin 'C:\absolute\path\session-peer.cmd'` if needed. A previously
191
+ 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
194
+ `C:\Users\...\.codex` path for `--codex-home`. The Python CLI, if present,
195
+ is not removed or replaced by this client.
196
+
197
+ ### Replies
198
+
199
+ Use a `session-peer://v1/reply?...` URI as `--to`. Unknown/duplicate fields,
200
+ 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.
206
+
207
+ ## What success means
208
+
209
+ | Result | Meaning |
210
+ | --- | --- |
211
+ | `validated`, `submitted:false` | Dry-run checks passed; nothing sent. |
212
+ | `posted` / `queued` | Native inbox write / queue acceptance, **not consumption or ACK**. |
213
+ | `refused`, `submitted:false` | Rejected before submission. |
214
+ | `unknown`, `submitted:null` | Submission may have happened; do not automatically resend. |
215
+
216
+ After submission, a missing reply or a target exit alone does not establish
217
+ consumption or failure; do not automatically resend.
218
+
219
+ `consumptionConfirmed` is always false. Verify an actual ACK separately in the
220
+ receiver's TUI, not from queueing or transcript polling. Exit codes are 0/1/2
221
+ for success/error/usage. Errors use fixed codes instead of raw native stderr or
222
+ message content. Codex uses real kernel flock, file identity and same-user owner
223
+ start time across samples, then revalidates before queueing. No lock is deleted
224
+ and no owning agent process is signaled. Discovery output still contains local
225
+ names/paths/IDs: redact it before sharing.
226
+
227
+ ## Development and verification
228
+
229
+ ```sh
230
+ npm ci --ignore-scripts
231
+ npm run build
232
+ node scripts/check-repository.mjs
233
+ SESSION_PEER_PYTHON_ROOT=/path/to/python-reference npm test
234
+ npm run test:package
235
+ npm audit
236
+ ```
237
+
238
+ Python is only the development conformance oracle (v1.0.2 commit
239
+ `47c23713d0a2a3c11ebde6186afd8c43489b8b65`), never a runtime dependency. Tests also
240
+ need a C compiler and lsof for the POSIX contract suite. CI uses Node 22/24 on
241
+ macOS, Linux and Windows. macOS/Linux run the full contract suite and package
242
+ checks against the pinned reference. Windows x64 runs build/type checks, native
243
+ Claude inbox and held/free lock fixtures, writer ownership/revalidation races,
244
+ CLI queue outcomes, PowerShell/.cmd SSH framing through an isolated fake endpoint,
245
+ package install/native-load/uninstall checks and audit. These are fixture checks;
246
+ Windows does not run the POSIX/Python reference suite.
247
+ The Windows x64/Node 24 live ACKs are separate, one-shot evidence. Temporary
248
+ SQLite, Unix inbox and real lock fixtures are distinct from
249
+ the dedicated real-TUI evidence in [VALIDATION.md](../VALIDATION.md). A green fixture
250
+ test is not an ACK. Package tests inspect contents, repeat-pack hashes, clean
251
+ install and uninstall. The native dependency normally has an install script;
252
+ the verified prebuilt path uses `--ignore-scripts`. SQLite read-only readers may
253
+ participate in WAL shared-memory bookkeeping; they are not snapshots.
254
+
255
+ See [CONTRIBUTING.md](../CONTRIBUTING.md), [RELEASING.md](../RELEASING.md) and
256
+ [SECURITY.md](../SECURITY.md). Future publication remains manual and requires
257
+ separate approval. Licensed under [MIT](../LICENSE).
258
+
259
+ ## Package release
260
+
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:
264
+
265
+ ```sh
266
+ npm view session-peer@0.2.0 version dist.integrity
267
+ npm view session-peer dist-tags
268
+ ```
269
+
270
+ The immutable 0.1.0 archive retained pre-publication README wording. This
271
+ archive uses versioned feature descriptions; dated release evidence remains in
272
+ [VALIDATION.md](../VALIDATION.md#public-010--2026-09-27-kst).
273
+
274
+ The release workflow uses Trusted Publisher OIDC staging and a maintainer's
275
+ separate 2FA approval. A staged upload is not a public release. See
276
+ [RELEASING.md](../RELEASING.md) for the process.
277
+
278
+ ## Related project
279
+
280
+ [Python session-peer](https://github.com/abruption/session-peer) is maintained
281
+ and released independently; its own optional features and installation guide
282
+ remain there (for example `pipx install session-peer`). Its command is also
283
+ `session-peer`, so apply the PATH guidance above. This client does not depend on
284
+ that installation or claim complete feature/flag parity.
285
+
286
+ ### Read-only diagnostics in 0.2.0
287
+
288
+ ```sh
289
+ session-peer doctor --json
290
+ session-peer doctor --agent codex --codex-home /absolute/home --json
291
+ session-peer doctor --host user@host --json
292
+ ```
293
+
294
+ This source command is not in published npm 0.1.0. Diagnostic success (`ok:true`,
295
+ exit 0) is separate from agent readiness (`ready` and per-agent/home results).
296
+ It inspects bounded metadata and executable paths without executing Codex,
297
+ connecting to inboxes, acquiring writer locks or submitting messages. Windows
298
+ inbox readiness means a live process advertises a pipe; it does not prove the
299
+ pipe exists or accepts connections. `capabilities` explicitly excludes
300
+ wake/wait/ACK and consumption confirmation. Optional TS skill metadata checks
301
+ never install anything. See [diagnostic boundaries](../PARITY.md#source-read-only-doctor--18--020).
302
+ SSH requires the same source build on both ends.
303
+ ## Agent skill: explicit installation
304
+
305
+ 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.
306
+
307
+ Review the [exact skill source](https://github.com/abruption/session-peer-skill/tree/081cc3c1d16a394bd92824333f4bc61c36951799/session-peer-ts),
308
+ then choose the agent and scope. This example selects **Codex, current project**;
309
+ run from that project directory. For Claude Code use `--agent claude-code`.
310
+ For user scope add `--global` consistently to add/list/remove. Inspect any existing
311
+ `session-peer-ts` copy for local edits before approving its replacement. Codex's
312
+ `.agents/skills` directory is shared with other clients that discover that path.
313
+
314
+ ```sh
315
+ npx -y skills@1.7.0 add https://github.com/abruption/session-peer-skill/tree/081cc3c1d16a394bd92824333f4bc61c36951799/session-peer-ts --skill session-peer-ts --agent codex --copy --yes
316
+ npx -y skills@1.7.0 list --agent codex --json
317
+ npx -y skills@1.7.0 remove session-peer-ts --agent codex --yes
318
+ ```
319
+
320
+ For a pinned update, review another exact commit and repeat `add` with the same
321
+ agent/scope. Restart the agent if its catalog is cached. Runtime and skill
322
+ lifecycles are independent: npm `--ignore-scripts` works, no postinstall invokes
323
+ Skills CLI, and installing this skill does not overwrite the Python skill or
324
+ install a runtime. See [compatibility and validation](../PARITY.md#source-ts-skill-guidance--25--020).
@@ -0,0 +1,204 @@
1
+ # 用户指南 — session-peer (TypeScript)
2
+
3
+ [返回 README](../README.zh-CN.md)
4
+
5
+ [English](guide.md) | [한국어](guide.ko.md) | [日本語](guide.ja.md) | [简体中文](guide.zh-CN.md)
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 的说明用于旧版本对比。
8
+
9
+ ## 目录
10
+
11
+ - [功能与边界](#功能与边界)
12
+ - [环境要求](#环境要求)
13
+ - [安装](#安装)
14
+ - [使用](#使用)
15
+ - [成功含义与安全性](#成功含义与安全性)
16
+ - [开发与验证](#开发与验证)
17
+ - [npm 版本](#npm-版本)
18
+ - [相关项目](#相关项目)
19
+ - [显式安装代理技能](#显式安装代理技能)
20
+
21
+
22
+ 向正在运行的 **Claude Code 和 Codex 会话**发送消息,支持本机和跨机器 SSH。这是运行于 Node.js 的 TypeScript 客户端,不需要 Python。
23
+
24
+ **这是 0.2.1 使用指南。**包名为 `session-peer`,CLI 命令为 **`session-peer`**。本项目不提供 Relay 服务器或托管服务。
25
+
26
+ ## 功能与边界
27
+
28
+ - 发现本机 Claude/Codex 会话与已知 Codex home(面向 0.2.0 的功能,见下文)。
29
+ - 先用 `--dry-run` 验证目标,再向原生 inbox / queue 提交一次消息。Codex 要求唯一且稳定的活跃 writer。
30
+ - 通过 SSH 调用远端已安装的同版本客户端,支持结构化 Reply-To URI 和 JSON 输出。
31
+ - 目标或进程归属不明确时拒绝操作;不会自动重试结果不确定的提交。
32
+
33
+ 未实现 Relay 传输、MCP、wake/resume、Antigravity、自动更新。不支持的命令会明确失败;这不是通用编排器。
34
+
35
+ 客户端功能计划见 [版本化兼容性表与 npm 迁移指南](../PARITY.md);计划不代表当前支持。提供 Relay 服务器或托管服务不属于本客户端范围。
36
+
37
+ ### 0.2.0 统一列表
38
+
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
+
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 构建。
42
+
43
+ ### 0.2.0 CLI 易用性
44
+
45
+ 0.2.0新增 `list --help`、`send --help`、`doctor --help` 和 `--output-format text`。
46
+ 仍须明确选择输出格式:`--json` 或 `--output-format json|text`。解析错误
47
+ 使用 JSON;有效 text 请求的操作结果和错误使用文本。SSH 内部始终传输 JSON。
48
+ 支持 `send --to TARGET "message" --json` 位置正文,不可同时使用
49
+ `--message`/`-m`。省略正文或使用 `-` 从 stdin 读取;选项形式的位置正文
50
+ 前须加 `--`。空或纯空白正文在添加发件人信息前被拒绝。Claude 名称使用
51
+ Unicode 14.0.0 默认 full casefold 精确匹配,不进行规范化或模糊匹配;
52
+ 冲突时须指定 PID。这些源码功能不会追溯到已经发布的 0.1.0 包。
53
+
54
+
55
+ ## 环境要求
56
+
57
+ macOS、Linux 或 Windows native;Node **22.x 中的 22.13 及以上,或 24.x**。不支持 Node 26。原生锁依赖需要匹配的 x64/arm64 预编译二进制,本包不是纯 JavaScript 实现。Codex 发送需要 `codex`,macOS/Linux 还需要 `lsof`、`ps`;Windows 使用原生锁和 Restart Manager 验证所有者。Claude 需要运行中的 TUI 及可访问的原生 inbox。SSH 使用已有密钥和主机信任,远端必须安装**同版本**客户端。
58
+
59
+ ## 安装
60
+
61
+ 已验证的稳定版可在 Node 22.x 的 22.13 及以上或 24.x 上安装。Python CLI 也使用同一个命令名;若已有安装,请先检查 PATH。
62
+
63
+ ```sh
64
+ npm install --global --ignore-scripts session-peer@0.2.1
65
+ session-peer --version
66
+ ```
67
+
68
+ 预期输出:`session-peer 0.2.1 (typescript)`。
69
+
70
+ 1. 用 `session-peer list --agent claude --json` 查找目标并选择准确 PID。
71
+ 2. 用 `session-peer send --to CLAUDE_PID --message 'Please reply after checking.' --dry-run --json` 验证,不提交。
72
+ 3. 确定发送时使用选定 PID,移除同一命令中的 `--dry-run`,只执行一次。
73
+ 4. 若需要 ACK,在消息中明确请求回复,并单独确认目标 TUI 的响应。`posted` / `queued` 仅表示提交。
74
+
75
+ ### 从源码构建
76
+
77
+ 若要使用经审查的源码而非公开的 npm 包,请构建源码,并按需安装本地 tarball:
78
+
79
+ ```sh
80
+ git clone https://github.com/abruption/session-peer-ts.git
81
+ cd session-peer-ts
82
+ npm ci --ignore-scripts
83
+ npm run build
84
+ node dist/cli.js --version
85
+ npm pack --ignore-scripts
86
+ # 可选:全局安装前先检查 PATH 选择的现有命令
87
+ npm install --global --ignore-scripts ./session-peer-0.2.1.tgz
88
+ session-peer --version
89
+ ```
90
+
91
+ 保留 `./...tgz` 路径以选择本地产物。使用后续版本的源码时,请先确认检出的版本。
92
+
93
+ ### 与已有安装共存
94
+
95
+ 安装前后用 `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
+ 在 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
+
99
+ ## 使用
100
+
101
+ ```sh
102
+ session-peer list --agent claude --json
103
+ session-peer list --agent codex --codex-home "$HOME/.codex" --json
104
+ session-peer send --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
105
+ session-peer send --to codex:THREAD_UUID --codex-home "$HOME/.codex" --message 'Please review the API contract.' --dry-run --json
106
+ ```
107
+
108
+ 只有确定要投递时才移除 `--dry-run`。省略 `--message` 或使用 `--message -` 会读取 UTF-8 stdin。`--all` 仅让列表包含陈旧 / 已归档记录,不授予发送权限。Claude 支持 PID、`claude:PID` 或唯一的 Unicode 14.0.0 casefold 名称;冲突时使用 PID。Codex 发送需要完整 UUID,home 遵循上述选择规则;`--codex-bin` 可指定可执行文件。输出必须选择 `--json` 或 `--output-format json|text`。
109
+
110
+ ### 跨机器 SSH
111
+
112
+ ```sh
113
+ session-peer send --host user@machine --remote-bin /absolute/path/session-peer \
114
+ --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
115
+ ```
116
+
117
+ 默认远程命令是 PATH 中的 `session-peer`。绝对路径 `--remote-bin` 也可选择使用受支持 Node 的包装器。握手检查 TypeScript 标记及精确版本,不同实现会被拒绝。SSH 使用 BatchMode 和 StrictHostKeyChecking,不自动接受新主机密钥、不安装远程运行时,也不会退回 Python。消息通过 JSON stdin 传输,不放进远程 shell 参数。不支持任意 `--ssh-opt`、IPv6 字面量或 Tailscale 规范名补全,请使用 SSH 别名 / 主机名。正向访问不意味着反向访问已配置。
118
+
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
+
121
+ ### 回复
122
+
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 文本执行。
124
+
125
+ ## 成功含义与安全性
126
+
127
+ | 结果 | 含义 |
128
+ | --- | --- |
129
+ | `validated`, `submitted:false` | dry-run 检查通过,尚未发送。 |
130
+ | `posted` / `queued` | inbox 已写入 / queue 已接受,**不是消费确认或 ACK**。 |
131
+ | `refused`, `submitted:false` | 提交前被拒绝。 |
132
+ | `unknown`, `submitted:null` | 可能已经提交,不要自动重发。 |
133
+
134
+ 提交后没有回复或目标退出,都不能单独证明消息已消费或失败。不要自动重发。
135
+
136
+ `consumptionConfirmed` 始终为 false。必须在目标 TUI 中另行确认实际 ACK,不可由排队或轮询 transcript 推断。退出码 0/1/2 分别表示成功/错误/用法错误。错误只返回固定代码,不返回原生 stderr 或消息内容。Codex 使用真实内核 flock、文件身份和同用户进程开始时间进行多次核验,排队前再次检查。不删除 lock,也不向拥有它的代理进程发送信号。发现结果仍包含本地名称、路径、ID,分享前请脱敏。
137
+
138
+ ## 开发与验证
139
+
140
+ ```sh
141
+ npm ci --ignore-scripts
142
+ npm run build
143
+ node scripts/check-repository.mjs
144
+ SESSION_PEER_PYTHON_ROOT=/path/to/python-reference npm test
145
+ npm run test:package
146
+ npm audit
147
+ ```
148
+
149
+ Python 只用作开发时的兼容性基准(v1.0.2,`47c23713d0a2a3c11ebde6186afd8c43489b8b65`),不是运行时依赖。POSIX 契约测试还需要 C 编译器和 lsof。CI 在三种 OS 上使用 Node 22/24。macOS/Linux 对固定基准执行完整契约与包检查;Windows x64 执行构建、类型检查、原生 Claude inbox、持有/空闲锁、writer 归属与提交前竞争、CLI 队列结果、隔离模拟 SSH 目标的实际 PowerShell/.cmd 帧处理、包安装/原生加载/卸载及 audit。这些属于 fixture 检查;Windows 不运行 POSIX/Python 参考测试套件。Windows x64/Node 24 实机 ACK 是单独的一次性证据。临时 SQLite、Unix inbox、真实锁 fixture 与 [VALIDATION.md](../VALIDATION.md) 中专用真实 TUI 的证据分开记录;fixture 通过不是 ACK。包测试检查文件清单、重复打包哈希、全新安装与卸载。原生依赖通常有安装脚本,已验证的预编译路径使用 `--ignore-scripts`。SQLite 只读连接仍可能参与 WAL 共享内存管理,不能视为快照。
150
+
151
+ 参见 [CONTRIBUTING.md](../CONTRIBUTING.md)、[RELEASING.md](../RELEASING.md) 和 [SECURITY.md](../SECURITY.md)。后续版本的发布需单独批准,未启用自动 npm 发布。采用 [MIT](../LICENSE) 许可证。
152
+
153
+ ## npm 版本
154
+
155
+ 0.2.0 已于 2026-09-28 KST 公开并验证。请参阅[公开记录](../VALIDATION.md#public-020--2026-09-28-kst),
156
+ 安装前核对准确版本与当前标签。
157
+
158
+ ```sh
159
+ npm view session-peer@0.2.0 version dist.integrity
160
+ npm view session-peer dist-tags
161
+ ```
162
+
163
+ 0.1.0 tarball 的历史措辞差异和验证保留在[日期记录](../VALIDATION.md#public-010--2026-09-27-kst)。
164
+ 发布使用 OIDC staging 和单独的 2FA 批准。Staging 成功不等于公开发布。
165
+ 请参阅 [RELEASING.md](../RELEASING.md)。
166
+
167
+ ## 相关项目
168
+
169
+ [Python session-peer](https://github.com/abruption/session-peer) 独立维护和发布,其可选功能与安装指南(例如 `pipx install session-peer`)见该项目。同样使用 `session-peer` 命令,请注意上述 PATH 规则。本客户端不依赖该安装,也不承诺功能和参数完全对等。
170
+
171
+ ### 0.2.0 只读诊断
172
+
173
+ ```sh
174
+ session-peer doctor --json
175
+ session-peer doctor --agent codex --codex-home /absolute/home --json
176
+ session-peer doctor --host user@host --json
177
+ ```
178
+
179
+ 公开 npm 0.1.0 不包含此命令。诊断成功(`ok:true`、退出码 0)与代理就绪状态
180
+ (`ready`、各代理和 home 的结果)分开报告。只检查限定的元数据和可执行文件路径,
181
+ 不会执行 Codex、连接 inbox、获取 writer 锁或提交消息。Windows 就绪状态只表示
182
+ 存活进程公布了 pipe,并不证明 pipe 存在或可以连接。`capabilities` 明确将
183
+ wake/wait/ACK 和消费确认标为不支持。可选的 TS 技能元数据检查也不会安装任何内容。
184
+ 参见[诊断边界](../PARITY.md#source-read-only-doctor--18--020)。SSH 两端需要相同的源码构建。
185
+ ## 显式安装代理技能
186
+
187
+ 独立的 `session-peer-ts` 技能在配套 PR 中管理,不代表新 npm 或技能标签发布。它支持已发布的 0.1.0 基础功能,通过 TypeScript 标识和帮助检查开发功能。Python 的 `session-peer` 技能仍独立保留。
188
+
189
+ 先检查[固定提交的技能源码](https://github.com/abruption/session-peer-skill/tree/081cc3c1d16a394bd92824333f4bc61c36951799/session-peer-ts),再选择代理和安装范围。
190
+ 以下示例选择 **Codex、当前项目**;请在该项目目录中运行。
191
+ Claude Code 使用 `--agent claude-code`。用户范围安装应在 add/list/remove 中一致添加 `--global`。
192
+ 批准替换已有的 `session-peer-ts` 副本前,请检查本地修改。
193
+ Codex 的 `.agents/skills` 目录与其他扫描该路径的客户端共享。
194
+
195
+ ```sh
196
+ npx -y skills@1.7.0 add https://github.com/abruption/session-peer-skill/tree/081cc3c1d16a394bd92824333f4bc61c36951799/session-peer-ts --skill session-peer-ts --agent codex --copy --yes
197
+ npx -y skills@1.7.0 list --agent codex --json
198
+ npx -y skills@1.7.0 remove session-peer-ts --agent codex --yes
199
+ ```
200
+
201
+ 更新固定版本时,请检查另一个准确的提交,然后以相同代理和范围重新运行 `add`。
202
+ 如果代理缓存了技能目录,请重启代理。运行时和技能独立管理:npm `--ignore-scripts` 可正常使用,
203
+ postinstall 不会调用 Skills CLI,安装此技能不会覆盖 Python 技能或安装运行时。
204
+ 参见[兼容性和验证](../PARITY.md#source-ts-skill-guidance--25--020)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "session-peer",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "files": [
26
26
  "dist",
27
+ "docs",
27
28
  "README.md",
28
29
  "README.ko.md",
29
30
  "README.ja.md",
@@ -39,7 +40,7 @@
39
40
  "build": "tsc -p tsconfig.json",
40
41
  "test": "npm run build && npm run test:types && node --experimental-strip-types --test test/*.test.ts",
41
42
  "test:types": "tsc -p tsconfig.test.json",
42
- "test:windows": "npm run build && npm run test:types && node --experimental-strip-types --test --test-concurrency=1 test/windows.test.ts test/windows-contract.test.ts test/input-boundaries.test.ts test/discovery.test.ts test/codex-homes.test.ts test/diagnostics.test.ts test/cli-usability.test.ts test/skill-guidance.test.ts",
43
+ "test:windows": "npm run build && npm run test:types && node --import ./test/fixtures/windows-inspection-diagnostic.mjs --experimental-strip-types --test --test-concurrency=1 test/windows.test.ts test/windows-contract.test.ts test/windows-inspection.test.ts test/input-boundaries.test.ts test/discovery.test.ts test/codex-homes.test.ts test/diagnostics.test.ts test/cli-usability.test.ts test/skill-guidance.test.ts",
43
44
  "test:package": "npm run build && node --experimental-strip-types test/package-smoke.ts"
44
45
  },
45
46
  "devDependencies": {