@hmharness/cli 0.23.43 → 0.23.45
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/board/install-kaihongos.cjs +10 -5
- package/dist/extension-daemon.d.ts +10 -1
- package/dist/extension-daemon.js +61 -0
- package/dist/main.js +16 -10
- package/dist/markdown.d.ts +10 -0
- package/dist/markdown.js +497 -0
- package/dist/tui.d.ts +3 -4
- package/dist/tui.js +28 -27
- package/package.json +15 -15
- package/release-notes.json +10 -0
|
@@ -67,11 +67,11 @@ let PACKAGES = ['cli', 'web', 'agent', 'kernel', 'sandbox', 'evolution',
|
|
|
67
67
|
// the offline path tried <name>-undefined.tgz → 404 → INSTALL FAILED (directly
|
|
68
68
|
// contradicting the promise above; evidence: cli 0.23.42 declares 14 deps).
|
|
69
69
|
const FALLBACK_PINS = {
|
|
70
|
-
cli: '0.23.
|
|
71
|
-
sandbox: '0.23.
|
|
72
|
-
evaluation: '0.23.
|
|
73
|
-
cognitive: '0.23.
|
|
74
|
-
browser: '0.23.
|
|
70
|
+
cli: '0.23.45', web: '0.23.45', agent: '0.23.45', kernel: '0.23.45',
|
|
71
|
+
sandbox: '0.23.45', evolution: '0.23.45', 'domain-ops': '0.23.45',
|
|
72
|
+
evaluation: '0.23.45', observability: '0.23.45', 'domain-harmony': '0.23.45',
|
|
73
|
+
cognitive: '0.23.45', environments: '0.23.45', lsp: '0.23.45',
|
|
74
|
+
browser: '0.23.45', extension: '0.23.45',
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
// ---------- helpers ---------------------------------------------------------
|
|
@@ -259,6 +259,11 @@ function healHookSource() {
|
|
|
259
259
|
' _HMH_HEAL_NODE="${HNODE:-' + path.join(BOARD_HOME, 'dsh-pack/node/bin/node.bin') + '}"',
|
|
260
260
|
' if [ -x "$_HMH_HEAL_NODE" ]; then',
|
|
261
261
|
' HMH_BOARD_HOME="' + BOARD_HOME + '" \\',
|
|
262
|
+
// jitless self-contained: this hook can run BEFORE the launcher exports
|
|
263
|
+
// NODE_OPTIONS="--jitless" (apikeys.env is sourced first) — on RWX-forbidden
|
|
264
|
+
// boards a JIT node crashes here (V8 errno check, observed on the VM).
|
|
265
|
+
// jitless is harmless on JIT-capable boards for a ~0.1s heal check.
|
|
266
|
+
' NODE_OPTIONS="--jitless${NODE_OPTIONS:+ $NODE_OPTIONS}" \\',
|
|
262
267
|
' "$_HMH_HEAL_NODE" ' + path.join(HMH_HOME, 'heal-tree.cjs') + ' >>' + path.join(HMH_HOME, 'heal.log') + ' 2>&1 \\',
|
|
263
268
|
' || echo "hmh: self-heal could not complete (see ' + path.join(HMH_HOME, 'heal.log') + ') — starting anyway" >&2',
|
|
264
269
|
' fi',
|
|
@@ -33,5 +33,14 @@ export declare function watchdogPidPath(): string;
|
|
|
33
33
|
export declare function runWatchdogLoop(port: number, entry: string): Promise<never>;
|
|
34
34
|
/** Spawn the watchdog detached (no window). Safe to call repeatedly. */
|
|
35
35
|
export declare function startWatchdog(port?: number, entry?: string): number;
|
|
36
|
-
/**
|
|
36
|
+
/** Windows scheduled-task watchdog: the OS revives the watchdog every
|
|
37
|
+
* minute REGARDLESS of process trees, logoffs, or test sweeps — detached
|
|
38
|
+
* pids died twice in the field (round 55/56), a SYSTEM timer cannot.
|
|
39
|
+
* Field-hardened: (a) the task entry is a PLAIN SCRIPT FILE — inline -e
|
|
40
|
+
* code gets its quotes eaten by schtasks/TR; (b) run through `cmd /c
|
|
41
|
+
* start /b` so the SYSTEM-triggered run inherits the user env chain
|
|
42
|
+
* (mise shim dies without HOME); (c) node path = process.execPath — a
|
|
43
|
+
* hardcoded Program Files path silently ENOENTs on mise machines. */
|
|
44
|
+
export declare function installScheduledWatchdog(port?: number): boolean;
|
|
45
|
+
export declare function uninstallScheduledWatchdog(): boolean;
|
|
37
46
|
export declare function stopWatchdog(): boolean;
|
package/dist/extension-daemon.js
CHANGED
|
@@ -233,6 +233,67 @@ export function startWatchdog(port = DEFAULT_EXTENSION_PORT, entry = process.arg
|
|
|
233
233
|
return child.pid ?? 0;
|
|
234
234
|
}
|
|
235
235
|
/** Stop the watchdog (used by `extension stop` — it must not resurrect). */
|
|
236
|
+
const WATCHDOG_TASK = 'hmharness-extension-watchdog';
|
|
237
|
+
/** Windows scheduled-task watchdog: the OS revives the watchdog every
|
|
238
|
+
* minute REGARDLESS of process trees, logoffs, or test sweeps — detached
|
|
239
|
+
* pids died twice in the field (round 55/56), a SYSTEM timer cannot.
|
|
240
|
+
* Field-hardened: (a) the task entry is a PLAIN SCRIPT FILE — inline -e
|
|
241
|
+
* code gets its quotes eaten by schtasks/TR; (b) run through `cmd /c
|
|
242
|
+
* start /b` so the SYSTEM-triggered run inherits the user env chain
|
|
243
|
+
* (mise shim dies without HOME); (c) node path = process.execPath — a
|
|
244
|
+
* hardcoded Program Files path silently ENOENTs on mise machines. */
|
|
245
|
+
export function installScheduledWatchdog(port = DEFAULT_EXTENSION_PORT) {
|
|
246
|
+
if (process.platform !== 'win32')
|
|
247
|
+
return false;
|
|
248
|
+
const entry = process.argv[1];
|
|
249
|
+
const taskEntry = join(entry, '..', 'extension-watchdog-task.cjs');
|
|
250
|
+
try {
|
|
251
|
+
writeFileSync(taskEntry, [
|
|
252
|
+
`// auto-generated by hmh extension start — scheduled-task watchdog entry`,
|
|
253
|
+
`const { pathToFileURL } = require('node:url');`,
|
|
254
|
+
`const ENTRY = ${JSON.stringify(entry)};`,
|
|
255
|
+
`import(pathToFileURL(${JSON.stringify(join(entry, '..', 'extension-daemon.js'))}).href)`,
|
|
256
|
+
` .then((m) => m.runWatchdogLoop(${port}, ENTRY))`,
|
|
257
|
+
` .catch((e) => { try { require('node:fs').appendFileSync(require('node:path').join(require('node:os').homedir(), '.hmharness', 'extension-watchdog.log'), 'task entry error: ' + String(e) + '\\n'); } catch { /* */ } });`,
|
|
258
|
+
``,
|
|
259
|
+
].join('\n'), 'utf8');
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const node = process.execPath.replace(/'/g, "''");
|
|
265
|
+
const ps = [
|
|
266
|
+
`$action = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument '/c start "" /b "${node}" "${taskEntry.replace(/\\/g, '\\\\')}"'`,
|
|
267
|
+
`$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 1) -RepetitionDuration (New-TimeSpan -Days 3650)`,
|
|
268
|
+
`$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Days 3650) -MultipleInstances IgnoreNew`,
|
|
269
|
+
`Register-ScheduledTask -TaskName '${WATCHDOG_TASK}' -Action $action -Trigger $trigger -Settings $settings -Force | Out-Null`,
|
|
270
|
+
`Write-Host ok`,
|
|
271
|
+
].join('; ');
|
|
272
|
+
try {
|
|
273
|
+
const out = execSync(`powershell -NoProfile -Command "${ps.replace(/"/g, '\\"')}"`, { encoding: 'utf8', timeout: 30_000, windowsHide: true });
|
|
274
|
+
return out.includes('ok');
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
try {
|
|
278
|
+
execSync(`schtasks /Query /TN ${WATCHDOG_TASK}`, { stdio: 'ignore', timeout: 10_000 });
|
|
279
|
+
return true; // an existing task under our name is acceptable
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
export function uninstallScheduledWatchdog() {
|
|
287
|
+
if (process.platform !== 'win32')
|
|
288
|
+
return false;
|
|
289
|
+
try {
|
|
290
|
+
execSync(`schtasks /Delete /F /TN ${WATCHDOG_TASK}`, { stdio: 'ignore', timeout: 15_000 });
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
236
297
|
export function stopWatchdog() {
|
|
237
298
|
try {
|
|
238
299
|
const wp = watchdogPidPath();
|
package/dist/main.js
CHANGED
|
@@ -1183,10 +1183,11 @@ flags:
|
|
|
1183
1183
|
if (sub === 'stop') {
|
|
1184
1184
|
const w = ed.stopWatchdog();
|
|
1185
1185
|
const killed = ed.stopExtensionDaemon(port);
|
|
1186
|
-
|
|
1186
|
+
const task = ed.uninstallScheduledWatchdog();
|
|
1187
|
+
stdout.write(w || killed || task ? '已停止扩展桥守护(含看门狗/计划任务)\n' : '守护本就未运行\n');
|
|
1187
1188
|
return;
|
|
1188
1189
|
}
|
|
1189
|
-
const { probeExtensionDaemon, ensureExtensionDaemon, startWatchdog, DEFAULT_EXTENSION_PORT } = ed;
|
|
1190
|
+
const { probeExtensionDaemon, ensureExtensionDaemon, startWatchdog, installScheduledWatchdog, DEFAULT_EXTENSION_PORT } = ed;
|
|
1190
1191
|
const p = port ?? DEFAULT_EXTENSION_PORT;
|
|
1191
1192
|
const already = await probeExtensionDaemon(p);
|
|
1192
1193
|
if (already.up) {
|
|
@@ -1198,10 +1199,12 @@ flags:
|
|
|
1198
1199
|
stdout.write(`✗ 守护启动失败(详见 ${homeDir()}/extension.log)\n`);
|
|
1199
1200
|
return;
|
|
1200
1201
|
}
|
|
1201
|
-
|
|
1202
|
+
startWatchdog(p);
|
|
1203
|
+
const task = installScheduledWatchdog(p);
|
|
1202
1204
|
stdout.write(`✓ 扩展桥守护已启动(后台,PID 文件 ${homeDir()}/extension.pid)\n`);
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
+
stdout.write(task
|
|
1206
|
+
? `✓ 双保险就位:进程看门狗 + Windows 计划任务(每分钟系统级自愈,重启电脑也常驻)\n`
|
|
1207
|
+
: `✓ 看门狗已就位(每 60s 自检,桥意外死亡自动复活)\n`);
|
|
1205
1208
|
stdout.write(r.connected ? ' 浏览器扩展已连接 — 智能体 extension_* 工具可用\n' : ' 装有扩展的浏览器 30 秒内自动连接(浏览器先开也行)\n');
|
|
1206
1209
|
stdout.write(DIM(' 停止: hmh extension stop;前台调试: hmh extension serve;状态: hmh extension status\n'));
|
|
1207
1210
|
return;
|
|
@@ -1254,12 +1257,15 @@ flags:
|
|
|
1254
1257
|
stdout.write(DIM(' 生效时机: 浏览器重启后常驻;撤销: hmh extension uninstall\n'));
|
|
1255
1258
|
// 装完即用:终端侧零操作 —— 直接把桥守护拉起(幂等,已在跑则跳过)
|
|
1256
1259
|
try {
|
|
1257
|
-
const { ensureExtensionDaemon, startWatchdog } = await import("./extension-daemon.js");
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1260
|
-
|
|
1260
|
+
const { ensureExtensionDaemon, startWatchdog, installScheduledWatchdog } = await import("./extension-daemon.js");
|
|
1261
|
+
const portN = pArg ? Number(pArg.slice(7)) : undefined;
|
|
1262
|
+
const p = await ensureExtensionDaemon(portN);
|
|
1263
|
+
if (p.up) {
|
|
1264
|
+
startWatchdog(portN);
|
|
1265
|
+
installScheduledWatchdog(portN);
|
|
1266
|
+
}
|
|
1261
1267
|
stdout.write(p.up
|
|
1262
|
-
? `✓ 扩展桥守护已启动(
|
|
1268
|
+
? `✓ 扩展桥守护已启动(后台+双保险看门狗) — 浏览器打开后 30 秒内自动连接\n`
|
|
1263
1269
|
: DIM(' · 桥守护未能启动 — 手动: hmh extension start\n'));
|
|
1264
1270
|
}
|
|
1265
1271
|
catch { /* 守护是锦上添花,不阻塞安装报告 */ }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function strWidth(s: string): number;
|
|
2
|
+
export interface InlineTok {
|
|
3
|
+
text: string;
|
|
4
|
+
sgr: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseInline(text: string): InlineTok[];
|
|
7
|
+
/** Render markdown text into styled terminal lines. One linear pass splits
|
|
8
|
+
* blocks; every block renderer is O(lines). Deterministic: same input and
|
|
9
|
+
* width always produce the same array (streaming repaint relies on it). */
|
|
10
|
+
export declare function renderMarkdown(text: string, width: number): string[];
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hmharness/cli - terminal markdown renderer (zero dependencies)
|
|
3
|
+
*
|
|
4
|
+
* Renders model markdown into clean terminal lines - styled headings with
|
|
5
|
+
* rules, CJK-aware aligned box tables, nested/task lists, fenced code,
|
|
6
|
+
* blockquotes, inline bold/code/links - closing the gap to the Codex CLI /
|
|
7
|
+
* Claude Code terminals (2026-10-29 user feedback: the old mdColor was a
|
|
8
|
+
* line-start tint, not a renderer; the model emits standard markdown, the
|
|
9
|
+
* CLI owns the rendering). SGR escapes only: no cursor moves, no alt-screen,
|
|
10
|
+
* so conhost/Windows Terminal both cope. Pure + deterministic: the TUI's
|
|
11
|
+
* streaming repaint feeds completed lines here and appends the raw in-flight
|
|
12
|
+
* tail (codex markdown_stream.rs re-renders open blocks the same way).
|
|
13
|
+
*/
|
|
14
|
+
const RESET = '\x1b[0m';
|
|
15
|
+
const DIM = '\x1b[2m';
|
|
16
|
+
const BOLD = '\x1b[1m';
|
|
17
|
+
const CYAN = '\x1b[36m';
|
|
18
|
+
const GREEN = '\x1b[32m';
|
|
19
|
+
const UNDERLINE = '\x1b[4m';
|
|
20
|
+
const INVERSE = '\x1b[7m';
|
|
21
|
+
/* ---------------- width (CJK-aware; same table as tui.ts) ---------------- */
|
|
22
|
+
/* Not imported from tui.ts: tui.ts imports this module, and duplicating the
|
|
23
|
+
* 8-line table beats a dependency cycle. Keep the ranges in sync. */
|
|
24
|
+
function cw(ch) {
|
|
25
|
+
const c = ch.codePointAt(0) ?? 0;
|
|
26
|
+
if ((c >= 0x1100 && c <= 0x115f) || (c >= 0x2e80 && c <= 0xa4cf) || (c >= 0xac00 && c <= 0xd7a3) ||
|
|
27
|
+
(c >= 0xf900 && c <= 0xfaff) || (c >= 0xfe30 && c <= 0xfe6f) || (c >= 0xff00 && c <= 0xff60) ||
|
|
28
|
+
(c >= 0xffe0 && c <= 0xffe6) || (c >= 0x20000 && c <= 0x3fffd))
|
|
29
|
+
return 2;
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
export function strWidth(s) {
|
|
33
|
+
let w = 0;
|
|
34
|
+
for (const ch of s)
|
|
35
|
+
w += cw(ch);
|
|
36
|
+
return w;
|
|
37
|
+
}
|
|
38
|
+
function stripAnsi(s) {
|
|
39
|
+
return s.replace(/\x1b\[[0-9;?]*[a-zA-Z]/g, '');
|
|
40
|
+
}
|
|
41
|
+
const ESCAPABLE = new Set(['\\', '`', '*', '_', '[', ']', '(', ')', '<', '>', '#', '+', '-', '~', '!']);
|
|
42
|
+
const wbBefore = (s, i) => i === 0 || /[\s("']/.test(s[i - 1]);
|
|
43
|
+
const wbAfter = (s, i) => i + 1 >= s.length || /[\s,.;:!?"')]/.test(s[i + 1]);
|
|
44
|
+
export function parseInline(text) {
|
|
45
|
+
const toks = [];
|
|
46
|
+
let plain = '';
|
|
47
|
+
const flush = () => { if (plain) {
|
|
48
|
+
toks.push({ text: plain, sgr: '' });
|
|
49
|
+
plain = '';
|
|
50
|
+
} };
|
|
51
|
+
let i = 0;
|
|
52
|
+
while (i < text.length) {
|
|
53
|
+
const ch = text[i];
|
|
54
|
+
if (ch === '\\' && ESCAPABLE.has(text[i + 1] ?? '')) {
|
|
55
|
+
plain += text[i + 1];
|
|
56
|
+
i += 2;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (ch === '`') {
|
|
60
|
+
const close = text.indexOf('`', i + 1);
|
|
61
|
+
if (close > i) {
|
|
62
|
+
flush();
|
|
63
|
+
toks.push({ text: text.slice(i + 1, close), sgr: INVERSE });
|
|
64
|
+
i = close + 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (ch === '*' && text[i + 1] === '*') {
|
|
69
|
+
const close = text.indexOf('**', i + 2);
|
|
70
|
+
if (close > i + 2) {
|
|
71
|
+
flush();
|
|
72
|
+
toks.push({ text: text.slice(i + 2, close), sgr: BOLD });
|
|
73
|
+
i = close + 2;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if ((ch === '*' || ch === '_') && text[i + 1] !== '*' && text[i + 1] !== ' ' && wbBefore(text, i)) {
|
|
78
|
+
let close = -1;
|
|
79
|
+
for (let j = i + 1; j < text.length; j++) {
|
|
80
|
+
if (text[j] === ch && text[j + 1] !== ch) {
|
|
81
|
+
close = j;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// body must not end with a space either, so `a * b * c` stays literal
|
|
86
|
+
if (close > i + 1 && text[close - 1] !== ' ' && wbAfter(text, close)) {
|
|
87
|
+
flush();
|
|
88
|
+
toks.push({ text: text.slice(i + 1, close), sgr: BOLD });
|
|
89
|
+
i = close + 1;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (ch === '[') {
|
|
94
|
+
const cb = text.indexOf('](', i + 1);
|
|
95
|
+
if (cb > i) {
|
|
96
|
+
const cp = text.indexOf(')', cb + 2);
|
|
97
|
+
if (cp > cb) {
|
|
98
|
+
flush();
|
|
99
|
+
toks.push({ text: text.slice(i + 1, cb), sgr: UNDERLINE });
|
|
100
|
+
i = cp + 1;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (ch === '<') {
|
|
106
|
+
const m = /^<\/?[a-zA-Z][^>]*>/.exec(text.slice(i));
|
|
107
|
+
if (m) {
|
|
108
|
+
i += m[0].length;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
plain += ch;
|
|
113
|
+
i++;
|
|
114
|
+
}
|
|
115
|
+
flush();
|
|
116
|
+
return toks;
|
|
117
|
+
}
|
|
118
|
+
function renderToks(toks, override = '') {
|
|
119
|
+
let out = '';
|
|
120
|
+
for (const t of toks) {
|
|
121
|
+
const s = override || t.sgr;
|
|
122
|
+
out += s ? s + t.text + RESET : t.text;
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
const toksWidth = (toks) => toks.reduce((a, t) => a + strWidth(t.text), 0);
|
|
127
|
+
function renderCells(cells) {
|
|
128
|
+
let out = '';
|
|
129
|
+
let run = '';
|
|
130
|
+
let cur = null;
|
|
131
|
+
for (const c of cells) {
|
|
132
|
+
if (c.sgr !== cur) {
|
|
133
|
+
if (run)
|
|
134
|
+
out += cur ? cur + run + RESET : run;
|
|
135
|
+
cur = c.sgr;
|
|
136
|
+
run = '';
|
|
137
|
+
}
|
|
138
|
+
run += c.ch;
|
|
139
|
+
}
|
|
140
|
+
if (run)
|
|
141
|
+
out += cur ? cur + run + RESET : run;
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
/** Break at the last in-line space when possible; CJK runs (no spaces) break
|
|
145
|
+
* hard at the width limit. Every emitted line fits its budget. */
|
|
146
|
+
function wrapToks(toks, firstW, restW) {
|
|
147
|
+
const cells = [];
|
|
148
|
+
for (const t of toks)
|
|
149
|
+
for (const ch of t.text)
|
|
150
|
+
cells.push({ ch, sgr: t.sgr, w: cw(ch) });
|
|
151
|
+
const out = [];
|
|
152
|
+
let line = [];
|
|
153
|
+
let lw = 0;
|
|
154
|
+
let first = true;
|
|
155
|
+
const flush = () => {
|
|
156
|
+
while (line.length > 0 && line[line.length - 1].ch === ' ')
|
|
157
|
+
line.pop();
|
|
158
|
+
out.push(renderCells(line));
|
|
159
|
+
line = [];
|
|
160
|
+
lw = 0;
|
|
161
|
+
first = false;
|
|
162
|
+
};
|
|
163
|
+
for (const c of cells) {
|
|
164
|
+
if (c.ch === ' ' && lw === 0 && !first)
|
|
165
|
+
continue;
|
|
166
|
+
if (c.ch !== ' ' && line.length > 0 && lw + c.w > (first ? firstW : restW)) {
|
|
167
|
+
let sp = -1;
|
|
168
|
+
for (let j = line.length - 1; j > 0; j--)
|
|
169
|
+
if (line[j].ch === ' ') {
|
|
170
|
+
sp = j;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (sp > 0) {
|
|
174
|
+
const carry = line.slice(sp + 1);
|
|
175
|
+
line.length = sp;
|
|
176
|
+
flush();
|
|
177
|
+
line = carry;
|
|
178
|
+
lw = carry.reduce((a, b) => a + b.w, 0);
|
|
179
|
+
while (line.length > 0 && line[0].ch === ' ') {
|
|
180
|
+
lw -= line[0].w;
|
|
181
|
+
line.shift();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
flush();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
line.push(c);
|
|
189
|
+
lw += c.w;
|
|
190
|
+
}
|
|
191
|
+
flush();
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
/** SGR-aware truncation with an ellipsis (code lines, table cells, headings). */
|
|
195
|
+
function truncateVis(s, max) {
|
|
196
|
+
if (strWidth(stripAnsi(s)) <= max)
|
|
197
|
+
return s;
|
|
198
|
+
let w = 0;
|
|
199
|
+
let out = '';
|
|
200
|
+
for (let i = 0; i < s.length;) {
|
|
201
|
+
const m = /^\x1b\[[0-9;]*m/.exec(s.substring(i));
|
|
202
|
+
if (m) {
|
|
203
|
+
out += m[0];
|
|
204
|
+
i += m[0].length;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const ch = String.fromCodePoint(s.codePointAt(i));
|
|
208
|
+
if (w + cw(ch) > max - 1)
|
|
209
|
+
return out + '…';
|
|
210
|
+
out += ch;
|
|
211
|
+
w += cw(ch);
|
|
212
|
+
i += ch.length;
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
/* ---------------- block renderers ---------------- */
|
|
217
|
+
function renderHeading(level, content, width) {
|
|
218
|
+
const sgr = level <= 2 ? BOLD + CYAN : level <= 4 ? BOLD : DIM + BOLD;
|
|
219
|
+
let line = renderToks(parseInline(content), sgr);
|
|
220
|
+
if (strWidth(stripAnsi(line)) > width)
|
|
221
|
+
line = truncateVis(line, width);
|
|
222
|
+
const out = [line];
|
|
223
|
+
if (level <= 2) {
|
|
224
|
+
out.push(DIM + '─'.repeat(Math.min(width, strWidth(stripAnsi(line)) + 2)) + RESET);
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
function renderCode(lines, lang, width) {
|
|
229
|
+
// no inline parsing inside fences; 2-space `│ ` dim prefix, lang at tail of line 1
|
|
230
|
+
const max = Math.max(4, width - 2);
|
|
231
|
+
const out = lines.length === 0 ? [''] : lines.map((cl) => (strWidth(cl) > max ? truncateVis(cl, max) : cl));
|
|
232
|
+
return out.map((cl, idx) => DIM + '│ ' + RESET + cl + (idx === 0 && lang ? ' ' + DIM + lang + RESET : ''));
|
|
233
|
+
}
|
|
234
|
+
function renderQuote(contents, width) {
|
|
235
|
+
const out = [];
|
|
236
|
+
let para = [];
|
|
237
|
+
const emitPara = () => {
|
|
238
|
+
if (para.length === 0)
|
|
239
|
+
return;
|
|
240
|
+
for (const l of wrapToks(parseInline(para.join(' ')), width - 2, width - 2)) {
|
|
241
|
+
out.push(DIM + '│ ' + RESET + l);
|
|
242
|
+
}
|
|
243
|
+
para = [];
|
|
244
|
+
};
|
|
245
|
+
for (const c of contents) {
|
|
246
|
+
if (c === '') {
|
|
247
|
+
emitPara();
|
|
248
|
+
out.push(DIM + '│ ' + RESET);
|
|
249
|
+
}
|
|
250
|
+
else
|
|
251
|
+
para.push(c);
|
|
252
|
+
}
|
|
253
|
+
emitPara();
|
|
254
|
+
return out.length === 0 ? [DIM + '│ ' + RESET] : out;
|
|
255
|
+
}
|
|
256
|
+
function tableSepAlign(cell) {
|
|
257
|
+
const t = cell.trim();
|
|
258
|
+
const core = t.replace(/^:/, '').replace(/:$/, '');
|
|
259
|
+
if (!/^-+$/.test(core))
|
|
260
|
+
return null;
|
|
261
|
+
return t.startsWith(':') && t.endsWith(':') ? 'c' : t.endsWith(':') ? 'r' : 'l';
|
|
262
|
+
}
|
|
263
|
+
function isTableSepLine(line) {
|
|
264
|
+
const t = line.trim();
|
|
265
|
+
if (!t.includes('-') || !t.includes('|'))
|
|
266
|
+
return false;
|
|
267
|
+
let body = t;
|
|
268
|
+
if (body.startsWith('|'))
|
|
269
|
+
body = body.slice(1);
|
|
270
|
+
if (body.endsWith('|'))
|
|
271
|
+
body = body.slice(0, -1);
|
|
272
|
+
const cells = body.split('|');
|
|
273
|
+
return cells.length > 0 && cells.every((c) => tableSepAlign(c) !== null);
|
|
274
|
+
}
|
|
275
|
+
function splitRow(line) {
|
|
276
|
+
let t = line.trim();
|
|
277
|
+
if (t.startsWith('|'))
|
|
278
|
+
t = t.slice(1);
|
|
279
|
+
if (t.endsWith('|') && !t.endsWith('\\|'))
|
|
280
|
+
t = t.slice(0, -1);
|
|
281
|
+
// `\|` inside a cell is a literal pipe, not a separator (GFM tables)
|
|
282
|
+
const cells = [];
|
|
283
|
+
let cur = '';
|
|
284
|
+
for (let k = 0; k < t.length; k++) {
|
|
285
|
+
if (t[k] === '\\' && t[k + 1] === '|') {
|
|
286
|
+
cur += '|';
|
|
287
|
+
k++;
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (t[k] === '|') {
|
|
291
|
+
cells.push(cur.trim());
|
|
292
|
+
cur = '';
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
cur += t[k];
|
|
296
|
+
}
|
|
297
|
+
cells.push(cur.trim());
|
|
298
|
+
return cells;
|
|
299
|
+
}
|
|
300
|
+
function renderTable(header, aligns, rows, width) {
|
|
301
|
+
const n = header.length;
|
|
302
|
+
const headToks = header.map(parseInline);
|
|
303
|
+
const rowToks = rows.map((r) => r.map(parseInline));
|
|
304
|
+
const natural = new Array(n).fill(0);
|
|
305
|
+
for (const set of [headToks, ...rowToks]) {
|
|
306
|
+
set.forEach((toks, i) => { if (i < n)
|
|
307
|
+
natural[i] = Math.max(natural[i], toksWidth(toks)); });
|
|
308
|
+
}
|
|
309
|
+
// Columns keep their natural width while the box fits `width`; only when
|
|
310
|
+
// it overflows does the widest column shrink first (floor 3), so an
|
|
311
|
+
// in-budget table is never truncated (task spec: only what does not fit
|
|
312
|
+
// gets the ellipsis). chrome = borders + one space of padding per side.
|
|
313
|
+
const chrome = n + 1 + 2 * n;
|
|
314
|
+
const colW = natural.map((w) => Math.max(1, w));
|
|
315
|
+
const boxW = () => colW.reduce((a, b) => a + b, 0) + chrome;
|
|
316
|
+
while (boxW() > width) {
|
|
317
|
+
let widest = 0;
|
|
318
|
+
for (let i = 0; i < n; i++)
|
|
319
|
+
if (colW[i] > colW[widest])
|
|
320
|
+
widest = i;
|
|
321
|
+
if (colW[widest] <= 3)
|
|
322
|
+
break;
|
|
323
|
+
colW[widest] -= 1;
|
|
324
|
+
}
|
|
325
|
+
const bar = (l, m, r) => DIM + l + colW.map((w) => '─'.repeat(w + 2)).join(m) + r + RESET;
|
|
326
|
+
const rowLine = (cells, isHead) => {
|
|
327
|
+
const parts = cells.map((toks, i) => {
|
|
328
|
+
let s = renderToks(toks);
|
|
329
|
+
if (toksWidth(toks) > colW[i])
|
|
330
|
+
s = truncateVis(s, colW[i]);
|
|
331
|
+
if (isHead)
|
|
332
|
+
s = BOLD + s + RESET;
|
|
333
|
+
const pad = colW[i] - Math.min(toksWidth(toks), colW[i]);
|
|
334
|
+
const a = aligns[i] ?? 'l';
|
|
335
|
+
if (a === 'r')
|
|
336
|
+
return ' ' + ' '.repeat(pad) + s + ' ';
|
|
337
|
+
if (a === 'c') {
|
|
338
|
+
const l = Math.floor(pad / 2);
|
|
339
|
+
return ' ' + ' '.repeat(l) + s + ' '.repeat(pad - l) + ' ';
|
|
340
|
+
}
|
|
341
|
+
return ' ' + s + ' '.repeat(pad) + ' ';
|
|
342
|
+
});
|
|
343
|
+
return DIM + '│' + RESET + parts.join(DIM + '│' + RESET) + DIM + '│' + RESET;
|
|
344
|
+
};
|
|
345
|
+
const out = [bar('┌', '┬', '┐'), rowLine(headToks, true), bar('├', '┼', '┤')];
|
|
346
|
+
for (const r of rowToks)
|
|
347
|
+
out.push(rowLine(r, false));
|
|
348
|
+
out.push(bar('└', '┴', '┘'));
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
const TASK_RE = /^\[( |x|X)\]\s+/;
|
|
352
|
+
function renderList(items, width) {
|
|
353
|
+
const out = [];
|
|
354
|
+
for (const it of items) {
|
|
355
|
+
const indent = ' '.repeat(it.level * 2);
|
|
356
|
+
const task = TASK_RE.exec(it.text);
|
|
357
|
+
const body = task ? it.text.slice(task[0].length) : it.text;
|
|
358
|
+
let marker;
|
|
359
|
+
let markerW;
|
|
360
|
+
if (task) {
|
|
361
|
+
const sym = task[1] === ' ' ? DIM + '☐' + RESET : GREEN + '☑' + RESET;
|
|
362
|
+
marker = sym + ' ';
|
|
363
|
+
markerW = 2;
|
|
364
|
+
}
|
|
365
|
+
else if (it.ordered) {
|
|
366
|
+
marker = it.num + '. ';
|
|
367
|
+
markerW = strWidth(it.num) + 2;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
marker = '• ';
|
|
371
|
+
markerW = 2;
|
|
372
|
+
}
|
|
373
|
+
const avail = Math.max(8, width - indent.length - markerW);
|
|
374
|
+
const wrapped = wrapToks(parseInline(body), avail, avail);
|
|
375
|
+
out.push(indent + marker + wrapped[0]);
|
|
376
|
+
for (let k = 1; k < wrapped.length; k++)
|
|
377
|
+
out.push(indent + ' '.repeat(markerW) + wrapped[k]);
|
|
378
|
+
}
|
|
379
|
+
return out;
|
|
380
|
+
}
|
|
381
|
+
/* ---------------- block scanner + main entry ---------------- */
|
|
382
|
+
const LIST_RE = /^(\s*)([-*+]|\d{1,9}[.)])\s+(.*)$/;
|
|
383
|
+
/** Render markdown text into styled terminal lines. One linear pass splits
|
|
384
|
+
* blocks; every block renderer is O(lines). Deterministic: same input and
|
|
385
|
+
* width always produce the same array (streaming repaint relies on it). */
|
|
386
|
+
export function renderMarkdown(text, width) {
|
|
387
|
+
const W = Math.max(8, width);
|
|
388
|
+
const src = text.replace(/\r\n?/g, '\n').split('\n');
|
|
389
|
+
const out = [];
|
|
390
|
+
let pendingGap = false;
|
|
391
|
+
let prevType = '';
|
|
392
|
+
const emit = (type, block) => {
|
|
393
|
+
// blank line between blocks: forced before headings (except the very
|
|
394
|
+
// first line), on source blank lines, and across block-type changes
|
|
395
|
+
if (out.length > 0 && out[out.length - 1] !== '' && (type === 'heading' || pendingGap || prevType !== type)) {
|
|
396
|
+
out.push('');
|
|
397
|
+
}
|
|
398
|
+
out.push(...block);
|
|
399
|
+
prevType = type;
|
|
400
|
+
pendingGap = false;
|
|
401
|
+
};
|
|
402
|
+
let i = 0;
|
|
403
|
+
while (i < src.length) {
|
|
404
|
+
const raw = src[i];
|
|
405
|
+
const t = raw.trim();
|
|
406
|
+
if (t === '') {
|
|
407
|
+
i++;
|
|
408
|
+
pendingGap = true;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const fence = /^(`{3,}|~{3,})(.*)$/.exec(t);
|
|
412
|
+
if (fence) {
|
|
413
|
+
const lang = fence[2].trim();
|
|
414
|
+
i++;
|
|
415
|
+
const code = [];
|
|
416
|
+
while (i < src.length && !/^(`{3,}|~{3,})\s*$/.test(src[i].trim())) {
|
|
417
|
+
code.push(src[i]);
|
|
418
|
+
i++;
|
|
419
|
+
}
|
|
420
|
+
if (i < src.length)
|
|
421
|
+
i++; // closing fence (absent while streaming: fine)
|
|
422
|
+
emit('code', renderCode(code, lang, W));
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
const h = /^(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/.exec(t);
|
|
426
|
+
if (h) {
|
|
427
|
+
emit('heading', renderHeading(h[1].length, h[2], W));
|
|
428
|
+
i++;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (t.includes('|') && i + 1 < src.length && isTableSepLine(src[i + 1])) {
|
|
432
|
+
const header = splitRow(raw);
|
|
433
|
+
const aligns = splitRow(src[i + 1]).map((c) => tableSepAlign(c) ?? 'l');
|
|
434
|
+
i += 2;
|
|
435
|
+
const rows = [];
|
|
436
|
+
while (i < src.length && src[i].trim() !== '' && src[i].includes('|')) {
|
|
437
|
+
rows.push(splitRow(src[i]));
|
|
438
|
+
i++;
|
|
439
|
+
}
|
|
440
|
+
emit('table', renderTable(header, aligns, rows, W));
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (/^([-*_])\1{2,}$/.test(t)) {
|
|
444
|
+
emit('hr', [DIM + '─'.repeat(W) + RESET]);
|
|
445
|
+
i++;
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (t.startsWith('>')) {
|
|
449
|
+
const contents = [];
|
|
450
|
+
while (i < src.length && src[i].trim().startsWith('>')) {
|
|
451
|
+
contents.push(src[i].trim().replace(/^>\s?/, '').trim());
|
|
452
|
+
i++;
|
|
453
|
+
}
|
|
454
|
+
emit('quote', renderQuote(contents, W));
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (LIST_RE.test(raw)) {
|
|
458
|
+
const items = [];
|
|
459
|
+
while (i < src.length && src[i].trim() !== '' && LIST_RE.test(src[i])) {
|
|
460
|
+
const m = LIST_RE.exec(src[i]);
|
|
461
|
+
items.push({
|
|
462
|
+
level: Math.floor(m[1].length / 2),
|
|
463
|
+
ordered: /^\d/.test(m[2]),
|
|
464
|
+
num: m[2].replace(/[.)]$/, ''),
|
|
465
|
+
text: m[3],
|
|
466
|
+
});
|
|
467
|
+
i++;
|
|
468
|
+
}
|
|
469
|
+
emit('list', renderList(items, W));
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
// paragraph: consecutive plain lines merge into one block (GFM soft
|
|
473
|
+
// breaks); the block reflows internally until a blank line closes it,
|
|
474
|
+
// and closed blocks above never change (streaming stability)
|
|
475
|
+
const paraLines = [t];
|
|
476
|
+
i++;
|
|
477
|
+
while (i < src.length && !paraBreak(src, i)) {
|
|
478
|
+
paraLines.push(src[i].trim());
|
|
479
|
+
i++;
|
|
480
|
+
}
|
|
481
|
+
emit('para', wrapToks(parseInline(paraLines.join(' ')), W, W));
|
|
482
|
+
}
|
|
483
|
+
return out;
|
|
484
|
+
}
|
|
485
|
+
/** true when lines[k] opens a new block (or is blank), ending the paragraph.
|
|
486
|
+
* Any pipe-bearing line breaks too: while streaming it may be the header of
|
|
487
|
+
* a table whose separator row has not arrived yet, so merging it into the
|
|
488
|
+
* surrounding prose would reflow that prose once the table closes. */
|
|
489
|
+
function paraBreak(lines, k) {
|
|
490
|
+
const s = lines[k];
|
|
491
|
+
const tt = s.trim();
|
|
492
|
+
if (tt === '')
|
|
493
|
+
return true;
|
|
494
|
+
if (/^(`{3,}|~{3,})/.test(tt) || /^#{1,6}\s/.test(tt) || tt.startsWith('>') || /^([-*_])\1{2,}$/.test(tt) || LIST_RE.test(s))
|
|
495
|
+
return true;
|
|
496
|
+
return tt.includes('|');
|
|
497
|
+
}
|
package/dist/tui.d.ts
CHANGED
|
@@ -255,6 +255,9 @@ export declare class TuiRuntime {
|
|
|
255
255
|
waitExit(): Promise<void>;
|
|
256
256
|
private quit;
|
|
257
257
|
addText(text: string, style?: 'dim' | 'plain' | 'err'): void;
|
|
258
|
+
/** Markdown-aware transcript text (resume/replay): the same renderer the
|
|
259
|
+
* live say stream uses, so replayed answers look like what was streamed. */
|
|
260
|
+
addMarkdown(text: string): void;
|
|
258
261
|
/** The user's own input, chat-style: separated by a blank line above and
|
|
259
262
|
* below, right-aligned to the terminal width so it reads as "the human
|
|
260
263
|
* side" against left-aligned model output. */
|
|
@@ -316,10 +319,6 @@ export declare class TuiRuntime {
|
|
|
316
319
|
/** Fold a settled tool call onto its start line and register it as a
|
|
317
320
|
* z-expandable cell (same cell semantics as addToolCell). */
|
|
318
321
|
settleToolCall(entry: Entry, folded: string, full: string): void;
|
|
319
|
-
/** Light zero-dep markdown line color for STREAMED text: headings cyan,
|
|
320
|
-
* list markers dim, fences dim, blockquotes dim; everything else plain.
|
|
321
|
-
* Applied per completed line so already-stable rows never reflow. */
|
|
322
|
-
static mdColor(line: string): string;
|
|
323
322
|
private overlayKey;
|
|
324
323
|
/** @-file palette (B2): opens/refreshes from the input's trailing @token. */
|
|
325
324
|
private refreshAtPal;
|
package/dist/tui.js
CHANGED
|
@@ -18,6 +18,7 @@ import { loadConfig, homeDir, resolveProvider, listProviders, saveProvider, setC
|
|
|
18
18
|
import { listDrafts, listSkills, runBench, runEvolution } from '@hmharness/evolution';
|
|
19
19
|
import { buildRegistry, runAgentTask, strings } from '@hmharness/agent';
|
|
20
20
|
import { ensureWebDaemon, DEFAULT_WEB_PORT } from "./web-daemon.js";
|
|
21
|
+
import { renderMarkdown } from "./markdown.js";
|
|
21
22
|
import { formatRow, initialPickerState, pickerKey, reducePicker, toolbarLine, visibleRows } from "./resume-picker.js";
|
|
22
23
|
import { savePending, loadPending, clearPending } from "./tui-state.js";
|
|
23
24
|
/** installed version, shown in the TUI header (v0.4.0) so users always
|
|
@@ -921,6 +922,14 @@ export class TuiRuntime {
|
|
|
921
922
|
this.scrollFromBottom = 0;
|
|
922
923
|
this.dirty = true;
|
|
923
924
|
}
|
|
925
|
+
/** Markdown-aware transcript text (resume/replay): the same renderer the
|
|
926
|
+
* live say stream uses, so replayed answers look like what was streamed. */
|
|
927
|
+
addMarkdown(text) {
|
|
928
|
+
const width = Math.max(20, (stdout.columns || 100) - 2);
|
|
929
|
+
this.entries.push({ lines: renderMarkdown(text, width) });
|
|
930
|
+
this.scrollFromBottom = 0;
|
|
931
|
+
this.dirty = true;
|
|
932
|
+
}
|
|
924
933
|
/** The user's own input, chat-style: separated by a blank line above and
|
|
925
934
|
* below, right-aligned to the terminal width so it reads as "the human
|
|
926
935
|
* side" against left-aligned model output. */
|
|
@@ -960,17 +969,20 @@ export class TuiRuntime {
|
|
|
960
969
|
const entry = { lines };
|
|
961
970
|
const repaint = () => {
|
|
962
971
|
if (kind === 'say') {
|
|
963
|
-
const wrapped = wrapTo(buf, width);
|
|
964
972
|
lines.length = 0;
|
|
965
|
-
//
|
|
966
|
-
//
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
973
|
+
// wave7-A: completed lines (up to the last \n) go through the real
|
|
974
|
+
// markdown renderer — headings lose their #, pipe tables become
|
|
975
|
+
// aligned box tables, ** becomes bold (Codex/Claude Code parity).
|
|
976
|
+
// The in-progress tail stays raw until its line completes. An
|
|
977
|
+
// unclosed fence/table may reflow as chunks arrive; closed blocks
|
|
978
|
+
// are pure functions of their text and never change.
|
|
979
|
+
const lastNl = buf.lastIndexOf('\n');
|
|
980
|
+
const done = lastNl >= 0 ? buf.slice(0, lastNl) : '';
|
|
981
|
+
const tail = lastNl >= 0 ? buf.slice(lastNl + 1) : buf;
|
|
982
|
+
if (done)
|
|
983
|
+
lines.push(...renderMarkdown(done, width));
|
|
984
|
+
if (tail)
|
|
985
|
+
lines.push(tail);
|
|
974
986
|
}
|
|
975
987
|
else {
|
|
976
988
|
// thinking stays FOLDED while streaming: one live line (what Claude
|
|
@@ -1202,22 +1214,9 @@ export class TuiRuntime {
|
|
|
1202
1214
|
this.toolCells.push({ entry, full, folded, expanded: false });
|
|
1203
1215
|
this.dirty = true;
|
|
1204
1216
|
}
|
|
1205
|
-
/*
|
|
1206
|
-
|
|
1207
|
-
*
|
|
1208
|
-
* Applied per completed line so already-stable rows never reflow. */
|
|
1209
|
-
static mdColor(line) {
|
|
1210
|
-
const t = line.trim();
|
|
1211
|
-
if (/^#{1,6}\s/.test(t))
|
|
1212
|
-
return CYAN(BOLD(line));
|
|
1213
|
-
if (/^```/.test(t))
|
|
1214
|
-
return DIM(line);
|
|
1215
|
-
if (/^>\s?/.test(t))
|
|
1216
|
-
return DIM(line);
|
|
1217
|
-
if (/^[-*+]\s/.test(t) || /^\d+[.)]\s/.test(t))
|
|
1218
|
-
return DIM(line.replace(/^(\s*[-*+]\s|\s*\d+[.)]\s)/, '$1'));
|
|
1219
|
-
return line;
|
|
1220
|
-
}
|
|
1217
|
+
/* streaming markdown coloring (old M4/B10 line colorizer) was replaced by
|
|
1218
|
+
* the block renderer in markdown.ts (wave7-A, 2026-10-29): the say stream
|
|
1219
|
+
* renders completed lines via renderMarkdown instead of tinting prefixes */
|
|
1221
1220
|
overlayKey(data) {
|
|
1222
1221
|
const ov = this.overlay;
|
|
1223
1222
|
if (!ov)
|
|
@@ -2496,8 +2495,10 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
2496
2495
|
}
|
|
2497
2496
|
else if (m.role === 'assistant') {
|
|
2498
2497
|
const calls = m.tool_calls ?? [];
|
|
2498
|
+
// rendered like the live say stream (wave7-A): headings/tables/lists
|
|
2499
|
+
// come back as terminal output, not raw markdown with pipes and hashes
|
|
2499
2500
|
if (text.trim())
|
|
2500
|
-
rt.
|
|
2501
|
+
rt.addMarkdown(text.slice(0, 2000));
|
|
2501
2502
|
for (const c of calls)
|
|
2502
2503
|
rt.addText('● ' + CYAN(String(c.function?.name ?? 'tool')) + DIM(' …'), 'dim');
|
|
2503
2504
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.45",
|
|
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",
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
"build": "tsc -p tsconfig.build.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@hmharness/agent": "0.23.
|
|
49
|
-
"@hmharness/browser": "0.23.
|
|
50
|
-
"@hmharness/cognitive": "0.23.
|
|
51
|
-
"@hmharness/domain-harmony": "0.23.
|
|
52
|
-
"@hmharness/domain-ops": "0.23.
|
|
53
|
-
"@hmharness/environments": "0.23.
|
|
54
|
-
"@hmharness/evaluation": "0.23.
|
|
55
|
-
"@hmharness/evolution": "0.23.
|
|
56
|
-
"@hmharness/extension": "0.23.
|
|
57
|
-
"@hmharness/kernel": "0.23.
|
|
58
|
-
"@hmharness/observability": "0.23.
|
|
59
|
-
"@hmharness/sandbox": "0.23.
|
|
60
|
-
"@hmharness/web": "0.23.
|
|
48
|
+
"@hmharness/agent": "0.23.45",
|
|
49
|
+
"@hmharness/browser": "0.23.45",
|
|
50
|
+
"@hmharness/cognitive": "0.23.45",
|
|
51
|
+
"@hmharness/domain-harmony": "0.23.45",
|
|
52
|
+
"@hmharness/domain-ops": "0.23.45",
|
|
53
|
+
"@hmharness/environments": "0.23.45",
|
|
54
|
+
"@hmharness/evaluation": "0.23.45",
|
|
55
|
+
"@hmharness/evolution": "0.23.45",
|
|
56
|
+
"@hmharness/extension": "0.23.45",
|
|
57
|
+
"@hmharness/kernel": "0.23.45",
|
|
58
|
+
"@hmharness/observability": "0.23.45",
|
|
59
|
+
"@hmharness/sandbox": "0.23.45",
|
|
60
|
+
"@hmharness/web": "0.23.45",
|
|
61
61
|
"qrcode": "^1.5.4",
|
|
62
|
-
"@hmharness/lsp": "0.23.
|
|
62
|
+
"@hmharness/lsp": "0.23.45"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/release-notes.json
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"notes": [
|
|
3
|
+
{
|
|
4
|
+
"v": "0.23.45",
|
|
5
|
+
"date": "2026-10-29",
|
|
6
|
+
"note": "测试诚实化双收官:server close 句柄排干(CI 假绿根修+5 潜伏缺陷+本机首次全绿)+clean-room 发版验真自动化(P0-2);1037 测试"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"v": "0.23.44",
|
|
10
|
+
"date": "2026-10-29",
|
|
11
|
+
"note": "结构化结论输出双修(TUI markdown 渲染器+Codex 式答复结构规范)+外部复现包 P2-1+web page.ts 拆分;1036 测试"
|
|
12
|
+
},
|
|
3
13
|
{
|
|
4
14
|
"v": "0.23.43",
|
|
5
15
|
"date": "2026-10-27",
|