@logicseek/hello-cc 0.1.9 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/README.md +50 -3
  3. package/README.zh-CN.md +48 -3
  4. package/bin/hcc.mjs +3 -5656
  5. package/docs/README.md +8 -0
  6. package/docs/README.zh-CN.md +6 -0
  7. package/docs/architecture.md +29 -18
  8. package/docs/architecture.zh-CN.md +20 -10
  9. package/docs/commands.md +13 -4
  10. package/docs/commands.zh-CN.md +13 -4
  11. package/docs/guide.md +97 -3
  12. package/docs/guide.zh-CN.md +89 -2
  13. package/lib/cli/app.mjs +644 -0
  14. package/lib/cli/commands/coordination.mjs +249 -0
  15. package/lib/cli/commands/doctor.mjs +81 -0
  16. package/lib/cli/commands/gc.mjs +1002 -0
  17. package/lib/cli/commands/hook.mjs +205 -0
  18. package/lib/cli/commands/install.mjs +294 -0
  19. package/lib/cli/commands/lifecycle.mjs +101 -0
  20. package/lib/cli/commands/lock.mjs +197 -0
  21. package/lib/cli/commands/misc.mjs +76 -0
  22. package/lib/cli/commands/msg.mjs +152 -0
  23. package/lib/cli/commands/peer.mjs +249 -0
  24. package/lib/cli/commands/query.mjs +96 -0
  25. package/lib/cli/commands/run.mjs +463 -0
  26. package/lib/cli/commands/task.mjs +405 -0
  27. package/lib/cli/commands/team.mjs +131 -0
  28. package/lib/cli/commands/tmux.mjs +838 -0
  29. package/lib/cli/commands/up.mjs +135 -0
  30. package/lib/cli-args.mjs +16 -2
  31. package/lib/coordination-state.mjs +112 -51
  32. package/lib/core/coordination/automation.mjs +5 -8
  33. package/lib/core/coordination/clock-safety.mjs +323 -0
  34. package/lib/core/coordination/event-retention.mjs +17 -0
  35. package/lib/core/coordination/gc-plan.mjs +614 -0
  36. package/lib/core/coordination/lease-renewal.mjs +102 -0
  37. package/lib/core/coordination/lock-evidence.mjs +77 -0
  38. package/lib/core/coordination/optimistic-evidence.mjs +26 -0
  39. package/lib/core/coordination/tasks.mjs +156 -36
  40. package/lib/core/peers/evidence-runtime.mjs +312 -0
  41. package/lib/core/peers/evidence.mjs +103 -0
  42. package/lib/core/peers/hook-owner.mjs +32 -0
  43. package/lib/core/peers/liveness.mjs +44 -4
  44. package/lib/core/peers/peer-helpers.mjs +121 -0
  45. package/lib/core/peers/session.mjs +8 -2
  46. package/lib/core/peers/tmux-safety.mjs +290 -0
  47. package/lib/core/sessions/launch.mjs +13 -1
  48. package/lib/db/connection.mjs +104 -0
  49. package/lib/db/events.mjs +34 -0
  50. package/lib/db/migration-backup.mjs +225 -0
  51. package/lib/db/schema.mjs +102 -5
  52. package/lib/db/stores/peers.mjs +34 -0
  53. package/lib/integrations/peers/identity.mjs +62 -16
  54. package/lib/integrations/shims/script.mjs +111 -9
  55. package/lib/process/identity.mjs +222 -0
  56. package/lib/process/pty-lifecycle.mjs +149 -0
  57. package/lib/runtime/buffer-directory-lease.mjs +48 -0
  58. package/lib/runtime/buffer-evidence.mjs +336 -0
  59. package/lib/runtime/buffer-gc-protocol.mjs +167 -0
  60. package/lib/runtime/buffer-gc.mjs +270 -0
  61. package/lib/runtime/client.mjs +63 -7
  62. package/lib/runtime/fatal-shutdown.mjs +54 -0
  63. package/lib/runtime/project-path.mjs +139 -0
  64. package/lib/runtime/projects.mjs +320 -40
  65. package/lib/runtime/state.mjs +227 -27
  66. package/lib/shared/cleanup-error.mjs +54 -0
  67. package/lib/shared/clock-grace.mjs +106 -0
  68. package/lib/shared/errors.mjs +9 -0
  69. package/lib/shared/file-lock.mjs +377 -0
  70. package/lib/shared/json-file.mjs +6 -2
  71. package/lib/shared/redact.mjs +60 -0
  72. package/lib/shared/socket-lock-worker.mjs +250 -0
  73. package/lib/terminal/tmux.mjs +131 -27
  74. package/lib/tmux.mjs +4 -0
  75. package/lib/ui/help.mjs +53 -15
  76. package/lib/web/api-version.mjs +42 -0
  77. package/lib/web/auto-attach.mjs +185 -0
  78. package/lib/web/buffer-gc-runtime.mjs +175 -0
  79. package/lib/web/cookie-auth.mjs +119 -0
  80. package/lib/web/external-sessions.mjs +254 -0
  81. package/lib/web/http-routes.mjs +542 -0
  82. package/lib/web/http.mjs +135 -6
  83. package/lib/web/liveness-reaper.mjs +145 -0
  84. package/lib/web/peer-actions.mjs +132 -23
  85. package/lib/web/project-contexts.mjs +183 -0
  86. package/lib/web/pty-sessions.mjs +203 -0
  87. package/lib/web/runtime-main.mjs +717 -0
  88. package/lib/web/runtime.mjs +91 -36
  89. package/lib/web/session-serialize.mjs +0 -0
  90. package/lib/web/startup.mjs +335 -0
  91. package/lib/web/tls.mjs +365 -0
  92. package/lib/web/tmux-sessions.mjs +1361 -0
  93. package/lib/web/tmux-stream.mjs +166 -0
  94. package/lib/web/ui-template.mjs +152 -20
  95. package/package.json +6 -3
  96. package/scripts/check-free-identifiers.mjs +290 -0
  97. package/scripts/regression.mjs +5404 -273
  98. package/docs/architecture-split-review.md +0 -217
  99. package/docs/layout-split-stack-audit.md +0 -298
