@songtonyli/dsh-cli 0.1.41 → 0.1.43

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.41; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.43; `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.41 (deepseek-harness 0.1.7-rc.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.43 (deepseek-harness 0.1.7-rc.2)')
22
22
  process.exit(0)
23
23
  }
24
24
 
@@ -532,21 +532,29 @@ const PROFILE_TEMPLATES = {
532
532
  headless: { bundles: ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-headless"] },
533
533
  sdk: { bundles: ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-sdk-app"] },
534
534
  "sdk-minimal": { bundles: ["@deepseek-ai/dsh-sdk-minimal"] },
535
- tui: { bundles: ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-tui-app"] }
535
+ tui: { bundles: [
536
+ "@deepseek-ai/dsh-base",
537
+ "@deepseek-ai/dsh-tui-app",
538
+ "@deepseek-ai/dsh-experimental-auto-review"
539
+ ] }
536
540
  };
537
541
  /** Installation-owned bundle tuples normalized to the shipped template. */
538
- const INSTALLATION_OWNED_PROFILE_TUPLES = { headless: [
539
- "@deepseek-ai/dsh-base",
540
- "@deepseek-ai/dsh-web-app",
541
- "@deepseek-ai/dsh-headless"
542
- ] };
542
+ const INSTALLATION_OWNED_PROFILE_TUPLES = {
543
+ headless: [
544
+ "@deepseek-ai/dsh-base",
545
+ "@deepseek-ai/dsh-web-app",
546
+ "@deepseek-ai/dsh-headless"
547
+ ],
548
+ tui: ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-tui-app"]
549
+ };
543
550
  /** The bundle list a `dsh plugin` init uses for a name with no shipped template. */
544
551
  const DEFAULT_PROFILE_BUNDLES = ["@deepseek-ai/dsh-base"];
545
552
  /**
546
553
  * The bundles the dsh installation ships for a person to switch on: each a
547
554
  * runtime dependency of the installation that declares `dsh.bundle.patch`,
548
- * an `icon`, and `./locale/*.json` display metadata, selected by no shipped
549
- * template, and offered switched off by the plugin manager
555
+ * an `icon`, and `./locale/*.json` display metadata, and offered switched off
556
+ * by the plugin manager. The shipped TUI template selects Auto review; no
557
+ * other template does
550
558
  * ([rationale](../../../../.agents/notes/implemented/process/2026-09-15-shipped-optional-bundles.md),
551
559
  * [admission](../../../../.agents/notes/implemented/architecture/2026-09-21-experimental-capabilities-as-optional-bundles.md)).
552
560
  */
@@ -47,9 +47,9 @@
47
47
  "micromark-extension-gfm": "^3.0.0",
48
48
  "micromark-util-sanitize-uri": "^2.0.1",
49
49
  "simple-icons": "16.31.0",
50
- "@deepseek-ai/dsh-client-store": "0.1.7-rc.2",
51
50
  "@deepseek-ai/dsh-util-code-language": "0.1.7-rc.2",
52
51
  "@deepseek-ai/dsh-util-workspace-path": "0.1.7-rc.2",
52
+ "@deepseek-ai/dsh-client-store": "0.1.7-rc.2",
53
53
  "@deepseek-ai/cordis": "~4.0.4"
54
54
  },
