@logicseek/hello-cc 0.1.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.
package/docs/design.md ADDED
@@ -0,0 +1,263 @@
1
+ # hello-cc Design
2
+
3
+ Date: 2026-06-09
4
+
5
+ ## Requirement Boundary
6
+
7
+ hello-cc targets same-project, cross-session coordination for ordinary local
8
+ terminal sessions:
9
+
10
+ - multiple Claude Code sessions;
11
+ - multiple Codex CLI sessions;
12
+ - sessions started independently from different terminals;
13
+ - durable tasks, messages, locks, handoffs, and events;
14
+ - conflict visibility while peers edit the same project;
15
+ - LAN web observability and terminal operation.
16
+
17
+ This is not only "Claude talks to Codex". It is a local coordination layer for
18
+ all active coding CLI sessions in one project.
19
+
20
+ The model is a flat peer mesh, not a CCB-style main/worker topology:
21
+
22
+ ```text
23
+ codex-a <-> codex-b
24
+ ^ ^
25
+ | |
26
+ claude-a <-> claude-b
27
+ ```
28
+
29
+ Every session is a named peer. Optional labels such as `reviewer`, `runner`, or
30
+ `docs` may help humans route work, but they do not create hierarchy.
31
+
32
+ ## Project Boundary
33
+
34
+ By default, "same project" means the exact current working directory. On first
35
+ use hello-cc creates:
36
+
37
+ ```text
38
+ <cwd>/.hello-cc/mesh.db
39
+ ```
40
+
41
+ It does not automatically walk to parent directories and inherit their bus. This
42
+ keeps project membership predictable: two terminals communicate automatically
43
+ when they are started from the same project path.
44
+
45
+ Cross-path sharing is explicit:
46
+
47
+ ```bash
48
+ hcc --root /path/to/project web
49
+ export HCC_ROOT=/path/to/project
50
+ export HCC_DB=/path/to/project/.hello-cc/mesh.db
51
+ ```
52
+
53
+ ## Default UX
54
+
55
+ The default user path is one command:
56
+
57
+ ```bash
58
+ cd /path/to/project
59
+ hcc web
60
+ ```
61
+
62
+ `hcc web` must:
63
+
64
+ - initialize the project-local SQLite bus;
65
+ - install or refresh Claude Code hooks;
66
+ - install or refresh Codex hooks;
67
+ - install or refresh `claude` and `codex` shell shims;
68
+ - add the shim directory to PATH when needed;
69
+ - ensure `tmux` is available, with best-effort automatic install and a clear
70
+ install command if it cannot install;
71
+ - start the web runtime in the background;
72
+ - print URL, PID, runtime path, log path, and stop command;
73
+ - return control to the invoking terminal.
74
+
75
+ Plain `claude` and `codex` commands in a new shell should then become
76
+ tmux-backed hello-cc peers automatically. The local terminal attaches to the
77
+ same tmux session that the web console can display and operate.
78
+
79
+ `hcc up` remains a lower-level command for local coordination without Web or
80
+ shims. Maintenance commands may exist for tests and manual cleanup, but they are
81
+ not the public product path.
82
+
83
+ ## Capability Levels
84
+
85
+ ```text
86
+ Level 1: Coordination
87
+ Any Claude/Codex/human terminal can communicate by running hcc commands or by
88
+ firing installed hooks. This covers tasks, messages, locks, handoffs, and
89
+ status.
90
+
91
+ Level 2: Web-attached local terminals
92
+ hello-cc starts Claude/Codex/shell as local tmux-backed terminals, wraps
93
+ direct claude/codex launches through shims, or attaches an existing tmux pane.
94
+ The web UI displays and operates those terminals through WebSocket.
95
+
96
+ Level 3: Existing raw terminal takeover
97
+ A terminal already opened outside hello-cc cannot be fully captured or
98
+ controlled unless it is already inside tmux, screen, or another attachable PTY
99
+ layer. It can still participate in coordination.
100
+ ```
101
+
102
+ `hcc down` stops only the web runtime. It does not kill tmux-backed terminals.
103
+ Running `hcc web` again reattaches live recorded panes.
104
+
105
+ ## Technical Route
106
+
107
+ Recommended first layer:
108
+
109
+ ```text
110
+ Node npm CLI
111
+ + built-in node:sqlite
112
+ + project-local .hello-cc/mesh.db
113
+ + Claude/Codex hooks for prompt-time context
114
+ + tmux as the browser-controllable local terminal backend
115
+ + shell shims for transparent claude/codex launch
116
+ ```
117
+
118
+ Why:
119
+
120
+ - ordinary terminals can join;
121
+ - no MCP requirement for local communication;
122
+ - no A2A requirement for local terminal/worktree coordination;
123
+ - SQLite transactions are enough for low-volume coordination writes;
124
+ - Node gives a natural npm CLI packaging path;
125
+ - Node 24 has built-in SQLite;
126
+ - tmux gives persistent local terminals that survive web runtime restarts.
127
+
128
+ Rejected as the first layer:
129
+
130
+ - A2A: useful for remote peer interoperability, not required for local terminal
131
+ coordination.
132
+ - MCP-only: useful later as a tool surface, but too indirect for transparent
133
+ cross-session operation.
134
+ - tmux-only: good for managed terminals, but hooks and CLI commands are still
135
+ needed for already-open raw sessions.
136
+ - shared markdown/jsonl files: simple, but weak for atomic task claims and lock
137
+ acquisition.
138
+
139
+ ## Runtime Framework
140
+
141
+ ```text
142
+ Node >= 24
143
+ node:sqlite DatabaseSync
144
+ SQLite WAL
145
+ Node HTTP server
146
+ ws WebSocket
147
+ xterm.js browser renderer
148
+ tmux create/capture/send for terminal control
149
+ Claude Code hooks
150
+ Codex hooks
151
+ shell shim wrappers
152
+ ```
153
+
154
+ Control plane:
155
+
156
+ ```text
157
+ CLI commands and HTTP JSON APIs read/write SQLite.
158
+ ```
159
+
160
+ Terminal plane:
161
+
162
+ ```text
163
+ Browser xterm.js sends keyboard bytes over WebSocket.
164
+ Server writes bytes into tmux panes.
165
+ Server polls/captures tmux pane output and broadcasts it to browsers.
166
+ ```
167
+
168
+ ## Core Tables
169
+
170
+ ```text
171
+ peers stable terminal identities and heartbeat
172
+ peer_bindings provider session binding and runtime transport metadata
173
+ tasks task assignment, ownership, and lifecycle
174
+ messages direct or broadcast messages
175
+ message_reads per-peer ack state
176
+ locks advisory exclusive locks with TTL
177
+ handoffs durable cross-session handoff summaries
178
+ events audit trail for observability
179
+ ```
180
+
181
+ ## Coordination Semantics
182
+
183
+ - `task claim`, `task next`, `lock acquire`, `lock release`, and `handoff
184
+ create` use `BEGIN IMMEDIATE`.
185
+ - SQLite runs with WAL and `busy_timeout=5000`.
186
+ - Tasks are project facts. They remain visible to all peers until status becomes
187
+ `done` or `abandoned`.
188
+ - Messages are addressed mailbox items. Read state is tracked per peer.
189
+ - Broadcast messages use per-peer acknowledgement, so one peer cannot consume a
190
+ message for everyone else.
191
+ - Locks are advisory and TTL-based. Peers must follow the protocol.
192
+
193
+ ## Hook Path
194
+
195
+ The primary model-facing path is hook context injection, not project markdown.
196
+
197
+ `hcc web` installs hooks that register sessions and inject hello-cc snapshots at
198
+ session start and before model answers. The injected snapshot contains current
199
+ peer identity, active peers, open tasks, unread messages, active locks, and the
200
+ commands the model should use to inspect state.
201
+
202
+ `CLAUDE.md`, `AGENTS.md`, and `.hello-cc/HCC.md` are fallback instruction
203
+ layers. Existing root files are updated only inside a bounded hello-cc block.
204
+
205
+ ## Provider Session Binding
206
+
207
+ hello-cc peer IDs are separate from Claude/Codex conversation IDs:
208
+
209
+ ```text
210
+ peer: codex-a
211
+ provider: codex
212
+ provider_session_id: Codex/Claude resume id or name when known
213
+ resume_mode: new | resume | last | continue | fork | fork-resume
214
+ transport: tmux | hcc-run | detected | optional pty
215
+ ```
216
+
217
+ Known resume IDs map to stable peer IDs. Launch modes that do not expose the
218
+ real provider session before startup use a terminal-derived peer ID first, then
219
+ hooks or discovery record provider metadata after the session starts.
220
+
221
+ `hcc peer start` records bindings when it launches or reuses a tmux-backed
222
+ terminal:
223
+
224
+ ```bash
225
+ hcc peer start codex-a --kind codex --resume <session-id-or-name>
226
+ hcc peer start codex-b --kind codex --last
227
+ hcc peer start claude-a --kind claude --resume <session-id>
228
+ hcc peer start claude-b --kind claude --continue
229
+ ```
230
+
231
+ `hcc peer attach` records a tmux transport binding when it imports an existing
232
+ pane:
233
+
234
+ ```bash
235
+ hcc peer attach codex-a --pane %1
236
+ ```
237
+
238
+ If a known provider session is already bound to another peer, hello-cc blocks a
239
+ second binding unless `--force` is used.
240
+
241
+ ## Applied Lessons
242
+
243
+ - `claude_codex_bridge` proves tmux-backed mixed-provider workspaces are useful,
244
+ but hello-cc avoids fixed main/worker topology.
245
+ - `hcom` proves local SQLite plus hooks is a strong cross-session communication
246
+ model.
247
+ - `squad` proves a project-local mailbox/task protocol can stay transparent and
248
+ easy to operate.
249
+ - `dmux` proves npm CLI plus worktree/session management is a good outer layer,
250
+ but it is not itself the communication bus.
251
+ - `agent-bus` has strong bus semantics, but its primary integration path is MCP.
252
+
253
+ hello-cc combines hooks + SQLite + tmux first, leaving MCP/A2A/worktree layers
254
+ optional.
255
+
256
+ ## Next Iterations
257
+
258
+ 1. Harden hook payloads for lock warnings and handoff reminders.
259
+ 2. Add a watch command for live inbox/event tailing.
260
+ 3. Add terminal output snapshot/export commands for runtime-attached sessions.
261
+ 4. Add screen attach support for already-running attachable sessions.
262
+ 5. Publish as an npm package with a stable `npx hcc` flow.
263
+ 6. Add worktree helpers only after the core bus and terminal model are stable.
@@ -0,0 +1,345 @@
1
+ # hello-cc Implementation Plan
2
+
3
+ Date: 2026-06-09
4
+
5
+ ## Product Requirement
6
+
7
+ hello-cc is a project-local peer mesh for coding CLI sessions. It connects
8
+ multiple Claude Code and Codex terminals in the same project so they can
9
+ communicate, coordinate work, avoid conflicts, hand off progress, and be
10
+ operated through a LAN web UI.
11
+
12
+ Default project identity is the exact current working directory. On first use,
13
+ hello-cc creates `<cwd>/.hello-cc/mesh.db`; it does not inherit a parent
14
+ directory's mesh automatically. Users who want several paths or worktrees to
15
+ share one bus must set `--root`, `HCC_ROOT`, or `HCC_DB` explicitly.
16
+
17
+ The model is flat:
18
+
19
+ ```text
20
+ codex-a <-> codex-b
21
+ ^ ^
22
+ | |
23
+ claude-a <-> claude-b
24
+ ```
25
+
26
+ There is no required `main`, `worker`, or `reviewer`. Every session is a peer.
27
+
28
+ ## Target UX
29
+
30
+ The default user experience is:
31
+
32
+ ```bash
33
+ cd /path/to/project
34
+ hcc web
35
+ ```
36
+
37
+ Expected output:
38
+
39
+ ```text
40
+ hello-cc web started in background
41
+ pid: 12345
42
+ project: /path/to/project
43
+ database: /path/to/project/.hello-cc/mesh.db
44
+ runtime: /path/to/project/.hello-cc/runtime.json
45
+ log: /path/to/project/.hello-cc/web.log
46
+ open: http://<machine-ip>:8787/?token=xxxxx
47
+ local: http://127.0.0.1:8787/?token=xxxxx
48
+ shims: installed claude, codex
49
+ PATH updated in ~/.bashrc; open a new terminal or source it
50
+ stop: hcc down
51
+ ```
52
+
53
+ `hcc web` is responsible for bootstrap and runtime startup:
54
+
55
+ - project-local SQLite bus;
56
+ - bounded guidance files;
57
+ - Claude Code hooks;
58
+ - Codex hooks;
59
+ - `claude` and `codex` shell shims;
60
+ - shell PATH entry for the shims;
61
+ - tmux availability;
62
+ - background web runtime.
63
+
64
+ After that, opening a new shell and typing `claude` or `codex` should create or
65
+ reuse a tmux-backed local terminal. The user interacts in the local terminal,
66
+ and the web console can operate the same tmux pane. `hcc down` stops the web
67
+ runtime only and leaves tmux terminals alive.
68
+
69
+ `hcc up` remains a lower-level local coordination command. Maintenance commands
70
+ remain available for tests and manual recovery, but the public product path is
71
+ `hcc web`.
72
+
73
+ ## Architecture
74
+
75
+ hello-cc is session-runtime-first:
76
+
77
+ ```text
78
+ hcc CLI
79
+ |
80
+ +-- neutral web runtime
81
+ | |
82
+ | +-- peer registry
83
+ | +-- routing and injection
84
+ | +-- task / message / lock / handoff services
85
+ | +-- tmux terminal supervisor
86
+ |
87
+ +-- control plane
88
+ | |
89
+ | +-- SQLite WAL
90
+ | +-- HTTP REST
91
+ | +-- hook entrypoints
92
+ |
93
+ +-- terminal plane
94
+ |
95
+ +-- tmux adapter
96
+ +-- shell shims
97
+ +-- optional node-pty adapter
98
+ +-- WebSocket terminal stream
99
+ +-- xterm.js web terminal
100
+ ```
101
+
102
+ The runtime is not a main peer. It is a neutral router and state machine.
103
+
104
+ ## Core Protocol
105
+
106
+ Peers:
107
+
108
+ ```text
109
+ id codex-a, claude-a, shell-a
110
+ kind codex | claude | shell | custom
111
+ tags optional routing labels
112
+ transport tmux | hcc-run | detected | optional pty
113
+ target tmux pane id or optional pty session id
114
+ status idle | busy | blocked | stale | exited
115
+ ```
116
+
117
+ Messages:
118
+
119
+ ```text
120
+ from peer
121
+ to peer | all | tag:<tag> | task:<task-id>
122
+ kind note | ask | handoff | system
123
+ delivery store-only | inject-terminal | both
124
+ ```
125
+
126
+ Tasks:
127
+
128
+ ```text
129
+ pending -> claimed -> running -> review/block/done|abandoned
130
+ owner is dynamic; there is no fixed dispatcher
131
+ ```
132
+
133
+ Default task reads are lifecycle-based: all peers see tasks until they are
134
+ `done` or `abandoned`. Read/ack state exists only for messages.
135
+
136
+ Locks:
137
+
138
+ ```text
139
+ resource -> owner peer
140
+ TTL-based advisory lock
141
+ resource can be file, directory, module, test env, GPU, or service port
142
+ ```
143
+
144
+ ## User-Facing Commands
145
+
146
+ Primary:
147
+
148
+ ```bash
149
+ hcc web
150
+ hcc down
151
+ ```
152
+
153
+ Coordination:
154
+
155
+ ```bash
156
+ hcc peers
157
+ hcc status
158
+ hcc task create/list/claim/next/update/done
159
+ hcc msg send/inbox/ack
160
+ hcc lock acquire/renew/release/list
161
+ hcc handoff create/list
162
+ hcc event tail
163
+ hcc ask
164
+ hcc broadcast
165
+ ```
166
+
167
+ Terminal control:
168
+
169
+ ```bash
170
+ hcc peer list
171
+ hcc peer start codex-a --kind codex -- codex
172
+ hcc peer start codex-a --kind codex --resume <session-id-or-name>
173
+ hcc peer start codex-a --kind codex --last
174
+ hcc peer start claude-a --kind claude --resume <session-id>
175
+ hcc peer start claude-a --kind claude --continue
176
+ hcc peer attach codex-a --pane %1
177
+ hcc peer stop codex-a
178
+ hcc inject codex-a "hcc msg inbox --peer codex-a"
179
+ ```
180
+
181
+ Lower-level:
182
+
183
+ ```bash
184
+ hcc up
185
+ hcc run --peer codex-a --kind codex -- codex
186
+ ```
187
+
188
+ `hcc run` registers and runs a command in the current terminal. Browser
189
+ control should use `hcc peer start`, the web UI, or the installed shims.
190
+
191
+ ## Technical Stack
192
+
193
+ Runtime and CLI:
194
+
195
+ ```text
196
+ Node.js >= 24
197
+ node:sqlite
198
+ local option parser
199
+ ```
200
+
201
+ State:
202
+
203
+ ```text
204
+ SQLite WAL
205
+ project-local DB
206
+ busy_timeout for concurrent CLI access
207
+ BEGIN IMMEDIATE for task claim and lock acquisition
208
+ ```
209
+
210
+ Terminal control:
211
+
212
+ ```text
213
+ tmux
214
+ tmux send-keys
215
+ tmux load-buffer / paste-buffer
216
+ tmux capture-pane
217
+ tmux attach-session / switch-client
218
+ node-pty optional internal backend
219
+ ```
220
+
221
+ Web:
222
+
223
+ ```text
224
+ Node HTTP server
225
+ ws WebSocket
226
+ xterm.js
227
+ token authentication for LAN access
228
+ ```
229
+
230
+ Integrations:
231
+
232
+ ```text
233
+ Claude Code hooks
234
+ Codex hooks
235
+ UserPromptSubmit additionalContext
236
+ SessionStart additionalContext
237
+ shell shim wrappers
238
+ ```
239
+
240
+ ## Shim Behavior
241
+
242
+ `hcc web` installs shims into `~/.hcc-shims`. Each shim:
243
+
244
+ 1. Resolves the hello-cc project root from the current directory or `HCC_ROOT`.
245
+ 2. Parses provider resume/session arguments for a stable peer ID.
246
+ 3. Exports `HCC_PEER` and `HCC_ROOT`.
247
+ 4. Ensures the web runtime is running.
248
+ 5. Calls `hcc peer start <peer> --kind <kind> -- <real-binary> ...`.
249
+ 6. Attaches the local terminal to the tmux session returned by `peer start`.
250
+
251
+ If the shim is invoked non-interactively, it prints the `peer start` output and
252
+ does not attach.
253
+
254
+ ## Reference Projects
255
+
256
+ ### claude_codex_bridge
257
+
258
+ Path:
259
+
260
+ ```text
261
+ <checkout>/claude_codex_bridge
262
+ ```
263
+
264
+ Use for tmux session ownership, pane registry, injection with `send-keys` /
265
+ `load-buffer` / `paste-buffer`, output capture, and recoverable visible CLI
266
+ workspaces. Do not copy fixed main/worker topology or role-pack assumptions.
267
+
268
+ ### hcom
269
+
270
+ Use for local SQLite + hooks communication and live cross-session notification
271
+ ideas.
272
+
273
+ ### squad
274
+
275
+ Use for project-local mailbox/task ergonomics.
276
+
277
+ ### dmux
278
+
279
+ Use for npm CLI UX and optional worktree/session management ideas.
280
+
281
+ ### agent-bus
282
+
283
+ Use for richer task/message/handoff/review semantics. MCP remains optional.
284
+
285
+ ## Implementation Phases
286
+
287
+ Phase 1: current protocol
288
+
289
+ ```text
290
+ SQLite bus
291
+ flat peer identities
292
+ task/message/lock/handoff/event
293
+ run wrapper
294
+ tmux-backed peer start
295
+ tmux pane attach
296
+ ```
297
+
298
+ Phase 2: default bootstrap
299
+
300
+ ```text
301
+ hcc web as the one-command entrypoint
302
+ hooks installed by default
303
+ shims installed by default
304
+ tmux ensured by default
305
+ background web runtime
306
+ ```
307
+
308
+ Phase 3: terminal hardening
309
+
310
+ ```text
311
+ create or reuse tmux-backed local terminal with hcc peer start
312
+ attach existing tmux pane with hcc peer attach
313
+ record peer -> pane_id
314
+ inject via send-keys
315
+ capture output via capture-pane
316
+ detach without killing user panes
317
+ ```
318
+
319
+ Phase 4: direct CLI ergonomics
320
+
321
+ ```text
322
+ plain claude/codex auto-start tmux-backed peers
323
+ resume/fork/continue-aware peer identity
324
+ hooks for prompt-time snapshots, heartbeat, lock reminders, and handoff reminders
325
+ ```
326
+
327
+ Phase 5: hardening
328
+
329
+ ```text
330
+ stale session recovery
331
+ token and access controls
332
+ audit log
333
+ worktree isolation
334
+ merge queue
335
+ MCP adapter only if useful
336
+ A2A adapter only for remote/server peers
337
+ ```
338
+
339
+ ## Non-Goals For The Core
340
+
341
+ - No required MCP setup.
342
+ - No required A2A protocol.
343
+ - No fixed main/worker hierarchy.
344
+ - No attempt to invisibly control a raw existing terminal that was not started
345
+ by hello-cc, tmux, screen, or another attachable PTY layer.