package/docs/README.md CHANGED
@@ -3,6 +3,14 @@
3
3
  Start with the [project README](../README.md) when you only need the project
4
4
  summary and first command. Use these docs when you need more detail.
5
5
 
6
+ The 1.0.0 contract is breaking: schema v7 has no downgrade path, migrations
7
+ create a verified backup, provider peer IDs changed without legacy remapping,
8
+ and protected routes use Runtime API v2. Process evidence controls liveness and
9
+ only unknown evidence gets 120 seconds of grace; `gc --history` is opt-in.
10
+ Use `--tls` directly, or `--trust-proxy` with a fixed `--proxy-origin`.
11
+ Plaintext LAN operation and
12
+ authenticated selection of any existing server directory are accepted risks.
13
+
6
14
  ## User Docs
7
15
 
8
16
  - [User Guide](guide.md): install, start, Web console, coordination semantics,
@@ -3,6 +3,12 @@
3
3
  只需要项目简介和第一条命令时,先看[仓库 README](../README.zh-CN.md)。
4
4
  需要更多细节时,再看下面的文档。
5
5
 
6
+ 1.0.0 是 breaking release:schema v7 不支持降级,迁移前会生成并校验备份;
7
+ provider peer ID 已变更且不会映射旧 ID;受保护接口使用 Runtime API v2。存活由
8
+ 进程证据决定,只有 unknown 证据获得 120 秒宽限;`gc --history` 必须显式启用。
9
+ 可以直接使用 `--tls`,或让 `--trust-proxy` 固定 `--proxy-origin`。默认可信内网明文监听,以及已认证
10
+ 浏览器可选择服务器上任意已存在目录,是明确接受的风险。
11
+
6
12
  ## 用户文档
7
13
 
8
14
  - [用户指南](guide.zh-CN.md):安装、启动、Web 控制台、协作语义、工作流、稳定
@@ -31,19 +31,29 @@ architectural idea: split by boundary, not by convenience.
31
31
 
32
32
  ## Current Pressure Points
33
33
 
34
- The codebase has already extracted many focused modules under `lib/`, including
35
- schema, runtime state, task/message stores, peer identity, provider command
36
- building, tmux helpers, Web HTTP helpers, and render helpers.
34
+ The 2026-08 monolith split is complete: `bin/hcc.mjs` is a thin entrypoint that
35
+ imports `lib/cli/app.mjs`. All composition (constants, shared helpers, command
36
+ factory wiring, dispatch, `main()`) lives in `lib/cli/app.mjs`; command groups
37
+ live in `lib/cli/commands/`; GC lives in `lib/cli/commands/gc.mjs` plus
38
+ `lib/core/coordination/gc-plan.mjs`; runtime evidence helpers live in
39
+ `lib/core/peers/evidence-runtime.mjs`.
40
+
41
+ The former 3100-line `cmdWeb()` closure is fully decomposed into `lib/web/`
42
+ subsystem modules, each behind a `create*(deps)` factory:
43
+ `project-contexts.mjs`, `external-sessions.mjs`, `liveness-reaper.mjs`,
44
+ `buffer-gc-runtime.mjs`, `tmux-sessions.mjs`, `auto-attach.mjs`,
45
+ `pty-sessions.mjs`, `http-routes.mjs`, `startup.mjs`, `cookie-auth.mjs`,
46
+ `session-serialize.mjs`, `tmux-stream.mjs`. `runtime-main.mjs` is now the
47
+ composition root (option parsing, factory wiring in dependency order, the
48
+ WebSocket terminal handler, server setup, and shutdown).
37
49
 
