@logicseek/hello-cc 0.1.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +18 -3
  3. package/README.zh-CN.md +17 -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/current-state-review-2026-08.md +341 -0
  12. package/docs/defect-review-2026-07.md +382 -0
  13. package/docs/guide.md +39 -3
  14. package/docs/guide.zh-CN.md +34 -2
  15. package/docs/superpowers/plans/2026-08-03-runtime-safety-plan.md +294 -0
  16. package/docs/superpowers/plans/2026-08-03-v1-data-identity-plan.md +400 -0
  17. package/docs/superpowers/plans/2026-08-03-v1-release-verification-plan.md +284 -0
  18. package/docs/superpowers/plans/2026-08-03-web-api-hardening-plan.md +303 -0
  19. package/docs/superpowers/plans/2026-08-04-runtime-buffer-gc-two-phase.md +71 -0
  20. package/docs/superpowers/specs/2026-08-03-runtime-safety-design.md +117 -0
  21. package/docs/superpowers/specs/2026-08-03-v1-data-identity-design.md +120 -0
  22. package/docs/superpowers/specs/2026-08-03-v1-release-verification-design.md +117 -0
  23. package/docs/superpowers/specs/2026-08-03-web-api-hardening-design.md +104 -0
  24. package/lib/cli/app.mjs +642 -0
  25. package/lib/cli/commands/coordination.mjs +247 -0
  26. package/lib/cli/commands/doctor.mjs +81 -0
  27. package/lib/cli/commands/gc.mjs +852 -0
  28. package/lib/cli/commands/hook.mjs +205 -0
  29. package/lib/cli/commands/install.mjs +294 -0
  30. package/lib/cli/commands/lifecycle.mjs +101 -0
  31. package/lib/cli/commands/lock.mjs +197 -0
  32. package/lib/cli/commands/misc.mjs +61 -0
  33. package/lib/cli/commands/msg.mjs +152 -0
  34. package/lib/cli/commands/peer.mjs +233 -0
  35. package/lib/cli/commands/query.mjs +96 -0
  36. package/lib/cli/commands/run.mjs +463 -0
  37. package/lib/cli/commands/task.mjs +405 -0
  38. package/lib/cli/commands/team.mjs +131 -0
  39. package/lib/cli/commands/tmux.mjs +838 -0
  40. package/lib/cli/commands/up.mjs +135 -0
  41. package/lib/cli-args.mjs +16 -2
  42. package/lib/coordination-state.mjs +112 -51
  43. package/lib/core/coordination/automation.mjs +5 -8
  44. package/lib/core/coordination/clock-safety.mjs +323 -0
  45. package/lib/core/coordination/event-retention.mjs +17 -0
  46. package/lib/core/coordination/gc-plan.mjs +614 -0
  47. package/lib/core/coordination/lease-renewal.mjs +102 -0
  48. package/lib/core/coordination/lock-evidence.mjs +77 -0
  49. package/lib/core/coordination/optimistic-evidence.mjs +26 -0
  50. package/lib/core/coordination/tasks.mjs +156 -36
  51. package/lib/core/peers/evidence-runtime.mjs +312 -0
  52. package/lib/core/peers/evidence.mjs +103 -0
  53. package/lib/core/peers/hook-owner.mjs +32 -0
  54. package/lib/core/peers/liveness.mjs +44 -4
  55. package/lib/core/peers/peer-helpers.mjs +121 -0
  56. package/lib/core/peers/session.mjs +8 -2
  57. package/lib/core/peers/tmux-safety.mjs +290 -0
  58. package/lib/core/sessions/launch.mjs +13 -1
  59. package/lib/db/connection.mjs +104 -0
  60. package/lib/db/events.mjs +34 -0
  61. package/lib/db/migration-backup.mjs +225 -0
  62. package/lib/db/schema.mjs +102 -5
  63. package/lib/db/stores/peers.mjs +34 -0
  64. package/lib/integrations/peers/identity.mjs +62 -16
  65. package/lib/integrations/shims/script.mjs +111 -9
  66. package/lib/process/identity.mjs +192 -0
  67. package/lib/process/pty-lifecycle.mjs +149 -0
  68. package/lib/runtime/buffer-directory-lease.mjs +47 -0
  69. package/lib/runtime/buffer-evidence.mjs +336 -0
  70. package/lib/runtime/buffer-gc-protocol.mjs +167 -0
  71. package/lib/runtime/buffer-gc.mjs +270 -0
  72. package/lib/runtime/client.mjs +60 -7
  73. package/lib/runtime/fatal-shutdown.mjs +54 -0
  74. package/lib/runtime/project-path.mjs +139 -0
  75. package/lib/runtime/projects.mjs +320 -40
  76. package/lib/runtime/state.mjs +227 -27
  77. package/lib/shared/cleanup-error.mjs +54 -0
  78. package/lib/shared/clock-grace.mjs +106 -0
  79. package/lib/shared/errors.mjs +9 -0
  80. package/lib/shared/file-lock.mjs +370 -0
  81. package/lib/shared/json-file.mjs +6 -2
  82. package/lib/shared/redact.mjs +60 -0
  83. package/lib/shared/socket-lock-worker.mjs +201 -0
  84. package/lib/terminal/tmux.mjs +78 -4
  85. package/lib/tmux.mjs +4 -0
  86. package/lib/ui/help.mjs +53 -15
  87. package/lib/web/api-version.mjs +42 -0
  88. package/lib/web/auto-attach.mjs +185 -0
  89. package/lib/web/buffer-gc-runtime.mjs +175 -0
  90. package/lib/web/cookie-auth.mjs +119 -0
  91. package/lib/web/external-sessions.mjs +254 -0
  92. package/lib/web/http-routes.mjs +542 -0
  93. package/lib/web/http.mjs +135 -6
  94. package/lib/web/liveness-reaper.mjs +145 -0
  95. package/lib/web/peer-actions.mjs +132 -23
  96. package/lib/web/project-contexts.mjs +178 -0
  97. package/lib/web/pty-sessions.mjs +203 -0
  98. package/lib/web/runtime-main.mjs +714 -0
  99. package/lib/web/runtime.mjs +91 -36
  100. package/lib/web/session-serialize.mjs +0 -0
  101. package/lib/web/startup.mjs +333 -0
  102. package/lib/web/tls.mjs +365 -0
  103. package/lib/web/tmux-sessions.mjs +1361 -0
  104. package/lib/web/tmux-stream.mjs +166 -0
  105. package/lib/web/ui-template.mjs +152 -20
  106. package/package.json +5 -2
  107. package/scripts/check-free-identifiers.mjs +290 -0
  108. package/scripts/regression.mjs +5397 -263
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