pi-courier 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,61 +2,61 @@
2
2
 
3
3
  [English](README.md) | [简体中文](README.zh-CN.md)
4
4
 
5
- Run the [pi coding agent](https://pi.dev) headlessly from **Matrix**. Slash commands, skills and prompt templates fully work from your chat client.
5
+ Run the [pi coding agent](https://pi.dev) from **Matrix**. Send a message in a chat, pi answers — and every slash command, skill and prompt template works, exactly like in the terminal.
6
6
 
7
- Unlike the classic extension mode, this project drives pi over the [RPC protocol](https://pi.dev/docs/latest/rpc), so **slash commands work from messengers** (`/new`, `/compact`, `/model`, `/skill:name`, prompt templates, extension commands) — the extension mode can't do this because pi's `sendUserMessage()` deliberately skips command handling.
7
+ Unlike pi's classic extension mode, pi-courier drives pi over the [RPC protocol](https://pi.dev/docs/latest/rpc), which is why commands work from chat: the extension mode can't do this because pi's `sendUserMessage()` deliberately skips command handling.
8
8
 
9
- > **Upstream**: this project is a rework of [tintinweb/pi-messenger-bridge](https://github.com/tintinweb/pi-messenger-bridge) — the Matrix transport layer and challenge auth come from there; the RPC-based standalone architecture, slash-command mapping, CLI and setup wizard are new.
9
+ ## 1. What is it
10
10
 
11
- ## Features
12
-
13
- - 📱 Matrix transport (E2EE-capable), challenge-based auth (6-digit codes)
14
- - 🎛️ Full slash-command support: `/new`, `/compact`, `/model`, `/thinking`, `/bash`, `/reload`, ...
15
- - 🧩 Skills & prompt templates pass through: `/skill:name`, `/template`
16
- - 💾 Session persistence: pi sessions live on disk, resume across restarts
17
- - 🔄 `/reload` restarts the pi process (after installing extensions/config) — lossless
18
- - 🔌 pi is **not bundled**: installed independently on the system, upgraded on its own
19
- - 🧭 One-command CLI: `pi-courier setup` wizard, `pi-courier enable` auto-start, `pi-courier update` self-update
20
-
21
- ## Architecture
11
+ pi-courier is a small standalone service that bridges Matrix to a locally installed pi:
22
12
 
23
13
  ```
24
- Messenger ──> pi-courier (dist/standalone.js) ──> pi --mode rpc (system-installed)
25
- Messenger <── replies <────────────────────── <── agent events (stdout JSONL)
14
+ Matrix bot ←→ pi-courier ←→ pi --mode rpc (system-installed)
26
15
  ```
27
16
 
28
- - pi-courier spawns and manages the `pi --mode rpc` child process
29
- - Sessions persist to `~/.pi/agent/sessions`, resumed automatically after restarts
30
- - systemd only needs to manage the pi-courier service
17
+ - **You talk to a Matrix bot account**; messages are forwarded to pi over the RPC protocol
18
+ - **Full command support**: `/new`, `/compact`, `/model`, `/thinking`, `/skill:name`, prompt templates, extension commands
19
+ - **pi is not bundled** installed independently on the system, upgraded on its own
20
+ - **Sessions persist** to `~/.pi/agent/sessions` and resume automatically after restarts
21
+ - **One-command CLI**: setup wizard, systemd auto-start, self-update
22
+
23
+ ## 2. Install
31
24
 
32
- ## Requirements
25
+ ### Prerequisites
33
26
 
34
- | Component | Requirement | Check |
35
- |---|---|---|
36
- | Node.js | >= 20 (tested on 24.x) | `node --version` |
37
- | pi | >= 0.83, **installed globally** (not bundled) | `pi --version` |
38
- | Network | access to your homeserver and LLM provider | — |
27
+ | Component | Requirement |
28
+ |---|---|
29
+ | Node.js | >= 20 (tested on 24.x) |
30
+ | pi | >= 0.83, installed **globally** |
39
31
 
40
- Install pi first — pi-courier is a companion app that connects to it over RPC:
32
+ Install pi first — pi-courier connects to it:
41
33
 
42
34
  ```bash
43
35
  npm install -g @earendil-works/pi-coding-agent
44
36
  pi --version
45
37
  ```
46
38
 
47
- > Using nvm? Run `source ~/.nvm/nvm.sh` (or your nvm init) in each new terminal and make sure `pi` is on PATH.
39
+ Using nvm? Run `source ~/.nvm/nvm.sh` in each new terminal so `pi` and `node` are on PATH.
48
40
 
49
- ## Installation
41
+ ### Option A: Regular users — one command
42
+
43
+ ```bash
44
+ npm install -g pi-courier
45
+ ```
46
+
47
+ That's it. Verify: `pi-courier help`.
48
+
49
+ ### Option B: Developers — from source
50
50
 
51
51
  ```bash
52
52
  git clone https://github.com/Hi-Barry/pi-courier.git
53
53
  cd pi-courier
54
54
  npm install
55
- npm link # make the `pi-courier` command available globally
56
55
  npm run build
56
+ npm link # make the `pi-courier` command available globally
57
57
  ```
58
58
 
59
- **Do not use `--ignore-scripts`**: the Matrix E2EE library (`@matrix-org/matrix-sdk-crypto-nodejs`) downloads its native binary via postinstall. If your npm blocks it (allow-scripts) and you hit `Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'`, run:
59
+ **Do not use `--ignore-scripts`**: the Matrix E2EE library downloads its native binary via postinstall. If your npm blocks it and you hit `Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'`, run:
60
60
 
61
61
  ```bash
62
62
  cd node_modules/@matrix-org/matrix-sdk-crypto-nodejs
@@ -64,132 +64,81 @@ node download-lib.js
64
64
  cd ../..
65
65
  ```
66
66
 
67
- A successful build produces `dist/standalone.js`.
67
+ Slow download (20-60 kB/s)? The binary comes from GitHub Releases and ignores npm's proxy — set `export https_proxy=... http_proxy=...` first.
68
+
69
+ ## 3. Get started
68
70
 
69
- ## Configuration
71
+ ### Step 0 — Make sure pi can chat (one-time)
70
72
 
71
- ### pi's LLM provider (`~/.pi/agent/`)
73
+ pi needs an LLM provider configured in `~/.pi/agent/` (`models.json`, `auth.json`, `settings.json`). Easiest check: run `pi`, send any message, confirm it answers. If it can't, configure it first — pi's own docs cover this; the field names are `defaultProvider`/`defaultModel` in `settings.json`.
72
74
 
73
- **a) models.json**model metadata. Best pulled from models.dev so fields are complete and correct (opencode-go example):
75
+ ### Step 1 Run the setup wizard
74
76
 
75
77
  ```bash
76
- curl -s https://models.dev/api.json -o /tmp/modelsdev.json
77
- python3 -c "
78
- import json, os
79
- md = json.load(open('/tmp/modelsdev.json')) # top level is the provider dict
80
- out = {'providers': {'opencode-go': md['opencode-go']}}
81
- json.dump(out, open(os.path.expanduser('~/.pi/agent/models.json'), 'w'), indent=2)
82
- "
78
+ pi-courier setup
83
79
  ```
84
80
 
85
- **b) auth.json** API key (chmod 600):
81
+ It walks you through, prompting for each value (defaults in brackets; press Enter to accept):
86
82
 
87
- ```json
88
- {
89
- "opencode-go": { "type": "api_key", "key": "sk-your-key" }
90
- }
91
83
  ```
84
+ === pi-courier 首次配置向导 ===
85
+ 将生成 ~/.pi/msg-bridge.json(权限 600)
92
86
 
93
- **c) settings.json** default provider & model:
87
+ Matrix homeserver URL (如 https://matrix.example.com): ← 输入,如 https://matrix.example.com
88
+ 获取 token 方式 [1=用户名密码登录, 2=粘贴已有 token] (1): ← 1 或 2(Enter 默认 1)
89
+ [方式 1] bot 用户名 (如 test2): ← bot 账号名,如 test3
90
+ bot 密码: ← 密码(不回显)
91
+ [方式 2] 粘贴 access token (syt_...): ← 已有 token
92
+ ✅ 登录成功,账号: @test3:matrix.example.com
93
+ 信任用户(管理员)MXID [默认 @test3:matrix.example.com]: ← 直接回车 = 只有 bot 自己可信;建议填你的账号,如 @barry:matrix.example.com
94
+ 启用 E2EE 加密? [y/N]: ← y/n(非加密房间也选 y 无妨)
95
+ pi 工作目录 [默认 /home/you/Projects]: ← Enter 或输入其他目录
94
96
 
95
- ```json
96
- {
97
- "defaultProvider": "opencode-go",
98
- "defaultModel": "deepseek-v4-flash"
99
- }
97
+ ✅ 配置已写入 ~/.pi/msg-bridge.json
98
+ 账号: @test3:...
99
+ 信任用户: @barry:...
100
+ E2EE: 开启
101
+ 工作目录: /home/you/Projects
100
102
  ```
101
103
 
102
- > Field names are `defaultProvider`/`defaultModel` (not `provider`/`model`).
104
+ The wizard verifies the token and writes `~/.pi/msg-bridge.json`. To skip the wizard, create that file manually — the format is in the [FAQ](#4-faq).
103
105
 
104
- Verify (run inside the pi-courier project dir):
106
+ ### Step 2 Start it
105
107
 
106
108
  ```bash
107
- node --input-type=module -e "
108
- import { RpcClient } from '@earendil-works/pi-coding-agent';
109
- import { fileURLToPath } from 'node:url';
110
- import path from 'node:path';
111
- const entry = fileURLToPath(import.meta.resolve('@earendil-works/pi-coding-agent'));
112
- const c = new RpcClient({ cliPath: path.join(path.dirname(entry), 'cli.js') });
113
- await c.start();
114
- console.log('models:', (await c.getAvailableModels()).length);
115
- console.log('current:', (await c.getState()).model?.id);
116
- await c.stop();
117
- "
109
+ pi-courier enable # install a systemd service: auto-start on boot + start now
118
110
  ```
119
111
 
120
- ### Messenger (Matrix example)
112
+ Or run in the foreground for a quick test: `pi-courier run` (Ctrl+C to stop).
121
113
 
122
- **Option A (recommended): setup wizard**
114
+ Startup success looks like:
123
115
 
124
- ```bash
125
- pi-courier setup
126
116
  ```
127
-
128
- Follow the prompts: platform → homeserver URL → token (password login or paste an existing one) → trusted admin user MXID → E2EE toggle → pi workdir. The wizard verifies the token and writes `~/.pi/msg-bridge.json`.
129
-
130
- **Option B: manual `~/.pi/msg-bridge.json`** (chmod 600):
131
-
132
- ```json
133
- {
134
- "matrix": {
135
- "homeserverUrl": "https://your-homeserver",
136
- "accessToken": "syt_...",
137
- "encryption": true
138
- },
139
- "auth": {
140
- "trustedUsers": ["matrix:@you:your-homeserver"],
141
- "adminUserId": "matrix:@you:your-homeserver"
142
- },
143
- "workdir": "/path/to/pi/workdir",
144
- "autoConnect": true,
145
- "debug": true
146
- }
117
+ ✅ Matrix connected as @test3:... (2 rooms, E2EE enabled)
118
+ pi RPC connected (model: deepseek-v4-flash, session: 019f...)
119
+ 🚀 msg-bridge standalone ready. Waiting for messages...
147
120
  ```
148
121
 
149
- - Get an access token: `POST /_matrix/client/v3/login` (password login) or from Element's settings page
150
- - `trustedUsers`/`adminUserId` format: `<transport>:<full userId>`, e.g. `matrix:@barry:matrix.example.com`
151
- - `workdir`: pi's working directory (spawned automatically if missing); `pi-courier run --workdir <dir>` overrides it
152
- - `sessionDir` / `cliPath`: optional overrides (defaults: pi's session dir, and `which pi` for the CLI)
153
- - `encryption: true` for encrypted rooms (works for plain rooms too)
154
- - Env var alternatives: `PI_MATRIX_HOMESERVER` / `PI_MATRIX_ACCESS_TOKEN`
122
+ ### Step 3 Use it from Matrix
155
123
 
156
- ## Usage
124
+ **First contact (one-time pairing):**
157
125
 
158
- Everything goes through a single command:
126
+ 1. **DM the bot** from your account and send any message
127
+ 2. The bot is not yet a trusted user, so the bridge prints a challenge code in its log (`pi-courier logs` or `journalctl --user -u pi-msg-bridge -f`):
159
128
 
160
129
  ```
161
- pi-courier setup first-run configuration wizard (Matrix account, trusted user, workdir)
162
- pi-courier run run in the foreground (workdir from config; --workdir overrides)
163
- pi-courier enable install a user-level systemd service (auto-start) and start it
164
- pi-courier start start the service
165
- pi-courier stop stop the service
166
- pi-courier restart restart the service
167
- pi-courier status show service status + recent logs
168
- pi-courier logs tail the service logs
169
- pi-courier disable uninstall the service (stop + remove autostart + delete unit file)
170
- pi-courier update update this project (git pull + npm install + build)
171
- ```
172
-
173
- Typical first deployment:
174
-
175
- ```bash
176
- pi-courier setup # answer the prompts (or edit ~/.pi/msg-bridge.json manually)
177
- pi-courier enable # auto-start on boot, running as your user
130
+ 🔐 Challenge code for @barry: 138949
178
131
  ```
179
132
 
180
- For a quick foreground test: `pi-courier run` (Ctrl+C to stop). The old `node dist/standalone.js --workdir ...` form still works if you prefer it.
181
-
182
- Startup success looks like:
133
+ 3. **Reply with that code** in the chat (just the digits) the log confirms the pairing:
183
134
 
184
135
  ```
185
- ✅ Matrix connected as @bot:your-homeserver (2 rooms, E2EE enabled)
186
- ✅ pi RPC connected (model: deepseek-v4-flash, session: 019f...)
187
- 🚀 msg-bridge standalone ready. Waiting for messages...
136
+ [auth:info] barry authenticated
188
137
  ```
189
138
 
190
- ### Commands (send in the bot's DM)
139
+ You are now a trusted user (the first trusted user also becomes admin). Any user not in `auth.trustedUsers` goes through this flow once; pre-listed users skip it entirely.
191
140
 
192
- **Pi commands (mapped to RPC):**
141
+ **Then** chat normally, or send commands:
193
142
 
194
143
  | Command | Action |
195
144
  |---|---|
@@ -202,162 +151,96 @@ Startup success looks like:
202
151
  | `/status` | Current model & state |
203
152
  | `/name <name>` | Name the session |
204
153
  | `/export [path]` | Export session HTML |
205
- | `/bash <cmd>` | Run a shell command (goes into context) |
154
+ | `/bash <cmd>` | Run a shell command |
206
155
  | `/abort` | Abort current operation |
207
- | `/reload` | Restart pi process (after installing extensions/config) |
156
+ | `/reload` | Restart pi (after installing extensions/config) |
208
157
  | `/help` | Full help |
209
158
 
210
- **Bridge admin commands:** `/trusted`, `/revoke <userId>`, `/channels`, `/enable <chatId> <mode>`, `/disable <chatId>`, `/toggletools`
211
-
212
- **Pass-through:** any other `/`-prefixed command goes to pi directly — extension commands, `/skill:name` and prompt templates are expanded by pi. Plain text is a normal conversation turn.
159
+ **Bridge admin commands**: `/trusted`, `/revoke <userId>`, `/channels`, `/enable <chatId> <mode>`, `/disable <chatId>`, `/toggletools`
213
160
 
214
- ### First run: authentication
161
+ **Anything else** starting with `/` passes through to pi directly — extension commands, `/skill:name`, prompt templates. Plain text is a normal conversation turn.
215
162
 
216
- 1. DM the bot account from your account
217
- 2. The bridge terminal (or `journalctl --user -u pi-msg-bridge -f`) prints a 6-digit code
218
- 3. Reply with the code → you become a trusted user (the first trusted user becomes admin)
163
+ **Group chats**: enable the room first with `/enable <roomId> all` (in a DM to the bot).
219
164
 
220
- Users pre-listed in `msg-bridge.json` → `auth.trustedUsers` skip this step.
221
-
222
- ## systemd deployment
223
-
224
- **User-level (recommended, no sudo):**
165
+ ### Managing the service
225
166
 
226
167
  ```bash
227
- pi-courier enable
168
+ pi-courier status # status + recent logs
169
+ pi-courier logs # tail logs
170
+ pi-courier restart # restart
171
+ pi-courier stop # stop
172
+ pi-courier start # start
173
+ pi-courier disable # uninstall the service
174
+ pi-courier update # update pi-courier itself
228
175
  ```
229
176
 
230
- That's it it writes a systemd unit to `~/.config/systemd/user/pi-msg-bridge.service` (using the absolute node path and your configured workdir), enables auto-start and starts the service. For fully headless operation (keep running after logout), run once: `sudo loginctl enable-linger $USER`.
231
-
232
- Commands: `pi-courier status`, `pi-courier logs`, `pi-courier stop`, `pi-courier start` (or `systemctl --user restart pi-msg-bridge`).
233
-
234
- **System-level (needs sudo):** copy `deploy/pi-msg-bridge.service` to `/etc/systemd/system/`, adjust the three marked values (`User`, `WorkingDirectory`, `NVM_DIR`), then `sudo systemctl enable --now pi-msg-bridge`.
235
-
236
- ## Upgrading pi
237
-
238
- pi is managed independently on the system — upgrade it, no bridge code changes:
177
+ Upgrading **pi** is independent pi-courier always uses the system pi via `which pi`:
239
178
 
240
179
  ```bash
241
180
  npm install -g @earendil-works/pi-coding-agent@latest
242
- pi --version
243
- pi-courier restart # or: systemctl --user restart pi-msg-bridge
181
+ pi-courier restart
244
182
  ```
245
183
 
246
- pi-courier always connects to the system pi via `which pi`. Only a breaking change to pi's RPC protocol would require bridge code changes (the protocol is a documented stable interface and has never broken).
247
-
248
- ## FAQ
249
-
250
- ### Installation & deployment
251
-
252
- **Q: `git clone` fails with 404?**
253
- A: Wrong repo URL. Use `https://github.com/Hi-Barry/pi-courier.git` (install from npm instead: `npm install -g pi-courier`).
184
+ ## 4. FAQ
254
185
 
255
- **Q: `npm install` hangs / crawls at ~20-60 kB/s?**
256
- A: Two downloads are involved:
257
- - npm registry packages → set npm proxy: `npm config set proxy http://...` and `npm config set https-proxy http://...`
258
- - the 21 MB E2EE native lib (downloaded from GitHub Releases by matrix-sdk-crypto-nodejs) → does **not** use npm's proxy; export `https_proxy`/`http_proxy` env vars before installing (e.g. `export https_proxy=http://10.88.88.8:10809`). Add them to `~/.bashrc` to make it permanent.
186
+ **Q: `npm install` hangs / crawls at 20-60 kB/s?**
187
+ A: The 21 MB E2EE native library downloads from GitHub Releases and ignores npm's proxy. Set `export https_proxy=... http_proxy=...` (add to `~/.bashrc`) and reinstall.
259
188
 
260
189
  **Q: `Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'`?**
261
- A: The native binary wasn't downloaded (postinstall blocked or interrupted). Run manually (with proxy env vars set if needed):
262
- ```bash
263
- cd node_modules/@matrix-org/matrix-sdk-crypto-nodejs
264
- node download-lib.js
265
- cd ../..
266
- ```
190
+ A: The native binary didn't download (postinstall blocked). Run manually: `cd node_modules/@matrix-org/matrix-sdk-crypto-nodejs && node download-lib.js`.
267
191
 
268
192
  **Q: `npm install -g pi-courier` fails with EEXIST?**
269
- A: A previous `npm link` left a conflicting `pi-courier` bin. Remove it first:
270
- ```bash
271
- npm unlink -g pi-courier
272
- rm -f ~/.nvm/versions/node/v24.18.1/bin/pi-courier
273
- npm install -g pi-courier
274
- ```
275
-
276
- **Q: `pi-courier` command not found after `npm link`?**
277
- A: The link was created before `npm run build`, so `dist/cli.js` didn't exist yet. Re-run `npm link` after building (or just install via npm instead).
278
-
279
- **Q: The systemd service keeps restarting in a loop?**
280
- A: The pi child process crashed — almost always a Node version mismatch. The bridge spawns pi via PATH, and systemd's default PATH may find a system node (e.g. v20) that pi's undici is incompatible with (`webidl.util.markAsUncloneable is not a function`). Fix: load nvm (`source ~/.nvm/nvm.sh`) and re-run `pi-courier enable` (v0.1.2+ writes `Environment=PATH=<nvm bin first>` into the unit automatically). Stick to one Node version (nvm v24) everywhere.
193
+ A: A previous `npm link` left a conflicting bin. `npm unlink -g pi-courier && rm -f $(npm prefix -g)/bin/pi-courier && npm install -g pi-courier`.
281
194
 
282
- ### Configuration
195
+ **Q: The systemd service restarts in a loop?**
196
+ A: Almost always a Node version mismatch — the pi child crashes on system node v20 (`webidl.util.markAsUncloneable is not a function`). Load nvm and re-run `pi-courier enable` (v0.1.2+ writes the correct PATH into the unit). Stick to one Node version everywhere.
283
197
 
284
- **Q: Startup logs `model: unknown`?**
285
- A: pi's provider isn't configured. Check the three files in `~/.pi/agent/`: `models.json` (model metadata), `auth.json` (API key, chmod 600), `settings.json` (`defaultProvider` / `defaultModel` — note the exact field names).
286
-
287
- **Q: `getAvailableModels` returns nothing?**
288
- A: `models.json` is malformed. Regenerate it with the models.dev extraction command in the Configuration section.
289
-
290
- **Q: `no transports configured` at startup?**
291
- A: The bridge config is empty. Check `~/.pi/msg-bridge.json` (run `pi-courier setup`) or the `PI_*` env vars.
292
-
293
- **Q: Weird `DeprecationWarning: util._extend` appears during setup?**
294
- A: Known noise from a transport dependency, filtered since v0.1.0 — update pi-courier if you still see it.
295
-
296
- ### Messaging & encryption
198
+ **Q: Startup shows `model: unknown`?**
199
+ A: pi's provider isn't configured. Check `~/.pi/agent/`: `models.json` + `auth.json` + `settings.json` (`defaultProvider` / `defaultModel` — exact field names).
297
200
 
298
201
  **Q: Lots of `Decryption error` lines in the log?**
299
- A: Historical events that can't be decrypted (new device without old keys). Normal — new messages decrypt fine.
202
+ A: Historical events that can't be decrypted (new device without old keys). Normal — new messages work fine.
300
203
 
301
204
  **Q: Encrypted room: no reply / can't decrypt new messages?**
302
- A: The bot's new device never received the room keys from your client. Options:
303
- - In Element (web: Settings → Security & Privacy → Encryption), make sure "Only share keys with verified devices" is unchecked, then send a message in the room
304
- - The bot account has no cross-signing, so user verification shows "unavailable" — device-level trust is the relevant one, but the simplest reliable fix is: **use a non-encrypted room** (create a room without encryption enabled and invite the bot). The bridge handles plain rooms fine even with `encryption: true`.
205
+ A: The bot's new device never received the room keys. The bot account has no cross-signing, so the most reliable fix is to **use a non-encrypted room** (create a room without encryption and invite the bot) — the bridge handles plain rooms fine even with `encryption: true`.
305
206
 
306
- **Q: `M_BAD_JSON: Provided device_id in device_keys does not match...` at startup?**
307
- A: The crypto store holds an old device identity but your access token belongs to a newer device (token was re-logged). Delete the store and restart:
308
- ```bash
309
- rm -rf ~/.pi/msg-bridge-matrix-crypto
310
- pi-courier restart
311
- ```
312
- Remember this whenever you re-run setup / change the token.
313
-
314
- **Q: Matrix connection fails (wrong homeserver/token)?**
315
- A: Verify the token: `curl -H "Authorization: Bearer <token>" https://homeserver/_matrix/client/v3/account/whoami`.
207
+ **Q: `M_BAD_JSON: Provided device_id in device_keys does not match...`?**
208
+ A: The crypto store holds an old device identity but the token belongs to a newer device (re-logged). Delete and restart: `rm -rf ~/.pi/msg-bridge-matrix-crypto && pi-courier restart`. Do this whenever you re-run setup / change the token.
316
209
 
317
- **Q: First message to the bot asks for a 6-digit code?**
318
- A: That's the challenge auth — reply with the code to become a trusted user (the first trusted user becomes admin). Users pre-listed in `auth.trustedUsers` skip this.
210
+ **Q: First message asks for a 6-digit code?**
211
+ A: That's the challenge auth — reply with the code to become a trusted user.
319
212
 
320
213
  **Q: No reply to messages at all?**
321
- A: Check in order: (1) `pi-courier status` / logs is Matrix connected? any Decryption errors (encrypted room)? (2) is pi RPC connected? (3) the model call itself — run `curl` against the provider endpoint with your key to isolate it.
322
-
323
- ### Running & maintenance
214
+ A: Check in order: (1) `pi-courier status` — Matrix connected? Decryption errors (encrypted room)? (2) pi RPC connected? (3) the model call itself — curl the provider endpoint with your key.
324
215
 
325
216
  **Q: `pi RPC did not become ready`?**
326
- A: The pi child failed to start. Run it manually to see the real error:
327
- ```bash
328
- node node_modules/@earendil-works/pi-coding-agent/dist/cli.js --mode rpc
329
- ```
330
- Common causes: Node version mismatch (see service restart loop above), invalid provider config, no network access to the provider.
217
+ A: pi failed to start. Run `node node_modules/@earendil-works/pi-coding-agent/dist/cli.js --mode rpc` manually to see the real error. Common causes: Node version mismatch, invalid provider config, no network to the provider.
331
218
 
332
219
  **Q: After a restart the conversation context is gone?**
333
- A: Since v0.1.1 the bridge passes `--continue` to pi, resuming the most recent session per workdir (same as `pi -c`). Update pi-courier and restart; `/new` starts a fresh session and the next restart resumes that one.
220
+ A: Since v0.1.1 the bridge passes `--continue` to pi, resuming the most recent session per workdir. Update pi-courier and restart; `/new` starts a fresh session and the next restart resumes that one.
334
221
 
335
222
  **Q: Element (web client) intercepts `/`-prefixed messages?**
336
223
  A: Prefix with `//` to send a literal slash (`//compact` sends `/compact`).
337
224
 
338
- **Q: Proxy environment tips?**
339
- A: npm registry → `npm config set proxy/https-proxy`; GitHub downloads & bridge runtime → `export https_proxy`/`http_proxy` (systemd: add to `EnvironmentFile`).
225
+ **Q: What exactly is in `~/.pi/msg-bridge.json`?**
226
+ A: The wizard-generated config. Example:
340
227
 
341
- ## Tips
342
-
343
- - **Element clients** treat `/`-prefixed messages as client commands — prefix with `//` to send a literal slash (`//compact` sends `/compact`)
344
- - **Proxy environments**: set `HTTP_PROXY`/`HTTPS_PROXY` (systemd: via `EnvironmentFile`)
345
- - **Group chats**: enable with `/enable <roomId> all` first; DMs need no setup
346
-
347
- ## Development
348
-
349
- ```bash
350
- npm run build # compile
351
- npm run typecheck # type-check
352
- npm run test # unit tests (vitest)
353
- npm run lint # biome lint
228
+ ```json
229
+ {
230
+ "matrix": { "homeserverUrl": "https://matrix.example.com", "accessToken": "syt_...", "encryption": true },
231
+ "auth": { "trustedUsers": ["matrix:@you:matrix.example.com"], "adminUserId": "matrix:@you:matrix.example.com" },
232
+ "workdir": "/home/you/Projects",
233
+ "autoConnect": true,
234
+ "debug": true
235
+ }
354
236
  ```
355
237
 
356
- The full development history research, design decisions, every pitfall hit in
357
- real deployments — is documented in [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md).
238
+ Env var alternatives: `PI_MATRIX_HOMESERVER` / `PI_MATRIX_ACCESS_TOKEN`.
239
+
240
+ ## 5. License & Acknowledgements
358
241
 
359
- ## License
242
+ MIT License — see [LICENSE](LICENSE).
360
243
 
361
- MIT
244
+ **Upstream**: this project is a rework of [tintinweb/pi-messenger-bridge](https://github.com/tintinweb/pi-messenger-bridge) (MIT). The Matrix transport layer and challenge auth come from upstream; the RPC-based standalone architecture, slash-command mapping, CLI, setup wizard and docs are new.
362
245
 
363
- Upstream: [tintinweb/pi-messenger-bridge](https://github.com/tintinweb/pi-messenger-bridge) (MIT)
246
+ pi-courier is an independent companion app for [pi](https://pi.dev) — it is not affiliated with Earendil Inc.
package/README.zh-CN.md CHANGED
@@ -2,61 +2,61 @@
2
2
 
3
3
  [English](README.md) | [简体中文](README.zh-CN.md)
4
4
 
5
- 通过 **Matrix** 远程操控 [pi coding agent](https://pi.dev),slash 命令、技能、提示词模板在聊天客户端里完整可用。
5
+ 通过 **Matrix** 远程使用 [pi coding agent](https://pi.dev)。在聊天里发消息,pi 回复 —— 而且 slash 命令、技能、提示词模板**全部可用**,和终端里一模一样。
6
6
 
7
- 与传统的 pi 扩展模式不同,本项目通过 [RPC 协议](https://pi.dev/docs/latest/rpc)驱动 pi,因此 **messenger 里可以直接执行 slash 命令**(`/new`、`/compact`、`/model`、`/skill:name`、提示词模板、扩展命令)—— 这是扩展模式做不到的,因为 pi 的 `sendUserMessage()` 刻意跳过了命令解析。
7
+ pi 经典的扩展模式不同,pi-courier 通过 [RPC 协议](https://pi.dev/docs/latest/rpc)驱动 pi,这是命令能在聊天里生效的原因:扩展模式做不到,因为 pi 的 `sendUserMessage()` 刻意跳过了命令解析。
8
8
 
9
- > **上游来源**:本项目改造自 [tintinweb/pi-messenger-bridge](https://github.com/tintinweb/pi-messenger-bridge) —— Matrix 传输层与挑战码认证来自上游;基于 RPC 的独立架构、slash 命令映射、CLI 与配置向导为本项目新增。
9
+ ## 1. 是什么
10
10
 
11
- ## 特性
12
-
13
- - 📱 Matrix 传输(支持 E2EE)、6 位验证码挑战认证
14
- - 🎛️ slash 命令全支持:`/new`、`/compact`、`/model`、`/thinking`、`/bash`、`/reload` 等
15
- - 🧩 技能与提示词模板透传:`/skill:名称`、`/模板名` 直接生效
16
- - 💾 会话持久化:pi 会话存磁盘,重启自动恢复
17
- - 🔄 `/reload` 重启 pi 进程:装新插件、改配置后一条命令生效,会话无损
18
- - 🔌 不打包 pi:作为 pi 的伴侣程序独立部署,通过 RPC 连接系统安装的 pi,pi 独立升级
19
- - 🧭 一条命令搞定: `pi-courier setup` 配置向导、`pi-courier enable` 开机自启、`pi-courier update` 自更新
20
-
21
- ## 架构
11
+ pi-courier 是一个把 Matrix 桥接到本机 pi 的轻量独立服务:
22
12
 
23
13
  ```
24
- Messenger ──> pi-courier (dist/standalone.js) ──> pi --mode rpc(系统安装)
25
- Messenger <── 回复 <────────────────────────── <── agent 事件流(stdout JSONL)
14
+ Matrix bot ←→ pi-courier ←→ pi --mode rpc(系统安装)
26
15
  ```
27
16
 
28
- - pi-courier 负责 spawn 并管理 `pi --mode rpc` 子进程
29
- - 会话持久化到 `~/.pi/agent/sessions`,重启自动恢复
30
- - systemd 只需托管 pi-courier 一个服务
17
+ - **你和 Matrix bot 账号对话**;消息通过 RPC 协议转发给 pi
18
+ - **命令全支持**:`/new`、`/compact`、`/model`、`/thinking`、`/skill:名称`、提示词模板、扩展命令
19
+ - **不捆绑 pi** —— pi 独立安装、独立升级
20
+ - **会话持久化**到 `~/.pi/agent/sessions`,重启自动恢复
21
+ - **一条命令的 CLI**:配置向导、systemd 开机自启、自动更新
31
22
 
32
- ## 环境要求
23
+ ## 2. 怎么装
33
24
 
34
- | 组件 | 要求 | 检查命令 |
35
- |---|---|---|
36
- | Node.js | **>= 20**(实测 24.x) | `node --version` |
37
- | pi | **>= 0.83,全局安装**(项目不打包) | `pi --version` |
38
- | 网络 | 能访问 homeserver 与 LLM provider 端点 | — |
25
+ ### 前置条件
39
26
 
40
- **先装 pi**(bridge pi 的伴侣程序,通过 RPC 协议连接系统安装的 pi):
27
+ | 组件 | 要求 |
28
+ |---|---|
29
+ | Node.js | >= 20(实测 24.x) |
30
+ | pi | >= 0.83,**全局安装** |
31
+
32
+ 先装 pi —— pi-courier 连接的是它:
41
33
 
42
34
  ```bash
43
35
  npm install -g @earendil-works/pi-coding-agent
44
36
  pi --version
45
37
  ```
46
38
 
47
- > 使用 nvm 的注意:每次新终端先 `source ~/.nvm/nvm.sh`(或按你的 nvm 初始化方式),并确认 `pi` 在 PATH 中(`which pi`)。
39
+ nvm 的话,每个新终端先 `source ~/.nvm/nvm.sh`,确保 `pi` `node` 在 PATH 里。
40
+
41
+ ### 方式 A:普通用户 —— 一条命令
42
+
43
+ ```bash
44
+ npm install -g pi-courier
45
+ ```
46
+
47
+ 完事。验证:`pi-courier help`。
48
48
 
49
- ## 安装
49
+ ### 方式 B:开发人员 —— 源码构建
50
50
 
51
51
  ```bash
52
52
  git clone https://github.com/Hi-Barry/pi-courier.git
53
53
  cd pi-courier
54
54
  npm install
55
- npm link # 把 `pi-courier` 命令全局化,之后任何目录都能用
56
55
  npm run build
56
+ npm link # 让 `pi-courier` 命令全局可用
57
57
  ```
58
58
 
59
- **重要:不要加 `--ignore-scripts`**。Matrix E2EE 加密库(`@matrix-org/matrix-sdk-crypto-nodejs`)的原生二进制由 postinstall 脚本下载。若你的 npm 配置了 allow-scripts 拦截导致安装后报 `Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'`,手动补下载:
59
+ **不要用 `--ignore-scripts`**:Matrix E2EE 库的 postinstall 会下载原生二进制。如果被 npm 拦截,报 `Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'` 时手动补:
60
60
 
61
61
  ```bash
62
62
  cd node_modules/@matrix-org/matrix-sdk-crypto-nodejs
@@ -64,299 +64,183 @@ node download-lib.js
64
64
  cd ../..
65
65
  ```
66
66
 
67
- 构建成功标志:出现 `dist/standalone.js`。
67
+ 下载很慢(20-60 kB/s)?这个二进制来自 GitHub Releases,**不走 npm 代理** —— 先 `export https_proxy=... http_proxy=...` 再装。
68
68
 
69
- ## 配置
69
+ ## 3. 怎么用
70
70
 
71
- ### pi LLM provider(`~/.pi/agent/`)
71
+ ### 0 —— 确认 pi 能对话(一次性)
72
72
 
73
- **a) models.json** 模型元数据。推荐从 models.dev 提取(字段完整正确),以 opencode-go 为例:
73
+ pi 需要在 `~/.pi/agent/` 里配好 LLM provider(`models.json`、`auth.json`、`settings.json`)。最快的检查方式:跑 `pi`,随便发条消息,能回复就行。不能回复就先配好(参考 pi 官方文档;注意 `settings.json` 的字段名是 `defaultProvider` / `defaultModel`)。
74
+
75
+ ### 第 1 步 —— 运行配置向导
74
76
 
75
77
  ```bash
76
- curl -s https://models.dev/api.json -o /tmp/modelsdev.json
77
- python3 -c "
78
- import json, os
79
- md = json.load(open('/tmp/modelsdev.json')) # 顶层直接是 provider 字典
80
- out = {'providers': {'opencode-go': md['opencode-go']}}
81
- json.dump(out, open(os.path.expanduser('~/.pi/agent/models.json'), 'w'), indent=2)
82
- "
78
+ pi-courier setup
83
79
  ```
84
80
 
85
- **b) auth.json** — API key(权限 600):
81
+ 向导会逐步询问,照着输入(方括号里是默认值,直接回车接受):
86
82
 
87
- ```json
88
- {
89
- "opencode-go": { "type": "api_key", "key": "sk-你的密钥" }
90
- }
91
83
  ```
84
+ === pi-courier 首次配置向导 ===
85
+ 将生成 ~/.pi/msg-bridge.json(权限 600)
92
86
 
93
- **c) settings.json** 默认 provider 与模型:
87
+ Matrix homeserver URL (如 https://matrix.example.com): ← 输入,如 https://matrix.example.com
88
+ 获取 token 方式 [1=用户名密码登录, 2=粘贴已有 token] (1): ← 1 或 2(回车默认 1)
89
+ [方式 1] bot 用户名 (如 test2): ← bot 账号名,如 test3
90
+ bot 密码: ← 密码(不回显)
91
+ [方式 2] 粘贴 access token (syt_...): ← 已有 token
92
+ ✅ 登录成功,账号: @test3:matrix.example.com
93
+ 信任用户(管理员)MXID [默认 @test3:matrix.example.com]: ← 直接回车 = 只有 bot 自己可信;建议填你的账号,如 @barry:matrix.example.com
94
+ 启用 E2EE 加密? [y/N]: ← y/n(非加密房间选 y 也没问题)
95
+ pi 工作目录 [默认 /home/你/Projects]: ← 回车或输入其他目录
94
96
 
95
- ```json
96
- {
97
- "defaultProvider": "opencode-go",
98
- "defaultModel": "deepseek-v4-flash"
99
- }
97
+ ✅ 配置已写入 ~/.pi/msg-bridge.json
98
+ 账号: @test3:...
99
+ 信任用户: @barry:...
100
+ E2EE: 开启
101
+ 工作目录: /home/你/Projects
100
102
  ```
101
103
 
102
- > 字段名是 `defaultProvider` / `defaultModel`(不是 `provider` / `model`)。
104
+ 向导会验证 token 并写入 `~/.pi/msg-bridge.json`。不想用向导的话,手动创建这个文件也行 —— 格式见[常见问题](#4-常见问题)。
103
105
 
104
- 验证配置(在 pi-courier 项目目录内执行):
106
+ ### 2 步 —— 启动
105
107
 
106
108
  ```bash
107
- node --input-type=module -e "
108
- import { RpcClient } from '@earendil-works/pi-coding-agent';
109
- import { fileURLToPath } from 'node:url';
110
- import path from 'node:path';
111
- const entry = fileURLToPath(import.meta.resolve('@earendil-works/pi-coding-agent'));
112
- const c = new RpcClient({ cliPath: path.join(path.dirname(entry), 'cli.js') });
113
- await c.start();
114
- console.log('可用模型数:', (await c.getAvailableModels()).length);
115
- console.log('当前模型:', (await c.getState()).model?.id);
116
- await c.stop();
117
- "
109
+ pi-courier enable # 安装 systemd 服务:开机自启 + 立即启动
118
110
  ```
119
111
 
120
- ### 配置 messenger(Matrix 为例)
112
+ 想先快速前台测试:`pi-courier run`(Ctrl+C 停止)
121
113
 
122
- **方式一(推荐):首次运行配置向导**
114
+ 启动成功长这样:
123
115
 
124
- ```bash
125
- pi-courier setup
126
116
  ```
127
-
128
- 按提示依次输入:平台 homeserver URL → token(用户名密码登录或粘贴已有 token)→ 信任用户 MXID → 是否启用 E2EE → pi 工作目录。向导会验证 token 并自动写入 `~/.pi/msg-bridge.json`。
129
-
130
- **方式二:手动编辑 `~/.pi/msg-bridge.json`**(权限 600):
131
-
132
- ```json
133
- {
134
- "matrix": {
135
- "homeserverUrl": "https://你的homeserver",
136
- "accessToken": "syt_你的token",
137
- "encryption": true
138
- },
139
- "auth": {
140
- "trustedUsers": ["matrix:@你的账号:你的homeserver域名"],
141
- "adminUserId": "matrix:@你的账号:你的homeserver域名"
142
- },
143
- "workdir": "/path/to/pi/workdir",
144
- "autoConnect": true,
145
- "debug": true
146
- }
117
+ ✅ Matrix connected as @test3:... (2 rooms, E2EE enabled)
118
+ pi RPC connected (model: deepseek-v4-flash, session: 019f...)
119
+ 🚀 msg-bridge standalone ready. Waiting for messages...
147
120
  ```
148
121
 
149
- - `accessToken` 获取:`POST /_matrix/client/v3/login`(密码登录)或 Element 设置页
150
- - `trustedUsers` / `adminUserId` 格式:`<transport>:<完整userId>`,Matrix 的 userId 是完整 MXID(如 `@barry:matrix.example.com`)
151
- - `workdir`:pi 的工作目录(不存在会自动创建);`pi-courier run --workdir <目录>` 可覆盖
152
- - `sessionDir` / `cliPath`:可选覆盖(默认:pi 的会话目录、`which pi` 定位 CLI)
153
- - `encryption: true` 用于加密房间;普通房间保持 true 也可用
154
- - 环境变量替代:`PI_MATRIX_HOMESERVER` / `PI_MATRIX_ACCESS_TOKEN`
122
+ ### 3 —— 在 Matrix 里使用
155
123
 
156
- ## 使用
124
+ **首次接触(一次性配对):**
157
125
 
158
- 全部操作走一个命令:
126
+ 1. 用你的账号**给 bot 发私聊消息**(随便发什么都行)
127
+ 2. 此时你还不是 trusted user,bridge 会在日志里打印验证码(`pi-courier logs` 或 `journalctl --user -u pi-msg-bridge -f`):
159
128
 
160
129
  ```
161
- pi-courier setup 首次运行配置向导(Matrix 账号、信任用户、工作目录)
162
- pi-courier run 前台运行(工作目录从配置读,--workdir 可覆盖)
163
- pi-courier enable 安装用户级 systemd 服务并开机自启、立即启动
164
- pi-courier start 启动服务
165
- pi-courier stop 停止服务
166
- pi-courier restart 重启服务
167
- pi-courier status 查看服务状态与最近日志
168
- pi-courier logs 跟踪服务日志(Ctrl+C 退出)
169
- pi-courier disable 卸载服务(停止 + 取消自启 + 删除 unit 文件)
170
- pi-courier update 更新本项目(git pull + 安装依赖 + 重新构建)
130
+ 🔐 Challenge code for @barry: 138949
171
131
  ```
172
132
 
173
- 典型首次部署:
174
-
175
- ```bash
176
- pi-courier setup # 按提示配置(或手动编辑 ~/.pi/msg-bridge.json)
177
- pi-courier enable # 开机自启,以当前用户运行
178
- ```
179
-
180
- 前台快速测试:`pi-courier run`(Ctrl+C 停止)。旧的 `node dist/standalone.js --workdir ...` 方式仍然可用。
181
-
182
- **启动成功的标志日志:**
133
+ 3. **在聊天里回复这串数字**(只发数字),日志确认配对成功:
183
134
 
184
135
  ```
185
- Matrix connected as @bot:你的homeserver (2 rooms, E2EE enabled)
186
- ✅ pi RPC connected (model: deepseek-v4-flash, session: 019f...)
187
- 🚀 msg-bridge standalone ready. Waiting for messages...
136
+ [auth:info] barry authenticated
188
137
  ```
189
138
 
190
- ### 命令一览(DM 中直接发送)
139
+ 你就成为 trusted user(第一个 trusted 用户自动成为管理员)。不在 `auth.trustedUsers` 里的用户都会走一次这个流程;预信任用户完全跳过。
191
140
 
192
- **Pi 命令(映射到 RPC):**
141
+ **之后**正常对话,或发命令:
193
142
 
194
- | 命令 | 说明 |
143
+ | 命令 | 作用 |
195
144
  |---|---|
196
145
  | `/new` `/clear` | 新会话 |
197
146
  | `/compact [说明]` | 压缩上下文 |
198
147
  | `/model` / `/model <provider/id>` | 查看 / 切换模型 |
199
- | `/models` | 列出可用模型 |
200
- | `/thinking [level]` | 查看 / 设置思考级别 |
148
+ | `/models` | 列出模型 |
149
+ | `/thinking [级别]` | 查看 / 设置思考级别 |
201
150
  | `/session` `/cost` | 会话统计与费用 |
202
151
  | `/status` | 当前模型与状态 |
203
152
  | `/name <名字>` | 会话命名 |
204
153
  | `/export [路径]` | 导出会话 HTML |
205
- | `/bash <命令>` | 执行 shell 命令(写入上下文) |
154
+ | `/bash <命令>` | 执行 shell 命令 |
206
155
  | `/abort` | 中止当前操作 |
207
- | `/reload` | 重启 pi 进程(装插件 / 改配置后使用) |
156
+ | `/reload` | 重启 pi(装完扩展/配置后) |
208
157
  | `/help` | 完整帮助 |
209
158
 
210
- **Bridge 管理命令:** `/trusted`、`/revoke <userId>`、`/channels`、`/enable <chatId> <mode>`、`/disable <chatId>`、`/toggletools`
211
-
212
- **透传:** 其他 `/` 开头的命令直接交给 pi(扩展命令、`/skill:名称`、提示词模板由 pi 展开);普通文本 = 正常对话。
213
-
214
- ### 首次使用:认证
215
-
216
- 1. 你的账号给 bot 账号发第一条 DM
217
- 2. bridge 终端(或 `journalctl --user -u pi-msg-bridge -f`)会打印 6 位验证码
218
- 3. 把验证码发回给 bot → 成为 trusted user(第一个 trusted 用户自动成为 admin)
159
+ **bridge 管理命令**:`/trusted`、`/revoke <userId>`、`/channels`、`/enable <chatId> <mode>`、`/disable <chatId>`、`/toggletools`
219
160
 
220
- 已在 `msg-bridge.json` `auth.trustedUsers` 里预置的账号跳过此步骤。
161
+ **其他任何 `/` 开头的内容**都直接透传给 pi —— 扩展命令、`/skill:名称`、提示词模板由 pi 展开。普通文本就是正常对话。
221
162
 
222
- ## systemd 部署(开机自启)
163
+ **群聊**:先给 bot 发 `/enable <roomId> all` 启用该房间。
223
164
 
224
- **用户级(推荐,无需 sudo):**
165
+ ### 服务管理
225
166
 
226
167
  ```bash
227
- pi-courier enable
168
+ pi-courier status # 状态 + 最近日志
169
+ pi-courier logs # 跟踪日志
170
+ pi-courier restart # 重启
171
+ pi-courier stop # 停止
172
+ pi-courier start # 启动
173
+ pi-courier disable # 卸载服务
174
+ pi-courier update # 更新 pi-courier 自身
228
175
  ```
229
176
 
230
- 一条命令搞定 —— 自动写入 `~/.config/systemd/user/pi-msg-bridge.service`(使用绝对 node 路径和配置的工作目录)、启用开机自启并立即启动。彻底无人值守(注销后继续运行)执行一次:`sudo loginctl enable-linger $USER`。
231
-
232
- 常用命令:`pi-courier status`、`pi-courier logs`、`pi-courier stop`、`pi-courier start`(或 `systemctl --user restart pi-msg-bridge`)。
233
-
234
- **系统级(需要 sudo):** 复制 `deploy/pi-msg-bridge.service` 到 `/etc/systemd/system/`,按注释修改三处必改项(`User`、`WorkingDirectory`、`NVM_DIR`),再 `sudo systemctl enable --now pi-msg-bridge`。
235
-
236
- ## 升级 pi
237
-
238
- pi 由系统独立管理,升级只需全局更新,bridge 无需任何改动:
177
+ **升级 pi** 是独立的事 —— pi-courier 始终通过 `which pi` 连接系统 pi:
239
178
 
240
179
  ```bash
241
180
  npm install -g @earendil-works/pi-coding-agent@latest
242
- pi --version
243
- pi-courier restart # 或: systemctl --user restart pi-msg-bridge
181
+ pi-courier restart
244
182
  ```
245
183
 
246
- bridge 通过 `which pi` 始终连接系统最新版 pi。仅当 pi 的 RPC 协议发生破坏性变更时才需要改 bridge 代码(协议为文档化稳定接口,从未破坏性变更)。
247
-
248
- ## FAQ(常见问题)
249
-
250
- ### 安装与部署
251
-
252
- **Q: `git clone` 报 404?**
253
- A: 仓库地址写错。用 `https://github.com/Hi-Barry/pi-courier.git`(或直接 `npm install -g pi-courier` 安装)。
184
+ ## 4. 常见问题
254
185
 
255
186
  **Q: `npm install` 卡住 / 只有 20-60 kB/s?**
256
- A: 涉及两个下载,要分开配代理:
257
- - npm registry 的包 → 配 npm 代理:`npm config set proxy http://...` 和 `npm config set https-proxy http://...`
258
- - 21MB 的 E2EE 原生库(由 matrix-sdk-crypto-nodejs 从 GitHub Releases 下载)→ **不走 npm 代理**,需先 `export https_proxy=http://...` `export http_proxy=http://...` 再安装(想永久生效写进 `~/.bashrc`)
187
+ A: 21MB 的 E2EE 原生库从 GitHub Releases 下载,不走 npm 代理。先 `export https_proxy=... http_proxy=...`(写进 `~/.bashrc` 永久生效)再装。
259
188
 
260
189
  **Q: 报 `Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'`?**
261
- A: 原生二进制没下载成功(postinstall 被拦或中断)。手动补(必要时先设置代理环境变量):
262
- ```bash
263
- cd node_modules/@matrix-org/matrix-sdk-crypto-nodejs
264
- node download-lib.js
265
- cd ../..
266
- ```
190
+ A: 原生二进制没下载(postinstall 被拦)。手动补:`cd node_modules/@matrix-org/matrix-sdk-crypto-nodejs && node download-lib.js`。
267
191
 
268
192
  **Q: `npm install -g pi-courier` 报 EEXIST?**
269
- A: 之前 `npm link` 过,bin 冲突。先清理:
270
- ```bash
271
- npm unlink -g pi-courier
272
- rm -f ~/.nvm/versions/node/v24.18.1/bin/pi-courier
273
- npm install -g pi-courier
274
- ```
275
-
276
- **Q: `npm link` 后 `pi-courier` 命令找不到?**
277
- A: link 在 `npm run build` 之前执行,`dist/cli.js` 还不存在。build 后重新 `npm link`(或直接改用 npm 安装)。
278
-
279
- **Q: systemd 服务反复重启循环?**
280
- A: pi 子进程崩溃,几乎都是 **Node 版本不匹配**:bridge 通过 PATH 找 node 启动 pi,systemd 默认 PATH 可能命中系统 node(如 v20),而 pi 的 undici 与 Node 20 不兼容(报 `webidl.util.markAsUncloneable is not a function`)。修复:`source ~/.nvm/nvm.sh` 后重新 `pi-courier enable`(0.1.2+ 会自动把 `Environment=PATH=<nvm bin 优先>` 写进 unit)。**全机统一用一个 Node 版本(nvm v24)**,别和系统 node 混用。
281
-
282
- ### 配置
193
+ A: 之前 `npm link` 过,bin 冲突。`npm unlink -g pi-courier && rm -f $(npm prefix -g)/bin/pi-courier && npm install -g pi-courier`。
283
194
 
284
- **Q: 启动日志显示 `model: unknown`?**
285
- A: pi provider 没配置。检查 `~/.pi/agent/` 三个文件:`models.json`(模型元数据)、`auth.json`(API key,权限 600)、`settings.json`(`defaultProvider` / `defaultModel` —— 注意字段名是这两个,不是 provider/model)。
195
+ **Q: systemd 服务反复重启?**
196
+ A: 几乎都是 Node 版本不匹配 —— pi 子进程在系统 node v20 上崩溃(报 `webidl.util.markAsUncloneable is not a function`)。加载 nvm 后重新 `pi-courier enable`(0.1.2+ 会自动写入正确的 PATH)。全机统一一个 Node 版本。
286
197
 
287
- **Q: `getAvailableModels` 为空?**
288
- A: `models.json` 格式错误。用配置章节的 models.dev 提取命令重新生成。
289
-
290
- **Q: 启动报 `no transports configured`?**
291
- A: bridge 配置为空。运行 `pi-courier setup` 生成 `~/.pi/msg-bridge.json`,或检查 `PI_*` 环境变量。
292
-
293
- **Q: setup 向导里出现奇怪的 `DeprecationWarning: util._extend`?**
294
- A: 传输层依赖的已知噪音,0.1.0 起已过滤。更新 pi-courier 后仍看到就说明版本太旧。
295
-
296
- ### 消息与加密
198
+ **Q: 启动显示 `model: unknown`?**
199
+ A: pi 的 provider 没配。检查 `~/.pi/agent/`:`models.json` + `auth.json` + `settings.json`(字段名是 `defaultProvider` / `defaultModel`)。
297
200
 
298
201
  **Q: 日志大量 `Decryption error`?**
299
- A: 历史消息无法解密(新设备没有旧密钥)。**正常**,不影响新消息。
202
+ A: 历史消息无法解密(新设备没有旧密钥)。**正常**,新消息不受影响。
300
203
 
301
204
  **Q: 加密房间:发消息没回复 / 新消息解不开?**
302
- A: bot 的新设备没拿到你客户端的房间密钥。处理:
303
- - Element(网页:设置 → 安全与隐私 → 加密):确保 **"仅向已验证设备共享密钥"未勾选**,然后在房间里发一条消息
304
- - bot 账号没有交叉签名,"用户验证"显示不可用是正常的;最省心的可靠方案:**直接用非加密房间**(新建房间时不要勾选加密,把 bot 拉进来)。bridge 配置 `encryption: true` 也照常处理非加密房间。
305
-
306
- **Q: 启动报 `M_BAD_JSON: Provided device_id in device_keys does not match...`?**
307
- A: 加密存储里是旧设备身份,而 access token 属于新设备(重新登录过)。删掉存储重启:
308
- ```bash
309
- rm -rf ~/.pi/msg-bridge-matrix-crypto
310
- pi-courier restart
311
- ```
312
- **以后每次重跑 setup / 换 token,都顺手删一次这个目录。**
205
+ A: bot 的新设备没拿到房间密钥。bot 账号没有交叉签名,最可靠的解法是**用非加密房间**(新建房间时不勾选加密,把 bot 拉进来)—— 配置 `encryption: true` 也照常处理非加密房间。
313
206
 
314
- **Q: Matrix 连接失败(homeserver/token 错误)?**
315
- A: 验证 token:`curl -H "Authorization: Bearer <token>" https://homeserver/_matrix/client/v3/account/whoami`。
207
+ **Q: `M_BAD_JSON: Provided device_id in device_keys does not match...`?**
208
+ A: 加密存储里是旧设备身份,而 token 属于新设备(重新登录过)。删除重启:`rm -rf ~/.pi/msg-bridge-matrix-crypto && pi-courier restart`。**每次重跑 setup / 换 token 都顺手删一次。**
316
209
 
317
- **Q: 第一次给 bot 发消息要 6 位验证码?**
318
- A: 这是 challenge 认证 —— 把验证码回复给 bot 即成为 trusted user(第一个 trusted 用户自动成为 admin)。已在 `auth.trustedUsers` 里的用户跳过此步骤。
210
+ **Q: 第一次发消息要 6 位验证码?**
211
+ A: 这是挑战认证 —— 把验证码回复给 bot 即成为 trusted user
319
212
 
320
213
  **Q: 消息完全没有回复?**
321
- A: 按顺序排查:(1) `pi-courier status` / 日志 —— Matrix 连上了吗?有没有 Decryption error(加密房间)?(2) pi RPC 连上了吗?(3) 模型调用本身 —— 用 curl 直接测 provider 端点,排除网络/密钥问题。
322
-
323
- ### 运行与维护
214
+ A: 按顺序排查:(1) `pi-courier status` —— Matrix 连上了吗?有 Decryption error(加密房间)?(2) pi RPC 连上了吗?(3) 模型调用本身 —— 用 curl 直接测 provider 端点。
324
215
 
325
216
  **Q: `pi RPC did not become ready`?**
326
- A: pi 子进程启动失败。手动跑它看真实报错:
327
- ```bash
328
- node node_modules/@earendil-works/pi-coding-agent/dist/cli.js --mode rpc
329
- ```
330
- 常见原因:Node 版本不匹配(见上面重启循环)、provider 配置错误、无法访问 provider 端点。
217
+ A: pi 启动失败。手动跑 `node node_modules/@earendil-works/pi-coding-agent/dist/cli.js --mode rpc` 看真实报错。常见原因:Node 版本不匹配、provider 配置错误、无法访问 provider。
331
218
 
332
219
  **Q: 重启后对话上下文丢了?**
333
- A: 0.1.1 起 bridge 会给 pi 传 `--continue`(等价 `pi -c`),按 workdir 恢复最近会话。升级并重启即可;`/new` 开新会话,下次重启恢复的是新会话。
220
+ A: 0.1.1 起 bridge 会给 pi 传 `--continue`,按 workdir 恢复最近会话。升级并重启即可;`/new` 开新会话,下次重启恢复新会话。
334
221
 
335
222
  **Q: Element(网页客户端)拦截 `/` 开头的消息?**
336
223
  A: 用 `//` 转义发送字面文本(如 `//compact` 会发出 `/compact`)。
337
224
 
338
- **Q: 代理环境有什么讲究?**
339
- A: npm registry → `npm config set proxy/https-proxy`;GitHub 下载与 bridge 运行 → `export https_proxy` / `http_proxy`(systemd 里加进 EnvironmentFile)。
225
+ **Q: `~/.pi/msg-bridge.json` 里到底有什么?**
226
+ A: 向导生成的配置,示例:
340
227
 
341
- ## 使用提示
342
-
343
- - **Element 客户端**:`/` 开头的消息会被客户端当作命令拦截,要发送字面文本用 `//` 转义(如 `//compact` 会发送 `/compact`)
344
- - **代理环境**:设置 `HTTP_PROXY` / `HTTPS_PROXY` 环境变量(systemd 用 EnvironmentFile)
345
- - **群聊**:需先 `/enable <roomId> all` 启用;DM 无需配置
346
-
347
- ## 开发
348
-
349
- ```bash
350
- npm run build # 编译
351
- npm run typecheck # 类型检查
352
- npm run test # 单元测试(vitest)
353
- npm run lint # biome lint
228
+ ```json
229
+ {
230
+ "matrix": { "homeserverUrl": "https://matrix.example.com", "accessToken": "syt_...", "encryption": true },
231
+ "auth": { "trustedUsers": ["matrix:@你:matrix.example.com"], "adminUserId": "matrix:@你:matrix.example.com" },
232
+ "workdir": "/home/你/Projects",
233
+ "autoConnect": true,
234
+ "debug": true
235
+ }
354
236
  ```
355
237
 
356
- 完整的开发历程 —— 调研、设计决策、真实部署中踩过的每一个坑 —— 见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。
238
+ 环境变量替代:`PI_MATRIX_HOMESERVER` / `PI_MATRIX_ACCESS_TOKEN`。
239
+
240
+ ## 5. 协议与声明
357
241
 
358
- ## License
242
+ MIT License —— 见 [LICENSE](LICENSE)。
359
243
 
360
- MIT
244
+ **上游来源**:本项目改造自 [tintinweb/pi-messenger-bridge](https://github.com/tintinweb/pi-messenger-bridge)(MIT)。Matrix 传输层与挑战码认证来自上游;基于 RPC 的独立架构、slash 命令映射、CLI、配置向导与文档为本项目新增。
361
245
 
362
- 上游:[tintinweb/pi-messenger-bridge](https://github.com/tintinweb/pi-messenger-bridge)(MIT)
246
+ pi-courier 是 [pi](https://pi.dev) 的独立伴侣应用,与 Earendil Inc. 无隶属关系。
package/dist/setup.js CHANGED
@@ -96,7 +96,7 @@ async function matrixWhoami(homeserver, accessToken) {
96
96
  export async function runSetup() {
97
97
  const { ask, close } = createPrompter();
98
98
  console.log("");
99
- console.log("=== pi-remote 首次配置向导 ===");
99
+ console.log("=== pi-courier 首次配置向导 ===");
100
100
  console.log("将生成 ~/.pi/msg-bridge.json(权限 600)\n");
101
101
  try {
102
102
  const homeserver = (await ask("Matrix homeserver URL (如 https://matrix.example.com): ")).trim();
@@ -146,7 +146,7 @@ export async function runSetup() {
146
146
  console.log(` 信任用户: ${adminRaw}`);
147
147
  console.log(` E2EE: ${encryption ? "开启" : "关闭"}`);
148
148
  console.log(` 工作目录: ${workdir}`);
149
- console.log("\n下一步: pi-remote enable(开机自启)或 pi-remote run(前台运行)");
149
+ console.log("\n下一步: pi-courier enable(开机自启)或 pi-courier run(前台运行)");
150
150
  }
151
151
  catch (err) {
152
152
  console.error(`\n❌ 配置失败: ${err.message}`);
package/dist/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;GAOG;AACH,SAAS,cAAc;IAIrB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7D,OAAO;YACL,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CACd,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBACtB,IAAI,IAAI,GAAG,KAAK,CAAC;gBACjB,MAAM,MAAM,GAAG,CAAC,MAAc,EAAQ,EAAE;oBACtC,IAAI,CAAC,IAAI,EAAE,CAAC;wBACV,IAAI,GAAG,IAAI,CAAC;wBACZ,OAAO,CAAC,MAAM,CAAC,CAAC;oBAClB,CAAC;gBACH,CAAC,CAAC;gBACF,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC5B,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,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;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,aAAc,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,KAAK,EAAE,CAAC,CAAC,yDAAyD;IACpE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-courier",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Run pi coding agent from Matrix. Slash commands, skills and prompts fully work from messengers via the RPC protocol.",
5
5
  "type": "module",
6
6
  "main": "dist/standalone.js",