@logicseek/hello-cc 0.1.6 → 0.1.8
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 +104 -0
- package/README.md +33 -9
- package/README.zh-CN.md +31 -9
- package/assets/screenshots/web-console.png +0 -0
- package/bin/hcc.mjs +749 -149
- package/docs/commands.md +13 -6
- package/docs/commands.zh-CN.md +11 -6
- package/docs/guide.md +10 -5
- package/docs/guide.zh-CN.md +8 -5
- package/lib/cli-runtime.mjs +2 -1
- package/lib/core/coordination/tasks.mjs +17 -1
- package/lib/core/coordination/timeline.mjs +11 -1
- package/lib/core/peers/identity.mjs +10 -2
- package/lib/core/sessions/launch.mjs +1 -0
- package/lib/integrations/shims/script.mjs +42 -22
- package/lib/integrations/shims.mjs +45 -6
- package/lib/setup.mjs +1 -0
- package/lib/shell-path.mjs +31 -16
- package/lib/ui/help.mjs +36 -1
- package/lib/web/peer-actions.mjs +42 -6
- package/lib/web/ui-template.mjs +5 -3
- package/package.json +1 -1
- package/scripts/regression.mjs +821 -97
package/lib/ui/help.mjs
CHANGED
|
@@ -60,6 +60,8 @@ Environment:
|
|
|
60
60
|
|
|
61
61
|
Usage:
|
|
62
62
|
${cliName} task create --title TEXT [--body TEXT] [--from ID] [--to ID] [--priority N]
|
|
63
|
+
${cliName} task dispatch --to ID --title TEXT [--body TEXT] [--from ID] [--message TEXT] [--no-inject] [--force]
|
|
64
|
+
${cliName} task dispatch --to ID --id N [--from ID] [--message TEXT] [--no-inject] [--force]
|
|
63
65
|
${cliName} task create --title TEXT --parent N [--team-role ROLE]
|
|
64
66
|
${cliName} task list [--status pending|claimed|running|review|blocked|done|abandoned] [--peer ID] [--all]
|
|
65
67
|
${cliName} task claim [--peer ID] --id N[,N] [--id N] [--ids N,N] [--force]
|
|
@@ -74,6 +76,11 @@ Messages use per-peer unread ack state; tasks do not.
|
|
|
74
76
|
task next returns your existing claimed/running/review/blocked task before
|
|
75
77
|
claiming another pending task. Use --force when intentionally taking additional
|
|
76
78
|
pending tasks; combine it with --count N for explicit batch claims.
|
|
79
|
+
task dispatch explicitly assigns a new or existing task to one peer, sends a
|
|
80
|
+
durable task message, and injects the startup prompt only when the peer has a
|
|
81
|
+
running managed Claude/Codex terminal. Use --no-inject for message-only
|
|
82
|
+
dispatch; use --force only when intentionally injecting while the target already
|
|
83
|
+
owns another active task.
|
|
77
84
|
Use task takeover when explicitly taking over a non-complete task from another
|
|
78
85
|
owner; it records the previous owner, requires a reason, and notifies them.
|
|
79
86
|
Use --policy blocked, stale, or blocked-or-stale to require an auditable
|
|
@@ -380,7 +387,7 @@ Usage:
|
|
|
380
387
|
${cliName} uninstall [--purge --yes]
|
|
381
388
|
|
|
382
389
|
Stops the current project runtime and removes user-level hello-cc integrations:
|
|
383
|
-
Claude/Codex hooks
|
|
390
|
+
Claude/Codex hooks, claude/codex shims, and the shell PATH entry for shims.
|
|
384
391
|
|
|
385
392
|
With --purge --yes, also removes current project data:
|
|
386
393
|
.hello-cc/
|
|
@@ -388,6 +395,34 @@ With --purge --yes, also removes current project data:
|
|
|
388
395
|
`);
|
|
389
396
|
},
|
|
390
397
|
|
|
398
|
+
helpInstallHooks() {
|
|
399
|
+
console.log(`${cliName} install-hooks
|
|
400
|
+
|
|
401
|
+
Usage:
|
|
402
|
+
${cliName} install-hooks
|
|
403
|
+
${cliName} install-hooks --status
|
|
404
|
+
${cliName} install-hooks --uninstall
|
|
405
|
+
|
|
406
|
+
Installs, checks, or removes Claude Code and Codex hook entries used by
|
|
407
|
+
hello-cc. This is a maintenance command; hcc up, hcc web, and hcc setup install
|
|
408
|
+
hooks automatically when needed.
|
|
409
|
+
`);
|
|
410
|
+
},
|
|
411
|
+
|
|
412
|
+
helpShim() {
|
|
413
|
+
console.log(`${cliName} shim
|
|
414
|
+
|
|
415
|
+
Usage:
|
|
416
|
+
${cliName} shim install
|
|
417
|
+
${cliName} shim status
|
|
418
|
+
${cliName} shim uninstall
|
|
419
|
+
|
|
420
|
+
Installs, checks, or removes claude/codex shims in ~/.hcc-shims and manages the
|
|
421
|
+
shell PATH entry for that directory. hcc web and hcc setup install shims
|
|
422
|
+
automatically when provider CLIs are available on PATH.
|
|
423
|
+
`);
|
|
424
|
+
},
|
|
425
|
+
|
|
391
426
|
helpWeb() {
|
|
392
427
|
console.log(`${cliName} web
|
|
393
428
|
|
package/lib/web/peer-actions.mjs
CHANGED
|
@@ -30,6 +30,7 @@ function requireFn(value, name) {
|
|
|
30
30
|
export function createWebPeerActions(deps = {}) {
|
|
31
31
|
const activePeerTtl = Number(deps.activePeerTtl ?? DEFAULT_ACTIVE_PEER_TTL);
|
|
32
32
|
const addEvent = requireFn(deps.addEvent, 'addEvent');
|
|
33
|
+
const assertTaskOwnerForMutation = requireFn(deps.assertTaskOwnerForMutation, 'assertTaskOwnerForMutation');
|
|
33
34
|
const claimNextTasksForPeer = requireFn(deps.claimNextTasksForPeer, 'claimNextTasksForPeer');
|
|
34
35
|
const connect = requireFn(deps.connect, 'connect');
|
|
35
36
|
const defaultLockTtl = Number(deps.defaultLockTtl ?? DEFAULT_LOCK_TTL);
|
|
@@ -44,7 +45,32 @@ export function createWebPeerActions(deps = {}) {
|
|
|
44
45
|
const tx = requireFn(deps.tx, 'tx');
|
|
45
46
|
const upsertPeer = requireFn(deps.upsertPeer, 'upsertPeer');
|
|
46
47
|
|
|
48
|
+
function webMutationPeer(peer, input = {}) {
|
|
49
|
+
const actorPeer = String(input.actorPeer || input.actor_peer || '').trim();
|
|
50
|
+
if (!actorPeer) {
|
|
51
|
+
throw new CliError('PEER_IDENTITY_REQUIRED', 'Web peer mutations require a managed session identity');
|
|
52
|
+
}
|
|
53
|
+
if (actorPeer !== peer) {
|
|
54
|
+
throw new CliError('PEER_IDENTITY_MISMATCH', `Web peer action for ${peer} cannot run as ${actorPeer}`, {
|
|
55
|
+
peer,
|
|
56
|
+
actor_peer: actorPeer
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return actorPeer;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function webAuditPayload(peer, input = {}, extra = {}) {
|
|
63
|
+
const actorPeer = String(input.actorPeer || input.actor_peer || peer).trim() || peer;
|
|
64
|
+
return {
|
|
65
|
+
...extra,
|
|
66
|
+
source: 'web',
|
|
67
|
+
actor_peer: actorPeer,
|
|
68
|
+
target_peer: peer
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
47
72
|
function webPeerRegister(projectCtx, peer, input = {}) {
|
|
73
|
+
webMutationPeer(peer, input);
|
|
48
74
|
const db = connect(projectCtx);
|
|
49
75
|
const row = {
|
|
50
76
|
id: peer,
|
|
@@ -58,7 +84,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
58
84
|
};
|
|
59
85
|
try {
|
|
60
86
|
upsertPeer(db, row);
|
|
61
|
-
addEvent(db, 'peer.registered', peer, null,
|
|
87
|
+
addEvent(db, 'peer.registered', peer, null, webAuditPayload(peer, input, row));
|
|
62
88
|
} finally {
|
|
63
89
|
db.close();
|
|
64
90
|
}
|
|
@@ -66,6 +92,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
66
92
|
}
|
|
67
93
|
|
|
68
94
|
function webPeerHeartbeat(projectCtx, peer, input = {}) {
|
|
95
|
+
webMutationPeer(peer, input);
|
|
69
96
|
const ttl = intOpt(input, 'ttl', defaultLockTtl);
|
|
70
97
|
const status = input.status || null;
|
|
71
98
|
const renewLocks = input['renew-locks'] !== false && input.renew_locks !== false;
|
|
@@ -80,7 +107,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
80
107
|
WHERE owner = ? AND expires_at > ?
|
|
81
108
|
`).run(t + ttl, peer, t).changes;
|
|
82
109
|
}
|
|
83
|
-
addEvent(db, 'peer.heartbeat', peer, null, { status, renewed
|
|
110
|
+
addEvent(db, 'peer.heartbeat', peer, null, webAuditPayload(peer, input, { status, renewed }));
|
|
84
111
|
} finally {
|
|
85
112
|
db.close();
|
|
86
113
|
}
|
|
@@ -93,6 +120,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
93
120
|
}
|
|
94
121
|
|
|
95
122
|
function webPeerTaskNext(projectCtx, peer, input = {}) {
|
|
123
|
+
webMutationPeer(peer, input);
|
|
96
124
|
const db = connect(projectCtx);
|
|
97
125
|
try {
|
|
98
126
|
touchPeer(db, peer, 'working');
|
|
@@ -117,6 +145,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
117
145
|
}
|
|
118
146
|
|
|
119
147
|
function webPeerTaskTakeover(projectCtx, peer, input = {}) {
|
|
148
|
+
webMutationPeer(peer, input);
|
|
120
149
|
const id = intOpt(input, 'id', intOpt({ id: input.task }, 'id'));
|
|
121
150
|
if (!id) throw new CliError('BAD_REQUEST', 'task id required');
|
|
122
151
|
const reason = required(input, 'reason');
|
|
@@ -133,6 +162,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
133
162
|
}
|
|
134
163
|
|
|
135
164
|
function webPeerLockAcquire(projectCtx, peer, input = {}) {
|
|
165
|
+
webMutationPeer(peer, input);
|
|
136
166
|
const requested = scopedLockResource(required(input, 'resource'), input.scope);
|
|
137
167
|
const ttl = intOpt(input, 'ttl', defaultLockTtl);
|
|
138
168
|
const taskId = intOpt(input, 'task', intOpt(input, 'task_id', null));
|
|
@@ -142,6 +172,11 @@ export function createWebPeerActions(deps = {}) {
|
|
|
142
172
|
touchPeer(db, peer, 'working');
|
|
143
173
|
const lock = tx(db, () => {
|
|
144
174
|
const t = now();
|
|
175
|
+
if (taskId) {
|
|
176
|
+
const task = db.prepare('SELECT * FROM tasks WHERE id = ?').get(taskId);
|
|
177
|
+
if (!task) throw new CliError('NOT_FOUND', `Task #${taskId} does not exist`);
|
|
178
|
+
assertTaskOwnerForMutation(db, peer, task, 'lock-acquire');
|
|
179
|
+
}
|
|
145
180
|
const activeLocks = db.prepare('SELECT * FROM locks WHERE expires_at > ?').all(t);
|
|
146
181
|
const conflict = activeLocks.find((row) => locksConflict(row, requested) && row.owner !== peer);
|
|
147
182
|
if (conflict) {
|
|
@@ -166,7 +201,7 @@ export function createWebPeerActions(deps = {}) {
|
|
|
166
201
|
reason = excluded.reason,
|
|
167
202
|
expires_at = excluded.expires_at
|
|
168
203
|
`).run(requested.resource, requested.base_resource, requested.scope, peer, taskId, reason, t + ttl, existing ? existing.created_at : t);
|
|
169
|
-
addEvent(db, 'lock.acquired', peer, taskId, { resource: requested.base_resource, lock_resource: requested.resource, scope: requested.scope, ttl, previous_owner: existing ? existing.owner : null
|
|
204
|
+
addEvent(db, 'lock.acquired', peer, taskId, webAuditPayload(peer, input, { resource: requested.base_resource, lock_resource: requested.resource, scope: requested.scope, ttl, previous_owner: existing ? existing.owner : null }));
|
|
170
205
|
return db.prepare('SELECT * FROM locks WHERE resource = ?').get(requested.resource);
|
|
171
206
|
});
|
|
172
207
|
return { peer, lock, summary: `locked ${lockLabel(lock)} by ${lock.owner} until ${iso(lock.expires_at)}` };
|
|
@@ -176,19 +211,20 @@ export function createWebPeerActions(deps = {}) {
|
|
|
176
211
|
}
|
|
177
212
|
|
|
178
213
|
function webPeerLockRelease(projectCtx, peer, input = {}) {
|
|
214
|
+
webMutationPeer(peer, input);
|
|
179
215
|
const requested = scopedLockResource(required(input, 'resource'), input.scope);
|
|
180
|
-
const force =
|
|
216
|
+
const force = false;
|
|
181
217
|
const db = connect(projectCtx);
|
|
182
218
|
try {
|
|
183
219
|
touchPeer(db, peer, null);
|
|
184
220
|
const result = tx(db, () => {
|
|
185
221
|
const existing = db.prepare('SELECT * FROM locks WHERE resource = ?').get(requested.resource);
|
|
186
222
|
if (!existing) return { released: false, ...requested };
|
|
187
|
-
if (existing.owner !== peer
|
|
223
|
+
if (existing.owner !== peer) {
|
|
188
224
|
throw new CliError('LOCK_OWNED', `Lock is owned by ${existing.owner}`, { owner: existing.owner });
|
|
189
225
|
}
|
|
190
226
|
db.prepare('DELETE FROM locks WHERE resource = ?').run(requested.resource);
|
|
191
|
-
addEvent(db, 'lock.released', peer, existing.task_id || null, { resource: requested.base_resource, lock_resource: requested.resource, scope: requested.scope, force
|
|
227
|
+
addEvent(db, 'lock.released', peer, existing.task_id || null, webAuditPayload(peer, input, { resource: requested.base_resource, lock_resource: requested.resource, scope: requested.scope, force }));
|
|
192
228
|
return { released: true, ...requested };
|
|
193
229
|
});
|
|
194
230
|
return { peer, result, summary: result.released ? `released ${lockLabel(result)}` : `no lock for ${lockLabel(result)}` };
|
package/lib/web/ui-template.mjs
CHANGED
|
@@ -1693,7 +1693,7 @@ export function webIndexHtml() {
|
|
|
1693
1693
|
if (!body) return;
|
|
1694
1694
|
await api('/api/detected/' + encodeURIComponent(peer.id) + '/msg', {
|
|
1695
1695
|
method: 'POST',
|
|
1696
|
-
body: JSON.stringify({ body
|
|
1696
|
+
body: JSON.stringify({ body })
|
|
1697
1697
|
});
|
|
1698
1698
|
document.getElementById('detMsg').value = '';
|
|
1699
1699
|
await refreshDetectedState();
|
|
@@ -1733,7 +1733,8 @@ export function webIndexHtml() {
|
|
|
1733
1733
|
const session = sessions.find((s) => s.id === active) || { id: active, kind: 'other', role: 'peer' };
|
|
1734
1734
|
return {
|
|
1735
1735
|
session,
|
|
1736
|
-
peerId: sessionPeerId(session) || active
|
|
1736
|
+
peerId: sessionPeerId(session) || active,
|
|
1737
|
+
actionToken: session.action_token || ''
|
|
1737
1738
|
};
|
|
1738
1739
|
}
|
|
1739
1740
|
|
|
@@ -1807,12 +1808,13 @@ export function webIndexHtml() {
|
|
|
1807
1808
|
async function runPeerAction(action) {
|
|
1808
1809
|
const info = activePeerInfo();
|
|
1809
1810
|
if (!info) return;
|
|
1811
|
+
const readOnly = ['status', 'state', 'inbox'].includes(action);
|
|
1810
1812
|
const payload = action === 'register'
|
|
1811
1813
|
? { kind: info.session.kind || 'other', role: info.session.role || 'peer', worktree: info.session.cwd || currentProject }
|
|
1812
1814
|
: action === 'heartbeat'
|
|
1813
1815
|
? { renew_locks: true }
|
|
1814
1816
|
: {};
|
|
1815
|
-
|
|
1817
|
+
if (!readOnly) payload.action_token = info.actionToken;
|
|
1816
1818
|
const result = await api('/api/peers/' + encodeURIComponent(info.peerId) + '/actions/' + encodeURIComponent(action), readOnly
|
|
1817
1819
|
? {}
|
|
1818
1820
|
: { method: 'POST', body: JSON.stringify(payload) });
|