@songtonyli/dsh-cli 0.1.23 → 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.23; `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.23 (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-33b866e-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 }) {
@@ -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: b96a38f5e0d042e701f0e994aa508474316fddda
6
- README.zh.md: 537d1b8aae4006b2050a9aa29810d53cdb5af9e4
5
+ README.md: 804426a98ae3b7b8392a4b3619c5700cab7d3824
6
+ README.zh.md: 221d3b06d7cde8d3f2c8fb6d288e431edd91a519
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
9
9
 
10
10
  ## Summary
11
11
 
12
- `dsh-tui-app` is the terminal surface of dsh: `dsh tui` starts a multi-turn session in your terminal, with no browser and no server. Replies stream, tool calls become foldable cards, approvals and `ask_user_question` questions appear above the input, `@` completes paths and sessions, and `/`-commands share the Web registry. Arrow keys walk the conversation through a docked inspector; `Ctrl+G` reads it full screen, turns side by side. Persisted sessions reopen through `/resume`, `/sessions`, or startup `--resume`; `/new` and `/fork` create them, and `/export` writes ZIPs. It runs `dsh web`'s model, tools, and safety defaults, one session at a time.
12
+ `dsh-tui-app` is the terminal surface of dsh: `dsh tui` starts a multi-turn session in your terminal, with no browser and no server. Replies stream, tool calls become foldable cards, approvals and `ask_user_question` questions appear above the input, `@` completes paths and sessions, and `/`-commands share the Web registry. Arrow keys walk the conversation through a docked inspector; `Ctrl+G` reads it full screen, turns side by side. Persisted sessions reopen through `/resume`, `/sessions`, or startup `--resume`; `/new`, `/clear`, and `/fork` create them, and `/export` writes ZIPs. It runs `dsh web`'s model, tools, and safety defaults, one session at a time.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -36,13 +36,13 @@ dsh tui --resume <session-id> # continue an earlier session
36
36
  dsh tui --no-open # print sign-in URLs without opening a browser
37
37
  ```
38
38
 
39
- On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new` starts a fresh one, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
39
+ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new` and `/clear` each start a fresh empty one while the previous session stays on disk for `/resume`, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
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 `›` (attachments listed under them), assistant reasoning is dim above the Markdown reply, and each tool call is a card with a status glyph, the tool name, the presenter headline, and a body folded to `toolPreviewLines` rows. 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, and the changed rows of an `edit` or `write` diff card — behind their line numbers and `+` / `-` signs, in the language the file's extension names — are drawn in 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. 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
+ 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 `›` (attachments listed under them), assistant reasoning is dim above the Markdown reply, and each tool call is a card with a status glyph, the tool name, the presenter headline, and a body folded to `toolPreviewLines` rows. 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, and 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 — 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. 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
- Below the transcript sit a spinner while the agent works, any open prompt, 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 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`, 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, cumulative token usage, 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.
45
+ Below the transcript sit a spinner while the agent works, any open prompt, a framed pending-prompt panel while messages wait, 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 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`, 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, cumulative token usage, 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
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.
48
48
 
@@ -58,13 +58,13 @@ The subagent panel is drawn while a subagent session under the bound one is resi
58
58
 
59
59
  ### Keys and commands
60
60
 
61
- The conversation, the input, the subagent panel, and the status bar stack in the order the screen draws them, and `Up` / `Down` walk that stack through the input: `Down` at the newest section, `Up` on the panel's first row, and `Up` on the status bar with no panel drawn all land at the caret. While a region other than the editor has the keyboard, `Tab` and `Shift+Tab` walk the regions that are drawn, wrapping at both ends; in the editor, `Tab` takes the offered completion and `Shift+Tab` opens the reasoning-effort picker. A printable key pressed in any of them returns to the input and types there, so a sentence started while reading lands where it was aimed; `Space` in the conversation is the one exception, and folds the marked tool card or context block. `Ctrl+G` and `Ctrl+O` mean the same thing in every one of those regions, and `Ctrl+C` and `Ctrl+D` return the keyboard to the input before they act. A prompt and the reader own their whole key stream instead, and answer `Ctrl+C` by giving the keyboard back.
61
+ The conversation, input, subagent panel, and status bar form the vertical arrow-key walk: `Down` at the newest section, `Up` on the subagent panel's first row, and `Up` on the status bar with no subagent panel drawn all land at the caret. The queued-prompt panel sits above the input; `Shift+Down` enters it while it is drawn, and it joins the `Tab` walk. While a region other than the editor has the keyboard, `Tab` and `Shift+Tab` walk the regions that are drawn, wrapping at both ends; in the editor, `Tab` takes the offered completion and `Shift+Tab` opens the reasoning-effort picker. A printable key pressed in any of them returns to the input and types there, so a sentence started while reading lands where it was aimed; `Space` in the conversation is the one exception, and folds the marked tool card or context block. `Ctrl+G` and `Ctrl+O` mean the same thing in every one of those regions, and `Ctrl+C` and `Ctrl+D` return the keyboard to the input before they act. A prompt and the reader own their whole key stream instead, and answer `Ctrl+C` by giving the keyboard back.
62
62
 
63
63
  While the input has the keyboard:
64
64
 
65
65
  | Key | Effect |
66
66
  |---|---|
67
- | `Enter` | Send the editor text; while a turn runs it is queued for the next turn and waits as a dim `⏳ next turn` row above the editor until the loop claims it, entering the conversation then |
67
+ | `Enter` | Send the editor text; while a turn runs it waits for the next turn in the framed `QUEUE` panel above the editor until the loop claims it, entering the conversation then |
68
68
  | `Shift+Enter` | Insert a newline |
69
69
  | `Ctrl+S` | While a turn runs, steer the editor text into the running turn's next step |
70
70
  | `Up` / `Down` | Recall earlier prompts |
@@ -72,7 +72,7 @@ While the input has the keyboard:
72
72
  | `Tab` | Take the completion the editor offers |
73
73
  | `Shift+Tab` | Open the current model's reasoning-effort picker for the next request, the same picker as empty `/effort` |
74
74
  | `Shift+Up` | Focus the conversation on the section the walk stopped at; a first entry, and the entry after a session switch, land on the newest section |
75
- | `Shift+Down` | Focus the subagent panel's first row while it is drawn, and the status bar otherwise |
75
+ | `Shift+Down` | Focus the queued-prompt panel's first row while prompts wait, otherwise the subagent panel's first row while it is drawn, and the status bar otherwise |
76
76
  | `Ctrl+G` | Read the conversation full screen, on its newest section |
77
77
  | `Ctrl+O` | Expand or collapse every tool card and context row |
78
78
  | `Esc` | Arm the stop and say so; a second press while that line is on screen stops the running turn, and queued messages stay queued |
@@ -81,6 +81,18 @@ While the input has the keyboard:
81
81
 
82
82
  An `Esc` that only handed the keyboard back — leaving a region, closing a page, a picker, or the reader — opens a 750 ms window in which an `Esc` reaching the input does nothing at all, so a habitual double press stops no turn. With no turn running, `Esc` closes the completion list while one is open and is silent otherwise. A session with nothing to read yet answers `Shift+Up` and `Ctrl+G` with `nothing in the transcript to read yet` and leaves the keyboard in the input.
83
83
 
84
+ While the queued-prompt panel has the keyboard:
85
+
86
+ | Key | Effect |
87
+ |---|---|
88
+ | `Up` / `Down`, `Home` / `End` | Select a pending prompt |
89
+ | `S` | Remove the selected prompt from its queue and steer it into the nearest step, waking the Agent |
90
+ | `I` | Move the selected prompt to next-step injection without waking the Agent |
91
+ | `E` | Remove the selected prompt into the editor; `Enter` sends the revision and `Ctrl+C` restores the original prompt to the next-turn queue |
92
+ | `Tab` / `Shift+Tab` | The next / previous region that is drawn |
93
+ | `Esc` | Return to the input |
94
+ | Any other printable key | Return to the input and type the character at the caret |
95
+
84
96
  While the conversation has the keyboard:
