@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
@@ -1,217 +0,0 @@
1
- # Architecture Split Review
2
-
3
- Date: 2026-06-14
4
-
5
- This review covers the local commits on `master` that are ahead of
6
- `origin/master` after `0.1.5`.
7
-
8
- It is written from the separate review branch
9
- `arch-review/split-layout-from-origin`. The main worktree is intentionally left
10
- untouched because other peers may still be finishing scoped implementation work.
11
-
12
- ## Recommendation
13
-
14
- Keep the current architecture direction. Do not merge the new product-boundary
15
- modules back into `bin/hcc.mjs`, and do not collapse them into another large
16
- generic helper file.
17
-
18
- If the goal is to publish or synchronize soon, keep the current local commit
19
- history and add one or more cleanup commits. Those cleanup commits should focus
20
- on remaining boundary issues and compatibility-shim policy.
21
-
22
- If the goal is clean commit history, rebuild the stack in a separate worktree
23
- from `origin/master`. Do not rewrite the active `master` worktree while peers
24
- are coordinating through it.
25
-
26
- ## What Happened
27
-
28
- The first local split commits were mostly flat helper extraction from
29
- `bin/hcc.mjs` into top-level `lib/*.mjs` files. They reduced the entrypoint size
30
- but did not yet express the product architecture:
31
-
32
- - provider and tmux helpers
33
- - lock and team planning helpers
34
- - peer identity, peer format, and peer binding helpers
35
- - project registry and project context helpers
36
- - handoff, timeline, runtime state, task liveness, automation, and render helpers
37
- - help text, message store, runtime request, task store, task CLI, and
38
- coordination-state helpers
39
-
40
- Later commits introduced `docs/architecture.md` and started moving primary
41
- implementations into product boundaries:
42
-
43
- - `lib/core/coordination`
44
- - `lib/core/peers`
45
- - `lib/core/sessions`
46
- - `lib/db`
47
- - `lib/db/stores`
48
- - `lib/runtime`
49
- - `lib/terminal`
50
- - `lib/web`
51
- - `lib/integrations`
52
- - `lib/release`
53
- - `lib/shared`
54
- - `lib/ui`
55
-
56
- That second phase is the correct direction.
57
-
58
- ## Keep
59
-
60
- These boundaries are worth keeping as the primary implementation shape:
61
-
62
- - `lib/core/coordination/*` for product coordination semantics.
63
- - `lib/core/peers/*` for pure peer semantics.
64
- - `lib/db/schema.mjs` and `lib/db/stores/*` for SQLite schema and stores.
65
- - `lib/runtime/*` for runtime files, runtime client access, project registry,
66
- and project context.
67
- - `lib/terminal/tmux.mjs` for tmux adapter behavior.
68
- - `lib/web/*` for Web runtime, HTTP helpers, peer actions, and UI template.
69
- - `lib/integrations/*` for provider, hook, shim, and process integration
70
- details.
71
- - `lib/release/*` for release metadata and release-note logic.
72
- - `lib/shared/*` only for small dependency-light utilities.
73
- - `lib/ui/*` for text/help/state rendering.
74
-
75
- ## Cleanup Candidates
76
-
77
- The remaining cleanup should be deliberate, not another broad helper extraction.
78
-
79
- ### Top-Level Compatibility Shims
80
-
81
- Many top-level `lib/*.mjs` files are now compatibility re-export shims. Examples
82
- include `lib/tmux.mjs`, `lib/provider-commands.mjs`, `lib/web-runtime.mjs`,
83
- `lib/web-http.mjs`, `lib/web-ui-template.mjs`, `lib/task-store.mjs`,
84
- `lib/messages.mjs`, `lib/locks.mjs`, `lib/db-schema.mjs`, and
85
- `lib/session-launch.mjs`.
86
-
87
- Before publish:
88
-
89
- - Treat the installed CLI commands as the public API. Do not document new
90
- `@logicseek/hello-cc/lib/*` imports as user-facing API.
91
- - `@logicseek/hello-cc@0.1.5` is already published from git head `4969100`, and
92
- that package exposed several top-level `lib/*.mjs` helper paths because the
93
- package includes `lib/` and has no `exports` map.
94
- - Keep already-published top-level `lib/*.mjs` paths as compatibility
95
- re-exports for at least one release cycle unless the project explicitly
96
- chooses a breaking package-surface change.
97
- - For compatibility shims added only in local commits after `0.1.5`, either
98
- remove them before the next publish or document them in the release notes as
99
- compatibility-only and revisit removal before the following release.
100
- - Do not let compatibility shims become the target architecture. Primary
101
- implementations should live under the product-boundary directories.
102
-
103
- Classify top-level shims before release:
104
-
105
- - Group A: already-published or CLI-facing helper paths that stay stable for
106
- this release.
107
- - Group B: migration compatibility paths that re-export moved implementations;
108
- keep only if needed and describe them as compatibility-only deep-import paths.
109
- - Group C: unpublished shims with no internal use and no compatibility value;
110
- remove before publishing.
111
-
112
- ### CLI Boundary
113
-
114
- `bin/hcc.mjs` is smaller but still mixes command dispatch, command handlers, Web
115
- startup, session lifecycle, and terminal/Web orchestration. Future work should
116
- move by command or subsystem boundary, not by helper name.
117
-
118
- Good next boundaries:
119
-
120
- - `lib/cli/args.mjs`
121
- - `lib/cli/context.mjs`
122
- - `lib/cli/dispatch.mjs`
123
- - `lib/cli/commands/*`
124
-
125
- ### Regression Runner
126
-
127
- `scripts/regression.mjs` has grown too large. It should become a runner over
128
- domain-specific files:
129
-
130
- - `scripts/regression/cli.mjs`
131
- - `scripts/regression/db.mjs`
132
- - `scripts/regression/runtime.mjs`
133
- - `scripts/regression/web.mjs`
134
- - `scripts/regression/integrations.mjs`
135
- - `scripts/regression/release.mjs`
136
-
137
- This should be done after the current layout work is stable, because regression
138
- coverage is the safety net for the refactor.
139
-
140
- ### Setup, Discover, Guidance, and Shims
141
-
142
- `lib/setup.mjs`, `lib/discover.mjs`, `lib/guidance.mjs`, and
143
- `lib/shim-script.mjs` still carry mixed responsibilities. Continue splitting
144
- these by product boundary:
145
-
146
- - hooks under `lib/integrations/hooks*`
147
- - shims under `lib/integrations/shims*`
148
- - shell and terminal adapters under `lib/terminal`
149
- - runtime/project concerns under `lib/runtime`
150
- - guidance text generation under `lib/ui` or a dedicated guidance boundary
151
-
152
- ### Handoff Boundary
153
-
154
- `lib/handoff.mjs` is still a top-level helper. Decide whether it belongs in
155
- `lib/core/coordination/handoff.mjs` as product semantics or under
156
- `lib/cli/commands/handoff.mjs` if it is mostly CLI formatting and file listing.
157
-
158
- ## Branch Strategy
159
-
160
- Use one of two paths.
161
-
162
- Path A: publish-oriented cleanup
163
-
164
- 1. Keep current `master` history.
165
- 2. Add focused cleanup commits.
166
- 3. Run full regression, release checks, GitHub release dry-run, and pack dry-run.
167
- 4. Publish/synchronize only after the cleanup decision is complete.
168
-
169
- Path B: clean-history rebuild
170
-
171
- 1. Keep `master` untouched.
172
- 2. Use a separate worktree from `origin/master`.
173
- 3. Rebuild the split as fewer architectural commits:
174
- - architecture docs
175
- - core coordination and peer semantics
176
- - db schema/stores
177
- - runtime/project/session helpers
178
- - terminal adapters
179
- - web runtime and UI
180
- - integrations providers/hooks/shims
181
- - release/shared/ui helpers
182
- - regression restructuring
183
- 4. Run full regression and release checks before replacing the active stack.
184
-
185
- ## Current Decision
186
-
187
- The safer default is Path A: keep current history and add cleanup commits.
188
-
189
- Choose Path B only if the project explicitly values a clean local commit stack
190
- more than the time and risk of rebuilding and revalidating the entire series.
191
-
192
- The current safety refs are:
193
-
194
- - `safety/layout-split-20260614-at-ffc42a7`, protecting the earlier split stack.
195
- - `safety/layout-split-20260614-at-11fd4f6`, protecting the split stack through
196
- `11fd4f6` before this package-surface policy update.
197
-
198
- Because `0.1.5` is already on npm, the next publish that includes the current
199
- local commits must bump the package version. Do not republish `0.1.5`.
200
-
201
- ## Coordination Notes
202
-
203
- Continue finishing any already-started layout lanes that are clearly correcting
204
- the architecture boundary. For example, moving setup hooks and shim
205
- implementation into `lib/integrations` is still part of the same boundary
206
- cleanup, not a new random helper extraction.
207
-
208
- After those active lanes finish, pause new implementation splits and make a
209
- cleanup decision:
210
-
211
- 1. Decide whether this review document should be copied into `master` as a
212
- durable design record.
213
- 2. Decide whether top-level compatibility shims are public for this release.
214
- 3. If shims are kept, document that they are compatibility paths.
215
- 4. If shims are removed, do it before publish and run full pack/release checks.
216
- 5. Do not start broad `bin/hcc.mjs` command extraction or regression runner
217
- splitting until the shim policy is settled.
@@ -1,298 +0,0 @@
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.