38
50
  The remaining structural pressure is mostly:
39
51
 
40
- - `bin/hcc.mjs` still contains command dispatch, command handlers, Web server
41
- setup, HTTP routes, WebSocket terminal handling, tmux session management, PTY
42
- session management, external buffer adoption, and shutdown cleanup.
43
- - `cmdWeb()` is the largest mixed boundary. It should be treated as a Web
44
- runtime subsystem, not as a normal CLI command body.
45
52
  - `scripts/regression.mjs` is a valuable full regression gate, but it should
46
53
  eventually become a runner over domain-specific regression modules.
54
+ - `lib/web/tmux-sessions.mjs` is the largest subsystem module (~1300 lines);
55
+ its kill/rebind planning could split further once tmux GC command handling
56
+ and session lifecycle settle.
47
57
 
48
58
  ## Target Layout
49
59
 
@@ -174,10 +184,11 @@ scripts/
174
184
 
175
185
  ## Boundary Rules
176
186
 
177
- `bin/hcc.mjs` should become a thin entrypoint. It may parse global arguments,
178
- create the root context, invoke dispatch, and convert top-level errors to CLI
179
- output. It should not own Web routing, DB schema, tmux streaming, provider
180
- command construction, or task state machines.
187
+ `bin/hcc.mjs` is a thin entrypoint: it imports `runCli()` from
188
+ `lib/cli/app.mjs` and nothing else. Argument parsing, context creation,
189
+ dispatch, and top-level error conversion live in `lib/cli/app.mjs`. Neither
190
+ file should own Web routing, DB schema, tmux streaming, provider command
191
+ construction, or task state machines.
181
192
 
182
193
  `lib/cli/` owns command parsing and command handlers. A command handler can
183
194
  open a database, call stores or core services, and print results. It should not
@@ -295,13 +306,13 @@ npm package contents stable unless the task explicitly says otherwise.
295
306
  `messages`, `help`, `state-render`, and release helpers. Keep compatibility
296
307
  re-export files temporarily if the import churn becomes too large.
297
308
 
298
- 3. Split the Web runtime by subsystem.
299
- Extract project selection, session manager, Web routes, WebSocket terminal
300
- handling, tmux stream, PTY session, and external buffer adoption from
301
- `cmdWeb()` in separate commits.
309
+ 3. Split the Web runtime by subsystem. (Done in 2026-08: twelve subsystem
310
+ modules under `lib/web/`, each behind a `create*(deps)` factory;
311
+ `runtime-main.mjs` is the composition root with the WebSocket terminal
312
+ handler and shutdown.)
302
313
 
303
- 4. Make `bin/hcc.mjs` a thin entrypoint.
304
- Move dispatch and command groups under `lib/cli/commands/`.
314
+ 4. Make `bin/hcc.mjs` a thin entrypoint. (Done in 2026-08: 6 lines, delegating
315
+ to `lib/cli/app.mjs`; command groups live under `lib/cli/commands/`.)
305
316
 
306
317
  5. Split regression tests by domain.
307
318
  Keep `npm test` as the single full regression command, but make it call
@@ -31,13 +31,22 @@ store、hooks、config、execution adapter 分开。hello-cc 不需要 Rust crat
31
31
  store、peer identity、provider command builder、tmux helper、Web HTTP helper
32
32
  和 render helper。
33
33
 
34
+ 2026-08 的单体拆分已完成:`bin/hcc.mjs` 是薄入口(6 行),只导入
35
+ `lib/cli/app.mjs`。全部装配(常量、共享助手、命令工厂接线、dispatch、
36
+ `main()`)在 `lib/cli/app.mjs`;命令组在 `lib/cli/commands/`;Web runtime 在
37
+ `lib/web/`(startup、runtime-main、cookie-auth、session-serialize、
38
+ tmux-stream);GC 在 `lib/cli/commands/gc.mjs` 与
39
+ `lib/core/coordination/gc-plan.mjs`;运行时证据助手在
40
+ `lib/core/peers/evidence-runtime.mjs`。
41
+
34
42
  剩余结构压力主要在:
