@songtonyli/dsh-cli 0.1.80 → 0.1.81

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.80; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.81; `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.80 (deepseek-harness 0.2.1-rc.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.81 (deepseek-harness 0.2.1-rc.2)')
22
22
  process.exit(0)
23
23
  }
24
24
 
@@ -537,7 +537,7 @@ var ClientModuleRegistry = class extends Service {
537
537
  constructor(ctx) {
538
538
  super(ctx, "clientModules");
539
539
  const { version } = createRequire(import.meta.url)("../package.json");
540
- const commit = "f517a47";
540
+ const commit = "407dd9b";
541
541
  this.release = {
542
542
  version,
543
543
  commit
@@ -167,7 +167,7 @@ window.__ModuleLoader__.load({
167
167
  const SCROLLBAR_LINGER_MS = 2e3;
168
168
  /** Format complete-build metadata for the local brand badge. */
169
169
  function localBuildVersion() {
170
- return `0.2.1-rc.2-f517a47-dirty`;
170
+ return `0.2.1-rc.2-407dd9b-dirty`;
171
171
  }
172
172
  /** Each panel row subscribes only to its own selection state. */
173
173
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -21,11 +21,11 @@
21
21
  en: 58a8cf392bd6a90b
22
22
  zh: ff147492c5baf643
23
23
  /deepseek-ai-dsh-tui-app/use-this-package/the-screen:
24
- en: 365ce77bf78accd5
25
- zh: e945a1f209e18f36
24
+ en: 2fb0a7ccd2a6df6d
25
+ zh: 933ab5f630718dc9
26
26
  /deepseek-ai-dsh-tui-app/use-this-package/keys-and-commands:
27
- en: 8397ec35de157ed5
28
- zh: 135411de6c63f306
27
+ en: d4d29cef63aa3865
28
+ zh: 56c323b5eb14c415
29
29
  /deepseek-ai-dsh-tui-app/use-this-package/background-tool-calls:
30
30
  en: 322ae3c6d76383ec
31
31
  zh: 8c38eee4b57ed8dd
@@ -54,8 +54,8 @@
54
54
  en: 142f04bf29e981dd
55
55
  zh: a1689297b06c9ca6
56
56
  /deepseek-ai-dsh-tui-app/understand-the-implementation/source-map:
57
- en: a1b526bb25bf3096
58
- zh: 36d8f8acc73700fd
57
+ en: e6f77b3bf21d07d2
58
+ zh: 3bc6f715a4bdca0b
59
59
  /deepseek-ai-dsh-tui-app/understand-the-implementation/invariant-ownership:
60
60
  en: 0ddf6de8928026d5
61
61
  zh: 24feedcbb9e9d676
@@ -40,15 +40,15 @@ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui
40
40
 
41
41
  ### The screen
42
42
 
43
- Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), and a prompt steered or injected into a turn that already had a model step draws dim on a darker band so it recedes behind the turn it joined, assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, a bloom spinning beside `Thinking` while it streams, and each tool call is a card with a status glyph — a yellow spinner of that tool family's flowers, blooms, and stars while it runs, a green `◆` once done, a red `◆` on failure — the bold tool name, the presenter headline in violet — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. A top-level workflow call also draws its own run beside that card: the name, member count, status, and a ten-cell member progress bar with the settled count, then each phase and the members that started. While a live run runs, its `◇` pulses through a diamond animation and each running member's `○` spins in the subagent family's flowers, one phase ahead of the member before it; a run drawn from a replayed log spins only while its background job is still live, and reduced motion draws the static glyphs. Running groups and groups with a failed, cancelled, or interrupted member open; a clean completion stays closed. Space or Enter on a run or phase folds that level, and Enter on a running member opens its child only while that child is a live direct child of this session. The card appears when the model starts the call and flows out row after row, each row left to right, at one pace whatever the card holds: a full-width row takes `toolRevealFrames` frames, a shorter row proportionally less, and the columns just drawn brighten from the terminal background to their own colors. The result rows flow out the same way when the tool answers, behind whatever the card is still drawing; neither the call nor the result waits for the animation. An `edit` or `write` diff card fills each added row edge to edge with a green background and each removed row with a red one, the removed rows above the added ones, and paints the `+` and `-` in their own lighter colour so each sign reads against the fill rather than in it; a wrapped row carries the fill on without a second sign; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status glyph, spinning while it runs and a dim `◆` for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt is omitted. A compaction, from `/compact` or automatic, draws as one context block whose accent `⬡` title names its origin and the estimated tokens it replaced and its summary costs, as in `context compacted by /compact · ~6.4k → ~0.9k tokens` or `context compacted automatically in turn 12 · …`; under the title, `compressed` names the item count and turns the summary replaced, each prompt among them (five at most, one row each), and a count of the replies, tool results by tool, context blocks, and earlier summaries, and `preserved` names the system prompt and what each later turn still holds verbatim; both stay drawn while the summary under them folds to `contextPreviewLines` rows like any context block. The checkpoint message itself is not drawn again. A `/compact` attempt the log closes with an error prints `/compact failed · <error>` when the session is redrawn, since the live command reports its own failure; a failed automatic attempt changes nothing and draws nothing, as in the browser. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use warm orange, links and inline code use violet, and quotes stay dim. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning floats out over the same duration: it appears at a lifted color and recedes to the dim italic it settles in. Each column of a tool card brightens over it from the terminal background to the palette color it settles in; a card redrawn from persisted history carries no flow or fade, and text that has settled is never dimmed again.
43
+ Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), and a prompt steered or injected into a turn that already had a model step draws dim on a darker band so it recedes behind the turn it joined, assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, a bloom spinning beside `Thinking` while it streams, and each tool call is a card with a status glyph — a yellow spinner of that tool family's flowers, blooms, and stars while it runs, a green `◆` once done, a red `◆` on failure — the tool name in bold cyan, the presenter headline in teal — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. A top-level workflow call also draws its own run beside that card: the name, member count, status, and a ten-cell member progress bar with the settled count, then each phase and the members that started. While a live run runs, its `◇` pulses through a diamond animation and each running member's `○` spins in the subagent family's flowers, one phase ahead of the member before it; a run drawn from a replayed log spins only while its background job is still live, and reduced motion draws the static glyphs. Running groups and groups with a failed, cancelled, or interrupted member open; a clean completion stays closed. Space or Enter on a run or phase folds that level, and Enter on a running member opens its child only while that child is a live direct child of this session. The card appears when the model starts the call and flows out row after row, each row left to right, at one pace whatever the card holds: a full-width row takes `toolRevealFrames` frames, a shorter row proportionally less, and the columns just drawn brighten from the terminal background to their own colors. The result rows flow out the same way when the tool answers, behind whatever the card is still drawing; neither the call nor the result waits for the animation. An `edit` or `write` diff card fills each added row edge to edge with a green background and each removed row with a red one, the removed rows above the added ones, and paints the `+` and `-` in their own lighter colour so each sign reads against the fill rather than in it; a wrapped row carries the fill on without a second sign; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status glyph, spinning while it runs and a dim `◆` for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt is omitted. A compaction, from `/compact` or automatic, draws as one context block whose accent `⬡` title names its origin and the estimated tokens it replaced and its summary costs, as in `context compacted by /compact · ~6.4k → ~0.9k tokens` or `context compacted automatically in turn 12 · …`; under the title, `compressed` names the item count and turns the summary replaced, each prompt among them (five at most, one row each), and a count of the replies, tool results by tool, context blocks, and earlier summaries, and `preserved` names the system prompt and what each later turn still holds verbatim; both stay drawn while the summary under them folds to `contextPreviewLines` rows like any context block. The checkpoint message itself is not drawn again. A `/compact` attempt the log closes with an error prints `/compact failed · <error>` when the session is redrawn, since the live command reports its own failure; a failed automatic attempt changes nothing and draws nothing, as in the browser. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use orange, links and inline code use magenta, and quotes stay dim. Every hue is a Tokyo Night (Night) color, drawn exactly when `COLORTERM` declares `truecolor` or `24bit` and as the nearest of the 256 indexed colors otherwise; the background bands keep their 256-color greys and diff tints. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning floats out over the same duration: it appears at a lifted color and recedes to the dim italic it settles in. Each column of a tool card brightens over it from the terminal background to the palette color it settles in; a card redrawn from persisted history carries no flow or fade, and text that has settled is never dimmed again.
44
44
 
45
- Below the transcript sit a spinner while the agent works — `thinking`, `writing`, `calling <tool>`, a retry, or `compacting`, each beside its own braille animation: circling dots, filling lines, an orbiting dot, a sliding bar, or a settling cell — with a bright highlight sweeping across the word, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and latest descendant line while either has a row — completed todo content scratched out and status glyphs colored green, yellow, or cyan, the in-progress one a spinner, at most four todo rows then `+<n> more`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model and entry keys are colored; live turn, context, and todo facts use yellow, violet, and green. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, or `Shift+↑ select · Shift+↓ status` while follow-ups wait, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. 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 — `thinking`, `writing`, `calling <tool>`, a retry, or `compacting`, each beside its own braille animation: circling dots, filling lines, an orbiting dot, a sliding bar, or a settling cell — with a bright highlight sweeping across the word, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and latest descendant line while either has a row — completed todo content scratched out and status glyphs colored green, yellow, or blue, the in-progress one a spinner, at most four todo rows then `+<n> more`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model is purple and the entry keys magenta; live turn, context, and todo facts use yellow, magenta, and green. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, or `Shift+↑ select · Shift+↓ status` while follow-ups wait, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. 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 closed by a `│ ` border on both sides and wrapped four columns narrower, folded at `focusPreviewLines` for every section kind — a system prompt and an injected context included — with `… <n> more rows · Ctrl+G reads it` under them. The bottom rule carries the keys the conversation answers, `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`, narrowed to `↑↓ ←→ · Space folds · Esc input` and then to `Esc input` as the terminal loses columns.
48
48
 
49
49
  The focused block is also marked where it stands, with a two-column gutter that is dim beside the block's other lines and accented beside the focused section's own — or beside the fold marker, when the fold left that section out of the drawn rows entirely — and its content wraps two columns narrower while the mark is drawn. That mark reaches only the lines pi-tui still repaints differentially — the last `rows` lines of the last frame it wrote, a window a taller frame raises and a shorter one never lowers — because changing anything above them would clear the terminal's scrollback. A block that has scrolled past that point keeps no gutter, the inspector heading appends ` · off screen`, and the frame's own rules draw dim instead of accent, so the frame itself reports that the mark cannot be drawn where the block stands. A fade whose rows reach that edge settles them to their final colors in the frame that writes them, so nothing stays dim in the scrollback.
50
50
 
51
- `Ctrl+G` from any region, `Enter` on a conversation section, and `/turns` read the conversation full screen, one turn at a time. The reader takes the terminal rather than drawing over the conversation: it runs on the terminal's alternate screen, the screen a pager runs on, and the conversation's own screen is held off the terminal for as long as it is up. So it costs the conversation no line, leaves the repaint window where it was, fills the screen on every terminal, and cannot leave a row of itself in your scrollback; closing it restores the conversation exactly as you left it, with whatever landed meanwhile drawn underneath. When the turn panel scrolls below its first row, a compact tinted bar replaces the top rule with the current user prompt, collapsed to one line and ellipsized to the terminal width; scrolling back to the top restores the ` ● READER ` chip and `turn <n> of <total>`. Under that fixed header, the turn being read takes most of the screen and a narrow turn list sits to its left, every body row closed by a right border. The list has one row per turn — `❯` on the turn being read, the turn number, the first line of its prompt, and right-aligned markers, `⬡<n>` injected context blocks, `✻` any reasoning, `¶` any reply, `◆<n>` tool calls — with the sections of the turn being read listed under it, `▸` on the one the reader holds, so any turn's own context is one step away. The turn panel scrolls that turn end to end in the conversation's own glyphs, a blank row between each two sections: the prompt opens it behind `❯` on a shaded band, then `✻ Thinking` in dim italic, `¶ Reply` rendered as the conversation renders Markdown — headings, emphasis, inline code, and fenced code in syntax colour — except that unordered bullets are drawn as `•`, a call's `◆` — green once its result landed, yellow while it runs — with the tool name in bold and its headline in the link blue, `⎿ Result` indented under its call with a diff's `+ ` rows green and `- ` rows red on shaded bands and a `read` card's file rows in syntax colour, and `⬡` with the label of an injected context. The section the top row belongs to is accented and carries the conversation walk's `┃` gutter on every row, which reads with no color at all. The bands are mixed from the background color the terminal reports, so a terminal that reports none, or draws no color, draws the panel without them. Rows are never folded there: the reader is where the full model-facing text of a system prompt, an injected snapshot, a long reply, or a tool result is read. `Right` opens the selected turn and `Left` goes back to the list; in the list `Up` / `Down` step one section at a time and cross into the turn either side while `PageUp` / `PageDown` step a whole turn, in the turn they scroll one row at a time, and the section the top row belongs to is where the conversation resumes when the reader closes. `/` opens a query line in place of the legend and narrows the list to the turns whose prompt or text matches, with the readout reading `<kept>/<total> turns`; otherwise the legend rule reports `turn 3/12 · row 14/212` at its right, which no width drops. Below `readerMinColumns` the body draws one panel at a time — the list, or the turn `Right` opens from it — and below 24 columns or 8 rows it draws one dim line, `terminal too small for the reader (needs 24×8)`, and answers only `Esc`, `Ctrl+G`, and `Ctrl+C`. It re-reads the conversation on every render, draws only sections in view, and reuses cached rows when their content, width, and styling match, so long turns stay responsive while the session runs; a streaming reply grows inside it, a landing tool result appears, and a new turn joins the list; a rewrap re-anchors on the section being read rather than on a row number; an approval or a question steps it aside for that prompt's lifetime; and a session switch takes it down with the notice `the transcript changed · reader closed`.
51
+ `Ctrl+G` from any region, `Enter` on a conversation section, and `/turns` read the conversation full screen, one turn at a time. The reader takes the terminal rather than drawing over the conversation: it runs on the terminal's alternate screen, the screen a pager runs on, and the conversation's own screen is held off the terminal for as long as it is up. So it costs the conversation no line, leaves the repaint window where it was, fills the screen on every terminal, and cannot leave a row of itself in your scrollback; closing it restores the conversation exactly as you left it, with whatever landed meanwhile drawn underneath. When the turn panel scrolls below its first row, a compact tinted bar replaces the top rule with the current user prompt, collapsed to one line and ellipsized to the terminal width; scrolling back to the top restores the ` ● READER ` chip and `turn <n> of <total>`. Under that fixed header, the turn being read takes most of the screen and a narrow turn list sits to its left, every body row closed by a right border. The list has one row per turn — `❯` on the turn being read, the turn number, the first line of its prompt, and right-aligned markers, `⬡<n>` injected context blocks, `✻` any reasoning, `¶` any reply, `◆<n>` tool calls — with the sections of the turn being read listed under it, `▸` on the one the reader holds, so any turn's own context is one step away. The turn panel scrolls that turn end to end in the conversation's own glyphs, a blank row between each two sections: the prompt opens it behind `❯` on a shaded band, then `✻ Thinking` in dim italic, `¶ Reply` rendered as the conversation renders Markdown — headings, emphasis, inline code, and fenced code in syntax colour — except that unordered bullets are drawn as `•`, a call's `◆` — green once its result landed, yellow while it runs — with the tool name in bold cyan and its headline in teal, `⎿ Result` indented under its call with a diff's `+ ` rows green and `- ` rows red on shaded bands and a `read` card's file rows in syntax colour, and `⬡` with the label of an injected context. The section the top row belongs to is accented and carries the conversation walk's `┃` gutter on every row, which reads with no color at all. The bands are mixed from the background color the terminal reports, so a terminal that reports none, or draws no color, draws the panel without them. Rows are never folded there: the reader is where the full model-facing text of a system prompt, an injected snapshot, a long reply, or a tool result is read. `Right` opens the selected turn and `Left` goes back to the list; in the list `Up` / `Down` step one section at a time and cross into the turn either side while `PageUp` / `PageDown` step a whole turn, in the turn they scroll one row at a time, and the section the top row belongs to is where the conversation resumes when the reader closes. `/` opens a query line in place of the legend and narrows the list to the turns whose prompt or text matches, with the readout reading `<kept>/<total> turns`; otherwise the legend rule reports `turn 3/12 · row 14/212` at its right, which no width drops. Below `readerMinColumns` the body draws one panel at a time — the list, or the turn `Right` opens from it — and below 24 columns or 8 rows it draws one dim line, `terminal too small for the reader (needs 24×8)`, and answers only `Esc`, `Ctrl+G`, and `Ctrl+C`. It re-reads the conversation on every render, draws only sections in view, and reuses cached rows when their content, width, and styling match, so long turns stay responsive while the session runs; a streaming reply grows inside it, a landing tool result appears, and a new turn joins the list; a rewrap re-anchors on the section being read rather than on a row number; an approval or a question steps it aside for that prompt's lifetime; and a session switch takes it down with the notice `the transcript changed · reader closed`.
52
52
 
53
53
  Transient key feedback floats as a dim framed line in the top-right corner of the viewport: `press Esc again to stop turn <n>`, `press Ctrl+C again to quit`, and `nothing in the transcript to read yet`. It holds at full strength for `toastMs`, fades out, costs the conversation no row of its own, and takes no keyboard; where the renderer can no longer repaint the top of the viewport it is printed into the conversation instead, which keeps it. Facts worth keeping are notices in the conversation: `stopping the turn…`, `wait for the session switch to finish`, `above the repaint window · opened in the reader`, and every command result.
54
54
 
@@ -190,7 +190,7 @@ Typing `/` at the start of the editor completes the terminal's own commands and
190
190
  | `/login` | Sign in with a provider subscription (hides key-collecting logins); `/login <key>` skips the picker |
191
191
  | `/export [dir]` | Write this session's log ZIP (sub-sessions and attachments included) into `dir`, default the workspace |
192
192
  | `/status` | Context window usage and breakdown, token totals with cache hit, session stats, todos, goal, plan mode, and permission |
193
- | `/context` | How the context window is used right now: a grid of 200 cells beside the model, the occupancy, and the estimated tokens of the system prompt, tool definitions, instruction files, skills, other injected context, and messages, then the free space. The cells holding the tokens the newest turn added are the hot region, drawn bold and counted on the `▲ hot` row. Where the terminal runs motion, the grid fills on open and a bright band sweeps through the hot region; while a turn runs the report re-reads the usage every quarter second, marks itself `live`, and blinks the first free cell. It settles once no turn runs and its open animation ended, when another `/context` opens, on a session switch, or once it leaves the repaint window. Reduced motion draws only the settled report |
193
+ | `/context` | How the context window is used right now: a grid of 200 cells beside the model, the occupancy, and the estimated tokens of the system prompt, tool definitions, instruction files, skills, other injected context, and messages, then the free space. Each category draws its cells in its own hue — system blue, tools cyan, instructions orange, skills yellow, other context green, and messages magenta. The cells holding the tokens the newest turn added are the hot region, drawn bold and counted on the `▲ hot` row. Where the terminal runs motion, the grid fills on open and a bright band sweeps through the hot region; while a turn runs the report re-reads the usage every quarter second, marks itself `live`, and blinks the first free cell. It settles once no turn runs and its open animation ended, when another `/context` opens, on a session switch, or once it leaves the repaint window. Reduced motion draws only the settled report |
194
194
  | `/todos` | Browse the agent's todo list; completed rows are scratched out; `Enter` opens one item in full with its status, position, and turns |
195
195
  | `/outline` | The turns of this session with their prompt and reply previews |
196
196
  | `/deliverables` | The files the agent presented, grouped by turn |
@@ -315,7 +315,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
315
315
  | [`src/pinned-prompt.ts`](src/pinned-prompt.ts) | The prompt row the reader pins over a scrolled turn: the glyph, the prompt collapsed to one line, and the band |
316
316
  | [`src/transcript.ts`](src/transcript.ts) | Pure text folding of presentation views, usage, and turn-end reasons, the `$ command` span, and the one fold grammar every marker is written in |
317
317
  | [`src/diff.ts`](src/diff.ts) | Line diff, hunk selection, and the addition and removal marks diff cards box |
318
- | [`src/style.ts`](src/style.ts) | The palette, including the cool dark-mode heading and link hues a Markdown reply uses, the strikethrough role completed todo content uses, the background band a prompt is drawn on and the darker one a steered or injected prompt is drawn on, the green and red fills and sign colours of a diff card's changed rows, whether key chips are clickable, and the derived pi-tui themes |
318
+ | [`src/style.ts`](src/style.ts) | The palette: the Tokyo Night hues as truecolor or 256-color SGR, the semantic roles drawn in them — including the heading and link hues a Markdown reply uses and the tool-name, call-subject, and model hues — the strikethrough role completed todo content uses, the background band a prompt is drawn on and the darker one a steered or injected prompt is drawn on, the green and red fills and sign colours of a diff card's changed rows, whether key chips are clickable, and the derived pi-tui themes |
319
319
  | [`src/highlight.ts`](src/highlight.ts) | Syntax colour for fenced code, file rows, and shell commands: the grammars a block may load, the theme the background picks, and the SGR one token is drawn with |
320
320
  | [`src/completion.ts`](src/completion.ts) | Slash-command and `@`-reference completion for the editor |
321
321
  | [`src/editor.ts`](src/editor.ts) | The prompt editor's terminal caret, its `Shift+Left` / `Shift+Right` mapping to pi-tui word navigation, and syntax colour on a `!` / `!!` draft |
@@ -40,15 +40,15 @@ dsh tui --no-open # print sign-in URLs without opening a
40
40
 
41
41
  ### 屏幕布局
42
42
 
43
- 每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),而在已有模型步骤的轮次中被引导或注入的提示以暗色文字铺在更深的背景带上,退到它所加入的轮次之后,assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,流式期间标题旁的绽放符号随之旋转,每次工具调用是一张卡片,含状态符号(运行中为按工具族混合花朵、绽放与星形的黄色旋转指示、完成为绿色 `◆`、失败为红色 `◆`)、粗体工具名、以紫色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。顶层 workflow 调用还会在该卡片旁另绘一次运行:运行名、成员数、状态,以及一条十格的成员进度条与已结束数,然后是每个阶段和已启动的成员。实时运行进行中时,其 `◇` 以菱形动画脉动,每个运行中成员的 `○` 以子 agent 族的花朵旋转,相位比前一个成员领先一格;从重放日志绘制的运行只在其后台作业仍存活时旋转,减少动效时绘制静态符号。运行中的层级,以及含失败、取消或中断成员的层级会展开;干净完成的层级保持折叠。在运行或阶段上按 Space 或 Enter 折叠该层,在仍在运行的成员上按 Enter 只会在该子会话是本会话的直接子会话且仍在本进程运行时打开它。卡片在模型开始调用时出现,并逐行向外流出,每行从左到右,无论卡片装着什么,速度都一致:一整行宽的内容需 `toolRevealFrames` 帧,较短的行按比例更短,刚画出的列会从终端背景色亮起到各自的颜色。工具回答后,结果行也以同样方式流出,排在卡片尚未画完的内容之后;调用与结果都不会等待动画。`edit` 或 `write` diff 卡片把每一新增行整行铺满绿色背景、每一删除行整行铺满红色背景,删除的旧行在上、新增的新行在下,并把 `+` 与 `-` 画成各自更亮的颜色,使符号从填充色中读得出来;折行续行只延续填充色,不再画第二个符号;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样的状态符号,运行中旋转,交给后台的子 agent 则为暗色 `◆`:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词则省略。一次压缩(compaction)——无论来自 `/compact` 还是自动触发——绘制为一个上下文块,其强调色 `⬡` 标题写明来源,以及被替换内容与摘要各自的估算 token 数,如 `context compacted by /compact · ~6.4k → ~0.9k tokens` 或 `context compacted automatically in turn 12 · …`;标题之下,`compressed` 写明摘要替换的条目数与轮次、其中的每条提示(最多五条,每条一行),以及回复、按工具分列的工具结果、上下文块与更早摘要的计数,`preserved` 写明系统提示词以及之后每一轮仍逐字保留的内容;这两部分始终绘出,其下的摘要则像其他上下文块一样折叠到 `contextPreviewLines` 行。检查点消息本身不再重复绘制。日志以错误结束的 `/compact` 尝试会在会话重绘时打印 `/compact failed · <error>`,因为实时运行的命令会自己报告失败;失败的自动尝试不改变任何内容,也不绘制任何内容,与浏览器一致。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用暖橙色,链接与行内代码使用紫色,引用保持暗色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理在同一时长内浮出:以抬高的颜色出现,再退回到稳定时的暗色斜体。工具卡片的每一列则在这段时长内从终端背景色亮起到它稳定时的调色板颜色;从持久化历史重绘的卡片不带流出或淡入,已经稳定下来的文字也不会再被调暗。
43
+ 每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),而在已有模型步骤的轮次中被引导或注入的提示以暗色文字铺在更深的背景带上,退到它所加入的轮次之后,assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,流式期间标题旁的绽放符号随之旋转,每次工具调用是一张卡片,含状态符号(运行中为按工具族混合花朵、绽放与星形的黄色旋转指示、完成为绿色 `◆`、失败为红色 `◆`)、粗体青色工具名、以蓝绿色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。顶层 workflow 调用还会在该卡片旁另绘一次运行:运行名、成员数、状态,以及一条十格的成员进度条与已结束数,然后是每个阶段和已启动的成员。实时运行进行中时,其 `◇` 以菱形动画脉动,每个运行中成员的 `○` 以子 agent 族的花朵旋转,相位比前一个成员领先一格;从重放日志绘制的运行只在其后台作业仍存活时旋转,减少动效时绘制静态符号。运行中的层级,以及含失败、取消或中断成员的层级会展开;干净完成的层级保持折叠。在运行或阶段上按 Space 或 Enter 折叠该层,在仍在运行的成员上按 Enter 只会在该子会话是本会话的直接子会话且仍在本进程运行时打开它。卡片在模型开始调用时出现,并逐行向外流出,每行从左到右,无论卡片装着什么,速度都一致:一整行宽的内容需 `toolRevealFrames` 帧,较短的行按比例更短,刚画出的列会从终端背景色亮起到各自的颜色。工具回答后,结果行也以同样方式流出,排在卡片尚未画完的内容之后;调用与结果都不会等待动画。`edit` 或 `write` diff 卡片把每一新增行整行铺满绿色背景、每一删除行整行铺满红色背景,删除的旧行在上、新增的新行在下,并把 `+` 与 `-` 画成各自更亮的颜色,使符号从填充色中读得出来;折行续行只延续填充色,不再画第二个符号;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样的状态符号,运行中旋转,交给后台的子 agent 则为暗色 `◆`:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词则省略。一次压缩(compaction)——无论来自 `/compact` 还是自动触发——绘制为一个上下文块,其强调色 `⬡` 标题写明来源,以及被替换内容与摘要各自的估算 token 数,如 `context compacted by /compact · ~6.4k → ~0.9k tokens` 或 `context compacted automatically in turn 12 · …`;标题之下,`compressed` 写明摘要替换的条目数与轮次、其中的每条提示(最多五条,每条一行),以及回复、按工具分列的工具结果、上下文块与更早摘要的计数,`preserved` 写明系统提示词以及之后每一轮仍逐字保留的内容;这两部分始终绘出,其下的摘要则像其他上下文块一样折叠到 `contextPreviewLines` 行。检查点消息本身不再重复绘制。日志以错误结束的 `/compact` 尝试会在会话重绘时打印 `/compact failed · <error>`,因为实时运行的命令会自己报告失败;失败的自动尝试不改变任何内容,也不绘制任何内容,与浏览器一致。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用橙色,链接与行内代码使用品红色,引用保持暗色。每种色相都是 Tokyo Night(Night)配色,当 `COLORTERM` 声明 `truecolor` 或 `24bit` 时按原色精确绘制,否则取 256 色索引中最接近的一色;背景带保留其 256 色灰阶与 diff 底色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理在同一时长内浮出:以抬高的颜色出现,再退回到稳定时的暗色斜体。工具卡片的每一列则在这段时长内从终端背景色亮起到它稳定时的调色板颜色;从持久化历史重绘的卡片不带流出或淡入,已经稳定下来的文字也不会再被调暗。
44
44
 
45
- 对话记录下方依次是 agent 工作时的旋转指示——`thinking`、`writing`、`calling <tool>`、重试或 `compacting`,各自旁边是它自己的盲文动画:环绕的点、逐行填满的线、绕行的单点、滑动的横条,或沉降又回满的方格——标签单词上带着一道扫过的高亮,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与最新后代行的 activity board(有行时才绘制;已完成内容划掉,状态符号以绿色、黄色或青色显示,进行中的那一项为旋转指示,todo 最多四行其后 `+<n> more`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型与入口按键带有颜色;进行中的轮次、上下文与 todo 信息分别使用黄色、紫色与绿色。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,有 follow-ups 等待时则写作 `Shift+↑ select · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
45
+ 对话记录下方依次是 agent 工作时的旋转指示——`thinking`、`writing`、`calling <tool>`、重试或 `compacting`,各自旁边是它自己的盲文动画:环绕的点、逐行填满的线、绕行的单点、滑动的横条,或沉降又回满的方格——标签单词上带着一道扫过的高亮,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与最新后代行的 activity board(有行时才绘制;已完成内容划掉,状态符号以绿色、黄色或蓝色显示,进行中的那一项为旋转指示,todo 最多四行其后 `+<n> more`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型为紫色,入口按键为品红色;进行中的轮次、上下文与 todo 信息分别使用黄色、品红色与绿色。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,有 follow-ups 等待时则写作 `Shift+↑ select · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
46
46
 
47
47
  键盘在对话记录中移动时,编辑器正上方停靠着一个带边框的检视面板,边框即模式:它恰好在对话记录持有键盘时绘制。其顶边线带有一个反白的 ` ● READ ` 徽标与当前聚焦小节的标题——该小节在可导航块中的位置、所属轮次,以及这是哪一种小节——例如 `╭ ● READ ─ 3/12 · turn 2 · bash git status · result ─╮`。其下在块含多个部分时,把这些部分绘制成形如 `← 1 call · [2 result] →` 的带编号、会折行的选择行,被持有的标签除强调色外还加上方括号,因此完全无颜色时选择仍然可读;再往下是该小节自身的源文本行,每行左右两侧都由 `│ ` 边框闭合并按窄四列换行,对每一种小节——含系统提示词与注入的上下文——都折叠到 `focusPreviewLines` 行,其下写出 `… <n> more rows · Ctrl+G reads it`。底边线列出对话记录所应答的按键 `↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input`,随着终端列数减少收缩为 `↑↓ ←→ · Space folds · Esc input`,再收缩为 `Esc input`。
48
48
 
49
49
  被聚焦的块也会在原地被标记:一条两列宽的标记条,在块的其他行旁为暗色、在被聚焦小节自身的行旁为强调色——若折叠把该小节整个留在了绘出的行之外,强调色便落在那一行折叠标记旁——标记绘制期间该块的内容按窄两列换行。这个标记只能落在 pi-tui 仍以差分方式重绘的行上——也就是它写出的上一帧的最后 `rows` 行,这条边界只会被更高的帧抬高、不会被更矮的帧降低——因为改动其上方的任何一行都会清空终端的回滚区。已经滚过该位置的块不带标记条,检视面板的标题追加 ` · off screen`,其边框线也改画暗色而非强调色,于是边框本身就报告出标记无法画在该块所在之处。淡入中的各行抵达这一边界时,会在写出它们的同一帧内被结算为最终颜色,因此回滚区里不会留下暗色文字。
50
50
 
51
- 在任一区域按 `Ctrl+G`、在对话记录的某个小节上按 `Enter`,以及 `/turns`,都会整屏读出对话记录,一次读一个轮次。阅读器并不画在对话记录之上,而是接管终端:它运行在终端的备用屏幕(alternate screen,分页器所用的那块屏幕)上,只要它还开着,对话记录自己的屏幕就被挡在终端之外。因此它不占用对话记录的任何一行,让重绘边界保持原位,在任何终端上都铺满整屏,也不可能把自己的任何一行留在你的回滚缓冲里;关闭它会把对话记录原样恢复成你离开时的样子,期间落地的内容则绘制在其下方。轮次面板滚过首行后,紧凑的着色条会替代顶边线,将当前用户提示合并为一行,并按终端宽度以省略号截断;滚回顶部时恢复 ` ● READER ` 徽标与 `turn <n> of <total>`。在这个固定页眉之下,正在阅读的轮次占据屏幕的大部分,左侧是一列窄的轮次列表,每个正文行都以右边框收口。列表每个轮次一行——正在阅读的轮次带 `❯`、轮次编号、其提示的首行,以及右对齐的标记 `⬡<n>` 注入上下文块数、`✻` 有推理、`¶` 有回复、`◆<n>` 工具调用数——并在正在阅读的那个轮次之下列出它的各小节,`▸` 落在阅读器所持的那一个上,因此任何轮次自己的上下文都只有一步之遥。轮次面板用对话记录自己的符号把该轮次从头到尾滚动读出,相邻两个小节之间隔一空行:提示以 `❯` 开头、铺在着色背景带上,其后是暗色斜体的 `✻ Thinking`、按对话记录的方式渲染 Markdown(标题、强调、行内代码,以及带语法着色的围栏代码)但无序列表符号画成 `•` 的 `¶ Reply`、工具调用的 `◆`(结果落地后为绿色、运行中为黄色)连同粗体工具名与链接蓝色的标题、缩进在调用之下的 `⎿ Result`(diff 的 `+ ` 行为绿色、`- ` 行为红色,各铺在着色背景带上;`read` 卡片的文件行带语法着色),以及带注入上下文标签的 `⬡`。顶行所属的小节带强调色,并在每一行带上对话记录走查所用的 `┃` 标记条,无色时也能辨认。背景带由终端报告的背景色混合而成,因此没有报告背景色、或不绘制颜色的终端画出的面板不带背景带。那里的行从不折叠:阅读器正是读取系统提示词、注入快照、长回复或工具结果完整面向模型文本的地方。`Right` 打开被选中的轮次,`Left` 回到轮次列表;在列表中 `Up` / `Down` 每次步进一个小节并跨入相邻的轮次,而 `PageUp` / `PageDown` 步进整个轮次;在轮次面板中它们逐行滚动,而顶行所属的小节就是阅读器关闭后对话记录恢复到的位置。`/` 在按键提示的位置打开一行查询,把轮次列表收窄到提示或文本匹配的轮次,读数写作 `<kept>/<total> turns`;其余时候提示边线在右端报告 `turn 3/12 · row 14/212`,任何宽度都不会丢弃它。列数不足 `readerMinColumns` 时正文一次只画一个面板——轮次列表,或由 `Right` 从中打开的那个轮次——不足 24 列或 8 行时只画一行暗色文字 `terminal too small for the reader (needs 24×8)`,并且只应答 `Esc`、`Ctrl+G` 与 `Ctrl+C`。它每一帧都会重新读取对话记录,只绘制视区内的小节,并在内容、宽度和样式与缓存匹配时复用已有行,因此长轮次在会话运行期间仍能保持响应;流式回复会在其中增长、落地的工具结果会出现、新轮次会加入轮次列表;重新换行时它按正在阅读的小节重新锚定,而不是按行号;审批或提问出现时它在该提示存续期间让位;切换会话会让它随通知 `the transcript changed · reader closed` 一同关闭。
51
+ 在任一区域按 `Ctrl+G`、在对话记录的某个小节上按 `Enter`,以及 `/turns`,都会整屏读出对话记录,一次读一个轮次。阅读器并不画在对话记录之上,而是接管终端:它运行在终端的备用屏幕(alternate screen,分页器所用的那块屏幕)上,只要它还开着,对话记录自己的屏幕就被挡在终端之外。因此它不占用对话记录的任何一行,让重绘边界保持原位,在任何终端上都铺满整屏,也不可能把自己的任何一行留在你的回滚缓冲里;关闭它会把对话记录原样恢复成你离开时的样子,期间落地的内容则绘制在其下方。轮次面板滚过首行后,紧凑的着色条会替代顶边线,将当前用户提示合并为一行,并按终端宽度以省略号截断;滚回顶部时恢复 ` ● READER ` 徽标与 `turn <n> of <total>`。在这个固定页眉之下,正在阅读的轮次占据屏幕的大部分,左侧是一列窄的轮次列表,每个正文行都以右边框收口。列表每个轮次一行——正在阅读的轮次带 `❯`、轮次编号、其提示的首行,以及右对齐的标记 `⬡<n>` 注入上下文块数、`✻` 有推理、`¶` 有回复、`◆<n>` 工具调用数——并在正在阅读的那个轮次之下列出它的各小节,`▸` 落在阅读器所持的那一个上,因此任何轮次自己的上下文都只有一步之遥。轮次面板用对话记录自己的符号把该轮次从头到尾滚动读出,相邻两个小节之间隔一空行:提示以 `❯` 开头、铺在着色背景带上,其后是暗色斜体的 `✻ Thinking`、按对话记录的方式渲染 Markdown(标题、强调、行内代码,以及带语法着色的围栏代码)但无序列表符号画成 `•` 的 `¶ Reply`、工具调用的 `◆`(结果落地后为绿色、运行中为黄色)连同粗体青色工具名与蓝绿色的标题、缩进在调用之下的 `⎿ Result`(diff 的 `+ ` 行为绿色、`- ` 行为红色,各铺在着色背景带上;`read` 卡片的文件行带语法着色),以及带注入上下文标签的 `⬡`。顶行所属的小节带强调色,并在每一行带上对话记录走查所用的 `┃` 标记条,无色时也能辨认。背景带由终端报告的背景色混合而成,因此没有报告背景色、或不绘制颜色的终端画出的面板不带背景带。那里的行从不折叠:阅读器正是读取系统提示词、注入快照、长回复或工具结果完整面向模型文本的地方。`Right` 打开被选中的轮次,`Left` 回到轮次列表;在列表中 `Up` / `Down` 每次步进一个小节并跨入相邻的轮次,而 `PageUp` / `PageDown` 步进整个轮次;在轮次面板中它们逐行滚动,而顶行所属的小节就是阅读器关闭后对话记录恢复到的位置。`/` 在按键提示的位置打开一行查询,把轮次列表收窄到提示或文本匹配的轮次,读数写作 `<kept>/<total> turns`;其余时候提示边线在右端报告 `turn 3/12 · row 14/212`,任何宽度都不会丢弃它。列数不足 `readerMinColumns` 时正文一次只画一个面板——轮次列表,或由 `Right` 从中打开的那个轮次——不足 24 列或 8 行时只画一行暗色文字 `terminal too small for the reader (needs 24×8)`,并且只应答 `Esc`、`Ctrl+G` 与 `Ctrl+C`。它每一帧都会重新读取对话记录,只绘制视区内的小节,并在内容、宽度和样式与缓存匹配时复用已有行,因此长轮次在会话运行期间仍能保持响应;流式回复会在其中增长、落地的工具结果会出现、新轮次会加入轮次列表;重新换行时它按正在阅读的小节重新锚定,而不是按行号;审批或提问出现时它在该提示存续期间让位;切换会话会让它随通知 `the transcript changed · reader closed` 一同关闭。
52
52
 
53
53
  临时按键反馈以一行暗色带框文字浮在视口右上角:`press Esc again to stop turn <n>`、`press Ctrl+C again to quit` 与 `nothing in the transcript to read yet`。它以全亮度保持 `toastMs`、随后淡出,不占用对话记录自身的任何一行,也不接管键盘;渲染器已无法重绘视口顶部时,它改为打印进对话记录,从而被保留下来。值得留存的事实则是对话记录中的通知:`stopping the turn…`、`wait for the session switch to finish`、`above the repaint window · opened in the reader` 以及每一条命令结果。
54
54
 
@@ -190,7 +190,7 @@ follow-ups 面板持有键盘时:
190
190
  | `/login` | 用提供方订阅登录(隐藏仅收集密钥的登录);`/login <key>` 跳过选择器 |
191
191
  | `/export [dir]` | 把本会话的日志 ZIP(含子会话与附件)写入 `dir`,默认 workspace |
192
192
  | `/status` | 上下文窗口用量与构成、含缓存命中的 token 总计、会话统计、todo、目标、计划模式与权限 |
193
- | `/context` | 上下文窗口此刻的用法:200 个单元格的网格,旁边是模型、占用,以及系统提示词、工具定义、指令文件、技能、其他注入上下文与消息的估算 token,最后是剩余空间。保存最新一轮新增 token 的单元格是热区,以粗体绘制,并在 `▲ hot` 行计数。终端运行动效时,网格在打开时逐格填充,一道亮带扫过热区;轮次进行期间,报告每四分之一秒重新读取用量、标记为 `live`,并让第一个空闲单元格闪烁。当没有轮次进行且打开动画结束、另一个 `/context` 打开、会话切换,或它离开重绘窗口时,报告定格。减弱动效时只绘制定格后的报告 |
193
+ | `/context` | 上下文窗口此刻的用法:200 个单元格的网格,旁边是模型、占用,以及系统提示词、工具定义、指令文件、技能、其他注入上下文与消息的估算 token,最后是剩余空间。每个类别以自己的色相绘制单元格——系统提示词蓝色、工具青色、指令橙色、技能黄色、其他上下文绿色、消息品红色。保存最新一轮新增 token 的单元格是热区,以粗体绘制,并在 `▲ hot` 行计数。终端运行动效时,网格在打开时逐格填充,一道亮带扫过热区;轮次进行期间,报告每四分之一秒重新读取用量、标记为 `live`,并让第一个空闲单元格闪烁。当没有轮次进行且打开动画结束、另一个 `/context` 打开、会话切换,或它离开重绘窗口时,报告定格。减弱动效时只绘制定格后的报告 |
194
194
  | `/todos` | 浏览 agent 的 todo 列表;已完成行会被划掉;`Enter` 完整打开其中一条,含其状态、位置与轮次 |
195
195
  | `/outline` | 本会话各轮次及其提示与回复预览 |
196
196
  | `/deliverables` | agent 交付的文件,按轮次分组 |
@@ -315,7 +315,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
315
315
  | [`src/pinned-prompt.ts`](src/pinned-prompt.ts) | 阅读器在轮次面板滚动后固定在顶部的提示行:符号、合并为一行的提示,以及背景带 |
316
316
  | [`src/transcript.ts`](src/transcript.ts) | 呈现视图、用量与轮次结束原因的纯文本折叠、`$ command` 的 span,以及每条标记共用的那一套折叠措辞 |
317
317
  | [`src/diff.ts`](src/diff.ts) | diff 卡片的行 diff、hunk 选择,以及卡片加框所依据的新增与删除标记 |
318
- | [`src/style.ts`](src/style.ts) | 调色板(含 Markdown 回复所用的暗色冷色阶标题与链接色、已完成 todo 内容所用的划线角色、提示所铺的背景带与被引导或注入的提示所铺的更深背景带、diff 卡片变更行的绿色与红色填充及符号颜色)、按键徽标是否可点击,以及派生的 pi-tui 主题 |
318
+ | [`src/style.ts`](src/style.ts) | 调色板:以真彩色或 256 色 SGR 表示的 Tokyo Night 色相,以及用这些色相绘制的语义角色(含 Markdown 回复所用的标题与链接色、工具名、调用对象与模型的色相、已完成 todo 内容所用的划线角色、提示所铺的背景带与被引导或注入的提示所铺的更深背景带、diff 卡片变更行的绿色与红色填充及符号颜色)、按键徽标是否可点击,以及派生的 pi-tui 主题 |
319
319
  | [`src/highlight.ts`](src/highlight.ts) | 围栏代码、文件行与 shell 命令的语法高亮:某个块可能加载的语法、由背景选定的配色主题,以及一个 token 所用的 SGR |
320
320
  | [`src/completion.ts`](src/completion.ts) | 编辑器的斜杠命令与 `@` 引用补全 |
321
321
  | [`src/editor.ts`](src/editor.ts) | 提示编辑器的终端光标、把 `Shift+Left` / `Shift+Right` 映射到 pi-tui 词导航的逻辑,以及 `!` / `!!` 草稿上的语法高亮 |
@@ -2324,6 +2324,280 @@ function sliceColumns(line, cuts) {
2324
2324
  }
2325
2325
  return pieces;
2326
2326
  }
2327
+ //#endregion
2328
+ //#region lib/types/style.js
2329
+ /**
2330
+ * The terminal palette: one table of SGR open/close pairs behind named roles,
2331
+ * so components never emit raw escape codes. Colored roles draw from the
2332
+ * Tokyo Night (Night) hues, as 24-bit color on a terminal that declares
2333
+ * truecolor and as the nearest xterm-256 index otherwise. A disabled palette
2334
+ * returns text unchanged for dumb terminals and captured output. The palette
2335
+ * also says whether the keys a surface names are clickable, because it is what
2336
+ * every surface draws a key chip with.
2337
+ * @module @deepseek-ai/dsh-tui-app/style
2338
+ */
2339
+ const ESC = "\x1B[";
2340
+ /** SGR that resets the foreground, closing every hue. */
2341
+ const FOREGROUND_CLOSE = "39";
2342
+ /** Each hue's Tokyo Night (Night) color and its nearest xterm-256 index. */
2343
+ const HUES = {
2344
+ blue: ["#7aa2f7", 111],
2345
+ cyan: ["#7dcfff", 117],
2346
+ teal: ["#73daca", 80],
2347
+ green: ["#9ece6a", 149],
2348
+ yellow: ["#e0af68", 179],
2349
+ orange: ["#ff9e64", 215],
2350
+ red: ["#f7768e", 210],
2351
+ magenta: ["#bb9af7", 141],
2352
+ purple: ["#9d7cd8", 140]
2353
+ };
2354
+ /** The hue each colored role draws in. */
2355
+ const ROLE_HUES = {
2356
+ accent: "blue",
2357
+ heading: "orange",
2358
+ link: "magenta",
2359
+ success: "green",
2360
+ warning: "yellow",
2361
+ error: "red",
2362
+ tool: "cyan",
2363
+ subject: "teal",
2364
+ model: "purple",
2365
+ addedSign: "green",
2366
+ removedSign: "red"
2367
+ };
2368
+ /** SGR open/close code pairs of the roles that are not a hue. */
2369
+ const SGR = {
2370
+ dim: ["2", "22"],
2371
+ bold: ["1", "22"],
2372
+ italic: ["3", "23"],
2373
+ underline: ["4", "24"],
2374
+ strikethrough: ["9", "29"],
2375
+ inverse: ["7", "27"],
2376
+ band: ["48;5;236", "49"],
2377
+ injectedBand: ["48;5;234", "49"],
2378
+ addedBand: ["48;5;22", "49"],
2379
+ removedBand: ["48;5;52", "49"]
2380
+ };
2381
+ /**
2382
+ * The SGR parameters that set one hue as the foreground.
2383
+ * @param hue - the hue.
2384
+ * @param depth - how the terminal encodes it.
2385
+ * @returns e.g. `38;2;122;162;247` or `38;5;111`.
2386
+ */
2387
+ function hueOpen(hue, depth) {
2388
+ const [rgb, ansi256] = HUES[hue];
2389
+ if (depth === "ansi256") return `38;5;${String(ansi256)}`;
2390
+ const value = Number.parseInt(rgb.slice(1), 16);
2391
+ return `38;2;${String(value >> 16)};${String(value >> 8 & 255)};${String(value & 255)}`;
2392
+ }
2393
+ /**
2394
+ * Whether the environment declares 24-bit color: `COLORTERM` of `truecolor` or `24bit`.
2395
+ * @param env - the process environment.
2396
+ * @returns true when `ESC[38;2;R;G;Bm` is understood.
2397
+ */
2398
+ function declaresTruecolor(env) {
2399
+ const colorterm = (env.COLORTERM ?? "").toLowerCase();
2400
+ return colorterm === "truecolor" || colorterm === "24bit";
2401
+ }
2402
+ /**
2403
+ * Decide how the palette encodes its hues.
2404
+ * @param env - the process environment.
2405
+ * @returns `truecolor` when the environment declares it, otherwise `ansi256`.
2406
+ */
2407
+ function paletteDepth(env) {
2408
+ return declaresTruecolor(env) ? "truecolor" : "ansi256";
2409
+ }
2410
+ /**
2411
+ * Build the palette.
2412
+ * @param enabled - whether escape sequences are emitted; false makes every role the identity.
2413
+ * @param clickableKeys - whether key chips carry click marks; false by default.
2414
+ * @param depth - how hues are encoded; `ansi256` by default.
2415
+ * @returns the palette.
2416
+ */
2417
+ function createPalette(enabled, clickableKeys = false, depth = "ansi256") {
2418
+ const wrap = (open, close) => enabled ? (text) => `${ESC}${open}m${text}${ESC}${close}m` : (text) => text;
2419
+ const role = (name) => wrap(...SGR[name]);
2420
+ const paint = (name) => wrap(hueOpen(name, depth), FOREGROUND_CLOSE);
2421
+ const hue = {
2422
+ blue: paint("blue"),
2423
+ cyan: paint("cyan"),
2424
+ teal: paint("teal"),
2425
+ green: paint("green"),
2426
+ yellow: paint("yellow"),
2427
+ orange: paint("orange"),
2428
+ red: paint("red"),
2429
+ magenta: paint("magenta"),
2430
+ purple: paint("purple")
2431
+ };
2432
+ const colored = (name) => hue[ROLE_HUES[name]];
2433
+ return {
2434
+ dim: role("dim"),
2435
+ bold: role("bold"),
2436
+ italic: role("italic"),
2437
+ underline: role("underline"),
2438
+ strikethrough: role("strikethrough"),
2439
+ accent: colored("accent"),
2440
+ heading: colored("heading"),
2441
+ link: colored("link"),
2442
+ success: colored("success"),
2443
+ warning: colored("warning"),
2444
+ error: colored("error"),
2445
+ tool: colored("tool"),
2446
+ subject: colored("subject"),
2447
+ model: colored("model"),
2448
+ inverse: role("inverse"),
2449
+ band: role("band"),
2450
+ injectedBand: role("injectedBand"),
2451
+ addedBand: role("addedBand"),
2452
+ removedBand: role("removedBand"),
2453
+ addedSign: colored("addedSign"),
2454
+ removedSign: colored("removedSign"),
2455
+ hue,
2456
+ enabled,
2457
+ clickableKeys
2458
+ };
2459
+ }
2460
+ /**
2461
+ * Paint added and removed diff rows while leaving context and metadata rows
2462
+ * unchanged. `source` stays plain so syntax-colored rows can be classified.
2463
+ * @param rows - rows after optional syntax highlighting.
2464
+ * @param source - corresponding plain rows carrying the diff prefixes.
2465
+ * @param palette - active terminal palette.
2466
+ * @returns the rows with additions green and removals red.
2467
+ */
2468
+ function paintDiffRows(rows, source, palette) {
2469
+ return rows.map((row, index) => {
2470
+ const plain = source[index];
2471
+ if (plain?.startsWith("+ ") === true) return palette.success(row);
2472
+ if (plain?.startsWith("- ") === true) return palette.error(row);
2473
+ return row;
2474
+ });
2475
+ }
2476
+ /**
2477
+ * Lay one row on a background tint across the full width.
2478
+ * @param palette - the active palette.
2479
+ * @param row - the styled row, at most `width` columns.
2480
+ * @param width - the columns the band spans.
2481
+ * @param band - the tint; {@link Palette.band} by default.
2482
+ * @returns the row padded to `width` under the tint; the row unchanged, with
2483
+ * no padding, when the palette is disabled.
2484
+ */
2485
+ function bandRow(palette, row, width, band = palette.band) {
2486
+ return palette.enabled ? band(`${row}${" ".repeat(Math.max(0, width - visibleWidth(row)))}`) : row;
2487
+ }
2488
+ /**
2489
+ * The `+` or `-` of a changed row, painted apart from the tint the row is
2490
+ * filled with. The sign sits in the plain row's own prefix - the file line
2491
+ * number, when the diff carries one, then the sign and a space - and syntax
2492
+ * colour starts after it, so the styled row opens with the same characters.
2493
+ * @param row - the styled row.
2494
+ * @param plain - the same row before any syntax colour.
2495
+ * @param mark - whether the row is an addition or a removal.
2496
+ * @param palette - the active palette.
2497
+ * @returns the row with its sign painted, or unchanged when the styled row
2498
+ * does not open with the plain prefix.
2499
+ */
2500
+ function paintDiffSign(row, plain, mark, palette) {
2501
+ const sign = mark === "added" ? "+" : "-";
2502
+ const at = plain.indexOf(`${sign} `);
2503
+ if (at === -1 || !row.startsWith(plain.slice(0, at + 1))) return row;
2504
+ const paint = mark === "added" ? palette.addedSign : palette.removedSign;
2505
+ return `${row.slice(0, at)}${paint(sign)}${row.slice(at + 1)}`;
2506
+ }
2507
+ /**
2508
+ * Wrap rows to `width` and fill each changed row edge to edge with its own
2509
+ * background tint - green for an addition, red for a removal - so a run of
2510
+ * changes reads as one region without spending a column on a border. The `+`
2511
+ * and `-` are painted in their own lighter colour, apart from the fill, and a
2512
+ * wrapped continuation carries the tint with no sign of its own. Every
2513
+ * returned line is at most `width` columns, and every filled line is exactly
2514
+ * `width`; a disabled palette pads nothing and returns the rows as they are.
2515
+ * @param rows - the styled rows.
2516
+ * @param plain - the same rows before any syntax colour, which carry the signs.
2517
+ * @param marks - per row, whether it is an addition or a removal; undefined
2518
+ * for a row no tint fills.
2519
+ * @param width - the columns the rows fit.
2520
+ * @param palette - the active palette.
2521
+ * @returns the wrapped rows, the changed ones filled.
2522
+ */
2523
+ function bandDiffRows(rows, plain, marks, width, palette) {
2524
+ const columns = Math.max(1, width);
2525
+ const out = [];
2526
+ for (const [index, row] of rows.entries()) {
2527
+ const mark = marks[index];
2528
+ if (mark === void 0) {
2529
+ out.push(...wrapTextWithAnsi(row, columns));
2530
+ continue;
2531
+ }
2532
+ const fill = mark === "added" ? palette.addedBand : palette.removedBand;
2533
+ const signed = paintDiffSign(row, plain[index] ?? "", mark, palette);
2534
+ for (const part of wrapTextWithAnsi(signed, columns)) out.push(palette.enabled ? fill(`${part}${" ".repeat(Math.max(0, columns - visibleWidth(part)))}`) : part);
2535
+ }
2536
+ return out;
2537
+ }
2538
+ /**
2539
+ * Decide whether the terminal gets color: `NO_COLOR` (any non-empty value)
2540
+ * wins, then a non-empty non-zero `FORCE_COLOR`, then whether stdout is a TTY.
2541
+ * @param env - the process environment.
2542
+ * @param isTty - whether stdout is a terminal.
2543
+ * @returns true when SGR styling should be emitted.
2544
+ */
2545
+ function colorEnabled(env, isTty) {
2546
+ if (env.NO_COLOR !== void 0 && env.NO_COLOR !== "") return false;
2547
+ if (env.FORCE_COLOR !== void 0 && env.FORCE_COLOR !== "" && env.FORCE_COLOR !== "0") return true;
2548
+ return isTty;
2549
+ }
2550
+ /**
2551
+ * The Markdown theme derived from the palette.
2552
+ * @param palette - the active palette.
2553
+ * @param highlight - colours fenced code; omitted draws every block plain,
2554
+ * which is also what a block whose language has no grammar here draws as.
2555
+ * @returns a complete pi-tui Markdown theme.
2556
+ */
2557
+ function markdownTheme(palette, highlight) {
2558
+ return {
2559
+ highlightCode: (code, lang) => highlight?.lines(code, lang) ?? code.split("\n"),
2560
+ heading: (text) => palette.bold(palette.heading(text)),
2561
+ link: (text) => palette.underline(palette.link(text)),
2562
+ linkUrl: palette.dim,
2563
+ code: palette.link,
2564
+ codeBlock: (text) => text,
2565
+ codeBlockBorder: palette.dim,
2566
+ quote: (text) => palette.italic(palette.dim(text)),
2567
+ quoteBorder: palette.dim,
2568
+ hr: palette.dim,
2569
+ listBullet: palette.heading,
2570
+ bold: palette.bold,
2571
+ italic: palette.italic,
2572
+ strikethrough: palette.strikethrough,
2573
+ underline: palette.underline
2574
+ };
2575
+ }
2576
+ /**
2577
+ * The select-list theme derived from the palette.
2578
+ * @param palette - the active palette.
2579
+ * @returns a complete pi-tui select-list theme.
2580
+ */
2581
+ function selectListTheme(palette) {
2582
+ return {
2583
+ selectedPrefix: palette.accent,
2584
+ selectedText: (text) => palette.bold(palette.accent(text)),
2585
+ description: palette.dim,
2586
+ scrollInfo: palette.dim,
2587
+ noMatch: palette.dim
2588
+ };
2589
+ }
2590
+ /**
2591
+ * The editor theme derived from the palette.
2592
+ * @param palette - the active palette.
2593
+ * @returns a complete pi-tui editor theme.
2594
+ */
2595
+ function editorTheme(palette) {
2596
+ return {
2597
+ borderColor: palette.dim,
2598
+ selectList: selectListTheme(palette)
2599
+ };
2600
+ }
2327
2601
  /** Control Sequence Introducer. */
2328
2602
  const CSI$2 = "\x1B[";
2329
2603
  /**
@@ -2391,8 +2665,7 @@ function resolveFadeCapability(input) {
2391
2665
  if (env.NO_COLOR !== void 0 && env.NO_COLOR !== "") return "none";
2392
2666
  const term = env.TERM ?? "";
2393
2667
  if (term === "dumb") return "none";
2394
- const colorterm = (env.COLORTERM ?? "").toLowerCase();
2395
- if (colorterm === "truecolor" || colorterm === "24bit") return "truecolor";
2668
+ if (declaresTruecolor(env)) return "truecolor";
2396
2669
  return term.includes("256color") ? "ansi256" : "dim";
2397
2670
  }
2398
2671
  /**
@@ -3455,213 +3728,6 @@ var TailWrappedText = class {
3455
3728
  }
3456
3729
  };
3457
3730
  //#endregion
3458
- //#region lib/types/style.js
3459
- /**
3460
- * The terminal palette: one table of SGR open/close pairs behind named roles,
3461
- * so components never emit raw escape codes. A disabled palette returns text
3462
- * unchanged for dumb terminals and captured output. The palette also says
3463
- * whether the keys a surface names are clickable, because it is what every
3464
- * surface draws a key chip with.
3465
- * @module @deepseek-ai/dsh-tui-app/style
3466
- */
3467
- const ESC = "\x1B[";
3468
- /** SGR open/close code pairs by role. */
3469
- const SGR = {
3470
- dim: ["2", "22"],
3471
- bold: ["1", "22"],
3472
- italic: ["3", "23"],
3473
- underline: ["4", "24"],
3474
- strikethrough: ["9", "29"],
3475
- accent: ["36", "39"],
3476
- heading: ["38;5;215", "39"],
3477
- link: ["38;5;141", "39"],
3478
- success: ["32", "39"],
3479
- warning: ["33", "39"],
3480
- error: ["31", "39"],
3481
- inverse: ["7", "27"],
3482
- band: ["48;5;236", "49"],
3483
- injectedBand: ["48;5;234", "49"],
3484
- addedBand: ["48;5;22", "49"],
3485
- removedBand: ["48;5;52", "49"],
3486
- addedSign: ["38;5;120", "39"],
3487
- removedSign: ["38;5;210", "39"]
3488
- };
3489
- /**
3490
- * Build the palette.
3491
- * @param enabled - whether escape sequences are emitted; false makes every role the identity.
3492
- * @param clickableKeys - whether key chips carry click marks; false by default.
3493
- * @returns the palette.
3494
- */
3495
- function createPalette(enabled, clickableKeys = false) {
3496
- const role = (name) => {
3497
- const [open, close] = SGR[name];
3498
- return enabled ? (text) => `${ESC}${open}m${text}${ESC}${close}m` : (text) => text;
3499
- };
3500
- return {
3501
- dim: role("dim"),
3502
- bold: role("bold"),
3503
- italic: role("italic"),
3504
- underline: role("underline"),
3505
- strikethrough: role("strikethrough"),
3506
- accent: role("accent"),
3507
- heading: role("heading"),
3508
- link: role("link"),
3509
- success: role("success"),
3510
- warning: role("warning"),
3511
- error: role("error"),
3512
- inverse: role("inverse"),
3513
- band: role("band"),
3514
- injectedBand: role("injectedBand"),
3515
- addedBand: role("addedBand"),
3516
- removedBand: role("removedBand"),
3517
- addedSign: role("addedSign"),
3518
- removedSign: role("removedSign"),
3519
- enabled,
3520
- clickableKeys
3521
- };
3522
- }
3523
- /**
3524
- * Paint added and removed diff rows while leaving context and metadata rows
3525
- * unchanged. `source` stays plain so syntax-colored rows can be classified.
3526
- * @param rows - rows after optional syntax highlighting.
3527
- * @param source - corresponding plain rows carrying the diff prefixes.
3528
- * @param palette - active terminal palette.
3529
- * @returns the rows with additions green and removals red.
3530
- */
3531
- function paintDiffRows(rows, source, palette) {
3532
- return rows.map((row, index) => {
3533
- const plain = source[index];
3534
- if (plain?.startsWith("+ ") === true) return palette.success(row);
3535
- if (plain?.startsWith("- ") === true) return palette.error(row);
3536
- return row;
3537
- });
3538
- }
3539
- /**
3540
- * Lay one row on a background tint across the full width.
3541
- * @param palette - the active palette.
3542
- * @param row - the styled row, at most `width` columns.
3543
- * @param width - the columns the band spans.
3544
- * @param band - the tint; {@link Palette.band} by default.
3545
- * @returns the row padded to `width` under the tint; the row unchanged, with
3546
- * no padding, when the palette is disabled.
3547
- */
3548
- function bandRow(palette, row, width, band = palette.band) {
3549
- return palette.enabled ? band(`${row}${" ".repeat(Math.max(0, width - visibleWidth(row)))}`) : row;
3550
- }
3551
- /**
3552
- * The `+` or `-` of a changed row, painted apart from the tint the row is
3553
- * filled with. The sign sits in the plain row's own prefix - the file line
3554
- * number, when the diff carries one, then the sign and a space - and syntax
3555
- * colour starts after it, so the styled row opens with the same characters.
3556
- * @param row - the styled row.
3557
- * @param plain - the same row before any syntax colour.
3558
- * @param mark - whether the row is an addition or a removal.
3559
- * @param palette - the active palette.
3560
- * @returns the row with its sign painted, or unchanged when the styled row
3561
- * does not open with the plain prefix.
3562
- */
3563
- function paintDiffSign(row, plain, mark, palette) {
3564
- const sign = mark === "added" ? "+" : "-";
3565
- const at = plain.indexOf(`${sign} `);
3566
- if (at === -1 || !row.startsWith(plain.slice(0, at + 1))) return row;
3567
- const paint = mark === "added" ? palette.addedSign : palette.removedSign;
3568
- return `${row.slice(0, at)}${paint(sign)}${row.slice(at + 1)}`;
3569
- }
3570
- /**
3571
- * Wrap rows to `width` and fill each changed row edge to edge with its own
3572
- * background tint - green for an addition, red for a removal - so a run of
3573
- * changes reads as one region without spending a column on a border. The `+`
3574
- * and `-` are painted in their own lighter colour, apart from the fill, and a
3575
- * wrapped continuation carries the tint with no sign of its own. Every
3576
- * returned line is at most `width` columns, and every filled line is exactly
3577
- * `width`; a disabled palette pads nothing and returns the rows as they are.
3578
- * @param rows - the styled rows.
3579
- * @param plain - the same rows before any syntax colour, which carry the signs.
3580
- * @param marks - per row, whether it is an addition or a removal; undefined
3581
- * for a row no tint fills.
3582
- * @param width - the columns the rows fit.
3583
- * @param palette - the active palette.
3584
- * @returns the wrapped rows, the changed ones filled.
3585
- */
3586
- function bandDiffRows(rows, plain, marks, width, palette) {
3587
- const columns = Math.max(1, width);
3588
- const out = [];
3589
- for (const [index, row] of rows.entries()) {
3590
- const mark = marks[index];
3591
- if (mark === void 0) {
3592
- out.push(...wrapTextWithAnsi(row, columns));
3593
- continue;
3594
- }
3595
- const fill = mark === "added" ? palette.addedBand : palette.removedBand;
3596
- const signed = paintDiffSign(row, plain[index] ?? "", mark, palette);
3597
- for (const part of wrapTextWithAnsi(signed, columns)) out.push(palette.enabled ? fill(`${part}${" ".repeat(Math.max(0, columns - visibleWidth(part)))}`) : part);
3598
- }
3599
- return out;
3600
- }
3601
- /**
3602
- * Decide whether the terminal gets color: `NO_COLOR` (any non-empty value)
3603
- * wins, then a non-empty non-zero `FORCE_COLOR`, then whether stdout is a TTY.
3604
- * @param env - the process environment.
3605
- * @param isTty - whether stdout is a terminal.
3606
- * @returns true when SGR styling should be emitted.
3607
- */
3608
- function colorEnabled(env, isTty) {
3609
- if (env.NO_COLOR !== void 0 && env.NO_COLOR !== "") return false;
3610
- if (env.FORCE_COLOR !== void 0 && env.FORCE_COLOR !== "" && env.FORCE_COLOR !== "0") return true;
3611
- return isTty;
3612
- }
3613
- /**
3614
- * The Markdown theme derived from the palette.
3615
- * @param palette - the active palette.
3616
- * @param highlight - colours fenced code; omitted draws every block plain,
3617
- * which is also what a block whose language has no grammar here draws as.
3618
- * @returns a complete pi-tui Markdown theme.
3619
- */
3620
- function markdownTheme(palette, highlight) {
3621
- return {
3622
- highlightCode: (code, lang) => highlight?.lines(code, lang) ?? code.split("\n"),
3623
- heading: (text) => palette.bold(palette.heading(text)),
3624
- link: (text) => palette.underline(palette.link(text)),
3625
- linkUrl: palette.dim,
3626
- code: palette.link,
3627
- codeBlock: (text) => text,
3628
- codeBlockBorder: palette.dim,
3629
- quote: (text) => palette.italic(palette.dim(text)),
3630
- quoteBorder: palette.dim,
3631
- hr: palette.dim,
3632
- listBullet: palette.heading,
3633
- bold: palette.bold,
3634
- italic: palette.italic,
3635
- strikethrough: palette.strikethrough,
3636
- underline: palette.underline
3637
- };
3638
- }
3639
- /**
3640
- * The select-list theme derived from the palette.
3641
- * @param palette - the active palette.
3642
- * @returns a complete pi-tui select-list theme.
3643
- */
3644
- function selectListTheme(palette) {
3645
- return {
3646
- selectedPrefix: palette.accent,
3647
- selectedText: (text) => palette.bold(palette.accent(text)),
3648
- description: palette.dim,
3649
- scrollInfo: palette.dim,
3650
- noMatch: palette.dim
3651
- };
3652
- }
3653
- /**
3654
- * The editor theme derived from the palette.
3655
- * @param palette - the active palette.
3656
- * @returns a complete pi-tui editor theme.
3657
- */
3658
- function editorTheme(palette) {
3659
- return {
3660
- borderColor: palette.dim,
3661
- selectList: selectListTheme(palette)
3662
- };
3663
- }
3664
- //#endregion
3665
3731
  //#region lib/types/blocks.js
3666
3732
  /**
3667
3733
  * Transcript components: one pi-tui component per rendered fact (a user
@@ -4829,7 +4895,7 @@ var ToolBlock = class {
4829
4895
  marker: 0
4830
4896
  };
4831
4897
  }
4832
- const header = `${this.statusStyle()(TOOL_GLYPH)} ${palette.bold(this.toolName)}${this.call.title === "" ? "" : ` ${palette.link(this.call.title)}`}`;
4898
+ const header = `${this.statusStyle()(TOOL_GLYPH)} ${palette.bold(palette.tool(this.toolName))}${this.call.title === "" ? "" : ` ${palette.subject(this.call.title)}`}`;
4833
4899
  const loading = this.status === "running" ? ["…"] : [];
4834
4900
  const body = [
4835
4901
  ...this.call.lines,
@@ -4899,7 +4965,7 @@ var ToolBlock = class {
4899
4965
  }
4900
4966
  /**
4901
4967
  * The one row a folded subagent card draws, led by the status-coloured
4902
- * {@link SUBAGENT_RUNNING_GLYPH}. A running row carries the accent tool
4968
+ * {@link SUBAGENT_RUNNING_GLYPH}. A running row carries the cyan tool
4903
4969
  * name; a settled row is dim and ends on its outcome tag at the right edge:
4904
4970
  * `[failed]` for an error, `[started]` for a call that handed the child to
4905
4971
  * the background, whose result reads `started …` and whose glyph is dim,
@@ -4913,7 +4979,7 @@ var ToolBlock = class {
4913
4979
  const meta = facts.meta.length === 0 ? "" : ` ${palette.dim(facts.meta.join(" · "))}`;
4914
4980
  const description = facts.description === "" ? "" : ` ${facts.description}`;
4915
4981
  if (this.status === "running") {
4916
- const name = palette.bold(palette.accent(this.toolName));
4982
+ const name = palette.bold(palette.tool(this.toolName));
4917
4983
  return truncateToWidth(`${palette.warning("◆")} ${name}${description}${meta}`, width, "…");
4918
4984
  }
4919
4985
  const started = this.status === "done" && this.resultLines[0]?.startsWith("started ") === true;
@@ -6438,12 +6504,12 @@ function hotRow(usage, palette, frame) {
6438
6504
  */
6439
6505
  function categoryStyle(palette, id) {
6440
6506
  switch (id) {
6441
- case "system": return palette.dim;
6442
- case "tools": return palette.accent;
6443
- case "instructions": return palette.heading;
6444
- case "skills": return palette.warning;
6445
- case "context": return palette.success;
6446
- case "messages": return palette.link;
6507
+ case "system": return palette.hue.blue;
6508
+ case "tools": return palette.hue.cyan;
6509
+ case "instructions": return palette.hue.orange;
6510
+ case "skills": return palette.hue.yellow;
6511
+ case "context": return palette.hue.green;
6512
+ case "messages": return palette.hue.magenta;
6447
6513
  /* v8 ignore next 2 -- closed-union exhaustiveness guard */
6448
6514
  default: return assertNever(id, "context category");
6449
6515
  }
@@ -10541,7 +10607,7 @@ function unfocusedLine(segments, palette, width, queue) {
10541
10607
  return palette.dim(segment.label);
10542
10608
  });
10543
10609
  const drawn = middleFacts(facts, rest.length - facts.length, width - visibleWidth(model) - reserved);
10544
- const left = [model === "" ? "" : palette.accent(model), ...drawn].filter((token) => token !== "").join(palette.dim(SEPARATOR$2));
10610
+ const left = [model === "" ? "" : palette.model(model), ...drawn].filter((token) => token !== "").join(palette.dim(SEPARATOR$2));
10545
10611
  if (hint === "") return fitLine(left, width);
10546
10612
  return fitLine(`${left}${" ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(hint)))}${paintKeys(palette, hint, palette.link)}`, width);
10547
10613
  }
@@ -11133,7 +11199,7 @@ function sectionName(block, part) {
11133
11199
  function restingHeader(block, part, palette) {
11134
11200
  const glyph = sectionGlyph(block, part);
11135
11201
  const name = sectionName(block, part);
11136
- if (block.blockKind === "tool" && part.kind === "call") return `${(settledTool(block) ? palette.success : palette.warning)(glyph)} ${palette.bold(block.name)}${palette.link(name.slice(block.name.length))}`;
11202
+ if (block.blockKind === "tool" && part.kind === "call") return `${(settledTool(block) ? palette.success : palette.warning)(glyph)} ${palette.bold(palette.tool(block.name))}${palette.subject(name.slice(block.name.length))}`;
11137
11203
  if (block.blockKind === "assistant" && part.kind === "reply") return `${palette.accent(glyph)} ${name}`;
11138
11204
  return palette.dim(`${glyph} ${name}`);
11139
11205
  }
@@ -12737,8 +12803,7 @@ function resolveColorDepth(input) {
12737
12803
  if (!input.paletteEnabled) return "none";
12738
12804
  const term = input.env.TERM ?? "";
12739
12805
  if (term === "dumb") return "none";
12740
- const colorterm = (input.env.COLORTERM ?? "").toLowerCase();
12741
- if (colorterm === "truecolor" || colorterm === "24bit") return "truecolor";
12806
+ if (declaresTruecolor(input.env)) return "truecolor";
12742
12807
  return term.includes("256color") ? "ansi256" : "none";
12743
12808
  }
12744
12809
  /**
@@ -19129,6 +19194,7 @@ const internals = {
19129
19194
  },
19130
19195
  stderr: process.stderr,
19131
19196
  color: colorEnabled(process.env, process.stdout.isTTY),
19197
+ depth: paletteDepth(process.env),
19132
19198
  canOpenUrl: () => canOpenNativePath(),
19133
19199
  openUrl: openNativeUrl
19134
19200
  };
@@ -19380,7 +19446,7 @@ async function run(ctx, config, host) {
19380
19446
  host: sessions,
19381
19447
  initial,
19382
19448
  terminal: host.createTerminal(),
19383
- palette: createPalette(host.color, config.mouse),
19449
+ palette: createPalette(host.color, config.mouse, host.depth),
19384
19450
  toolPreviewLines: config.toolPreviewLines,
19385
19451
  contextPreviewLines: config.contextPreviewLines,
19386
19452
  focusPreviewLines: config.focusPreviewLines,
@@ -19439,6 +19505,7 @@ function apply(ctx, config) {
19439
19505
  releaseInput: internals.releaseInput,
19440
19506
  stderr: internals.stderr,
19441
19507
  color: internals.color,
19508
+ depth: internals.depth,
19442
19509
  canOpenUrl: internals.canOpenUrl,
19443
19510
  openUrl: internals.openUrl,
19444
19511
  exit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.80",
3
+ "version": "0.1.81",
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",