ccoding 0.1.0__tar.gz → 0.2.1__tar.gz

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 (35) hide show
  1. ccoding-0.2.1/PKG-INFO +441 -0
  2. ccoding-0.2.1/README.md +390 -0
  3. {ccoding-0.1.0 → ccoding-0.2.1}/pyproject.toml +20 -1
  4. ccoding-0.2.1/src/ccode/__init__.py +12 -0
  5. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/api.py +5 -1
  6. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/config.py +92 -0
  7. ccoding-0.2.1/src/ccode/remote.py +634 -0
  8. ccoding-0.2.1/src/ccode/remote_cli.py +226 -0
  9. ccoding-0.2.1/src/ccode/remote_client.py +274 -0
  10. ccoding-0.2.1/src/ccode/remote_common.py +194 -0
  11. ccoding-0.2.1/src/ccode/remote_server.py +302 -0
  12. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/ui.py +198 -9
  13. ccoding-0.2.1/src/ccode/web/__init__.py +0 -0
  14. ccoding-0.2.1/src/ccode/web/app.js +288 -0
  15. ccoding-0.2.1/src/ccode/web/assets/addon-fit.js +2 -0
  16. ccoding-0.2.1/src/ccode/web/assets/xterm-LICENSE +21 -0
  17. ccoding-0.2.1/src/ccode/web/assets/xterm-addon-fit-LICENSE +19 -0
  18. ccoding-0.2.1/src/ccode/web/assets/xterm.css +285 -0
  19. ccoding-0.2.1/src/ccode/web/assets/xterm.js +2 -0
  20. ccoding-0.2.1/src/ccode/web/index.html +39 -0
  21. ccoding-0.2.1/src/ccode/web/style.css +179 -0
  22. ccoding-0.2.1/uv.lock +699 -0
  23. ccoding-0.1.0/PKG-INFO +0 -144
  24. ccoding-0.1.0/README.md +0 -104
  25. ccoding-0.1.0/src/ccode/__init__.py +0 -7
  26. ccoding-0.1.0/uv.lock +0 -31
  27. {ccoding-0.1.0 → ccoding-0.2.1}/.github/workflows/publish.yml +0 -0
  28. {ccoding-0.1.0 → ccoding-0.2.1}/.gitignore +0 -0
  29. {ccoding-0.1.0 → ccoding-0.2.1}/CLAUDE.md +0 -0
  30. {ccoding-0.1.0 → ccoding-0.2.1}/LICENSE +0 -0
  31. {ccoding-0.1.0 → ccoding-0.2.1}/screenshot.png +0 -0
  32. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/__main__.py +0 -0
  33. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/cli.py +0 -0
  34. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/env_schema.json +0 -0
  35. {ccoding-0.1.0 → ccoding-0.2.1}/src/ccode/logo.py +0 -0