35
43
 
36
- - `bin/hcc.mjs` 仍包含 command dispatch、command handler、Web server setup、
37
- HTTP routes、WebSocket terminal、tmux session 管理、PTY session 管理、
38
- external buffer adoption 和 shutdown cleanup。
39
- - `cmdWeb()` 是最大的混合边界。它应该被视为 Web runtime 子系统,而不是普通
40
- CLI command body。
44
+ - (已于 2026-08 完成)原 3100 行 `cmdWeb()` 闭包已全部分解为 `lib/web/` 下的
45
+ 子系统模块,各自通过 `create*(deps)` 工厂注入依赖:project-contexts、
46
+ external-sessions、liveness-reaper、buffer-gc-runtime、tmux-sessions、
47
+ auto-attach、pty-sessions、http-routes、startup、cookie-auth、
48
+ session-serialize、tmux-stream。`runtime-main.mjs` 现在是组合根(参数解析、
49
+ 按依赖序装配工厂、WebSocket 终端处理、server 搭建与 shutdown)。
41
50
  - `scripts/regression.mjs` 是有价值的全量回归入口,但后续应该变成一个调用领域
42
51
  regression module 的 runner。
43
52
 
@@ -170,9 +179,10 @@ scripts/
170
179
 
171
180
  ## 边界规则
172
181
 
173
- `bin/hcc.mjs` 应该变成很薄的入口。它可以解析全局参数、创建 root context、调用
174
- dispatch,并把顶层错误转换为 CLI 输出。它不应该拥有 Web routing、DB schema、
175
- tmux streaming、provider command construction 或 task state machine。
182
+ `bin/hcc.mjs` 是薄入口:只从 `lib/cli/app.mjs` 导入 `runCli()`。参数解析、
183
+ context 创建、dispatch 和顶层错误转换都在 `lib/cli/app.mjs`。两个文件都
184
+ 不应该拥有 Web routing、DB schema、tmux streaming、provider command
185
+ construction 或 task state machine。
176
186
 
177
187
  `lib/cli/` 负责命令解析和命令处理器。命令处理器可以打开数据库、调用 store 或
178
188
  core service,并打印结果。当逻辑可以放进 `core`、`runtime`、`terminal`、`web`
@@ -283,8 +293,8 @@ release -> shared
283
293
  分提交从 `cmdWeb()` 抽出 project selection、session manager、Web routes、
284
294
  WebSocket terminal、tmux stream、PTY session 和 external buffer adoption。
285
295
 
286
- 4. 让 `bin/hcc.mjs` 变成薄入口。
287
- 把 dispatch 和 command groups 移到 `lib/cli/commands/`。
296
+ 4. 让 `bin/hcc.mjs` 变成薄入口。(2026-08 已完成:6 行,委托给
297
+ `lib/cli/app.mjs`;命令组在 `lib/cli/commands/`。)
288
298
 
289
299
  5. 按领域拆 regression。
290
300
  保持 `npm test` 是唯一全量回归命令,但让它调用 `scripts/regression/` 下的
package/docs/commands.md CHANGED
@@ -4,6 +4,12 @@ Use `hcc --help` for the current top-level command list. Most subcommands also
4
4
  accept `--help`, for example `hcc update --help`, `hcc peer --help`, and
5
5
  `hcc task --help`.
6
6
 
7
+ Version 1.0.0 uses schema v7 (no downgrade), verified pre-migration backups,
8
+ new full-session provider peer IDs without old-ID remapping, and Runtime API v2.
9
+ Process evidence controls liveness with 120 seconds only for unknown evidence;
10
+ history cleanup requires `gc --history`. The default plaintext LAN listener and
11
+ authenticated access to any existing server directory are accepted risks.
12
+
7
13
  ## Install Maintenance
8
14
 
9
15
  ```text
@@ -18,16 +24,16 @@ current project's `.hello-cc` data and guidance blocks.
18
24
  ## Start And Stop
19
25
 
20
26
  ```text
21
- hcc web [--host HOST] [--port N] [--token TEXT] [--local] [--no-token] [--no-discover] [--no-guidance]
27
+ hcc web [--host HOST] [--port N] [--token TEXT] [--local] [--tls] [--trust-proxy --proxy-origin ORIGIN] [--no-token] [--no-discover] [--no-guidance]
22
28
  hcc down
23
29
  hcc up [--no-discover] [--no-guidance]
