@hmharness/cli 0.18.3 → 0.18.4

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 CHANGED
@@ -1,5 +1,8 @@
1
1
  import { type SessionSummary } from '@hmharness/kernel';
2
2
  import { type Locale } from '@hmharness/agent';
3
+ interface Entry {
4
+ lines: string[];
5
+ }
3
6
  /** desc keys index into Strings (agent i18n); matched by name at runtime. */
4
7
  export declare const COMMANDS: Array<{
5
8
  name: string;
@@ -292,6 +295,15 @@ export declare class TuiRuntime {
292
295
  * LAST cell to its full output. */
293
296
  addToolCell(folded: string, full: string): void;
294
297
  toggleLastCell(): boolean;
298
+ /** In-progress tool call: ONE line that the result later REPLACES in
299
+ * place (2026-09-25 user request: consecutive tool calls used to cost
300
+ * two transcript lines each - the `● name args` line plus the folded
301
+ * `⎿ result` line - and a run of ten calls buried the conversation).
302
+ * Returns the mutable entry so settleToolCall() can swap it. */
303
+ startToolCall(display: string): Entry;
304
+ /** Fold a settled tool call onto its start line and register it as a
305
+ * z-expandable cell (same cell semantics as addToolCell). */
306
+ settleToolCall(entry: Entry, folded: string, full: string): void;
295
307
  /** Light zero-dep markdown line color for STREAMED text: headings cyan,
296
308
  * list markers dim, fences dim, blockquotes dim; everything else plain.
297
309
  * Applied per completed line so already-stable rows never reflow. */
@@ -313,3 +325,4 @@ export declare class TuiRuntime {
313
325
  export declare function tui(yes: boolean, noWeb?: boolean, opts?: {
314
326
  resumeAtStart?: boolean;
315
327
  }): Promise<void>;
328
+ export {};
package/dist/tui.js CHANGED
@@ -991,6 +991,27 @@ export class TuiRuntime {
991
991
  this.dirty = true;
992
992
  return true;
993
993
  }
994
+ /** In-progress tool call: ONE line that the result later REPLACES in
995
+ * place (2026-09-25 user request: consecutive tool calls used to cost
996
+ * two transcript lines each - the `● name args` line plus the folded
997
+ * `⎿ result` line - and a run of ten calls buried the conversation).
998
+ * Returns the mutable entry so settleToolCall() can swap it. */
999
+ startToolCall(display) {
1000
+ const width = Math.max(20, (stdout.columns || 100) - 2);
1001
+ const entry = { lines: wrapTo(display, width) };
1002
+ this.entries.push(entry);
1003
+ this.scrollFromBottom = 0;
1004
+ this.dirty = true;
1005
+ return entry;
1006
+ }
1007
+ /** Fold a settled tool call onto its start line and register it as a
1008
+ * z-expandable cell (same cell semantics as addToolCell). */
1009
+ settleToolCall(entry, folded, full) {
1010
+ const width = Math.max(20, (stdout.columns || 100) - 2);
1011
+ entry.lines = wrapTo(folded, width).map((l) => DIM(l));
1012
+ this.toolCells.push({ entry, full, folded, expanded: false });
1013
+ this.dirty = true;
1014
+ }
994
1015
  /* ---------------- M4: streaming markdown colorizer (B10) ---------------- */
995
1016
  /** Light zero-dep markdown line color for STREAMED text: headings cyan,
996
1017
  * list markers dim, fences dim, blockquotes dim; everything else plain.
@@ -2032,6 +2053,10 @@ export async function tui(yes, noWeb = false, opts = {}) {
2032
2053
  fullToolLog.push({ name: 'thinking', output: reasoningBuf.slice(0, 8000) });
2033
2054
  } reasoningBuf = ''; rt.foldThinking(); };
2034
2055
  let kind = null;
2056
+ // the in-flight tool call's transcript entry: the result REPLACES it
2057
+ // in place (one line per call, 2026-09-25)
2058
+ let pendingToolEntry = null;
2059
+ let pendingToolName = null;
2035
2060
  try {
2036
2061
  const result = await runAgentTask({
2037
2062
  task: line,
@@ -2076,14 +2101,24 @@ export async function tui(yes, noWeb = false, opts = {}) {
2076
2101
  const brief = name === 'run_command' && typeof args.command === 'string'
2077
2102
  ? args.command
2078
2103
  : JSON.stringify(args);
2079
- rt.addText(`${YELLOW('●')} ${CYAN(name)} ${DIM(brief.replace(/\s+/g, ' ').slice(0, 90))}`);
2104
+ // ONE line per call (2026-09-25): the running `● name args` line
2105
+ // is REPLACED in place by the folded result line on settle, so a
2106
+ // run of N calls costs N transcript lines, not 2N
2107
+ pendingToolEntry = rt.startToolCall(`${YELLOW('●')} ${CYAN(name)} ${DIM(brief.replace(/\s+/g, ' ').slice(0, 90))}`);
2108
+ pendingToolName = name;
2080
2109
  },
2081
2110
  onToolResult: (name, output, isError) => {
2082
2111
  const dot = isError ? RED('✗') : GREEN('•');
2083
2112
  const first = output.split('\n').find((l) => l.trim()) ?? '';
2084
- // M4 B8: tool call + result = one collapsible cell (folded summary
2085
- // by default; `z` with an empty input expands the last one)
2086
- rt.addToolCell(` ${dot} ${CYAN(name)} ${DIM('⎿ ' + first.trim().slice(0, 100))}`, output);
2113
+ // M4 B8 + 2026-09-25: the call line settles INTO the folded cell
2114
+ // (one line per call; `z` with an empty input expands the last)
2115
+ const folded = ` ${dot} ${CYAN(name)} ${DIM('⎿ ' + first.trim().slice(0, 100))}`;
2116
+ if (pendingToolEntry && pendingToolName === name)
2117
+ rt.settleToolCall(pendingToolEntry, folded, output);
2118
+ else
2119
+ rt.addToolCell(folded, output);
2120
+ pendingToolEntry = null;
2121
+ pendingToolName = null;
2087
2122
  // M4 B9 (T18 复案 2026-09-21): outputs beyond a screen NO LONGER
2088
2123
  // auto-open the full-screen pager - on every system it read as a
2089
2124
  // break-in (a wall of raw output hijacking the screen while the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.18.3",
3
+ "version": "0.18.4",
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",
@@ -50,7 +50,7 @@
50
50
  "@hmharness/domain-ops": "0.8.3",
51
51
  "@hmharness/agent": "0.14.19",
52
52
  "@hmharness/evaluation": "0.8.6",
53
- "@hmharness/web": "0.9.5",
53
+ "@hmharness/web": "0.9.6",
54
54
  "@hmharness/sandbox": "0.8.5"
55
55
  }
56
56
  }