85
97
 
86
98
  | Key | Effect |
@@ -152,6 +164,7 @@ Typing `/` at the start of the editor completes the terminal's own commands and
152
164
  | `/resume` | Open the same persisted-session picker as `/sessions` and resume the selected previous session |
153
165
  | `/sessions` | Open the persisted-session picker and switch to the selected session |
154
166
  | `/new` | Start a new session |
167
+ | `/clear` | Start a new session with empty context; the previous session stays on disk and is resumable with `/resume` |
155
168
  | `/fork [turn]` | Fork this session at its last completed turn, or after turn `turn` |
156
169
  | `/title <text>` | Rename this session; alone it shows the current title |
157
170
  | `/attach <path>` | Attach an image or file to the next prompt; `/attach` lists, `/attach clear` drops them |
@@ -244,7 +257,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
244
257
  | [`src/effort.ts`](src/effort.ts) | Reasoning-effort names and picker rows shared by `/model`, `/effort`, and editor `Shift+Tab` |
245
258
  | [`src/attach.ts`](src/attach.ts) | `/attach`: local files into image or file blocks through the attachment store |
246
259
  | [`src/export.ts`](src/export.ts) | `/export`: the session-log ZIP written through the export package's archive helpers |
247
- | [`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 |
248
261
  | [`src/context.ts`](src/context.ts) | Project logged system prompts and injected user messages into transcript sections |
249
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 |
250
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 |
@@ -327,7 +340,7 @@ The runner adds nothing to the request prefix; a `/model` switch starts a new re
327
340
 
328
341
  These limits describe the terminal surface as shipped; they are not a general CLI comparison or a task backlog.
329
342
 
330
- - **One session at a time** — `/resume`, `/sessions`, `/new`, and `/fork` move the terminal between sessions, but only the bound Agent streams; the browser shows several sessions side by side.
343
+ - **One session at a time** — `/resume`, `/sessions`, `/new`, `/clear`, and `/fork` move the terminal between sessions, but only the bound Agent streams; the browser shows several sessions side by side.
331
344
  - **Approvals are one-shot** — the prompt offers allow once or reject, matching the approval seam's vocabulary; there is no remembered grant.
332
345
  - **Browser-only pages stay in the browser** — workspace and directory pickers, open-in-app links, the trajectory ledger, and per-message like/dislike have no terminal counterpart; `/settings`, `/plugins`, `/subagents`, `/outline`, and the shared `/feedback` cover their facts as text, and subagent transcripts are read by switching to the child session.
333
346
  - **Deliverables are named, not opened** — `/deliverables` lists the presented paths and `/changes` shows line comparisons; the browser previews the files.
@@ -9,7 +9,7 @@ kind: "package-bundle"
9
9
 
10
10
  ## 概述
11
11
 
12
- `dsh-tui-app` 是 dsh 的终端表层:`dsh tui` 在你的终端里启动一个多轮会话,没有浏览器、也没有服务器。回复流式显示,工具调用变成可折叠的卡片,审批与 `ask_user_question` 的问题出现在输入框上方,`@` 补全路径与会话,`/` 命令与 Web 共用注册表。方向键在停靠的检视面板中走遍对话记录;`Ctrl+G` 把它整屏读出、各轮次并排。持久化会话可通过 `/resume`、`/sessions` 或启动参数 `--resume` 恢复;`/new` 与 `/fork` 创建会话,`/export` 写出 ZIP。它运行 `dsh web` 的模型、工具与安全默认值,同一时间一个会话。
12
+ `dsh-tui-app` 是 dsh 的终端表层:`dsh tui` 在你的终端里启动一个多轮会话,没有浏览器、也没有服务器。回复流式显示,工具调用变成可折叠的卡片,审批与 `ask_user_question` 的问题出现在输入框上方,`@` 补全路径与会话,`/` 命令与 Web 共用注册表。方向键在停靠的检视面板中走遍对话记录;`Ctrl+G` 把它整屏读出、各轮次并排。持久化会话可通过 `/resume`、`/sessions` 或启动参数 `--resume` 恢复;`/new`、`/clear` 与 `/fork` 创建会话,`/export` 写出 ZIP。它运行 `dsh web` 的模型、工具与安全默认值,同一时间一个会话。
13
13
 
14
14
  ## 目录
15
15
 
@@ -36,13 +36,13 @@ dsh tui --resume <session-id> # continue an earlier session
36
36
  dsh tui --no-open # print sign-in URLs without opening a browser
37
37
  ```
38
38
 
39
- 退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史;在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new` 开始一个新会话,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
39
+ 退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史;在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new` 与 `/clear` 都会开始一个空的新会话且先前会话仍留在磁盘上可用 `/resume` 恢复,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
40
40
 
41
41
  ### 屏幕布局
42
42
 
43
- 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `›` 开头(附件列在其下),assistant 的推理以暗色显示在 Markdown 回复上方,每次工具调用是一张卡片,含状态符号、工具名、呈现器标题,以及折叠到 `toolPreviewLines` 行的正文。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行,以及 `edit` 或 `write` diff 卡片的变更行——在其行号与 `+` / `-` 符号之后,按文件扩展名对应的语言——都以语法高亮绘制,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
43
+ 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `›` 开头(附件列在其下),assistant 的推理以暗色显示在 Markdown 回复上方,每次工具调用是一张卡片,含状态符号、工具名、呈现器标题,以及折叠到 `toolPreviewLines` 行的正文。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行,以及 `edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
44
44
 
45
- 对话记录下方依次是 agent 工作时的旋转指示、任何打开的提示、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、累计 token 用量、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
45
+ 对话记录下方依次是 agent 工作时的旋转指示、任何打开的提示、有消息等待时的带框待处理提示面板、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、累计 token 用量、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
46
46
 
47
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
 
@@ -58,13 +58,13 @@ dsh tui --no-open # print sign-in URLs without opening a
58
58
 
59
59
  ### 按键与命令
60
60
 
61
- 对话记录、编辑器、子 agent 面板与状态栏按屏幕绘制它们的顺序排布,`Up` / `Down` 穿过编辑器走遍这一序列:在最新小节上按 `Down`、在面板第一行上按 `Up`、在没有绘制面板时于状态栏上按 `Up`,都会落到光标处。编辑器以外的区域持有键盘时,`Tab` 与 `Shift+Tab` 走遍已绘制的各区域,并在两端环绕;在编辑器中,`Tab` 采用给出的补全,`Shift+Tab` 打开推理强度选择器。在其中任何一个区域按下可打印键都会回到编辑器并在那里输入,因此在阅读时开始写的句子会落在它所指向的地方;对话记录中的 `Space` 是唯一的例外,它折叠被标记的工具卡片或上下文块。`Ctrl+G` 与 `Ctrl+O` 在这些区域中含义完全相同,而 `Ctrl+C` 与 `Ctrl+D` 会先把键盘交还编辑器再行动。提示与阅读器则各自持有整条按键流,并以交还键盘的方式应答 `Ctrl+C`。
61
+ 对话记录、编辑器、子 agent 面板与状态栏构成垂直方向键走查:在最新小节上按 `Down`、在子 agent 面板第一行上按 `Up`、在没有绘制子 agent 面板时于状态栏上按 `Up`,都会落到光标处。待处理提示面板位于输入框上方;绘制该面板时,`Shift+Down` 会进入它,它也加入 `Tab` 走查。编辑器以外的区域持有键盘时,`Tab` 与 `Shift+Tab` 走遍已绘制的各区域,并在两端环绕;在编辑器中,`Tab` 采用给出的补全,`Shift+Tab` 打开推理强度选择器。在其中任何一个区域按下可打印键都会回到编辑器并在那里输入,因此在阅读时开始写的句子会落在它所指向的地方;对话记录中的 `Space` 是唯一的例外,它折叠被标记的工具卡片或上下文块。`Ctrl+G` 与 `Ctrl+O` 在这些区域中含义完全相同,而 `Ctrl+C` 与 `Ctrl+D` 会先把键盘交还编辑器再行动。提示与阅读器则各自持有整条按键流,并以交还键盘的方式应答 `Ctrl+C`。
62
62
 
63
63
  编辑器持有键盘时:
64
64
 
65
65
  | 按键 | 效果 |
66
66
  |---|---|
67
- | `Enter` | 发送编辑器文本;轮次进行中时它排队到下一轮次,并作为一行暗色的 `⏳ next turn` 停在编辑器上方,直到循环领取它后才进入对话 |
67
+ | `Enter` | 发送编辑器文本;轮次进行中时它在编辑器上方的带框 `QUEUE` 面板中等待下一轮次,直到循环领取它后才进入对话 |
68
68
  | `Shift+Enter` | 插入换行 |
69
69
  | `Ctrl+S` | 轮次进行中时,把编辑器文本引导(steer)进当前轮次的下一步 |
70
70
  | `Up` / `Down` | 调出先前的提示 |
@@ -72,7 +72,7 @@ dsh tui --no-open # print sign-in URLs without opening a
72
72
  | `Tab` | 采用编辑器给出的补全 |
73
73
  | `Shift+Tab` | 打开当前模型的推理强度选择器,从下一次请求生效;与空参数 `/effort` 打开的是同一个选择器 |
74
74
  | `Shift+Up` | 把焦点放到对话记录上、停在走查上次停下的小节;首次进入以及切换会话后的首次进入停在最新小节 |
75
- | `Shift+Down` | 面板已绘制时把焦点放到子 agent 面板的第一行,否则放到状态栏 |
75
+ | `Shift+Down` | 有提示等待时把焦点放到待处理提示面板第一行,否则在子 agent 面板已绘制时放到其第一行,再否则放到状态栏 |
76
76
  | `Ctrl+G` | 整屏读出对话记录,停在其最新小节 |
77
77
  | `Ctrl+O` | 展开或折叠所有工具卡片与上下文行 |
78
78
  | `Esc` | 装填停止并给出提示;该提示仍在屏幕上时再按一次会停止正在进行的轮次,已排队的消息保持排队 |
@@ -81,6 +81,18 @@ dsh tui --no-open # print sign-in URLs without opening a
81
81
 
82
82
  仅仅交还了键盘的 `Esc`——离开某个区域、关闭页面、选择器或阅读器——会打开一个 750 ms 的窗口,其间到达编辑器的 `Esc` 完全不做任何事,因此习惯性的连按停不掉任何轮次。没有轮次进行时,`Esc` 在补全列表打开时关闭它,其余情况保持沉默。尚无可读内容的会话对 `Shift+Up` 与 `Ctrl+G` 回以 `nothing in the transcript to read yet`,并把键盘留在编辑器。
83
83
 
84
+ 待处理提示面板持有键盘时:
85
+
86
+ | 按键 | 效果 |
87
+ |---|---|
88
+ | `Up` / `Down`、`Home` / `End` | 选择一条待处理提示 |
89
+ | `S` | 从队列移除所选提示,并把它引导进最近的步骤,同时唤醒 Agent |
90
+ | `I` | 把所选提示移到下一步骤的注入队列,但不唤醒 Agent |
91
+ | `E` | 从队列移除所选提示并放入编辑器;`Enter` 发送修订内容,`Ctrl+C` 把原提示恢复到下一轮次队列 |
92
+ | `Tab` / `Shift+Tab` | 下一个 / 上一个已绘制区域 |
93
+ | `Esc` | 返回输入框 |
94
+ | 任何其他可打印键 | 返回输入框并在光标处输入该字符 |
95
+
84
96
  对话记录持有键盘时:
85
97
 
86
98
  | 按键 | 效果 |
@@ -152,6 +164,7 @@ dsh tui --no-open # print sign-in URLs without opening a
152
164
  | `/resume` | 打开与 `/sessions` 相同的持久化会话选择器,并恢复选中的先前会话 |
153
165
  | `/sessions` | 打开持久化会话选择器,并切换到选中的会话 |
154
166
  | `/new` | 开始新会话 |
167
+ | `/clear` | 开始一个空上下文的新会话;先前会话仍留在磁盘上,可用 `/resume` 恢复 |
155
168
  | `/fork [turn]` | 在本会话最后一个完成轮次处 fork,或在第 `turn` 轮之后 fork |
156
169
  | `/title <text>` | 重命名本会话;单独使用时显示当前标题 |
157
170
  | `/attach <path>` | 把图片或文件附加到下一条提示;`/attach` 列出,`/attach clear` 丢弃 |
@@ -244,7 +257,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
244
257
  | [`src/effort.ts`](src/effort.ts) | `/model`、`/effort` 与编辑器 `Shift+Tab` 共用的推理强度名称及选择器行 |
245
258
  | [`src/attach.ts`](src/attach.ts) | `/attach`:本地文件经附件存储成为图片或文件块 |
246
259
  | [`src/export.ts`](src/export.ts) | `/export`:通过导出包的归档辅助函数写出会话日志 ZIP |
247
- | [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块暴露其各小节并绘制焦点标记条,可折叠的块则承载两个折叠键共用的那条标记 |
260
+ | [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块暴露其各小节并绘制焦点标记条,可折叠的块则承载两个折叠键共用的那条标记。每个块保留上次画出的行,回复还保留上次 Markdown 解析所着色的代码围栏,因此已稳定的对话记录每帧只花每块一次键比较,一次流式增量也只为发生变化的那个围栏着色 |
248
261
  | [`src/context.ts`](src/context.ts) | 把已记录的系统提示词与注入的用户消息投影为对话记录小节 |
249
262
  | [`src/navigation.ts`](src/navigation.ts) | 把对话记录看作各个小节、沿四条轴走遍它们的光标、这些小节归入的各轮次,以及检视面板的标题 |
250
263
  | [`src/inspector.ts`](src/inspector.ts) | 停靠的检视面板:带模式徽标的边框面板、小节标题、带编号且会折行的各部分选择行、折叠后的各行,及其挂载的组件 |
@@ -327,7 +340,7 @@ runner 不向请求前缀添加任何内容;`/model` 切换像在浏览器中
327
340
 
328
341
  这些限制描述随发行版交付的终端表层;它们不是一般的 CLI 比较,也不是任务积压。
329
342
 
330
- - **同一时间一个会话**——`/resume`、`/sessions`、`/new` 与 `/fork` 在会话间移动终端,但只有绑定的 Agent 流式显示;浏览器可并排展示多个会话。
343
+ - **同一时间一个会话**——`/resume`、`/sessions`、`/new`、`/clear` 与 `/fork` 在会话间移动终端,但只有绑定的 Agent 流式显示;浏览器可并排展示多个会话。
331
344
  - **审批为一次性**——提示只提供允许一次或拒绝,与审批接缝的词汇一致;没有记忆的授权。
332
345
  - **仅浏览器的页面留在浏览器**——workspace 与目录选择器、在应用中打开的链接、轨迹账本与逐条消息的点赞/点踩没有终端对应物;`/settings`、`/plugins`、`/subagents`、`/outline` 与共享的 `/feedback` 以文本覆盖其事实,子 agent 的对话记录通过切换到子会话来阅读。
333
346
  - **交付物只列名、不打开**——`/deliverables` 列出交付路径,`/changes` 显示逐行对比;浏览器会预览这些文件。
@@ -2146,6 +2146,22 @@ function createPalette(enabled) {
2146
2146
  };
2147
2147
  }
2148
2148
  /**
2149
+ * Paint added and removed diff rows while leaving context and metadata rows
2150
+ * unchanged. `source` stays plain so syntax-colored rows can be classified.
2151
+ * @param rows - rows after optional syntax highlighting.
2152
+ * @param source - corresponding plain rows carrying the diff prefixes.
2153
+ * @param palette - active terminal palette.
2154
+ * @returns the rows with additions green and removals red.
2155
+ */
2156
+ function paintDiffRows(rows, source, palette) {
2157
+ return rows.map((row, index) => {
2158
+ const plain = source[index];
2159
+ if (plain?.startsWith("+ ") === true) return palette.success(row);
2160
+ if (plain?.startsWith("- ") === true) return palette.error(row);
2161
+ return row;
2162
+ });
2163
+ }
2164
+ /**
2149
2165
  * Decide whether the terminal gets color: `NO_COLOR` (any non-empty value)
2150
2166
  * wins, then a non-empty non-zero `FORCE_COLOR`, then whether stdout is a TTY.
2151
2167
  * @param env - the process environment.
@@ -2224,6 +2240,18 @@ function editorTheme(palette) {
2224
2240
  * content wraps at and is prepended after any fade recoloring, so the fade
2225
2241
  * keeps matching the block's own text and the gutter's styling never enters
2226
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.
2227
2255
  * @module @deepseek-ai/dsh-tui-app/blocks
2228
2256
  */
2229
2257
  /** Columns the focus gutter takes from the width a block's content wraps at. */
@@ -2285,6 +2313,85 @@ function withGutter(palette, lines, focused, level) {
2285
2313
  function markedRange(section, marker) {
2286
2314
  return section.to > section.from ? section : marker;
2287
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
+ };
2288
2395
  /** A prompt the user submitted, drawn with a leading `›`. */
2289
2396
  var UserBlock = class {
2290
2397
  theme;
@@ -2296,6 +2403,8 @@ var UserBlock = class {
2296
2403
  highlight;
2297
2404
  /** How far above its settled accent the focus mark is drawn right now. */
2298
2405
  highlightLevel = 0;
2406
+ /** The wrapped prompt, by width and whether the gutter narrowed it. */
2407
+ drawn = new LastDrawn();
2299
2408
  constructor(theme, text, turn) {
2300
2409
  this.theme = theme;
2301
2410
  this.text = text;
@@ -2319,11 +2428,15 @@ var UserBlock = class {
2319
2428
  this.highlight = part;
2320
2429
  this.highlightLevel = level;
2321
2430
  }
2322
- invalidate() {}
2431
+ invalidate() {
2432
+ this.drawn.clear();
2433
+ }
2323
2434
  render(width) {
2324
2435
  const palette = this.theme.palette;
2325
2436
  const { marked, content: inner } = focusFrame(width, this.highlight);
2326
- 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
+ });
2327
2440
  return marked ? withGutter(palette, lines, () => true, this.highlightLevel) : lines;
2328
2441
  }
2329
2442
  };
@@ -2367,6 +2480,8 @@ var ContextBlock = class {
2367
2480
  /** How far above its settled accent the focus mark is drawn right now. */
2368
2481
  highlightLevel = 0;
2369
2482
  expanded = false;
2483
+ /** The wrapped block, by width, fold, and whether the gutter narrowed it. */
2484
+ drawn = new LastDrawn();
2370
2485
  /**
2371
2486
  * @param theme - the palette the glyph and title are styled with.
2372
2487
  * @param title - form and producer, a notice summary, or `system prompt`.
@@ -2408,10 +2523,34 @@ var ContextBlock = class {
2408
2523
  setExpanded(expanded) {
2409
2524
  this.expanded = expanded;
2410
2525
  }
2411
- invalidate() {}
2526
+ invalidate() {
2527
+ this.drawn.clear();
2528
+ }
2412
2529
  render(width) {
2413
2530
  const palette = this.theme.palette;
2414
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;
2415
2554
  const textWidth = Math.max(1, inner - 2);
2416
2555
  const indent = (line) => ` ${line}`;
2417
2556
  const dimRows = (text) => wrapTextWithAnsi(text, textWidth).map((line) => indent(palette.dim(line)));
@@ -2430,19 +2569,14 @@ var ContextBlock = class {
2430
2569
  const kept = this.theme.contextPreviewLines;
2431
2570
  const cut = !this.expanded && body.length > kept;
2432
2571
  const shown = cut ? [...body.slice(0, kept), ...dimRows(foldMarker(body.length - kept, marked ? "marked" : "transcript"))] : body;
2433
- const lines = [...head, ...shown];
2434
- if (this.highlight === void 0) return lines;
2435
- const section = ranges[this.highlight];
2436
- if (section === void 0) return withGutter(palette, lines, () => true, this.highlightLevel);
2437
- const drawn = Math.min(section.to, cut ? kept : body.length);
2438
- const held = markedRange({
2439
- from: head.length + section.from,
2440
- to: head.length + drawn
2441
- }, {
2442
- from: head.length + (cut ? kept : body.length),
2443
- to: lines.length
2444
- });
2445
- 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
+ };
2446
2580
  }
2447
2581
  };
2448
2582
  /**
@@ -2478,11 +2612,18 @@ var AssistantBlock = class {
2478
2612
  highlight;
2479
2613
  /** How far above its settled accent the focus mark is drawn right now. */
2480
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;
2481
2621
  constructor(theme, turn) {
2482
2622
  this.theme = theme;
2483
2623
  this.turn = turn;
2484
2624
  const palette = theme.palette;
2485
- 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));
2486
2627
  this.reasoningText = new Text("", 0, 0);
2487
2628
  }
2488
2629
  /**
@@ -2546,6 +2687,7 @@ var AssistantBlock = class {
2546
2687
  */
2547
2688
  appendText(delta) {
2548
2689
  this.text += delta;
2690
+ this.revision += 1;
2549
2691
  this.markdown.setText(this.text);
2550
2692
  }
2551
2693
  /**
@@ -2554,6 +2696,7 @@ var AssistantBlock = class {
2554
2696
  */
2555
2697
  appendReasoning(delta) {
2556
2698
  this.reasoning += delta;
2699
+ this.revision += 1;
2557
2700
  this.reasoningText.setText(this.theme.palette.dim(this.theme.palette.italic(this.reasoning.trimEnd())));
2558
2701
  }
2559
2702
  /**
@@ -2566,6 +2709,7 @@ var AssistantBlock = class {
2566
2709
  this.text = text;
2567
2710
  this.reasoning = reasoning;
2568
2711
  this.interrupted = interrupted;
2712
+ this.revision += 1;
2569
2713
  this.fade = void 0;
2570
2714
  this.reasoningFade = void 0;
2571
2715
  this.markdown.setText(text);
@@ -2574,9 +2718,22 @@ var AssistantBlock = class {
2574
2718
  invalidate() {
2575
2719
  this.markdown.invalidate();
2576
2720
  this.reasoningText.invalidate();
2721
+ this.fences?.clear();
2722
+ this.drawn.clear();
2577
2723
  }
2578
2724
  render(width) {
2579
- 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) {
2580
2737
  const lines = [""];
2581
2738
  const reasoning = {
2582
2739
  from: 0,
@@ -2598,9 +2755,11 @@ var AssistantBlock = class {
2598
2755
  reply.to = lines.length;
2599
2756
  }
2600
2757
  if (this.interrupted) lines.push(this.theme.palette.dim("[interrupted]"));
2601
- if (this.highlight === void 0) return lines;
2602
- const section = this.parts()[this.highlight]?.kind === "reasoning" ? reasoning : reply;
2603
- return withGutter(this.theme.palette, lines, (index) => index >= section.from && index < section.to, this.highlightLevel);
2758
+ return {
2759
+ lines,
2760
+ reasoning,
2761
+ reply
2762
+ };
2604
2763
  }
2605
2764
  /**
2606
2765
  * The reasoning lines, with the streaming tail floated out toward dim italic.
@@ -2634,6 +2793,7 @@ var AssistantBlock = class {
2634
2793
  renderText(width, at) {
2635
2794
  const fade = this.fade;
2636
2795
  const lines = this.markdown.render(width);
2796
+ this.fences?.settle();
2637
2797
  if (fade === void 0) return lines;
2638
2798
  if (this.fadeWidth !== void 0 && this.fadeWidth !== width) fade.flush();
2639
2799
  this.fadeWidth = width;
@@ -2668,6 +2828,10 @@ var ToolBlock = class {
2668
2828
  highlight;
2669
2829
  /** How far above its settled accent the focus mark is drawn right now. */
2670
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;
2671
2835
  constructor(theme, name, call, turn) {
2672
2836
  this.theme = theme;
2673
2837
  this.name = name;
@@ -2740,6 +2904,7 @@ var ToolBlock = class {
2740
2904
  this.resultLines = lines;
2741
2905
  this.resultCode = code;
2742
2906
  this.status = isError ? "error" : "done";
2907
+ this.revision += 1;
2743
2908
  }
2744
2909
  /**
2745
2910
  * Whether the whole body is drawn right now.
@@ -2755,35 +2920,28 @@ var ToolBlock = class {
2755
2920
  setExpanded(expanded) {
2756
2921
  this.expanded = expanded;
2757
2922
  }
2758
- invalidate() {}
2923
+ invalidate() {
2924
+ this.drawn.clear();
2925
+ }
2759
2926
  render(width) {
2760
2927
  const palette = this.theme.palette;
2761
2928
  const { marked, content: outer } = focusFrame(width, this.highlight);
2762
- 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)}`}`;
2763
- const body = [...this.call.lines, ...this.resultLines];
2764
- 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)];
2765
- const shown = paintCodeRows(this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript")), code, this.theme.codeHighlight);
2766
- const callCount = Math.min(this.call.lines.length, shown.length);
2767
- const inner = Math.max(1, outer - 4);
2768
- const rows = (lines) => lines.flatMap((line) => wrapTextWithAnsi(line, inner).map((part) => ` ${palette.dim("│")} ${part}`));
2769
- const callLines = [...wrapTextWithAnsi(header, outer), ...rows(shown.slice(0, callCount))];
2770
- const resultLines = rows(shown.slice(callCount));
2771
- const call = faded(callLines, this.fade, this.repaintFloor - 1);
2772
- const result = faded(resultLines, this.resultFade, this.repaintFloor - 1 - callLines.length);
2773
- 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 : [
2774
2933
  "",
2775
2934
  ...call,
2776
2935
  ...result
2777
2936
  ];
2778
2937
  if (this.highlight === void 0) return lines;
2779
- const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
2780
- const sections = lines.length - (cut ? rows(shown.slice(-1)).length : 0);
2938
+ const sections = lines.length - layout.marker;
2781
2939
  const section = this.parts()[this.highlight]?.kind === "result" ? {
2782
- from: 1 + callLines.length,
2940
+ from: 1 + layout.call.length,
2783
2941
  to: lines.length
2784
2942
  } : {
2785
2943
  from: 1,
2786
- to: 1 + callLines.length
2944
+ to: 1 + layout.call.length
2787
2945
  };
2788
2946
  const held = markedRange({
2789
2947
  from: section.from,
@@ -2794,6 +2952,37 @@ var ToolBlock = class {
2794
2952
  });
2795
2953
  return withGutter(palette, lines, (index) => index >= held.from && index < held.to, this.highlightLevel);
2796
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
+ }
2797
2986
  };
2798
2987
  /**
2799
2988
  * Draw one group of a card's rows at the mix its fade reports.
@@ -3443,6 +3632,11 @@ const HINTS = {
3443
3632
  "↑↓ ←→ · Space folds · Esc input",
3444
3633
  "Esc input"
3445
3634
  ],
3635
+ queue: [
3636
+ "↑↓ prompts · S steer · I inject · E edit · Esc input",
3637
+ "S steer · I inject · E edit · Esc input",
3638
+ "Esc input"
3639
+ ],
3446
3640
  panel: [
3447
3641
  "↑↓ children · Enter details · Tab regions · Esc input",
3448
3642
  "↑↓ children · Esc input",
@@ -3463,6 +3657,7 @@ const HINTS = {
3463
3657
  const FOCUS_REGIONS = [
3464
3658
  "editor",
3465
3659
  "transcript",
3660
+ "queue",
3466
3661
  "panel",
3467
3662
  "bar"
3468
3663
  ];
@@ -3470,6 +3665,7 @@ const FOCUS_REGIONS = [
3470
3665
  const REGION_LABELS = {
3471
3666
  editor: "input",
3472
3667
  transcript: "conversation",
3668
+ queue: "queued prompts",
3473
3669
  panel: "subagent panel",
3474
3670
  bar: "status bar"
3475
3671
  };
@@ -3510,6 +3706,7 @@ const KEY_LINES = {
3510
3706
  "Ctrl+C clears the input, twice quits · Ctrl+D quits an empty input"
3511
3707
  ],
3512
3708
  transcript: [widestHint("transcript"), "Shift+↑↓ blocks · PgUp PgDn turns · Home End ends · Tab regions · Enter reads"],
3709
+ queue: [widestHint("queue")],
3513
3710
  panel: [widestHint("panel")],
3514
3711
  bar: [widestHint("bar")]
3515
3712
  };
@@ -3539,6 +3736,7 @@ function resolveKey(region, data) {
3539
3736
  switch (region) {
3540
3737
  case "editor": return editorKey(data);
3541
3738
  case "transcript": return transcriptKey(data);
3739
+ case "queue": return queueKey(data);
3542
3740
  case "panel": return panelKey(data);
3543
3741
  case "bar": return barKey(data);
3544
3742
  /* v8 ignore next 2 -- closed-union exhaustiveness guard */
@@ -3629,6 +3827,29 @@ const TRANSCRIPT_MOVES = [
3629
3827
  to: "last"
3630
3828
  }
3631
3829
  ];
3830
+ /** The pending-prompt panel's movement keys. */
3831
+ const QUEUE_MOVES = [
3832
+ {
3833
+ key: "up",
3834
+ axis: "prompt",
3835
+ to: "previous"
3836
+ },
3837
+ {
3838
+ key: "down",
3839
+ axis: "prompt",
3840
+ to: "next"
3841
+ },
3842
+ {
3843
+ key: "home",
3844
+ axis: "prompt",
3845
+ to: "first"
3846
+ },
3847
+ {
3848
+ key: "end",
3849
+ axis: "prompt",
3850
+ to: "last"
3851
+ }
3852
+ ];
3632
3853
  /**
3633
3854
  * The subagent panel's movement keys. The panel lists at most six rows, so
3634
3855
  * every coarse key means the same thing there: its first row or its last.
@@ -3763,6 +3984,28 @@ function transcriptKey(data) {
3763
3984
  return cycleKey(data) ?? typeKey(data);
3764
3985
  }
3765
3986
  /**
3987
+ * What one key means while the pending-prompt panel holds the keyboard.
3988
+ * @param data - the raw key bytes.
3989
+ * @returns the action, or undefined for a key the panel consumes without effect.
3990
+ */
3991
+ function queueKey(data) {
3992
+ const move = moveKey(data, QUEUE_MOVES);
3993
+ if (move !== void 0) return move;
3994
+ if (data === "s" || data === "S") return {
3995
+ kind: "queue",
3996
+ action: "steer"
3997
+ };
3998
+ if (data === "i" || data === "I") return {
3999
+ kind: "queue",
4000
+ action: "inject"
4001
+ };
4002
+ if (data === "e" || data === "E") return {
4003
+ kind: "queue",
4004
+ action: "edit"
4005
+ };
4006
+ return cycleKey(data) ?? typeKey(data);
4007
+ }
4008
+ /**
3766
4009
  * What one key means while the subagent panel holds the keyboard.
3767
4010
  * @param data - the raw key bytes.
3768
4011
  * @returns the action, or undefined for a key the panel consumes without effect.
@@ -5805,6 +6048,62 @@ var ModalQueue = class {
5805
6048
  this.active?.withdraw();
5806
6049
  }
5807
6050
  };
6051
+ //#endregion
6052
+ //#region lib/types/queue-panel.js
6053
+ /**
6054
+ * The pending-prompt panel above the editor. It presents the Agent inbox as a
6055
+ * framed, selectable list without mutating the messages it displays.
6056
+ * @module @deepseek-ai/dsh-tui-app/queue-panel
6057
+ */
6058
+ /**
6059
+ * Build the panel rows in claim order: next-step input before ordinary turns.
6060
+ * @param nextStep - messages waiting for the nearest step boundary.
6061
+ * @param nextTurn - messages waiting for separate turns.
6062
+ * @returns selectable pending-prompt rows.
6063
+ */
6064
+ function queuePanelRows(nextStep, nextTurn) {
6065
+ const row = (target, message) => ({
6066
+ message,
6067
+ target,
6068
+ text: contentText(message.content).split("\n", 1)[0] ?? ""
6069
+ });
6070
+ return [...nextStep.map((message) => row("next-step", message)), ...nextTurn.map((message) => row("next-turn", message))];
6071
+ }
6072
+ /**
6073
+ * Render the pending prompts inside a frame. A focused panel accents its held
6074
+ * row and names its actions; an unfocused panel names the key that enters it.
6075
+ * @param rows - pending prompts in claim order.
6076
+ * @param render - palette, terminal width, and optional selection.
6077
+ * @returns panel text, or the empty string when no prompt waits.
6078
+ */
6079
+ function renderQueuePanel(rows, render) {
6080
+ if (rows.length === 0) return "";
6081
+ const { palette, selected } = render;
6082
+ const width = Math.max(1, render.width);
6083
+ const tone = selected === void 0 ? "muted" : "focus";
6084
+ const title = `${String(rows.length)} pending`;
6085
+ const lines = [topRule({
6086
+ chip: chip(palette, "QUEUE"),
6087
+ title: palette.bold(title),
6088
+ width,
6089
+ palette,
6090
+ tone
6091
+ })];
6092
+ const room = Math.max(1, width - 2);
6093
+ for (const [index, row] of rows.entries()) {
6094
+ const label = row.target === "next-step" ? "next step" : "next turn";
6095
+ const text = `${selected === index ? palette.accent("▸ ") : " "}${palette.dim(`${label} ·`)} ${row.text}`;
6096
+ for (const wrapped of wrapTextWithAnsi(text, room)) lines.push(bodyLine(wrapped, width, palette, tone));
6097
+ }
6098
+ const hints = selected === void 0 ? ["Shift+↓ manages"] : HINTS.queue;
6099
+ lines.push(bottomRule({
6100
+ left: palette.dim(fitLegend(hints, ruleRoom(width))),
6101
+ width,
6102
+ palette,
6103
+ tone
6104
+ }));
6105
+ return lines.join("\n");
6106
+ }
5808
6107
  /** Narrowest turn list. */
5809
6108
  const LIST_MIN_WIDTH = 18;
5810
6109
  /** Widest turn list. */
@@ -7744,6 +8043,10 @@ const LOCAL_COMMANDS = [
7744
8043
  name: "new",
7745
8044
  description: "Start a new session"
7746
8045
  },
8046
+ {
8047
+ name: "clear",
8048
+ description: "Start a new session with empty context; previous session stays on disk (resumable with /resume)"
8049
+ },
7747
8050
  {
7748
8051
  name: "fork",
7749
8052
  description: "Fork this session at its last completed turn (/fork <turn> for an earlier one)"
@@ -7849,6 +8152,14 @@ var TuiApp = class {
7849
8152
  queueSlot = new Container();
7850
8153
  /** The prompts queued for the next turn or step, drawn above the editor until the loop claims them. */
7851
8154
  queue;
8155
+ /** Rows of the last queued-prompt draw, in claim order. */
8156
+ queueView = [];
8157
+ /** Pending prompt held while the queue panel owns the keyboard. */
8158
+ queueSelection;
8159
+ /** A removed queued prompt whose text is being revised in the editor. */
8160
+ queueDraft;
8161
+ /** Suppresses the empty-queue focus handoff during a synchronous inbox transfer. */
8162
+ transferringQueue = false;
7852
8163
  /** Holds {@link panel} exactly while the bound session has subagent rows. */
7853
8164
  panelSlot = new Container();
7854
8165
  /** Blank rows that give the mounted reader the whole viewport; see {@link ViewportPad}. */
@@ -8126,6 +8437,7 @@ var TuiApp = class {
8126
8437
  /** Release the terminal and tell the host to exit; later calls are no-ops. */
8127
8438
  stop() {
8128
8439
  if (this.stopped) return;
8440
+ this.restoreQueueDraft();
8129
8441
  this.stopped = true;
8130
8442
  this.updateTicker();
8131
8443
  this.updateFadeTicker();
@@ -8142,6 +8454,10 @@ var TuiApp = class {
8142
8454
  }
8143
8455
  /** Draw `next` as the terminal's session: clear the transcript and replay its history. */
8144
8456
  bind(next) {
8457
+ if (this.queueDraft !== void 0) {
8458
+ this.restoreQueueDraft();
8459
+ this.editor.setText("");
8460
+ }
8145
8461
  this.bound = next;
8146
8462
  const reading = this.dropReader();
8147
8463
  this.focusEditor();
@@ -8160,6 +8476,8 @@ var TuiApp = class {
8160
8476
  this.blockFades.clear();
8161
8477
  this.usage = EMPTY_USAGE;
8162
8478
  this.pending = [];
8479
+ this.queueView = [];
8480
+ this.queueSelection = void 0;
8163
8481
  this.subagentEntries = [];
8164
8482
  this.panelSelection = void 0;
8165
8483
  this.listingFailure = void 0;
@@ -8307,20 +8625,36 @@ var TuiApp = class {
8307
8625
  * directly under the conversation the rest of the time.
8308
8626
  */
8309
8627
  refreshQueue() {
8310
- const palette = this.deps.palette;
8311
8628
  const inbox = this.agent.inbox;
8312
- const row = (label, message) => `${palette.dim(`⏳ ${label}`)} ${contentText(message.content).split("\n", 1).join("")}`;
8313
- const rows = [...inbox.nextStep.map((message) => row("next step", message)), ...inbox.nextTurn.map((message) => row("next turn", message))];
8629
+ const rows = queuePanelRows(inbox.nextStep, inbox.nextTurn);
8630
+ this.queueView = rows;
8314
8631
  const mounted = this.queueSlot.children.length > 0;
8315
8632
  if (rows.length === 0) {
8633
+ this.queueSelection = void 0;
8634
+ if (this.focus === "queue" && !this.transferringQueue) this.focusEditor();
8316
8635
  if (mounted) this.queueSlot.removeChild(this.queue);
8317
8636
  } else {
8318
- this.queue.setText(rows.join("\n"));
8319
8637
  if (!mounted) this.queueSlot.addChild(this.queue);
8638
+ const selected = this.queueSelectionIndex(rows);
8639
+ this.queueSelection = rows[selected]?.message.id;
8640
+ this.queue.setText(renderQueuePanel(rows, {
8641
+ palette: this.deps.palette,
8642
+ width: this.deps.terminal.columns,
8643
+ ...this.focus === "queue" ? { selected } : {}
8644
+ }));
8320
8645
  }
8321
8646
  this.tui.requestRender();
8322
8647
  }
8323
8648
  /**
8649
+ * Locate the held pending prompt after inbox insertions and claims.
8650
+ * @param rows - current queue rows.
8651
+ * @returns the selected index, or 0 when the prior row left.
8652
+ */
8653
+ queueSelectionIndex(rows) {
8654
+ const index = rows.findIndex((row) => row.message.id === this.queueSelection);
8655
+ return index === -1 ? 0 : index;
8656
+ }
8657
+ /**
8324
8658
  * Redraw the panel from the last listing and a fresh sample of the live
8325
8659
  * facts. The panel is mounted exactly while it has a row, so the last
8326
8660
  * resident child leaving takes the panel with it — and the keyboard back to
@@ -8630,7 +8964,10 @@ var TuiApp = class {
8630
8964
  description: choice.description
8631
8965
  },
8632
8966
  heading: choice.label,
8633
- detail: () => changeDiffRows(this.deps.ctx, sessionId, choice, signal)
8967
+ detail: async () => {
8968
+ const rows = await changeDiffRows(this.deps.ctx, sessionId, choice, signal);
8969
+ return paintDiffRows(rows, rows, this.deps.palette);
8970
+ }
8634
8971
  })));
8635
8972
  }
8636
8973
  /**
@@ -8770,6 +9107,12 @@ var TuiApp = class {
8770
9107
  if (this.focus === "editor" && !matchesKey(data, "escape")) this.disarmStop();
8771
9108
  if (matchesKey(data, "ctrl+c")) {
8772
9109
  this.focusEditor();
9110
+ if (this.queueDraft !== void 0) {
9111
+ this.restoreQueueDraft();
9112
+ this.editor.setText("");
9113
+ this.notice("queued prompt edit canceled");
9114
+ return { consume: true };
9115
+ }
8773
9116
  const now = Date.now();
8774
9117
  if (now - this.lastCtrlC < QUIT_DOUBLE_PRESS_MS) {
8775
9118
  this.stop();
@@ -8830,6 +9173,9 @@ var TuiApp = class {
8830
9173
  case "steer":
8831
9174
  this.onSubmit(this.editor.getText(), "steer");
8832
9175
  return { consume: true };
9176
+ case "queue":
9177
+ this.actOnQueuedPrompt(action.action);
9178
+ return { consume: true };
8833
9179
  case "effort":
8834
9180
  if (this.switching) {
8835
9181
  this.notice(SESSION_SWITCH_WAIT, "error");
@@ -8984,6 +9330,7 @@ var TuiApp = class {
8984
9330
  this.readerOpening = void 0;
8985
9331
  this.cursor = exit.cursor;
8986
9332
  this.setFocus(exit.target);
9333
+ this.refreshQueue();
8987
9334
  this.refreshSubagentPanel();
8988
9335
  this.armEscapeHandoff();
8989
9336
  const motion = this.startMotion(4);
@@ -9023,6 +9370,9 @@ var TuiApp = class {
9023
9370
  case "part":
9024
9371
  this.moveTranscript(axis, to);
9025
9372
  return;
9373
+ case "prompt":
9374
+ this.moveQueueBy(to);
9375
+ return;
9026
9376
  case "row":
9027
9377
  this.movePanelBy(to);
9028
9378
  return;
@@ -9055,6 +9405,49 @@ var TuiApp = class {
9055
9405
  else this.moveCursor(next);
9056
9406
  }
9057
9407
  /**
9408
+ * Walk the queued-prompt selection, stopping at both ends.
9409
+ * @param to - which way along the pending prompts.
9410
+ */
9411
+ moveQueueBy(to) {
9412
+ const rows = this.queueView;
9413
+ const index = this.queueSelectionIndex(rows);
9414
+ const last = Math.max(0, rows.length - 1);
9415
+ const selected = to === "first" ? 0 : to === "last" ? last : to === "previous" ? Math.max(0, index - 1) : Math.min(last, index + 1);
9416
+ this.queueSelection = rows[selected]?.message.id;
9417
+ this.refreshQueue();
9418
+ }
9419
+ /** Apply one focused queue-panel command to the selected pending prompt. */
9420
+ actOnQueuedPrompt(action) {
9421
+ const row = this.queueView[this.queueSelectionIndex(this.queueView)];
9422
+ if (row === void 0) return;
9423
+ if (action === "edit") {
9424
+ if (!this.agent.inbox.remove(row.message.id)) {
9425
+ this.notice("that queued prompt was already claimed", "error");
9426
+ this.refreshQueue();
9427
+ return;
9428
+ }
9429
+ this.queueDraft = row.message;
9430
+ this.editor.setText(contentText(row.message.content));
9431
+ this.focusEditor();
9432
+ this.notice("editing queued prompt; Enter sends the revision");
9433
+ return;
9434
+ }
9435
+ this.transferringQueue = true;
9436
+ try {
9437
+ if (!this.agent.inbox.remove(row.message.id)) {
9438
+ this.notice("that queued prompt was already claimed", "error");
9439
+ return;
9440
+ }
9441
+ if (action === "steer") this.agent.steer(row.message);
9442
+ else this.agent.inject(row.message);
9443
+ } finally {
9444
+ this.transferringQueue = false;
9445
+ this.refreshQueue();
9446
+ this.refreshFooter();
9447
+ }
9448
+ this.notice(action === "steer" ? "queued prompt is steering the nearest step" : "queued prompt will be injected at the nearest step without waking the Agent");
9449
+ }
9450
+ /**
9058
9451
  * Walk the subagent panel's selection. Above the first row the walk
9059
9452
  * continues in the editor, below the last one at the status bar.
9060
9453
  * @param to - which way along the drawn rows.
@@ -9160,6 +9553,11 @@ var TuiApp = class {
9160
9553
  this.startChrome("selection", 4);
9161
9554
  this.refreshFooter();
9162
9555
  }
9556
+ /** Give the keyboard to the queued-prompt panel on one of its rows. */
9557
+ focusQueue(index) {
9558
+ this.queueSelection = this.queueView[index]?.message.id;
9559
+ this.focusRegion("queue");
9560
+ }
9163
9561
  /**
9164
9562
  * Give the keyboard to the subagent panel on one of its rows.
9165
9563
  * @param index - the row the selection lands on.
@@ -9169,11 +9567,12 @@ var TuiApp = class {
9169
9567
  this.focusRegion("panel");
9170
9568
  }
9171
9569
  /**
9172
- * Give the keyboard to the region under the editor: the subagent panel's
9173
- * first row while the panel is drawn, and the status bar otherwise.
9570
+ * Give `Shift+Down` to the pending-prompt panel when it is drawn, then the
9571
+ * first region below the editor.
9174
9572
  */
9175
9573
  focusBelowEditor() {
9176
- if (this.panelView.rows.length > 0) this.focusPanel(0);
9574
+ if (this.queueView.length > 0) this.focusQueue(0);
9575
+ else if (this.panelView.rows.length > 0) this.focusPanel(0);
9177
9576
  else this.focusBar();
9178
9577
  }
9179
9578
  /**
@@ -9211,14 +9610,14 @@ var TuiApp = class {
9211
9610
  this.tui.requestRender();
9212
9611
  }
9213
9612
  /**
9214
- * The regions drawn around the editor right now, in stack order: the
9215
- * conversation while it holds a section, the subagent panel while it has
9216
- * rows, and the status bar, which is always drawn.
9613
+ * The regions drawn around the editor right now, in screen order, except
9614
+ * that the editor itself is not part of the `Tab` walk.
9217
9615
  * @returns the regions `Tab` walks.
9218
9616
  */
9219
9617
  drawnRegions() {
9220
9618
  const drawn = [];
9221
9619
  if (this.transcriptEntry() !== void 0) drawn.push("transcript");
9620
+ if (this.queueView.length > 0) drawn.push("queue");
9222
9621
  if (this.panelView.rows.length > 0) drawn.push("panel");
9223
9622
  drawn.push("bar");
9224
9623
  return drawn;
@@ -9235,6 +9634,7 @@ var TuiApp = class {
9235
9634
  /* v8 ignore next -- the status bar is always drawn, so the wrapped index names a region */
9236
9635
  if (next === void 0) return;
9237
9636
  if (next === "transcript") this.focusTranscript();
9637
+ else if (next === "queue") this.focusQueue(this.queueSelectionIndex(this.queueView));
9238
9638
  else if (next === "panel") this.focusPanel(this.panelSelectionIndex(this.panelView.rows));
9239
9639
  else this.focusBar();
9240
9640
  }
@@ -9300,6 +9700,7 @@ var TuiApp = class {
9300
9700
  focusRegion(region) {
9301
9701
  if (this.focus === region) return;
9302
9702
  this.setFocus(region);
9703
+ this.refreshQueue();
9303
9704
  this.refreshSubagentPanel();
9304
9705
  }
9305
9706
  /**
@@ -9371,11 +9772,13 @@ var TuiApp = class {
9371
9772
  }
9372
9773
  this.editor.setText("");
9373
9774
  this.editor.addToHistory(text);
9374
- if (text.startsWith("/")) {
9775
+ const draft = this.queueDraft;
9776
+ this.queueDraft = void 0;
9777
+ if (draft === void 0 && text.startsWith("/")) {
9375
9778
  this.dispatchCommand(text);
9376
9779
  return;
9377
9780
  }
9378
- this.submit(text, mode);
9781
+ this.submit(text, mode, draft);
9379
9782
  }
9380
9783
  /**
9381
9784
  * Run one slash command and turn a rejection into a terminal notice.
@@ -9388,15 +9791,28 @@ var TuiApp = class {
9388
9791
  this.notice(`${name} failed: ${describeFailure(error)}`, "error");
9389
9792
  });
9390
9793
  }
9391
- submit(text, mode = "queue") {
9794
+ /** Return an abandoned edit to the ordinary-turn inbox without waking the Agent. */
9795
+ restoreQueueDraft() {
9796
+ const draft = this.queueDraft;
9797
+ if (draft === void 0) return;
9798
+ this.queueDraft = void 0;
9799
+ this.agent.inbox.append("next-turn", draft);
9800
+ this.refreshQueue();
9801
+ this.refreshFooter();
9802
+ }
9803
+ submit(text, mode = "queue", draft) {
9392
9804
  const agent = this.agent;
9393
9805
  const attachments = this.pending.splice(0);
9394
9806
  const message = createUserMessage({
9395
- content: [...attachments.map((attachment) => attachment.block), {
9396
- type: "text",
9397
- text
9398
- }],
9399
- source: { kind: "user" }
9807
+ content: [
9808
+ ...draft?.content.filter((block) => block.type !== "text") ?? [],
9809
+ ...attachments.map((attachment) => attachment.block),
9810
+ {
9811
+ type: "text",
9812
+ text
9813
+ }
9814
+ ],
9815
+ source: draft?.source ?? { kind: "user" }
9400
9816
  });
9401
9817
  if (agent.status !== "running") {
9402
9818
  this.submittedIds.add(message.id);
@@ -9443,6 +9859,7 @@ var TuiApp = class {
9443
9859
  await this.openSessionPicker();
9444
9860
  return;
9445
9861
  case "new":
9862
+ case "clear":
9446
9863
  await this.switchSession(() => this.deps.host.create(), "new session");
9447
9864
  return;
9448
9865
  case "fork": {
@@ -8,8 +8,8 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v22.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 15 Sep 2026 20:33:28 GMT
11
+ * Last updated: Sat, 19 Sep 2026 00:09:37 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
15
- These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [David Junger](https://github.com/touffy), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Sebastian Silbermann](https://github.com/eps1lon), [Wilco Bakker](https://github.com/WilcoBakker), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), [Dmitry Semigradsky](https://github.com/Semigradsky), and [René](https://github.com/Renegade334).
15
+ These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [David Junger](https://github.com/touffy), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Sebastian Silbermann](https://github.com/eps1lon), [Wilco Bakker](https://github.com/WilcoBakker), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), [Dmitry Semigradsky](https://github.com/Semigradsky), and [René](https://github.com/Renegade334).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.20.3",
3
+ "version": "22.20.4",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -50,11 +50,6 @@
50
50
  "githubUsername": "WilcoBakker",
51
51
  "url": "https://github.com/WilcoBakker"
52
52
  },
53
- {
54
- "name": "Marcin Kopacz",
55
- "githubUsername": "chyzwar",
56
- "url": "https://github.com/chyzwar"
57
- },
58
53
  {
59
54
  "name": "Trivikram Kamat",
60
55
  "githubUsername": "trivikr",
@@ -65,11 +60,6 @@
65
60
  "githubUsername": "yoursunny",
66
61
  "url": "https://github.com/yoursunny"
67
62
  },
68
- {
69
- "name": "Ilia Baryshnikov",
70
- "githubUsername": "qwelias",
71
- "url": "https://github.com/qwelias"
72
- },
73
63
  {
74
64
  "name": "ExE Boss",
75
65
  "githubUsername": "ExE-Boss",
@@ -85,11 +75,6 @@
85
75
  "githubUsername": "addaleax",
86
76
  "url": "https://github.com/addaleax"
87
77
  },
88
- {
89
- "name": "Victor Perin",
90
- "githubUsername": "victorperin",
91
- "url": "https://github.com/victorperin"
92
- },
93
78
  {
94
79
  "name": "NodeJS Contributors",
95
80
  "githubUsername": "NodeJS",
@@ -139,6 +124,6 @@
139
124
  "undici-types": "~6.21.0"
140
125
  },
141
126
  "peerDependencies": {},
142
- "typesPublisherContentHash": "96f0a72c6119022091f6102f750c1a5d1b46ea12c877c15cd9614b20c51cdbc0",
127
+ "typesPublisherContentHash": "05f54235bb066f4e83979e69cde16a4f509085e0d5636acc15e9f31672f72e74",
143
128
  "typeScriptVersion": "5.6"
144
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.23",
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",
@@ -370,7 +370,7 @@
370
370
  "@swc/helpers": "0.5.23",
371
371
  "@types/hast": "3.0.5",
372
372
  "@types/mdast": "4.0.4",
373
- "@types/node": "22.20.3",
373
+ "@types/node": "22.20.4",
374
374
  "@types/retry": "0.12.0",
375
375
  "@types/unist": "3.0.3",
376
376
  "@ungap/structured-clone": "1.4.0",