@songtonyli/dsh-cli 0.1.14 → 0.1.15

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.14; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.15; `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.14 (deepseek-harness 0.1.6-alpha.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.15 (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-1d90b61-dirty`;
163
+ return `0.1.6-alpha.2-b9dc981-dirty`;
164
164
  }
165
165
  /** Each panel row subscribes only to its own selection state. */
166
166
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -24,8 +24,8 @@
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
26
  "@types/react": "~18.3.1",
27
- "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2",
28
- "@deepseek-ai/cordis": "^4.0.2"
27
+ "@deepseek-ai/cordis": "^4.0.2",
28
+ "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2"
29
29
  },
30
30
  "files": [
31
31
  "lib/index.js",
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/bundle/tui-app/README.md
5
- README.md: 609455db6daa218a2d71ed685495d1e9a5ca7283
6
- README.zh.md: 4b943b769e10c62bfe960fb133f311d759f63093
5
+ README.md: 815424dd7f4c7f007714bf2e41214a0862df64f4
6
+ README.zh.md: 620b2cc2a27103b42ccd1c836f9507d7ebf3ecbd
@@ -40,9 +40,9 @@ 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 `›` (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. 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. 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 of key facts. 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, effort (`effort default` when the selection leaves reasoning to the model), and workspace path (shortened with `~` and `…/` when long) are always present; every other segment appears only when its fact exists — the permission preset, the running turn's elapsed time, cumulative token usage, the context window percentage, todo and goal and plan-mode markers from the projection seam, and the count of pending attachments — and `Shift+Down` expands the bar around the selected segment so that segment stays on screen. Compaction and model-request retries appear as notices, the same facts the browser's markers carry.
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 `⬡` row that includes the full model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. 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. 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 of key facts. 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, effort (`effort default` when the selection leaves reasoning to the model), and workspace path (shortened with `~` and `…/` when long) are always present; every other segment appears only when its fact exists — the permission preset, the running turn's elapsed time, cumulative token usage, the context window percentage, todo and goal and plan-mode markers from the projection seam, and the count of pending attachments — and `Shift+Down` expands the bar around the selected segment so that segment stays on screen. Compaction and model-request retries appear as notices, the same facts the browser's markers carry.
44
44
 
45
- While the keyboard walks the conversation an inspector is docked directly above the editor. It names the focused section — its position among the navigable blocks, the turn it belongs to, and what the section is, such as `3/12 · turn 2 · bash git status · result` — draws the block's parts as a strip like `‹ reasoning · reply ›` when it has more than one, shows the section's own source rows cut to `focusPreviewLines` with `… <n> more rows · Enter opens the page` under them, and ends with a dim line of the keys it answers. 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, 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 boundary 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 and its inspector heading reads `off screen` instead, and 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.
45
+ While the keyboard walks the conversation an inspector is docked directly above the editor. It names the focused section — its position among the navigable blocks, the turn it belongs to, and what the section is, such as `3/12 · turn 2 · bash git status · result` — draws the block's parts as a numbered wrapping strip like `← 1 reasoning · 2 reply →` when it has more than one, shows the section's own source rows — every row of a system prompt or injected context, otherwise cut to `focusPreviewLines` with `… <n> more rows · Enter opens the page` under them, and ends with a dim line of the keys it answers. 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, 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 boundary 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 and its inspector heading reads `off screen` instead, and 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.
46
46
 
47
47
  The subagent panel is drawn while a subagent session under the bound one is resident, or the listing carries a candidate it could not read. Unfocused it is one summary line with the listed count and the first child's key label; focused, its heading counts what it lists, and each row gives the child's depth indent, its label or id, its mode (`one-shot` or `continuable`), `resident`, whether its agent is `running` or `idle`, its elapsed time — the open turn's, else the total its settled turns took — and its token usage, as far as this process's own view of that child and the composed projections carry them. Six rows are drawn at most, with `+<n> more · /subagents lists them all` under them; a candidate the listing could not interpret draws as `unreadable: <reason>` and opens nothing, and a failed listing keeps the rows the last good one produced with `listing failed: <reason>` beneath. The panel disappears with its last row.
48
48
 
@@ -55,20 +55,20 @@ The subagent panel is drawn while a subagent session under the bound one is resi
55
55
  | `Shift+Enter` | Insert a newline |
56
56
  | `Shift+Tab` | While the editor has focus, cycle the current model's reasoning effort for the next request |
57
57
  | `Up` / `Down` | Recall earlier prompts |
58
- | `Shift+Up` | Focus the conversation on its newest block; from any region it jumps there |
59
- | `Shift+Down` | Focus the subagent panel's first row while it is drawn, and the status bar's first segment otherwise; from any region it jumps to the bar |
58
+ | `Shift+Up` | From the editor, panel, or bar, focus the conversation on its newest section; while the conversation has focus, walk to the previous section |
59
+ | `Shift+Down` | From the editor, focus the subagent panel's first row while it is drawn, and the status bar otherwise; from the panel, jump to the bar; while the conversation has focus, walk to the next section |
60
60
  | `Esc` | Stop the running turn; queued messages stay queued |
61
61
  | `Ctrl+O` | Expand or collapse every tool card |
62
62
  | `Ctrl+C` | Clear the editor; a second press within 600 ms quits |
63
63
  | `Ctrl+D` | Quit when the editor is empty |
64
64
 
65
- The conversation, the subagent panel, and the status bar stack in that order, and `Up` / `Down` walk the whole stack without wrapping at either end. While the conversation has focus, `Up` / `Down` move between blocks — your prompts, assistant messages, and tool cards, with notices and printed reports skipped — `Left` / `Right` move between a block's parts, which are the reasoning and the reply of a message and the call and the result of a tool, `Enter` opens the focused part as a read-only page carrying its full rows and comes back to the same part, and `Esc` returns focus to the editor. The rows a part carries are the block's own source text, so a reply reads as the Markdown the model wrote rather than the rendering drawn above. Every other key is consumed there, apart from `Ctrl+C` and `Ctrl+D`; a session switch drops the focus back to the editor, and a session with nothing to inspect yet answers `Shift+Up` with `nothing in the transcript to inspect yet` and leaves the keyboard in the editor.
65
+ The conversation, the subagent panel, and the status bar stack in that order, and `Up` / `Down` walk the whole stack without wrapping at either end. While the conversation has focus, `Up` / `Down` and `Shift+Up` / `Shift+Down` walk every section in reading order — a system prompt, injected context (each snapshot contribution as its own part), the reasoning and the reply of a message, the call and the result of a tool, and your prompts, with turn-end notices and printed reports skipped — `Left` / `Right` move between a block's parts without leaving the block, `Enter` opens the focused part as a read-only page carrying its full rows and comes back to the same part, and `Esc` returns focus to the editor. The rows a part carries are the block's own source text, so a reply reads as the Markdown the model wrote rather than the rendering drawn above. A message that streamed reasoning and then called a tool exposes that reasoning as its only section until visible text arrives, so the walk does not land on a blank reply. Every other key is consumed there, apart from `Ctrl+C` and `Ctrl+D`; a session switch drops the focus back to the editor, and a session with nothing to inspect yet answers `Shift+Up` with `nothing in the transcript to inspect yet` and leaves the keyboard in the editor.
66
66
 
67
- While the status bar has focus, `Left` / `Right`, `Shift+Left` / `Shift+Right`, and `Tab` / `Shift+Tab` move between segments and wrap at both ends, `Up` leaves the bar for the subagent panel's last row while it is drawn and for the conversation otherwise, `Enter` opens the selected segment while the bar keeps focus, and `Esc` returns focus to the editor. No other key reaches the editor while the bar has focus; `Ctrl+C` and `Ctrl+D` keep their usual meaning and return focus to the editor.
67
+ While the status bar has focus, `Left` / `Right`, `Shift+Left` / `Shift+Right`, and `Tab` / `Shift+Tab` move between segments and wrap at both ends, the second line expands the selected segment's most important details, `Up` leaves the bar for the subagent panel's last row while it is drawn and for the conversation otherwise, `Enter` opens the selected segment while the bar keeps focus, and `Esc` returns focus to the editor. No other key reaches the editor while the bar has focus; `Ctrl+C` and `Ctrl+D` keep their usual meaning and return focus to the editor.
68
68
 
69
69
  While the subagent panel has focus, `Up` / `Down` move the selection and continue into the neighboring regions at its ends — `Up` on the first row reaches the conversation and `Down` on the last row the status bar — `Enter` opens that child's session details as a read-only page and comes back to the panel on the same row, and `Esc` returns focus to the editor. Every other key is consumed there as well, apart from `Ctrl+C` and `Ctrl+D`; the panel also hands the keyboard back to the editor when its last row leaves.
70
70
 
71
- Every segment except `todo` prints its details into the transcript, stating its current facts and naming what changes them: the model segment names `/model`, the effort segment `Shift+Tab`, and the permission segment its preset, the `turn` segment — drawn as `turn <elapsed>` between the permission and usage segments, and only while a turn runs — gives the turn number, its start time, its elapsed time, and the queued-message counts, while the usage, context, goal, and plan segments print the matching sections of the `/status` report, the workspace segment the full path, and the attachments segment the pending attachments. The `todo` segment opens the agent's todo list instead, the same list `/todos` opens.
71
+ Every focused segment expands its most important facts on the second line. `Enter` prints those facts into the transcript for every segment except `todo`, stating what they are and what changes them: the model segment names `/model`, the effort segment `Shift+Tab`, and the permission segment its preset, the `turn` segment — drawn as `turn <elapsed>` between the permission and usage segments, and only while a turn runs — gives the turn number, its start time, its elapsed time, and the queued-message counts, while the usage, context, goal, and plan segments print the matching sections of the `/status` report, the workspace segment the full path, and the attachments segment the pending attachments. The `todo` segment expands the counts by status and the item being worked on, or the next pending item when none is in progress, and `Enter` opens the agent's todo list, the same list `/todos` opens.
72
72
 
73
73
  Typing `/` at the start of the editor completes the terminal's own commands and the shared registry's; `@` anywhere completes references.
74
74
 
@@ -147,7 +147,7 @@ The runner awaits the complete application (`ctx.get('loader')?.await()`) and bu
147
147
 
148
148
  ### Rendering model
149
149
 
150
- Durable facts come from the session log: `user/message` (own submissions are drawn once and their echo skipped by message id; a plugin notice is one dim row and other injected context is not drawn), `assistant/message` (which replaces the streamed block with the committed text and folds usage into the footer), `tool/call` and `tool/result` (drawn through the tool's `presentCall` and `presentResult` views when it declares them, with a raw-argument and raw-result fallback), `turn/end` notices, `workspace/changes` (one notice with the turn's file and line counts while the Host still holds the summary), `session/title` (header), `permission/preset` (footer), and `todo/write` under the enclosing `turn/start` (the turns one todo item's page reports; the list carries no per-item identity, so a reworded item counts as a new one). Live incrementality comes from `agent/assistant-stream` text and reasoning deltas. Session facts outside the log come from the same services the browser reads: `sessionTitle`, `permissionPresets`, `sessionQuery` for the picker, `/deliverables`, and subagent details, `sessionProjections` for the footer, `/status`, `/todos`, and `/outline`, `fileReferences` and `sessionReferenceResolver` for `@` completion, `attachments`, `skills`, `authorization`, `settings`, `subagents`, and the Loader's entries for `/plugins`. Modal prompts are process-local presentation and are never logged.
150
+ Durable facts come from the session log: `system/message` (a nonempty prompt draws in full; an empty rendering is omitted), `user/message` (own submissions are drawn once and their echo skipped by message id; injected context — instructions, catalogs, snapshots, notices, relays, recalls, and undeclared forms — draws in full as a dim `⬡` row, a snapshot as one named contribution per part; compaction replacements and tool or model sources are omitted), `assistant/message` (which replaces the streamed block with the committed text and folds usage into the footer), `tool/call` and `tool/result` (drawn through the tool's `presentCall` and `presentResult` views when it declares them, with a raw-argument and raw-result fallback), `turn/end` notices, `workspace/changes` (one notice with the turn's file and line counts while the Host still holds the summary), `session/title` (header), `permission/preset` (footer), and `todo/write` under the enclosing `turn/start` (the turns one todo item's page reports; the list carries no per-item identity, so a reworded item counts as a new one). Live incrementality comes from `agent/assistant-stream` text and reasoning deltas. Session facts outside the log come from the same services the browser reads: `sessionTitle`, `permissionPresets`, `sessionQuery` for the picker, `/deliverables`, and subagent details, `sessionProjections` for the footer, `/status`, `/todos`, and `/outline`, `fileReferences` and `sessionReferenceResolver` for `@` completion, `attachments`, `skills`, `authorization`, `settings`, `subagents`, and the Loader's entries for `/plugins`. Modal prompts are process-local presentation and are never logged.
151
151
 
152
152
  ### Patch surface over base
153
153
 
@@ -163,9 +163,10 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
163
163
  | [`src/sessions.ts`](src/sessions.ts) | The `/sessions` list over the query engine and its picker rows |
164
164
  | [`src/attach.ts`](src/attach.ts) | `/attach`: local files into image or file blocks through the attachment store |
165
165
  | [`src/export.ts`](src/export.ts) | `/export`: the session-log ZIP written through the export package's archive helpers |
166
- | [`src/blocks.ts`](src/blocks.ts) | Transcript components: user prompt, assistant reply, tool card, notice; the navigable blocks expose their sections and draw the focus gutter |
166
+ | [`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 |
167
+ | [`src/context.ts`](src/context.ts) | Project logged system prompts and injected user messages into transcript sections |
167
168
  | [`src/navigation.ts`](src/navigation.ts) | The transcript as sections, the cursor that walks them, and the inspector heading |
168
- | [`src/inspector.ts`](src/inspector.ts) | The docked inspector: the focused section's heading, parts strip, folded rows, and its mounted component |
169
+ | [`src/inspector.ts`](src/inspector.ts) | The docked inspector: the focused section's heading, numbered wrapping parts strip, rows, and its mounted component |
169
170
  | [`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, and the per-block repaint floor |
170
171
  | [`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 |
171
172
  | [`src/prompts.ts`](src/prompts.ts) | Approval, question, picker, and read-only detail prompts plus the modal queue |
@@ -185,6 +186,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
185
186
  | [`tests/commands.spec.ts`](tests/commands.spec.ts) | Session, attachment, queue, skill, sign-in, `/login`, Shift+Tab effort cycling, export, reference, and effort commands over scripted services |
186
187
  | [`tests/panels.spec.ts`](tests/panels.spec.ts) | Status footer and report, the navigable subagent and todo lists, catalog commands, command hints, and the approval detail |
187
188
  | [`tests/transcript-focus.spec.ts`](tests/transcript-focus.spec.ts) | Walking the conversation, the region stack, the inspector, and the in-place gutter inside the repaint window |
189
+ | [`tests/context.spec.ts`](tests/context.spec.ts) | Projection of system prompts and injected context into transcript sections |
188
190
  | [`tests/index.spec.ts`](tests/index.spec.ts) | Creation, resume paging, fork cut, session switching, quit flow, and failure reporting |
189
191
  | [`tests/startup.spec.ts`](tests/startup.spec.ts) | Command-line parsing over a real Loader tree |
190
192
  | [`../../../apps/cli/tests/profiles/tui/tests/keyless-smoke.e2e.ts`](../../../apps/cli/tests/profiles/tui/tests/keyless-smoke.e2e.ts) | The shipped profile through the real launcher with a keyless mock model |
@@ -234,7 +236,7 @@ These limits describe the terminal surface as shipped; they are not a general CL
234
236
  - **Approvals are one-shot** — the prompt offers allow once or reject, matching the approval seam's vocabulary; there is no remembered grant.
235
237
  - **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.
236
238
  - **Deliverables are named, not opened** — `/deliverables` lists the presented paths and `/changes` shows line comparisons; the browser previews the files.
237
- - **Terminal scrollback owns history** — the keyboard walks every block and part of the conversation, but there is no search and nothing folds beyond tool cards; the browser surface owns richer navigation.
239
+ - **Terminal scrollback owns history** — the keyboard walks every block and part of the conversation, including system prompts and injected context drawn in full, but there is no search and nothing else folds beyond tool cards; the browser surface owns richer navigation.
238
240
  - **A focused block that scrolled away is marked only in the inspector** — pi-tui repaints differentially just the last `rows` lines of the last frame it wrote and clears the terminal's scrollback to change anything above them, so a block further back gains no gutter and the inspector heading says `off screen`; a page that filled the terminal raises that boundary for good, so the block it was opened from can read `off screen` once the page closes, and its section still reads in the inspector and on the page `Enter` opens.
239
241
  - **The page shows source text** — `Enter` on an assistant reply opens the Markdown the model wrote, not the rendering the transcript draws, so tables and headings read as their source.
240
242
  - **The panel lists residency, not the tree** — a child joins it while its session record is resident in this process, so a subagent run by an out-of-process provider, which owns no session here, never appears; `/subagents` remains the way to every durable descendant.
@@ -40,9 +40,9 @@ dsh tui --no-open # print sign-in URLs without opening a
40
40
 
41
41
  ### 屏幕布局
42
42
 
43
- 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `›` 开头(附件列在其下),assistant 的推理以暗色显示在 Markdown 回复上方,每次工具调用是一张卡片,含状态符号、工具名、呈现器标题,以及折叠到 `toolPreviewLines` 行的正文。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。对话记录下方依次是 agent 工作时的旋转指示、任何打开的提示、编辑器、子 agent 面板,以及页脚:未聚焦时是一行关键事实的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型、推理强度(选择把推理交给模型时标为 `effort default`)以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)始终出现;其余分段只在其事实存在时出现——权限预设、正在进行轮次的已用时间、累计 token 用量、上下文窗口百分比、来自投影接缝的 todo、目标与计划模式标记、待发送附件数量——`Shift+Down` 展开状态栏并使所选分段留在屏幕上。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
43
+ 页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `›` 开头(附件列在其下),assistant 的推理以暗色显示在 Markdown 回复上方,每次工具调用是一张卡片,含状态符号、工具名、呈现器标题,以及折叠到 `toolPreviewLines` 行的正文。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 行,并带上完整的面向模型文本,快照的每一份贡献写在其自身各行上方;空的系统提示词与压缩替换则省略。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。对话记录下方依次是 agent 工作时的旋转指示、任何打开的提示、编辑器、子 agent 面板,以及页脚:未聚焦时是一行关键事实的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型、推理强度(选择把推理交给模型时标为 `effort default`)以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)始终出现;其余分段只在其事实存在时出现——权限预设、正在进行轮次的已用时间、累计 token 用量、上下文窗口百分比、来自投影接缝的 todo、目标与计划模式标记、待发送附件数量——`Shift+Down` 展开状态栏并使所选分段留在屏幕上。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
44
44
 
45
- 键盘在对话记录中移动时,编辑器正上方停靠着一个检视面板。它写出当前聚焦小节的名称——它在可导航块中的位置、所属轮次,以及这是哪一种小节,例如 `3/12 · turn 2 · bash git status · result`——在块含多个部分时把这些部分绘制成形如 `‹ reasoning · reply ›` 的一条选择行,把该小节自身的源文本行截到 `focusPreviewLines` 行并在其下写出 `… <n> more rows · Enter opens the page`,最后以一行暗色文字列出它所应答的按键。被聚焦的块也会在原地被标记:一条两列宽的标记条,在块的其他行旁为暗色、在被聚焦小节自身的行旁为强调色,标记绘制期间该块的内容按窄两列换行。这个标记只能落在 pi-tui 仍以差分方式重绘的行上——也就是它写出的上一帧的最后 `rows` 行,这条边界只会被更高的帧抬高、不会被更矮的帧降低——因为改动其上方的任何一行都会清空终端的回滚区;已经滚过该位置的块不带标记条,其检视面板标题改为写出 `off screen`;淡入中的各行抵达这一边界时,会在写出该帧的同一帧内被结算为最终颜色,因此回滚区里不会留下暗色文字。
45
+ 键盘在对话记录中移动时,编辑器正上方停靠着一个检视面板。它写出当前聚焦小节的名称——它在可导航块中的位置、所属轮次,以及这是哪一种小节,例如 `3/12 · turn 2 · bash git status · result`——在块含多个部分时把这些部分绘制成形如 `← 1 reasoning · 2 reply →` 的带编号、会折行的选择行,把该小节自身的源文本行画出来——系统提示词或注入上下文画出全部各行,其余截到 `focusPreviewLines` 行并在其下写出 `… <n> more rows · Enter opens the page`,最后以一行暗色文字列出它所应答的按键。被聚焦的块也会在原地被标记:一条两列宽的标记条,在块的其他行旁为暗色、在被聚焦小节自身的行旁为强调色,标记绘制期间该块的内容按窄两列换行。这个标记只能落在 pi-tui 仍以差分方式重绘的行上——也就是它写出的上一帧的最后 `rows` 行,这条边界只会被更高的帧抬高、不会被更矮的帧降低——因为改动其上方的任何一行都会清空终端的回滚区;已经滚过该位置的块不带标记条,其检视面板标题改为写出 `off screen`;淡入中的各行抵达这一边界时,会在写出该帧的同一帧内被结算为最终颜色,因此回滚区里不会留下暗色文字。
46
46
 
47
47
  子 agent 面板在绑定会话之下有常驻的子 agent 会话、或列表中带有无法读取的候选者时绘制。未聚焦时它是一行摘要,含列出的数量与第一个子会话的关键标签;聚焦时其标题统计所列出的条目,每一行给出该子会话的层级缩进、其标签或 id、其模式(`one-shot` 或 `continuable`)、`resident`、其 agent 处于 `running` 还是 `idle`、其已用时间——进行中轮次的用时,否则是已结束轮次的合计——以及其 token 用量,以本进程对该子会话的可见程度与已组合的投影所能提供的为限。最多绘制六行,其下是 `+<n> more · /subagents lists them all`;列表无法解读的候选者绘制为 `unreadable: <reason>` 且打不开任何页面,读取失败的列表则保留上一次成功读取产生的各行,并在其下写出 `listing failed: <reason>`。面板随其最后一行一同消失。
48
48
 
@@ -55,20 +55,20 @@ dsh tui --no-open # print sign-in URLs without opening a
55
55
  | `Shift+Enter` | 插入换行 |
56
56
  | `Shift+Tab` | 编辑器持有焦点时,循环切换当前模型的推理强度,从下一次请求生效 |
57
57
  | `Up` / `Down` | 调出先前的提示 |
58
- | `Shift+Up` | 把焦点放到对话记录的最新块上;在任何区域都直接跳过去 |
59
- | `Shift+Down` | 面板已绘制时把焦点放到其第一行,否则放到状态栏的第一个分段;在任何区域都直接跳到状态栏 |
58
+ | `Shift+Up` | 从编辑器、面板或状态栏把焦点放到对话记录的最新小节上;对话记录已持有焦点时,走到上一小节 |
59
+ | `Shift+Down` | 从编辑器把焦点放到子 agent 面板的第一行(面板已绘制时)或状态栏;从面板跳到状态栏;对话记录已持有焦点时,走到下一小节 |
60
60
  | `Esc` | 停止正在进行的轮次;已排队的消息保持排队 |
61
61
  | `Ctrl+O` | 展开或折叠所有工具卡片 |
62
62
  | `Ctrl+C` | 清空编辑器;600 ms 内再按一次则退出 |
63
63
  | `Ctrl+D` | 编辑器为空时退出 |
64
64
 
65
- 对话记录、子 agent 面板与状态栏按此顺序自上而下排布,`Up` / `Down` 走遍整个序列且在两端都不环绕。对话记录持有焦点时,`Up` / `Down` 在块之间移动——你的提示、assistant 消息与工具卡片,通知与打印出的报告会被跳过——`Left` / `Right` 在块的各部分之间移动,也就是一条消息的推理与回复、一次工具调用的调用与结果,`Enter` 把当前聚焦的部分作为只读页面打开、其中带有该部分的完整各行,离开后回到同一部分,`Esc` 把焦点交还编辑器。各部分承载的是块自身的源文本,因此一条回复读到的是模型写下的 Markdown,而不是其上方绘制出的渲染结果。除 `Ctrl+C` 与 `Ctrl+D` 外,其他按键都在此被消费;切换会话会把焦点交回编辑器,尚无可查看内容的会话对 `Shift+Up` 回以 `nothing in the transcript to inspect yet` 并把键盘留在编辑器。
65
+ 对话记录、子 agent 面板与状态栏按此顺序自上而下排布,`Up` / `Down` 走遍整个序列且在两端都不环绕。对话记录持有焦点时,`Up` / `Down` 与 `Shift+Up` / `Shift+Down` 按阅读顺序走遍每一个小节——系统提示词、注入的上下文(快照的每一份贡献各自作为一部分)、一条消息的推理与回复、一次工具调用的调用与结果,以及你的提示,轮次结束通知与打印出的报告会被跳过——`Left` / `Right` 在块的各部分之间移动且不离开该块,`Enter` 把当前聚焦的部分作为只读页面打开、其中带有该部分的完整各行,离开后回到同一部分,`Esc` 把焦点交还编辑器。各部分承载的是块自身的源文本,因此一条回复读到的是模型写下的 Markdown,而不是其上方绘制出的渲染结果。一条先流出推理再调用工具的消息在可见文本到来之前只暴露推理小节,因此走查不会落在空白回复上。除 `Ctrl+C` 与 `Ctrl+D` 外,其他按键都在此被消费;切换会话会把焦点交回编辑器,尚无可查看内容的会话对 `Shift+Up` 回以 `nothing in the transcript to inspect yet` 并把键盘留在编辑器。
66
66
 
67
- 状态栏持有焦点时,`Left` / `Right`、`Shift+Left` / `Shift+Right` 与 `Tab` / `Shift+Tab` 在分段之间移动并在两端环绕,`Up` 在面板已绘制时离开状态栏前往面板的最后一行、否则前往对话记录,`Enter` 打开所选分段且状态栏保持焦点,`Esc` 把焦点交还编辑器。状态栏持有焦点期间其他按键不会到达编辑器;`Ctrl+C` 与 `Ctrl+D` 保持其一贯含义,并把焦点交还编辑器。
67
+ 状态栏持有焦点时,`Left` / `Right`、`Shift+Left` / `Shift+Right` 与 `Tab` / `Shift+Tab` 在分段之间移动并在两端环绕,第二行展开所选分段最重要的详情,`Up` 在面板已绘制时离开状态栏前往面板的最后一行、否则前往对话记录,`Enter` 打开所选分段且状态栏保持焦点,`Esc` 把焦点交还编辑器。状态栏持有焦点期间其他按键不会到达编辑器;`Ctrl+C` 与 `Ctrl+D` 保持其一贯含义,并把焦点交还编辑器。
68
68
 
69
69
  子 agent 面板持有焦点时,`Up` / `Down` 移动选择,并在其两端继续进入相邻区域——在第一行按 `Up` 到达对话记录,在最后一行按 `Down` 到达状态栏——`Enter` 把该子会话的详情作为只读页面打开、离开后回到面板的同一行,`Esc` 把焦点交还编辑器。除 `Ctrl+C` 与 `Ctrl+D` 外,其他按键同样在此被消费;面板的最后一行离开时,它也会把键盘交还编辑器。
70
70
 
71
- 除 `todo` 之外的每个分段都把详情打印到对话记录,陈述其当前事实并指出改变它们的方式:模型分段指出 `/model`,推理强度分段指出 `Shift+Tab`,权限分段指出其预设;`turn` 分段——绘制在权限与用量分段之间、形如 `turn <elapsed>`,且只在轮次进行时出现——给出轮次编号、其开始时间、已用时间与排队消息数量;用量、上下文、目标与计划分段打印 `/status` 报告中对应的小节,workspace 分段显示完整路径,附件分段列出待发送的附件。`todo` 分段则改为打开 agent 的 todo 列表,与 `/todos` 打开的是同一个列表。
71
+ 每个聚焦的分段都在第二行展开其最重要的事实。除 `todo` 之外,`Enter` 把这些事实打印到对话记录,并指出改变它们的方式:模型分段指出 `/model`,推理强度分段指出 `Shift+Tab`,权限分段指出其预设;`turn` 分段——绘制在权限与用量分段之间、形如 `turn <elapsed>`,且只在轮次进行时出现——给出轮次编号、其开始时间、已用时间与排队消息数量;用量、上下文、目标与计划分段打印 `/status` 报告中对应的小节,workspace 分段显示完整路径,附件分段列出待发送的附件。`todo` 分段展开按状态统计的计数以及正在进行的条目(若无正在进行的条目则为下一条待办),`Enter` 打开 agent 的 todo 列表,与 `/todos` 打开的是同一个列表。
72
72
 
73
73
  在编辑器开头输入 `/` 会补全终端自身的命令与共享注册表的命令;任意位置的 `@` 补全引用。
74
74
 
@@ -147,7 +147,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
147
147
 
148
148
  ### 渲染模型
149
149
 
150
- 持久事实来自会话日志:`user/message`(自己提交的消息只绘制一次,其回显按消息 id 跳过;插件通知是一行暗色文字,其他注入的上下文不绘制)、`assistant/message`(用已提交文本替换流式块,并把用量折入页脚)、`tool/call` 与 `tool/result`(工具声明 `presentCall` 与 `presentResult` 视图时据此绘制,否则回退到原始参数与原始结果)、`turn/end` 通知、`workspace/changes`(在 Host 仍保存摘要时,以一行通知给出该轮的文件数与行数)、`session/title`(页眉)、`permission/preset`(页脚),以及所属 `turn/start` 之下的 `todo/write`(某条 todo 的详情页所报告的轮次;该列表不带逐条标识,因此改写措辞的条目算作新条目)。实时增量来自 `agent/assistant-stream` 的文本与推理增量。日志之外的会话事实来自浏览器读取的同一批服务:`sessionTitle`、`permissionPresets`、供选择器、`/deliverables` 与子 agent 详情使用的 `sessionQuery`、供页脚、`/status`、`/todos` 与 `/outline` 使用的 `sessionProjections`、供 `@` 补全使用的 `fileReferences` 与 `sessionReferenceResolver`、`attachments`、`skills`、`authorization`、`settings`、`subagents`,以及供 `/plugins` 使用的 Loader 条目。模态提示是进程本地的呈现,从不写入日志。
150
+ 持久事实来自会话日志:`system/message`(非空提示词完整画出;空的绘制则省略)、`user/message`(自己提交的消息只绘制一次,其回显按消息 id 跳过;注入的上下文——instructions、catalogs、snapshots、notices、relays、recalls 以及未声明的形式——以暗色 `⬡` 行完整画出,快照按具名贡献各成一部分;压缩替换以及工具或模型来源则省略)、`assistant/message`(用已提交文本替换流式块,并把用量折入页脚)、`tool/call` 与 `tool/result`(工具声明 `presentCall` 与 `presentResult` 视图时据此绘制,否则回退到原始参数与原始结果)、`turn/end` 通知、`workspace/changes`(在 Host 仍保存摘要时,以一行通知给出该轮的文件数与行数)、`session/title`(页眉)、`permission/preset`(页脚),以及所属 `turn/start` 之下的 `todo/write`(某条 todo 的详情页所报告的轮次;该列表不带逐条标识,因此改写措辞的条目算作新条目)。实时增量来自 `agent/assistant-stream` 的文本与推理增量。日志之外的会话事实来自浏览器读取的同一批服务:`sessionTitle`、`permissionPresets`、供选择器、`/deliverables` 与子 agent 详情使用的 `sessionQuery`、供页脚、`/status`、`/todos` 与 `/outline` 使用的 `sessionProjections`、供 `@` 补全使用的 `fileReferences` 与 `sessionReferenceResolver`、`attachments`、`skills`、`authorization`、`settings`、`subagents`,以及供 `/plugins` 使用的 Loader 条目。模态提示是进程本地的呈现,从不写入日志。
151
151
 
152
152
  ### 基于 base 的 patch 面
153
153
 
@@ -163,9 +163,10 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
163
163
  | [`src/sessions.ts`](src/sessions.ts) | 基于查询引擎的 `/sessions` 列表及其选择器行 |
164
164
  | [`src/attach.ts`](src/attach.ts) | `/attach`:本地文件经附件存储成为图片或文件块 |
165
165
  | [`src/export.ts`](src/export.ts) | `/export`:通过导出包的归档辅助函数写出会话日志 ZIP |
166
- | [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、通知;可导航的块还暴露其各小节并绘制焦点标记条 |
166
+ | [`src/blocks.ts`](src/blocks.ts) | 对话记录组件:用户提示、assistant 回复、工具卡片、系统提示词与注入上下文、通知;可导航的块还暴露其各小节并绘制焦点标记条 |
167
+ | [`src/context.ts`](src/context.ts) | 把已记录的系统提示词与注入的用户消息投影为对话记录小节 |
167
168
  | [`src/navigation.ts`](src/navigation.ts) | 把对话记录看作各个小节、走遍它们的光标,以及检视面板的标题 |
168
- | [`src/inspector.ts`](src/inspector.ts) | 停靠的检视面板:聚焦小节的标题、各部分选择行、折叠后的各行,及其挂载的组件 |
169
+ | [`src/inspector.ts`](src/inspector.ts) | 停靠的检视面板:聚焦小节的标题、带编号且会折行的各部分选择行、各行,及其挂载的组件 |
169
170
  | [`src/screen.ts`](src/screen.ts) | 在构建一帧与写出该帧之间带若干次结算的主屏幕、每次结算所依据的重绘窗口,以及每个块的重绘下界 |
170
171
  | [`src/fade.ts`](src/fade.ts) | 流式文本淡入与浮出:基于挂钟的尾部追踪器、块时钟与注册表、淡入亮度级别、浮出混合,以及对已渲染行的重新着色 |
171
172
  | [`src/prompts.ts`](src/prompts.ts) | 审批、提问、选择器与只读详情提示以及模态队列 |
@@ -185,6 +186,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
185
186
  | [`tests/commands.spec.ts`](tests/commands.spec.ts) | 基于脚本化服务的会话、附件、队列、技能、登录、`/login`、Shift+Tab 推理强度循环、导出、引用与推理强度命令 |
186
187
  | [`tests/panels.spec.ts`](tests/panels.spec.ts) | 状态页脚与报告、可导航的子 agent 与 todo 列表、目录命令、命令提示与审批详情 |
187
188
  | [`tests/transcript-focus.spec.ts`](tests/transcript-focus.spec.ts) | 走遍对话记录、区域序列、检视面板,以及重绘窗口内的原地标记条 |
189
+ | [`tests/context.spec.ts`](tests/context.spec.ts) | 把系统提示词与注入上下文投影为对话记录小节 |
188
190
  | [`tests/index.spec.ts`](tests/index.spec.ts) | 创建、恢复分页、fork 切割、会话切换、退出流程与失败报告 |
189
191
  | [`tests/startup.spec.ts`](tests/startup.spec.ts) | 基于真实 Loader 配置树的命令行解析 |
190
192
  | [`../../../apps/cli/tests/profiles/tui/tests/keyless-smoke.e2e.ts`](../../../apps/cli/tests/profiles/tui/tests/keyless-smoke.e2e.ts) | 通过真实启动器与免密钥模拟模型运行随附 profile |
@@ -234,7 +236,7 @@ runner 不向请求前缀添加任何内容;`/model` 切换像在浏览器中
234
236
  - **审批为一次性**——提示只提供允许一次或拒绝,与审批接缝的词汇一致;没有记忆的授权。
235
237
  - **仅浏览器的页面留在浏览器**——workspace 与目录选择器、在应用中打开的链接、轨迹账本与逐条消息的点赞/点踩没有终端对应物;`/settings`、`/plugins`、`/subagents`、`/outline` 与共享的 `/feedback` 以文本覆盖其事实,子 agent 的对话记录通过切换到子会话来阅读。
236
238
  - **交付物只列名、不打开**——`/deliverables` 列出交付路径,`/changes` 显示逐行对比;浏览器会预览这些文件。
237
- - **历史由终端回滚区持有**——键盘可以走遍对话记录的每个块与每个部分,但没有搜索,除工具卡片外也没有折叠;更丰富的导航由浏览器表层持有。
239
+ - **历史由终端回滚区持有**——键盘可以走遍对话记录的每个块与每个部分,包括完整画出的系统提示词与注入上下文,但没有搜索;除工具卡片外,其余内容都不折叠;更丰富的导航由浏览器表层持有。
238
240
  - **滚走的聚焦块只在检视面板中被标记**——pi-tui 只对它写出的上一帧的最后 `rows` 行做差分重绘,要改动其上方的内容就得清空终端回滚区,因此更靠前的块得不到标记条,检视面板标题写出 `off screen`;占满终端的页面会把这条边界永久抬高,因此页面关闭后,打开它的那个块也可能写出 `off screen`;该小节仍可在检视面板中、以及 `Enter` 打开的页面上阅读。
239
241
  - **页面显示的是源文本**——在 assistant 回复上按 `Enter` 打开的是模型写下的 Markdown,而不是对话记录绘制出的渲染结果,因此表格与标题以源码形式呈现。
240
242
  - **面板列出的是常驻,而不是整棵树**——子会话在其会话记录常驻于本进程期间加入面板,因此由进程外提供方运行、在此没有自己会话的子 agent 永远不会出现;`/subagents` 仍是到达每一个持久后代的途径。
@@ -1962,16 +1962,18 @@ function editorTheme(palette) {
1962
1962
  //#region lib/types/blocks.js
1963
1963
  /**
1964
1964
  * Transcript components: one pi-tui component per rendered fact (a user
1965
- * prompt, an assistant reply, a tool card, a notice). Each owns its display
1966
- * state and re-renders from it at any width.
1965
+ * prompt, an assistant reply, a tool card, a system prompt or injected
1966
+ * context, a notice). Each owns its display state and re-renders from it at
1967
+ * any width.
1967
1968
  *
1968
- * The prompt, the reply, and the tool card are also the navigable blocks the
1969
- * keyboard walks (`./navigation.ts`): each reports its sections as plain source
1970
- * rows and draws a two-column gutter beside them while it holds the focus -
1971
- * accented on the focused section's own lines and dim on the rest of the
1972
- * block. The gutter narrows the width the block's content wraps at and is
1973
- * prepended after any fade recoloring, so the fade keeps matching the block's
1974
- * own text and the gutter's styling never enters that match.
1969
+ * The prompt, the reply, the tool card, and the compact context row are also
1970
+ * the navigable blocks the keyboard walks (`./navigation.ts`): each reports
1971
+ * its sections as plain source rows and draws a two-column gutter beside them
1972
+ * while it holds the focus - accented on the focused section's own lines and
1973
+ * dim on the rest of the block. The gutter narrows the width the block's
1974
+ * content wraps at and is prepended after any fade recoloring, so the fade
1975
+ * keeps matching the block's own text and the gutter's styling never enters
1976
+ * that match.
1975
1977
  * @module @deepseek-ai/dsh-tui-app/blocks
1976
1978
  */
1977
1979
  /** Columns the focus gutter takes from the width a block's content wraps at. */
@@ -2020,7 +2022,7 @@ var UserBlock = class {
2020
2022
  }
2021
2023
  /**
2022
2024
  * Draw this prompt with the focus gutter, or without it.
2023
- * @param part - the focused section, or undefined to clear the mark.
2025
+ * @param part - the index of the focused section, or undefined to clear the mark.
2024
2026
  */
2025
2027
  setHighlight(part) {
2026
2028
  this.highlight = part;
@@ -2034,6 +2036,8 @@ var UserBlock = class {
2034
2036
  return marked ? withGutter(palette, lines, () => true) : lines;
2035
2037
  }
2036
2038
  };
2039
+ /** What a compact context row uses in place of the user prompt's `›`. */
2040
+ const CONTEXT_GLYPH = "⬡";
2037
2041
  /** A dim one-line notice about the session (a stopped turn, a command result, a model switch). */
2038
2042
  var NoticeBlock = class {
2039
2043
  text;
@@ -2049,6 +2053,72 @@ var NoticeBlock = class {
2049
2053
  }
2050
2054
  };
2051
2055
  /**
2056
+ * A system prompt or injected context, drawn in full under a dim title.
2057
+ * Snapshot contributions keep their names above their own rows so every
2058
+ * piece of context is visible in the transcript; the inspector Left/Right
2059
+ * walk still addresses one contribution at a time.
2060
+ */
2061
+ var ContextBlock = class {
2062
+ theme;
2063
+ title;
2064
+ sectionParts;
2065
+ turn;
2066
+ navigable = true;
2067
+ blockKind = "context";
2068
+ /** The section drawn as focused; absent while the keyboard is elsewhere. */
2069
+ highlight;
2070
+ /**
2071
+ * @param theme - the palette the glyph and title are styled with.
2072
+ * @param title - form and producer, a notice summary, or `system prompt`.
2073
+ * @param sectionParts - the model-facing rows, one part per snapshot contribution.
2074
+ * @param turn - the turn the message was appended in.
2075
+ */
2076
+ constructor(theme, title, sectionParts, turn) {
2077
+ this.theme = theme;
2078
+ this.title = title;
2079
+ this.sectionParts = sectionParts;
2080
+ this.turn = turn;
2081
+ }
2082
+ /**
2083
+ * The injection as navigable sections.
2084
+ * @returns the parts the constructor was given.
2085
+ */
2086
+ parts() {
2087
+ return this.sectionParts;
2088
+ }
2089
+ /**
2090
+ * Draw this row with the focus gutter, or without it.
2091
+ * @param part - the index of the focused section, or undefined to clear the mark.
2092
+ */
2093
+ setHighlight(part) {
2094
+ this.highlight = part;
2095
+ }
2096
+ invalidate() {}
2097
+ render(width) {
2098
+ const palette = this.theme.palette;
2099
+ const inner = this.highlight !== void 0 ? Math.max(1, width - GUTTER_WIDTH) : width;
2100
+ const textWidth = Math.max(1, inner - 2);
2101
+ const indent = (line) => ` ${line}`;
2102
+ const lines = ["", ...wrapTextWithAnsi(this.title, textWidth).map((line, index) => `${palette.dim(index === 0 ? CONTEXT_GLYPH : " ")} ${palette.dim(line)}`)];
2103
+ const ranges = [];
2104
+ for (const part of this.sectionParts) {
2105
+ const from = lines.length;
2106
+ if (part.label !== void 0) lines.push(...wrapTextWithAnsi(part.label, textWidth).map((line) => indent(palette.bold(line))));
2107
+ if (!(part.rows.length === 1 && part.rows[0] === "")) for (const row of part.rows) lines.push(...wrapTextWithAnsi(row, textWidth).map((line) => indent(palette.dim(line))));
2108
+ ranges.push({
2109
+ from,
2110
+ to: lines.length
2111
+ });
2112
+ }
2113
+ if (this.highlight === void 0) return lines;
2114
+ const section = ranges[this.highlight] ?? {
2115
+ from: 0,
2116
+ to: lines.length
2117
+ };
2118
+ return withGutter(palette, lines, (line) => line >= section.from && line < section.to);
2119
+ }
2120
+ };
2121
+ /**
2052
2122
  * An assistant reply: streamed reasoning above streamed Markdown text. The
2053
2123
  * durable `assistant/message` replaces both with the committed content.
2054
2124
  *
@@ -2091,7 +2161,8 @@ var AssistantBlock = class {
2091
2161
  * reasoning as it was streamed or committed, and the reply as Markdown
2092
2162
  * source rather than the rendering the transcript draws.
2093
2163
  * @returns the reasoning part while the message has reasoning, then the
2094
- * reply, which is present from the start and empty until text arrives.
2164
+ * reply once visible text has arrived. An empty reply is kept only while the
2165
+ * message has no reasoning, so a tool-call step does not add a blank section.
2095
2166
  */
2096
2167
  parts() {
2097
2168
  const parts = [];
@@ -2099,7 +2170,7 @@ var AssistantBlock = class {
2099
2170
  kind: "reasoning",
2100
2171
  rows: this.reasoning.split("\n")
2101
2172
  });
2102
- parts.push({
2173
+ if (this.text !== "" || parts.length === 0) parts.push({
2103
2174
  kind: "reply",
2104
2175
  rows: this.text.split("\n")
2105
2176
  });
@@ -2107,7 +2178,7 @@ var AssistantBlock = class {
2107
2178
  }
2108
2179
  /**
2109
2180
  * Draw this message with the focus gutter, or without it.
2110
- * @param part - the focused section, or undefined to clear the mark.
2181
+ * @param part - the index of the focused section, or undefined to clear the mark.
2111
2182
  */
2112
2183
  setHighlight(part) {
2113
2184
  this.highlight = part;
@@ -2175,8 +2246,7 @@ var AssistantBlock = class {
2175
2246
  this.reasoningText.invalidate();
2176
2247
  }
2177
2248
  render(width) {
2178
- const marked = this.highlight !== void 0;
2179
- const inner = marked ? Math.max(1, width - GUTTER_WIDTH) : width;
2249
+ const inner = this.highlight !== void 0 ? Math.max(1, width - GUTTER_WIDTH) : width;
2180
2250
  const lines = [""];
2181
2251
  const reasoning = {
2182
2252
  from: 0,
@@ -2198,8 +2268,8 @@ var AssistantBlock = class {
2198
2268
  reply.to = lines.length;
2199
2269
  }
2200
2270
  if (this.interrupted) lines.push(this.theme.palette.dim("[interrupted]"));
2201
- if (!marked) return lines;
2202
- const section = this.highlight === "reasoning" ? reasoning : reply;
2271
+ if (this.highlight === void 0) return lines;
2272
+ const section = this.parts()[this.highlight]?.kind === "reasoning" ? reasoning : reply;
2203
2273
  return withGutter(this.theme.palette, lines, (index) => index >= section.from && index < section.to);
2204
2274
  }
2205
2275
  /**
@@ -2292,7 +2362,7 @@ var ToolBlock = class {
2292
2362
  }
2293
2363
  /**
2294
2364
  * Draw this card with the focus gutter, or without it.
2295
- * @param part - the focused section, or undefined to clear the mark.
2365
+ * @param part - the index of the focused section, or undefined to clear the mark.
2296
2366
  */
2297
2367
  setHighlight(part) {
2298
2368
  this.highlight = part;
@@ -2343,8 +2413,7 @@ var ToolBlock = class {
2343
2413
  invalidate() {}
2344
2414
  render(width) {
2345
2415
  const palette = this.theme.palette;
2346
- const marked = this.highlight !== void 0;
2347
- const outer = marked ? Math.max(1, width - GUTTER_WIDTH) : width;
2416
+ const outer = this.highlight !== void 0 ? Math.max(1, width - GUTTER_WIDTH) : width;
2348
2417
  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)}`}`;
2349
2418
  const body = [...this.call.lines, ...this.resultLines];
2350
2419
  const shown = previewLines(body, this.theme.toolPreviewLines, this.expanded);
@@ -2360,10 +2429,10 @@ var ToolBlock = class {
2360
2429
  ...call,
2361
2430
  ...result
2362
2431
  ];
2363
- if (!marked) return lines;
2432
+ if (this.highlight === void 0) return lines;
2364
2433
  const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
2365
2434
  const sections = lines.length - (cut ? rows(shown.slice(-1)).length : 0);
2366
- const section = this.highlight === "result" ? {
2435
+ const section = this.parts()[this.highlight]?.kind === "result" ? {
2367
2436
  from: 1 + callLines.length,
2368
2437
  to: lines.length
2369
2438
  } : {
@@ -2471,6 +2540,202 @@ function editorCompletion(sources) {
2471
2540
  };
2472
2541
  }
2473
2542
  //#endregion
2543
+ //#region lib/types/context.js
2544
+ /**
2545
+ * Project logged system prompts and injected user-role messages into the
2546
+ * compact titles and navigable sections the terminal transcript walks.
2547
+ *
2548
+ * Compaction replacements, tool results, and the user's own prompts are not
2549
+ * context: those have their own blocks. An empty system-prompt rendering logs
2550
+ * that no prompt is in force and is omitted here.
2551
+ * @module @deepseek-ai/dsh-tui-app/context
2552
+ */
2553
+ /** Producer-declared forms this surface presents structurally. */
2554
+ const KNOWN_FORMS = [
2555
+ "instructions",
2556
+ "catalog",
2557
+ "snapshot",
2558
+ "notice",
2559
+ "relay",
2560
+ "recall"
2561
+ ];
2562
+ /**
2563
+ * Project one nonempty system prompt into a transcript section.
2564
+ * @param text - the rendered prompt; `''` means no prompt is in force.
2565
+ * @param update - whether a nonempty prompt already appeared in this transcript.
2566
+ * @returns the section, or undefined when `text` is empty.
2567
+ */
2568
+ function systemPromptView(text, update) {
2569
+ if (text === "") return void 0;
2570
+ return {
2571
+ title: update ? "system prompt update" : "system prompt",
2572
+ parts: [{
2573
+ kind: "system",
2574
+ rows: text.split("\n")
2575
+ }]
2576
+ };
2577
+ }
2578
+ /**
2579
+ * Project one injected `user/message` into a transcript section.
2580
+ * @param source - the message's durable source.
2581
+ * @param content - the model-facing blocks.
2582
+ * @returns the section, or undefined when this message is not injected context.
2583
+ */
2584
+ function injectedContextView(source, content) {
2585
+ const record = recordOf(source);
2586
+ const kind = stringField(record, "kind");
2587
+ if (record === void 0 || kind === void 0) return void 0;
2588
+ if (kind === "user" || kind === "tool" || kind === "model") return void 0;
2589
+ if (kind === "plugin" && stringField(record, "plugin") === "compact") return void 0;
2590
+ const form = knownForm(stringField(record, "form"));
2591
+ return {
2592
+ title: titled(form, producerOf(record, kind), stringField(record, "summary")),
2593
+ parts: form === "snapshot" ? snapshotParts(record, content) : [{
2594
+ kind: partKind(form),
2595
+ rows: rowsOf(content)
2596
+ }]
2597
+ };
2598
+ }
2599
+ /**
2600
+ * Narrow a value to a string-keyed record.
2601
+ * @param value - a durable source or a snapshot entry.
2602
+ * @returns the record, or undefined when the value is not one.
2603
+ */
2604
+ function recordOf(value) {
2605
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
2606
+ return value;
2607
+ }
2608
+ /**
2609
+ * Read a nonempty string field.
2610
+ * @param record - the record to read, or undefined.
2611
+ * @param key - the field name.
2612
+ * @returns the field, or undefined when it is missing or empty.
2613
+ */
2614
+ function stringField(record, key) {
2615
+ const value = record?.[key];
2616
+ return typeof value === "string" && value !== "" ? value : void 0;
2617
+ }
2618
+ /**
2619
+ * Collect nonempty named strings from an array field, first-seen order.
2620
+ * @param record - the source record.
2621
+ * @param member - the array field.
2622
+ * @param key - the entry field that names the item.
2623
+ * @returns the labels.
2624
+ */
2625
+ function labelsIn(record, member, key) {
2626
+ const list = record?.[member];
2627
+ if (!Array.isArray(list)) return [];
2628
+ const labels = [];
2629
+ for (const entry of list) {
2630
+ const label = stringField(recordOf(entry), key);
2631
+ if (label !== void 0 && !labels.includes(label)) labels.push(label);
2632
+ }
2633
+ return labels;
2634
+ }
2635
+ /**
2636
+ * Name the producer a durable source identifies.
2637
+ * @param record - the source record.
2638
+ * @param kind - the source kind, already read.
2639
+ * @returns a label the heading can show.
2640
+ */
2641
+ function producerOf(record, kind) {
2642
+ switch (kind) {
2643
+ case "plugin": return stringField(record, "plugin") ?? kind;
2644
+ case "skill-invocation": return stringField(record, "name") ?? kind;
2645
+ case "session-reference": {
2646
+ const labels = labelsIn(record, "references", "label");
2647
+ return labels.length > 0 ? labels.join(", ") : kind;
2648
+ }
2649
+ case "agent-instructions": {
2650
+ const paths = labelsIn(record, "changes", "path");
2651
+ return paths.length > 0 ? paths.join(", ") : kind;
2652
+ }
2653
+ default: return kind;
2654
+ }
2655
+ }
2656
+ /**
2657
+ * Narrow a logged form to one this surface presents structurally.
2658
+ * @param form - the source's `form` field.
2659
+ * @returns the form, or undefined for an absent or unknown value.
2660
+ */
2661
+ function knownForm(form) {
2662
+ return form !== void 0 && KNOWN_FORMS.includes(form) ? form : void 0;
2663
+ }
2664
+ /**
2665
+ * The section kind that matches a known form, or `context` for an opaque body.
2666
+ * @param form - the known form, or undefined.
2667
+ * @returns the kind.
2668
+ */
2669
+ function partKind(form) {
2670
+ return form ?? "context";
2671
+ }
2672
+ /**
2673
+ * Compose the compact title from form, producer, and an optional notice summary.
2674
+ * @param form - the known form, or undefined.
2675
+ * @param producer - the producer label.
2676
+ * @param summary - a notice's one-line account, when present.
2677
+ * @returns the title.
2678
+ */
2679
+ function titled(form, producer, summary) {
2680
+ if (form === "notice") return summary === void 0 ? `notice · ${producer}` : `notice · ${summary}`;
2681
+ return form === void 0 ? producer : `${form} · ${producer}`;
2682
+ }
2683
+ /**
2684
+ * The assembled snapshot as one part, used when named contributions are
2685
+ * absent or unreadable so the model-facing text is never dropped.
2686
+ * @param content - the assembled blocks.
2687
+ * @returns one snapshot part.
2688
+ */
2689
+ function assembledSnapshot(content) {
2690
+ return [{
2691
+ kind: "snapshot",
2692
+ rows: rowsOf(content)
2693
+ }];
2694
+ }
2695
+ /**
2696
+ * Split a snapshot into one part per named contribution.
2697
+ *
2698
+ * The list is all-or-nothing: one unreadable entry means the assembled
2699
+ * text is the part, matching how a partial list would hide the only
2700
+ * complete account of what the model read.
2701
+ * @param record - the source record, which may carry `sections`.
2702
+ * @param content - the assembled model-facing blocks, used when sections are absent or unreadable.
2703
+ * @returns the parts.
2704
+ */
2705
+ function snapshotParts(record, content) {
2706
+ const list = record.sections;
2707
+ if (!Array.isArray(list) || list.length === 0) return assembledSnapshot(content);
2708
+ const parts = [];
2709
+ for (const entry of list) {
2710
+ const item = recordOf(entry);
2711
+ if (item === void 0) return assembledSnapshot(content);
2712
+ const name = stringField(item, "name");
2713
+ if (name === void 0 || typeof item.text !== "string") return assembledSnapshot(content);
2714
+ parts.push({
2715
+ kind: "snapshot",
2716
+ label: name,
2717
+ rows: rowsOfText(item.text)
2718
+ });
2719
+ }
2720
+ return parts;
2721
+ }
2722
+ /**
2723
+ * The model-facing blocks as source rows.
2724
+ * @param content - the content blocks.
2725
+ * @returns the rows; one blank row when there is no text, so the keyboard still has a section.
2726
+ */
2727
+ function rowsOf(content) {
2728
+ return rowsOfText(contentText(content));
2729
+ }
2730
+ /**
2731
+ * Split text into source rows.
2732
+ * @param text - the model-facing text.
2733
+ * @returns the rows; one blank row when `text` is empty.
2734
+ */
2735
+ function rowsOfText(text) {
2736
+ return text === "" ? [""] : text.split("\n");
2737
+ }
2738
+ //#endregion
2474
2739
  //#region lib/types/editor.js
2475
2740
  /**
2476
2741
  * The prompt editor's caret. pi-tui draws the caret cell itself in reverse
@@ -2649,24 +2914,29 @@ async function exportSessionZip(ctx, sessionId, directory, signal) {
2649
2914
  /**
2650
2915
  * The docked inspector above the editor: while the keyboard walks the
2651
2916
  * transcript it shows the focused section in full - what it is, which part of
2652
- * its block is held, and the start of that part's own rows.
2917
+ * its block is held, and that part's own rows. Context sections draw every
2918
+ * row; other sections fold at `focusPreviewLines` with Enter opening the rest.
2653
2919
  *
2654
2920
  * It is the focus indicator that is always on screen. A block is also marked
2655
2921
  * in place, but only while the renderer can still repaint its first line
2656
2922
  * (`./navigation.ts`), so the heading says when the marked block itself has
2657
2923
  * scrolled out of reach. Rows arrive as the block's source text with no fade
2658
2924
  * and no palette styling of their own, so a section that is still streaming
2659
- * grows here as it arrives.
2925
+ * grows here as it arrives. A block with several parts draws them as a numbered
2926
+ * wrapping strip `← 1 reasoning · 2 reply →` so Left/Right walk is visible
2927
+ * and every part label stays on screen.
2660
2928
  * @module @deepseek-ai/dsh-tui-app/inspector
2661
2929
  */
2662
2930
  /** What separates two labels of the parts strip. */
2663
2931
  const SEPARATOR$3 = " · ";
2664
- /** Brackets the parts strip, so the strip reads as one row of choices. */
2665
- const STRIP_ENDS = ["‹ ", " ›"];
2666
2932
  /** What the heading appends while the focused block lies outside the repaint window. */
2667
2933
  const OFF_SCREEN = " · off screen";
2668
2934
  /** The keys the inspector answers, drawn dim under its rows. */
2669
- const HINT = "↑ ↓ blocks · ← → parts · Enter page · Esc back";
2935
+ const HINT = "↑ ↓ sections · ← → parts · Enter page · Esc back";
2936
+ /** Opens the numbered parts strip, so Left/Right read as a walk along this row. */
2937
+ const STRIP_START = "← ";
2938
+ /** Closes the numbered parts strip. */
2939
+ const STRIP_END = " →";
2670
2940
  /** What ends a line the width cut short; one column, so the mark itself fits. */
2671
2941
  const ELLIPSIS$1 = "…";
2672
2942
  /**
@@ -2674,18 +2944,22 @@ const ELLIPSIS$1 = "…";
2674
2944
  * @param view - the section to show.
2675
2945
  * @param render - the palette, the row budget, and the width.
2676
2946
  * @returns the inspector's lines, none wider than `width`: a blank separator,
2677
- * the heading, the parts strip when the block has more than one part, the
2678
- * folded rows, and the hints.
2947
+ * the heading, the numbered parts strip when the block has more than one part
2948
+ * (wrapped so every part stays on screen), the rows, and the hints.
2679
2949
  */
2680
2950
  function renderInspector(view, render) {
2681
2951
  const { palette } = render;
2682
2952
  const width = Math.max(1, render.width);
2683
- const lines = ["", heading(view, palette, width)];
2684
- if (view.parts.length > 1) lines.push(partsStrip(view.parts, palette));
2953
+ const chrome = ["", heading(view, palette, width)];
2954
+ if (view.parts.length > 1) chrome.push(...partsStrip(view.parts, palette, width));
2685
2955
  const wrapped = view.rows.flatMap((row) => wrapTextWithAnsi(row, width));
2686
- lines.push(...foldRows(wrapped, render.previewLines, (hidden) => palette.dim(`… ${String(hidden)} more row${hidden === 1 ? "" : "s"} · Enter opens the page`)));
2687
- lines.push(palette.dim(HINT));
2688
- return lines.map((line) => truncateToWidth(line, width, ELLIPSIS$1));
2956
+ const body = view.complete === true ? wrapped : foldRows(wrapped, render.previewLines, (hidden) => palette.dim(`… ${String(hidden)} more row${hidden === 1 ? "" : "s"} · Enter opens the page`));
2957
+ const cut = (line) => truncateToWidth(line, width, ELLIPSIS$1);
2958
+ return [
2959
+ ...chrome.map(cut),
2960
+ ...view.complete === true ? body : body.map(cut),
2961
+ cut(palette.dim(HINT))
2962
+ ];
2689
2963
  }
2690
2964
  /**
2691
2965
  * The heading line. A tool title can run past any terminal, so the subject is
@@ -2703,14 +2977,66 @@ function heading(view, palette, width) {
2703
2977
  return `${truncateToWidth(subject, Math.max(1, width - visibleWidth(suffix)), ELLIPSIS$1)}${suffix}`;
2704
2978
  }
2705
2979
  /**
2706
- * Draw the parts of the focused block as one row of choices.
2980
+ * Draw the parts of the focused block as numbered choices that wrap rather
2981
+ * than disappearing past the width. `Left` / `Right` move along this list:
2982
+ * each label is `N name`, the held one is accented, and the arrows mark that
2983
+ * the walk stays inside this block.
2707
2984
  * @param parts - the labels in reading order, the held one marked.
2708
2985
  * @param palette - the palette the labels are styled with.
2709
- * @returns the strip line.
2986
+ * @param width - the width each line must fit; at least 1.
2987
+ * @returns the strip lines, every part present.
2710
2988
  */
2711
- function partsStrip(parts, palette) {
2712
- const labels = parts.map((part) => part.focused ? palette.accent(part.label) : palette.dim(part.label)).join(palette.dim(SEPARATOR$3));
2713
- return `${palette.dim(STRIP_ENDS[0])}${labels}${palette.dim(STRIP_ENDS[1])}`;
2989
+ function partsStrip(parts, palette, width) {
2990
+ const tokens = parts.map((part, index) => {
2991
+ const text = `${String(index + 1)} ${part.label}`;
2992
+ return part.focused ? palette.accent(text) : palette.dim(text);
2993
+ });
2994
+ const sep = palette.dim(SEPARATOR$3);
2995
+ const indent = palette.dim(" ");
2996
+ const end = palette.dim(STRIP_END);
2997
+ const indentWidth = visibleWidth(" ");
2998
+ const endWidth = visibleWidth(STRIP_END);
2999
+ const lines = [];
3000
+ let current = palette.dim(STRIP_START);
3001
+ let used = visibleWidth(STRIP_START);
3002
+ const startLine = () => {
3003
+ lines.push(current);
3004
+ current = indent;
3005
+ used = indentWidth;
3006
+ };
3007
+ for (let index = 0; index < tokens.length; index += 1) {
3008
+ const token = tokens[index];
3009
+ /* v8 ignore next -- the loop bound is tokens.length */
3010
+ if (token === void 0) continue;
3011
+ const extra = index === tokens.length - 1 ? endWidth : 0;
3012
+ let leading = index === 0 || current === indent ? "" : sep;
3013
+ let leadingWidth = leading === "" ? 0 : visibleWidth(SEPARATOR$3);
3014
+ const tokenWidth = visibleWidth(token);
3015
+ if (used + leadingWidth + tokenWidth + extra > width && used > indentWidth) {
3016
+ startLine();
3017
+ leading = "";
3018
+ leadingWidth = 0;
3019
+ }
3020
+ const room = Math.max(1, width - used - extra);
3021
+ if (tokenWidth > room) {
3022
+ const wrapped = wrapTextWithAnsi(token, room);
3023
+ const first = wrapped[0];
3024
+ /* v8 ignore next -- wrapTextWithAnsi returns a line for nonempty text */
3025
+ if (first === void 0) continue;
3026
+ current += leading + first;
3027
+ used += leadingWidth + visibleWidth(first);
3028
+ for (const more of wrapped.slice(1)) {
3029
+ startLine();
3030
+ current += more;
3031
+ used += visibleWidth(more);
3032
+ }
3033
+ } else {
3034
+ current += leading + token;
3035
+ used += leadingWidth + tokenWidth;
3036
+ }
3037
+ }
3038
+ lines.push(`${current}${end}`);
3039
+ return lines;
2714
3040
  }
2715
3041
  /**
2716
3042
  * The inspector as a mounted component.
@@ -2751,8 +3077,11 @@ var InspectorPane = class {
2751
3077
  * The transcript as a list of navigable sections.
2752
3078
  *
2753
3079
  * A conversation is drawn as one component per fact, and the keyboard walks it
2754
- * in two directions: between blocks and, inside a block, between its parts -
2755
- * the reasoning and the reply of a message, the call and the result of a tool.
3080
+ * in two directions: `Up` / `Down` through every section in reading order —
3081
+ * a system prompt, injected context, the reasoning and the reply of a message,
3082
+ * the call and the result of a tool — and `Left` / `Right` between the parts
3083
+ * of the held block without leaving it. Snapshot contributions are separate
3084
+ * parts of one injected block, so the arrows walk each named piece of context.
2756
3085
  * This module turns the transcript container's children into that list and
2757
3086
  * moves one cursor over it. Everything here is plain data: no pi-tui, no
2758
3087
  * palette, no clock. The rows a part carries are the block's own source text,
@@ -2812,19 +3141,65 @@ function enterNewest(blocks) {
2812
3141
  };
2813
3142
  }
2814
3143
  /**
2815
- * Move to another block, landing on its last part.
3144
+ * Every section of the transcript in drawing order, oldest block first and
3145
+ * each block's parts in reading order. Blocks that currently expose no parts
3146
+ * are omitted, so a walk never lands on an empty index.
3147
+ * @param blocks - the navigable blocks.
3148
+ * @returns one cursor per section.
3149
+ */
3150
+ function flattenSections(blocks) {
3151
+ const sections = [];
3152
+ for (let block = 0; block < blocks.length; block += 1) {
3153
+ const count = partCount(blocks, block);
3154
+ for (let part = 0; part < count; part += 1) sections.push({
3155
+ block,
3156
+ part
3157
+ });
3158
+ }
3159
+ return sections;
3160
+ }
3161
+ /**
3162
+ * Whether two cursors name the same section.
3163
+ * @param left - one cursor.
3164
+ * @param right - the other.
3165
+ * @returns true when both name the same block and part.
3166
+ */
3167
+ function sameSection(left, right) {
3168
+ return left.block === right.block && left.part === right.part;
3169
+ }
3170
+ /**
3171
+ * Index into a non-empty flattened section list.
3172
+ * @param sections - the flattened sections; length at least 1.
3173
+ * @param index - an in-range index.
3174
+ * @param fallback - used when that index has no section.
3175
+ * @returns that section.
3176
+ */
3177
+ function sectionAt(sections, index, fallback) {
3178
+ /* v8 ignore next -- callers pass an in-range index into a non-empty list */
3179
+ return sections[index] ?? fallback;
3180
+ }
3181
+ /**
3182
+ * Move to another section in reading order: the previous or next part of the
3183
+ * held block, or the last or first part of the neighbouring block that has
3184
+ * one. A block whose `parts()` is empty is skipped.
2816
3185
  * @param cursor - where the focus sits.
2817
- * @param step - 1 for the next block, -1 for the previous one.
3186
+ * @param step - 1 for the next section, -1 for the previous one.
2818
3187
  * @param blocks - the navigable blocks.
2819
- * @returns the new cursor; the cursor itself at either end of the list.
3188
+ * @returns the new cursor; the cursor itself at either end of the transcript.
2820
3189
  */
2821
- function moveBlock(cursor, step, blocks) {
2822
- const block = clampIndex(cursor.block + step, blocks.length);
2823
- if (block === cursor.block) return cursor;
2824
- return {
2825
- block,
2826
- part: Math.max(0, partCount(blocks, block) - 1)
2827
- };
3190
+ function moveSection(cursor, step, blocks) {
3191
+ const sections = flattenSections(blocks);
3192
+ if (sections.length === 0) return cursor;
3193
+ const settled = clampCursor(cursor, blocks);
3194
+ if (settled === void 0) {
3195
+ const index = step >= 0 ? sections.findIndex((section) => section.block > cursor.block) : sections.findLastIndex((section) => section.block < cursor.block);
3196
+ if (index < 0) return sectionAt(sections, step >= 0 ? sections.length - 1 : 0, cursor);
3197
+ return sectionAt(sections, index, cursor);
3198
+ }
3199
+ const index = sections.findIndex((section) => sameSection(section, settled));
3200
+ /* v8 ignore next -- a settled cursor is always in flattenSections */
3201
+ if (index < 0) return settled;
3202
+ return sectionAt(sections, clampIndex(index + step, sections.length), settled);
2828
3203
  }
2829
3204
  /**
2830
3205
  * Move between the parts of the held block.
@@ -2887,6 +3262,7 @@ function subjectOf(block, part) {
2887
3262
  case "user":
2888
3263
  case "assistant": return [partLabel(part.kind)];
2889
3264
  case "tool": return [block.title === "" ? block.name : `${block.name} ${block.title}`, block.parts().some((candidate) => candidate.kind === "result") ? partLabel(part.kind) : "running"];
3265
+ case "context": return part.label === void 0 || part.label === block.title ? [block.title] : [block.title, part.label];
2890
3266
  /* v8 ignore next -- closed-union exhaustiveness guard */
2891
3267
  default: return assertNever(block, "tui transcript block kind");
2892
3268
  }
@@ -2919,7 +3295,7 @@ function partLabels(cursor, blocks) {
2919
3295
  const block = blocks[cursor.block];
2920
3296
  if (block === void 0) return [];
2921
3297
  return block.parts().map((part, index) => ({
2922
- label: partLabel(part.kind),
3298
+ label: part.label ?? partLabel(part.kind),
2923
3299
  focused: index === cursor.part
2924
3300
  }));
2925
3301
  }
@@ -3205,6 +3581,19 @@ function todoLines(facts) {
3205
3581
  return [`todos: ${String(done)} done · ${String(active)} active · ${String(pending)} pending`, ...items.map((item) => ` ${TODO_GLYPH[item.status]} ${item.content}`)];
3206
3582
  }
3207
3583
  /**
3584
+ * One-line todo expansion for the status bar: the counts by status, and the
3585
+ * item being worked on, or the next pending item when none is in progress.
3586
+ * @param facts - the facts one status read produced.
3587
+ * @returns the expansion; empty when no todo list is known.
3588
+ */
3589
+ function todoSummary(facts) {
3590
+ if (facts.todos === void 0) return "";
3591
+ const { items, done, active, pending } = facts.todos;
3592
+ const counts = `todos: ${String(done)} done · ${String(active)} active · ${String(pending)} pending`;
3593
+ const current = items.find((item) => item.status === "in_progress") ?? items.find((item) => item.status === "pending");
3594
+ return current === void 0 ? counts : `${counts} · ${current.content}`;
3595
+ }
3596
+ /**
3208
3597
  * The goal section: phase, admitted rounds, objective, and the blocking
3209
3598
  * condition while the goal is blocked.
3210
3599
  * @param facts - the facts one status read produced.
@@ -3307,9 +3696,10 @@ function plural(count, noun) {
3307
3696
  * The status bar under the editor: plain session facts become an ordered list
3308
3697
  * of segments, each with a stable id, the short label the bar draws, and what
3309
3698
  * `Enter` on it does — the rows the app prints, or the app's own navigable
3310
- * page; a second function renders those segments as one unfocused line of key
3311
- * facts, or as two focused lines whose first is a sliding window that always
3312
- * includes the selected segment. Everything here is pure — no Context, no
3699
+ * page with the one-line summary the focused bar expands; a second function
3700
+ * renders those segments as one unfocused line of key facts, or as two focused
3701
+ * lines whose first is a sliding window that always includes the selected
3702
+ * segment. Everything here is pure — no Context, no
3313
3703
  * services, no terminal, and no clock: elapsed values arrive already formatted,
3314
3704
  * and the terminal width arrives as an input so every line fits it.
3315
3705
  * @module @deepseek-ai/dsh-tui-app/footer
@@ -3339,19 +3729,18 @@ const KEY_SEGMENT_IDS = new Set([
3339
3729
  "effort",
3340
3730
  "turn",
3341
3731
  "context",
3732
+ "todo",
3342
3733
  "workspace"
3343
3734
  ]);
3344
3735
  /** The command that prints every projection section at once. */
3345
3736
  const STATUS_COMMAND_ROW = "/status prints all of these sections";
3346
3737
  /**
3347
3738
  * What opening each projection-fact segment does: a section builder produces
3348
- * the rows the app prints, and `OPENED_PAGE` names a fact the app has its own
3349
- * navigable page for. The printed `/status` report still carries a todo
3350
- * section; the bar hands the todo list to the app instead.
3739
+ * the rows the app prints. The `todo` segment is a page instead: the bar
3740
+ * expands its counts on line 2 and the app opens the same list `/todos` opens.
3351
3741
  */
3352
3742
  const STATUS_SECTIONS = {
3353
3743
  context: contextLines,
3354
- todo: { kind: "page" },
3355
3744
  goal: goalLines,
3356
3745
  plan: planLines
3357
3746
  };
@@ -3367,6 +3756,17 @@ function printed(rows) {
3367
3756
  };
3368
3757
  }
3369
3758
  /**
3759
+ * A segment the app opens as a page, with the one-line summary the bar expands.
3760
+ * @param summary - the expansion the focused bar draws.
3761
+ * @returns the detail.
3762
+ */
3763
+ function openedPage(summary) {
3764
+ return {
3765
+ kind: "page",
3766
+ summary
3767
+ };
3768
+ }
3769
+ /**
3370
3770
  * The workspace label: a home-directory prefix becomes `~`, and a path still
3371
3771
  * wider than the bar allows keeps only its last two segments.
3372
3772
  * @param cwd - the workspace root.
@@ -3453,11 +3853,19 @@ function buildFooterSegments(inputs) {
3453
3853
  ])
3454
3854
  });
3455
3855
  for (const part of footerStatus(facts)) {
3856
+ if (part.id === "todo") {
3857
+ segments.push({
3858
+ id: "todo",
3859
+ label: part.label,
3860
+ detail: openedPage(todoSummary(facts))
3861
+ });
3862
+ continue;
3863
+ }
3456
3864
  const section = STATUS_SECTIONS[part.id];
3457
3865
  segments.push({
3458
3866
  id: part.id,
3459
3867
  label: part.label,
3460
- detail: typeof section === "function" ? printed([...section(facts), STATUS_COMMAND_ROW]) : section
3868
+ detail: printed([...section(facts), STATUS_COMMAND_ROW])
3461
3869
  });
3462
3870
  }
3463
3871
  segments.push({
@@ -3539,13 +3947,13 @@ function unfocusedLine(segments, palette, width) {
3539
3947
  return fitLine(palette.dim(key.join(SEPARATOR$1)), width);
3540
3948
  }
3541
3949
  /**
3542
- * The first detail row of a printed segment, or the label of a page segment.
3950
+ * The first detail row of a printed segment, or the summary of a page segment.
3543
3951
  * @param segment - the selected segment; absent when the bar has none.
3544
3952
  * @returns the expansion body.
3545
3953
  */
3546
3954
  function expansionBody(segment) {
3547
3955
  if (segment === void 0) return "";
3548
- if (segment.detail.kind === "page") return segment.label;
3956
+ if (segment.detail.kind === "page") return segment.detail.summary;
3549
3957
  return segment.detail.rows[0];
3550
3958
  }
3551
3959
  /**
@@ -4578,6 +4986,8 @@ var TuiApp = class {
4578
4986
  todoTurns = /* @__PURE__ */ new Map();
4579
4987
  /** The turn the last logged `turn/start` opened; 0 before the first one. */
4580
4988
  turn = 0;
4989
+ /** Whether a nonempty system prompt has already been drawn in this transcript. */
4990
+ sawSystemPrompt = false;
4581
4991
  /** When the running turn started, from its `turn/start` envelope; absent between turns. */
4582
4992
  turnStartedAt;
4583
4993
  pending = [];
@@ -4792,6 +5202,7 @@ var TuiApp = class {
4792
5202
  this.submittedIds.clear();
4793
5203
  this.todoTurns.clear();
4794
5204
  this.turn = 0;
5205
+ this.sawSystemPrompt = false;
4795
5206
  this.turnStartedAt = void 0;
4796
5207
  this.streaming = void 0;
4797
5208
  this.endFade();
@@ -5378,7 +5789,8 @@ var TuiApp = class {
5378
5789
  /**
5379
5790
  * Answer the keys every non-editor region answers the same way: `Escape`
5380
5791
  * hands the keyboard back to the editor, `Shift+Up` names the conversation,
5381
- * and `Shift+Down` the status bar.
5792
+ * and `Shift+Down` the status bar. The transcript reads those two shift
5793
+ * arrows as a walk instead, so this helper is for the bar and the panel.
5382
5794
  * @param data - the raw key bytes.
5383
5795
  * @returns the consume marker when the key named a region, `undefined` when the focused region owns the key.
5384
5796
  */
@@ -5426,12 +5838,17 @@ var TuiApp = class {
5426
5838
  * Answer one key while the transcript holds focus. Every key is consumed
5427
5839
  * here, so nothing typed while reading the conversation reaches the editor;
5428
5840
  * `Ctrl+C` and `Ctrl+D` never reach this far and keep their global meaning.
5841
+ * `Up` / `Down` and `Shift+Up` / `Shift+Down` walk every section in reading
5842
+ * order; `Shift+Up` from the editor still enters on the newest section, and
5843
+ * `Shift+Down` from the editor still names the regions under it.
5429
5844
  * @param data - the raw key bytes.
5430
5845
  * @returns the consume marker the input listener returns.
5431
5846
  */
5432
5847
  onTranscriptKey(data) {
5433
- const region = this.onRegionKey(data);
5434
- if (region !== void 0) return region;
5848
+ if (matchesKey(data, "escape")) {
5849
+ this.focusEditor();
5850
+ return { consume: true };
5851
+ }
5435
5852
  const section = this.focusedSection();
5436
5853
  /* v8 ignore next 5 -- only a session change empties the transcript, and it hands the keyboard back first */
5437
5854
  if (section === void 0) {
@@ -5439,13 +5856,14 @@ var TuiApp = class {
5439
5856
  return { consume: true };
5440
5857
  }
5441
5858
  const { cursor, blocks } = section;
5442
- if (matchesKey(data, "up")) {
5443
- this.moveCursor(moveBlock(cursor, -1, blocks));
5859
+ if (matchesKey(data, "up") || matchesKey(data, "shift+up")) {
5860
+ this.moveCursor(moveSection(cursor, -1, blocks));
5444
5861
  return { consume: true };
5445
5862
  }
5446
- if (matchesKey(data, "down")) {
5447
- if (cursor.block === blocks.length - 1) this.focusBelowEditor();
5448
- else this.moveCursor(moveBlock(cursor, 1, blocks));
5863
+ if (matchesKey(data, "down") || matchesKey(data, "shift+down")) {
5864
+ const next = moveSection(cursor, 1, blocks);
5865
+ if (next.block === cursor.block && next.part === cursor.part) this.focusBelowEditor();
5866
+ else this.moveCursor(next);
5449
5867
  return { consume: true };
5450
5868
  }
5451
5869
  if (matchesKey(data, "left")) {
@@ -5625,7 +6043,8 @@ var TuiApp = class {
5625
6043
  heading: sectionHeading(cursor, blocks),
5626
6044
  parts: partLabels(cursor, blocks),
5627
6045
  rows: section.part.rows,
5628
- highlighted: this.highlighted !== void 0
6046
+ highlighted: this.highlighted !== void 0,
6047
+ complete: section.block.blockKind === "context"
5629
6048
  };
5630
6049
  }
5631
6050
  /** Hand the keyboard back to the editor; a no-op while the editor already has it. */
@@ -5810,7 +6229,7 @@ var TuiApp = class {
5810
6229
  "Esc stops the running turn · Ctrl+O expands or collapses tool output",
5811
6230
  "Shift+Tab cycles the current model's reasoning effort for the next request",
5812
6231
  "Shift+Up focuses the transcript, Shift+Down the subagent panel or the status bar",
5813
- "Then ↑ ↓ move between blocks, panel rows, and the bar; ← → move between a block's parts or the bar's segments (Shift+← → also move the bar)",
6232
+ "Then ↑ ↓ walk every section, panel row, and bar segment; ← → move between a block's parts or the bar's segments (Shift+← → also move the bar)",
5814
6233
  "Enter opens the focused section or segment, Esc returns to the input",
5815
6234
  "Ctrl+C clears the input (twice quits) · Ctrl+D on an empty input quits"
5816
6235
  ];
@@ -6405,7 +6824,7 @@ var TuiApp = class {
6405
6824
  const section = this.focusedSection();
6406
6825
  const wanted = section !== void 0 && this.focus === "transcript" ? {
6407
6826
  block: section.block,
6408
- part: section.part.kind
6827
+ part: section.cursor.part
6409
6828
  } : void 0;
6410
6829
  const fades = this.fadesMoving();
6411
6830
  if (!fades && wanted === void 0 && this.highlighted === void 0) return false;
@@ -6495,6 +6914,9 @@ var TuiApp = class {
6495
6914
  case "user/message":
6496
6915
  this.onUserMessage(event.data);
6497
6916
  break;
6917
+ case "system/message":
6918
+ this.onSystemMessage(event.data);
6919
+ break;
6498
6920
  case "assistant/message": {
6499
6921
  const { message, usage, interrupted } = event.data;
6500
6922
  const text = message.content.filter((block) => block.type === "text").map((block) => block.text).join("");
@@ -6598,7 +7020,19 @@ var TuiApp = class {
6598
7020
  this.chat.addChild(new UserBlock(this.theme, [contentText(message.content), ...attachments].filter((part) => part !== "").join("\n"), this.turn));
6599
7021
  return;
6600
7022
  }
6601
- if (source.kind === "plugin" && source.form === "notice") this.chat.addChild(new NoticeBlock(this.theme, source.summary));
7023
+ const view = injectedContextView(source, message.content);
7024
+ if (view === void 0) return;
7025
+ this.chat.addChild(new ContextBlock(this.theme, view.title, view.parts, this.turn));
7026
+ }
7027
+ /**
7028
+ * Draw one nonempty system prompt as a navigable context block.
7029
+ * @param data - the durable `system/message` payload.
7030
+ */
7031
+ onSystemMessage(data) {
7032
+ const view = systemPromptView(contentText(data.message.content), this.sawSystemPrompt);
7033
+ if (view === void 0) return;
7034
+ this.sawSystemPrompt = true;
7035
+ this.chat.addChild(new ContextBlock(this.theme, view.title, view.parts, data.turn));
6602
7036
  }
6603
7037
  presentCall(name, args) {
6604
7038
  const definition = this.deps.ctx.get("tools")?.get(name, this.agent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
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",