@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/CHANGELOG.md CHANGED
@@ -16,6 +16,142 @@ the release description from the current changelog section. Use
16
16
  `npm run release:github` with `GH_TOKEN` or `GITHUB_TOKEN` only for local
17
17
  backfills.
18
18
 
19
+ ## 1.0.1
20
+
21
+ ### Summary
22
+
23
+ hello-cc 1.0.1 is a file-lock determinism, buffer-GC safety, fresh-install, and
24
+ release-reliability patch. It makes worker shutdown reclaim kernel lock
25
+ endpoints deterministically when an identity probe keeps its client write half
26
+ open, restores real PTY startup in fresh macOS npm installations, and keeps
27
+ automatic GC fail-closed when optional buffer paths disappear or change.
28
+
29
+ ### Highlights
30
+
31
+ - The socket-lock worker now tracks each locally accepted socket and destroys
32
+ those accepted handles during server shutdown, so release no longer depends
33
+ on the peer closing its writable half after reading the lock banner.
34
+ - A real half-open identity-probe regression verifies that release returns
35
+ promptly, a nonblocking reacquisition succeeds immediately, and the probe is
36
+ explicitly stopped and awaited during final cleanup.
37
+ - `node-pty` is exactly pinned to `1.2.0-beta.15`. The stable `node-pty 1.1.0`
38
+ npm artifact contains non-executable Darwin helpers, which makes a fresh
39
+ macOS install fail with `posix_spawnp failed`; the selected artifact publishes
40
+ both Darwin helpers with executable modes.
41
+ - Linux, macOS, and WSL installation instructions now list Node.js 24, tmux
42
+ commands for the major system package managers, CLI verification, and safe
43
+ handling for npm global-install permission errors.
44
+ - `hcc down` now waits for the exact Runtime process identity to exit before it
45
+ reports success, including safe handling for PID reuse and a bounded timeout
46
+ when shutdown cannot be confirmed.
47
+ - Background Web startup keeps its immediate child-exit failure but allows a
48
+ bounded 60-second health window, avoiding false failures on loaded macOS CI
49
+ hosts where process identity and project restoration can exceed 30 seconds.
50
+ - Manual buffer GC allows a bounded 30-second window for runtime evidence
51
+ planning and apply, while still deferring all eligible files if the runtime
52
+ remains unavailable.
53
+ - Automatic GC now treats a missing `.hello-cc/bufs` leaf as empty without
54
+ recreating it. A missing state directory, a symlinked path component, an
55
+ inode replacement, or a retargeted project-root alias fails closed with
56
+ `PROJECT_PATH_FORBIDDEN` before buffer, clock, lock, or history mutation.
57
+ - Buffer path identity is retained through evidence collection, lease
58
+ acquisition, planning, clock reads, and database transactions. GC uses a
59
+ no-create lease while existing file-lock callers retain their original
60
+ parent-creation behavior.
61
+ - Per-connection Web action tokens now require their issuing terminal socket to
62
+ still be open, closing the handshake race before asynchronous token cleanup.
63
+ - Runtime request deadlines now reach the underlying HTTP transport, and peer
64
+ start/attach preflight and mutation requests use a bounded 60-second window
65
+ while stop and terminal-input operations use 30 seconds, instead of all
66
+ inheriting the shorter read-request default.
67
+
68
+ ### Compatibility Notes
69
+
70
+ - No CLI command or package-surface behavior changes are intended. Schema v7,
71
+ Runtime API v2, the authenticated browser's ability to choose any existing
72
+ server directory as a project root, and the 1.0.0 accepted-risk boundaries
73
+ are unchanged.
74
+ - Stable project-root aliases remain supported. Only path disappearance,
75
+ replacement, symlink traversal, or alias retargeting during GC is rejected.
76
+ - The existing five-second fail-closed deadline and cleanup-error behavior are
77
+ unchanged.
78
+ - `node-pty@1.2.0-beta.15` is a bounded prerelease dependency risk. The exact
79
+ pin prevents unreviewed beta movement, and release tests verify the installed
80
+ version, regular-file identity, executable modes, and a real PTY. There is no
81
+ postinstall or CI-only `chmod` workaround.
82
+
83
+ ### Validation
84
+
85
+ The 1.0.1 release gate includes repeated macOS Node 24 tests; a no-cache Linux
86
+ Node 24/tmux image build followed by three complete `npm test` runs in that same
87
+ image, each ending with `FULL_REGRESSION_OK`; and a fourth clean container that
88
+ installs the same 1.0.1 package tarball and passes PTY, database, Web, and
89
+ missing-buffer GC smoke checks. Fresh macOS consumer installs pass both normal
90
+ and `--ignore-scripts` installation, proving that executable helper modes come
91
+ from the package artifact rather than lifecycle-script mutation. GC regression
92
+ coverage includes absent optional leaves, symlink and ancestor replacement,
93
+ alias retargeting, no-create lock acquisition, and path guards around clock and
94
+ history writes.
95
+
96
+ ## 1.0.0
97
+
98
+ ### Summary
99
+
100
+ hello-cc 1.0.0 is a breaking data, identity, and Runtime API release. It makes
101
+ process identity the authority for session liveness, bounds unknown evidence,
102
+ and hardens browser terminal control and technical-state cleanup.
103
+
104
+ ### Highlights
105
+
106
+ - Process identity now controls live/dead decisions across tmux and ordinary
107
+ child processes, including sleep, detach, PID reuse, and stale status rows.
108
+ - Browser credentials, trusted proxy headers, Runtime API TLS, and buffer GC
109
+ all have narrower, tested authority boundaries.
110
+
111
+ ### Breaking Changes
112
+
113
+ - Databases upgrade to schema v7. Downgrading a migrated database is not
114
+ supported. Before migration, hello-cc creates a verified
115
+ `<db>.pre-v<from>-to-v7.<timestamp>.<suffix>.bak` snapshot; stop all hello-cc
116
+ processes and validate the backup with SQLite `quick_check` before any manual
117
+ recovery. At most five strictly named backups are retained per database; the
118
+ recovery procedure is documented in the user guide.
119
+ - Provider peer IDs now hash the complete provider session value. Existing
120
+ pre-v1 provider IDs and bindings are left unchanged: there is no automatic
121
+ alias, graph rewrite, or migration to the new ID.
122
+ - Protected HTTP and WebSocket operations require Runtime API v2. Browser
123
+ terminal write tokens are issued per WebSocket connection and revoked when
124
+ that connection closes.
125
+
126
+ ### Security And Reliability
127
+
128
+ - Live tmux and non-tmux sessions are decided from immutable process evidence;
129
+ sleep and tmux detachment do not mark a live process dead. Unknown evidence
130
+ receives at most 120 seconds of grace, while confirmed dead owners expire.
131
+ - Generated Web access tokens are scoped to one runtime and are not persisted.
132
+ HTTPS runtime overrides use normal certificate verification; set
133
+ `HCC_RUNTIME_CA` to a CA file for a private or self-signed endpoint.
134
+ - `--trust-proxy` now requires `--proxy-origin https://host[:port]`; forwarded
135
+ scheme and host must match that fixed origin and arrive from loopback.
136
+ - Garbage collection keeps task/message/event/handoff history unless
137
+ `hcc gc --history --yes` is explicitly requested. Buffer deletion rechecks
138
+ producer evidence and leases immediately before each bounded batch.
139
+
140
+ ### Accepted Risks
141
+
142
+ - The default Web listener remains `0.0.0.0` over plaintext HTTP for trusted
143
+ LAN use. The token controls access but does not provide transport encryption;
144
+ use `--tls` or a pinned TLS reverse proxy when the network is not trusted.
145
+ - An authenticated browser may select any existing server directory as a
146
+ project root. This is intentional for the operator console and is not a
147
+ project-root sandbox or tenant boundary.
148
+
149
+ ### Validation
150
+
151
+ The release gate requires Node 24 unit and full regression tests, package import
152
+ closure checks, a fresh Docker build, and three consecutive container runs that
153
+ end with `FULL_REGRESSION_OK`.
154
+
19
155
  ## 0.1.9