ccoding-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,441 @@
1
+ Metadata-Version: 2.4
2
+ Name: ccoding
3
+ Version: 0.2.1
4
+ Summary: Curses-based Claude Code launcher
5
+ Project-URL: Homepage, https://github.com/8DE4732A/ccode
6
+ Project-URL: Repository, https://github.com/8DE4732A/ccode
7
+ Project-URL: Issues, https://github.com/8DE4732A/ccode/issues
8
+ Author: 8de4732a
9
+ License: MIT License
10
+
11
+ Copyright (c) 2025 8DE4732A
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: claude,claude-code,curses,launcher,tui
32
+ Classifier: Environment :: Console :: Curses
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: POSIX
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3 :: Only
37
+ Requires-Python: >=3.10
38
+ Requires-Dist: windows-curses; sys_platform == 'win32'
39
+ Provides-Extra: remote
40
+ Requires-Dist: fastapi; extra == 'remote'
41
+ Requires-Dist: pexpect; (sys_platform != 'win32') and extra == 'remote'
42
+ Requires-Dist: uvicorn[standard]; extra == 'remote'
43
+ Requires-Dist: websockets; extra == 'remote'
44
+ Provides-Extra: remote-client
45
+ Requires-Dist: pexpect; (sys_platform != 'win32') and extra == 'remote-client'
46
+ Requires-Dist: websockets; extra == 'remote-client'
47
+ Provides-Extra: remote-server
48
+ Requires-Dist: fastapi; extra == 'remote-server'
49
+ Requires-Dist: uvicorn[standard]; extra == 'remote-server'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # CCode Launcher (Curses UI)
53
+
54
+ 这是一个基于 curses 的 Claude Code 启动器,提供键盘全操作的终端界面,用于配置 Base URL、API Key、模型选择和常用开关,并直接启动 `claude` 命令。
55
+
56
+ 工具的目的是方便启动 claude code 时快速选择想要使用的模型。模型网关可以使用 litellm proxy 或者 CLI Proxy API。
57
+
58
+ ![](screenshot.png)
59
+
60
+ ## 功能特点
61
+
62
+ - 终端 curses UI,键盘全操作
63
+ - 主界面选择 OPUS / SONNET / HAIKU 的 owned_by 与 model_id
64
+ - 配置界面编辑 Base URL / API Key 与常用开关
65
+ - 自动保存配置到 `~/.ccode/config.json`
66
+ - 直接启动 `claude` 并传递额外参数
67
+ - Remote/Web 模式:通过 tmux 保留多个 Claude Code 会话,并在浏览器中选择和操作
68
+ - 支持本机 local hub,也支持公网中心 `ccode-remote-server` 聚合多台设备
69
+ - 动画 Logo(颜色渐变 / 流光 / 轻微波浪)
70
+
71
+ ## 安装
72
+
73
+ 推荐使用 [uv](https://github.com/astral-sh/uv) 安装为全局工具:
74
+
75
+ ```bash
76
+ uv tool install ccoding
77
+ ```
78
+
79
+ 如果需要 Remote/Web 功能,按使用场景安装对应 extra:
80
+
81
+ ```bash
82
+ uv tool install 'ccoding[remote-client]' # 客户端设备:运行 ccode,并连接中心 server
83
+ uv tool install 'ccoding[remote-server]' # 公网中心 server:运行 ccode-remote-server
84
+ uv tool install 'ccoding[remote]' # 同时包含 client/server remote 依赖
85
+ ```
86
+
87
+ 已经安装过基础版本时,可以用 `--reinstall` 重新安装带 extra 的版本:
88
+
89
+ ```bash
90
+ uv tool install --reinstall 'ccoding[remote]'
91
+ ```
92
+
93
+ 或使用 [pipx](https://pipx.pypa.io):
94
+
95
+ ```bash
96
+ pipx install ccoding
97
+ pipx install 'ccoding[remote]'
98
+ ```
99
+
100
+ ### uv tool extras 区别
101
+
102
+ `uv tool install 'ccoding[remote-client]'`、`uv tool install 'ccoding[remote-server]'` 和 `uv tool install 'ccoding[remote]'` 安装的都是同一个 Python 包 `ccoding`,因此都会安装基础命令入口。区别只在于额外依赖是否齐全,以及对应 remote 能力是否可用。
103
+
104
+ | 安装方式 | `ccode` 基础 TUI | `ccode-remote` | `ccode-remote-server` | 安装的额外依赖 | 适合场景 |
105
+ |---|---:|---:|---:|---|---|
106
+ | `uv tool install ccoding` | 可用 | 命令存在,但 remote 功能依赖不足 | 命令存在,但缺 server 依赖不能运行 | 无 | 只用模型选择 TUI |
107
+ | `uv tool install 'ccoding[remote-client]'` | 可用 | 可管理 client connector;local hub 可能缺 FastAPI/uvicorn | 命令存在,但缺 FastAPI/uvicorn 不能运行 | `pexpect`、`websockets` | 客户端设备:启动 Claude session 并连接中心 server |
108
+ | `uv tool install 'ccoding[remote-server]'` | 可用 | 命令存在,但 client/local 能力依赖不足 | 可运行 | `fastapi`、`uvicorn[standard]` | 只部署公网中心 server |
109
+ | `uv tool install 'ccoding[remote]'` | 可用 | 可用 | 可用 | `pexpect`、`websockets`、`fastapi`、`uvicorn[standard]` | 开发环境或单机全功能 |
110
+
111
+ 推荐选择:
112
+
113
+ - 只在本机选择模型并启动 Claude:`uv tool install ccoding`
114
+ - 这台机器是“客户端设备”,需要用 `ccode` 启动 remote session 并连接中心 server:`uv tool install 'ccoding[remote-client]'`
115
+ - 这台机器只负责运行公网中心 server:`uv tool install 'ccoding[remote-server]'`
116
+ - 不想区分角色,或开发调试需要本机同时跑 server 和 client:`uv tool install 'ccoding[remote]'`
117
+
118
+ 安装后直接运行:
119
+
120
+ ```bash
121
+ ccode
122
+ ccode --chrome # 传递额外参数给 claude
123
+ ccode-remote # 查看 remote hub / client connector 状态
124
+ ```
125
+
126
+ ## 开发者运行方式
127
+
128
+ 需要 Python >=3.10。基础 TUI 不再强制安装 remote 依赖。Remote/Web 模式需要额外依赖,并需要系统中已安装 `tmux` 和 `claude`;Windows 建议在 WSL 中使用 remote 模式。
129
+
130
+ ```bash
131
+ git clone https://github.com/8DE4732A/ccode
132
+ cd ccode
133
+ uv sync
134
+ uv run ccode
135
+ ```
136
+
137
+ 按需安装 remote extras:
138
+
139
+ ```bash
140
+ uv sync --extra remote-client # 客户端 connector:pexpect + websockets
141
+ uv sync --extra remote-server # 公网中心 server:FastAPI + uvicorn
142
+ uv sync --extra remote # 同时安装 client/server 依赖
143
+ ```
144
+
145
+ ## 快捷键(主界面)
146
+
147
+ - `↑ / ↓`:切换 OPUS / SONNET / HAIKU 行
148
+ - `← / →`:切换 owned_by / model_id 字段
149
+ - `a / d`:循环切换当前字段的可选项
150
+ - `b`:刷新模型列表
151
+ - `r`:切换 Remote/Web 模式
152
+ - `c`:进入配置界面
153
+ - `Enter`:校验并启动本地 `claude`;Remote/Web 模式开启时启动 remote session
154
+ - `q`:退出
155
+
156
+ > 提示:首次使用需要先在配置界面设置 Base URL 与 API Key,然后返回主界面按 `b` 获取模型列表。
157
+
158
+ ## 快捷键(配置界面)
159
+
160
+ - `↑ / ↓`:移动字段焦点
161
+ - `Enter / Space`:切换开关项
162
+ - 文本输入:编辑 BASE_URL / API_KEY、remote local/server URL/token/device/prefix 等字段
163
+ - `g`:在 Remote local token 或 server client token 字段重新生成访问 token
164
+ - `ESC`:自动保存并返回主界面
165
+
166
+ ## 配置文件
167
+
168
+ 配置自动保存在:
169
+
170
+ ```
171
+ ~/.ccode/config.json
172
+ ```
173
+
174
+ 示例结构:
175
+
176
+ ```json
177
+ {
178
+ "base_url": "http://127.0.0.1:8317",
179
+ "api_key": "",
180
+ "models": {
181
+ "opus": {"owned_by": null, "id": null},
182
+ "sonnet": {"owned_by": null, "id": null},
183
+ "haiku": {"owned_by": null, "id": null}
184
+ },
185
+ "toggles": {
186
+ "CLAUDE_CODE_ENABLE_TELEMETRY": "0",
187
+ "DISABLE_COST_WARNINGS": "1",
188
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
189
+ },
190
+ "remote": {
191
+ "enabled": false,
192
+ "mode": "local",
193
+ "session_name": "ccode-claude",
194
+ "reuse_session": true,
195
+ "local": {
196
+ "host": "127.0.0.1",
197
+ "port": 8765,
198
+ "token": ""
199
+ },
200
+ "server": {
201
+ "url": "",
202
+ "token": "",
203
+ "device_name": "",
204
+ "device_id": "",
205
+ "auto_connect": true,
206
+ "verify_tls": true
207
+ }
208
+ }
209
+ }
210
+ ```
211
+
212
+ ## Remote/Web 模式
213
+
214
+ Remote/Web 让 Claude Code 运行在 tmux session 中,浏览器通过 WebSocket attach 到这个 session。它有两种模式:
215
+
216
+ | 模式 | 浏览器访问 | session 所在位置 | 适合场景 |
217
+ |---|---|---|---|
218
+ | `local` | 直接访问本机 local hub | 当前这台机器 | 单机使用,或把这一台机器通过 tunnel 暴露出去 |
219
+ | `server` | 访问公网中心 `ccode-remote-server` | 各客户端设备本机 | 多设备、NAT 后设备、统一入口管理多个 sessions |
220
+
221
+ ### local 模式
222
+
223
+ local 模式会在本机启动一个共享 FastAPI hub。浏览器直接访问这个 hub,hub 再 attach 到本机 tmux session。
224
+
225
+ ```text
226
+ Browser
227
+ │ HTTP / WebSocket
228
+ ▼
229
+ Local ccode remote hub
230
+ │ pexpect attach
231
+ ▼
232
+ tmux session
233
+ │
234
+ ▼
235
+ claude
236
+ ```
237
+
238
+ 使用步骤:
239
+
240
+ 1. 安装完整 remote 或至少确保 local hub 依赖可用:
241
+
242
+ ```bash
243
+ uv tool install 'ccoding[remote]'
244
+ ```
245
+
246
+ 2. 运行 `ccode`,进入配置页:
247
+
248
+ - `MODE`:`local`
249
+ - `LOCAL HOST`:默认 `127.0.0.1`
250
+ - `LOCAL PORT`:默认 `8765`
251
+ - `LOCAL TOKEN`:手动输入,或在该字段按 `g` 生成
252
+
253
+ 3. 回到主界面,按 `r` 开启 Remote/Web,再按 `Enter` 启动 remote session。
254
+
255
+ 4. 浏览器打开终端输出的本地地址,输入 `LOCAL TOKEN`,选择 session 后进入 terminal。
256
+
257
+ local 模式默认只监听 `127.0.0.1`。终端只输出不带 token 的本地访问地址。浏览器打开页面后需要手动输入 token,前端会用 `sessionStorage` 做浏览器会话级缓存;关闭该浏览器会话后需要重新输入。所有 session list、session API 和 WebSocket 连接仍然需要 token。
258
+
259
+ 每个启用 Remote/Web 的 `ccode` 进程都会创建一个唯一 tmux session,session 名由配置里的 `session_name` 前缀、时间戳和进程号组成,例如 `ccode-claude-20260509-153022-12345`。本机只启动一个共享 remote hub,多个本地 `ccode` 进程会复用同一个 host/port/token。浏览器认证后会先显示 session 列表,选择某个 session 后进入 terminal,也可以返回列表重新选择。
260
+
261
+ 如果通过 Cloudflare Tunnel、Nginx、Caddy 等反向代理暴露 local hub,建议额外叠加 Cloudflare Access、Basic Auth 或 OAuth2 proxy。监听 `0.0.0.0` 会把所有 remote sessions 暴露给网络内可达主机,请保护好访问入口和 token。
262
+
263
+ ```bash
264
+ cloudflared tunnel --url http://127.0.0.1:8765
265
+ ```
266
+
267
+ local hub 日志写入 `~/.ccode/remote_server.log`,记录 hub 启停、session 注册、session API 和 WebSocket 连接状态,不记录 token。启动 hub 前如果日志超过 5 MiB 会自动轮转,默认保留 3 个历史文件(`.1`、`.2`、`.3`)。
268
+
269
+ ### server 模式和 `ccode-remote-server`
270
+
271
+ `ccode-remote-server` 是可部署到公网的中心 registry/router/relay。它不创建本地 PTY,也不会保存 Anthropic API key、模型配置、客户端环境变量或 terminal 内容;每台客户端继续负责自己的 tmux/Claude 会话,并通过出站 WebSocket 连接 server。
272
+
273
+ 整体结构:
274
+
275
+ ```text
276
+ Browser
277
+ │
278
+ │ HTTPS/WSS + admin token
279
+ ▼
280
+ ┌───────────────────────┐
281
+ │ ccode-remote-server │
282
+ │ registry/router/relay │
283
+ └───────────┬───────────┘
284
+ │ attach relay
285
+ ┌─────────────┼─────────────┐
286
+ │ │ │
287
+ ▼ ▼ ▼
288
+ ┌────────────┐ ┌────────────┐ ┌────────────┐
289
+ │ Laptop A │ │ Server B │ │ Desktop C │
290
+ │ connector │ │ connector │ │ connector │
291
+ │ tmux/claude│ │ tmux/claude│ │ tmux/claude│
292
+ └────────────┘ └────────────┘ └────────────┘
293
+ ```
294
+
295
+ 连接方向:
296
+
297
+ ```text
298
+ 客户端设备 ──出站 WebSocket──▶ ccode-remote-server ◀──浏览器访问── Browser
299
+ ```
300
+
301
+ server 不反连客户端,所以客户端可以在 NAT、家庭网络或公司内网后面。只要客户端能主动访问 server,就可以注册设备和暴露自己的 remote sessions。
302
+
303
+ #### server token
304
+
305
+ server token 不会自动生成,必须通过环境变量显式设置:
306
+
307
+ - `CCODE_REMOTE_SERVER_ADMIN_TOKEN`:浏览器 Web UI / `/api/*` / browser WebSocket 使用的管理 token。
308
+ - `CCODE_REMOTE_SERVER_CLIENT_TOKEN`:各设备客户端 connector 注册和心跳使用的 token。
309
+ - `CCODE_REMOTE_SERVER_HOST` / `CCODE_REMOTE_SERVER_PORT`:可选,默认监听 `127.0.0.1:8765`。
310
+
311
+ 启动中心 server:
312
+
313
+ ```bash
314
+ CCODE_REMOTE_SERVER_ADMIN_TOKEN="admin-secret" \
315
+ CCODE_REMOTE_SERVER_CLIENT_TOKEN="client-secret" \
316
+ ccode-remote-server --host 127.0.0.1 --port 8765
317
+ ```
318
+
319
+ 如果使用源码开发环境运行:
320
+
321
+ ```bash
322
+ CCODE_REMOTE_SERVER_ADMIN_TOKEN="admin-secret" \
323
+ CCODE_REMOTE_SERVER_CLIENT_TOKEN="client-secret" \
324
+ uv run --extra remote-server ccode-remote-server --host 127.0.0.1 --port 8765
325
+ ```
326
+
327
+ 浏览器访问 server 页面时输入 `admin-secret`。如果未设置 `CCODE_REMOTE_SERVER_ADMIN_TOKEN`,管理 API 会返回 401,页面上任何 token 都无法通过认证。
328
+
329
+ #### 客户端设备配置
330
+
331
+ 每台客户端设备需要安装 client extra:
332
+
333
+ ```bash
334
+ uv tool install 'ccoding[remote-client]'
335
+ ```
336
+
337
+ 然后运行 `ccode`,在配置页设置:
338
+
339
+ - `MODE`:`server`
340
+ - `SERVER URL`:中心 server 地址,例如 `http://127.0.0.1:8765`;如果只填 `127.0.0.1:8765`,会自动按 `http://127.0.0.1:8765` 处理
341
+ - `CLIENT TOKEN`:与 server 的 `CCODE_REMOTE_SERVER_CLIENT_TOKEN` 一致
342
+ - `DEVICE NAME`:设备显示名,可留空后由配置迁移填充 hostname
343
+ - `DEVICE ID`:稳定设备 ID,可留空后自动生成
344
+ - `AUTO CONNECT`:是否默认自动连接中心 server
345
+
346
+ 配置完成后,在主界面按 `r` 开启 Remote/Web,再按 `Enter` 启动 remote session。server 模式会注册本地 tmux session,并确保后台 client connector 运行。浏览器打开中心 server 后即可看到所有在线设备和 sessions。
347
+
348
+ 也可以用命令检查和管理客户端 connector:
349
+
350
+ ```bash
351
+ ccode-remote client status
352
+ ccode-remote client start
353
+ ccode-remote client restart
354
+ ccode-remote client stop
355
+ ```
356
+
357
+ #### attach 数据流
358
+
359
+ 浏览器点击某个设备上的 session 时,server 会创建一次性短生命周期 `attach_id`,通知目标客户端主动建立 attach WebSocket,然后在浏览器和客户端之间转发 terminal JSON 帧。
360
+
361
+ ```text
362
+ 1. Browser ── WS /ws/devices/{device_id}/sessions/{session_id} ──▶ Server
363
+ 2. Server ── attach_request(attach_id, session_id) ─────────────▶ Client connector
364
+ 3. Client ── WS /client/attach/{attach_id} ─────────────────────▶ Server
365
+ 4. Server ◀──────────── relay input/output/resize ─────────────▶ Browser
366
+ 5. Client connector ── pexpect ──▶ local tmux session ──▶ claude
367
+ ```
368
+
369
+ server 只做 registry/router/relay,不保存 terminal frame data,不保存 Anthropic API key,不保存模型配置。`cwd`、tmux session 名、创建时间等 metadata 会用于 session 列表展示。
370
+
371
+ #### Cloudflare Tunnel / 反向代理
372
+
373
+ 如果用 Cloudflare Tunnel 暴露中心 server,只需要 tunnel server 这一处入口,多台客户端设备都配置同一个 `SERVER URL` 和 `CLIENT TOKEN`:
374
+
375
+ ```bash
376
+ cloudflared tunnel --url http://127.0.0.1:8765
377
+ ```
378
+
379
+ 生产环境建议只使用 HTTPS/WSS;如果 `SERVER URL` 使用 `http://`,客户端会提示明文连接风险。建议再叠加 Cloudflare Access、Basic Auth 或 OAuth2 proxy。
380
+
381
+ ### remote 管理命令
382
+
383
+ `ccode-remote` 会根据当前配置的 `remote.mode` 自动管理 local hub 或 client connector;也可以显式指定 `local` / `client`:
384
+
385
+ ```bash
386
+ ccode-remote
387
+ ccode-remote status
388
+ ccode-remote start
389
+ ccode-remote restart
390
+ ccode-remote stop
391
+
392
+ ccode-remote local status
393
+ ccode-remote local start
394
+ ccode-remote local stop
395
+
396
+ ccode-remote client status
397
+ ccode-remote client start
398
+ ccode-remote client restart
399
+ ccode-remote client stop
400
+ ```
401
+
402
+ 日志和状态文件:
403
+
404
+ | 文件 | 用途 |
405
+ |---|---|
406
+ | `~/.ccode/remote_sessions.json` | 本机 session registry,只记录 tmux session、cwd、args、创建时间和 owner pid |
407
+ | `~/.ccode/remote_server.log` | local hub 日志 |
408
+ | `~/.ccode/remote_client.log` | server 模式 client connector 日志 |
409
+ | `~/.ccode/remote_hub.pid` | local hub 后台进程 pid |
410
+ | `~/.ccode/remote_client.pid` | client connector 后台进程 pid |
411
+
412
+ 浏览器和多个本地终端可以同时 attach 到同一个 tmux session,输入会互相影响,这是预期行为。可用 `Ctrl+B` 然后 `D` 从本地终端 detach;remote hub 或 client connector 会独立留在后台运行,tmux session 不会因为浏览器断开而被 kill。
413
+
414
+ ## 工作原理
415
+
416
+ 基础启动流程:
417
+
418
+ ```text
419
+ ~/.ccode/config.json
420
+ │
421
+ ▼
422
+ ccode curses UI ── fetch /v1/models ──▶ LiteLLM proxy / CLI Proxy API
423
+ │
424
+ ▼
425
+ 选择 OPUS / SONNET / HAIKU model_id
426
+ │
427
+ ▼
428
+ build_env() 注入环境变量
429
+ │
430
+ ▼
431
+ subprocess.run(["claude", ...])
432
+ ```
433
+
434
+ 1. 从 `~/.ccode/config.json` 读取配置(首次运行自动生成)。
435
+ 2. 根据 Base URL + API Key 拉取模型列表。
436
+ 3. 选择 OPUS / SONNET / HAIKU 的 owned_by / model_id。
437
+ 4. 启动 `claude`,并注入相关环境变量。
438
+
439
+ ## 许可证
440
+
441
+ MIT