@logicseek/hello-cc 0.1.5 → 0.1.6
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.
- package/CHANGELOG.md +75 -0
- package/bin/hcc.mjs +1541 -3430
- package/docs/README.md +2 -0
- package/docs/README.zh-CN.md +3 -1
- package/docs/architecture-split-review.md +217 -0
- package/docs/architecture.md +385 -0
- package/docs/architecture.zh-CN.md +364 -0
- package/docs/layout-split-stack-audit.md +298 -0
- package/lib/automation.mjs +8 -0
- package/lib/cli-args.mjs +1 -1
- package/lib/cli-runtime.mjs +44 -0
- package/lib/coordination-state.mjs +218 -0
- package/lib/core/coordination/automation.mjs +222 -0
- package/lib/core/coordination/locks.mjs +46 -0
- package/lib/core/coordination/messages.mjs +116 -0
- package/lib/core/coordination/tasks.mjs +224 -0
- package/lib/core/coordination/teams.mjs +73 -0
- package/lib/core/coordination/timeline.mjs +187 -0
- package/lib/core/peers/bindings.mjs +83 -0
- package/lib/core/peers/format.mjs +13 -0
- package/lib/core/peers/identity.mjs +53 -0
- package/lib/core/peers/liveness.mjs +90 -0
- package/lib/core/peers/reconcile.mjs +238 -0
- package/lib/core/peers/session.mjs +14 -0
- package/lib/core/sessions/launch.mjs +89 -0
- package/lib/db/schema.mjs +324 -0
- package/lib/db/stores/peers.mjs +231 -0
- package/lib/db-schema.mjs +7 -324
- package/lib/errors.mjs +1 -7
- package/lib/handoff.mjs +26 -0
- package/lib/help.mjs +3 -0
- package/lib/integrations/hooks.mjs +171 -0
- package/lib/integrations/peers/identity.mjs +208 -0
- package/lib/integrations/peers/processes.mjs +151 -0
- package/lib/integrations/providers.mjs +282 -0
- package/lib/integrations/shims/script.mjs +384 -0
- package/lib/integrations/shims.mjs +106 -0
- package/lib/json-file.mjs +1 -14
- package/lib/locks.mjs +10 -0
- package/lib/messages.mjs +3 -0
- package/lib/package-meta.mjs +6 -24
- package/lib/peer-bindings.mjs +14 -0
- package/lib/peer-format.mjs +4 -0
- package/lib/peer-identity.mjs +15 -0
- package/lib/project-context.mjs +6 -0
- package/lib/project-registry.mjs +7 -0
- package/lib/provider-commands.mjs +13 -0
- package/lib/release/package-meta.mjs +31 -0
- package/lib/release/release-notes.mjs +40 -0
- package/lib/release-notes.mjs +6 -40
- package/lib/runtime/client.mjs +42 -0
- package/lib/runtime/paths.mjs +45 -0
- package/lib/runtime/project-context.mjs +32 -0
- package/lib/runtime/projects.mjs +76 -0
- package/lib/runtime/state.mjs +128 -0
- package/lib/runtime-client.mjs +3 -0
- package/lib/runtime-paths.mjs +11 -45
- package/lib/runtime-state.mjs +11 -0
- package/lib/session-launch.mjs +17 -0
- package/lib/setup.mjs +17 -293
- package/lib/shared/errors.mjs +7 -0
- package/lib/shared/json-file.mjs +14 -0
- package/lib/shim-script.mjs +1 -384
- package/lib/state-render.mjs +5 -0
- package/lib/task-cli.mjs +45 -0
- package/lib/task-liveness.mjs +8 -0
- package/lib/task-store.mjs +3 -0
- package/lib/team-planning.mjs +7 -0
- package/lib/terminal/tmux.mjs +372 -0
- package/lib/timeline.mjs +12 -0
- package/lib/tmux.mjs +18 -0
- package/lib/ui/help.mjs +419 -0
- package/lib/ui/state-render.mjs +61 -0
- package/lib/web/http.mjs +55 -0
- package/lib/web/peer-actions.mjs +270 -0
- package/lib/web/runtime.mjs +154 -0
- package/lib/web/ui-template.mjs +2055 -0
- package/lib/web-http.mjs +7 -55
- package/lib/web-peer-actions.mjs +3 -0
- package/lib/web-runtime.mjs +17 -108
- package/lib/web-ui-template.mjs +3 -1909
- package/package.json +1 -1
- package/scripts/github-release.mjs +2 -2
- package/scripts/regression.mjs +2468 -17
- package/scripts/release-notes.mjs +2 -2
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# hello-cc 架构设计
|
|
2
|
+
|
|
3
|
+
日期:2026-06-14
|
|
4
|
+
|
|
5
|
+
本文定义 hello-cc 的目标模块布局。它是后续重构的设计目标,不表示当前所有文件
|
|
6
|
+
都已经符合这个结构。
|
|
7
|
+
|
|
8
|
+
目标是停止按 helper 大小拆代码,改为按产品边界移动代码。薄 CLI、明确的核心
|
|
9
|
+
状态模型、独立 runtime 层、terminal adapter 和 Web server 边界,能让后续修改
|
|
10
|
+
更容易审查,也更不容易把无关行为混在一起。
|
|
11
|
+
|
|
12
|
+
## 参考结构
|
|
13
|
+
|
|
14
|
+
成熟的 agent CLI 项目通常采用类似分层:
|
|
15
|
+
|
|
16
|
+
- 入口文件保持很薄,只转发到 command 或 server 模块;
|
|
17
|
+
- 核心协作逻辑不依赖 HTTP、tmux 或进程启动细节;
|
|
18
|
+
- runtime 文件和 runtime client 独立于命令处理器;
|
|
19
|
+
- Web server routes、WebSocket transport、session lifecycle 是明确的 server
|
|
20
|
+
模块;
|
|
21
|
+
- provider 特有行为与通用 session/task 逻辑隔离;
|
|
22
|
+
- 测试按领域分组,而不是一直追加到一个巨大脚本里。
|
|
23
|
+
|
|
24
|
+
Codex 这类结构会把 `cli`、`core`、`app-server`、`protocol` 或 transport、state
|
|
25
|
+
store、hooks、config、execution adapter 分开。hello-cc 不需要 Rust crate,也
|
|
26
|
+
不需要同样规模,但应该采用同一个架构原则:按边界拆,不按顺手程度拆。
|
|
27
|
+
|
|
28
|
+
## 当前压力点
|
|
29
|
+
|
|
30
|
+
当前代码已经抽出了很多聚焦模块,例如 schema、runtime state、task/message
|
|
31
|
+
store、peer identity、provider command builder、tmux helper、Web HTTP helper
|
|
32
|
+
和 render helper。
|
|
33
|
+
|
|
34
|
+
剩余结构压力主要在:
|
|
35
|
+
|
|
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。
|
|
41
|
+
- `scripts/regression.mjs` 是有价值的全量回归入口,但后续应该变成一个调用领域
|
|
42
|
+
regression module 的 runner。
|
|
43
|
+
|
|
44
|
+
## 目标目录
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
bin/
|
|
48
|
+
hcc.mjs
|
|
49
|
+
|
|
50
|
+
lib/
|
|
51
|
+
cli/
|
|
52
|
+
dispatch.mjs
|
|
53
|
+
context.mjs
|
|
54
|
+
commands/
|
|
55
|
+
ask.mjs
|
|
56
|
+
broadcast.mjs
|
|
57
|
+
down.mjs
|
|
58
|
+
event.mjs
|
|
59
|
+
gc.mjs
|
|
60
|
+
handoff.mjs
|
|
61
|
+
hooks.mjs
|
|
62
|
+
init.mjs
|
|
63
|
+
inject.mjs
|
|
64
|
+
join.mjs
|
|
65
|
+
lock.mjs
|
|
66
|
+
msg.mjs
|
|
67
|
+
peer.mjs
|
|
68
|
+
prompt.mjs
|
|
69
|
+
run.mjs
|
|
70
|
+
scan.mjs
|
|
71
|
+
setup.mjs
|
|
72
|
+
shim.mjs
|
|
73
|
+
state.mjs
|
|
74
|
+
status.mjs
|
|
75
|
+
task.mjs
|
|
76
|
+
team.mjs
|
|
77
|
+
uninstall.mjs
|
|
78
|
+
update.mjs
|
|
79
|
+
up.mjs
|
|
80
|
+
web.mjs
|
|
81
|
+
|
|
82
|
+
core/
|
|
83
|
+
coordination/
|
|
84
|
+
automation.mjs
|
|
85
|
+
handoff.mjs
|
|
86
|
+
locks.mjs
|
|
87
|
+
messages.mjs
|
|
88
|
+
tasks.mjs
|
|
89
|
+
teams.mjs
|
|
90
|
+
timeline.mjs
|
|
91
|
+
peers/
|
|
92
|
+
bindings.mjs
|
|
93
|
+
format.mjs
|
|
94
|
+
identity.mjs
|
|
95
|
+
liveness.mjs
|
|
96
|
+
sessions/
|
|
97
|
+
launch.mjs
|
|
98
|
+
model.mjs
|
|
99
|
+
providers.mjs
|
|
100
|
+
serialization.mjs
|
|
101
|
+
|
|
102
|
+
db/
|
|
103
|
+
connection.mjs
|
|
104
|
+
migrations.mjs
|
|
105
|
+
schema.mjs
|
|
106
|
+
stores/
|
|
107
|
+
locks.mjs
|
|
108
|
+
messages.mjs
|
|
109
|
+
peers.mjs
|
|
110
|
+
tasks.mjs
|
|
111
|
+
|
|
112
|
+
runtime/
|
|
113
|
+
client.mjs
|
|
114
|
+
paths.mjs
|
|
115
|
+
projects.mjs
|
|
116
|
+
state.mjs
|
|
117
|
+
|
|
118
|
+
terminal/
|
|
119
|
+
external-buffer.mjs
|
|
120
|
+
pty.mjs
|
|
121
|
+
tmux-stream.mjs
|
|
122
|
+
tmux.mjs
|
|
123
|
+
|
|
124
|
+
web/
|
|
125
|
+
projects.mjs
|
|
126
|
+
routes.mjs
|
|
127
|
+
server.mjs
|
|
128
|
+
session-manager.mjs
|
|
129
|
+
websocket.mjs
|
|
130
|
+
http.mjs
|
|
131
|
+
ui-template.mjs
|
|
132
|
+
|
|
133
|
+
integrations/
|
|
134
|
+
hooks/
|
|
135
|
+
claude.mjs
|
|
136
|
+
codex.mjs
|
|
137
|
+
providers/
|
|
138
|
+
claude.mjs
|
|
139
|
+
codex.mjs
|
|
140
|
+
shell.mjs
|
|
141
|
+
shims/
|
|
142
|
+
setup.mjs
|
|
143
|
+
script.mjs
|
|
144
|
+
|
|
145
|
+
ui/
|
|
146
|
+
format.mjs
|
|
147
|
+
help.mjs
|
|
148
|
+
state-render.mjs
|
|
149
|
+
|
|
150
|
+
release/
|
|
151
|
+
package-meta.mjs
|
|
152
|
+
release-notes.mjs
|
|
153
|
+
|
|
154
|
+
shared/
|
|
155
|
+
errors.mjs
|
|
156
|
+
json-file.mjs
|
|
157
|
+
text.mjs
|
|
158
|
+
|
|
159
|
+
scripts/
|
|
160
|
+
regression.mjs
|
|
161
|
+
regression/
|
|
162
|
+
cli.mjs
|
|
163
|
+
coordination.mjs
|
|
164
|
+
db.mjs
|
|
165
|
+
release.mjs
|
|
166
|
+
runtime.mjs
|
|
167
|
+
sessions.mjs
|
|
168
|
+
web.mjs
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 边界规则
|
|
172
|
+
|
|
173
|
+
`bin/hcc.mjs` 应该变成很薄的入口。它可以解析全局参数、创建 root context、调用
|
|
174
|
+
dispatch,并把顶层错误转换为 CLI 输出。它不应该拥有 Web routing、DB schema、
|
|
175
|
+
tmux streaming、provider command construction 或 task state machine。
|
|
176
|
+
|
|
177
|
+
`lib/cli/` 负责命令解析和命令处理器。命令处理器可以打开数据库、调用 store 或
|
|
178
|
+
core service,并打印结果。当逻辑可以放进 `core`、`runtime`、`terminal`、`web`
|
|
179
|
+
或 `integrations` 时,不应该留在 command handler 里。
|
|
180
|
+
|
|
181
|
+
`lib/core/` 负责产品语义。task lifecycle、takeover readiness、message thread、
|
|
182
|
+
lock conflict rule、team planning、peer identity semantics 和 session identity
|
|
183
|
+
rule 属于这里。core module 不应该依赖 HTTP request、WebSocket、tmux command 或
|
|
184
|
+
process spawning。
|
|
185
|
+
|
|
186
|
+
`lib/db/` 负责 SQLite connection、schema、migration 和 data store。store module
|
|
187
|
+
应该暴露明确操作和事务边界。schema migration 必须能安全迁移每个注册项目数据库,
|
|
188
|
+
而不只是当前项目。
|
|
189
|
+
|
|
190
|
+
`lib/runtime/` 负责 runtime file、runtime discovery、runtime client request 和
|
|
191
|
+
project registry state。它不应该知道 Web route 如何渲染 UI,也不应该知道
|
|
192
|
+
terminal byte 如何传输。
|
|
193
|
+
|
|
194
|
+
`lib/terminal/` 负责 terminal adapter。tmux pane inspection、tmux stream setup、
|
|
195
|
+
tmux input、PTY spawn 和 external buffer adoption 属于这里。terminal adapter
|
|
196
|
+
可以发出 session event,但不应该决定 task ownership 或 message 行为。
|
|
197
|
+
|
|
198
|
+
`lib/web/` 负责 Web runtime。它应该组装 project context、session manager、HTTP
|
|
199
|
+
route、WebSocket terminal upgrade 和 shutdown cleanup。route handler 应该很薄,
|
|
200
|
+
并委托给 store、core service、runtime module 或 terminal/session manager。
|
|
201
|
+
|
|
202
|
+
`lib/integrations/` 负责 provider 特有行为。Claude、Codex、shell command
|
|
203
|
+
construction、hook installation details 和 shim script 不应混入通用 session 和
|
|
204
|
+
coordination module。
|
|
205
|
+
|
|
206
|
+
`lib/ui/` 负责 CLI 文本输出和 help。它可以格式化已经计算好的状态,但不应该读取
|
|
207
|
+
或修改项目状态。
|
|
208
|
+
|
|
209
|
+
`lib/release/` 负责 release metadata 和 release notes helper。release script 和
|
|
210
|
+
GitHub release 工具应共享这里的 helper。
|
|
211
|
+
|
|
212
|
+
`lib/shared/` 只放少量低依赖通用工具,不能变成新的杂物箱。
|
|
213
|
+
|
|
214
|
+
## 包发布面策略
|
|
215
|
+
|
|
216
|
+
受支持的公共接口是安装后的 CLI:`hcc` 和 `hello-cc`。`package.json` 包含
|
|
217
|
+
`lib/` 是因为 CLI 运行时会 import 这些文件,不表示每个 `lib/*` 路径都是稳定
|
|
218
|
+
library API。
|
|
219
|
+
|
|
220
|
+
不要在用户文档里新增 `@logicseek/hello-cc/lib/*` 这类导入用法。主实现应该放在
|
|
221
|
+
目标产品目录里;顶层 `lib/*.mjs` 文件只有在有明确兼容理由时,才作为
|
|
222
|
+
compatibility entrypoint 保留。
|
|
223
|
+
|
|
224
|
+
`@logicseek/hello-cc@0.1.5` 已经从 git head `4969100` 发布。这个已发布包因为
|
|
225
|
+
没有定义 `exports` map,已经暴露了一些顶层 `lib/*.mjs` helper 路径。常规 cleanup
|
|
226
|
+
提交里不要删除或重命名这些已发布路径;除非项目明确选择破坏性 package surface
|
|
227
|
+
变更,否则至少保留一个 release cycle,作为 compatibility re-export。
|
|
228
|
+
|
|
229
|
+
对于 `0.1.5` 之后的本地迁移提交,默认不要继续增加顶层 compatibility shim。如果
|
|
230
|
+
某个尚未发布的顶层 shim 要保留到下一版,需要在 release notes 里说明它只是
|
|
231
|
+
compatibility-only,并在再下一版前重新评估是否删除。不要让 compatibility shim
|
|
232
|
+
变成目标架构。
|
|
233
|
+
|
|
234
|
+
发行前,把顶层 `lib/*.mjs` 路径分成三类:
|
|
235
|
+
|
|
236
|
+
- A 类:已发布过,或 CLI 面向用户需要稳定的 helper 路径,本次发行必须保留。
|
|
237
|
+
- B 类:目录迁移产生的 compatibility path,只是 re-export 已移动实现;如确有
|
|
238
|
+
需要可保留一个版本,但 release notes 要说明它只是 compatibility-only 的
|
|
239
|
+
deep-import 路径。
|
|
240
|
+
- C 类:尚未发布、内部也不用、没有兼容价值的 shim,发布前删除。
|
|
241
|
+
|
|
242
|
+
因为 npm 上已经存在 `0.1.5`,任何包含 `4969100` 之后本地提交的发行都必须使用新
|
|
243
|
+
package 版本。不要尝试重新发布 `0.1.5`。
|
|
244
|
+
|
|
245
|
+
## 依赖方向
|
|
246
|
+
|
|
247
|
+
目标依赖方向:
|
|
248
|
+
|
|
249
|
+
```text
|
|
250
|
+
bin -> cli -> web/runtime/db/core/terminal/integrations/ui
|
|
251
|
+
web -> runtime/db/core/terminal/ui
|
|
252
|
+
terminal -> shared/core sessions only when needed
|
|
253
|
+
core -> shared
|
|
254
|
+
db -> shared
|
|
255
|
+
ui -> shared
|
|
256
|
+
release -> shared
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
避免以下依赖:
|
|
260
|
+
|
|
261
|
+
- `core` import `web`、`terminal`、`cli` 或 `integrations`;
|
|
262
|
+
- `db` import `cli` 或 `web`;
|
|
263
|
+
- `terminal` import Web route module;
|
|
264
|
+
- provider integration import command handler;
|
|
265
|
+
- `shared` import 产品特定模块。
|
|
266
|
+
|
|
267
|
+
这样大多数行为可以在没有 Web runtime 或 tmux process 的情况下测试。
|
|
268
|
+
|
|
269
|
+
## 迁移计划
|
|
270
|
+
|
|
271
|
+
重构必须小步进行,每一步都保持公共行为和 npm package 内容稳定,除非任务明确要
|
|
272
|
+
改行为。
|
|
273
|
+
|
|
274
|
+
1. 写下目标架构。
|
|
275
|
+
本文就是后续拆分的合同。
|
|
276
|
+
|
|
277
|
+
2. 把现有平铺模块移动到目标目录。
|
|
278
|
+
先做低风险迁移,例如 `runtime-*`、`web-*`、`task-store`、`messages`、`help`、
|
|
279
|
+
`state-render` 和 release helper。如果 import churn 太大,可以临时保留
|
|
280
|
+
compatibility re-export 文件。
|
|
281
|
+
|
|
282
|
+
3. 按子系统拆 Web runtime。
|
|
283
|
+
分提交从 `cmdWeb()` 抽出 project selection、session manager、Web routes、
|
|
284
|
+
WebSocket terminal、tmux stream、PTY session 和 external buffer adoption。
|
|
285
|
+
|
|
286
|
+
4. 让 `bin/hcc.mjs` 变成薄入口。
|
|
287
|
+
把 dispatch 和 command groups 移到 `lib/cli/commands/`。
|
|
288
|
+
|
|
289
|
+
5. 按领域拆 regression。
|
|
290
|
+
保持 `npm test` 是唯一全量回归命令,但让它调用 `scripts/regression/` 下的
|
|
291
|
+
领域模块。
|
|
292
|
+
|
|
293
|
+
## Web Runtime 目标
|
|
294
|
+
|
|
295
|
+
最有价值的 runtime 拆分如下:
|
|
296
|
+
|
|
297
|
+
```text
|
|
298
|
+
lib/web/server.mjs
|
|
299
|
+
createWebRuntime(ctx, opts, deps)
|
|
300
|
+
start/stop lifecycle
|
|
301
|
+
|
|
302
|
+
lib/web/projects.mjs
|
|
303
|
+
rememberProject()
|
|
304
|
+
knownProjects()
|
|
305
|
+
projectFromRequest()
|
|
306
|
+
|
|
307
|
+
lib/web/session-manager.mjs
|
|
308
|
+
sessions map
|
|
309
|
+
getSession()
|
|
310
|
+
serializeSession()
|
|
311
|
+
startSession()
|
|
312
|
+
stopSession()
|
|
313
|
+
restoreManagedSessions()
|
|
314
|
+
|
|
315
|
+
lib/web/routes.mjs
|
|
316
|
+
routeHttpRequest(req, res, env)
|
|
317
|
+
|
|
318
|
+
lib/web/websocket.mjs
|
|
319
|
+
handleTerminalUpgrade(req, socket, head, env)
|
|
320
|
+
|
|
321
|
+
lib/terminal/tmux-stream.mjs
|
|
322
|
+
startTmuxStream()
|
|
323
|
+
stopTmuxStream()
|
|
324
|
+
refreshTmuxSnapshot()
|
|
325
|
+
|
|
326
|
+
lib/terminal/external-buffer.mjs
|
|
327
|
+
adoptExternalSession()
|
|
328
|
+
scanExternalSessions()
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
这个拆分能让 Web 空白、stale session、tmux stream 和 provider binding 问题更
|
|
332
|
+
容易定位。
|
|
333
|
+
|
|
334
|
+
## 测试要求
|
|
335
|
+
|
|
336
|
+
每个结构迁移任务至少运行:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
git diff --check
|
|
340
|
+
node --check bin/hcc.mjs
|
|
341
|
+
node --check <changed modules>
|
|
342
|
+
npm test
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
涉及发行面的变更还要运行:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
npm run release:check
|
|
349
|
+
npm run release:github:dry-run
|
|
350
|
+
npm pack --dry-run --json
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
新增 `lib/` 模块后,要确认 `npm pack --dry-run --json` 包含它们。
|
|
354
|
+
|
|
355
|
+
## 非目标
|
|
356
|
+
|
|
357
|
+
不要在本次布局迁移中引入 TypeScript、Rust、bundler 或 build step。这些都是单独
|
|
358
|
+
的产品决策,会影响 release 和安装成本。
|
|
359
|
+
|
|
360
|
+
不要在移动文件时重写已工作的行为。目录迁移提交应该很朴素:import 改了、模块
|
|
361
|
+
路径改了、regression guard 改了,但行为不变。
|
|
362
|
+
|
|
363
|
+
在没有单独 Web UI build 方案前,不要把 UI template asset 移到前端框架里。当前
|
|
364
|
+
npm 包安装后应继续可以直接运行。
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# Layout Split Stack Audit
|
|
2
|
+
|
|
3
|
+
Date: 2026-06-14
|
|
4
|
+
|
|
5
|
+
Audit branch: `audit/layout-split-stack-20260614`
|
|
6
|
+
|
|
7
|
+
Reviewed range: `origin/master..HEAD`
|
|
8
|
+
|
|
9
|
+
- Base: `4969100` (`origin/master`, published as `@logicseek/hello-cc@0.1.5`)
|
|
10
|
+
- Audited head: `4283234`
|
|
11
|
+
- Commit count: 40
|
|
12
|
+
|
|
13
|
+
This document audits the local architecture split stack before any push or npm
|
|
14
|
+
publish. It is intentionally on a dedicated audit branch/worktree so the active
|
|
15
|
+
`master` implementation stack is not rewritten during review.
|
|
16
|
+
|
|
17
|
+
## Review Standard
|
|
18
|
+
|
|
19
|
+
Each commit is classified against `docs/architecture.md`:
|
|
20
|
+
|
|
21
|
+
- `keep`: the commit directly moves code toward a documented product boundary.
|
|
22
|
+
- `keep-with-cleanup`: the direction is right, but package surface, shim policy,
|
|
23
|
+
or module placement still needs a cleanup decision before release.
|
|
24
|
+
- `squash/rebuild`: the code is useful, but the commit exists mostly as an
|
|
25
|
+
intermediate flat extraction and should be folded into a product-boundary
|
|
26
|
+
commit if a clean release branch is rebuilt.
|
|
27
|
+
- `decision-needed`: the final location or public surface is not settled.
|
|
28
|
+
- `docs-only`: documentation or process record.
|
|
29
|
+
|
|
30
|
+
The important distinction is code shape versus history shape. A commit can be
|
|
31
|
+
useful for reaching the current code state while still being a poor standalone
|
|
32
|
+
release-history commit.
|
|
33
|
+
|
|
34
|
+
## Team Review Split
|
|
35
|
+
|
|
36
|
+
Parent task: `#232`
|
|
37
|
+
|
|
38
|
+
- `#234 lead-audit`: maintain this matrix and merge review feedback.
|
|
39
|
+
- `#236 review-core-db`: core, coordination, db, peers, session semantics.
|
|
40
|
+
- `#235 review-runtime-web`: runtime, web, terminal, integrations, release,
|
|
41
|
+
shared helper placement.
|
|
42
|
+
- `#237 review-package-surface`: top-level `lib/*.mjs` compatibility shims,
|
|
43
|
+
npm package surface, and release-note risk.
|
|
44
|
+
|
|
45
|
+
## Summary
|
|
46
|
+
|
|
47
|
+
The current `HEAD` is not a random bad refactor. The final code shape has mostly
|
|
48
|
+
been corrected toward the target architecture:
|
|
49
|
+
|
|
50
|
+
- coordination logic under `lib/core/coordination`
|
|
51
|
+
- peer/session semantics under `lib/core/peers` and `lib/core/sessions`
|
|
52
|
+
- schema and stores under `lib/db`
|
|
53
|
+
- runtime state/client/project helpers under `lib/runtime`
|
|
54
|
+
- tmux under `lib/terminal`
|
|
55
|
+
- Web runtime helpers under `lib/web`
|
|
56
|
+
- provider/hooks/shims under `lib/integrations`
|
|
57
|
+
- small utilities under `lib/shared`
|
|
58
|
+
- text rendering/help under `lib/ui`
|
|
59
|
+
- release helpers under `lib/release`
|
|
60
|
+
|
|
61
|
+
The problem is the history shape. The first 25 local commits were mostly
|
|
62
|
+
"extract a helper from `bin/hcc.mjs` into a top-level `lib/*.mjs` file". That
|
|
63
|
+
was useful as a safety step, but it does not match the architecture design by
|
|
64
|
+
itself. Later commits then moved many of those flat files into real product
|
|
65
|
+
boundaries.
|
|
66
|
+
|
|
67
|
+
Therefore:
|
|
68
|
+
|
|
69
|
+
1. If the project keeps the current `master` history, do not keep making broad
|
|
70
|
+
split commits. Finish only package-surface cleanup, run full validation, bump
|
|
71
|
+
the version, and publish/sync with a clear changelog.
|
|
72
|
+
2. If the project wants clean history for this major refactor, create a rebuild
|
|
73
|
+
branch from `origin/master` and replay the final shape as fewer architectural
|
|
74
|
+
commits. Do not rewrite the active `master` while peers use it.
|
|
75
|
+
|
|
76
|
+
## Phase Classification
|
|
77
|
+
|
|
78
|
+
### Phase 1: Early Flat Extractions
|
|
79
|
+
|
|
80
|
+
These commits reduced `bin/hcc.mjs`, but mostly created top-level helper modules
|
|
81
|
+
before the design document existed. They should be treated as
|
|
82
|
+
`squash/rebuild` if a clean branch is made.
|
|
83
|
+
|
|
84
|
+
| Commit | Area | Classification | Reason |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `1bb1967` | providers + tmux | `squash/rebuild` | Mixed two product boundaries in one top-level extraction; should become integrations/provider and terminal/tmux commits. |
|
|
87
|
+
| `e155d5a` | locks | `squash/rebuild` | Useful code, but final home is `lib/core/coordination/locks.mjs`, not top-level `lib/locks.mjs`. |
|
|
88
|
+
| `9ab464d` | team planning | `squash/rebuild` | Same pattern; final home is `lib/core/coordination/teams.mjs`. |
|
|
89
|
+
| `807fa96` | peer identity | `squash/rebuild` | Useful extraction, but identity is split between integration discovery and core peer semantics later. |
|
|
90
|
+
| `494d38f` | peer format | `squash/rebuild` | Good low-level helper, but should land with peer-boundary cleanup rather than a standalone flat helper commit. |
|
|
91
|
+
| `e2b745d` | project registry | `squash/rebuild` | Final boundary is runtime/project registry. |
|
|
92
|
+
| `e4c4497` | project context | `squash/rebuild` | Final boundary is runtime/project context. |
|
|
93
|
+
| `dec3e2e` | handoff | `decision-needed` | `lib/handoff.mjs` remains top-level; decide core coordination semantics versus CLI command helper. |
|
|
94
|
+
| `61b02a2` | timeline | `squash/rebuild` | Final boundary is core coordination timeline. |
|
|
95
|
+
| `62ede11` | runtime state | `squash/rebuild` | Final boundary is `lib/runtime/state.mjs`. |
|
|
96
|
+
| `7d885f1` | task liveness | `squash/rebuild` | Final boundary is core peer liveness. |
|
|
97
|
+
| `3f0cc7e` | session launch | `decision-needed` | Current compatibility file bridges core session launch and terminal/tmux helpers; keep an eye on dependency direction. |
|
|
98
|
+
| `b07e9b5` | automation | `squash/rebuild` | Final boundary is core coordination automation. |
|
|
99
|
+
| `428bbf3` | state render | `squash/rebuild` | Final boundary is UI state rendering. |
|
|
100
|
+
| `8a6120f` | tmux pane | `squash/rebuild` | Should be folded into terminal/tmux movement. |
|
|
101
|
+
| `3ec062b` | help text | `squash/rebuild` | Final boundary is UI help. |
|
|
102
|
+
| `7e8068c` | uninstall help | `squash/rebuild` | Should be folded into UI help extraction. |
|
|
103
|
+
| `9ed79b6` | message store | `squash/rebuild` | Final boundary is core coordination messages. |
|
|
104
|
+
| `07ddcc9` | runtime client | `squash/rebuild` | Final boundary is `lib/runtime/client.mjs`. |
|
|
105
|
+
| `c06e55d` | web runtime server helpers | `squash/rebuild` | Useful step, but final boundary is `lib/web/runtime.mjs`; route/session/server split still pending. |
|
|
106
|
+
| `fe36930` | task store | `squash/rebuild` | Final boundary is core coordination tasks. |
|
|
107
|
+
| `3bd0782` | task CLI parsing | `keep-with-cleanup` | This is a CLI-specific helper and can remain near CLI until `lib/cli/*` exists. |
|
|
108
|
+
| `61538fc` | peer bindings | `squash/rebuild` | Final split crosses core peer bindings and db peer store. |
|
|
109
|
+
| `787857f` | CLI runtime | `keep-with-cleanup` | Still not the final `lib/cli/context.mjs` layout, but it is a valid CLI/runtime entrypoint reduction. |
|
|
110
|
+
| `00ac7ba` | coordination state | `squash/rebuild` | Useful factory boundary, but should be evaluated with core coordination dependencies. |
|
|
111
|
+
|
|
112
|
+
### Phase 2: Architecture Documentation And First Boundary Correction
|
|
113
|
+
|
|
114
|
+
| Commit | Area | Classification | Reason |
|
|
115
|
+
| --- | --- | --- | --- |
|
|
116
|
+
| `94d63c0` | architecture docs | `docs-only` | Correctly establishes the target layout. |
|
|
117
|
+
| `76d5181` | web peer actions | `squash/rebuild` | Good product boundary direction, but final import path is corrected later under `lib/web/peer-actions.mjs`. |
|
|
118
|
+
| `265284a` | broad architecture alignment | `keep-with-cleanup` | Correct direction, but too broad for ideal history; should become several product-boundary commits on a rebuild branch. Also review whether SQL/transaction-heavy task code belongs in `lib/core/coordination/tasks.mjs` or should split pure task policy from a db store. |
|
|
119
|
+
|
|
120
|
+
### Phase 3: Product-Boundary Cleanup Commits
|
|
121
|
+
|
|
122
|
+
These commits are much closer to the target design. They are the model for the
|
|
123
|
+
rebuild branch if one is created.
|
|
124
|
+
|
|
125
|
+
| Commit | Area | Classification | Reason |
|
|
126
|
+
| --- | --- | --- | --- |
|
|
127
|
+
| `294eb2e` | peer layout boundaries | `keep` | Moves peer semantics toward `core/peers`, `db/stores`, and integrations boundaries. |
|
|
128
|
+
| `a3eabd8` | tmux adapter | `keep` | Clear terminal adapter boundary. |
|
|
129
|
+
| `fb9c35a` | shared JSON file helpers | `keep-with-cleanup` | Shared utility is appropriate; keep `lib/json-file.mjs` compat because it was already published in `0.1.5`. |
|
|
130
|
+
| `77c098d` | provider commands | `keep` | Correct integrations boundary. |
|
|
131
|
+
| `6bbe4a0` | project context | `keep` | Correct runtime boundary. |
|
|
132
|
+
| `be7c882` | session launch helpers | `decision-needed` | Direction is mostly correct, but compat surface exports both core session and terminal/tmux helpers. Review dependency direction before release. |
|
|
133
|
+
| `ffc42a7` | setup hook installers | `keep` | Correct integrations/hooks boundary. |
|
|
134
|
+
| `1bd110f` | setup shims | `keep` | Correct integrations/shims boundary. |
|
|
135
|
+
| `c191c72` | shim script generator | `keep` | Correct integrations/shims/script boundary. |
|
|
136
|
+
| `11fd4f6` | CLI errors | `keep` | Correct small shared utility boundary with compatibility re-export. |
|
|
137
|
+
|
|
138
|
+
### Phase 4: Review And Policy Docs
|
|
139
|
+
|
|
140
|
+
| Commit | Area | Classification | Reason |
|
|
141
|
+
| --- | --- | --- | --- |
|
|
142
|
+
| `19c0856` | split review | `docs-only` | Captures the historical concern and branch strategy. |
|
|
143
|
+
| `4283234` | package surface policy | `docs-only` | Captures npm `0.1.5` fact, version-bump requirement, and A/B/C shim policy. |
|
|
144
|
+
|
|
145
|
+
## Initial Recommendations
|
|
146
|
+
|
|
147
|
+
### Use A New Branch
|
|
148
|
+
|
|
149
|
+
Yes. This is a major refactor stack and should not be pushed or published
|
|
150
|
+
directly just because `master` is currently green. Use this audit branch for
|
|
151
|
+
review. If the team chooses clean history, create a separate rebuild branch from
|
|
152
|
+
`origin/master`, not from current `master`.
|
|
153
|
+
|
|
154
|
+
Suggested rebuild branch:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
git worktree add ../hello-cc-layout-rebuild -b rebuild/layout-split-20260614 origin/master
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Suggested rebuilt commit order:
|
|
161
|
+
|
|
162
|
+
1. Architecture docs.
|
|
163
|
+
2. Core coordination modules: locks, teams, messages, tasks, timeline,
|
|
164
|
+
automation, liveness-related coordination state.
|
|
165
|
+
3. Core peer/session modules and db peer store.
|
|
166
|
+
4. Runtime modules: paths, state, client, project registry, project context.
|
|
167
|
+
5. Terminal adapter: tmux.
|
|
168
|
+
6. Web modules: runtime, HTTP, peer actions, UI template.
|
|
169
|
+
7. Integrations: providers, hooks, shims, shim script, peer identity.
|
|
170
|
+
8. Shared/release/ui helpers.
|
|
171
|
+
9. Compatibility shim policy and package-surface release notes.
|
|
172
|
+
|
|
173
|
+
### Do Not Revert The Final Shape Blindly
|
|
174
|
+
|
|
175
|
+
The final code shape is mostly aligned with the architecture document. The
|
|
176
|
+
problem is the noisy path taken to get there. A rebuild should preserve the
|
|
177
|
+
validated final behavior while changing the history granularity.
|
|
178
|
+
|
|
179
|
+
### Core/DB Review Findings
|
|
180
|
+
|
|
181
|
+
The core/db review from `#236` and the parallel read-only subagent agree on the
|
|
182
|
+
main shape:
|
|
183
|
+
|
|
184
|
+
- Keep the final direction of `lib/core/coordination/*`, `lib/core/peers/*`,
|
|
185
|
+
`lib/core/sessions/launch.mjs`, `lib/db/schema.mjs`,
|
|
186
|
+
`lib/db/stores/peers.mjs`, and `lib/shared/errors.mjs`.
|
|
187
|
+
- Rebuild the early top-level coordination/peer/session helper commits into
|
|
188
|
+
product-boundary commits if clean history is chosen.
|
|
189
|
+
- Do not treat `lib/handoff.mjs`, `lib/session-launch.mjs`, or
|
|
190
|
+
`lib/coordination-state.mjs` as settled final architecture.
|
|
191
|
+
|
|
192
|
+
Concrete cleanup items from that review:
|
|
193
|
+
|
|
194
|
+
- `lib/core/coordination/tasks.mjs` is currently SQL/transaction-heavy. Split
|
|
195
|
+
pure task lifecycle/takeover/team policy from DB store operations, or move the
|
|
196
|
+
store-style SQL operations under `lib/db/stores/tasks.mjs`.
|
|
197
|
+
- `lib/core/coordination/automation.mjs` and
|
|
198
|
+
`lib/core/coordination/timeline.mjs` depend on top-level `lib/format.mjs` for
|
|
199
|
+
`shellQuoteArg` / `compactText`. Move dependency-light text helpers to
|
|
200
|
+
`lib/shared/text.mjs` or keep rendering concerns in the UI/CLI layer.
|
|
201
|
+
- `lib/handoff.mjs` mixes CLI input normalization with runtime Git changed-file
|
|
202
|
+
discovery. Split handoff product semantics from CLI/runtime file inspection.
|
|
203
|
+
- `lib/session-launch.mjs` re-exports both core session helpers and
|
|
204
|
+
terminal/tmux helpers. That is acceptable only as a compatibility entrypoint;
|
|
205
|
+
do not let it become the conceptual module boundary.
|
|
206
|
+
- `lib/coordination-state.mjs` is useful as an interim assembler, but it mixes
|
|
207
|
+
DB queries, timeline, automation, hook context, status summary, and message
|
|
208
|
+
ack batching. Later split it into core state services plus CLI/Web adapters.
|
|
209
|
+
|
|
210
|
+
### Runtime/Web/Integrations Review Findings
|
|
211
|
+
|
|
212
|
+
The runtime/web/terminal/integrations review from `#235` and the parallel
|
|
213
|
+
read-only subagent agree on the main shape:
|
|
214
|
+
|
|
215
|
+
- Keep the final direction of `lib/terminal/tmux.mjs`.
|
|
216
|
+
- Keep the final direction of `lib/integrations/providers.mjs`,
|
|
217
|
+
`lib/integrations/hooks.mjs`, `lib/integrations/shims.mjs`, and
|
|
218
|
+
`lib/integrations/shims/script.mjs`.
|
|
219
|
+
- Keep the final direction of `lib/release/*`, `lib/shared/errors.mjs`, and
|
|
220
|
+
`lib/shared/json-file.mjs`.
|
|
221
|
+
- Keep the runtime and Web movement as directionally correct:
|
|
222
|
+
`lib/runtime/{paths,state,client,projects,project-context}.mjs` and
|
|
223
|
+
`lib/web/{http,runtime,ui-template,peer-actions}.mjs`.
|
|
224
|
+
|
|
225
|
+
Concrete cleanup items from that review:
|
|
226
|
+
|
|
227
|
+
- `lib/runtime/client.mjs` and `lib/runtime/state.mjs` import `runtimeApiUrl`
|
|
228
|
+
from `lib/web/runtime.mjs`. That creates a runtime -> web reverse dependency.
|
|
229
|
+
Move the URL helper into `lib/runtime`, `lib/shared`, or inject it from the
|
|
230
|
+
caller before claiming strict dependency direction.
|
|
231
|
+
- `lib/web/runtime.mjs` and `lib/web/peer-actions.mjs` import CLI parsing
|
|
232
|
+
helpers from `lib/cli-args.mjs`. Move shared option parsing such as
|
|
233
|
+
`intOpt`/`required` to a dependency-light shared helper, or inject parsing at
|
|
234
|
+
the route boundary.
|
|
235
|
+
- `lib/web/peer-actions.mjs` imports `normalizeStateResources` from
|
|
236
|
+
`lib/ui/state-render.mjs`. Move non-render normalization out of the UI layer,
|
|
237
|
+
or keep the dependency at a CLI/Web adapter edge.
|
|
238
|
+
- `cmdWeb()` in `bin/hcc.mjs` still owns server lifecycle, session manager,
|
|
239
|
+
WebSocket terminal transport, tmux/PTY orchestration, external-buffer
|
|
240
|
+
adoption, and shutdown cleanup. Future work should split this by subsystem;
|
|
241
|
+
do not continue random helper extraction from it.
|
|
242
|
+
|
|
243
|
+
No immediate runtime blocker was found. `#235` also reran `npm test` and got
|
|
244
|
+
`FULL_REGRESSION_OK`.
|
|
245
|
+
|
|
246
|
+
### Decide Shim Policy Before Release
|
|
247
|
+
|
|
248
|
+
Because `@logicseek/hello-cc@0.1.5` is already published from `4969100`, the
|
|
249
|
+
next package version must be new. Before that publish:
|
|
250
|
+
|
|
251
|
+
- Group A: already-published or CLI-facing top-level `lib/*.mjs` paths stay.
|
|
252
|
+
- Group B: migration compatibility paths stay one release if needed and are
|
|
253
|
+
documented as compatibility-only deep-import paths.
|
|
254
|
+
- Group C: unpublished top-level shims with no internal use or compatibility
|
|
255
|
+
value should be removed before release.
|
|
256
|
+
|
|
257
|
+
Initial package-surface inventory:
|
|
258
|
+
|
|
259
|
+
| Group | Paths | Current decision |
|
|
260
|
+
| --- | --- | --- |
|
|
261
|
+
| A: published in `0.1.5` | `lib/cli-args.mjs`, `lib/db-schema.mjs`, `lib/discover.mjs`, `lib/errors.mjs`, `lib/format.mjs`, `lib/guidance.mjs`, `lib/json-file.mjs`, `lib/package-meta.mjs`, `lib/release-notes.mjs`, `lib/runtime-paths.mjs`, `lib/setup.mjs`, `lib/shell-path.mjs`, `lib/shim-script.mjs`, `lib/web-http.mjs`, `lib/web-runtime.mjs`, `lib/web-ui-template.mjs` | Keep for the next release, even if some are now compatibility re-exports. Removing them would be a package-surface break. |
|
|
262
|
+
| A: current internal top-level runtime refs | `lib/cli-runtime.mjs`, `lib/coordination-state.mjs`, `lib/handoff.mjs`, `lib/project-context.mjs`, `lib/task-cli.mjs`, `lib/tmux.mjs` | Keep until a focused cleanup moves current internal imports to the target directories. Do not delete these as pure compatibility shims today. |
|
|
263
|
+
| B/C candidates: new re-export-only paths with no current runtime ref | `lib/automation.mjs`, `lib/help.mjs`, `lib/locks.mjs`, `lib/messages.mjs`, `lib/peer-bindings.mjs`, `lib/peer-format.mjs`, `lib/peer-identity.mjs`, `lib/project-registry.mjs`, `lib/provider-commands.mjs`, `lib/runtime-client.mjs`, `lib/runtime-state.mjs`, `lib/session-launch.mjs`, `lib/state-render.mjs`, `lib/task-liveness.mjs`, `lib/task-store.mjs`, `lib/team-planning.mjs`, `lib/timeline.mjs`, `lib/web-peer-actions.mjs` | Treat as C only if the project decides they have no migration compatibility value. Otherwise keep for one release as B and document them as compatibility-only deep imports. |
|
|
264
|
+
| C: remove before publish | None confirmed yet | Do not delete by guess. A candidate becomes C only after checking it was not in `0.1.5`, is not imported internally, and has no release compatibility value. |
|
|
265
|
+
|
|
266
|
+
### Watch Items
|
|
267
|
+
|
|
268
|
+
- `lib/handoff.mjs`: decide core coordination versus CLI command helper.
|
|
269
|
+
- `lib/session-launch.mjs`: review mixed core session and terminal/tmux
|
|
270
|
+
compatibility exports.
|
|
271
|
+
- `lib/core/coordination/tasks.mjs`: split pure task policy from DB store style
|
|
272
|
+
SQL/transactions.
|
|
273
|
+
- `lib/core/coordination/{automation,timeline}.mjs`: remove dependency on
|
|
274
|
+
top-level `lib/format.mjs`.
|
|
275
|
+
- `lib/coordination-state.mjs`: keep as interim assembler, but split before
|
|
276
|
+
claiming final architecture.
|
|
277
|
+
- `lib/runtime/{client,state}.mjs`: remove reverse dependency on
|
|
278
|
+
`lib/web/runtime.mjs`.
|
|
279
|
+
- `lib/web/{runtime,peer-actions}.mjs`: remove direct dependency on CLI parsing
|
|
280
|
+
helpers.
|
|
281
|
+
- `lib/web/peer-actions.mjs`: remove direct dependency on UI state-render
|
|
282
|
+
helpers for non-render normalization.
|
|
283
|
+
- `scripts/regression.mjs`: current test coverage is valuable, but its size
|
|
284
|
+
should be split after the architecture stack is stable.
|
|
285
|
+
- `bin/hcc.mjs`: still contains large command and Web orchestration areas; do
|
|
286
|
+
not continue extracting from it until this audit decides branch strategy.
|
|
287
|
+
|
|
288
|
+
## Current Status
|
|
289
|
+
|
|
290
|
+
Peer feedback from `#235`, `#236`, and `#237` has been merged into this audit.
|
|
291
|
+
The audit conclusion is:
|
|
292
|
+
|
|
293
|
+
- The final code shape is mostly reasonable.
|
|
294
|
+
- The early commit history is not clean architecture history.
|
|
295
|
+
- Use a new rebuild branch from `origin/master` if clean history matters.
|
|
296
|
+
- Keep the current `master` stack only if the project accepts noisy local
|
|
297
|
+
history and completes the release cleanup items above before publish.
|
|
298
|
+
- Do not resume release task `#233` until this audit decision is accepted.
|
package/lib/cli-args.mjs
CHANGED