55
55
  "files": [
@@ -167,7 +167,7 @@ window.__ModuleLoader__.load({
167
167
  const SCROLLBAR_LINGER_MS = 2e3;
168
168
  /** Format complete-build metadata for the local brand badge. */
169
169
  function localBuildVersion() {
170
- return `0.1.7-rc.2-9d9ac5c` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
170
+ return `0.1.7-rc.2-67d7f99` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
171
171
  }
172
172
  /** Each panel row subscribes only to its own selection state. */
173
173
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -3,14 +3,14 @@
3
3
  # After editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/experimental/auto-review/README.md
5
5
  /:
6
- en: 4f245200f5345e3c
7
- zh: 221e9996e8ce2963
6
+ en: 4ba7553052e868d6
7
+ zh: 84ef71a398b68599
8
8
  /deepseek-ai-dsh-experimental-auto-review:
9
9
  en: 566562e610f1b52b
10
10
  zh: 88796a19ab0b98b8
11
11
  /deepseek-ai-dsh-experimental-auto-review/summary:
12
- en: 1012423ee9084823
13
- zh: 7021aa4e0cd3adfc
12
+ en: a9deacccf0e79927
13
+ zh: 089704e9f48555f3
14
14
  /deepseek-ai-dsh-experimental-auto-review/table-of-contents:
15
15
  en: d152484eb41ac6b4
16
16
  zh: 09388d293f9be9cb
@@ -57,8 +57,8 @@
57
57
  en: 8da1089dee147f94
58
58
  zh: 87361347bfd10c6c
59
59
  /deepseek-ai-dsh-experimental-auto-review/known-limitations-and-deferred-work:
60
- en: 5682fe41fcc459ab
61
- zh: fa15b23a21d18ff4
60
+ en: cf0c266006daf9a0
61
+ zh: a29542f770947bfd
62
62
  /deepseek-ai-dsh-experimental-auto-review/known-limitations-and-deferred-work/dev-note:
63
63
  en: e67f633dc6fe7773
64
64
  zh: 3bb0c20c93f16f98
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Add experimental per-call Auto review to a Web profile, using the current agent's model before tools execute with Full access."
2
+ description: "Add experimental per-call Auto review, using the current agent's model before tools execute with Full access."
3
3
  kind: "package-bundle"
4
4
  ---
5
5
 
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
9
9
 
10
10
  ## Summary
11
11
 
12
- Add Auto review to the current-session permission pickers in a Web profile. Before each native or PTC inner tool call, the current agent's provider and model assess the pending action; an allowed call executes with Full access, and a denied call asks the user. The dsh installation ships this layer switched off; default Web keeps its three permission modes until it is switched on from the Web sidebar's Plugins page or installed explicitly. Auto review is experimental: it can allow unsafe actions, deny useful work, and spend additional tokens.
12
+ Add Auto review to the current-session permission pickers. Before each native or PTC inner tool call, the current agent's provider and model assess the pending action; an allowed call executes with Full access, and a denied call asks the user. The shipped TUI profile includes this layer. Default Web keeps its three permission modes until it is switched on from the Web sidebar's Plugins page or installed explicitly. Auto review is experimental: it can allow unsafe actions, deny useful work, and spend additional tokens.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -112,7 +112,7 @@ The denial appends an ordinary tool result; it does not rewrite earlier context
112
112
 
113
113
  <a id="known-limitations-and-deferred-work"></a>
114
114
 
115
- - Auto requires this Web layer switched on; it is absent from default Web, Headless, General settings, and new-session defaults.
115
+ - The shipped TUI profile includes Auto review. Default Web, Headless, General settings, and new-session defaults omit it until this layer is switched on.
116
116
  - Auto provides no file sandbox. The outer `run_code` transport and direct Node effects inside a PTC program do not pass through inner-tool review.
117
117
  - Model classification can be wrong. There are no deterministic tool exemptions, persistent grants, configurable policy, or retry layer.
118
118
  - In-process Auto children review their own calls. Out-of-process children retain their native permission systems after the parent delegation call is allowed.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "为 Web profile 添加实验性逐调用 Auto review,在工具以 Full access 执行前使用当前 agent 的模型审查。"
2
+ description: "添加实验性逐调用 Auto review,在工具以 Full access 执行前使用当前 agent 的模型审查。"
3
3
  kind: "package-bundle"
4
4
  ---
5
5
 
@@ -9,7 +9,7 @@ kind: "package-bundle"
9
9
 
10
10
  ## 概述
11
11
 
12
- 为 Web profile 当前会话权限选择器添加 Auto review。每次原生或 PTC inner 工具调用前,当前 agent 的 provider 与模型会评估待执行动作;获准调用以 Full access 执行,被拒绝调用会请求用户审批。dsh 安装随附此层但默认关闭;在 Web 侧栏插件页开启或显式安装之前,默认 Web 保持三种权限模式。Auto review 是实验功能:它可能误放行不安全动作、误拒绝有用操作,并消耗额外 token。
12
+ 为当前会话权限选择器添加 Auto review。每次原生或 PTC inner 工具调用前,当前 agent 的 provider 与模型会评估待执行动作;获准调用以 Full access 执行,被拒绝调用会请求用户审批。随附的 TUI profile 包含此层。在 Web 侧栏插件页开启或显式安装之前,默认 Web 保持三种权限模式。Auto review 是实验功能:它可能误放行不安全动作、误拒绝有用操作,并消耗额外 token。
13
13
 
14
14
  ## 目录
15
15
 
@@ -112,7 +112,7 @@ Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用
112
112
 
113
113
  <a id="known-limitations-and-deferred-work"></a>
114
114
 
115
- - Auto 需要开启此 Web 层;默认 Web、Headless、通用设置与新会话默认值都不包含它。
115
+ - 随附的 TUI profile 包含 Auto review。默认 Web、Headless、通用设置与新会话默认值在开启此层之前都不包含它。
116
116
  - Auto 不提供文件沙箱。外层 `run_code` transport 及PTC 程序内直接 Node 效果不经过 inner-tool review。
117
117
  - 模型分类可能出错。不提供确定性工具豁免、持久 grant、可配置策略或重试层。
118
118
  - 进程内 Auto child 独立审查自身调用。进程外 child 在父委派调用获准后保留原生权限系统。
@@ -86,7 +86,10 @@ function loggedSchema(value, expectedName, mode) {
86
86
  function isAborted(signal) {
87
87
  return signal.aborted;
88
88
  }
89
- /** Whether this visible message is a durable shipped-Web human instruction. */
89
+ /**
90
+ * Whether this visible message is a person-admitted prompt.
91
+ * Web writes the browser request id; the terminal writes one id per submission.
92
+ */
90
93
  function isHumanInstruction(source) {
91
94
  return source.kind === "user" && typeof source.rpcId === "string";
92
95
  }
@@ -21,11 +21,11 @@
21
21
  en: 847fde63152cd543
22
22
  zh: bcabc58850804e14
23
23
  /deepseek-ai-dsh-tui-app/use-this-package/the-screen:
24
- en: cb7406bf1aaf5cb0
25
- zh: c4f3ca2e96b0b2df
24
+ en: f46aab5ea9d40e5d
25
+ zh: c2b21f7d6faa40a4
26
26
  /deepseek-ai-dsh-tui-app/use-this-package/keys-and-commands:
27
- en: ca106ed5833cf760
28
- zh: 0b22e15b3ee1d40a
27
+ en: 144dbbfb32211390
28
+ zh: b0999e01748b7a05
29
29
  /deepseek-ai-dsh-tui-app/use-this-package/subscription-sign-in:
30
30
  en: 7c1b0e685a3a9415
31
31
  zh: 49f3bdc3e99d6259
@@ -51,8 +51,8 @@
51
51
  en: 142f04bf29e981dd
52
52
  zh: a1689297b06c9ca6
53
53
  /deepseek-ai-dsh-tui-app/understand-the-implementation/source-map:
54
- en: d2950e2997273b53
55
- zh: dae4d13ea8760105
54
+ en: 1c9ccdc98a9612d0
55
+ zh: 6a6b5426f34e4765
56
56
  /deepseek-ai-dsh-tui-app/understand-the-implementation/invariant-ownership:
57
57
  en: 0ddf6de8928026d5
58
58
  zh: 24feedcbb9e9d676
@@ -40,11 +40,11 @@ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui
40
40
 
41
41
  ### The screen
42
42
 
43
- The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, and each tool call is a card with a `◆` glyph coloured by status — yellow while it runs, green once done, red on failure — the bold tool name, the presenter headline in violet, a loading row while it runs, and a body folded to `toolPreviewLines` rows. The card appears when the model starts the call, its header first and its rows unrolling beneath it over about `toolRevealFrames` frames; the result rows unroll and float out the same way when the tool answers. An `edit` or `write` diff card frames each run of consecutive additions in a green rounded box and each run of removals in a red one, the removed rows above the added ones; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status-coloured `◆`, dim for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use warm orange, links and inline code use violet, and quotes stay dim. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
43
+ Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, and each tool call is a card with a `◆` glyph coloured by status — yellow while it runs, green once done, red on failure — the bold tool name, the presenter headline in violet — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. The card appears when the model starts the call, its header first and its rows unrolling beneath it over about `toolRevealFrames` frames; the result rows unroll and float out the same way when the tool answers. An `edit` or `write` diff card fills each added row edge to edge with a green background and each removed row with a red one, the removed rows above the added ones, and paints the `+` and `-` in their own lighter colour so each sign reads against the fill rather than in it; a wrapped row carries the fill on without a second sign; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status-coloured `◆`, dim for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use warm orange, links and inline code use violet, and quotes stay dim. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
44
44
 
45
45
  Below the transcript sit a spinner while the agent works — its label is `thinking` while the model reasons, `writing` while visible text arrives, or `calling <tool>` while a tool is streamed or still running, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and latest descendant line while either has a row — completed todo content scratched out and status glyphs colored green, yellow, or cyan, at most four todo rows then `+<n> more`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model and entry keys are colored; live turn, context, and todo facts use yellow, violet, and green. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, or `Shift+↑ select · Shift+↓ status` while follow-ups wait, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. Compaction and model-request retries appear as notices, the same facts the browser's markers carry.
46
46
 
47
- While the keyboard walks the conversation a framed inspector is docked directly above the editor, and the frame is the mode: it is drawn exactly while the conversation holds the keyboard. Its top rule carries an inverse ` ● READ ` chip and the focused section's heading — the section's position among the navigable blocks, the turn it belongs to, and what the section is — as in `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`. Under it the block's parts draw as a numbered wrapping strip like `← 1 call · [2 result] →` when the block has more than one, the held label bracketed as well as accented so the selection is legible with no color at all; then the section's own source rows, each prefixed with `│ ` and wrapped two columns narrower, folded at `focusPreviewLines` for every section kind — a system prompt and an injected context included — with `… <n> more rows · Ctrl+G reads it` under them. The bottom rule carries the keys the conversation answers, `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`, narrowed to `↑↓ ←→ · Space folds · Esc input` and then to `Esc input` as the terminal loses columns.
47
+ While the keyboard walks the conversation a framed inspector is docked directly above the editor, and the frame is the mode: it is drawn exactly while the conversation holds the keyboard. Its top rule carries an inverse ` ● READ ` chip and the focused section's heading — the section's position among the navigable blocks, the turn it belongs to, and what the section is — as in `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`. Under it the block's parts draw as a numbered wrapping strip like `← 1 call · [2 result] →` when the block has more than one, the held label bracketed as well as accented so the selection is legible with no color at all; then the section's own source rows, each closed by a `│ ` border on both sides and wrapped four columns narrower, folded at `focusPreviewLines` for every section kind — a system prompt and an injected context included — with `… <n> more rows · Ctrl+G reads it` under them. The bottom rule carries the keys the conversation answers, `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`, narrowed to `↑↓ ←→ · Space folds · Esc input` and then to `Esc input` as the terminal loses columns.
48
48
 
49
49
  The focused block is also marked where it stands, with a two-column gutter that is dim beside the block's other lines and accented beside the focused section's own — or beside the fold marker, when the fold left that section out of the drawn rows entirely — and its content wraps two columns narrower while the mark is drawn. That mark reaches only the lines pi-tui still repaints differentially — the last `rows` lines of the last frame it wrote, a window a taller frame raises and a shorter one never lowers — because changing anything above them would clear the terminal's scrollback. A block that has scrolled past that point keeps no gutter, the inspector heading appends ` · off screen`, and the frame's own rules draw dim instead of accent, so the frame itself reports that the mark cannot be drawn where the block stands. A fade whose rows reach that edge settles them to their final colors in the frame that writes them, so nothing stays dim in the scrollback.
50
50
 
@@ -169,7 +169,7 @@ Typing `/` at the start of the editor completes the terminal's own commands and
169
169
  | `/help` | List the commands, and the keys each focus state answers; `?` on an empty input does the same |
170
170
  | `/model` | Pick the model (type to filter the rows), then its reasoning effort when the model declares more than one, for the next request; `/model <provider>/<model>` selects directly, `/model save` stores the current selection as the default, and `Ctrl+S` in the model list stores the highlighted model as the default for the next launch without closing the list |
171
171
  | `/effort [id]` | With no argument, open the current model's reasoning-effort picker for the next request, the same picker as editor `Shift+Tab`; an id selects directly and `/effort default` restores the provider default |
172
- | `/permission [preset]` | With no argument, open the permission-preset picker; a preset selects directly |
172
+ | `/permission [preset]` | With no argument, open the permission-preset picker; a preset selects directly. The shipped profile includes experimental Auto review; `/permission auto` selects it for the current session |
173
173
  | `/resume` | Open the same persisted-session picker as `/sessions` and resume the selected previous session |
174
174
  | `/sessions` | Open the persisted-session picker and switch to the selected session |
175
175
  | `/new` | Start a new session |
@@ -277,7 +277,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
277
277
  | [`src/frame.ts`](src/frame.ts) | Pure box drawing: the rounded rules, the inverse mode chip, body rows, and the legend step a width holds |
278
278
  | [`src/reader.ts`](src/reader.ts) | The reader as plain data: its state, the intents keys become, its geometry, and the lines it draws |
279
279
  | [`src/reader-screen.ts`](src/reader-screen.ts) | The reader pane drawn on the alternate screen: its key map, and where it leaves the keyboard |
280
- | [`src/screen.ts`](src/screen.ts) | The main screen with the settle passes between building a frame and writing it, the repaint window each pass is judged against, the per-block repaint floor, and the suspension that holds the conversation off the terminal |
280
+ | [`src/screen.ts`](src/screen.ts) | The main screen with the page margins every frame is laid out and drawn inside, the settle passes between building a frame and writing it, the repaint window each pass is judged against, the per-block repaint floor, and the suspension that holds the conversation off the terminal |
281
281
  | [`src/alt-screen.ts`](src/alt-screen.ts) | The terminal's alternate screen: taking it, drawing absolutely addressed rows on it, and giving the conversation's own screen back |
282
282
  | [`src/fade.ts`](src/fade.ts) | The streamed-text fade: the wall-clock tail tracker, the block-fade clock and registry, the fade-in ramp, the float-out mix, and the recolor of rendered lines |
283
283
  | [`src/pace.ts`](src/pace.ts) | The stream pacer: the ordered queue between the assistant stream and the transcript, drained a backlog share per frame; and the row reveal that unrolls a tool card the same way |
@@ -286,7 +286,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
286
286
  | [`src/toast.ts`](src/toast.ts) | The transient key-feedback line: its overlay, its clock, and the lines it carries |
287
287
  | [`src/transcript.ts`](src/transcript.ts) | Pure text folding of presentation views, usage, and turn-end reasons, the `$ command` span, and the one fold grammar every marker is written in |
288
288
  | [`src/diff.ts`](src/diff.ts) | Line diff, hunk selection, and the addition and removal marks diff cards box |
289
- | [`src/style.ts`](src/style.ts) | The palette, including the cool dark-mode heading and link hues a Markdown reply uses, the strikethrough role completed todo content uses, the background band a prompt is drawn on, and the derived pi-tui themes |
289
+ | [`src/style.ts`](src/style.ts) | The palette, including the cool dark-mode heading and link hues a Markdown reply uses, the strikethrough role completed todo content uses, the background band a prompt is drawn on, the green and red fills and sign colours of a diff card's changed rows, and the derived pi-tui themes |
290
290
  | [`src/highlight.ts`](src/highlight.ts) | Syntax colour for fenced code, file rows, and shell commands: the grammars a block may load, the theme the background picks, and the SGR one token is drawn with |
291
291
  | [`src/completion.ts`](src/completion.ts) | Slash-command and `@`-reference completion for the editor |
292
292
  | [`src/editor.ts`](src/editor.ts) | The prompt editor's terminal caret, its `Shift+Left` / `Shift+Right` mapping to pi-tui word navigation, and syntax colour on a `!` / `!!` draft |
@@ -40,11 +40,11 @@ dsh tui --no-open # print sign-in URLs without opening a
40
40
 
41
41
  ### 屏幕布局
42
42
 
43
- 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,每次工具调用是一张卡片,含按状态着色的 `◆` 符号(运行中为黄色、完成为绿色、失败为红色)、粗体工具名、以紫色显示的呈现器标题、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。卡片在模型开始调用时出现,先画标题,其下各行在约 `toolRevealFrames` 帧内逐行展开;工具回答后,结果行也以同样方式展开并浮出。`edit` 或 `write` diff 卡片把每一段连续新增行框进绿色圆角框、每一段连续删除行框进红色圆角框,删除的旧行在上、新增的新行在下;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样按状态着色的 `◆`,交给后台的子 agent 则为暗色:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用暖橙色,链接与行内代码使用紫色,引用保持暗色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
43
+ 每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,每次工具调用是一张卡片,含按状态着色的 `◆` 符号(运行中为黄色、完成为绿色、失败为红色)、粗体工具名、以紫色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。卡片在模型开始调用时出现,先画标题,其下各行在约 `toolRevealFrames` 帧内逐行展开;工具回答后,结果行也以同样方式展开并浮出。`edit` 或 `write` diff 卡片把每一新增行整行铺满绿色背景、每一删除行整行铺满红色背景,删除的旧行在上、新增的新行在下,并把 `+` 与 `-` 画成各自更亮的颜色,使符号从填充色中读得出来;折行续行只延续填充色,不再画第二个符号;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样按状态着色的 `◆`,交给后台的子 agent 则为暗色:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用暖橙色,链接与行内代码使用紫色,引用保持暗色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
44
44
 
45
45
  对话记录下方依次是 agent 工作时的旋转指示——其标签在模型推理时为 `thinking`,可见文本到达时为 `writing`,工具正在流出或仍在执行时为 `calling <tool>`,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与最新后代行的 activity board(有行时才绘制;已完成内容划掉,状态符号以绿色、黄色或青色显示,todo 最多四行其后 `+<n> more`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型与入口按键带有颜色;进行中的轮次、上下文与 todo 信息分别使用黄色、紫色与绿色。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,有 follow-ups 等待时则写作 `Shift+↑ select · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
46
46
 
47
- 键盘在对话记录中移动时,编辑器正上方停靠着一个带边框的检视面板,边框即模式:它恰好在对话记录持有键盘时绘制。其顶边线带有一个反白的 ` ● READ ` 徽标与当前聚焦小节的标题——该小节在可导航块中的位置、所属轮次,以及这是哪一种小节——例如 `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`。其下在块含多个部分时,把这些部分绘制成形如 `← 1 call · [2 result] →` 的带编号、会折行的选择行,被持有的标签除强调色外还加上方括号,因此完全无颜色时选择仍然可读;再往下是该小节自身的源文本行,每行以 `│ ` 起头并按窄两列换行,对每一种小节——含系统提示词与注入的上下文——都折叠到 `focusPreviewLines` 行,其下写出 `… <n> more rows · Ctrl+G reads it`。底边线列出对话记录所应答的按键 `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`,随着终端列数减少收缩为 `↑↓ ←→ · Space folds · Esc input`,再收缩为 `Esc input`。
47
+ 键盘在对话记录中移动时,编辑器正上方停靠着一个带边框的检视面板,边框即模式:它恰好在对话记录持有键盘时绘制。其顶边线带有一个反白的 ` ● READ ` 徽标与当前聚焦小节的标题——该小节在可导航块中的位置、所属轮次,以及这是哪一种小节——例如 `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`。其下在块含多个部分时,把这些部分绘制成形如 `← 1 call · [2 result] →` 的带编号、会折行的选择行,被持有的标签除强调色外还加上方括号,因此完全无颜色时选择仍然可读;再往下是该小节自身的源文本行,每行左右两侧都由 `│ ` 边框闭合并按窄四列换行,对每一种小节——含系统提示词与注入的上下文——都折叠到 `focusPreviewLines` 行,其下写出 `… <n> more rows · Ctrl+G reads it`。底边线列出对话记录所应答的按键 `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`,随着终端列数减少收缩为 `↑↓ ←→ · Space folds · Esc input`,再收缩为 `Esc input`。
48
48
 
49
49
  被聚焦的块也会在原地被标记:一条两列宽的标记条,在块的其他行旁为暗色、在被聚焦小节自身的行旁为强调色——若折叠把该小节整个留在了绘出的行之外,强调色便落在那一行折叠标记旁——标记绘制期间该块的内容按窄两列换行。这个标记只能落在 pi-tui 仍以差分方式重绘的行上——也就是它写出的上一帧的最后 `rows` 行,这条边界只会被更高的帧抬高、不会被更矮的帧降低——因为改动其上方的任何一行都会清空终端的回滚区。已经滚过该位置的块不带标记条,检视面板的标题追加 ` · off screen`,其边框线也改画暗色而非强调色,于是边框本身就报告出标记无法画在该块所在之处。淡入中的各行抵达这一边界时,会在写出它们的同一帧内被结算为最终颜色,因此回滚区里不会留下暗色文字。
50
50
 
@@ -169,7 +169,7 @@ follow-ups 面板持有键盘时:
169
169
  | `/help` | 列出命令,以及每个焦点状态所应答的按键;输入为空时按 `?` 效果相同 |
170
170
  | `/model` | 为下一次请求选择模型(输入即可过滤行),若模型声明多于一种推理强度则接着选择强度;`/model <provider>/<model>` 直接选择,`/model save` 把当前选择存为默认,在模型列表中按 `Ctrl+S` 则把高亮的模型存为下次启动的默认而不关闭列表 |
171
171
  | `/effort [id]` | 不带参数时为下一次请求打开当前模型的推理强度选择器,与编辑器中的 `Shift+Tab` 打开的是同一个;id 直接选择,`/effort default` 恢复提供方默认值 |
172
- | `/permission [preset]` | 不带参数时打开权限预设选择器;preset 直接选择 |
172
+ | `/permission [preset]` | 不带参数时打开权限预设选择器;preset 直接选择。随附 profile 包含实验性 Auto review;`/permission auto` 为当前会话选中它 |
173
173
  | `/resume` | 打开与 `/sessions` 相同的持久化会话选择器,并恢复选中的先前会话 |
174
174
  | `/sessions` | 打开持久化会话选择器,并切换到选中的会话 |
175
175
  | `/new` | 开始新会话 |
@@ -277,7 +277,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
277
277
  | [`src/frame.ts`](src/frame.ts) | 纯粹的画框:圆角边框线、反白的模式徽标、正文行,以及某个宽度容纳得下的按键提示级别 |
278
278
  | [`src/reader.ts`](src/reader.ts) | 作为纯数据的阅读器:其状态、按键变成的各个意图、其几何布局,以及它画出的各行 |
279
279
  | [`src/reader-screen.ts`](src/reader-screen.ts) | 画在备用屏幕上的阅读器面板:其按键映射,以及它把键盘留在何处 |
280
- | [`src/screen.ts`](src/screen.ts) | 在构建一帧与写出该帧之间带若干次结算的主屏幕、每次结算所依据的重绘窗口、每个块的重绘下界,以及把对话记录挡在终端之外的挂起 |
280
+ | [`src/screen.ts`](src/screen.ts) | 每一帧据以排版与绘制的页边距、在构建一帧与写出该帧之间带若干次结算的主屏幕、每次结算所依据的重绘窗口、每个块的重绘下界,以及把对话记录挡在终端之外的挂起 |
281
281
  | [`src/alt-screen.ts`](src/alt-screen.ts) | 终端的备用屏幕:接管它、在其上按绝对行址绘制,以及把对话记录自己的屏幕交还 |
282
282
  | [`src/fade.ts`](src/fade.ts) | 流式文本淡入与浮出:基于挂钟的尾部追踪器、块时钟与注册表、淡入亮度级别、浮出混合,以及对已渲染行的重新着色 |
283
283
  | [`src/pace.ts`](src/pace.ts) | 流式节拍器:助手流与对话记录之间的有序队列,每帧释放积压的一份;以及以同样方式展开工具卡片的逐行展开器 |
@@ -286,7 +286,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
286
286
  | [`src/toast.ts`](src/toast.ts) | 临时按键提示行:其浮层、其时钟,以及它承载的各条文字 |
287
287
  | [`src/transcript.ts`](src/transcript.ts) | 呈现视图、用量与轮次结束原因的纯文本折叠、`$ command` 的 span,以及每条标记共用的那一套折叠措辞 |
288
288
  | [`src/diff.ts`](src/diff.ts) | diff 卡片的行 diff、hunk 选择,以及卡片加框所依据的新增与删除标记 |
289
- | [`src/style.ts`](src/style.ts) | 调色板(含 Markdown 回复所用的暗色冷色阶标题与链接色、已完成 todo 内容所用的划线角色、提示所铺的背景带)与派生的 pi-tui 主题 |
289
+ | [`src/style.ts`](src/style.ts) | 调色板(含 Markdown 回复所用的暗色冷色阶标题与链接色、已完成 todo 内容所用的划线角色、提示所铺的背景带、diff 卡片变更行的绿色与红色填充及符号颜色)与派生的 pi-tui 主题 |
290
290
  | [`src/highlight.ts`](src/highlight.ts) | 围栏代码、文件行与 shell 命令的语法高亮:某个块可能加载的语法、由背景选定的配色主题,以及一个 token 所用的 SGR |
291
291
  | [`src/completion.ts`](src/completion.ts) | 编辑器的斜杠命令与 `@` 引用补全 |
292
292
  | [`src/editor.ts`](src/editor.ts) | 提示编辑器的终端光标、把 `Shift+Left` / `Shift+Right` 映射到 pi-tui 词导航的逻辑,以及 `!` / `!!` 草稿上的语法高亮 |
@@ -668,13 +668,39 @@ function diffsBody(diffs) {
668
668
  };
669
669
  }
670
670
  /**
671
+ * One tool name as a headline opens with it: lowercase, with `_` and `-` read
672
+ * as spaces, so `web_search` matches a `Web search …` headline.
673
+ * @param text - the tool name or the headline's opening run.
674
+ * @returns the comparable form.
675
+ */
676
+ function headlineWord(text) {
677
+ return text.toLowerCase().replaceAll(/[_-]+/gu, " ");
678
+ }
679
+ /**
680
+ * The headline drawn after a tool's own name, without the name a presenter
681
+ * repeated. A view titled `Read src/app.ts` under the `read` tool draws
682
+ * `src/app.ts`, so the name is read once wherever the two are drawn together.
683
+ * @param toolName - the tool the call names.
684
+ * @param title - the presenter's title.
685
+ * @returns the title, or what follows the repeated name; empty when the title
686
+ * is the name alone.
687
+ */
688
+ function cardHeadline(toolName, title) {
689
+ const name = headlineWord(toolName);
690
+ if (name === "" || headlineWord(title.slice(0, name.length)) !== name) return title;
691
+ const rest = title.slice(name.length);
692
+ if (rest === "") return "";
693
+ return rest.startsWith(" ") ? rest.trimStart() : title;
694
+ }
695
+ /**
671
696
  * Text for a tool call from its presentation view, falling back to the raw
672
697
  * arguments when the tool declares no presenter.
673
698
  * @param argumentsJson - the verbatim argument JSON.
674
699
  * @param view - the tool's `presentCall` view, when it has one.
700
+ * @param toolName - the tool the call names, whose repeat the headline drops.
675
701
  * @returns the card's call text.
676
702
  */
677
- function toolCallText(argumentsJson, view) {
703
+ function toolCallText(argumentsJson, view, toolName) {
678
704
  if (view === void 0) {
679
705
  const parsed = parseArguments(argumentsJson);
680
706
  const summary = parsed === void 0 ? argumentsJson : JSON.stringify(parsed);
@@ -688,25 +714,24 @@ function toolCallText(argumentsJson, view) {
688
714
  const lines = [];
689
715
  if (view.content !== void 0) lines.push(...contentText(view.content).split("\n"));
690
716
  return {
691
- title: view.title,
717
+ title: cardHeadline(toolName, view.title),
692
718
  lines
693
719
  };
694
720
  }
695
721
  case "terminal": {
696
- const extra = [];
697
- if (view.description !== void 0) extra.push(view.description);
698
- if (view.cwd !== void 0) extra.push(`cwd: ${view.cwd}`);
722
+ const title = cardHeadline(toolName, view.description ?? "");
723
+ const extra = view.cwd === void 0 ? [] : [`cwd: ${view.cwd}`];
699
724
  if (view.title === "") return {
700
- title: view.title,
725
+ title,
701
726
  lines: extra
702
727
  };
703
728
  return {
704
- title: view.title,
729
+ title,
705
730
  ...shellCommandBody(view.title, extra)
706
731
  };
707
732
  }
708
733
  case "diff": return {
709
- title: view.title,
734
+ title: cardHeadline(toolName, view.title),
710
735
  ...diffsBody(view.diffs)
711
736
  };
712
737
  default: return assertNever(view, "tui tool call view");
@@ -2582,7 +2607,11 @@ const SGR = {
2582
2607
  warning: ["33", "39"],
2583
2608
  error: ["31", "39"],
2584
2609
  inverse: ["7", "27"],
2585
- band: ["48;5;236", "49"]
2610
+ band: ["48;5;236", "49"],
2611
+ addedBand: ["48;5;22", "49"],
2612
+ removedBand: ["48;5;52", "49"],
2613
+ addedSign: ["38;5;120", "39"],
2614
+ removedSign: ["38;5;210", "39"]
2586
2615
  };
2587
2616
  /**
2588
2617
  * Build the palette.
@@ -2608,6 +2637,10 @@ function createPalette(enabled) {
2608
2637
  error: role("error"),
2609
2638
  inverse: role("inverse"),
2610
2639
  band: role("band"),
2640
+ addedBand: role("addedBand"),
2641
+ removedBand: role("removedBand"),
2642
+ addedSign: role("addedSign"),
2643
+ removedSign: role("removedSign"),
2611
2644
  enabled
2612
2645
  };
2613
2646
  }
@@ -2638,45 +2671,54 @@ function paintDiffRows(rows, source, palette) {
2638
2671
  function bandRow(palette, row, width) {
2639
2672
  return palette.enabled ? palette.band(`${row}${" ".repeat(Math.max(0, width - visibleWidth(row)))}`) : row;
2640
2673
  }
2641
- /** Narrowest width a diff box is drawn at: two borders, two spaces, and one column of text. */
2642
- const DIFF_BOX_MIN_WIDTH = 5;
2643
2674
  /**
2644
- * Wrap rows to `width`, framing each run of consecutive additions in a green
2645
- * rounded box and each run of consecutive removals in a red one, so a change
2646
- * reads as one region. A removal run directly followed by an addition run
2647
- * draws as two stacked boxes, the old text above the new. Every returned line
2648
- * is at most `width` columns, and every box line is exactly `width`.
2675
+ * The `+` or `-` of a changed row, painted apart from the tint the row is
2676
+ * filled with. The sign sits in the plain row's own prefix - the file line
2677
+ * number, when the diff carries one, then the sign and a space - and syntax
2678
+ * colour starts after it, so the styled row opens with the same characters.
2679
+ * @param row - the styled row.
2680
+ * @param plain - the same row before any syntax colour.
2681
+ * @param mark - whether the row is an addition or a removal.
2682
+ * @param palette - the active palette.
2683
+ * @returns the row with its sign painted, or unchanged when the styled row
2684
+ * does not open with the plain prefix.
2685
+ */
2686
+ function paintDiffSign(row, plain, mark, palette) {
2687
+ const sign = mark === "added" ? "+" : "-";
2688
+ const at = plain.indexOf(`${sign} `);
2689
+ if (at === -1 || !row.startsWith(plain.slice(0, at + 1))) return row;
2690
+ const paint = mark === "added" ? palette.addedSign : palette.removedSign;
2691
+ return `${row.slice(0, at)}${paint(sign)}${row.slice(at + 1)}`;
2692
+ }
2693
+ /**
2694
+ * Wrap rows to `width` and fill each changed row edge to edge with its own
2695
+ * background tint - green for an addition, red for a removal - so a run of
2696
+ * changes reads as one region without spending a column on a border. The `+`
2697
+ * and `-` are painted in their own lighter colour, apart from the fill, and a
2698
+ * wrapped continuation carries the tint with no sign of its own. Every
2699
+ * returned line is at most `width` columns, and every filled line is exactly
2700
+ * `width`; a disabled palette pads nothing and returns the rows as they are.
2649
2701
  * @param rows - the styled rows.
2702
+ * @param plain - the same rows before any syntax colour, which carry the signs.
2650
2703
  * @param marks - per row, whether it is an addition or a removal; undefined
2651
- * for a row outside every box.
2704
+ * for a row no tint fills.
2652
2705
  * @param width - the columns the rows fit.
2653
- * @param palette - the active palette; a disabled one draws the boxes uncolored.
2654
- * @returns the wrapped rows with the boxes drawn around the changes; rows
2655
- * wrapped without boxes when the width cannot hold a box.
2706
+ * @param palette - the active palette.
2707
+ * @returns the wrapped rows, the changed ones filled.
2656
2708
  */
2657
- function boxDiffRows(rows, marks, width, palette) {
2709
+ function bandDiffRows(rows, plain, marks, width, palette) {
2710
+ const columns = Math.max(1, width);
2658
2711
  const out = [];
2659
- const inner = width - 4;
2660
- let open;
2661
- const close = () => {
2662
- if (open === void 0) return;
2663
- const paint = open === "added" ? palette.success : palette.error;
2664
- out.push(paint(`╰${"─".repeat(width - 2)}╯`));
2665
- open = void 0;
2666
- };
2667
2712
  for (const [index, row] of rows.entries()) {
2668
- const mark = width < DIFF_BOX_MIN_WIDTH ? void 0 : marks[index];
2669
- if (mark !== open) close();
2713
+ const mark = marks[index];
2670
2714
  if (mark === void 0) {
2671
- out.push(...wrapTextWithAnsi(row, Math.max(1, width)));
2715
+ out.push(...wrapTextWithAnsi(row, columns));
2672
2716
  continue;
2673
2717
  }
2674
- const paint = mark === "added" ? palette.success : palette.error;
2675
- if (open === void 0) out.push(paint(`╭${"─".repeat(width - 2)}╮`));
2676
- open = mark;
2677
- for (const part of wrapTextWithAnsi(row, inner)) out.push(`${paint("│")} ${part}${" ".repeat(Math.max(0, inner - visibleWidth(part)))} ${paint("│")}`);
2718
+ const fill = mark === "added" ? palette.addedBand : palette.removedBand;
2719
+ const signed = paintDiffSign(row, plain[index] ?? "", mark, palette);
2720
+ for (const part of wrapTextWithAnsi(signed, columns)) out.push(palette.enabled ? fill(`${part}${" ".repeat(Math.max(0, columns - visibleWidth(part)))}`) : part);
2678
2721
  }
2679
- close();
2680
2722
  return out;
2681
2723
  }
2682
2724
  /**
@@ -3780,7 +3822,7 @@ var ToolBlock = class {
3780
3822
  ...this.resultCode ?? new Array(this.resultLines.length).fill(void 0)
3781
3823
  ];
3782
3824
  const kept = this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript"));
3783
- const shown = paintDiffRows(paintCodeRows(kept, code, this.theme.codeHighlight), kept, palette);
3825
+ const shown = paintCodeRows(kept, code, this.theme.codeHighlight);
3784
3826
  const callCount = Math.min(this.call.lines.length + loading.length, shown.length);
3785
3827
  const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
3786
3828
  const marks = [
@@ -3789,7 +3831,7 @@ var ToolBlock = class {
3789
3831
  ...this.resultDiff ?? new Array(this.resultLines.length).fill(void 0)
3790
3832
  ].slice(0, cut ? kept.length - 1 : kept.length);
3791
3833
  const inner = Math.max(1, outer - 4);
3792
- const rows = (from, to) => boxDiffRows(shown.slice(from, to), marks.slice(from, to), inner, palette).map((part) => ` ${palette.dim("│")} ${part}`);
3834
+ const rows = (from, to) => bandDiffRows(shown.slice(from, to), kept.slice(from, to), marks.slice(from, to), inner, palette).map((part) => ` ${palette.dim("│")} ${part}`);
3793
3835
  const call = [...wrapTextWithAnsi(header, outer), ...rows(0, callCount)];
3794
3836
  const result = rows(callCount, shown.length);
3795
3837
  return {
@@ -5007,7 +5049,7 @@ const LEGEND_LEFT = "├";
5007
5049
  const LEGEND_RIGHT = "┤";
5008
5050
  /** What a rule fills the width between its texts with. */
5009
5051
  const FILL = "─";
5010
- /** The left border of a body row; the frame has no right border. */
5052
+ /** The border drawn on each side of a body row. */
5011
5053
  const SIDE$1 = "│";
5012
5054
  /** What separates the chip from the title on a top rule. */
5013
5055
  const CHIP_JOIN = ` ${FILL} `;
@@ -5097,18 +5139,25 @@ function legendRule(parts) {
5097
5139
  return rule(LEGEND_LEFT, LEGEND_RIGHT, parts, "");
5098
5140
  }
5099
5141
  /**
5100
- * One row inside a frame. There is no right border, so a row is not padded to
5101
- * the width and a wrapped line keeps the width it was wrapped at.
5142
+ * One row inside a frame, closed on both sides: the content is padded to the
5143
+ * room between the borders, so a frame reads as one box however short its
5144
+ * rows are. Content wrapped at {@link BODY_MARGIN} columns less than the width
5145
+ * is drawn whole; anything wider is cut.
5102
5146
  * @param content - the row, already styled and already wrapped.
5103
5147
  * @param width - the columns the line must fit.
5104
- * @param palette - the palette the border is styled with.
5105
- * @param tone - which role that border takes.
5106
- * @param level - how far above its settled drawing the border is lifted, so
5107
- * the whole outline of a frame moves as one; `0` draws the settled border.
5108
- * @returns the line, no wider than `width`.
5148
+ * @param palette - the palette the borders are styled with.
5149
+ * @param tone - which role those borders take.
5150
+ * @param level - how far above its settled drawing the borders are lifted, so
5151
+ * the whole outline of a frame moves as one; `0` draws the settled borders.
5152
+ * @returns the line, exactly `width` columns while both borders fit.
5109
5153
  */
5110
5154
  function bodyLine(content, width, palette, tone, level = 0) {
5111
- return truncateToWidth(`${tone === "focus" ? pulse(palette, palette.accent(SIDE$1), level) : palette.dim(SIDE$1)} ${content}`, Math.max(1, width), ELLIPSIS$4);
5155
+ const border = tone === "focus" ? pulse(palette, palette.accent(SIDE$1), level) : palette.dim(SIDE$1);
5156
+ const columns = Math.max(1, width);
5157
+ const room = columns - 4;
5158
+ if (room < 1) return truncateToWidth(`${border} ${content}`, columns, ELLIPSIS$4);
5159
+ const cut = truncateToWidth(content, room, ELLIPSIS$4);
5160
+ return `${border} ${cut}${" ".repeat(Math.max(0, room - visibleWidth(cut)))} ${border}`;
5112
5161
  }
5113
5162
  //#endregion
5114
5163
  //#region lib/types/keys.js
@@ -5623,8 +5672,6 @@ function typeKey(data) {
5623
5672
  */
5624
5673
  /** What the chip names this mode. */
5625
5674
  const READ_CHIP = "READ";
5626
- /** Columns a body row spends on the frame's left border and the space after it. */
5627
- const BODY_MARGIN = 2;
5628
5675
  /** What separates two labels of the parts strip. */
5629
5676
  const SEPARATOR$4 = " · ";
5630
5677
  /** What the heading appends while the focused block lies outside the repaint window. */
@@ -5658,7 +5705,7 @@ function renderInspector(view, render) {
5658
5705
  tone,
5659
5706
  level
5660
5707
  })];
5661
- const room = Math.max(1, width - BODY_MARGIN);
5708
+ const room = Math.max(1, width - 4);
5662
5709
  if (view.parts.length > 1) for (const line of partsStrip(view.parts, palette, room)) lines.push(bodyLine(line, width, palette, tone, level));
5663
5710
  const body = foldRows(view.rows.flatMap((row) => wrapTextWithAnsi(row, room)), render.previewLines, (hidden) => palette.dim(foldMarker(hidden, "inspector")));
5664
5711
  for (const row of body) lines.push(bodyLine(row, width, palette, tone, level));
@@ -7773,7 +7820,7 @@ function renderQueuePanel(rows, render) {
7773
7820
  palette,
7774
7821
  tone
7775
7822
  })];
7776
- const room = Math.max(1, width - 2);
7823
+ const room = Math.max(1, width - 4);
7777
7824
  for (const [index, row] of rows.entries()) {
7778
7825
  const glyph = selected === index ? palette.accent(FOLLOW_UP_GLYPH) : FOLLOW_UP_GLYPH;
7779
7826
  for (const content of followUpLines(row.text, room, glyph)) lines.push(bodyLine(content, width, palette, tone));
@@ -9504,6 +9551,11 @@ var SyntaxHighlighter = class {
9504
9551
  * entirely rather than drawing over the conversation, so no line of the
9505
9552
  * conversation is rewritten while the surface is up and none of the surface's
9506
9553
  * own rows can reach the terminal's scrollback.
9554
+ *
9555
+ * The screen also keeps {@link PAGE_MARGIN_COLUMNS} blank columns on each
9556
+ * side of every frame: the tree lays out in the columns that remain and each
9557
+ * drawn line is moved right by that many spaces, so nothing the conversation
9558
+ * or the docked chrome draws touches either edge of the terminal.
9507
9559
  * @module @deepseek-ai/dsh-tui-app/screen
9508
9560
  */
9509
9561
  /**
@@ -9513,6 +9565,37 @@ var SyntaxHighlighter = class {
9513
9565
  * own record of what is marked describes.
9514
9566
  */
9515
9567
  const SETTLE_PASSES = 2;
9568
+ /** Columns a frame keeps for the tree before the margins are worth their cost. */
9569
+ const MIN_CONTENT_COLUMNS = 8;
9570
+ /**
9571
+ * The columns the tree lays out in at a terminal width, which is what every
9572
+ * surface drawn into the main screen is measured against. A terminal too
9573
+ * narrow to hold {@link MIN_CONTENT_COLUMNS} beside the margins gives up the
9574
+ * margins rather than the text, and the frame then fills its width, because a
9575
+ * line wider than the terminal is a frame pi-tui refuses.
9576
+ * @param width - the terminal's total width.
9577
+ * @returns the width inside the page margins, or the whole width on a terminal
9578
+ * too narrow for them.
9579
+ */
9580
+ function pageContentWidth(width) {
9581
+ const inside = width - 2;
9582
+ return inside < MIN_CONTENT_COLUMNS ? Math.max(1, width) : inside;
9583
+ }
9584
+ /** The left margin as the spaces each drawn line is moved right by. */
9585
+ const LEFT_MARGIN = " ".repeat(1);
9586
+ /**
9587
+ * Move every drawn line right by the left margin. A line with nothing on it
9588
+ * keeps its own emptiness rather than gaining trailing spaces, so a frame adds
9589
+ * no whitespace to what the terminal's scrollback holds.
9590
+ * @param lines - the frame the tree built inside the margins.
9591
+ * @param margin - the spaces to move each line by; empty on a terminal that
9592
+ * gave its margins up.
9593
+ * @returns the frame as it is written.
9594
+ */
9595
+ function indentFrame(lines, margin) {
9596
+ if (margin === "") return [...lines];
9597
+ return lines.map((line) => line === "" ? line : `${margin}${line}`);
9598
+ }
9516
9599
  /**
9517
9600
  * The first line of one block the renderer can still repaint.
9518
9601
  * @param start - index of the block's first line in the frame.
@@ -9612,17 +9695,23 @@ var GuardedMainScreen = class extends TuiMainScreen {
9612
9695
  super.doRender();
9613
9696
  }
9614
9697
  /**
9615
- * Build the frame, let the guard settle what its geometry decides, and build
9616
- * it again for every pass that changed a line.
9617
- * @param width - the total width the tree lays out in.
9618
- * @returns the frame to write, settled against its own geometry.
9698
+ * Build the frame inside the page margins, let the guard settle what its
9699
+ * geometry decides, and build it again for every pass that changed a line.
9700
+ *
9701
+ * The guard is handed the width the tree was laid out in, not the terminal's
9702
+ * own, so the line counts it walks are the ones this frame has.
9703
+ * @param width - the terminal's total width.
9704
+ * @returns the frame to write, indented by the left margin and settled
9705
+ * against its own geometry.
9619
9706
  */
9620
9707
  render(width) {
9708
+ const content = pageContentWidth(width);
9709
+ const margin = content === width ? "" : LEFT_MARGIN;
9621
9710
  const previousTop = this.captureRenderState().previousViewportTop;
9622
- let lines = super.render(width);
9711
+ let lines = indentFrame(super.render(content), margin);
9623
9712
  for (let pass = 0; pass < SETTLE_PASSES; pass += 1) {
9624
- if (!this.guard(Math.max(previousTop, lines.length - this.terminal.rows), width, lines.length)) break;
9625
- lines = super.render(width);
9713
+ if (!this.guard(Math.max(previousTop, lines.length - this.terminal.rows), content, lines.length)) break;
9714
+ lines = indentFrame(super.render(content), margin);
9626
9715
  }
9627
9716
  return lines;
9628
9717
  }
@@ -10250,6 +10339,21 @@ function callingActivity(name) {
10250
10339
  function isCallingActivity(activity) {
10251
10340
  return activity === "calling" || activity.startsWith("calling ");
10252
10341
  }
10342
+ /**
10343
+ * Source for a prompt the person typed in this terminal.
10344
+ * A string `rpcId` is the admission mark Auto review treats as a human instruction.
10345
+ * An edited draft keeps a non-user source; a user draft is admitted again.
10346
+ * @param draft - the queue draft being revised, when this submission replaces one.
10347
+ * @returns the source stored on the submitted user message.
10348
+ */
10349
+ function terminalPromptSource(draft) {
10350
+ const preserved = draft?.source;
10351
+ if (preserved !== void 0 && preserved.kind !== "user") return preserved;
10352
+ return {
10353
+ kind: "user",
10354
+ rpcId: randomUUID()
10355
+ };
10356
+ }
10253
10357
  /** The interactive terminal application; one instance per process. */
10254
10358
  var TuiApp = class {
10255
10359
  deps;
@@ -10524,6 +10628,16 @@ var TuiApp = class {
10524
10628
  return this.bound.agent;
10525
10629
  }
10526
10630
  /**
10631
+ * The columns every surface of the main screen is laid out in, which the
10632
+ * page margins {@link GuardedMainScreen} holds are already taken from. A
10633
+ * surface that builds its own text ahead of a frame - the follow-ups list,
10634
+ * the subagent panel - measures against this rather than the terminal.
10635
+ * @returns the layout width at the terminal's current width.
10636
+ */
10637
+ contentWidth() {
10638
+ return pageContentWidth(this.deps.terminal.columns);
10639
+ }
10640
+ /**
10527
10641
  * Take over the terminal, subscribe to the Agent, and optionally submit a
10528
10642
  * first prompt.
10529
10643
  * @param initialPrompt - a prompt submitted as soon as the terminal is up.
@@ -10923,7 +11037,7 @@ var TuiApp = class {
10923
11037
  this.queueSelection = rows[selected]?.message.id;
10924
11038
  this.queue.setText(renderQueuePanel(rows, {
10925
11039
  palette: this.deps.palette,
10926
- width: this.deps.terminal.columns,
11040
+ width: this.contentWidth(),
10927
11041
  ...this.focus === "queue" ? { selected } : {}
10928
11042
  }));
10929
11043
  }
@@ -11048,7 +11162,8 @@ var TuiApp = class {
11048
11162
  name,
11049
11163
  args
11050
11164
  };
11051
- const title = args === void 0 ? void 0 : this.presentCall(name, args)?.title;
11165
+ const view = args === void 0 ? void 0 : this.presentCall(name, args);
11166
+ const title = view === void 0 ? void 0 : cardHeadline(name, view.title);
11052
11167
  this.setActivitySubagent({
11053
11168
  label: this.activityLabelFor(session.id),
11054
11169
  status: callingActivity(name),
@@ -11111,7 +11226,7 @@ var TuiApp = class {
11111
11226
  this.panelLift = this.panelLiftNow();
11112
11227
  this.panel.setText(renderSubagentPanel(view, {
11113
11228
  palette: this.deps.palette,
11114
- width: this.deps.terminal.columns,
11229
+ width: this.contentWidth(),
11115
11230
  ...this.focus === "panel" ? {
11116
11231
  selected,
11117
11232
  level: this.panelLift
@@ -12455,7 +12570,7 @@ var TuiApp = class {
12455
12570
  text
12456
12571
  }
12457
12572
  ],
12458
- source: draft?.source ?? { kind: "user" }
12573
+ source: terminalPromptSource(draft)
12459
12574
  });
12460
12575
  if (agent.status !== "running") {
12461
12576
  this.submittedIds.add(message.id);
@@ -13135,7 +13250,7 @@ var TuiApp = class {
13135
13250
  }
13136
13251
  async askApproval(toolName, reason, callId, signal) {
13137
13252
  const args = callId === void 0 ? void 0 : this.toolArguments.get(callId);
13138
- const detail = args === void 0 ? [] : toolCallText(JSON.stringify(args), this.presentCall(toolName, args)).lines;
13253
+ const detail = args === void 0 ? [] : toolCallText(JSON.stringify(args), this.presentCall(toolName, args), toolName).lines;
13139
13254
  const outcome = await this.showModal(new ApprovalPrompt(this.deps.palette, toolName, reason, detail), signal);
13140
13255
  const tone = outcome === "allowed-once" ? "success" : "dim";
13141
13256
  this.notice(`${toolName}: ${outcome === "allowed-once" ? "allowed once" : outcome}`, tone);
@@ -13832,7 +13947,7 @@ var TuiApp = class {
13832
13947
  const call = source === "stream" && args === void 0 ? {
13833
13948
  title: "",
13834
13949
  lines: []
13835
- } : toolCallText(argumentsJson, args === void 0 ? void 0 : this.presentCall(name, args));
13950
+ } : toolCallText(argumentsJson, args === void 0 ? void 0 : this.presentCall(name, args), name);
13836
13951
  const existing = this.toolBlocks.get(callId);
13837
13952
  if (existing !== void 0) {
13838
13953
  existing.setCall(name, call);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
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",