20
156
 
21
157
  ### Summary
package/README.md CHANGED
@@ -30,6 +30,20 @@ It is built for developers who run multiple AI coding agents in the same repo
30
30
  and need them to coordinate instead of guessing what the other sessions are
31
31
  doing.
32
32
 
33
+ ## v1 Compatibility And Trust Model
34
+
35
+ Version 1.0.0 upgrades project databases to schema v7 after creating a verified
36
+ pre-migration backup; downgrading that database is unsupported. Provider peer
37
+ IDs now hash the full provider session value and old IDs are not remapped.
38
+ Runtime API v2 and per-connection terminal action tokens are required.
39
+
40
+ Liveness follows tmux/non-tmux process evidence: sleep or detachment does not
41
+ kill a live session, and only unknown evidence receives the bounded 120-second
42
+ grace. `hcc gc` retains history unless `--history` is explicit. `--tls` encrypts
43
+ the console; `--trust-proxy` requires a fixed `--proxy-origin`. Two risks remain
44
+ intentional: the default listener is plaintext HTTP on `0.0.0.0` for trusted
45
+ LANs, and an authenticated browser may select any existing server directory.
46
+
33
47
  ## Highlights
34
48
 
35
49
  - **Shared project memory**: peers, tasks, messages, locks, handoffs, and
