@hmharness/cli 0.18.8 → 0.18.9

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.
Files changed (3) hide show
  1. package/dist/tui.d.ts +12 -52
  2. package/dist/tui.js +33 -155
  3. package/package.json +2 -2
package/dist/tui.d.ts CHANGED
@@ -52,21 +52,6 @@ export declare function renderStatusline(template: string, ctx: {
52
52
  export declare function parseKeySpec(spec: string): string | null;
53
53
  /** The remappable M2/M4 actions and their defaults (B14). */
54
54
  export declare const KEYMAP_DEFAULTS: Record<string, string>;
55
- /**
56
- * SGR mouse wheel decoding: '\x1b[<64;COL;ROWM' is wheel-up (-1), 65 is
57
- * wheel-down (+1), anything else (clicks, drags, plain keys) is 0.
58
- */
59
- export declare function parseWheel(data: string): number;
60
- /**
61
- * SGR reports can split across stdin chunks (fast wheel bursts fragment in
62
- * some terminals). If the buffer ends inside a report - a trailing
63
- * '\x1b[<...' with no terminating M/m yet - slice it off as `pending` for
64
- * the next chunk and hand back only the complete part.
65
- */
66
- export declare function splitMouseReport(data: string): {
67
- data: string;
68
- pending: string;
69
- };
70
55
  /**
71
56
  * Bracketed-paste body cleanup: strip the 200~/201~ markers and any escape
72
57
  * sequences (pasted terminal controls must not leak into the input line),
@@ -129,23 +114,15 @@ export declare class TuiRuntime {
129
114
  setModes(yolo: boolean, plan?: boolean): void;
130
115
  /** rows for the `/model ` picker (configured providers first, set by driver) */
131
116
  private modelChoices;
132
- /** Wheel/click handling (T23, settled design): capture (?1000h+?1006h)
133
- * is OFF by default - click-drag must stay the terminal's NATIVE
134
- * selection, always-on capture took that away on every system. The
135
- * wheel is covered by ?1007 (alternate scroll, enabled at startup):
136
- * the terminal itself translates wheel -> arrow keys without touching
137
- * clicks, and the existing arrow path scrolls the transcript. Capture
138
- * turns on only while a palette is open (clicks choose rows, wheel
139
- * drives selection) or when the user forces it with /mouse for
140
- * terminals that honour neither wheel translation nor ?1007 (legacy
141
- * conhost); Shift+drag still selects on mainstream terminals then. */
142
- private mouseReported;
143
- /** /mouse force flag (persisted as config.json tui.mouse): full-time
144
- * capture for terminals without any wheel translation */
145
- private forceMouse;
146
- /** tail of an SGR mouse report split across stdin chunks (fast wheel
147
- * bursts); prepended to the next chunk so parseWheel sees the sequence */
148
- private mousePending;
117
+ /** Mouse handling (2026-09-26, T24 FINAL - the /mouse saga ends here):
118
+ * the app NEVER turns on mouse capture. The wheel scrolls through the
119
+ * terminal's own ?1007 alternate-scroll translation (enabled at startup,
120
+ * sent with the alt-screen enter sequence) which reports wheel events as
121
+ * plain arrow keys - the existing arrow path scrolls the transcript, and
122
+ * inside an open palette the arrows drive the selection. Click-drag
123
+ * selection/copy stays 100% native at all times, on every system, because
124
+ * there is simply no capture to escape from. The old escape hatches
125
+ * (full-time capture via /mouse, Shift+drag, palette SGR clicks) are gone. */
149
126
  /** bracketed-paste accumulator: non-null while the 201~ end marker has
150
127
  * not arrived yet; everything buffered is literal insert-on-completion */
151
128
  private pasteBuf;
@@ -153,9 +130,6 @@ export declare class TuiRuntime {
153
130
  * TUI's terminal ownership (see installConsoleRedirection) */
154
131
  private restoreConsole;
155
132
  private fatalHandler;
156
- /** screen row of each visible palette item (SGR click hit-testing); the
157
- * render loop records row = frame.length (1-based) as it pushes rows */
158
- private paletteClickRows;
159
133
  /** Ctrl+R incremental history search: { query, matches (history indices), sel } */
160
134
  private histSearch;
161
135
  /** Ctrl+T full-transcript overlay (also the pager base for B9): title + lines + viewport top */
@@ -215,36 +189,22 @@ export declare class TuiRuntime {
215
189
  * with no palette open it just submits the typed input. */
216
190
  private pickHighlighted;
217
191
  /** Introspection probe for headless tests: input line, palette rows, the
218
- * highlighted row index, mouse-reporting state, clickable rows, the
219
- * transcript text, and the last rendered frame (ANSI-stripped). */
192
+ * highlighted row index, the transcript text, and the last rendered
193
+ * frame (ANSI-stripped). */
220
194
  paletteProbe(): {
221
195
  input: string;
222
196
  rows: string[];
223
197
  selected: number;
224
- mouse: boolean;
225
- clickRows: Array<{
226
- row: number;
227
- idx: number;
228
- }>;
229
198
  transcript: string;
230
199
  frameText: string;
231
200
  };
232
201
  /** Legacy single-tag setter kept for compatibility; new code uses
233
202
  * setModes(yolo, plan) which composes the full always-visible badge. */
234
203
  setModeTag(tag: string): void;
235
- /** Capture is on ONLY while a palette is open or /mouse forced it -
236
- * native selection must stay native everywhere else; ?1007 covers
237
- * the wheel without any capture (T23). */
238
- private syncMouseReporting;
239
- /** /mouse (T23): force full-time capture for terminals that honour
240
- * neither wheel->arrow translation nor ?1007. While forced, Shift+drag
241
- * is the mainstream-terminal escape hatch back to selection. */
242
- setMouseForced(on: boolean): void;
243
- isMouseForced(): boolean;
244
204
  /** The palette data source: `/model ` opens the model picker, otherwise
245
205
  * slash commands. (/resume submits straight through to the driver, which
246
206
  * opens the Codex-style full-frame picker - resume-picker.ts.) Rows are
247
- * {name, desc} so both share one renderer, keyboard and click machinery. */
207
+ * {name, desc} so both share one renderer and keyboard machinery. */
248
208
  private panelItems;
249
209
  configure(model: string, cwdName: string, skillCount: number, locale: Locale, version?: string): void;
250
210
  destroy(): void;
package/dist/tui.js CHANGED
@@ -113,7 +113,6 @@ export const COMMANDS = [
113
113
  { name: '/fork', key: 'cmdFork' },
114
114
  { name: '/copy', key: 'cmdCopy' },
115
115
  { name: '/export', key: 'cmdExport' },
116
- { name: '/mouse', key: 'cmdMouse' },
117
116
  { name: '/plan', key: 'cmdPlan' },
118
117
  { name: '/goal', key: 'cmdGoal' },
119
118
  { name: '/usage', key: 'cmdUsage' },
@@ -216,36 +215,11 @@ export const KEYMAP_DEFAULTS = {
216
215
  transcript: '\x14', // T15: Ctrl+T
217
216
  externalEdit: '\x07', // B12: Ctrl+G
218
217
  };
219
- /**
220
- * SGR mouse wheel decoding: '\x1b[<64;COL;ROWM' is wheel-up (-1), 65 is
221
- * wheel-down (+1), anything else (clicks, drags, plain keys) is 0.
222
- */
223
- export function parseWheel(data) {
224
- const m = data.match(/^\x1b\[<(\d+);\d+;\d+[Mm]/);
225
- if (!m)
226
- return 0;
227
- const btn = Number(m[1]);
228
- if (btn === 64)
229
- return -1;
230
- if (btn === 65)
231
- return 1;
232
- return 0;
233
- }
234
- /**
235
- * SGR reports can split across stdin chunks (fast wheel bursts fragment in
236
- * some terminals). If the buffer ends inside a report - a trailing
237
- * '\x1b[<...' with no terminating M/m yet - slice it off as `pending` for
238
- * the next chunk and hand back only the complete part.
239
- */
240
- export function splitMouseReport(data) {
241
- const cut = data.lastIndexOf('\x1b[<');
242
- if (cut === -1)
243
- return { data, pending: '' };
244
- const tail = data.slice(cut);
245
- return /^\x1b\[<\d+(;\d+)*[Mm]$/.test(tail)
246
- ? { data, pending: '' }
247
- : { data: data.slice(0, cut), pending: tail };
248
- }
218
+ // T24 (2026-09-26): parseWheel/splitMouseReport and every SGR-capture path
219
+ // were REMOVED - the app never enables mouse reporting. The wheel works via
220
+ // the terminal's ?1007 alternate-scroll translation (arrow keys), selection
221
+ // and copy are always native. Do not reintroduce capture modes here; the
222
+ // T21->T23 history showed each one cost native selection somewhere.
249
223
  /**
250
224
  * Bracketed-paste body cleanup: strip the 200~/201~ markers and any escape
251
225
  * sequences (pasted terminal controls must not leak into the input line),
@@ -330,23 +304,15 @@ export class TuiRuntime {
330
304
  }
331
305
  /** rows for the `/model ` picker (configured providers first, set by driver) */
332
306
  modelChoices = [];
333
- /** Wheel/click handling (T23, settled design): capture (?1000h+?1006h)
334
- * is OFF by default - click-drag must stay the terminal's NATIVE
335
- * selection, always-on capture took that away on every system. The
336
- * wheel is covered by ?1007 (alternate scroll, enabled at startup):
337
- * the terminal itself translates wheel -> arrow keys without touching
338
- * clicks, and the existing arrow path scrolls the transcript. Capture
339
- * turns on only while a palette is open (clicks choose rows, wheel
340
- * drives selection) or when the user forces it with /mouse for
341
- * terminals that honour neither wheel translation nor ?1007 (legacy
342
- * conhost); Shift+drag still selects on mainstream terminals then. */
343
- mouseReported = false;
344
- /** /mouse force flag (persisted as config.json tui.mouse): full-time
345
- * capture for terminals without any wheel translation */
346
- forceMouse = false;
347
- /** tail of an SGR mouse report split across stdin chunks (fast wheel
348
- * bursts); prepended to the next chunk so parseWheel sees the sequence */
349
- mousePending = '';
307
+ /** Mouse handling (2026-09-26, T24 FINAL - the /mouse saga ends here):
308
+ * the app NEVER turns on mouse capture. The wheel scrolls through the
309
+ * terminal's own ?1007 alternate-scroll translation (enabled at startup,
310
+ * sent with the alt-screen enter sequence) which reports wheel events as
311
+ * plain arrow keys - the existing arrow path scrolls the transcript, and
312
+ * inside an open palette the arrows drive the selection. Click-drag
313
+ * selection/copy stays 100% native at all times, on every system, because
314
+ * there is simply no capture to escape from. The old escape hatches
315
+ * (full-time capture via /mouse, Shift+drag, palette SGR clicks) are gone. */
350
316
  /** bracketed-paste accumulator: non-null while the 201~ end marker has
351
317
  * not arrived yet; everything buffered is literal insert-on-completion */
352
318
  pasteBuf = null;
@@ -354,9 +320,6 @@ export class TuiRuntime {
354
320
  * TUI's terminal ownership (see installConsoleRedirection) */
355
321
  restoreConsole = null;
356
322
  fatalHandler = null;
357
- /** screen row of each visible palette item (SGR click hit-testing); the
358
- * render loop records row = frame.length (1-based) as it pushes rows */
359
- paletteClickRows = [];
360
323
  /* ---------------- M2: runtime steering modals (codex parity) ---------------- */
361
324
  /** Ctrl+R incremental history search: { query, matches (history indices), sel } */
362
325
  histSearch = null;
@@ -617,8 +580,8 @@ export class TuiRuntime {
617
580
  this.driver?.();
618
581
  }
619
582
  /** Introspection probe for headless tests: input line, palette rows, the
620
- * highlighted row index, mouse-reporting state, clickable rows, the
621
- * transcript text, and the last rendered frame (ANSI-stripped). */
583
+ * highlighted row index, the transcript text, and the last rendered
584
+ * frame (ANSI-stripped). */
622
585
  paletteProbe() {
623
586
  const rows = this.panelItems(this.input);
624
587
  const lines = [];
@@ -640,8 +603,6 @@ export class TuiRuntime {
640
603
  input: this.input,
641
604
  rows: rows.map((r) => r.name),
642
605
  selected: rows.length ? Math.min(this.cmdIdx, rows.length - 1) : -1,
643
- mouse: this.mouseReported,
644
- clickRows: this.paletteClickRows.map((p) => ({ ...p })),
645
606
  transcript: lines.join('\n'),
646
607
  // frame rows: split on the CUP positioning pairs, take the content
647
608
  // halves by parity, strip ANSI. (A 'startsWith ESC' filter used to
@@ -664,31 +625,10 @@ export class TuiRuntime {
664
625
  this.modeTag = tag;
665
626
  this.dirty = true;
666
627
  }
667
- /** Capture is on ONLY while a palette is open or /mouse forced it -
668
- * native selection must stay native everywhere else; ?1007 covers
669
- * the wheel without any capture (T23). */
670
- syncMouseReporting() {
671
- const want = this.forceMouse || this.panelItems(this.input).length > 0;
672
- if (want === this.mouseReported)
673
- return;
674
- this.mouseReported = want;
675
- stdout.write(want ? '\x1b[?1000h\x1b[?1006h' : '\x1b[?1000l\x1b[?1006l');
676
- }
677
- /** /mouse (T23): force full-time capture for terminals that honour
678
- * neither wheel->arrow translation nor ?1007. While forced, Shift+drag
679
- * is the mainstream-terminal escape hatch back to selection. */
680
- setMouseForced(on) {
681
- this.forceMouse = on;
682
- this.syncMouseReporting();
683
- this.dirty = true;
684
- }
685
- isMouseForced() {
686
- return this.forceMouse;
687
- }
688
628
  /** The palette data source: `/model ` opens the model picker, otherwise
689
629
  * slash commands. (/resume submits straight through to the driver, which
690
630
  * opens the Codex-style full-frame picker - resume-picker.ts.) Rows are
691
- * {name, desc} so both share one renderer, keyboard and click machinery. */
631
+ * {name, desc} so both share one renderer and keyboard machinery. */
692
632
  panelItems(input) {
693
633
  if (input === '/model' || input.startsWith('/model ')) {
694
634
  const q = input.slice(6).trim().toLowerCase();
@@ -716,7 +656,9 @@ export class TuiRuntime {
716
656
  clearInterval(this.spinnerTimer);
717
657
  // ?1l restores default CSI cursor keys; reporting off whatever the
718
658
  // modal state was
719
- stdout.write((this.mouseReported ? '\x1b[?1000l\x1b[?1006l' : '') + '\x1b[?2004l\x1b[?1007l' + '\x1b[?1l\x1b[?25h\x1b[?1049l');
659
+ // T24: capture is never enabled; reset any reporting mode unconditionally
660
+ // on exit (defensive - covers a stray enable from an older version)
661
+ stdout.write('\x1b[?1000l\x1b[?1006l\x1b[?2004l\x1b[?1007l\x1b[?1l\x1b[?25h\x1b[?1049l');
720
662
  this.restoreConsole?.();
721
663
  if (this.fatalHandler) {
722
664
  process.off('unhandledRejection', this.fatalHandler);
@@ -1206,18 +1148,6 @@ export class TuiRuntime {
1206
1148
  return n;
1207
1149
  }
1208
1150
  onKey(data) {
1209
- // reassemble an SGR mouse report that arrived split across stdin chunks
1210
- // (fast wheel bursts fragment in some terminals) before anything parses
1211
- if (this.mousePending) {
1212
- data = this.mousePending + data;
1213
- this.mousePending = '';
1214
- }
1215
- const split = splitMouseReport(data);
1216
- if (split.pending)
1217
- this.mousePending = split.pending;
1218
- if (!split.data)
1219
- return;
1220
- data = split.data;
1221
1151
  // bracketed paste (T22): buffer until the 201~ end marker, then insert
1222
1152
  // the sanitized body at the caret; keys/bytes outside the markers keep
1223
1153
  // flowing through the normal path (recursion depth stays 1: indexOf
@@ -1260,11 +1190,10 @@ export class TuiRuntime {
1260
1190
  // matches so navigation never silently dies
1261
1191
  if (/^\x1bO[A-H]$/.test(data))
1262
1192
  data = '\x1b[' + data[2];
1263
- // resume picker modal owns every event while open - keyboard AND wheel
1264
- // (codex: the picker runs its own event loop until it resolves)
1193
+ // resume picker modal owns every event while open (codex: the picker
1194
+ // runs its own event loop until it resolves)
1265
1195
  if (this.resumeModal) {
1266
- const wheel = parseWheel(data);
1267
- const key = wheel !== 0 ? (wheel < 0 ? 'up' : 'down') : pickerKey(data);
1196
+ const key = pickerKey(data);
1268
1197
  if (key !== null)
1269
1198
  this.pickerInput(key);
1270
1199
  return;
@@ -1283,43 +1212,9 @@ export class TuiRuntime {
1283
1212
  this.atPalKey(data);
1284
1213
  return;
1285
1214
  }
1286
- // wheel-only mouse routing: 64 = wheel-up, 65 = wheel-down. Reporting
1287
- // is always on, so every other report - click, drag, release - is just
1288
- // swallowed below; the terminal's Shift+click native selection bypasses
1289
- // the app entirely and keeps working.
1290
- const wheel = parseWheel(data);
1291
- if (wheel !== 0) {
1292
- // an open palette takes the wheel: it moves the selection (the list
1293
- // is what the user is driving), the transcript only scrolls when the
1294
- // palette is closed
1295
- const hits = this.panelItems(this.input);
1296
- if (hits.length) {
1297
- this.cmdIdx = Math.max(0, Math.min(hits.length - 1, this.cmdIdx + wheel));
1298
- this.dirty = true;
1299
- return;
1300
- }
1301
- // wheel-up (-1) moves the viewport UP, i.e. further from the bottom
1302
- this.scrollFromBottom = Math.max(0, Math.min(this.totalLines(), this.scrollFromBottom - wheel * 3));
1303
- this.dirty = true;
1304
- return;
1305
- }
1306
- // click-to-choose on the open palette (SGR button-0 press): the
1307
- // terminal-reported row maps 1:1 to the screen row render() recorded
1308
- // for that item, so a click is a row selection + confirm
1309
- if (this.paletteClickRows.length) {
1310
- const click = data.match(/^\x1b\[<0;\d+;(\d+)M$/);
1311
- if (click) {
1312
- const row = Number(click[1]);
1313
- const hitRow = this.paletteClickRows.find((p) => p.row === row);
1314
- if (hitRow) {
1315
- this.cmdIdx = hitRow.idx;
1316
- this.pickHighlighted();
1317
- return;
1318
- }
1319
- }
1320
- }
1321
- // swallow any other SGR mouse report that slips through so it never
1322
- // leaks into the input line as garbage
1215
+ // T24: capture is never enabled, so SGR reports cannot legitimately
1216
+ // arrive - swallow the pattern anyway so a stray report from a weird
1217
+ // terminal never leaks into the input line as garbage
1323
1218
  if (/^\x1b\[<\d+;\d+;\d+[Mm]/.test(data))
1324
1219
  return;
1325
1220
  if (this.approval) {
@@ -1606,10 +1501,6 @@ export class TuiRuntime {
1606
1501
  this.flushFrame(frame, H);
1607
1502
  return;
1608
1503
  }
1609
- // capture follows palette/force state (see syncMouseReporting, T23);
1610
- // click rows are re-recorded every frame because screen positions move
1611
- this.syncMouseReporting();
1612
- this.paletteClickRows.length = 0;
1613
1504
  const spin = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'[this.spinnerFrame] ?? ' ';
1614
1505
  // Header = pure identity strip: logo · model · cwd · skills (+ mode tag
1615
1506
  // when set). NO status word up here at all (T1-v2, design-revised: the
@@ -1673,10 +1564,6 @@ export class TuiRuntime {
1673
1564
  const c = cmdHits[gi];
1674
1565
  const sel = gi === this.cmdIdx;
1675
1566
  frame.push(truncateTo((sel ? '› ' : ' ') + (sel ? CYAN(c.name) : DIM(c.name)) + ' ' + DIM(truncateTo(c.desc, 46)), W - 1));
1676
- // row lands at screen line frame.length (render addresses rows
1677
- // 1-based); only rows that survive the H clip are clickable
1678
- if (frame.length <= H)
1679
- this.paletteClickRows.push({ row: frame.length, idx: gi });
1680
1567
  }
1681
1568
  frame.push(DIM(truncateTo(' ' + this.t.panelHint, W - 1)));
1682
1569
  }
@@ -2022,10 +1909,9 @@ export async function tui(yes, noWeb = false, opts = {}) {
2022
1909
  }
2023
1910
  };
2024
1911
  applyStatusline();
2025
- // T23: persisted /mouse force (config.json tui.mouse) - for terminals
2026
- // that honour neither wheel->arrow translation nor ?1007
2027
- if (cfg.tui?.mouse)
2028
- rt.setMouseForced(true);
1912
+ // T24: config.json tui.mouse is intentionally IGNORED now - the permanent
1913
+ // scheme (?1007 wheel + native selection) has no modes. Leftover values
1914
+ // from older versions are harmless residue.
2029
1915
  // Ctrl+T overlay source: transcript + FULL (folded-away) tool outputs (B5)
2030
1916
  rt.setOverlaySource(() => {
2031
1917
  const out = [];
@@ -2381,18 +2267,10 @@ export async function tui(yes, noWeb = false, opts = {}) {
2381
2267
  return;
2382
2268
  }
2383
2269
  if (line === '/mouse') {
2384
- // T23: full-time capture toggle for terminals without wheel
2385
- // translation (?1007 already covers the wheel on mainstream ones);
2386
- // while forced, Shift+drag is the selection escape hatch
2387
- const next = !rt.isMouseForced();
2388
- rt.setMouseForced(next);
2389
- try {
2390
- const { patchConfig } = await import('@hmharness/kernel');
2391
- const merged = { ...(cfg.tui ?? {}), mouse: next };
2392
- cfg = await patchConfig({ tui: merged });
2393
- }
2394
- catch { /* runtime toggle applied even when persisting fails */ }
2395
- rt.addText(next ? t.cmdMouseOn : t.cmdMouseOff, 'plain');
2270
+ // T24 (2026-09-26): the toggle is GONE - the permanent scheme (wheel
2271
+ // via ?1007 translation + always-native selection) needs no modes.
2272
+ // Tell any muscle memory clearly instead of silently failing.
2273
+ rt.addText(t.cmdMouseRemoved, 'plain');
2396
2274
  return;
2397
2275
  }
2398
2276
  if (line === '/plan' || line.startsWith('/plan ')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.18.8",
3
+ "version": "0.18.9",
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": "*",
49
49
  "@hmharness/domain-harmony": "*",
50
50
  "@hmharness/domain-ops": "*",
51
- "@hmharness/agent": "0.14.21",
51
+ "@hmharness/agent": "0.14.22",
52
52
  "@hmharness/evaluation": "*",
53
53
  "@hmharness/web": "*",
54
54
  "@hmharness/sandbox": "*"