24
30
  ```
25
31
 
26
32
  `hcc web` is the default entry. It initializes coordination, installs hooks and
27
33
  shims, starts or reuses the Web console, and returns the terminal to you. Bare
28
- `hcc web` listens on `0.0.0.0` and uses a saved URL token, generating one on
29
- first use. Use `--local` to bind only `127.0.0.1`, `--token` or `HCC_WEB_TOKEN`
30
- to replace the saved token, and
34
+ `hcc web` listens on `0.0.0.0` and generates a URL token for that runtime.
35
+ Use `--local` to bind only `127.0.0.1`, `--token` or `HCC_WEB_TOKEN` to set an
36
+ explicit token, `HCC_RUNTIME_CA` to trust a private HTTPS Runtime API CA, and
31
37
  `--no-token` only in trusted local/test environments. Use `hcc up` only when you
32
38
  want coordination without the Web console or shims. Provider shims only join
33
39
  projects with a local `.hello-cc/runtime.json` from `hcc web`; they do not use a
@@ -103,6 +109,7 @@ hcc task takeover [--peer ID] --id N --reason TEXT [--policy any|blocked|stale|b
103
109
  hcc task next [--peer ID] [--force] [--count N]
104
110
  hcc task create --title TEXT --parent N [--team-role ROLE]
105
111
  hcc task update [--peer ID] --id N --status running|review|blocked|done|abandoned [--summary TEXT] [--body TEXT] [--to ID]
112
+ hcc task running|review|blocked|abandoned [--peer ID] --id N [--summary TEXT] [--body TEXT] [--to ID]
106
113
  hcc task done [--peer ID] --id N --summary TEXT
107
114
  ```
108
115
 
@@ -121,6 +128,8 @@ another owner; it records the previous owner, requires a reason, and notifies
121
128
  them. Add `--policy blocked`, `stale`, or `blocked-or-stale` when takeover
122
129
  should only proceed under that auditable precondition. The default policy is
123
130
  `any` for compatibility.
131
+ Use `task running`, `task review`, `task blocked`, or `task abandoned` as
132
+ shortcuts for `task update --status STATUS`.
124
133
 
125
134
  ## Teams
126
135
 
@@ -3,6 +3,11 @@
3
3
  使用 `hcc --help` 查看当前顶层命令列表。大多数子命令也支持 `--help`,
4
4
  例如 `hcc update --help`、`hcc peer --help` 和 `hcc task --help`。
5
5
 
6
+ 1.0.0 使用 schema v7(不支持降级)、经校验的迁移前备份、不会映射旧 ID 的
7
+ 完整 session provider peer ID,以及 Runtime API v2。进程证据决定存活,只有
8
+ unknown 证据获得 120 秒宽限;历史清理必须显式使用 `gc --history`。默认可信
9
+ 内网明文监听和已认证浏览器访问任意已存在服务器目录,是明确接受的风险。
10
+
6
11
  ## 安装维护
7
12
 
8
13
  ```text
@@ -17,15 +22,16 @@ hcc uninstall [--purge --yes]
17
22
  ## 启动和停止
18
23
 
19
24
  ```text
20
- hcc web [--host HOST] [--port N] [--token TEXT] [--local] [--no-token] [--no-discover] [--no-guidance]
25
+ hcc web [--host HOST] [--port N] [--token TEXT] [--local] [--tls] [--trust-proxy --proxy-origin ORIGIN] [--no-token] [--no-discover] [--no-guidance]
21
26
  hcc down
22
27
  hcc up [--no-discover] [--no-guidance]
23
28
  ```
24
29
 
25
30
  `hcc web` 是默认入口。它会初始化协作状态,安装 hooks 和 shims,启动或复用
26
- Web 控制台,然后把终端还给你。裸 `hcc web` 会监听 `0.0.0.0` 并使用固定
27
- URL token;首次使用时自动生成并保存。用 `--local` 可只绑定 `127.0.0.1`,
28
- 用 `--token` 或 `HCC_WEB_TOKEN` 可替换保存的 token,只有在可信本地/测试环境才使用 `--no-token`。
31
+ Web 控制台,然后把终端还给你。裸 `hcc web` 会监听 `0.0.0.0`,并为本次
32
+ runtime 生成 URL token。用 `--local` 可只绑定 `127.0.0.1`,用 `--token` 或
33
+ `HCC_WEB_TOKEN` 可设置显式 token;私有 HTTPS Runtime API CA 用
34
+ `HCC_RUNTIME_CA` 指定。只有在可信本地/测试环境才使用 `--no-token`。
29
35
  只想使用本地协作、不需要 Web 或 shims 时,再使用 `hcc up`。provider shim 只会加入
30
36
  已经由 `hcc web` 生成本地 `.hello-cc/runtime.json` 的项目,不会使用全局 runtime
31
37
  去管理任意目录。
@@ -96,6 +102,7 @@ hcc task takeover [--peer ID] --id N --reason TEXT [--policy any|blocked|stale|b
96
102
  hcc task next [--peer ID] [--force] [--count N]
97
103
  hcc task create --title TEXT --parent N [--team-role ROLE]
98
104
  hcc task update [--peer ID] --id N --status running|review|blocked|done|abandoned [--summary TEXT] [--body TEXT] [--to ID]
105
+ hcc task running|review|blocked|abandoned [--peer ID] --id N [--summary TEXT] [--body TEXT] [--to ID]
99
106
  hcc task done [--peer ID] --id N --summary TEXT
100
107
  ```
