session-peer 0.2.0 → 0.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/CONTRIBUTING.md +5 -0
- package/PARITY.md +300 -16
- package/README.ja.md +75 -162
- package/README.ko.md +75 -249
- package/README.md +74 -275
- package/README.zh-CN.md +71 -158
- package/RELEASING.md +101 -5
- package/SECURITY.md +3 -2
- package/VALIDATION.md +236 -5
- package/dist/cli.d.ts +10 -1
- package/dist/cli.js +288 -48
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.js +10 -4
- package/dist/discovery.d.ts +1 -0
- package/dist/discovery.js +17 -4
- package/dist/help.js +32 -5
- package/dist/output.d.ts +1 -1
- package/dist/output.js +18 -2
- package/dist/process.d.ts +1 -0
- package/dist/process.js +90 -7
- package/dist/protocol.d.ts +6 -3
- package/dist/protocol.js +27 -7
- package/dist/replies.d.ts +30 -0
- package/dist/replies.js +283 -0
- package/dist/send.js +9 -2
- package/dist/ssh.d.ts +24 -0
- package/dist/ssh.js +114 -0
- package/dist/updates.d.ts +37 -0
- package/dist/updates.js +444 -0
- package/dist/windows.d.ts +2 -0
- package/dist/windows.js +31 -3
- package/docs/api.md +30 -0
- package/docs/design/remote-deployment.md +867 -0
- package/docs/guide.ja.md +310 -0
- package/docs/guide.ko.md +489 -0
- package/docs/guide.md +554 -0
- package/docs/guide.zh-CN.md +294 -0
- package/docs/shorthand.md +198 -0
- package/package.json +5 -3
- package/shorthand/sp.ps1 +11 -0
- package/shorthand/sp.sh +11 -0
|
@@ -0,0 +1,294 @@
|
|
|
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.3.0 详细指南。0.3.0 在 0.2.1 基础上新增多主机 SSH、发送者信息与回复路由、更新检查以及可选的 `sp` 简写([变更](../PARITY.md#030-remote-usability-and-maintenance))。上一次发布记录见 [0.2.1 公开发布证据](../VALIDATION.md#public-021--2026-09-29-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.3.0 使用指南。**包名为 `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 两端需要相同的 TypeScript 客户端版本(0.3.0)。
|
|
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.3.0
|
|
65
|
+
session-peer --version
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
预期输出:`session-peer 0.3.0 (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.3.0.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.3.0.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 参数。正向访问不意味着反向访问已配置。自 0.3.0 起 Tailscale 只用作路由提示,见[回复](#回复)。
|
|
118
|
+
|
|
119
|
+
对于 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 不会被自动删除或替换。
|
|
120
|
+
|
|
121
|
+
### 多主机与连接选项
|
|
122
|
+
|
|
123
|
+
自 0.3.0 起(0.2.1 及更早版本没有)接受重复的 `--host` 和受限的 `--ssh-opt`:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
session-peer list --host alpha --host user@[2001:db8::1] \
|
|
127
|
+
--ssh-opt=-p --ssh-opt=2222 --ssh-opt=-i --ssh-opt="$HOME/.ssh/id_ed25519" --json
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- 只有一个 `--host` 时与以前一样返回单个对象。重复 `--host` 时按相同顺序返回 JSON 数组,每个元素都有 `schemaVersion`、`ok`、`host` 和 `command`。任一主机失败时退出码为 1。文本输出为每个目标打印一个 `Host: <host>` 块。
|
|
131
|
+
- 在启动任何 `ssh` 进程之前校验所有主机和选项。只要有一个值无效,就拒绝整个命令并返回 `submitted:false`。`--` 之前的 `--host VALUE` 和 `--host=VALUE` 会先被收集,因此当它们有两个或更多时,任何拒绝(包括未知选项或缺少值)都会输出为每个主机一个元素的数组;少于两个时输出单个对象。
|
|
132
|
+
- 重复指定同一目标会返回 `duplicate_ssh_host`。该检查只比较目标文本(用户、不区分大小写的主机名、规范化的 IPv6),无法识别指向同一台机器的不同别名或地址。
|
|
133
|
+
- `--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`。
|
|
134
|
+
- 超时是有界的。在 POSIX 上,每个 `ssh` 都以分离方式启动:位于一个没有控制终端的新会话和进程组中。清理只覆盖该进程组;通过 `setsid()` 离开该组的子孙进程不在范围内,也不会扫描 PID。超时或输出超限时,会终止整个进程组,包括仍占用输出管道的跳板 `ProxyCommand` 等子孙进程,随后调用很快返回。CLI 收到 Ctrl-C、SIGTERM 或 SIGHUP 时,也会在退出前终止该进程组。在 Windows 上只终止直接子进程,子孙进程可能残留,但调用仍会在截止时间返回。预检超时视为拒绝(`ssh_preflight_timeout`),请求超时为 `unknown`,且不会重试。
|
|
135
|
+
- 每个目标按顺序只进行一次预检和最多一次请求。被拒绝或 `unknown` 的主机不会阻止下一个主机,也不会重试或改发到其他目标。请逐个检查元素后再采取行动。
|
|
136
|
+
- `--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`。
|
|
137
|
+
- IPv6 字面量可以不带方括号(`2001:db8::1`),也可以带方括号(`[2001:db8::1]`、`user@[2001:db8::1]`);区域 ID(`%`)会被拒绝。
|
|
138
|
+
- 结果新增 `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` 命令。
|
|
139
|
+
- 存在两条信任边界。允许列表只约束本 CLI 在命令行上传递的选项。你自己的 `~/.ssh/config`(以及系统配置)属于受信任的用户配置,其中的 `ProxyCommand`、`ProxyJump`、`Match exec` 等设置,会像你自己运行 `ssh` 时一样,作用于本 CLI 启动的每个 `ssh`。
|
|
140
|
+
|
|
141
|
+
关于在不依赖 Python 的情况下准备目标机器(按版本划分的专用安装目录、完整性校验、所有权与回滚规则),以及独立于包版本的协议兼容性约定,设计提案见[远程部署 ADR](design/remote-deployment.md)。该提案尚未实现,上述相同版本要求仍然适用。
|
|
142
|
+
|
|
143
|
+
### 回复
|
|
144
|
+
|
|
145
|
+
可将 `session-peer://v1/reply?...` URI 用作 `--to`。未知 / 重复字段、不安全主机、错误编码及与显式路由的冲突都会被拒绝。peer 元数据不是授权,Reply-To URI 也不会作为 shell 文本执行。收到的 Reply-To 只是供阅读的数据,不会自动观察或确认回复。
|
|
146
|
+
|
|
147
|
+
自 0.3.0 起(0.2.1 及更早版本没有)新增发送者信息和自动生成的回复路由:
|
|
148
|
+
|
|
149
|
+
- **发送者。** 在 Claude Code 中,`CLAUDE_CODE_MESSAGING_SOCKET` 必须恰好匹配一个已注册且存活的会话;该会话唯一且可打印的名称(否则用 PID)成为 `From: claude:NAME`。在 Codex 中,有效的 `CODEX_THREAD_ID`(或 `CODEX_SESSION_ID`)成为 `From: codex:UUID`。证据冲突、嵌套或无效时不确定发送者,此时也不生成回复路由。`--no-from` 只省略 From。
|
|
150
|
+
- **自动 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` 相同的解析器校验。
|
|
151
|
+
- **JSON。** `replyRoute` 报告生成的路由:本机路由为 `verified`(`same_machine_route`),SSH 路由为 `unverified`(`reverse_ssh_not_checked`)。`--to` 为 URI 时,`addressResolution` 记录其传输方式;若改为本机投递,还会记录 `normalizedFrom: "ssh_self"`。
|
|
152
|
+
- **同一台机器。** 只有当 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。
|
|
153
|
+
- **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 处理。
|
|
154
|
+
- **回程路由检查。** `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`,见上文的信任边界)。命令行允许列表不适用于该配置文件。
|
|
155
|
+
|
|
156
|
+
## 成功含义与安全性
|
|
157
|
+
|
|
158
|
+
| 结果 | 含义 |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| `validated`, `submitted:false` | dry-run 检查通过,尚未发送。 |
|
|
161
|
+
| `posted` / `queued` | inbox 已写入 / queue 已接受,**不是消费确认或 ACK**。 |
|
|
162
|
+
| `refused`, `submitted:false` | 提交前被拒绝。 |
|
|
163
|
+
| `unknown`, `submitted:null` | 可能已经提交,不要自动重发。 |
|
|
164
|
+
|
|
165
|
+
提交后没有回复或目标退出,都不能单独证明消息已消费或失败。不要自动重发。
|
|
166
|
+
|
|
167
|
+
`consumptionConfirmed` 始终为 false。必须在目标 TUI 中另行确认实际 ACK,不可由排队或轮询 transcript 推断。退出码 0/1/2 分别表示成功/错误/用法错误。错误只返回固定代码,不返回原生 stderr 或消息内容。Codex 使用真实内核 flock、文件身份和同用户进程开始时间进行多次核验,排队前再次检查。不删除 lock,也不向拥有它的代理进程发送信号。发现结果仍包含本地名称、路径、ID,分享前请脱敏。
|
|
168
|
+
|
|
169
|
+
## 开发与验证
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
npm ci --ignore-scripts
|
|
173
|
+
npm run build
|
|
174
|
+
node scripts/check-repository.mjs
|
|
175
|
+
SESSION_PEER_PYTHON_ROOT=/path/to/python-reference npm test
|
|
176
|
+
npm run test:package
|
|
177
|
+
npm audit
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
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 共享内存管理,不能视为快照。
|
|
181
|
+
|
|
182
|
+
参见 [CONTRIBUTING.md](../CONTRIBUTING.md)、[RELEASING.md](../RELEASING.md) 和 [SECURITY.md](../SECURITY.md)。后续版本的发布需单独批准,未启用自动 npm 发布。采用 [MIT](../LICENSE) 许可证。
|
|
183
|
+
|
|
184
|
+
## npm 版本
|
|
185
|
+
|
|
186
|
+
0.2.1 已于 2026-09-29 KST、0.2.0 已于 2026-09-28 KST 公开并验证。请参阅
|
|
187
|
+
[0.2.1 公开记录](../VALIDATION.md#public-021--2026-09-29-kst)(之后的版本各自追加带日期的记录),
|
|
188
|
+
安装前核对准确版本与当前标签。
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
npm view session-peer@0.3.0 version dist.integrity
|
|
192
|
+
npm view session-peer dist-tags
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
0.1.0 tarball 的历史措辞差异和验证保留在[日期记录](../VALIDATION.md#public-010--2026-09-27-kst)。
|
|
196
|
+
发布使用 OIDC staging 和单独的 2FA 批准。Staging 成功不等于公开发布。
|
|
197
|
+
请参阅 [RELEASING.md](../RELEASING.md)。
|
|
198
|
+
|
|
199
|
+
## 相关项目
|
|
200
|
+
|
|
201
|
+
[Python session-peer](https://github.com/abruption/session-peer) 独立维护和发布,其可选功能与安装指南(例如 `pipx install session-peer`)见该项目。同样使用 `session-peer` 命令,请注意上述 PATH 规则。本客户端不依赖该安装,也不承诺功能和参数完全对等。
|
|
202
|
+
|
|
203
|
+
### 0.2.0 只读诊断
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
session-peer doctor --json
|
|
207
|
+
session-peer doctor --agent codex --codex-home /absolute/home --json
|
|
208
|
+
session-peer doctor --host user@host --json
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
公开 npm 0.1.0 不包含此命令。诊断成功(`ok:true`、退出码 0)与代理就绪状态
|
|
212
|
+
(`ready`、各代理和 home 的结果)分开报告。只检查限定的元数据和可执行文件路径,
|
|
213
|
+
不会执行 Codex、连接 inbox、获取 writer 锁或提交消息。Windows 就绪状态只表示
|
|
214
|
+
存活进程公布了 pipe,并不证明 pipe 存在或可以连接。`capabilities` 明确将
|
|
215
|
+
wake/wait/ACK 和消费确认标为不支持。可选的 TS 技能元数据检查也不会安装任何内容。
|
|
216
|
+
参见[诊断边界](../PARITY.md#source-read-only-doctor--18--020)。SSH 两端需要相同的 TypeScript 客户端版本。
|
|
217
|
+
### 更新检查与提示(0.3.0,#22)
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
session-peer update --check --json
|
|
221
|
+
session-peer update --check --channel preview --output-format text
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
此命令在 0.3.0 中加入,0.2.1 及更早版本没有。`update --check` 只请求一次 `session-peer` 的 npm
|
|
225
|
+
dist-tag(3 秒超时,不重试),并报告 `current`、`latest`、`channel`(默认 `latest`,
|
|
226
|
+
或 `preview`)、`source: "npm_registry"`、`status`(`update_available`、`up_to_date`、
|
|
227
|
+
`ahead`)、`managedBy`、`updateCommand` 和 `guidance`。只有根据当前 CLI 路径能确切识别
|
|
228
|
+
安装的管理方时才给出命令:其自身 `session-peer` 启动器指向本包的 npm 全局 prefix
|
|
229
|
+
(默认、Homebrew、nvm、nvm-windows、fnm,例如
|
|
230
|
+
`npm install --global --ignore-scripts session-peer@0.3.1`),清单中声明了
|
|
231
|
+
`session-peer` 的 pnpm、Yarn、Bun 全局存储,Volta,或 npx 缓存。项目安装
|
|
232
|
+
(`npm_project`、`pnpm_project`)、源码检出(`source`)以及其他情况(`unknown`)只返回
|
|
233
|
+
`updateCommand: null` 和一句 `guidance`,因此不会给出可能修改无关当前目录的命令。它只报告
|
|
234
|
+
npm 版本,Python 版 `session-peer` 的发布是独立的版本序列,从不与之比较。注册表失败时
|
|
235
|
+
退出码为 1,错误为 `registry_timeout`、`registry_unreachable`、`registry_http_error`、
|
|
236
|
+
`registry_response_invalid` 或 `dist_tag_missing`,不会输出响应正文。
|
|
237
|
+
|
|
238
|
+
不带 `--check` 的 `update` 不会修改任何内容:它以 `self_update_unsupported`(退出码 2)
|
|
239
|
+
拒绝,并返回 `managedBy`、`updateCommand`、`guidance` 和 `checkCommand`。`update` 本身
|
|
240
|
+
仅限本地:拒绝 `--host`,也拒绝经由 SSH wire 的请求。远程主机、Python 安装和单独管理的
|
|
241
|
+
`session-peer-ts` 技能都不会被更新;结果会列出本地 TS 技能元数据(`skills`,与 `doctor`
|
|
242
|
+
相同的约定)以及 `skillsManagedBy: "separate"`。
|
|
243
|
+
|
|
244
|
+
`list`、`send`、`doctor` 的缓存提示**默认关闭**,因为此 CLI 主要由代理和脚本调用,
|
|
245
|
+
不应发起未经请求的网络访问。设置 `SESSION_PEER_UPDATE_NOTICE=1` 开启后,若 24 小时内的
|
|
246
|
+
缓存显示有更新的 npm 稳定版,JSON 结果会增加 `clientUpdate` 对象,文本输出则在 stderr
|
|
247
|
+
写一行。缓存缺失、无效或过期时会启动一个分离的刷新进程,不会延迟或改变命令结果与退出码;
|
|
248
|
+
刷新失败后 1 小时内不再尝试。缓存写入是单次执行的,并在失败时保持关闭:无论是后台刷新还是
|
|
249
|
+
显式检查,写入都只在持有 `npm-update.lock` 时进行,且只覆盖更旧的记录。任何调用都不会接管或
|
|
250
|
+
删除不是自己创建的锁。若刷新异常退出,或因 I/O 错误未能释放锁而留下锁,后台刷新会停止,`update --check` 会报告
|
|
251
|
+
`cache: "skipped_stale_lock"`。请在没有 session-peer 进程运行时手动删除 `npm-update.lock`。
|
|
252
|
+
|
|
253
|
+
`--no-update-notice` 和 `SESSION_PEER_NO_UPDATE_NOTICE=1` 会抑制这些后台提示和刷新。
|
|
254
|
+
显式的 `update --check` 是有意的请求,总会访问注册表;对 `latest` 通道,在锁空闲时写入缓存
|
|
255
|
+
(`cache` 为 `written`、`skipped_locked`、`skipped_stale_lock`、`skipped_newer` 或 `failed`)。提示
|
|
256
|
+
属于本地客户端:使用 `--host` 时,客户端会在自身的顶层输出(包括经由 SSH 获得的结果)中
|
|
257
|
+
加入 `clientUpdate`(或 stderr 中的一行)。重复 `--host` 产生 JSON 数组时,数组及其元素保持原样,
|
|
258
|
+
不加入 `clientUpdate`;文本输出仍在 stderr 写一行。无论主机数量多少,每次调用最多刷新一次。失败的单主机结果(例如被拒绝的 SSH 预检)也可能带有提示,
|
|
259
|
+
但解析错误和本地拒绝不会带;提示从不改变状态、退出码或重试判断。远程主机返回的 `clientUpdate`
|
|
260
|
+
会被丢弃。`--stdio-request` 模式的接收端从不读取或刷新
|
|
261
|
+
缓存,也不会产生提示。
|
|
262
|
+
|
|
263
|
+
缓存文件为 `SESSION_PEER_CACHE_DIR`(绝对路径)下的 `npm-update.json`,否则依次为
|
|
264
|
+
`$XDG_CACHE_HOME/session-peer`、`~/Library/Caches/session-peer`(macOS)、
|
|
265
|
+
`~/.cache/session-peer`(Linux)或 `%LOCALAPPDATA%\session-peer\Cache`(Windows)。
|
|
266
|
+
以 0600 权限原子写入 0700 目录,仅包含公开的版本信息。`SESSION_PEER_UPDATE_REGISTRY`
|
|
267
|
+
可指定镜像(HTTPS,或仅限 loopback 的 HTTP;不允许凭据)。不会读取 npm 配置或 `.npmrc`。
|
|
268
|
+
参见[更新边界](../PARITY.md#source-update-checks--22)。
|
|
269
|
+
|
|
270
|
+
## 显式安装代理技能
|
|
271
|
+
|
|
272
|
+
独立的 `session-peer-ts` 技能在配套 PR 中管理,不代表新 npm 或技能标签发布。它支持已发布的 0.1.0 基础功能,通过 TypeScript 标识和帮助检查开发功能。Python 的 `session-peer` 技能仍独立保留。
|
|
273
|
+
|
|
274
|
+
先检查[固定提交的技能源码](https://github.com/abruption/session-peer-skill/tree/081cc3c1d16a394bd92824333f4bc61c36951799/session-peer-ts),再选择代理和安装范围。
|
|
275
|
+
以下示例选择 **Codex、当前项目**;请在该项目目录中运行。
|
|
276
|
+
Claude Code 使用 `--agent claude-code`。用户范围安装应在 add/list/remove 中一致添加 `--global`。
|
|
277
|
+
批准替换已有的 `session-peer-ts` 副本前,请检查本地修改。
|
|
278
|
+
Codex 的 `.agents/skills` 目录与其他扫描该路径的客户端共享。
|
|
279
|
+
|
|
280
|
+
```sh
|
|
281
|
+
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
|
|
282
|
+
npx -y skills@1.7.0 list --agent codex --json
|
|
283
|
+
npx -y skills@1.7.0 remove session-peer-ts --agent codex --yes
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
更新固定版本时,请检查另一个准确的提交,然后以相同代理和范围重新运行 `add`。
|
|
287
|
+
如果代理缓存了技能目录,请重启代理。运行时和技能独立管理:npm `--ignore-scripts` 可正常使用,
|
|
288
|
+
postinstall 不会调用 Skills CLI,安装此技能不会覆盖 Python 技能或安装运行时。
|
|
289
|
+
参见[兼容性和验证](../PARITY.md#source-ts-skill-guidance--25--020)。
|
|
290
|
+
|
|
291
|
+
## 可选 sp 简写
|
|
292
|
+
|
|
293
|
+
可选的 `sp` 简写包含在 0.3.0 及更高版本中(0.2.1 及更早版本没有),不会自动启用。
|
|
294
|
+
请参阅[显式启用、冲突与停用(英文)](shorthand.md)。
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Optional `sp` shorthand
|
|
2
|
+
|
|
3
|
+
[README](../README.md) · [User guide](guide.md)
|
|
4
|
+
|
|
5
|
+
This feature ships with 0.3.0 and later ([#74](https://github.com/abruption/session-peer-ts/issues/74)).
|
|
6
|
+
The npm 0.2.1 and earlier archives do **not** contain these activation files;
|
|
7
|
+
install 0.3.0 or later, or use a reviewed checkout or its
|
|
8
|
+
[locally built tarball](guide.md#build-from-source).
|
|
9
|
+
|
|
10
|
+
`session-peer` is the canonical command. `sp` is an opt-in alias in your current
|
|
11
|
+
Bash/zsh session or PowerShell scope. It resolves the same command on PATH: there
|
|
12
|
+
is no second CLI parser, argument reconstruction, `eval`, runtime dispatcher or
|
|
13
|
+
extra delivery attempt. Version/help output continues to say `session-peer`.
|
|
14
|
+
Keep `session-peer` in scripts, automation, SSH commands and reply instructions.
|
|
15
|
+
Windows cmd.exe also uses the canonical command; this feature does not install
|
|
16
|
+
an `sp.cmd` launcher.
|
|
17
|
+
|
|
18
|
+
Only one implementation is assumed installed. Check `session-peer --version`
|
|
19
|
+
and your installation manager before enabling the alias. Python and TypeScript
|
|
20
|
+
co-installation is outside this feature's scope.
|
|
21
|
+
|
|
22
|
+
## Checking for the activation files
|
|
23
|
+
|
|
24
|
+
An installation that reports 0.3.0 or later contains these files. `--version`
|
|
25
|
+
alone is not conclusive for a source build, which reports its checkout's
|
|
26
|
+
package version. Check for the files in the installed package directory:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
# Global npm installation:
|
|
30
|
+
ls "$(npm root --global)/session-peer/shorthand/sp.sh"
|
|
31
|
+
# Isolated or project prefix (replace <prefix>):
|
|
32
|
+
ls "$(npm root --prefix <prefix>)/session-peer/shorthand/sp.sh"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```powershell
|
|
36
|
+
Test-Path (Join-Path (npm root --global) 'session-peer/shorthand/sp.ps1')
|
|
37
|
+
# Isolated or project prefix (replace <prefix>):
|
|
38
|
+
Test-Path (Join-Path (npm root --prefix <prefix>) 'session-peer/shorthand/sp.ps1')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
A missing file means that installation predates the feature (for example the
|
|
42
|
+
0.2.1 archive); its `session-peer` command still works, but `sp` cannot
|
|
43
|
+
be activated from it.
|
|
44
|
+
|
|
45
|
+
## Why activation is explicit
|
|
46
|
+
|
|
47
|
+
npm owns only the `session-peer` executable. Adding another unconditional npm
|
|
48
|
+
`bin` entry would claim the generic `sp` name during installation. Instead, npm
|
|
49
|
+
ships activation files and never creates an `sp` executable, changes PATH,
|
|
50
|
+
edits a shell profile or runs an installation hook.
|
|
51
|
+
|
|
52
|
+
The activation file runs **in the shell you source it into**, so it can detect
|
|
53
|
+
that shell's aliases and functions as well as commands on PATH. A subprocess
|
|
54
|
+
cannot see every alias/function in its parent shell. This is why activation is
|
|
55
|
+
not a separate `session-peer install-alias` process. Detection is a snapshot of
|
|
56
|
+
that scope/PATH, not a machine-wide reservation; commands added later can still
|
|
57
|
+
change resolution. A repeated activation also refuses the already defined `sp`.
|
|
58
|
+
|
|
59
|
+
## Bash and zsh
|
|
60
|
+
|
|
61
|
+
Inspect the existing names and read the activation file before sourcing it:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
type -a session-peer
|
|
65
|
+
type -a sp
|
|
66
|
+
# Reviewed source checkout:
|
|
67
|
+
. ./shorthand/sp.sh
|
|
68
|
+
sp --version
|
|
69
|
+
sp list --agent claude --json
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`type -a sp` reporting no command is expected when the name is free. The asset
|
|
73
|
+
refuses an existing alias, function or executable and also refuses a missing
|
|
74
|
+
`session-peer`. It defines only `alias sp='session-peer'`. Quoted arguments,
|
|
75
|
+
Unicode, stdin and `--` retain their ordinary shell meaning; message contents
|
|
76
|
+
are never evaluated again.
|
|
77
|
+
|
|
78
|
+
With an npm installation **that contains the new files**, the activation path is:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
# Global npm installation:
|
|
82
|
+
. "$(npm root --global)/session-peer/shorthand/sp.sh"
|
|
83
|
+
# Or a project-local installation (choose one):
|
|
84
|
+
# . ./node_modules/session-peer/shorthand/sp.sh
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use this in an interactive Bash/zsh session. Bash disables alias expansion by
|
|
88
|
+
default in noninteractive scripts; the asset does not change shell options.
|
|
89
|
+
Use canonical `session-peer` in automation. If you want persistence, review and
|
|
90
|
+
add the chosen source line yourself to `.bashrc` or `.zshrc` after PATH setup.
|
|
91
|
+
A child shell cannot activate an alias in its parent.
|
|
92
|
+
|
|
93
|
+
To disable it, inspect `alias sp`; if it still points to `session-peer`, run
|
|
94
|
+
`unalias sp`. Remove your profile source line too, if you added one. Do not
|
|
95
|
+
remove a replacement alias belonging to another tool.
|
|
96
|
+
|
|
97
|
+
## PowerShell
|
|
98
|
+
|
|
99
|
+
PowerShell normally already defines `sp` as `Set-ItemProperty`. Activation
|
|
100
|
+
intentionally refuses that collision. Inspect **all** matches first:
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
Get-Command session-peer -All
|
|
104
|
+
Get-Command sp -All
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
If you decide to give up the built-in alias in this scope, explicitly remove it
|
|
108
|
+
only after verifying its definition. Windows PowerShell marks this built-in alias
|
|
109
|
+
read-only, so this explicit removal uses `-Force`. Activation never does. This
|
|
110
|
+
is a separate user choice:
|
|
111
|
+
|
|
112
|
+
```powershell
|
|
113
|
+
if ((Get-Alias sp -ErrorAction SilentlyContinue).Definition -eq 'Set-ItemProperty') {
|
|
114
|
+
Remove-Item Alias:sp -Force
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Other `sp` commands/functions/aliases must also be resolved by you.
|
|
119
|
+
|
|
120
|
+
The PowerShell activator detects collisions with `Get-Command sp -ListImported`,
|
|
121
|
+
which covers aliases, functions, cmdlets and PATH applications already visible in
|
|
122
|
+
the session. It does **not** consider an `sp` command exported by a module that
|
|
123
|
+
is installed but not yet imported (module auto-loading). Activation deliberately
|
|
124
|
+
does not import modules to find out, because importing runs module code. If you
|
|
125
|
+
rely on such a module, check `Get-Command sp -All` (which can auto-load it) and
|
|
126
|
+
choose accordingly; once that module is imported, the activator refuses its `sp`.
|
|
127
|
+
|
|
128
|
+
Then read
|
|
129
|
+
and dot-source the activation file (do not invoke it with `&`):
|
|
130
|
+
|
|
131
|
+
```powershell
|
|
132
|
+
# Reviewed source checkout:
|
|
133
|
+
. ./shorthand/sp.ps1
|
|
134
|
+
sp --version
|
|
135
|
+
sp list --agent claude --json
|
|
136
|
+
# For a global npm installation containing the new files, use this path instead:
|
|
137
|
+
# . (Join-Path (npm root --global) 'session-peer/shorthand/sp.ps1')
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The alias belongs to the caller's scope. Dot-sourcing inside a function does not
|
|
141
|
+
activate it globally. Shell execution policy still applies; activation does not
|
|
142
|
+
change it. PowerShell's normal native argument and text-pipeline encoding rules
|
|
143
|
+
remain the same for both names. The alias does not add a wrapper around npm's
|
|
144
|
+
existing launcher.
|
|
145
|
+
|
|
146
|
+
To disable only this alias:
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
if ((Get-Alias sp -ErrorAction SilentlyContinue).Definition -eq 'session-peer') {
|
|
150
|
+
Remove-Item Alias:sp
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Remove any activation line you chose to add to `$PROFILE`. A new unmodified
|
|
155
|
+
PowerShell session restores its normal built-in aliases.
|
|
156
|
+
|
|
157
|
+
## Updating, uninstalling and replacing an implementation
|
|
158
|
+
|
|
159
|
+
Use npm to update an npm-owned runtime as described in the [README](../README.md#update).
|
|
160
|
+
An active `sp` alias follows the canonical name on PATH after an in-place npm
|
|
161
|
+
update; it does not pin a package version or cache the previous CLI entry point.
|
|
162
|
+
After changing prefixes/PATH, check both `session-peer --version` and `sp --version`.
|
|
163
|
+
|
|
164
|
+
Disable the alias and remove a persistent profile line before running
|
|
165
|
+
`npm uninstall --global session-peer` (use your original prefix for a local
|
|
166
|
+
installation). npm removes the package and activation files but cannot remove
|
|
167
|
+
an alias already loaded into another shell. Such an alias becomes unresolved
|
|
168
|
+
when the canonical executable disappears; it does not install a fallback.
|
|
169
|
+
|
|
170
|
+
When changing between Python and TypeScript, first remove the old implementation
|
|
171
|
+
with its own manager, then select the new installation. Do not use npm `--force`
|
|
172
|
+
to replace another manager's files. Never silently replace another tool's `sp`.
|
|
173
|
+
|
|
174
|
+
## Validation boundaries
|
|
175
|
+
|
|
176
|
+
Package tests compare both names against an isolated installed CLI for
|
|
177
|
+
version/help/list/dry-run and argument errors, including exit codes and stdout
|
|
178
|
+
and stderr. Shell fixtures check whitespace, Unicode, literal metacharacters,
|
|
179
|
+
stdin, `--`, executable/alias/function collisions, missing canonical commands
|
|
180
|
+
and deactivation; each fixture shell first proves that its runner reports a
|
|
181
|
+
script's own exit code (3), not a 0/1 summary.
|
|
182
|
+
|
|
183
|
+
The lifecycle fixture runs in every fixture shell: Bash on macOS/Linux, zsh where
|
|
184
|
+
present (including macOS), and Windows PowerShell 5.1 on Windows Node 22/24. In an
|
|
185
|
+
isolated `--prefix` it installs the packed version, activates `sp`, replaces it
|
|
186
|
+
in place with a second, fixture-only version packed from a copy whose
|
|
187
|
+
`package.json` version and compiled `VERSION` constant were changed (it sorts
|
|
188
|
+
below the original, so this is a version replacement, not a registry upgrade),
|
|
189
|
+
and checks that `sp --version` and `session-peer --version` both report the
|
|
190
|
+
replacement. It then uninstalls the package and checks that both names fail as
|
|
191
|
+
command not found (Bash/zsh exit 127, PowerShell `CommandNotFoundException`) and
|
|
192
|
+
that deactivation removes `sp`. Installation and replacement use the same
|
|
193
|
+
prefix, so moving the canonical command to another PATH location is not covered.
|
|
194
|
+
It never installs globally or edits a profile.
|
|
195
|
+
|
|
196
|
+
These are isolated fixtures, not live message or ACK evidence. Submission,
|
|
197
|
+
ownership, permissions and no-retry-on-unknown contracts remain those of the
|
|
198
|
+
canonical CLI.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "session-peer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
+
"docs",
|
|
28
|
+
"shorthand",
|
|
27
29
|
"README.md",
|
|
28
30
|
"README.ko.md",
|
|
29
31
|
"README.ja.md",
|
|
@@ -37,9 +39,9 @@
|
|
|
37
39
|
],
|
|
38
40
|
"scripts": {
|
|
39
41
|
"build": "tsc -p tsconfig.json",
|
|
40
|
-
"test": "npm run build && npm run test:types && node --experimental-strip-types --test test/*.test.ts",
|
|
42
|
+
"test": "npm run build && npm run test:types && node --import ./test/fixtures/isolate-env.mjs --experimental-strip-types --test test/*.test.ts",
|
|
41
43
|
"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",
|
|
44
|
+
"test:windows": "npm run build && npm run test:types && node --import ./test/fixtures/isolate-env.mjs --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 test/ssh-hosts.test.ts test/replies.test.ts test/updates.test.ts",
|
|
43
45
|
"test:package": "npm run build && node --experimental-strip-types test/package-smoke.ts"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
package/shorthand/sp.ps1
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Dot-source this file to opt in in the caller's current PowerShell scope.
|
|
2
|
+
if ($MyInvocation.InvocationName -ne '.') {
|
|
3
|
+
throw 'Dot-source this file to activate sp in the current scope.'
|
|
4
|
+
}
|
|
5
|
+
if (Get-Command sp -ListImported -ErrorAction SilentlyContinue) {
|
|
6
|
+
throw 'sp already exists; inspect Get-Command sp -All before choosing a name.'
|
|
7
|
+
}
|
|
8
|
+
if (-not (Get-Command session-peer -ErrorAction SilentlyContinue)) {
|
|
9
|
+
throw 'session-peer is not available; select its installation on PATH first.'
|
|
10
|
+
}
|
|
11
|
+
Set-Alias -Name sp -Value session-peer -Scope Local -ErrorAction Stop
|
package/shorthand/sp.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Source this file in an interactive Bash or zsh session to opt in.
|
|
2
|
+
# No profile edits, PATH changes, argument reconstruction or external launcher.
|
|
3
|
+
if command -v sp >/dev/null 2>&1; then
|
|
4
|
+
printf '%s\n' 'sp already exists; inspect it with type -a sp before choosing a name.' >&2
|
|
5
|
+
return 1
|
|
6
|
+
fi
|
|
7
|
+
if ! command -v session-peer >/dev/null 2>&1; then
|
|
8
|
+
printf '%s\n' 'session-peer is not available; select its installation on PATH first.' >&2
|
|
9
|
+
return 1
|
|
10
|
+
fi
|
|
11
|
+
alias sp='session-peer'
|