@@ -56,10 +70,42 @@ currently supported; use WSL for a Linux-like environment.
56
70
  Linux has richer process auto-discovery through `/proc`. On macOS, use
57
71
  hello-cc shims or `hcc peer start` for reliable tmux-managed terminal sessions.
58
72
 
73
+ Install Node.js 24 or newer from the official Node.js packages or a Node
74
+ version manager. Then install `tmux` for your platform:
75
+
76
+ ```bash
77
+ # Debian / Ubuntu
78
+ sudo apt-get update && sudo apt-get install -y tmux
79
+ # Fedora / RHEL
80
+ sudo dnf install -y tmux
81
+ # Older RHEL / CentOS
82
+ sudo yum install -y tmux
83
+ # Alpine
84
+ sudo apk add tmux
85
+ # Arch Linux
86
+ sudo pacman -S --needed tmux
87
+ # openSUSE
88
+ sudo zypper install tmux
89
+ # macOS only
90
+ brew install tmux
91
+ ```
92
+
93
+ On Linux, use the distribution package manager; Homebrew is only the macOS
94
+ command above. Root shells can omit `sudo`. In WSL, run the matching Linux
95
+ distribution commands inside WSL. Then install and verify hello-cc:
96
+
59
97
  ```bash
60
98
  npm install -g @logicseek/hello-cc
99
+ node --version
100
+ npm --version
101
+ tmux -V
102
+ hcc --version
103
+ hcc --help
61
104
  ```
62
105
 
106
+ If npm reports `EACCES`, use a Node version manager or a user-owned npm prefix;
107
+ do not work around it with `sudo npm install -g`.
108
+
63
109
  Update an existing global install:
64
110
 
65
111
  ```bash
@@ -94,14 +140,14 @@ hcc web
94
140
  ```
95
141
 
96
142
  Then open the printed URL. By default, `hcc web` listens on LAN interfaces and
97
- requests `0.0.0.0:8787`, using a saved URL token generated on first use. If
143
+ requests `0.0.0.0:8787`, using a token generated for that runtime. If
98
144
  port 8787 is already busy and you did not pass `--port`, it automatically tries
99
145
  the next available port. The command prints both the LAN login URL and the local
100
146
  loopback URL:
101
147
 
102
148
  ```text
103
- open: http://<machine-ip>:8787/?token=<saved-token>&project=/path/to/project
104
- local: http://127.0.0.1:8787/?token=<saved-token>&project=/path/to/project
149
+ open: http://<machine-ip>:8787/?token=<runtime-token>&project=/path/to/project
150
+ local: http://127.0.0.1:8787/?token=<runtime-token>&project=/path/to/project
105
151
  ```
106
152
 
107
153
  Use `--local` to bind only to `127.0.0.1`, or `--port N` to request a specific
