@fengye404/termpilot 0.1.6 → 0.1.8

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.
Files changed (60) hide show
  1. package/README.md +58 -168
  2. package/dist/cli.js +432 -59
  3. package/docs/.vitepress/config.mts +64 -0
  4. package/docs/.vitepress/dist/404.html +23 -0
  5. package/docs/.vitepress/dist/README.html +26 -0
  6. package/docs/.vitepress/dist/architecture.html +42 -0
  7. package/docs/.vitepress/dist/assets/README.md.B4-OJVNQ.js +1 -0
  8. package/docs/.vitepress/dist/assets/README.md.B4-OJVNQ.lean.js +1 -0
  9. package/docs/.vitepress/dist/assets/app.BG4pRgiG.js +1 -0
  10. package/docs/.vitepress/dist/assets/architecture.md.JnC1zyYV.js +17 -0
  11. package/docs/.vitepress/dist/assets/architecture.md.JnC1zyYV.lean.js +1 -0
  12. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.l5vdUGaZ.js +1 -0
  13. package/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.DMeTzGam.js +9 -0
  14. package/docs/.vitepress/dist/assets/chunks/framework.BZohXCq9.js +19 -0
  15. package/docs/.vitepress/dist/assets/chunks/theme.D0_6rd9F.js +2 -0
  16. package/docs/.vitepress/dist/assets/development.md.iwUVjeO6.js +7 -0
  17. package/docs/.vitepress/dist/assets/development.md.iwUVjeO6.lean.js +1 -0
  18. package/docs/.vitepress/dist/assets/getting-started.md.Cirp1CHi.js +1 -0
  19. package/docs/.vitepress/dist/assets/getting-started.md.Cirp1CHi.lean.js +1 -0
  20. package/docs/.vitepress/dist/assets/index.md.D9XElNRh.js +1 -0
  21. package/docs/.vitepress/dist/assets/index.md.D9XElNRh.lean.js +1 -0
  22. package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  23. package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  24. package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  25. package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  26. package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  27. package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  28. package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  29. package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  30. package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  31. package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  32. package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  33. package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  34. package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  35. package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  36. package/docs/.vitepress/dist/assets/operations-guide.md.DfNiIg5F.js +18 -0
  37. package/docs/.vitepress/dist/assets/operations-guide.md.DfNiIg5F.lean.js +1 -0
  38. package/docs/.vitepress/dist/assets/protocol.md.CCXFJUPR.js +40 -0
  39. package/docs/.vitepress/dist/assets/protocol.md.CCXFJUPR.lean.js +1 -0
  40. package/docs/.vitepress/dist/assets/style.B0lvUXq1.css +1 -0
  41. package/docs/.vitepress/dist/assets/tech-selection-2026.md.Dk_ymWTx.js +1 -0
  42. package/docs/.vitepress/dist/assets/tech-selection-2026.md.Dk_ymWTx.lean.js +1 -0
  43. package/docs/.vitepress/dist/development.html +32 -0
  44. package/docs/.vitepress/dist/favicon.svg +6 -0
  45. package/docs/.vitepress/dist/getting-started.html +26 -0
  46. package/docs/.vitepress/dist/hashmap.json +1 -0
  47. package/docs/.vitepress/dist/index.html +26 -0
  48. package/docs/.vitepress/dist/operations-guide.html +43 -0
  49. package/docs/.vitepress/dist/protocol.html +65 -0
  50. package/docs/.vitepress/dist/tech-selection-2026.html +26 -0
  51. package/docs/.vitepress/dist/vp-icons.css +1 -0
  52. package/docs/.vitepress/theme/custom.css +42 -0
  53. package/docs/.vitepress/theme/index.ts +10 -0
  54. package/docs/README.md +10 -6
  55. package/docs/architecture.md +10 -7
  56. package/docs/getting-started.md +136 -0
  57. package/docs/index.md +57 -0
  58. package/docs/operations-guide.md +445 -0
  59. package/docs/public/favicon.svg +6 -0
  60. package/package.json +6 -2
package/README.md CHANGED
@@ -1,66 +1,60 @@
1
1
  # TermPilot
