@songtonyli/dsh-cli 0.1.24 → 0.1.25

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/README.md CHANGED
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
26
26
  ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
27
27
  ordinary optional dependencies, so npm resolves the right one for your machine.
28
28
 
29
- Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.24; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.25; `dsh --version`
30
30
  also reports the harness build the package was assembled from.
31
31
 
32
32
  ## License
package/bin/dsh.mjs CHANGED
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
18
18
  // version this package publishes. Reporting only one of the two would make an
19
19
  // ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
20
20
  if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
21
- console.log('@songtonyli/dsh-cli 0.1.24 (deepseek-harness 0.1.6-alpha.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.25 (deepseek-harness 0.1.6-alpha.2)')
22
22
  process.exit(0)
23
23
  }
24
24
 
@@ -160,7 +160,7 @@ window.__ModuleLoader__.load({
160
160
  const SCROLLBAR_LINGER_MS = 2e3;
161
161
  /** Format complete-build metadata for the local brand badge. */
162
162
  function localBuildVersion() {
163
- return `0.1.6-alpha.2-5f4682c-dirty`;
163
+ return `0.1.6-alpha.2-26160b0` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
164
164
  }
165
165
  /** Each panel row subscribes only to its own selection state. */
166
166
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -24,8 +24,8 @@
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
26
  "@types/react": "~18.3.1",
27
- "@deepseek-ai/cordis": "^4.0.2",
28
- "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2"
27
+ "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2",
28
+ "@deepseek-ai/cordis": "^4.0.2"
29
29
  },
30
30
  "files": [
31
31
  "lib/index.js",
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/bundle/tui-app/README.md
5
- README.md: 11567568640439cc4ecb48ce7aa37c31615e58c1
6
- README.zh.md: 85d202e1ca040030921db665b0b5bc44b8ce83ed
5
+ README.md: 804426a98ae3b7b8392a4b3619c5700cab7d3824
6
+ README.zh.md: 221d3b06d7cde8d3f2c8fb6d288e431edd91a519
@@ -257,7 +257,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
257
257
  | [`src/effort.ts`](src/effort.ts) | Reasoning-effort names and picker rows shared by `/model`, `/effort`, and editor `Shift+Tab` |
258
258
  | [`src/attach.ts`](src/attach.ts) | `/attach`: local files into image or file blocks through the attachment store |
259
259
  | [`src/export.ts`](src/export.ts) | `/export`: the session-log ZIP written through the export package's archive helpers |
260
- | [`src/blocks.ts`](src/blocks.ts) | Transcript components: user prompt, assistant reply, tool card, system prompt and injected context, notice; the navigable blocks expose their sections and draw the focus gutter, and the foldable ones carry the marker both fold keys name |
260
+ | [`src/blocks.ts`](src/blocks.ts) | Transcript components: user prompt, assistant reply, tool card, system prompt and injected context, notice; the navigable blocks expose their sections and draw the focus gutter, and the foldable ones carry the marker both fold keys name. Each block keeps the lines it last drew and a reply keeps the coloured fences of its last Markdown parse, so a frame of a settled transcript costs one key comparison per block and a stream delta colours only the fence that changed |
261
261
  | [`src/context.ts`](src/context.ts) | Project logged system prompts and injected user messages into transcript sections |
262
262
  | [`src/navigation.ts`](src/navigation.ts) | The transcript as sections, the cursor that walks them along four axes, the turns those sections group into, and the inspector heading |
263
263
  | [`src/inspector.ts`](src/inspector.ts) | The docked inspector: the framed pane with its mode chip, the section heading, the numbered wrapping parts strip, the folded rows, and its mounted component |
@@ -257,7 +257,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
257
257
  | [`src/effort.ts`](src/effort.ts) | `/model`、`/effort` 与编辑器 `Shift+Tab` 共用的推理强度名称及选择器行 |
258
258
  | [`src/attach.ts`](src/attach.ts) | `/attach`:本地文件经附件存储成为图片或文件块 |
259
259
  | [`src/export.ts`](src/export.ts) | `/export`:通过导出包的归档辅助函数写出会话日志 ZIP |
260
- | [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块暴露其各小节并绘制焦点标记条,可折叠的块则承载两个折叠键共用的那条标记 |
260
+ | [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块暴露其各小节并绘制焦点标记条,可折叠的块则承载两个折叠键共用的那条标记。每个块保留上次画出的行,回复还保留上次 Markdown 解析所着色的代码围栏,因此已稳定的对话记录每帧只花每块一次键比较,一次流式增量也只为发生变化的那个围栏着色 |
261
261
  | [`src/context.ts`](src/context.ts) | 把已记录的系统提示词与注入的用户消息投影为对话记录小节 |
262
262
  | [`src/navigation.ts`](src/navigation.ts) | 把对话记录看作各个小节、沿四条轴走遍它们的光标、这些小节归入的各轮次,以及检视面板的标题 |
263
263
  | [`src/inspector.ts`](src/inspector.ts) | 停靠的检视面板:带模式徽标的边框面板、小节标题、带编号且会折行的各部分选择行、折叠后的各行,及其挂载的组件 |
@@ -2240,6 +2240,18 @@ function editorTheme(palette) {
2240
2240
  * content wraps at and is prepended after any fade recoloring, so the fade
2241
2241
  * keeps matching the block's own text and the gutter's styling never enters
2242
2242
  * that match.
2243
+ *
2244
+ * pi-tui asks every component for its lines on every frame, and the
2245
+ * transcript is never pruned, so each block keeps the lines it last drew
2246
+ * ({@link LastDrawn}) and hands them back until its width, fold, focus, or
2247
+ * content changes - a settled block costs a frame one key comparison. What
2248
+ * changes per frame - a fade's level, the focus mark's lift - is drawn over
2249
+ * those kept lines. Fenced code is the expensive part of a reply, so a reply
2250
+ * also keeps the coloured fences of its last Markdown parse
2251
+ * ({@link FenceMemo}): a stream delta re-parses the whole message but colours
2252
+ * only the fence that changed. `invalidate()` drops all of it, which the
2253
+ * application calls on every block when a grammar lands; a new terminal width
2254
+ * needs no call, because it misses every key on its own.
2243
2255
  * @module @deepseek-ai/dsh-tui-app/blocks
2244
2256
  */
2245
2257
  /** Columns the focus gutter takes from the width a block's content wraps at. */
@@ -2301,6 +2313,85 @@ function withGutter(palette, lines, focused, level) {
2301
2313
  function markedRange(section, marker) {
2302
2314
  return section.to > section.from ? section : marker;
2303
2315
  }
2316
+ /**
2317
+ * The last drawing of one block and the key it was built for. One entry, so a
2318
+ * block holds exactly one drawing however many frames ask for it, and a key
2319
+ * that names every input the drawing depends on is what keeps it current.
2320
+ */
2321
+ var LastDrawn = class {
2322
+ entry;
2323
+ /**
2324
+ * The drawing for `key`, built once per key change.
2325
+ * @param key - every input the drawing depends on, joined.
2326
+ * @param build - builds the drawing when the key differs from the last one.
2327
+ * @returns the same value for the same key until {@link LastDrawn.clear}.
2328
+ */
2329
+ get(key, build) {
2330
+ if (this.entry?.key !== key) this.entry = {
2331
+ key,
2332
+ value: build()
2333
+ };
2334
+ return this.entry.value;
2335
+ }
2336
+ /** Forget the drawing, so the next frame builds it again. */
2337
+ clear() {
2338
+ this.entry = void 0;
2339
+ }
2340
+ };
2341
+ /**
2342
+ * The coloured fences of one reply, kept from one Markdown parse to the next.
2343
+ *
2344
+ * pi-tui's `Markdown` re-parses the whole message whenever its text changes
2345
+ * and asks the theme to colour every fence it finds, so a streaming reply
2346
+ * that already carries three fences would colour all three on every delta.
2347
+ * This keeps what the last parse asked for: a fence that is asked for again
2348
+ * is answered from memory, and a fence the last parse did not ask for is
2349
+ * dropped at the next {@link FenceMemo.settle}, so the memo never holds more
2350
+ * than the reply shows. A fence the highlighter left plain is not kept, so
2351
+ * the grammar that lands is asked for it.
2352
+ */
2353
+ var FenceMemo = class {
2354
+ inner;
2355
+ /** What the previous parse asked for. */
2356
+ previous = /* @__PURE__ */ new Map();
2357
+ /** What the parse in progress has asked for so far. */
2358
+ current = /* @__PURE__ */ new Map();
2359
+ /** Whether a parse asked for anything since the last settle. */
2360
+ asked = false;
2361
+ /** @param inner - the highlighter that colours a fence this memo does not hold. */
2362
+ constructor(inner) {
2363
+ this.inner = inner;
2364
+ }
2365
+ lines(code, lang) {
2366
+ this.asked = true;
2367
+ const key = `${String(lang)} ${code}`;
2368
+ const known = this.current.get(key) ?? this.previous.get(key);
2369
+ if (known !== void 0) {
2370
+ this.current.set(key, known);
2371
+ return known;
2372
+ }
2373
+ const coloured = this.inner.lines(code, lang);
2374
+ if (coloured !== void 0) this.current.set(key, coloured);
2375
+ return coloured;
2376
+ }
2377
+ /**
2378
+ * Close the parse that just ran: what it asked for is kept for the next
2379
+ * one, and what only the parse before it asked for goes. A render that
2380
+ * parsed nothing - `Markdown` served its own cache - changes nothing.
2381
+ */
2382
+ settle() {
2383
+ if (!this.asked) return;
2384
+ this.asked = false;
2385
+ this.previous = this.current;
2386
+ this.current = /* @__PURE__ */ new Map();
2387
+ }
2388
+ /** Forget every fence, so the next parse colours each one afresh. */
2389
+ clear() {
2390
+ this.previous = /* @__PURE__ */ new Map();
2391
+ this.current = /* @__PURE__ */ new Map();
2392
+ this.asked = false;
2393
+ }
2394
+ };
2304
2395
  /** A prompt the user submitted, drawn with a leading `›`. */
2305
2396
  var UserBlock = class {
2306
2397
  theme;
@@ -2312,6 +2403,8 @@ var UserBlock = class {
2312
2403
  highlight;
2313
2404
  /** How far above its settled accent the focus mark is drawn right now. */
2314
2405
  highlightLevel = 0;
2406
+ /** The wrapped prompt, by width and whether the gutter narrowed it. */
2407
+ drawn = new LastDrawn();
2315
2408
  constructor(theme, text, turn) {
2316
2409
  this.theme = theme;
2317
2410
  this.text = text;
@@ -2335,11 +2428,15 @@ var UserBlock = class {
2335
2428
  this.highlight = part;
2336
2429
  this.highlightLevel = level;
2337
2430
  }
2338
- invalidate() {}
2431
+ invalidate() {
2432
+ this.drawn.clear();
2433
+ }
2339
2434
  render(width) {
2340
2435
  const palette = this.theme.palette;
2341
2436
  const { marked, content: inner } = focusFrame(width, this.highlight);
2342
- const lines = ["", ...wrapTextWithAnsi(this.text, Math.max(1, inner - 2)).map((line, index) => `${palette.accent(index === 0 ? "›" : " ")} ${palette.bold(line)}`)];
2437
+ const lines = this.drawn.get(`${String(width)}:${String(marked)}`, () => {
2438
+ return ["", ...wrapTextWithAnsi(this.text, Math.max(1, inner - 2)).map((line, index) => `${palette.accent(index === 0 ? "›" : " ")} ${palette.bold(line)}`)];
2439
+ });
2343
2440
  return marked ? withGutter(palette, lines, () => true, this.highlightLevel) : lines;
2344
2441
  }
2345
2442
  };
@@ -2383,6 +2480,8 @@ var ContextBlock = class {
2383
2480
  /** How far above its settled accent the focus mark is drawn right now. */
2384
2481
  highlightLevel = 0;
2385
2482
  expanded = false;
2483
+ /** The wrapped block, by width, fold, and whether the gutter narrowed it. */
2484
+ drawn = new LastDrawn();
2386
2485
  /**
2387
2486
  * @param theme - the palette the glyph and title are styled with.
2388
2487
  * @param title - form and producer, a notice summary, or `system prompt`.
@@ -2424,10 +2523,34 @@ var ContextBlock = class {
2424
2523
  setExpanded(expanded) {
2425
2524
  this.expanded = expanded;
2426
2525
  }
2427
- invalidate() {}
2526
+ invalidate() {
2527
+ this.drawn.clear();
2528
+ }
2428
2529
  render(width) {
2429
2530
  const palette = this.theme.palette;
2430
2531
  const { marked, content: inner } = focusFrame(width, this.highlight);
2532
+ const { lines, head, ranges, cut, kept, body } = this.drawn.get(`${String(width)}:${String(marked)}:${String(this.expanded)}`, () => this.layout(inner, marked));
2533
+ if (this.highlight === void 0) return lines;
2534
+ const section = ranges[this.highlight];
2535
+ if (section === void 0) return withGutter(palette, lines, () => true, this.highlightLevel);
2536
+ const drawn = Math.min(section.to, cut ? kept : body);
2537
+ const held = markedRange({
2538
+ from: head + section.from,
2539
+ to: head + drawn
2540
+ }, {
2541
+ from: head + (cut ? kept : body),
2542
+ to: lines.length
2543
+ });
2544
+ return withGutter(palette, lines, (line) => line >= held.from && line < held.to, this.highlightLevel);
2545
+ }
2546
+ /**
2547
+ * Wrap the title and every body row, then fold the body.
2548
+ * @param inner - the columns the block's own rows lay out in.
2549
+ * @param marked - whether the block draws the focus gutter, which names the fold key.
2550
+ * @returns the lines and where the head, each part, and the fold fall in them.
2551
+ */
2552
+ layout(inner, marked) {
2553
+ const palette = this.theme.palette;
2431
2554
  const textWidth = Math.max(1, inner - 2);
2432
2555
  const indent = (line) => ` ${line}`;
2433
2556
  const dimRows = (text) => wrapTextWithAnsi(text, textWidth).map((line) => indent(palette.dim(line)));
@@ -2446,19 +2569,14 @@ var ContextBlock = class {
2446
2569
  const kept = this.theme.contextPreviewLines;
2447
2570
  const cut = !this.expanded && body.length > kept;
2448
2571
  const shown = cut ? [...body.slice(0, kept), ...dimRows(foldMarker(body.length - kept, marked ? "marked" : "transcript"))] : body;
2449
- const lines = [...head, ...shown];
2450
- if (this.highlight === void 0) return lines;
2451
- const section = ranges[this.highlight];
2452
- if (section === void 0) return withGutter(palette, lines, () => true, this.highlightLevel);
2453
- const drawn = Math.min(section.to, cut ? kept : body.length);
2454
- const held = markedRange({
2455
- from: head.length + section.from,
2456
- to: head.length + drawn
2457
- }, {
2458
- from: head.length + (cut ? kept : body.length),
2459
- to: lines.length
2460
- });
2461
- return withGutter(palette, lines, (line) => line >= held.from && line < held.to, this.highlightLevel);
2572
+ return {
2573
+ lines: [...head, ...shown],
2574
+ head: head.length,
2575
+ ranges,
2576
+ cut,
2577
+ kept,
2578
+ body: body.length
2579
+ };
2462
2580
  }
2463
2581
  };
2464
2582
  /**
@@ -2494,11 +2612,18 @@ var AssistantBlock = class {
2494
2612
  highlight;
2495
2613
  /** How far above its settled accent the focus mark is drawn right now. */
2496
2614
  highlightLevel = 0;
2615
+ /** The coloured fences of the last parse; absent when the theme colours none. */
2616
+ fences;
2617
+ /** The settled message, by width, focus, and content; a streaming message is drawn afresh each frame. */
2618
+ drawn = new LastDrawn();
2619
+ /** Counts every change to the text, the reasoning, or the committed state. */
2620
+ revision = 0;
2497
2621
  constructor(theme, turn) {
2498
2622
  this.theme = theme;
2499
2623
  this.turn = turn;
2500
2624
  const palette = theme.palette;
2501
- this.markdown = new Markdown("", 0, 0, markdownTheme(palette, theme.codeHighlight));
2625
+ this.fences = theme.codeHighlight === void 0 ? void 0 : new FenceMemo(theme.codeHighlight);
2626
+ this.markdown = new Markdown("", 0, 0, markdownTheme(palette, this.fences));
2502
2627
  this.reasoningText = new Text("", 0, 0);
2503
2628
  }
2504
2629
  /**
@@ -2562,6 +2687,7 @@ var AssistantBlock = class {
2562
2687
  */
2563
2688
  appendText(delta) {
2564
2689
  this.text += delta;
2690
+ this.revision += 1;
2565
2691
  this.markdown.setText(this.text);
2566
2692
  }
2567
2693
  /**
@@ -2570,6 +2696,7 @@ var AssistantBlock = class {
2570
2696
  */
2571
2697
  appendReasoning(delta) {
2572
2698
  this.reasoning += delta;
2699
+ this.revision += 1;
2573
2700
  this.reasoningText.setText(this.theme.palette.dim(this.theme.palette.italic(this.reasoning.trimEnd())));
2574
2701
  }
2575
2702
  /**
@@ -2582,6 +2709,7 @@ var AssistantBlock = class {
2582
2709
  this.text = text;
2583
2710
  this.reasoning = reasoning;
2584
2711
  this.interrupted = interrupted;
2712
+ this.revision += 1;
2585
2713
  this.fade = void 0;
2586
2714
  this.reasoningFade = void 0;
2587
2715
  this.markdown.setText(text);
@@ -2590,9 +2718,22 @@ var AssistantBlock = class {
2590
2718
  invalidate() {
2591
2719
  this.markdown.invalidate();
2592
2720
  this.reasoningText.invalidate();
2721
+ this.fences?.clear();
2722
+ this.drawn.clear();
2593
2723
  }
2594
2724
  render(width) {
2595
- const { content: inner } = focusFrame(width, this.highlight);
2725
+ const { marked, content: inner } = focusFrame(width, this.highlight);
2726
+ const { lines, reasoning, reply } = this.fade !== void 0 || this.reasoningFade !== void 0 ? this.compose(inner) : this.drawn.get(`${String(width)}:${String(marked)}:${String(this.revision)}`, () => this.compose(inner));
2727
+ if (this.highlight === void 0) return lines;
2728
+ const section = this.parts()[this.highlight]?.kind === "reasoning" ? reasoning : reply;
2729
+ return withGutter(this.theme.palette, lines, (index) => index >= section.from && index < section.to, this.highlightLevel);
2730
+ }
2731
+ /**
2732
+ * Stack the reasoning over the reply, each through its own tail.
2733
+ * @param inner - the columns the message lays out in.
2734
+ * @returns the lines, gutter not yet applied, and where each section falls.
2735
+ */
2736
+ compose(inner) {
2596
2737
  const lines = [""];
2597
2738
  const reasoning = {
2598
2739
  from: 0,
@@ -2614,9 +2755,11 @@ var AssistantBlock = class {
2614
2755
  reply.to = lines.length;
2615
2756
  }
2616
2757
  if (this.interrupted) lines.push(this.theme.palette.dim("[interrupted]"));
2617
- if (this.highlight === void 0) return lines;
2618
- const section = this.parts()[this.highlight]?.kind === "reasoning" ? reasoning : reply;
2619
- return withGutter(this.theme.palette, lines, (index) => index >= section.from && index < section.to, this.highlightLevel);
2758
+ return {
2759
+ lines,
2760
+ reasoning,
2761
+ reply
2762
+ };
2620
2763
  }
2621
2764
  /**
2622
2765
  * The reasoning lines, with the streaming tail floated out toward dim italic.
@@ -2650,6 +2793,7 @@ var AssistantBlock = class {
2650
2793
  renderText(width, at) {
2651
2794
  const fade = this.fade;
2652
2795
  const lines = this.markdown.render(width);
2796
+ this.fences?.settle();
2653
2797
  if (fade === void 0) return lines;
2654
2798
  if (this.fadeWidth !== void 0 && this.fadeWidth !== width) fade.flush();
2655
2799
  this.fadeWidth = width;
@@ -2684,6 +2828,10 @@ var ToolBlock = class {
2684
2828
  highlight;
2685
2829
  /** How far above its settled accent the focus mark is drawn right now. */
2686
2830
  highlightLevel = 0;
2831
+ /** The coloured, folded, wrapped body, by width, fold, focus, status, and result. */
2832
+ drawn = new LastDrawn();
2833
+ /** Counts every result the card was given. */
2834
+ revision = 0;
2687
2835
  constructor(theme, name, call, turn) {
2688
2836
  this.theme = theme;
2689
2837
  this.name = name;
@@ -2756,6 +2904,7 @@ var ToolBlock = class {
2756
2904
  this.resultLines = lines;
2757
2905
  this.resultCode = code;
2758
2906
  this.status = isError ? "error" : "done";
2907
+ this.revision += 1;
2759
2908
  }
2760
2909
  /**
2761
2910
  * Whether the whole body is drawn right now.
@@ -2771,36 +2920,28 @@ var ToolBlock = class {
2771
2920
  setExpanded(expanded) {
2772
2921
  this.expanded = expanded;
2773
2922
  }
2774
- invalidate() {}
2923
+ invalidate() {
2924
+ this.drawn.clear();
2925
+ }
2775
2926
  render(width) {
2776
2927
  const palette = this.theme.palette;
2777
2928
  const { marked, content: outer } = focusFrame(width, this.highlight);
2778
- const header = `${this.status === "running" ? palette.warning("●") : this.status === "done" ? palette.success("●") : palette.error("●")} ${palette.bold(this.name)}${this.call.title === "" ? "" : ` ${palette.dim(this.call.title)}`}`;
2779
- const body = [...this.call.lines, ...this.resultLines];
2780
- const code = this.call.code === void 0 && this.resultCode === void 0 ? void 0 : [...this.call.code ?? new Array(this.call.lines.length).fill(void 0), ...this.resultCode ?? new Array(this.resultLines.length).fill(void 0)];
2781
- const kept = this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript"));
2782
- const shown = paintDiffRows(paintCodeRows(kept, code, this.theme.codeHighlight), kept, palette);
2783
- const callCount = Math.min(this.call.lines.length, shown.length);
2784
- const inner = Math.max(1, outer - 4);
2785
- const rows = (lines) => lines.flatMap((line) => wrapTextWithAnsi(line, inner).map((part) => ` ${palette.dim("│")} ${part}`));
2786
- const callLines = [...wrapTextWithAnsi(header, outer), ...rows(shown.slice(0, callCount))];
2787
- const resultLines = rows(shown.slice(callCount));
2788
- const call = faded(callLines, this.fade, this.repaintFloor - 1);
2789
- const result = faded(resultLines, this.resultFade, this.repaintFloor - 1 - callLines.length);
2790
- const lines = [
2929
+ const layout = this.drawn.get(`${String(width)}:${String(marked)}:${String(this.expanded)}:${this.status}:${String(this.revision)}`, () => this.layout(outer, marked));
2930
+ const call = faded(layout.call, this.fade, this.repaintFloor - 1);
2931
+ const result = faded(layout.result, this.resultFade, this.repaintFloor - 1 - layout.call.length);
2932
+ const lines = call === layout.call && result === layout.result ? layout.lines : [
2791
2933
  "",
2792
2934
  ...call,
2793
2935
  ...result
2794
2936
  ];
2795
2937
  if (this.highlight === void 0) return lines;
2796
- const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
2797
- const sections = lines.length - (cut ? rows(shown.slice(-1)).length : 0);
2938
+ const sections = lines.length - layout.marker;
2798
2939
  const section = this.parts()[this.highlight]?.kind === "result" ? {
2799
- from: 1 + callLines.length,
2940
+ from: 1 + layout.call.length,
2800
2941
  to: lines.length
2801
2942
  } : {
2802
2943
  from: 1,
2803
- to: 1 + callLines.length
2944
+ to: 1 + layout.call.length
2804
2945
  };
2805
2946
  const held = markedRange({
2806
2947
  from: section.from,
@@ -2811,6 +2952,37 @@ var ToolBlock = class {
2811
2952
  });
2812
2953
  return withGutter(palette, lines, (index) => index >= held.from && index < held.to, this.highlightLevel);
2813
2954
  }
2955
+ /**
2956
+ * Colour, fold, and wrap the card body.
2957
+ * @param outer - the columns the card lays out in.
2958
+ * @param marked - whether the card draws the focus gutter, which names the fold key.
2959
+ * @returns the header with the call rows, the result rows, both stacked
2960
+ * under the blank line, and how many lines the fold marker took.
2961
+ */
2962
+ layout(outer, marked) {
2963
+ const palette = this.theme.palette;
2964
+ const header = `${this.status === "running" ? palette.warning("●") : this.status === "done" ? palette.success("●") : palette.error("●")} ${palette.bold(this.name)}${this.call.title === "" ? "" : ` ${palette.dim(this.call.title)}`}`;
2965
+ const body = [...this.call.lines, ...this.resultLines];
2966
+ const code = this.call.code === void 0 && this.resultCode === void 0 ? void 0 : [...this.call.code ?? new Array(this.call.lines.length).fill(void 0), ...this.resultCode ?? new Array(this.resultLines.length).fill(void 0)];
2967
+ const kept = this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript"));
2968
+ const shown = paintDiffRows(paintCodeRows(kept, code, this.theme.codeHighlight), kept, palette);
2969
+ const callCount = Math.min(this.call.lines.length, shown.length);
2970
+ const inner = Math.max(1, outer - 4);
2971
+ const rows = (lines) => lines.flatMap((line) => wrapTextWithAnsi(line, inner).map((part) => ` ${palette.dim("│")} ${part}`));
2972
+ const call = [...wrapTextWithAnsi(header, outer), ...rows(shown.slice(0, callCount))];
2973
+ const result = rows(shown.slice(callCount));
2974
+ const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
2975
+ return {
2976
+ call,
2977
+ result,
2978
+ lines: [
2979
+ "",
2980
+ ...call,
2981
+ ...result
2982
+ ],
2983
+ marker: cut ? rows(shown.slice(-1)).length : 0
2984
+ };
2985
+ }
2814
2986
  };
2815
2987
  /**
2816
2988
  * Draw one group of a card's rows at the mix its fade reports.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "The dsh terminal agent: an interactive TUI over the DeepSeek Harness, with its whole Node runtime bundled in one install.",
5
5
  "license": "MIT",
6
6
  "type": "module",