101
108
 
@@ -110,6 +117,8 @@ dispatch` 是显式的一步分发:创建或指定已有任务并分配给目
110
117
  填写 reason,会记录原 owner 并通知对方。需要更保守时,可加 `--policy blocked`、
111
118
  `stale` 或 `blocked-or-stale`,要求任务符合可审计的阻塞/陈旧条件后才允许接管。
112
119
  默认 policy 仍是 `any`,以保持兼容。
120
+ `task running`、`task review`、`task blocked` 和 `task abandoned` 是
121
+ `task update --status STATUS` 的便捷写法。
113
122
 
114
123
  ## 团队
115
124
 
package/docs/guide.md CHANGED
@@ -3,14 +3,107 @@
3
3
  This guide covers the practical workflow for installing, starting, and using
4
4
  hello-cc. For a compact command list, use the [Command Reference](commands.md).
5
5
 
6
+ ## v1 Upgrade Contract
7
+
8
+ Version 1.0.0 upgrades to schema v7 after a verified pre-migration backup and
9
+ does not support downgrade. Provider peer IDs changed without legacy remapping;
10
+ protected routes require Runtime API v2. Liveness is process-evidence-first and
11
+ only unknown evidence receives 120 seconds of grace. History GC requires
12
+ `--history`. Use `--tls`, or `--trust-proxy --proxy-origin ORIGIN`, when
13
+ encryption is required. Plaintext trusted-LAN mode and authenticated selection
14
+ of any existing server directory remain accepted risks.
15
+
16
+ ### Restoring a pre-migration backup
17
+
18
+ hello-cc keeps at most five verified migration backups per database. If a v1
19
+ migration must be rolled back, first stop the Web runtime and every hello-cc or
20
+ provider process that can still access that project. Validate the selected
21
+ backup, preserve the failed database and its WAL/SHM files under new names, then
22
+ publish a private copy of the backup:
23
+
24
+ ```bash
25
+ db=/path/to/project/.hello-cc/mesh.db
26
+ backup=/path/to/project/.hello-cc/mesh.db.pre-v6-to-v7.<timestamp>.<suffix>.bak
27
+ sqlite3 "$backup" 'PRAGMA quick_check;'
28
+ cp -p "$backup" "$db.restore"
29
+ chmod 600 "$db.restore"
30
+ mv "$db" "$db.failed-v7.<recovery-id>"
31
+ test ! -e "$db-wal" || mv "$db-wal" "$db-wal.failed-v7.<recovery-id>"
32
+ test ! -e "$db-shm" || mv "$db-shm" "$db-shm.failed-v7.<recovery-id>"
33
+ mv "$db.restore" "$db"
34
+ ```
35
+
36
+ The check must print `ok`. Keep the renamed files until the restored project has
37
+ been verified. Starting v1 again will migrate the restored database to schema
38
+ v7; using the restored pre-v1 database with an older hello-cc release is outside
39
+ the supported downgrade contract.
40
+
6
41
  ## Install, Update, And Uninstall
7
42
 
43
+ ### Prerequisites
44
+
45
+ Install Node.js 24 or newer from the official Node.js packages or a Node
46
+ version manager. Browser-controllable terminals also require `tmux`:
47
+
48
+ ```bash
49
+ # Debian / Ubuntu
50
+ sudo apt-get update
51
+ sudo apt-get install -y tmux
52
+ # Fedora / RHEL
53
+ sudo dnf install -y tmux
54
+ # Older RHEL / CentOS
55
+ sudo yum install -y tmux
56
+ # Alpine
57
+ sudo apk add tmux
58
+ # Arch Linux
59
+ sudo pacman -S --needed tmux
60
+ # openSUSE
61
+ sudo zypper install tmux
62
+ # macOS only
63
+ brew install tmux
64
+ ```
65
+
66
+ On Linux, use the distribution package manager, not Homebrew. A root shell can
67
+ omit `sudo`. WSL follows the matching Linux distribution instructions inside
68
+ WSL; native Windows shells are not supported.
69
+
70
+ `hcc web` can attempt to install tmux when a supported package manager and
71
+ sufficient privileges are available. Manual installation is the deterministic
72
+ choice for servers, containers, and non-interactive sudo configurations.
73
+
74
+ ### Install And Verify
75
+
8
76
  Install hello-cc globally:
9
77
 
10
78
  ```bash