@@ -139,6 +185,7 @@ project database.
139
185
  ```bash
140
186
  hcc task create --title "Review router changes" --priority 20
141
187
  hcc task next
188
+ hcc task running --id 1 --summary "Started"
142
189
  hcc lock acquire --resource src/router --ttl 900 --reason "edit router"
143
190
  hcc status
144
191
  hcc handoff create --summary "Router change ready for review" --tests "npm test"
package/README.zh-CN.md CHANGED
@@ -25,6 +25,19 @@
25
25
 
26
26
  它适合在同一个仓库里同时运行多个 AI 编程 agent 的场景:让它们知道彼此在做什么,而不是各自猜测。
27
27
 
28
+ ## v1 兼容性与信任边界
29
+
30
+ 1.0.0 会在生成并校验升级前备份后,把项目数据库升级到 schema v7;升级后的
31
+ 数据库不支持降级。provider peer ID 改为对完整 provider session 值做哈希,旧 ID
32
+ 不会自动映射或迁移。受保护的接口使用 Runtime API v2,终端 action token 按
33
+ WebSocket 连接签发和撤销。
34
+
35
+ 存活判断以 tmux/非 tmux 进程证据为准:休眠或 detach 不会把活进程判死,只有
36
+ unknown 证据获得最长 120 秒宽限。`hcc gc` 默认保留历史,必须显式使用
37
+ `--history`。`--tls` 提供传输加密;`--trust-proxy` 必须固定
38
+ `--proxy-origin`。两项风险是有意保留的:默认在可信内网以明文 HTTP 监听
39
+ `0.0.0.0`,且已认证浏览器可以选择服务器上任意已存在目录。
40
+
28
41
  ## 特色
29
42
 
30
43
  - **项目本地共享状态**:peers、tasks、messages、locks、handoffs 和 events 写入 `<project>/.hello-cc/mesh.db`。
@@ -44,10 +57,41 @@ hello-cc 支持 Linux 和 macOS。需要 Node.js 24 或更新版本;可被浏
44
57
  Linux 可以通过 `/proc` 做更完整的进程自动发现。macOS 上建议通过 hello-cc
45
58
  shim 或 `hcc peer start` 启动会话,以获得可靠的 tmux 托管终端。
46
59
 
60
+ 先通过 Node.js 官方软件包或 Node 版本管理器安装 Node.js 24 或更新版本,再按
61
+ 系统安装 `tmux`:
62
+
63
+ ```bash
64
+ # Debian / Ubuntu
65
+ sudo apt-get update && sudo apt-get install -y tmux
66
+ # Fedora / RHEL
67
+ sudo dnf install -y tmux
68
+ # 旧版 RHEL / CentOS
69
+ sudo yum install -y tmux
70
+ # Alpine
71
+ sudo apk add tmux
72
+ # Arch Linux
73
+ sudo pacman -S --needed tmux
74
+ # openSUSE
75
+ sudo zypper install tmux
76
+ # 仅 macOS
77
+ brew install tmux
78
+ ```
79
+
80
+ Linux 必须使用当前发行版的系统包管理器,而不是 Homebrew。root shell 可以省略
81
+ `sudo`。WSL 用户应在 WSL 内部执行对应 Linux 发行版的命令。然后安装并验证:
82
+
47
83
  ```bash
48
84
  npm install -g @logicseek/hello-cc
85
+ node --version
86
+ npm --version
87
+ tmux -V
88
+ hcc --version
89
+ hcc --help
49
90
  ```
50
91
 
92
+ 如果 npm 报 `EACCES`,请使用 Node 版本管理器或用户自有的 npm prefix,不要用
93
+ `sudo npm install -g` 绕过权限问题。
94
+
51
95
  更新已有的全局安装:
52
96
 
53
97
  ```bash
@@ -82,13 +126,13 @@ hcc web
82
126
  ```
83
127
 
84
128
  然后打开命令输出里的 URL。默认情况下,`hcc web` 会监听内网地址,请求
85
- `0.0.0.0:8787`,并在 URL 里附带首次自动生成并保存的稳定 token。如果 8787
129
+ `0.0.0.0:8787`,并在 URL 里附带为本次 runtime 自动生成的 token。如果 8787
86
130
  端口已被占用,且你没有显式传 `--port`,它会自动尝试后续可用端口。启动时会同时
87
131
  打印内网登录地址和本机 loopback 地址:
88
132
 
89
133
  ```text
90
- open: http://<machine-ip>:8787/?token=<saved-token>&project=/path/to/project
91
- local: http://127.0.0.1:8787/?token=<saved-token>&project=/path/to/project
134
+ open: http://<machine-ip>:8787/?token=<runtime-token>&project=/path/to/project
135
+ local: http://127.0.0.1:8787/?token=<runtime-token>&project=/path/to/project
92
136
  ```
93
137
 
94
138
  使用 `--local` 可以只绑定 `127.0.0.1`,使用 `--port N` 可以指定请求端口。
@@ -122,6 +166,7 @@ provider CLI,不会使用全局 Web runtime,也不会为这个目录新建
122
166
  ```bash
123
167
  hcc task create --title "Review router changes" --priority 20
124
168
  hcc task next
169
+ hcc task running --id 1 --summary "Started"
125
170
  hcc lock acquire --resource src/router --ttl 900 --reason "edit router"
126
171
  hcc status
127
172
  hcc handoff create --summary "Router change ready for review" --tests "npm test"