2
2
 
3
- TermPilot 是一个终端优先的远程控制工具。电脑上跑 `tmux` 会话,手机直接打开 relay 域名查看和控制同一批会话。
3
+ [![npm version](https://img.shields.io/npm/v/%40fengye404%2Ftermpilot)](https://www.npmjs.com/package/@fengye404/termpilot)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40fengye404%2Ftermpilot)](https://www.npmjs.com/package/@fengye404/termpilot)
5
+ [![GitHub Actions](https://img.shields.io/github/actions/workflow/status/fengye404/TermPilot/docs.yml?branch=main&label=docs)](https://github.com/fengye404/TermPilot/actions)
4
6
 
5
- ## 产品形态
7
+ TermPilot 是一个终端优先的远程控制工具。它把电脑上的 `tmux` 会话暴露给手机浏览器,让你在电脑和手机之间无缝切换,同步查看和控制同一批任务。
8
+
9
+ ## 为什么是它
6
10
 
7
11
  - 一个 npm 包:`@fengye404/termpilot`
8
12
  - 一个服务器命令:`termpilot relay`
9
13
  - 一个电脑命令:`termpilot agent`
10
14
  - 手机端不安装,直接打开 relay 域名
11
- - relay 同时负责消息中继和网页托管
15
+ - relay 同时负责 Web UI 托管和 WebSocket 中继
12
16
 
13
- ## 5 分钟快速上手
17
+ ## 30 秒理解工作流
14
18
 
15
- ### 1. 启动 relay
19
+ 1. 在服务器执行 `termpilot relay`
20
+ 2. 在电脑执行 `termpilot agent`
21
+ 3. 手机上打开 relay 域名并输入配对码
22
+ 4. 在电脑直接执行 `termpilot claude code`
23
+ 5. 手机和电脑同时看到同一个会话输出
24
+
25
+ ## 快速开始
16
26
 
17
- 在云服务器或一台能被手机访问到的机器上执行:
27
+ ### 1. 启动 relay
18
28
 
19
29
  ```bash
20
30
  npm install -g @fengye404/termpilot
21
31
  termpilot relay
22
32
  ```
23
33
 
24
- 如果你只是先本地体验,也可以直接在自己电脑上跑 relay,然后让手机走局域网访问。
25
-
26
- ### 2. 启动电脑 agent
27
-
28
- 在你的电脑上执行:
34
+ ### 2. 启动 agent
29
35
 
30
36
  ```bash
31
37
  npm install -g @fengye404/termpilot
32
- termpilot agent --relay ws://your-domain.com:8787/ws
38
+ termpilot agent
33
39
  ```
34
40
 
35
- 这条命令会直接:
41
+ 第一次运行时,`termpilot agent` 会交互式询问:
36
42
 
37
- - 后台启动 agent
38
- - 复用已有本地 agent(如果已经在跑)
39
- - 输出一次性配对码
43
+ 1. relay 域名或 IP
44
+ 2. 端口,默认 `8787`
40
45
 
41
- 常用管理命令:
42
-
43
- ```bash
44
- termpilot agent status
45
- termpilot agent stop
46
- ```
46
+ 然后它会自动保存配置、后台启动 agent,并打印一次性配对码。
47
47
 
48
48
  ### 3. 手机完成配对
49
49
 
50
- 手机浏览器直接打开 relay 域名:
50
+ 手机浏览器打开:
51
51
 
52
52
  - `http://your-domain.com:8787`
53
- - 或反代后的 `https://your-domain.com`
54
-
55
- 然后:
53
+ - `https://your-domain.com`
56
54
 
57
- 1. 输入电脑端刚打印出来的配对码
58
- 2. 点“配对”
59
- 3. 成功后直接进入会话列表
55
+ 输入配对码后,直接进入会话列表。
60
56
 
61
- ### 4. 直接跑一个可同步的任务
62
-
63
- 日常最短路径是:
57
+ ### 4. 直接启动任务
64
58
 
65
59
  ```bash
66
60
  termpilot claude code
@@ -72,164 +66,60 @@ termpilot claude code
72
66
  termpilot open code
73
67
  ```
74
68
 
75
- 这会直接:
76
-
77
- - 创建一个受 TermPilot 管理的 `tmux` 会话
78
- - 把命令写进这个会话
79
- - 当前终端自动 attach 进去
80
- - 手机端同步看到同一个会话
81
-
82
- ### 5. 你现在应该能做到什么
83
-
84
- 此时你可以:
85
-
86
- - 在电脑上看 `claude code` / `open code` 的流式输出
87
- - 在手机上看同一份输出
88
- - 在手机上补一条命令、发快捷键、关闭会话
89
- - 随时在电脑和手机之间切换
90
-
91
- ### 服务器
92
-
93
- 发布后:
94
-
95
- ```bash
96
- npm install -g @fengye404/termpilot
97
- termpilot relay
98
- ```
99
-
100
- 当前仓库内本地验证:
101
-
102
- ```bash
103
- pnpm install
104
- pnpm build
105
- npm install -g .
106
- termpilot relay
107
- ```
69
+ 这会直接创建一个受 TermPilot 管理的 `tmux` 会话并 attach 到当前终端,手机端会同步看到同一个会话。
108
70
 
109
- 常用参数:
71
+ ## 常用命令
110
72
 
111
73
  ```bash
112
74
  termpilot relay
113
- DATABASE_URL=postgresql://user:pass@127.0.0.1:5432/termpilot termpilot relay
114
- ```
115
-
116
- ### 电脑
117
-
118
- ```bash
119
- npm install -g @fengye404/termpilot
120
- termpilot agent --relay ws://your-domain.com/ws
121
- ```
122
-
123
- 如果你只是想看调试日志,可以显式前台运行:
124
-
125
- ```bash
126
- termpilot agent --relay ws://your-domain.com/ws --foreground
127
- ```
128
-
129
- 查看后台状态:
130
-
131
- ```bash
75
+ termpilot relay stop
76
+ termpilot relay run
77
+ termpilot agent
78
+ termpilot agent --pair
132
79
  termpilot agent status
133
- ```
134
-
135
- 停止后台 agent:
136
-
137
- ```bash
138
80
  termpilot agent stop
139
- ```
140
-
141
- 本地测试:
142
-
143
- ```bash
144
- termpilot agent --relay ws://127.0.0.1:8787/ws
145
- ```
146
-
147
- ### 手机
148
-
149
- 直接打开 relay 域名:
150
-
151
- - `https://your-domain.com`
152
-
153
- 首次使用时,直接执行上面的 `termpilot agent --relay ...` 就会拿到配对码;`termpilot pair` 现在只是补充入口,用于你已经有后台 agent、但想重新生成一次配对码的场景。
154
-
155
- 配对成功后:
156
-
157
- - 访问令牌会自动写回页面
158
- - 手机端默认先显示会话列表
159
- - 点进一个会话后才进入终端详情页
160
- - 连接信息和设备设置都在页面底部折叠区
161
-
162
- ## 日常使用
163
-
164
- ### 直接把命令交给 TermPilot
165
-
166
- ```bash
167
81
  termpilot claude code
168
82
  termpilot open code
169
- ```
170
-
171
- 如果你想跑别的命令,也可以直接:
172
-
173
- ```bash
174
- termpilot npm run dev
175
- termpilot python worker.py
176
- ```
177
-
178
- ### 手动管理会话
179
-
180
- 创建会话并进入:
181
-
182
- ```bash
183
- termpilot create --name claude-main --cwd /path/to/project
83
+ termpilot create --name my-task --cwd /path/to/project
184
84
  termpilot list
185
85
  termpilot attach --sid <sid>
86
+ termpilot kill --sid <sid>
186
87
  ```
187
88
 
188
- 进入会话以后,你仍然可以自己手动运行:
89
+ ## 文档
189
90
 
190
- ```bash
191
- claude code
192
- #
193
- open code
194
- ```
91
+ - [文档首页](./docs/index.md)
92
+ - [快速开始](./docs/getting-started.md)
93
+ - [部署与运维指南](./docs/operations-guide.md)
94
+ - [当前架构](./docs/architecture.md)
95
+ - [当前协议](./docs/protocol.md)
96
+ - [开发文档](./docs/development.md)
195
97
 
196
- 此时手机和电脑看到的是同一个会话,输出会同步刷新。
98
+ ## 最佳实践
197
99
 
198
- ## 常用命令
100
+ 1. 需要跨端同步的任务,一开始就用 `termpilot claude code`、`termpilot open code` 或 `termpilot create` 启动,不要先在普通终端里跑再想着接管。
101
+ 2. `termpilot agent` 适合作为长期后台入口。第一次配置完之后,日常只需要记住这一条命令。
102
+ 3. relay 长期使用时,优先挂到 HTTPS/WSS 域名后面;本地演示再用裸 IP 和 `8787`。
103
+ 4. 手机更适合看输出、发短命令和轻控制;电脑前的重输入仍然建议在本地终端完成。
104
+
105
+ ## 本地开发
199
106
 
200
107
  ```bash
201
- termpilot relay
202
- termpilot agent --relay ws://127.0.0.1:8787/ws
203
- termpilot agent status
204
- termpilot agent stop
205
- termpilot pair
206
- termpilot create --name claude-main
207
- termpilot list
208
- termpilot attach --sid <sid>
209
- termpilot kill --sid <sid>
210
- termpilot grants
211
- termpilot audit --limit 30
212
- termpilot revoke --token <accessToken>
213
- termpilot doctor
108
+ pnpm install
109
+ pnpm build
110
+ pnpm docs:dev
111
+ pnpm test:ui-smoke
112
+ pnpm check:stability
214
113
  ```
215
-
216
- ## 最佳实践
217
-
218
- 1. 需要跨端同步的任务,一开始就用 `termpilot create` 创建,不要先在普通终端里跑再想着接管。
219
- 2. 如果只是想“开一个会话然后立刻跑起来”,优先用 `termpilot claude code` 这类直达命令,不必手动 `create + attach`。
220
- 3. 一个长期任务用一个独立会话,名称直接写任务语义,比如 `claude-main`、`deploy-watch`、`batch-fix`。
221
- 4. 电脑前重操作优先 `termpilot attach`;手机更适合看进度、发短命令、补快捷键和关闭会话。
222
- 5. 普通 iTerm / Terminal 标签页不是 TermPilot 管理对象,不要指望后面“无缝接管”进来。
223
- 6. 手机优先走一次性配对码,不要长期传播访问令牌。
224
- 7. 要长期使用 relay,优先放到 HTTPS/WSS 域名后面,并接 PostgreSQL;本地演示可以先用内存模式。
225
- 8. 换手机或访问权变更时,先 `termpilot grants`,再 `termpilot revoke --token ...`。
226
- 9. 想排查控制历史时先看 `termpilot audit --limit 30`。
114
+ 10. 想排查控制历史时先看 `termpilot audit --limit 30`。
115
+ 11. 服务器上日常用 `termpilot relay` 后台运行;只有排查问题时才用 `termpilot relay run`。
227
116
 
228
117
  ## 常见坑
229
118
 
230
- - `termpilot agent --relay ...` 不会停在前台,这是正常的;它默认就是后台守护进程。
119
+ - `termpilot agent` 不会停在前台,这是正常的;它默认就是后台守护进程。
120
+ - `termpilot relay` 默认也不会停在前台;想看日志请用 `termpilot relay run`。
231
121
  - 手机上看不到任务时,先确认这个任务是不是通过 `termpilot ...` 或 `termpilot create` 启动的。
232
- - 首次配对优先用 `termpilot agent --relay ...` 拿配对码;`termpilot pair` 只是补充命令。
122
+ - 首次配对优先用 `termpilot agent` 拿配对码;重新给手机配对时用 `termpilot agent --pair`。
233
123
  - 外网正式使用时,不要长期直接裸奔 `ws://IP:8787/ws`,最好上域名和反代。
234
124
 
235
125
  ## 本地开发