11
79
  npm install -g @logicseek/hello-cc
12
80
  ```
13
81
 
82
+ If npm reports `EACCES`, use a Node version manager or configure a user-owned
83
+ npm prefix. Do not use `sudo npm install -g`, because it can create root-owned
84
+ package and configuration files.
85
+
86
+ Verify every prerequisite and the installed CLI:
87
+
88
+ ```bash
89
+ node --version
90
+ npm --version
91
+ tmux -V
92
+ hcc --version
93
+ hcc --help
94
+ ```
95
+
96
+ The Node version must start with `v24` or a newer major. Every command above
97
+ must exit successfully before starting a managed terminal.
98
+
99
+ To avoid a global install, use:
100
+
101
+ ```bash
102
+ npx @logicseek/hello-cc web
103
+ ```
104
+
105
+ ### Update And Uninstall
106
+
14
107
  Update an existing global install:
15
108
 
16
109
  ```bash
@@ -241,8 +334,8 @@ Start local and LAN-visible control with token authentication:
241
334
  hcc web
242
335
  ```
243
336
 
244
- Bare `hcc web` stores its generated token and reuses it across restarts. Set a
245
- token explicitly when you want to replace the saved value:
337
+ Bare `hcc web` generates a new token for that runtime and does not persist it.
338
+ Set a token explicitly when you need a stable operator-managed value:
246
339
 
247
340
  ```bash
248
341
  HCC_WEB_TOKEN='choose-a-long-token' hcc web --port 8787
@@ -370,7 +463,8 @@ hcc lock release --resource vllm/router
370
463
  | `HCC_PEER` | default peer identity |
371
464
  | `HCC_ROOT` | override project root |
372
465
  | `HCC_DB` | override database path |
373
- | `HCC_WEB_TOKEN` | replace and save the stable web access token |
466
+ | `HCC_WEB_TOKEN` | set an explicit web access token |
467
+ | `HCC_RUNTIME_CA` | CA file for an `HCC_RUNTIME_URL=https` endpoint |
374
468
  | `HCC_RUNTIME_URL` | direct runtime URL |
375
469
  | `HCC_NO_AUTO_INSTALL_TMUX=1` | disable tmux auto-install, mainly for tests |
376
470
 
@@ -3,14 +3,100 @@
3
3
  这份文档说明安装、启动和日常使用流程。紧凑命令清单见
4
4
  [命令参考](commands.zh-CN.md)。
5
5
 
6
+ ## v1 升级契约
7
+
8
+ 1.0.0 会在生成并校验迁移前备份后升级到 schema v7,且不支持降级。provider
9
+ peer ID 已变更,不会映射旧 ID;受保护接口要求 Runtime API v2。存活判断以进程
10
+ 证据为先,只有 unknown 证据获得 120 秒宽限。历史 GC 必须显式使用
11
+ `--history`。需要加密时使用 `--tls`,或
12
+ `--trust-proxy --proxy-origin ORIGIN`。可信内网明文模式和已认证浏览器选择任意
13
+ 已存在服务器目录,仍是明确接受的风险。
14
+
15
+ ### 从迁移前备份恢复
16
+
17
+ hello-cc 为每个数据库最多保留 5 份经校验的迁移备份。如果必须回退一次 v1
18
+ 迁移,先停止 Web runtime,以及所有仍可能访问该项目的 hello-cc/provider 进程。
19
+ 校验选定备份,把失败数据库及其 WAL/SHM 文件改名保留,再发布备份的私有副本:
20
+
21
+ ```bash
22
+ db=/path/to/project/.hello-cc/mesh.db
23
+ backup=/path/to/project/.hello-cc/mesh.db.pre-v6-to-v7.<timestamp>.<suffix>.bak
24
+ sqlite3 "$backup" 'PRAGMA quick_check;'
25
+ cp -p "$backup" "$db.restore"
26
+ chmod 600 "$db.restore"
27
+ mv "$db" "$db.failed-v7.<recovery-id>"
28
+ test ! -e "$db-wal" || mv "$db-wal" "$db-wal.failed-v7.<recovery-id>"
29
+ test ! -e "$db-shm" || mv "$db-shm" "$db-shm.failed-v7.<recovery-id>"
30
+ mv "$db.restore" "$db"
31
+ ```
32
+
33
+ 校验结果必须是 `ok`。确认恢复后的项目正常前,不要删除这些改名文件。再次启动
34
+ v1 会把恢复的数据库重新迁移到 schema v7;用旧版本 hello-cc 打开恢复出的 pre-v1
35
+ 数据库不属于受支持的降级路径。
36
+
6
37
  ## 安装、更新和卸载
