@hmharness/cli 0.14.21 → 0.14.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/tui.d.ts +6 -0
- package/dist/tui.js +70 -8
- package/package.json +2 -2
package/dist/tui.d.ts
CHANGED
|
@@ -140,6 +140,10 @@ export declare class TuiRuntime {
|
|
|
140
140
|
/** bracketed-paste accumulator: non-null while the 201~ end marker has
|
|
141
141
|
* not arrived yet; everything buffered is literal insert-on-completion */
|
|
142
142
|
private pasteBuf;
|
|
143
|
+
/** restores the console methods and process handlers captured by the
|
|
144
|
+
* TUI's terminal ownership (see installConsoleRedirection) */
|
|
145
|
+
private restoreConsole;
|
|
146
|
+
private fatalHandler;
|
|
143
147
|
/** screen row of each visible palette item (SGR click hit-testing); the
|
|
144
148
|
* render loop records row = frame.length (1-based) as it pushes rows */
|
|
145
149
|
private paletteClickRows;
|
|
@@ -163,6 +167,8 @@ export declare class TuiRuntime {
|
|
|
163
167
|
/** last user-submitted line, for Esc-Esc edit-and-fork (T13) */
|
|
164
168
|
private lastUserMsg;
|
|
165
169
|
constructor();
|
|
170
|
+
/** Route console.* and fatal-process dumps into the transcript. */
|
|
171
|
+
private installConsoleRedirection;
|
|
166
172
|
setModelChoices(list: Array<{
|
|
167
173
|
name: string;
|
|
168
174
|
desc: string;
|
package/dist/tui.js
CHANGED
|
@@ -335,6 +335,10 @@ export class TuiRuntime {
|
|
|
335
335
|
/** bracketed-paste accumulator: non-null while the 201~ end marker has
|
|
336
336
|
* not arrived yet; everything buffered is literal insert-on-completion */
|
|
337
337
|
pasteBuf = null;
|
|
338
|
+
/** restores the console methods and process handlers captured by the
|
|
339
|
+
* TUI's terminal ownership (see installConsoleRedirection) */
|
|
340
|
+
restoreConsole = null;
|
|
341
|
+
fatalHandler = null;
|
|
338
342
|
/** screen row of each visible palette item (SGR click hit-testing); the
|
|
339
343
|
* render loop records row = frame.length (1-based) as it pushes rows */
|
|
340
344
|
paletteClickRows = [];
|
|
@@ -373,6 +377,35 @@ export class TuiRuntime {
|
|
|
373
377
|
stdin.on('data', (d) => this.onKey(d));
|
|
374
378
|
stdout.on('resize', () => { this.dirty = true; });
|
|
375
379
|
this.renderTimer = setInterval(() => this.render(), 90);
|
|
380
|
+
// The TUI owns the terminal while it runs (user-reported on host + every
|
|
381
|
+
// VM): stray console output - MCP attach notices, library warnings,
|
|
382
|
+
// provider retries - sprayed over the alternate screen and froze the
|
|
383
|
+
// picture (nothing marked the frame dirty) until a keypress repainted.
|
|
384
|
+
// Every console line now lands in the transcript instead, scrollable
|
|
385
|
+
// like any other output; restored in destroy().
|
|
386
|
+
this.installConsoleRedirection();
|
|
387
|
+
}
|
|
388
|
+
/** Route console.* and fatal-process dumps into the transcript. */
|
|
389
|
+
installConsoleRedirection() {
|
|
390
|
+
const fmt = (a) => a.map((x) => (typeof x === 'string' ? x : JSON.stringify(x, null, 0) ?? String(x))).join(' ');
|
|
391
|
+
const prev = {
|
|
392
|
+
log: console.log.bind(console),
|
|
393
|
+
info: console.info.bind(console),
|
|
394
|
+
warn: console.warn.bind(console),
|
|
395
|
+
error: console.error.bind(console),
|
|
396
|
+
debug: console.debug.bind(console),
|
|
397
|
+
};
|
|
398
|
+
this.restoreConsole = () => { console.log = prev.log; console.info = prev.info; console.warn = prev.warn; console.error = prev.error; console.debug = prev.debug; };
|
|
399
|
+
console.log = (...a) => { this.addText(fmt(a).trim(), 'dim'); };
|
|
400
|
+
console.info = (...a) => { this.addText(fmt(a).trim(), 'dim'); };
|
|
401
|
+
console.debug = (...a) => { this.addText(fmt(a).trim(), 'dim'); };
|
|
402
|
+
console.warn = (...a) => { this.addText(fmt(a), 'err'); };
|
|
403
|
+
console.error = (...a) => { this.addText(fmt(a), 'err'); };
|
|
404
|
+
// Node's default dump for these would tear up the alternate screen too
|
|
405
|
+
this.fatalHandler = (err) => { this.addText('process: ' + String(err).slice(0, 500), 'err'); };
|
|
406
|
+
process.on('unhandledRejection', this.fatalHandler);
|
|
407
|
+
process.on('uncaughtException', this.fatalHandler);
|
|
408
|
+
process.on('warning', this.fatalHandler);
|
|
376
409
|
}
|
|
377
410
|
setModelChoices(list) {
|
|
378
411
|
this.modelChoices = list;
|
|
@@ -667,6 +700,12 @@ export class TuiRuntime {
|
|
|
667
700
|
// ?1l restores default CSI cursor keys; reporting off whatever the
|
|
668
701
|
// modal state was
|
|
669
702
|
stdout.write((this.mouseReported ? '\x1b[?1000l\x1b[?1006l' : '') + '\x1b[?2004l\x1b[?1007l' + '\x1b[?1l\x1b[?25h\x1b[?1049l');
|
|
703
|
+
this.restoreConsole?.();
|
|
704
|
+
if (this.fatalHandler) {
|
|
705
|
+
process.off('unhandledRejection', this.fatalHandler);
|
|
706
|
+
process.off('uncaughtException', this.fatalHandler);
|
|
707
|
+
process.off('warning', this.fatalHandler);
|
|
708
|
+
}
|
|
670
709
|
stdin.setRawMode?.(false);
|
|
671
710
|
stdin.pause();
|
|
672
711
|
}
|
|
@@ -697,10 +736,20 @@ export class TuiRuntime {
|
|
|
697
736
|
addUser(text) {
|
|
698
737
|
const width = Math.max(20, (stdout.columns || 100) - 2);
|
|
699
738
|
const lines = [''];
|
|
700
|
-
|
|
739
|
+
const wrapped = wrapTo(text.replace(/\n+/g, ' '), width);
|
|
740
|
+
// long prompts fold to two lines + a count marker (user ask 2026-09-21:
|
|
741
|
+
// a pasted prompt used to eat half the screen); the driver archives the
|
|
742
|
+
// full text into the Ctrl+T replay so nothing is lost
|
|
743
|
+
const shown = wrapped.length > 2 ? wrapped.slice(0, 2) : wrapped;
|
|
744
|
+
for (const l of shown) {
|
|
701
745
|
const pad = Math.max(1, width - strWidth(l));
|
|
702
746
|
lines.push(' '.repeat(pad) + BOLD(l));
|
|
703
747
|
}
|
|
748
|
+
if (wrapped.length > 2) {
|
|
749
|
+
const note = this.t.tuiUserFolded(wrapped.length - 2);
|
|
750
|
+
const pad = Math.max(1, width - strWidth(note));
|
|
751
|
+
lines.push(' '.repeat(pad) + DIM(note));
|
|
752
|
+
}
|
|
704
753
|
lines.push('');
|
|
705
754
|
this.entries.push({ lines });
|
|
706
755
|
this.scrollFromBottom = 0;
|
|
@@ -1943,6 +1992,9 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1943
1992
|
}
|
|
1944
1993
|
async function runSingleTask(line, forkFrom, forkResume) {
|
|
1945
1994
|
rt.addUser(line);
|
|
1995
|
+
// the folded echo hides everything past line 2 - keep the full prompt
|
|
1996
|
+
// retrievable in the Ctrl+T replay
|
|
1997
|
+
fullToolLog.push({ name: 'user', output: line.slice(0, 4000) });
|
|
1946
1998
|
rt.setBusy(true, t.running);
|
|
1947
1999
|
currentAbort = new AbortController();
|
|
1948
2000
|
const injectCh = { queue: [], active: false };
|
|
@@ -1953,6 +2005,10 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1953
2005
|
: [];
|
|
1954
2006
|
const resumeBase = [...planDirective, ...(forkResume ?? history)];
|
|
1955
2007
|
let appender = null;
|
|
2008
|
+
let reasoningBuf = '';
|
|
2009
|
+
const foldThinking = () => { if (reasoningBuf.trim()) {
|
|
2010
|
+
fullToolLog.push({ name: 'thinking', output: reasoningBuf.slice(0, 8000) });
|
|
2011
|
+
} reasoningBuf = ''; rt.foldThinking(); };
|
|
1956
2012
|
let kind = null;
|
|
1957
2013
|
try {
|
|
1958
2014
|
const result = await runAgentTask({
|
|
@@ -1971,8 +2027,10 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1971
2027
|
approvalAsk: (name, args) => rt.requestApproval(name, args),
|
|
1972
2028
|
events: {
|
|
1973
2029
|
onLine: (l) => { if (kind === 'reasoning')
|
|
1974
|
-
|
|
2030
|
+
foldThinking(); appender = null; kind = null; rt.addText(l, 'dim'); },
|
|
1975
2031
|
onDelta: (k, chunk) => {
|
|
2032
|
+
if (k === 'reasoning')
|
|
2033
|
+
reasoningBuf += chunk;
|
|
1976
2034
|
if (k === 'reset') {
|
|
1977
2035
|
// provider retry after a mid-stream cut: drop the half answer
|
|
1978
2036
|
appender?.drop?.();
|
|
@@ -1982,7 +2040,7 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1982
2040
|
}
|
|
1983
2041
|
if (k !== kind) {
|
|
1984
2042
|
if (kind === 'reasoning')
|
|
1985
|
-
|
|
2043
|
+
foldThinking();
|
|
1986
2044
|
appender = rt.startStream(k === 'reasoning' ? 'think' : 'say');
|
|
1987
2045
|
kind = k;
|
|
1988
2046
|
}
|
|
@@ -1990,7 +2048,7 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1990
2048
|
},
|
|
1991
2049
|
onToolCall: (name, args) => {
|
|
1992
2050
|
if (kind === 'reasoning')
|
|
1993
|
-
|
|
2051
|
+
foldThinking();
|
|
1994
2052
|
appender = null;
|
|
1995
2053
|
kind = null;
|
|
1996
2054
|
const brief = name === 'run_command' && typeof args.command === 'string'
|
|
@@ -2004,10 +2062,14 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
2004
2062
|
// M4 B8: tool call + result = one collapsible cell (folded summary
|
|
2005
2063
|
// by default; `z` with an empty input expands the last one)
|
|
2006
2064
|
rt.addToolCell(` ${dot} ${CYAN(name)} ${DIM('⎿ ' + first.trim().slice(0, 100))}`, output);
|
|
2007
|
-
// M4 B9: outputs
|
|
2008
|
-
//
|
|
2009
|
-
|
|
2010
|
-
|
|
2065
|
+
// M4 B9 (T18 复案 2026-09-21): outputs beyond a screen NO LONGER
|
|
2066
|
+
// auto-open the full-screen pager - on every system it read as a
|
|
2067
|
+
// break-in (a wall of raw output hijacking the screen while the
|
|
2068
|
+
// task ran on underneath, 'frozen' until Esc). The folded cell
|
|
2069
|
+
// plus this hint line keep the escape hatches visible instead.
|
|
2070
|
+
const outLines = output.split('\n').length;
|
|
2071
|
+
if (outLines > 2 * Math.max(20, (stdout.rows || 30))) {
|
|
2072
|
+
rt.addText(' ' + DIM(t.tuiLongOutputHint(name, outLines)), 'plain');
|
|
2011
2073
|
}
|
|
2012
2074
|
// retain the FULL output for the Ctrl+T transcript overlay (B5);
|
|
2013
2075
|
// the transcript itself keeps only the folded first line
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.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",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@hmharness/evolution": "0.14.15",
|
|
49
49
|
"@hmharness/domain-harmony": "0.13.6",
|
|
50
50
|
"@hmharness/domain-ops": "0.8.1",
|
|
51
|
-
"@hmharness/agent": "0.14.
|
|
51
|
+
"@hmharness/agent": "0.14.13",
|
|
52
52
|
"@hmharness/evaluation": "0.8.0",
|
|
53
53
|
"@hmharness/web": "0.9.2"
|
|
54
54
|
}
|