@hmharness/cli 0.23.21 → 0.23.23
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/dist/acp-serve.d.ts +5 -5
- package/dist/acp-serve.js +95 -41
- package/dist/main.js +119 -6
- package/dist/tui.js +19 -2
- package/dist/update-check.d.ts +31 -4
- package/dist/update-check.js +51 -3
- package/package.json +17 -15
- package/release-notes.json +54 -0
package/dist/acp-serve.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ChatMessage } from '@hmharness/kernel';
|
|
2
2
|
import { type RunnerEvents } from '@hmharness/agent';
|
|
3
|
-
/** close every window NOT in the
|
|
4
|
-
* (the host's per-connection workspace windows
|
|
5
|
-
*
|
|
6
|
-
* never
|
|
7
|
-
export declare function recycleBlankWindows(port: number,
|
|
3
|
+
/** close every window NOT in the protected snapshot whose tabs are ALL
|
|
4
|
+
* blank (the host's per-connection workspace windows). Protected-set
|
|
5
|
+
* windows — everything that existed when our connection initialized —
|
|
6
|
+
* are never touched. Returns how many closed; never throws. */
|
|
7
|
+
export declare function recycleBlankWindows(port: number, protectedWindows: Set<number>): Promise<number>;
|
|
8
8
|
interface AcpSession {
|
|
9
9
|
cwd: string;
|
|
10
10
|
/** hmh rollout id once the first prompt ran (resume appends) */
|
package/dist/acp-serve.js
CHANGED
|
@@ -100,16 +100,16 @@ async function listContentWindows(port) {
|
|
|
100
100
|
}
|
|
101
101
|
return content;
|
|
102
102
|
}
|
|
103
|
-
/** close every window NOT in the
|
|
104
|
-
* (the host's per-connection workspace windows
|
|
105
|
-
*
|
|
106
|
-
* never
|
|
107
|
-
export async function recycleBlankWindows(port,
|
|
103
|
+
/** close every window NOT in the protected snapshot whose tabs are ALL
|
|
104
|
+
* blank (the host's per-connection workspace windows). Protected-set
|
|
105
|
+
* windows — everything that existed when our connection initialized —
|
|
106
|
+
* are never touched. Returns how many closed; never throws. */
|
|
107
|
+
export async function recycleBlankWindows(port, protectedWindows) {
|
|
108
108
|
try {
|
|
109
109
|
const current = await listHostWindows(port);
|
|
110
110
|
let closed = 0;
|
|
111
111
|
for (const windowId of current) {
|
|
112
|
-
if (
|
|
112
|
+
if (protectedWindows.has(windowId))
|
|
113
113
|
continue;
|
|
114
114
|
try {
|
|
115
115
|
if (await windowIsBlank(port, windowId)) {
|
|
@@ -201,18 +201,46 @@ export function createAcpServer(opts) {
|
|
|
201
201
|
// implement (initialize/new/load/prompt/cancel/update/permission) is
|
|
202
202
|
// stable across the 0.4 interop baseline and later additions are
|
|
203
203
|
// optional; a hard version mismatch would just refuse to connect.
|
|
204
|
-
// loadSession
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
//
|
|
204
|
+
// loadSession + sessionCapabilities: the host treats agents that
|
|
205
|
+
// declare session-lifecycle capabilities (close/delete/fork/list/
|
|
206
|
+
// resume — observed on the built-in claude-agent-acp) as long-lived
|
|
207
|
+
// manageable sessions and REUSES the connection; without them it
|
|
208
|
+
// spawns a fresh agent (and a fresh workspace WINDOW) per message —
|
|
209
|
+
// the exact "a new browser window on every message" bug.
|
|
208
210
|
ok({
|
|
209
211
|
protocolVersion: m.params?.protocolVersion ?? '0',
|
|
210
|
-
agentCapabilities: {
|
|
212
|
+
agentCapabilities: {
|
|
213
|
+
loadSession: true,
|
|
214
|
+
sessionCapabilities: {
|
|
215
|
+
additionalDirectories: {},
|
|
216
|
+
close: {},
|
|
217
|
+
delete: {},
|
|
218
|
+
fork: {},
|
|
219
|
+
list: {},
|
|
220
|
+
resume: {},
|
|
221
|
+
},
|
|
222
|
+
// the host hands every session a browser MCP over http (with an
|
|
223
|
+
// internal lease header) — declaring we speak http MCP may be
|
|
224
|
+
// what keeps it from provisioning a workspace WINDOW instead
|
|
225
|
+
mcpCapabilities: { http: true, sse: false },
|
|
226
|
+
},
|
|
211
227
|
authMethods: [],
|
|
212
228
|
});
|
|
213
229
|
await opts.onInitialized?.().catch(() => undefined);
|
|
214
230
|
return;
|
|
215
231
|
}
|
|
232
|
+
case 'session/close':
|
|
233
|
+
case 'session/delete': {
|
|
234
|
+
const sid = m.params?.sessionId;
|
|
235
|
+
if (sid)
|
|
236
|
+
sessions.delete(sid);
|
|
237
|
+
ok({});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
case 'session/list': {
|
|
241
|
+
ok({ sessions: [...sessions.keys()].map((id) => ({ sessionId: id, ...(sessions.get(id).hmhId ? { title: sessions.get(id).hmhId } : {}) })) });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
216
244
|
case 'authenticate': {
|
|
217
245
|
ok({});
|
|
218
246
|
return;
|
|
@@ -225,10 +253,14 @@ export function createAcpServer(opts) {
|
|
|
225
253
|
ok({ sessionId });
|
|
226
254
|
return;
|
|
227
255
|
}
|
|
228
|
-
case 'session/load':
|
|
256
|
+
case 'session/load':
|
|
257
|
+
case 'session/resume': {
|
|
258
|
+
// `session/resume` is the acpx host's name for the same operation
|
|
259
|
+
// (observed on the wire) — both register the prior session and
|
|
260
|
+
// restore its transcript from the hmh rollout.
|
|
229
261
|
const sid = typeof m.params?.sessionId === 'string' ? m.params.sessionId : '';
|
|
230
262
|
if (!sid) {
|
|
231
|
-
err(m.id, -32602,
|
|
263
|
+
err(m.id, -32602, `${m.method} needs sessionId`);
|
|
232
264
|
return;
|
|
233
265
|
}
|
|
234
266
|
if (!sessions.has(sid)) {
|
|
@@ -361,6 +393,15 @@ export function createAcpServer(opts) {
|
|
|
361
393
|
return;
|
|
362
394
|
}
|
|
363
395
|
default: {
|
|
396
|
+
// unknown session/* methods: answer tolerantly with {} (the host's
|
|
397
|
+
// extended session vocabulary evolves; a hard -32601 made it fall
|
|
398
|
+
// back to fresh-session-per-message behavior). The wire log records
|
|
399
|
+
// every such call so we can implement the ones the host actually
|
|
400
|
+
// uses.
|
|
401
|
+
if (isRequest && m.method.startsWith('session/')) {
|
|
402
|
+
ok({});
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
364
405
|
if (isRequest)
|
|
365
406
|
err(m.id, -32601, `method not found: ${m.method}`);
|
|
366
407
|
}
|
|
@@ -404,15 +445,18 @@ export async function serveAcp() {
|
|
|
404
445
|
});
|
|
405
446
|
},
|
|
406
447
|
};
|
|
407
|
-
// window-recycling
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
//
|
|
411
|
-
//
|
|
412
|
-
//
|
|
413
|
-
//
|
|
448
|
+
// window-recycling (host browser only), SNAPSHOT-based — the safe design
|
|
449
|
+
// after the 2026-10-04 incident. The host opens a blank workspace window
|
|
450
|
+
// for every new agent connection (per-message in practice). W0 = ALL
|
|
451
|
+
// window ids at initialize time; sweeps close ONLY windows that (a) are
|
|
452
|
+
// not in W0 AND (b) currently hold nothing but blank tabs. The user's own
|
|
453
|
+
// windows ALWAYS predate our connection → they are in W0 → they can
|
|
454
|
+
// never be closed, even mid-load (the incident's failure mode). The one
|
|
455
|
+
// residual risk: a blank window the USER opens during our connection
|
|
456
|
+
// lifetime — accepted, it is empty by definition. No initialize (host
|
|
457
|
+
// skip) → no recycling (miss, never misfire).
|
|
414
458
|
const attachPort = Number(process.env.HMH_BROWSER_ATTACH ?? 0);
|
|
415
|
-
let
|
|
459
|
+
let w0Snapshot = null;
|
|
416
460
|
const recycleLog = async (msg) => {
|
|
417
461
|
console.error(`[acp-window] ${msg}`);
|
|
418
462
|
try {
|
|
@@ -424,35 +468,28 @@ export async function serveAcp() {
|
|
|
424
468
|
catch { /* logging is best-effort */ }
|
|
425
469
|
};
|
|
426
470
|
const sweep = async (why) => {
|
|
427
|
-
if (!
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
const closed = await recycleBlankWindows(attachPort, contentBaseline);
|
|
432
|
-
contentBaseline = await listContentWindows(attachPort).catch(() => contentBaseline);
|
|
433
|
-
await recycleLog(`${why}: closed=${closed} contentWindows=${contentBaseline?.size ?? '?'}`);
|
|
471
|
+
if (!w0Snapshot)
|
|
472
|
+
return; // no initialize → no snapshot → never sweep
|
|
473
|
+
const closed = await recycleBlankWindows(attachPort, w0Snapshot);
|
|
474
|
+
await recycleLog(`${why}: closed=${closed} (W0=${w0Snapshot.size})`);
|
|
434
475
|
};
|
|
435
|
-
const
|
|
476
|
+
const recycleEnabled = process.env.HMH_BROWSER_RECYCLE !== '0' && Number.isInteger(attachPort) && attachPort > 0;
|
|
477
|
+
const hooks = recycleEnabled
|
|
436
478
|
? {
|
|
437
479
|
onInitialized: async () => {
|
|
438
|
-
|
|
439
|
-
await recycleLog(`initialize:
|
|
440
|
-
// opening sweep: recycle whatever blank windows earlier
|
|
441
|
-
// connections left behind (the host may hard-kill us between
|
|
442
|
-
// messages — taskkill gives no stdin-close cleanup chance)
|
|
443
|
-
await sweep('opening');
|
|
480
|
+
w0Snapshot = await listHostWindows(attachPort).catch(() => null);
|
|
481
|
+
await recycleLog(`initialize: W0 snapshot = ${w0Snapshot?.size ?? 'unavailable'} windows`);
|
|
444
482
|
},
|
|
445
483
|
onTurnSettled: async () => {
|
|
446
484
|
await sweep('turn-settled');
|
|
447
|
-
// the host sometimes opens the workspace window AFTER the stop
|
|
448
|
-
// response — sweep again shortly, fire-and-forget
|
|
449
|
-
void (async () => {
|
|
450
|
-
await new Promise((r) => setTimeout(r, 2_500));
|
|
451
|
-
await sweep('turn-settled+2.5s').catch(() => undefined);
|
|
452
|
-
})();
|
|
453
485
|
},
|
|
454
486
|
}
|
|
455
487
|
: {};
|
|
488
|
+
let residentTimer = null;
|
|
489
|
+
if (recycleEnabled) {
|
|
490
|
+
residentTimer = setInterval(() => { void sweep('resident').catch(() => undefined); }, 2_000);
|
|
491
|
+
residentTimer.unref?.();
|
|
492
|
+
}
|
|
456
493
|
const server = createAcpServer({ io, ...hooks });
|
|
457
494
|
const rl = readline.createInterface({ input: process.stdin });
|
|
458
495
|
rl.on('line', (line) => {
|
|
@@ -467,6 +504,21 @@ export async function serveAcp() {
|
|
|
467
504
|
console.error('[acp] unparseable frame:', text.slice(0, 120));
|
|
468
505
|
return;
|
|
469
506
|
}
|
|
507
|
+
// full wire log (host→agent frames): the single best forensic artifact
|
|
508
|
+
// for host-behavior mysteries. Truncated params keep it bounded.
|
|
509
|
+
void (async () => {
|
|
510
|
+
try {
|
|
511
|
+
const { appendFile, mkdir } = await import('node:fs/promises');
|
|
512
|
+
const logsDir = join(homeDir(), 'logs');
|
|
513
|
+
await mkdir(logsDir, { recursive: true });
|
|
514
|
+
const m = msg;
|
|
515
|
+
const brief = m.method
|
|
516
|
+
? `${m.method} id=${String(m.id)} params=${JSON.stringify(m.params ?? {}).slice(0, 400)}`
|
|
517
|
+
: `response id=${String(m.id)} ${JSON.stringify(msg).slice(0, 200)}`;
|
|
518
|
+
await appendFile(join(logsDir, 'acp-wire.log'), `${new Date().toISOString()} ${brief}\n`, 'utf8');
|
|
519
|
+
}
|
|
520
|
+
catch { /* best-effort */ }
|
|
521
|
+
})();
|
|
470
522
|
// responses to OUR agent→client requests (permissions)
|
|
471
523
|
if ((msg.id !== undefined) && !('method' in msg)) {
|
|
472
524
|
const entry = pending.get(Number(msg.id));
|
|
@@ -486,6 +538,8 @@ export async function serveAcp() {
|
|
|
486
538
|
rl.on('close', async () => {
|
|
487
539
|
for (const [, p] of pending)
|
|
488
540
|
p.reject(new Error('client disconnected'));
|
|
541
|
+
if (residentTimer)
|
|
542
|
+
clearInterval(residentTimer);
|
|
489
543
|
// last-chance sweep: the host disposes us between messages, and the
|
|
490
544
|
// workspace window it gave this connection would otherwise linger
|
|
491
545
|
await Promise.race([sweep('disconnect'), new Promise((r) => setTimeout(r, 6_000))]);
|
package/dist/main.js
CHANGED
|
@@ -114,14 +114,31 @@ async function repl(yes, initialHistory, initialSessionId) {
|
|
|
114
114
|
let t = strings((cfg.locale ?? 'zh'));
|
|
115
115
|
const header = () => stdout.write(CYAN('hmh') + DIM(` · ${cfg.provider.model} · ${home}\n`));
|
|
116
116
|
stdout.write(CYAN('hmh') + DIM(` · ${cfg.provider.model} · ${home}\n`) + DIM(`${t.replHint} · /help ${String(t.cmdHelp)}\n\n`));
|
|
117
|
-
// npm is pull-based; the update
|
|
118
|
-
//
|
|
119
|
-
|
|
117
|
+
// npm is pull-based; the update check is cached and never blocks. T27-v2
|
|
118
|
+
// REPL trio (parity with the TUI): briefing on the first launch of a new
|
|
119
|
+
// version, then background auto-update with visible dim start/outcome
|
|
120
|
+
// lines - unless tui.autoUpdate=false, which downgrades to the plain hint
|
|
121
|
+
const { notifyUpdate, autoUpdate, nextBriefing } = await import("./update-check.js");
|
|
120
122
|
const { createRequire } = await import('node:module');
|
|
121
123
|
const CURRENT_VERSION = createRequire(import.meta.url)('../package.json').version;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
const briefing = await nextBriefing(home, CURRENT_VERSION);
|
|
125
|
+
if (briefing)
|
|
126
|
+
stdout.write(DIM(`${t.tuiBriefing(CURRENT_VERSION, briefing)}\n\n`));
|
|
127
|
+
const autoOff = cfg.tui?.autoUpdate === false;
|
|
128
|
+
if (autoOff) {
|
|
129
|
+
void notifyUpdate(home, CURRENT_VERSION, (latest) => {
|
|
130
|
+
stdout.write(DIM(`↑ ${t.updateHint(latest)}\n\n`));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
void autoUpdate({
|
|
135
|
+
home,
|
|
136
|
+
current: CURRENT_VERSION,
|
|
137
|
+
say: (v) => stdout.write(DIM(`${t.tuiUpdating(v)}\n`)),
|
|
138
|
+
onDone: (code, v) => stdout.write(DIM(`${code === 0 ? t.tuiUpdated(v) : t.tuiAutoUpdateFailed('exit ' + code)}\n`)),
|
|
139
|
+
sayFail: (why) => stdout.write(DIM(`${t.tuiAutoUpdateFailed(why)}\n`)),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
125
142
|
const { reg, clients } = await buildRegistry();
|
|
126
143
|
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
127
144
|
// stdin EOF (piped input, closed terminal) must exit the loop - a bare
|
|
@@ -496,6 +513,10 @@ usage:
|
|
|
496
513
|
hmh browser [status|trust|untrust|start|stop|open <url>]
|
|
497
514
|
BrowserOS AI browser: discovery + trust +
|
|
498
515
|
the dedicated instance browser_* tools drive
|
|
516
|
+
hmh extension [serve|pair|status|unpair|build]
|
|
517
|
+
browser-extension bridge: adapt the agent into
|
|
518
|
+
your REAL browser (Chrome/Edge/Brave, Firefox,
|
|
519
|
+
Safari payload) — loopback server + pairing
|
|
499
520
|
hmh tools list all registered tools (native + MCP)
|
|
500
521
|
hmh mcp show configured MCP servers and their tools
|
|
501
522
|
hmh evolve [--every=N] self-evolution cycle (or resident loop)
|
|
@@ -1077,6 +1098,98 @@ flags:
|
|
|
1077
1098
|
stdout.write('用法: hmh browser status | trust <id> | untrust <id> | start [--port=N] | stop | open <url> — BrowserOS 发现/信任/生命周期\n');
|
|
1078
1099
|
return;
|
|
1079
1100
|
}
|
|
1101
|
+
if (cmd === 'extension') {
|
|
1102
|
+
// Browser-extension bridge (2026-10-04): the ChatGPT-extension-style
|
|
1103
|
+
// loopback server + pairing flow that adapts the agent into the user's
|
|
1104
|
+
// REAL browser (Chrome/Edge/Brave, Firefox, Safari payload).
|
|
1105
|
+
await initHome();
|
|
1106
|
+
const sub = rest[0] ?? 'status';
|
|
1107
|
+
if (sub === 'serve') {
|
|
1108
|
+
const portArg = rest.find((a) => a.startsWith('--port='));
|
|
1109
|
+
const { ExtensionBridgeServer, issuePairingCode, isPaired } = await import('@hmharness/extension');
|
|
1110
|
+
const bridge = new ExtensionBridgeServer({ home: homeDir() });
|
|
1111
|
+
const { port: actual } = await bridge.start(portArg ? Number(portArg.slice(7)) : undefined);
|
|
1112
|
+
bridge.onConnectionChange = (connected) => {
|
|
1113
|
+
stdout.write(connected ? '\n ✓ 浏览器扩展已连接\n' : '\n ✗ 浏览器扩展断开\n');
|
|
1114
|
+
};
|
|
1115
|
+
stdout.write(`hmh 扩展桥已运行: http://127.0.0.1:${actual}(仅本机回环)\n`);
|
|
1116
|
+
if (await isPaired(homeDir())) {
|
|
1117
|
+
stdout.write(' 已配对 — 浏览器扩展会自动重连\n');
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
const code = await issuePairingCode(homeDir());
|
|
1121
|
+
if (code.ok) {
|
|
1122
|
+
stdout.write(` 配对码: ${code.code}(5 分钟内有效,单次使用 — 在扩展 popup 中输入)\n`);
|
|
1123
|
+
}
|
|
1124
|
+
else {
|
|
1125
|
+
stdout.write(` 配对码生成被锁定,${Math.ceil(code.retryInMs / 1000)}s 后重试(hmh extension pair)\n`);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
stdout.write(DIM(' Ctrl-C 停止;状态: hmh extension status;构建扩展: hmh extension build --target=all\n'));
|
|
1129
|
+
process.once('SIGINT', () => { void bridge.stop().then(() => process.exit(0)); });
|
|
1130
|
+
process.once('SIGTERM', () => { void bridge.stop().then(() => process.exit(0)); });
|
|
1131
|
+
return; // 桥以前台进程常驻
|
|
1132
|
+
}
|
|
1133
|
+
if (sub === 'pair') {
|
|
1134
|
+
const { issuePairingCode } = await import('@hmharness/extension');
|
|
1135
|
+
const r = await issuePairingCode(homeDir());
|
|
1136
|
+
if (!r.ok) {
|
|
1137
|
+
stdout.write(`配对码被锁定,${Math.ceil(r.retryInMs / 1000)}s 后重试\n`);
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
stdout.write(`配对码: ${r.code}\n`);
|
|
1141
|
+
stdout.write(` ${new Date(r.expiresAt).toLocaleTimeString()} 前有效,单次使用 — 打开浏览器扩展 popup 输入\n`);
|
|
1142
|
+
stdout.write(DIM(' 扩展未构建? hmh extension build --target=all;桥未运行? hmh extension serve\n'));
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
if (sub === 'unpair') {
|
|
1146
|
+
const { unpair } = await import('@hmharness/extension');
|
|
1147
|
+
const ok = await unpair(homeDir());
|
|
1148
|
+
stdout.write(ok ? '已吊销配对令牌(扩展下次请求即被拒,需重新配对)\n' : '本就未配对\n');
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
if (sub === 'status') {
|
|
1152
|
+
const { discoverExtensionBridge, isPaired } = await import('@hmharness/extension');
|
|
1153
|
+
const b = await discoverExtensionBridge();
|
|
1154
|
+
const paired = await isPaired(homeDir());
|
|
1155
|
+
if (!b.healthy) {
|
|
1156
|
+
stdout.write(`✗ 扩展桥未运行(${b.unhealthyReason})\n`);
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
stdout.write(`✓ 桥运行中: 127.0.0.1:${b.port} · 配对: ${paired ? '已配对' : '未配对(hmh extension pair)'}\n`);
|
|
1160
|
+
stdout.write(b.connected
|
|
1161
|
+
? ` 扩展已连接${b.browser ? ' · ' + b.browser : ''}${b.extVersion ? ' v' + b.extVersion : ''} — 智能体 extension_* 工具可用\n`
|
|
1162
|
+
: ' 扩展未连接 — 打开浏览器扩展 popup 配对/连接\n');
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
if (sub === 'build') {
|
|
1166
|
+
const tArg = rest.find((a) => a.startsWith('--target='));
|
|
1167
|
+
const oArg = rest.find((a) => a.startsWith('--out='));
|
|
1168
|
+
const pArg = rest.find((a) => a.startsWith('--port='));
|
|
1169
|
+
const target = (tArg ? tArg.slice(9) : 'all');
|
|
1170
|
+
if (!['chromium', 'firefox', 'safari', 'all'].includes(target)) {
|
|
1171
|
+
stdout.write('用法: hmh extension build [--target=chromium|firefox|safari|all] [--out=目录] [--port=N]\n');
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
const { buildExtension } = await import('@hmharness/extension');
|
|
1175
|
+
try {
|
|
1176
|
+
const results = await buildExtension({ target, outDir: oArg ? oArg.slice(6) : undefined, port: pArg ? Number(pArg.slice(7)) : undefined });
|
|
1177
|
+
for (const r of results) {
|
|
1178
|
+
stdout.write(`✓ ${r.target} → ${r.dir}\n`);
|
|
1179
|
+
stdout.write(` 载入: ${r.loadHint}\n`);
|
|
1180
|
+
for (const n of r.notes)
|
|
1181
|
+
stdout.write(DIM(` 注: ${n}\n`));
|
|
1182
|
+
}
|
|
1183
|
+
stdout.write(DIM(' 下一步: hmh extension serve(另开终端)→ 浏览器载入扩展 → popup 输入 hmh extension pair 的配对码\n'));
|
|
1184
|
+
}
|
|
1185
|
+
catch (err) {
|
|
1186
|
+
stdout.write(`构建失败: ${String(err instanceof Error ? err.message : err).slice(0, 300)}\n`);
|
|
1187
|
+
}
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
stdout.write('用法: hmh extension serve | pair | status | unpair | build [--target=all] [--out=dir] [--port=N] — 浏览器扩展桥(真实浏览器接入)\n');
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1080
1193
|
if (cmd === 'cognitive') {
|
|
1081
1194
|
// Cognitive OS (blueprint 2026-09): read-only status one-pager. The
|
|
1082
1195
|
// subsystems are libraries first — they come alive when the agent loop
|
package/dist/tui.js
CHANGED
|
@@ -1727,6 +1727,15 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
if (webUp)
|
|
1729
1729
|
rt.addText(t.tuiWebLinked(DEFAULT_WEB_PORT), 'dim');
|
|
1730
|
+
// update briefing (T27-v2): the FIRST launch of a new version shows its
|
|
1731
|
+
// one-line note from the shipped release-notes.json - shown once per
|
|
1732
|
+
// version (stamp in HMH_HOME), never on a fresh install
|
|
1733
|
+
{
|
|
1734
|
+
const { nextBriefing } = await import("./update-check.js");
|
|
1735
|
+
const briefing = await nextBriefing(home, HMH_VERSION);
|
|
1736
|
+
if (briefing)
|
|
1737
|
+
rt.addText(t.tuiBriefing(HMH_VERSION, briefing), 'dim');
|
|
1738
|
+
}
|
|
1730
1739
|
// update reminder: cached (1/day) registry check, resolved async into the
|
|
1731
1740
|
// transcript via addText (frame-safe); offline stays silent
|
|
1732
1741
|
{
|
|
@@ -1744,8 +1753,16 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1744
1753
|
void autoUpdate({
|
|
1745
1754
|
home,
|
|
1746
1755
|
current,
|
|
1747
|
-
// settled design T27
|
|
1748
|
-
//
|
|
1756
|
+
// settled design T27-v2 (复案 2026-10-03): windowless stays, but the
|
|
1757
|
+
// user keeps control - one dim line when the install starts, one
|
|
1758
|
+
// when it lands, and a one-line briefing on the first launch after
|
|
1759
|
+
say: (latest) => rt.addText(t.tuiUpdating(latest), 'dim'),
|
|
1760
|
+
onDone: (code, latest) => {
|
|
1761
|
+
if (code === 0)
|
|
1762
|
+
rt.addText(t.tuiUpdated(latest), 'dim');
|
|
1763
|
+
else
|
|
1764
|
+
rt.addText(t.tuiAutoUpdateFailed('exit ' + code), 'dim');
|
|
1765
|
+
},
|
|
1749
1766
|
sayFail: (why) => rt.addText(t.tuiAutoUpdateFailed(why), 'dim'),
|
|
1750
1767
|
});
|
|
1751
1768
|
}
|
package/dist/update-check.d.ts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/** Shipped one-line release notes (packages/cli/release-notes.json): the
|
|
2
|
+
* updater briefing reads them so the FIRST launch of a new version can tell
|
|
3
|
+
* the user what changed. publish.cjs enforces every released version has an
|
|
4
|
+
* entry. Degrades to null when absent - the briefing is a courtesy. */
|
|
5
|
+
export interface ReleaseNotes {
|
|
6
|
+
notes: Array<{
|
|
7
|
+
v: string;
|
|
8
|
+
date?: string;
|
|
9
|
+
note: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadReleaseNotes(distDir?: string): Promise<ReleaseNotes | null>;
|
|
13
|
+
/** The one-line note for one version ('' when unknown - never invented). */
|
|
14
|
+
export declare function noteFor(notes: ReleaseNotes | null, version: string): string;
|
|
15
|
+
/** First-launch-of-a-new-version briefing (T27-v2 part 3). Returns the
|
|
16
|
+
* note text when the HMH_HOME stamp differs from the RUNNING version
|
|
17
|
+
* (then re-stamps); fresh installs (no stamp) and same-version launches
|
|
18
|
+
* return null. Shared by the TUI and the REPL so "hmh starts" means
|
|
19
|
+
* both frontends. */
|
|
20
|
+
export declare function nextBriefing(home: string, current: string): Promise<string | null>;
|
|
1
21
|
/** Numeric per-component semver compare (no dependency, dot-split).
|
|
2
22
|
* Prerelease suffixes degrade to their leading number ('1-beta' -> 1) -
|
|
3
23
|
* good enough for an update hint, never claims to be full semver. */
|
|
@@ -93,8 +113,10 @@ export declare function aiRepairUpdate(opts: {
|
|
|
93
113
|
windowsHide?: boolean;
|
|
94
114
|
}) => {
|
|
95
115
|
unref: () => void;
|
|
96
|
-
on: (ev: string, fn: () => void) => void;
|
|
116
|
+
on: (ev: string, fn: (...a: never[]) => void) => void;
|
|
97
117
|
};
|
|
118
|
+
/** completion hook for the repaired install (T27-v2 briefing) */
|
|
119
|
+
onDone?: (code: number) => void;
|
|
98
120
|
logFd: number;
|
|
99
121
|
}): Promise<string | null>;
|
|
100
122
|
/** Wait ~3s for a spawn 'error' (ENOENT/EINVAL fire immediately) so the UI
|
|
@@ -105,8 +127,13 @@ export declare function spawnStarted(child: {
|
|
|
105
127
|
export declare function autoUpdate(opts: {
|
|
106
128
|
home: string;
|
|
107
129
|
current: string;
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
130
|
+
/** one dim line when the background install STARTS (T27-v2: visible but
|
|
131
|
+
* windowless - the user keeps a sense of control without popups) */
|
|
132
|
+
say?: (version: string) => void;
|
|
133
|
+
/** fires when the detached installer actually EXITS (code 0 = updated);
|
|
134
|
+
* the completion line lands here, minutes after autoUpdate returned */
|
|
135
|
+
onDone?: (code: number, version: string) => void;
|
|
136
|
+
/** failure notice only - a started install never nags */
|
|
110
137
|
sayFail?: (line: string) => void;
|
|
111
138
|
spawnImpl?: (cmd: string, args: string[], o: {
|
|
112
139
|
detached: boolean;
|
|
@@ -115,7 +142,7 @@ export declare function autoUpdate(opts: {
|
|
|
115
142
|
windowsHide?: boolean;
|
|
116
143
|
}) => {
|
|
117
144
|
unref: () => void;
|
|
118
|
-
on: (ev: string, fn: () => void) => void;
|
|
145
|
+
on: (ev: string, fn: (...a: never[]) => void) => void;
|
|
119
146
|
};
|
|
120
147
|
now?: number;
|
|
121
148
|
aiChat?: (prompt: string) => Promise<string>;
|
package/dist/update-check.js
CHANGED
|
@@ -8,6 +8,47 @@
|
|
|
8
8
|
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
10
|
import { join, dirname } from 'node:path';
|
|
11
|
+
export async function loadReleaseNotes(distDir) {
|
|
12
|
+
const base = distDir ?? join(import.meta.dirname ?? '.', '');
|
|
13
|
+
try {
|
|
14
|
+
const j = JSON.parse(await readFile(join(base, '..', 'release-notes.json'), 'utf8'));
|
|
15
|
+
return j && Array.isArray(j.notes) ? j : null;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** The one-line note for one version ('' when unknown - never invented). */
|
|
22
|
+
export function noteFor(notes, version) {
|
|
23
|
+
const hit = notes?.notes.find((n) => n && n.v === version && typeof n.note === 'string');
|
|
24
|
+
return hit ? hit.note : '';
|
|
25
|
+
}
|
|
26
|
+
/** First-launch-of-a-new-version briefing (T27-v2 part 3). Returns the
|
|
27
|
+
* note text when the HMH_HOME stamp differs from the RUNNING version
|
|
28
|
+
* (then re-stamps); fresh installs (no stamp) and same-version launches
|
|
29
|
+
* return null. Shared by the TUI and the REPL so "hmh starts" means
|
|
30
|
+
* both frontends. */
|
|
31
|
+
export async function nextBriefing(home, current) {
|
|
32
|
+
const notes = await loadReleaseNotes();
|
|
33
|
+
if (!notes)
|
|
34
|
+
return null;
|
|
35
|
+
const stamp = join(home, 'last-noted-version.json');
|
|
36
|
+
let last;
|
|
37
|
+
try {
|
|
38
|
+
last = JSON.parse(await readFile(stamp, 'utf8')).v;
|
|
39
|
+
}
|
|
40
|
+
catch { /* fresh install */ }
|
|
41
|
+
if (last === current)
|
|
42
|
+
return null;
|
|
43
|
+
try {
|
|
44
|
+
await mkdir(home, { recursive: true });
|
|
45
|
+
await writeFile(stamp, JSON.stringify({ v: current }), 'utf8');
|
|
46
|
+
}
|
|
47
|
+
catch { /* best-effort stamp */ }
|
|
48
|
+
if (last === undefined)
|
|
49
|
+
return null; // fresh install: welcome covers it
|
|
50
|
+
return noteFor(notes, current) || '—';
|
|
51
|
+
}
|
|
11
52
|
const REGISTRY = 'https://registry.npmjs.org/-/package/@hmharness/cli/dist-tags';
|
|
12
53
|
// 5 minutes for auto-update mode (fresh enough to catch new releases same-session);
|
|
13
54
|
// the check is a single lightweight GET, not worth caching longer
|
|
@@ -160,6 +201,7 @@ export async function aiRepairUpdate(opts) {
|
|
|
160
201
|
const child = plat === 'win32'
|
|
161
202
|
? spawnFn('cmd.exe', ['/d', '/s', '/c', cmd], { detached: true, stdio: ['ignore', opts.logFd, opts.logFd], cwd: opts.home, windowsHide: true })
|
|
162
203
|
: spawnFn(cmd.split(' ')[0], cmd.split(' ').slice(1), { detached: true, stdio: ['ignore', opts.logFd, opts.logFd], cwd: opts.home });
|
|
204
|
+
child.on('close', (code) => opts.onDone?.(code ?? -1));
|
|
163
205
|
child.unref();
|
|
164
206
|
return cmd;
|
|
165
207
|
}
|
|
@@ -216,12 +258,15 @@ export async function autoUpdate(opts) {
|
|
|
216
258
|
cwd: opts.home,
|
|
217
259
|
windowsHide: true, // never flash a console window (T27)
|
|
218
260
|
});
|
|
261
|
+
child.on('close', (code) => opts.onDone?.(code ?? -1, info.latest));
|
|
219
262
|
child.unref();
|
|
220
263
|
await writeFile(lockFile, JSON.stringify({ time: now, to: info.latest, via: 'board-installer' }), 'utf8');
|
|
264
|
+
opts.say?.(info.latest); // dim in-TUI start line (T27-v2), BEFORE the
|
|
265
|
+
// start-failure probe so the visual order is always start -> outcome
|
|
221
266
|
const started = await spawnStarted(child);
|
|
222
267
|
if (!started)
|
|
223
268
|
throw new Error('board installer failed to start');
|
|
224
|
-
return;
|
|
269
|
+
return;
|
|
225
270
|
}
|
|
226
271
|
opts.sayFail?.('board install: updater script missing');
|
|
227
272
|
return;
|
|
@@ -233,13 +278,14 @@ export async function autoUpdate(opts) {
|
|
|
233
278
|
cwd: opts.home,
|
|
234
279
|
windowsHide: true, // detached cmd.exe/npm MUST NOT open a visible window (T27)
|
|
235
280
|
});
|
|
281
|
+
child.on('close', (code) => opts.onDone?.(code ?? -1, info.latest));
|
|
236
282
|
child.unref();
|
|
237
283
|
await writeFile(lockFile, JSON.stringify({ time: now, to: info.latest }), 'utf8');
|
|
284
|
+
opts.say?.(info.latest); // dim in-TUI start line (T27-v2), BEFORE the
|
|
285
|
+
// start-failure probe so the visual order is always start -> outcome
|
|
238
286
|
const started = await spawnStarted(child);
|
|
239
287
|
if (!started)
|
|
240
288
|
throw new Error('installer failed to start');
|
|
241
|
-
// silent success (T27): no notice - the header version changes on the
|
|
242
|
-
// next launch; every detail is in update.log if anyone needs it
|
|
243
289
|
}
|
|
244
290
|
catch (err) {
|
|
245
291
|
// SMART layer: let the user's own model adapt to this machine
|
|
@@ -254,10 +300,12 @@ export async function autoUpdate(opts) {
|
|
|
254
300
|
version: info.latest,
|
|
255
301
|
chatImpl: opts.aiChat,
|
|
256
302
|
spawnImpl: opts.spawnImpl,
|
|
303
|
+
onDone: (code) => opts.onDone?.(code, info.latest),
|
|
257
304
|
logFd: log.fd,
|
|
258
305
|
});
|
|
259
306
|
if (ran) {
|
|
260
307
|
await writeFile(lockFile, JSON.stringify({ time: now, to: info.latest, via: 'ai-repair', cmd: ran }), 'utf8');
|
|
308
|
+
opts.say?.(info.latest + ' (AI 修复安装)');
|
|
261
309
|
}
|
|
262
310
|
else {
|
|
263
311
|
opts.sayFail?.(errText.slice(0, 80));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.23",
|
|
4
4
|
"description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
|
-
"board"
|
|
19
|
+
"board",
|
|
20
|
+
"release-notes.json"
|
|
20
21
|
],
|
|
21
22
|
"engines": {
|
|
22
23
|
"node": ">=22"
|
|
@@ -44,19 +45,20 @@
|
|
|
44
45
|
"build": "tsc -p tsconfig.build.json"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@hmharness/agent": "0.23.
|
|
48
|
-
"@hmharness/browser": "0.23.
|
|
49
|
-
"@hmharness/cognitive": "0.23.
|
|
50
|
-
"@hmharness/domain-harmony": "0.23.
|
|
51
|
-
"@hmharness/domain-ops": "0.23.
|
|
52
|
-
"@hmharness/environments": "0.23.
|
|
53
|
-
"@hmharness/evaluation": "0.23.
|
|
54
|
-
"@hmharness/evolution": "0.23.
|
|
55
|
-
"@hmharness/
|
|
56
|
-
"@hmharness/
|
|
57
|
-
"@hmharness/
|
|
58
|
-
"@hmharness/
|
|
48
|
+
"@hmharness/agent": "0.23.23",
|
|
49
|
+
"@hmharness/browser": "0.23.23",
|
|
50
|
+
"@hmharness/cognitive": "0.23.23",
|
|
51
|
+
"@hmharness/domain-harmony": "0.23.23",
|
|
52
|
+
"@hmharness/domain-ops": "0.23.23",
|
|
53
|
+
"@hmharness/environments": "0.23.23",
|
|
54
|
+
"@hmharness/evaluation": "0.23.23",
|
|
55
|
+
"@hmharness/evolution": "0.23.23",
|
|
56
|
+
"@hmharness/extension": "0.23.23",
|
|
57
|
+
"@hmharness/kernel": "0.23.23",
|
|
58
|
+
"@hmharness/observability": "0.23.23",
|
|
59
|
+
"@hmharness/sandbox": "0.23.23",
|
|
60
|
+
"@hmharness/web": "0.23.23",
|
|
59
61
|
"qrcode": "^1.5.4",
|
|
60
|
-
"@hmharness/lsp": "0.23.
|
|
62
|
+
"@hmharness/lsp": "0.23.23"
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"notes": [
|
|
3
|
+
{
|
|
4
|
+
"v": "0.23.23",
|
|
5
|
+
"date": "2026-10-04",
|
|
6
|
+
"note": "更新体验:后台更新时 TUI 内轻提示(开始/完成),升级后首次启动显示一行更新简报——无弹窗但不再失联"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"v": "0.23.22",
|
|
10
|
+
"date": "2026-10-04",
|
|
11
|
+
"note": "审计研究基建池全量:COG-MEA 长任务循环、版本化评测任务集(数据集指纹+种子+留出)、沙箱红队加固、WM-2 观测因果挖掘、Code World Model"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"v": "0.23.21",
|
|
15
|
+
"date": "2026-10-04",
|
|
16
|
+
"note": "BrowserOS AI 浏览器包(第 15 包)+ ACP 服务器(BrowserOS 助手面板可直接驱动 hmh)+ flaky 根因修复"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"v": "0.23.20",
|
|
20
|
+
"date": "2026-10-04",
|
|
21
|
+
"note": "认知消融三臂阶梯仪器(ablate --task --ladder3,支持 --difficulty=hard)"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"v": "0.23.19",
|
|
25
|
+
"date": "2026-10-04",
|
|
26
|
+
"note": "能力 OS 首片:LSP 源信任 + sha256 钉扎(DevEco 本地 clangd 自动发现并钉扎,PATH 源一次性信任)"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"v": "0.23.18",
|
|
30
|
+
"date": "2026-10-04",
|
|
31
|
+
"note": "群体循环远程吸收:absorb --from=<url>(协议墙+大小上限+免内容校验)"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"v": "0.23.17",
|
|
35
|
+
"date": "2026-10-04",
|
|
36
|
+
"note": "12 周计划收官特性:DevEco 本地 LSP 服务器发现(官方 clangd 全链路)"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"v": "0.23.16",
|
|
40
|
+
"date": "2026-10-03",
|
|
41
|
+
"note": "发布链三防线(private 包/依赖覆盖预检/板级兜底钉随版);@hmharness/lsp 首发修复全新安装;KaihongOS 板级自动更新通道生效"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"v": "0.23.15",
|
|
45
|
+
"date": "2026-10-03",
|
|
46
|
+
"note": "热修:补上 0.23.14 缺失的 lsp 依赖发布;发布预检加入依赖覆盖与 private 检查"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"v": "0.23.14",
|
|
50
|
+
"date": "2026-10-02",
|
|
51
|
+
"note": "无垫片更新链(更新弹窗根因修复,node 直跑 npm-cli.js);KaihongOS 板端随包安装器;长会话队列断路器与崩溃断点召回"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|