7
38
 
39
+ ### 前置依赖
40
+
41
+ 通过 Node.js 官方软件包或 Node 版本管理器安装 Node.js 24 或更新版本。浏览器可
42
+ 控制的终端还需要 `tmux`:
43
+
44
+ ```bash
45
+ # Debian / Ubuntu
46
+ sudo apt-get update
47
+ sudo apt-get install -y tmux
48
+ # Fedora / RHEL
49
+ sudo dnf install -y tmux
50
+ # 旧版 RHEL / CentOS
51
+ sudo yum install -y tmux
52
+ # Alpine
53
+ sudo apk add tmux
54
+ # Arch Linux
55
+ sudo pacman -S --needed tmux
56
+ # openSUSE
57
+ sudo zypper install tmux
58
+ # 仅 macOS
59
+ brew install tmux
60
+ ```
61
+
62
+ Linux 必须使用当前发行版的系统包管理器,而不是 Homebrew。root shell 可以省略
63
+ `sudo`。WSL 用户应在 WSL 内部按对应 Linux 发行版安装;不支持原生 Windows
64
+ shell。
65
+
66
+ 当存在受支持的包管理器且权限足够时,`hcc web` 可以尝试自动安装 tmux。对于
67
+ 服务器、容器和非交互式 sudo 环境,手动安装是确定性更高的方式。
68
+
69
+ ### 安装和验证
70
+
8
71
  全局安装 hello-cc:
9
72
 
10
73
  ```bash
11
74
  npm install -g @logicseek/hello-cc
12
75
  ```
13
76
 
77
+ 如果 npm 报 `EACCES`,请使用 Node 版本管理器或配置用户自有的 npm prefix。
78
+ 不要使用 `sudo npm install -g`,否则可能产生 root 所有的包和配置文件。
79
+
80
+ 验证全部前置依赖和 CLI:
81
+
82
+ ```bash
83
+ node --version
84
+ npm --version
85
+ tmux -V
86
+ hcc --version
87
+ hcc --help
88
+ ```
89
+
90
+ Node 版本应为 `v24` 开头或更高主版本;启动托管终端前,上述命令都应成功退出。
91
+
92
+ 不全局安装时可以使用:
93
+
94
+ ```bash
95
+ npx @logicseek/hello-cc web
96
+ ```
97
+
98
+ ### 更新和卸载
99
+
14
100
  更新已有的全局安装:
15
101
 
16
102
  ```bash
@@ -210,7 +296,7 @@ debug 日志里应该出现 `Hook UserPromptSubmit ... provided additionalContex
210
296
  hcc web
211
297
  ```
212
298
 
213
- 裸 `hcc web` 会保存自动生成的 token,并在重启后复用。需要替换保存值时可显式设置:
299
+ 裸 `hcc web` 会为本次 runtime 自动生成 token。需要稳定的运维 token 时可显式设置:
214
300
 
215
301
  ```bash
216
302
  HCC_WEB_TOKEN='choose-a-long-token' hcc web --port 8787
@@ -331,7 +417,8 @@ hcc lock release --resource vllm/router
331
417
  | `HCC_PEER` | 默认 peer 身份 |
332
418
  | `HCC_ROOT` | 覆盖项目根目录 |
333
419
  | `HCC_DB` | 覆盖数据库路径 |
334
- | `HCC_WEB_TOKEN` | 替换并保存固定 Web 访问令牌 |
420
+ | `HCC_WEB_TOKEN` | 设置显式 Web 访问令牌 |
421
+ | `HCC_RUNTIME_CA` | `HCC_RUNTIME_URL=https` 端点的 CA 文件 |
335
422
  | `HCC_RUNTIME_URL` | 直接指定 runtime URL |
336
423
  | `HCC_NO_AUTO_INSTALL_TMUX=1` | 禁用 tmux 自动安装,主要用于测试 |
337
424