@songtonyli/dsh-cli 0.1.26 → 0.1.27

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.26; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.27; `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.26 (deepseek-harness 0.1.6-alpha.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.27 (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-654605a` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
163
+ return `0.1.6-alpha.2-df9469c` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
164
164
  }
165
165
  /** Each panel row subscribes only to its own selection state. */
166
166
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -24,8 +24,8 @@
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
26
  "@types/react": "~18.3.1",
27
- "@deepseek-ai/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: 19aee69be4786730dfbff3aa106250993e8d8fa1
6
- README.zh.md: 0eedbea3eb5df6911b4e5185a394abf48ad386e5
5
+ README.md: 7d184af56b51a5a0bf5c162e3a84f66966abb85c
6
+ README.zh.md: c591d843f5683f15fc55c0789604b9229a5cdfd1
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Interactive terminal mode for dsh: talk to the agent in your terminal with streamed replies, tool cards, keyboard navigation over the conversation, a full-screen two-panel reader for turns, approvals, questions, slash commands, @-references, attachments, and session switching."
2
+ description: "Interactive terminal mode for dsh: talk to the agent in your terminal with streamed replies, tool cards, keyboard navigation over the conversation, a full-screen two-panel reader for turns, approvals, questions, slash commands, ! shell lines, @-references, attachments, and session switching."
3
3
  kind: "package-bundle"
4
4
  ---
5
5
 
@@ -65,6 +65,7 @@ While the input has the keyboard:
65
65
  | Key | Effect |
66
66
  |---|---|
67
67
  | `Enter` | Send the editor text; while a turn runs it waits for the next turn in the framed `QUEUE` panel above the editor until the loop claims it, entering the conversation then |
68
+ | `!command` / `!!command` | Run in this terminal; `!` is next-step context the next prompt can read, `!!` stays local |
68
69
  | `Shift+Enter` | Insert a newline |
69
70
  | `Ctrl+S` | While a turn runs, steer the editor text into the running turn's next step |
70
71
  | `Up` / `Down` | Recall earlier prompts |
@@ -75,11 +76,11 @@ While the input has the keyboard:
75
76
  | `Shift+Down` | Focus the queued-prompt panel's first row while prompts wait, otherwise the subagent panel's first row while it is drawn, and the status bar otherwise |
76
77
  | `Ctrl+G` | Read the conversation full screen, on its newest section |
77
78
  | `Ctrl+O` | Expand or collapse every tool card and context row |
78
- | `Esc` | Arm the stop and say so; a second press while that line is on screen stops the running turn, and queued messages stay queued |
79
+ | `Esc` | Cancel a running `!`; with a leading `!` draft and no turn running, clear the editor; otherwise arm the stop, and a second press while that line is on screen stops the running turn |
79
80
  | `Ctrl+C` | Clear the editor; a second press within 600 ms quits |
80
81
  | `Ctrl+D` | Quit when the editor is empty |
81
82
 
82
- An `Esc` that only handed the keyboard back — leaving a region, closing a page, a picker, or the reader — opens a 750 ms window in which an `Esc` reaching the input does nothing at all, so a habitual double press stops no turn. With no turn running, `Esc` closes the completion list while one is open and is silent otherwise. A session with nothing to read yet answers `Shift+Up` and `Ctrl+G` with `nothing in the transcript to read yet` and leaves the keyboard in the input.
83
+ An `Esc` that only handed the keyboard back — leaving a region, closing a page, a picker, or the reader — opens a 750 ms window in which an `Esc` reaching the input does nothing at all, so a habitual double press stops no turn. With no turn running, `Esc` closes the completion list while one is open, clears a draft that starts with `!`, and is silent otherwise. A session with nothing to read yet answers `Shift+Up` and `Ctrl+G` with `nothing in the transcript to read yet` and leaves the keyboard in the input.
83
84
 
84
85
  While the queued-prompt panel has the keyboard:
85
86
 
@@ -154,7 +155,7 @@ Every other key reaching the reader is consumed, and closing it opens the same 7
154
155
 
155
156
  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 names the picker shared by `Shift+Tab` and `/effort`, and the permission segment names 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.
156
157
 
157
- Typing `/` at the start of the editor completes the terminal's own commands and the shared registry's; `@` anywhere completes references.
158
+ Typing `/` at the start of the editor completes the terminal's own commands and the shared registry's; `@` anywhere completes references. A nonempty `!command` or `!!command` line runs through `ctx.shell` in the session cwd at `danger-full-access`; the transcript shows `$ command` and the output. `!` injects a plugin notice for the next admitted step; `!!` does not. A lone `!` is an ordinary prompt.
158
159
 
159
160
  | Command | Effect |
160
161
  |---|---|
@@ -235,7 +236,7 @@ The runner is a direct driver over the core API carrier, like `dsh-headless`, th
235
236
 
236
237
  ### Run flow
237
238
 
238
- The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with three operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` reads the persisted log in pages through a read handle of `ctx.sessionPersistence` and resumes the Agent through the registry, and `fork` observes the source through `ctx.sessionQuery`, cuts after the chosen (by default the last) `turn/end` up to the next `turn/start`, and creates a seeded Agent with `parentSession` and `isSeeded` metadata. Every operation installs a `ModelSelectionRef` in the Agent's scoped setup so `/model` changes the next request. The terminal application starts on the session `--resume` or a fresh `create` yields, subscribes to `session/event`, `agent/assistant-stream`, and `agent/status`, answers the `approval/request` and `user-questions/request` waterfalls for the bound Agent only, and switches sessions by binding the next one and disposing the previous handle; while the host opens the next session the editor refuses input, and a quit during that wait releases the session that arrives afterwards. Quitting cancels any running turn, waits for quiescence, flushes the bound Session, disposes its handle, and requests exit 0; a driver failure writes `dsh: <message>` to stderr and requests exit 1. `/resume` and `/sessions` share the persisted-session chooser. Editor `Shift+Tab` dispatches empty `/effort` to open its current-model picker, and editor `Shift+Left` / `Shift+Right` use pi-tui's word navigation. `/login` starts `authorization.begin` with only subscription methods (every method except a key-collecting `api-key` login). A notice the flow marks with `openInBrowser` is handed to the default browser through `dsh-native-command`'s credential-scrubbed helper while the URL stays printed; the handoff is suppressed when `openBrowser` is false, the launch came through SSH, or the host has no desktop, and an opener failure becomes a notice beside the URL rather than a sign-in failure.
239
+ The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with three operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` reads the persisted log in pages through a read handle of `ctx.sessionPersistence` and resumes the Agent through the registry, and `fork` observes the source through `ctx.sessionQuery`, cuts after the chosen (by default the last) `turn/end` up to the next `turn/start`, and creates a seeded Agent with `parentSession` and `isSeeded` metadata. Every operation installs a `ModelSelectionRef` in the Agent's scoped setup so `/model` changes the next request. The terminal application starts on the session `--resume` or a fresh `create` yields, subscribes to `session/event`, `agent/assistant-stream`, and `agent/status`, answers the `approval/request` and `user-questions/request` waterfalls for the bound Agent only, and switches sessions by binding the next one and disposing the previous handle; while the host opens the next session the editor refuses input, and a quit during that wait releases the session that arrives afterwards. Quitting cancels any running turn, waits for quiescence, flushes the bound Session, disposes its handle, and requests exit 0; a driver failure writes `dsh: <message>` to stderr and requests exit 1. `/resume` and `/sessions` share the persisted-session chooser. Editor `Shift+Tab` dispatches empty `/effort` to open its current-model picker, and editor `Shift+Left` / `Shift+Right` use pi-tui's word navigation. `/login` starts `authorization.begin` with only subscription methods (every method except a key-collecting `api-key` login). A notice the flow marks with `openInBrowser` is handed to the default browser through `dsh-native-command`'s credential-scrubbed helper while the URL stays printed; the handoff is suppressed when `openBrowser` is false, the launch came through SSH, or the host has no desktop, and an opener failure becomes a notice beside the URL rather than a sign-in failure. A nonempty `!` or `!!` line submitted in the editor runs through `ctx.shell` in this process; `!` injects a next-step notice and `!!` stays local.
239
240
 
240
241
  ### Rendering model
241
242
 
@@ -251,7 +252,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
251
252
  |---|---|
252
253
  | [`src/index.ts`](src/index.ts) | The `tui-app` plugin: the session host (create, resume, fork), history read, quit flow, exit mapping |
253
254
  | [`src/startup.ts`](src/startup.ts) | The `tui-app-startup` provider: prompt positional, `--resume`, `--no-open`, and `--help` |
254
- | [`src/app.ts`](src/app.ts) | The terminal application: layout, the key router, commands, session binding, seams, log and stream folding, the stop arm, the transient line it mounts, and the terminal handover the reader runs on |
255
+ | [`src/app.ts`](src/app.ts) | The terminal application: layout, the key router, commands, session binding, seams, log and stream folding, the stop arm, the transient line it mounts, the terminal handover the reader runs on, and prefix-on-submit `!` / `!!` |
255
256
  | [`src/keys.ts`](src/keys.ts) | The key model: the focus regions, what one press means in each, the legends they degrade through, the entry keys, the `/help` lines, and the handoff window |
256
257
  | [`src/sessions.ts`](src/sessions.ts) | The persisted-session list and picker rows shared by `/resume` and `/sessions` |
257
258
  | [`src/effort.ts`](src/effort.ts) | Reasoning-effort names and picker rows shared by `/model`, `/effort`, and editor `Shift+Tab` |
@@ -276,6 +277,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
276
277
  | [`src/highlight.ts`](src/highlight.ts) | Syntax colour for fenced code: the grammars a fence may load, the theme the background picks, and the SGR one token is drawn with |
277
278
  | [`src/completion.ts`](src/completion.ts) | Slash-command and `@`-reference completion for the editor |
278
279
  | [`src/editor.ts`](src/editor.ts) | The prompt editor's terminal caret and its `Shift+Left` / `Shift+Right` mapping to pi-tui word navigation |
280
+ | [`src/shell-line.ts`](src/shell-line.ts) | Parse a `!` / `!!` line and format the transcript rows and model-facing notice |
279
281
  | [`src/status.ts`](src/status.ts) | Projection-seam facts and the sections the `/status` report and the segment details share; compaction and retry notices |
280
282
  | [`src/footer.ts`](src/footer.ts) | The status bar: the ordered segments, each segment's detail rows, the unfocused line built from both ends, and the focused sliding window |
281
283
  | [`src/subagent-panel.ts`](src/subagent-panel.ts) | The live subagent panel: one descendant listing plus sampled live facts become its rows, the unfocused summary line, and the focused listing |
@@ -293,6 +295,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
293
295
  | [`tests/reader-screen.spec.ts`](tests/reader-screen.spec.ts) | The reader pane: its key map, the screen it fills, its re-anchoring, and its exit |
294
296
  | [`tests/alt-screen.spec.ts`](tests/alt-screen.spec.ts) | The alternate screen: its balanced switches, its per-row drawing, and the rows a shorter frame clears |
295
297
  | [`tests/commands.spec.ts`](tests/commands.spec.ts) | The `/resume` and `/sessions` picker, attachments, queues, skills, sign-in, export, references, the picker shared by `/effort` and `Shift+Tab`, and `Ctrl+S` in the model list over scripted services |
298
+ | [`tests/shell.spec.ts`](tests/shell.spec.ts) | Prefix-on-submit `!` / `!!` dispatch, next-step inject, Esc cancel, and the missing-shell notice |
296
299
  | [`tests/effort.spec.ts`](tests/effort.spec.ts) | Shared effort names, picker rows, the current-effort hint, and typed argument matching |
297
300
  | [`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 |
298
301
  | [`tests/transcript-focus.spec.ts`](tests/transcript-focus.spec.ts) | Walking the conversation, the region stack, the inspector, the reader over a live session with the terminal it takes and gives back, and the in-place gutter inside the repaint window |
@@ -329,11 +332,25 @@ Read these pages when you want to go deeper into the shared core, the sibling su
329
332
  <a id="model-experience"></a>
330
333
  ## Model Experience
331
334
 
332
- None, as the runner submits typed text as ordinary user messages and the composed base and terminal rows own the prompts and tools.
335
+ ### User-typed shell command
336
+
337
+ #### What the model sees
338
+
339
+ A nonempty `!command` line injects one plugin notice after the command finishes (`source.kind: plugin`, `plugin: tui-app`, `form: notice`). The next admitted step includes this wrapper; `<command>` and the fenced body are data-dependent. An empty run uses the exact line `(no output)` instead of a fence. A cancelled run appends a blank line and `(command cancelled)`. A nonzero exit appends a blank line and `Command exited with code <n>`. `!!command` and a lone `!` add no notice.
340
+
341
+ ##### User shell notice prefix
342
+
343
+ ```markdown
344
+ The user ran `<command>` in the terminal.
345
+ ```
346
+
347
+ #### Token effect
348
+
349
+ Conditional and retained: each `!` notice stays in conversation history for later requests; `!!` and a lone `!` add none.
333
350
 
334
351
  #### KV Cache effect
335
352
 
336
- The runner adds nothing to the request prefix; a `/model` switch starts a new request series exactly as it does from the browser.
353
+ Append-only conversation growth after the reusable request prefix. The notice does not change the system prompt or tool catalog. A `/model` switch starts a new request series exactly as it does from the browser.
337
354
 
338
355
  ## Known Limitations and Deferred Work
339
356
 
@@ -358,6 +375,7 @@ These limits describe the terminal surface as shipped; they are not a general CL
358
375
  - **The fade needs an answer from the terminal** — its ramp is built from the background color the terminal reports to the query sent at startup, so a terminal that stays silent, or that encodes neither truecolor nor 256 colors, gets the two-level faint mode instead; `NO_COLOR`, a disabled palette, `TERM=dumb`, and `reducedMotion` turn every fade and every chrome lift off entirely, and a transient line then disappears at the end of its hold instead of fading out.
359
376
  - **The terminal's own caret can flicker** — the editor draws no caret of its own and the app turns the terminal cursor on, which pi-tui then moves across the lines it repaints; a terminal that does not honor the synchronized-output sequences pi-tui wraps a frame in can show that movement.
360
377
  - **Runs through the `dsh` launcher** — starting the profile another way fails at startup, because only the launcher can request the process exit.
378
+ - **`!` is one-shot and not a TTY** — each line is a fresh `ctx.shell.run`; there is no persistent shell or interactive program. The Web composer does not intercept `!`. An optional first prompt on the command line is always a user message.
361
379
 
362
380
  <a id="dev-note"></a>
363
381
  ### Dev Note
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "dsh 的交互式终端模式:在你的终端里与 agent(智能体)对话,带流式回复、工具卡片、用键盘浏览对话记录、双面板全屏阅读器、审批、提问、斜杠命令、@ 引用、附件与会话切换。"
2
+ description: "dsh 的交互式终端模式:在你的终端里与 agent(智能体)对话,带流式回复、工具卡片、用键盘浏览对话记录、双面板全屏阅读器、审批、提问、斜杠命令、! 本地命令、@ 引用、附件与会话切换。"
3
3
  kind: "package-bundle"
4
4
  ---
5
5
 
@@ -65,6 +65,7 @@ dsh tui --no-open # print sign-in URLs without opening a
65
65
  | 按键 | 效果 |
66
66
  |---|---|
67
67
  | `Enter` | 发送编辑器文本;轮次进行中时它在编辑器上方的带框 `QUEUE` 面板中等待下一轮次,直到循环领取它后才进入对话 |
68
+ | `!command` / `!!command` | 在本终端运行;`!` 会作为下一步上下文供下一条提示阅读,`!!` 只留在本地 |
68
69
  | `Shift+Enter` | 插入换行 |
69
70
  | `Ctrl+S` | 轮次进行中时,把编辑器文本引导(steer)进当前轮次的下一步 |
70
71
  | `Up` / `Down` | 调出先前的提示 |
@@ -75,11 +76,11 @@ dsh tui --no-open # print sign-in URLs without opening a
75
76
  | `Shift+Down` | 有提示等待时把焦点放到待处理提示面板第一行,否则在子 agent 面板已绘制时放到其第一行,再否则放到状态栏 |
76
77
  | `Ctrl+G` | 整屏读出对话记录,停在其最新小节 |
77
78
  | `Ctrl+O` | 展开或折叠所有工具卡片与上下文行 |
78
- | `Esc` | 装填停止并给出提示;该提示仍在屏幕上时再按一次会停止正在进行的轮次,已排队的消息保持排队 |
79
+ | `Esc` | 取消正在运行的 `!`;在没有轮次进行且草稿以 `!` 开头时清空编辑器;否则装填停止,该提示仍在屏幕上时再按一次会停止正在进行的轮次 |
79
80
  | `Ctrl+C` | 清空编辑器;600 ms 内再按一次则退出 |
80
81
  | `Ctrl+D` | 编辑器为空时退出 |
81
82
 
82
- 仅仅交还了键盘的 `Esc`——离开某个区域、关闭页面、选择器或阅读器——会打开一个 750 ms 的窗口,其间到达编辑器的 `Esc` 完全不做任何事,因此习惯性的连按停不掉任何轮次。没有轮次进行时,`Esc` 在补全列表打开时关闭它,其余情况保持沉默。尚无可读内容的会话对 `Shift+Up` 与 `Ctrl+G` 回以 `nothing in the transcript to read yet`,并把键盘留在编辑器。
83
+ 仅仅交还了键盘的 `Esc`——离开某个区域、关闭页面、选择器或阅读器——会打开一个 750 ms 的窗口,其间到达编辑器的 `Esc` 完全不做任何事,因此习惯性的连按停不掉任何轮次。没有轮次进行时,`Esc` 在补全列表打开时关闭它,清空以 `!` 开头的草稿,其余情况保持沉默。尚无可读内容的会话对 `Shift+Up` 与 `Ctrl+G` 回以 `nothing in the transcript to read yet`,并把键盘留在编辑器。
83
84
 
84
85
  待处理提示面板持有键盘时:
85
86
 
@@ -154,7 +155,7 @@ dsh tui --no-open # print sign-in URLs without opening a
154
155
 
155
156
  每个聚焦的分段都在第二行展开其最重要的事实。除 `todo` 之外,`Enter` 把这些事实打印到对话记录,并指出改变它们的方式:模型分段指出 `/model`,推理强度分段指出 `Shift+Tab` 与 `/effort` 共用的选择器,权限分段指出其预设;`turn` 分段——绘制在权限与用量分段之间、形如 `turn <elapsed>`,且只在轮次进行时出现——给出轮次编号、其开始时间、已用时间与排队消息数量;用量、上下文、目标与计划分段打印 `/status` 报告中对应的小节,workspace 分段显示完整路径,附件分段列出待发送的附件。`todo` 分段展开按状态统计的计数以及正在进行的条目(若无正在进行的条目则为下一条待办),`Enter` 打开 agent 的 todo 列表,与 `/todos` 打开的是同一个列表。
156
157
 
157
- 在编辑器开头输入 `/` 会补全终端自身的命令与共享注册表的命令;任意位置的 `@` 补全引用。
158
+ 在编辑器开头输入 `/` 会补全终端自身的命令与共享注册表的命令;任意位置的 `@` 补全引用。非空的 `!command` 或 `!!command` 行经 `ctx.shell` 在会话 cwd 以 `danger-full-access` 运行;对话记录显示 `$ command` 与输出。`!` 会注入一条插件通知供下一步领取;`!!` 不会。单独的 `!` 仍是普通提示。
158
159
 
159
160
  | 命令 | 效果 |
160
161
  |---|---|
@@ -235,7 +236,7 @@ runner 与 `dsh-headless` 一样是核心 API 载体之上的直接驱动器,
235
236
 
236
237
  ### 运行流程
237
238
 
238
- runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含三个操作的会话宿主:`create` 用共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume` 通过 `ctx.sessionPersistence` 的只读句柄分页读取持久化日志并经注册表恢复 Agent,`fork` 通过 `ctx.sessionQuery` 观察源会话、在所选(默认最后一个)`turn/end` 之后直到下一个 `turn/start` 处切割,并创建带 `parentSession` 与 `isSeeded` 元数据的种子 Agent。每个操作都在 Agent 的作用域 setup 中安装 `ModelSelectionRef`,因此 `/model` 会改变下一次请求。终端应用从 `--resume` 或一次新的 `create` 产生的会话开始,订阅 `session/event`、`agent/assistant-stream` 与 `agent/status`,只为绑定的 Agent 应答 `approval/request` 与 `user-questions/request` waterfall,并通过绑定下一个会话、dispose 先前句柄来切换会话;宿主打开下一个会话期间编辑器拒绝输入,等待期间退出会释放随后到达的会话。退出时取消任何进行中的轮次、等待完全停稳、flush 绑定的会话、dispose 其句柄并请求以 0 退出;驱动器失败会向 stderr 写入 `dsh: <message>` 并请求以 1 退出。`/resume` 与 `/sessions` 共用持久化会话选择器。编辑器中的 `Shift+Tab` 会派发空参数 `/effort` 以打开当前模型的推理强度选择器,而编辑器中的 `Shift+Left` / `Shift+Right` 使用 pi-tui 的词导航。`/login` 只带着订阅方法(除收集密钥的 `api-key` 登录外的每一种方法)启动 `authorization.begin`。flow 用 `openInBrowser` 标记的 notice 会经 `dsh-native-command` 的凭据擦除辅助进程交给默认浏览器,URL 同时保持打印;当 `openBrowser` 为 false、启动经过 SSH 或宿主没有桌面时抑制该交接,打开器失败则成为 URL 旁的一条通知,而非登录失败。
239
+ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含三个操作的会话宿主:`create` 用共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume` 通过 `ctx.sessionPersistence` 的只读句柄分页读取持久化日志并经注册表恢复 Agent,`fork` 通过 `ctx.sessionQuery` 观察源会话、在所选(默认最后一个)`turn/end` 之后直到下一个 `turn/start` 处切割,并创建带 `parentSession` 与 `isSeeded` 元数据的种子 Agent。每个操作都在 Agent 的作用域 setup 中安装 `ModelSelectionRef`,因此 `/model` 会改变下一次请求。终端应用从 `--resume` 或一次新的 `create` 产生的会话开始,订阅 `session/event`、`agent/assistant-stream` 与 `agent/status`,只为绑定的 Agent 应答 `approval/request` 与 `user-questions/request` waterfall,并通过绑定下一个会话、dispose 先前句柄来切换会话;宿主打开下一个会话期间编辑器拒绝输入,等待期间退出会释放随后到达的会话。退出时取消任何进行中的轮次、等待完全停稳、flush 绑定的会话、dispose 其句柄并请求以 0 退出;驱动器失败会向 stderr 写入 `dsh: <message>` 并请求以 1 退出。`/resume` 与 `/sessions` 共用持久化会话选择器。编辑器中的 `Shift+Tab` 会派发空参数 `/effort` 以打开当前模型的推理强度选择器,而编辑器中的 `Shift+Left` / `Shift+Right` 使用 pi-tui 的词导航。`/login` 只带着订阅方法(除收集密钥的 `api-key` 登录外的每一种方法)启动 `authorization.begin`。flow 用 `openInBrowser` 标记的 notice 会经 `dsh-native-command` 的凭据擦除辅助进程交给默认浏览器,URL 同时保持打印;当 `openBrowser` 为 false、启动经过 SSH 或宿主没有桌面时抑制该交接,打开器失败则成为 URL 旁的一条通知,而非登录失败。编辑器里提交的非空 `!` 或 `!!` 行经本进程的 `ctx.shell` 运行;`!` 注入一条下一步通知,`!!` 只留在本地。
239
240
 
240
241
  ### 渲染模型
241
242
 
@@ -251,7 +252,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
251
252
  |---|---|
252
253
  | [`src/index.ts`](src/index.ts) | `tui-app` 插件:会话宿主(创建、恢复、fork)、历史读取、退出流程、退出码映射 |
253
254
  | [`src/startup.ts`](src/startup.ts) | `tui-app-startup` 提供方:提示位置参数、`--resume`、`--no-open` 与 `--help` |
254
- | [`src/app.ts`](src/app.ts) | 终端应用:布局、按键路由、命令、会话绑定、接缝、日志与流的折叠、停止装填、它挂载的临时提示行,以及阅读器所依托的终端交接 |
255
+ | [`src/app.ts`](src/app.ts) | 终端应用:布局、按键路由、命令、会话绑定、接缝、日志与流的折叠、停止装填、它挂载的临时提示行、阅读器所依托的终端交接,以及提交时解析的 `!` / `!!` |
255
256
  | [`src/keys.ts`](src/keys.ts) | 按键模型:各焦点区域、一次按键在每个区域中的含义、它们逐级收缩的按键提示、进入用的按键、`/help` 的各行,以及交接窗口 |
256
257
  | [`src/sessions.ts`](src/sessions.ts) | `/resume` 与 `/sessions` 共用的持久化会话列表及选择器行 |
257
258
  | [`src/effort.ts`](src/effort.ts) | `/model`、`/effort` 与编辑器 `Shift+Tab` 共用的推理强度名称及选择器行 |
@@ -276,6 +277,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
276
277
  | [`src/highlight.ts`](src/highlight.ts) | 围栏代码的语法高亮:某个围栏可能加载的语法、由背景选定的配色主题,以及一个 token 所用的 SGR |
277
278
  | [`src/completion.ts`](src/completion.ts) | 编辑器的斜杠命令与 `@` 引用补全 |
278
279
  | [`src/editor.ts`](src/editor.ts) | 提示编辑器的终端光标,以及把 `Shift+Left` / `Shift+Right` 映射到 pi-tui 词导航的逻辑 |
280
+ | [`src/shell-line.ts`](src/shell-line.ts) | 解析 `!` / `!!` 行,并格式化对话记录行与面向模型的通知 |
279
281
  | [`src/status.ts`](src/status.ts) | 投影接缝的事实,以及 `/status` 报告与分段详情共享的小节;压缩与重试通知 |
280
282
  | [`src/footer.ts`](src/footer.ts) | 状态栏:有序的各分段、每个分段的详情行、未聚焦时由两端向内构建的一行,以及聚焦时的滑动窗口 |
281
283
  | [`src/subagent-panel.ts`](src/subagent-panel.ts) | 实时子 agent 面板:一次后代列表加上采样到的实时事实构成其各行、未聚焦时的摘要行,以及聚焦时的列表 |
@@ -293,6 +295,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
293
295
  | [`tests/reader-screen.spec.ts`](tests/reader-screen.spec.ts) | 阅读器面板:其按键映射、它铺满的屏幕、其重新锚定与其退出 |
294
296
  | [`tests/alt-screen.spec.ts`](tests/alt-screen.spec.ts) | 备用屏幕:其成对的切换、其逐行绘制,以及更短的一帧所清除的行 |
295
297
  | [`tests/commands.spec.ts`](tests/commands.spec.ts) | 基于脚本化服务的 `/resume` 与 `/sessions` 选择器、附件、队列、技能、登录、导出、引用、`/effort` 与 `Shift+Tab` 共用的选择器,以及模型列表中的 `Ctrl+S` |
298
+ | [`tests/shell.spec.ts`](tests/shell.spec.ts) | 提交时解析的 `!` / `!!` 分发、下一步 inject、Esc 取消,以及缺少 shell 时的通知 |
296
299
  | [`tests/effort.spec.ts`](tests/effort.spec.ts) | 共用的推理强度名称、选择器行、当前强度提示与输入参数匹配 |
297
300
  | [`tests/panels.spec.ts`](tests/panels.spec.ts) | 状态页脚与报告、可导航的子 agent 与 todo 列表、目录命令、命令提示与审批详情 |
298
301
  | [`tests/transcript-focus.spec.ts`](tests/transcript-focus.spec.ts) | 走遍对话记录、区域序列、检视面板、实时会话上的阅读器连同它接管与交还的终端,以及重绘窗口内的原地标记条 |
@@ -329,11 +332,25 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
329
332
  <a id="model-experience"></a>
330
333
  ## 模型体验
331
334
 
332
- 无,因为 runner 把键入的文本作为普通用户消息提交,提示与工具由已组合的 base 与终端配置行持有。
335
+ ### 用户键入的 shell 命令
336
+
337
+ #### 模型看到什么
338
+
339
+ 非空的 `!command` 行在命令结束后注入一条插件通知(`source.kind: plugin`,`plugin: tui-app`,`form: notice`)。下一步领取时会带上此包装;`<command>` 与围栏正文依数据而定。没有输出时使用精确一行 `(no output)` 而不是围栏。取消的运行会再追加一个空行和 `(command cancelled)`。非零退出会再追加一个空行和 `Command exited with code <n>`。`!!command` 与单独的 `!` 不添加通知。
340
+
341
+ ##### 用户 shell 通知前缀
342
+
343
+ ```markdown
344
+ The user ran `<command>` in the terminal.
345
+ ```
346
+
347
+ #### Token 影响
348
+
349
+ 有条件且保留:每条 `!` 通知留在之后请求的对话历史中;`!!` 与单独的 `!` 不增加任何内容。
333
350
 
334
351
  #### KV Cache 影响
335
352
 
336
- runner 不向请求前缀添加任何内容;`/model` 切换像在浏览器中一样开始新的请求序列。
353
+ 在可复用的请求前缀之后只做追加式增长。该通知不改变系统提示或工具目录。`/model` 切换像在浏览器中一样开始新的请求序列。
337
354
 
338
355
  ## 已知限制与延期工作
339
356
 
@@ -358,6 +375,7 @@ runner 不向请求前缀添加任何内容;`/model` 切换像在浏览器中
358
375
  - **淡入需要终端的应答**——其亮度级别由终端对启动时发出的查询所报告的背景色构建,因此保持沉默、或既不编码真彩色也不编码 256 色的终端只会得到两级的暗淡模式;`NO_COLOR`、被禁用的调色板、`TERM=dumb` 与 `reducedMotion` 会完全关闭每一种淡入与每一种边框抬亮,临时提示行届时在保持结束时直接消失,而不是淡出。
359
376
  - **终端自身的光标可能闪烁**——编辑器不绘制自己的光标,应用打开终端光标,而 pi-tui 会在其重绘的各行之间移动它;不支持 pi-tui 为一帧包裹的同步输出序列的终端可能显示出这种移动。
360
377
  - **通过 `dsh` 启动器运行**——以其他方式启动该 profile 会在启动时失败,因为只有启动器能请求进程退出。
378
+ - **`!` 是一次性的,也不是 TTY**——每一行都是一次新的 `ctx.shell.run`;没有持久 shell,也不能跑交互式程序。Web 编辑器不拦截 `!`。命令行上的可选首条提示始终是用户消息。
361
379
 
362
380
  <a id="dev-note"></a>
363
381
  ### 开发备注
@@ -8,7 +8,7 @@ import { canOpenNativePath, openNativeUrl } from "@deepseek-ai/dsh-native-comman
8
8
  import { SessionLogOffset } from "@deepseek-ai/dsh-session";
9
9
  import { homedir } from "node:os";
10
10
  import "@deepseek-ai/cordis";
11
- import { HarnessError, ReasoningEffortId, createUserMessage } from "@deepseek-ai/dsh-llm";
11
+ import { HarnessError, ReasoningEffortId, boundContextSummary, createUserMessage } from "@deepseek-ai/dsh-llm";
12
12
  import { activeAtToken, formatFileMention } from "@deepseek-ai/dsh-file-reference";
13
13
  import { formatSessionReferenceMention } from "@deepseek-ai/dsh-session-reference";
14
14
  import { assertNever } from "@deepseek-ai/dsh-util-values";
@@ -3508,6 +3508,79 @@ var BarCursorEditor = class extends Editor {
3508
3508
  });
3509
3509
  }
3510
3510
  };
3511
+ //#endregion
3512
+ //#region lib/types/shell-line.js
3513
+ /**
3514
+ * Parse and present a user-typed `!` / `!!` shell line. The terminal runs the
3515
+ * command itself; `!` becomes next-step context and `!!` stays local.
3516
+ * @module @deepseek-ai/dsh-tui-app/shell-line
3517
+ */
3518
+ /**
3519
+ * Read a submitted editor line as a user shell command.
3520
+ * @param text - the trimmed editor text.
3521
+ * @returns the command and whether it is excluded, or undefined when the line
3522
+ * is not a nonempty `!` / `!!` prefix.
3523
+ */
3524
+ function parseUserShellLine(text) {
3525
+ const trimmed = text.trim();
3526
+ if (!trimmed.startsWith("!")) return void 0;
3527
+ const excluded = trimmed.startsWith("!!");
3528
+ const command = (excluded ? trimmed.slice(2) : trimmed.slice(1)).trim();
3529
+ return command === "" ? void 0 : {
3530
+ command,
3531
+ excluded
3532
+ };
3533
+ }
3534
+ /**
3535
+ * Shape one finished run as the text the next model request reads.
3536
+ * @param command - the command the user typed after `!`.
3537
+ * @param result - the completed foreground run.
3538
+ * @returns the model-facing notice body.
3539
+ */
3540
+ function userShellContextText(command, result) {
3541
+ const output = combinedOutput(result);
3542
+ let text = `The user ran \`${command}\` in the terminal.\n`;
3543
+ text += output === "" ? "(no output)" : `\`\`\`\n${output}\n\`\`\``;
3544
+ if (result.aborted) text += "\n\n(command cancelled)";
3545
+ else if (result.timedOut) text += `\n\n[timed out after ${String(result.timeoutMs)}ms]`;
3546
+ else if (result.signal !== null) text += `\n\n[killed by signal: ${result.signal}]`;
3547
+ else if (result.exitCode !== null && result.exitCode !== 0) text += `\n\nCommand exited with code ${String(result.exitCode)}`;
3548
+ return text;
3549
+ }
3550
+ /**
3551
+ * Shape one finished run as the rows the transcript draws immediately.
3552
+ * @param command - the command the user typed after `!`.
3553
+ * @param result - the completed foreground run.
3554
+ * @returns `$ command`, any output, and a cancel or nonzero-exit marker.
3555
+ */
3556
+ function userShellTranscriptRows(command, result) {
3557
+ const output = combinedOutput(result);
3558
+ const rows = [`$ ${command}`];
3559
+ if (output !== "") rows.push(output);
3560
+ if (result.aborted) rows.push("(command cancelled)");
3561
+ else if (result.exitCode !== null && result.exitCode !== 0) rows.push(`(exit ${String(result.exitCode)})`);
3562
+ return rows;
3563
+ }
3564
+ /**
3565
+ * Join stdout and a marked stderr section, dropping a single trailing newline
3566
+ * so a fenced body does not carry a blank last line.
3567
+ * @param result - the completed foreground run.
3568
+ * @returns the combined body, or the empty string when both streams are empty.
3569
+ */
3570
+ function combinedOutput(result) {
3571
+ const out = streamText(result.stdout);
3572
+ const err = streamText(result.stderr);
3573
+ if (err === "") return out;
3574
+ return out === "" ? `[stderr]\n${err}` : `${out}\n[stderr]\n${err}`;
3575
+ }
3576
+ /**
3577
+ * Take one collected stream, appending its truncation marker when present.
3578
+ * @param output - one captured stream.
3579
+ * @returns the text without a single trailing newline.
3580
+ */
3581
+ function streamText(output) {
3582
+ return (output.truncated ? `${output.text}\n[output truncated; full output: ${output.spillPath ?? "(unavailable)"}]` : output.text).replace(/\n$/u, "");
3583
+ }
3511
3584
  /** What the provider-default row is called. */
3512
3585
  const PROVIDER_DEFAULT_LABEL = "Provider default";
3513
3586
  /** The `/effort` argument that restores the provider default. */
@@ -3823,6 +3896,7 @@ const KEY_LINES = {
3823
3896
  "Enter sends · Shift+Enter newline · ↑↓ history · Ctrl+S steers",
3824
3897
  "Shift+Tab effort list · Shift+←→ words",
3825
3898
  "@ completes paths and sessions · / completes commands · Tab takes one",
3899
+ "!cmd runs here · the next prompt can read it · !!cmd stays local",
3826
3900
  `${ENTRY_KEYS} · Ctrl+G reader`,
3827
3901
  "Ctrl+O folds every tool card and context row",
3828
3902
  "Esc arms the stop · Esc again stops the turn",
@@ -6180,6 +6254,8 @@ var ModalQueue = class {
6180
6254
  */
6181
6255
  /**
6182
6256
  * Build the panel rows in claim order: next-step input before ordinary turns.
6257
+ * Messages whose source is not `user` are omitted: a `!` notice waiting for
6258
+ * the next prompt is context, not a prompt the keyboard can steer or edit.
6183
6259
  * @param nextStep - messages waiting for the nearest step boundary.
6184
6260
  * @param nextTurn - messages waiting for separate turns.
6185
6261
  * @returns selectable pending-prompt rows.
@@ -6190,7 +6266,8 @@ function queuePanelRows(nextStep, nextTurn) {
6190
6266
  target,
6191
6267
  text: contentText(message.content).split("\n", 1)[0] ?? ""
6192
6268
  });
6193
- return [...nextStep.map((message) => row("next-step", message)), ...nextTurn.map((message) => row("next-turn", message))];
6269
+ const pending = (target, messages) => messages.filter((message) => message.source.kind === "user").map((message) => row(target, message));
6270
+ return [...pending("next-step", nextStep), ...pending("next-turn", nextTurn)];
6194
6271
  }
6195
6272
  /**
6196
6273
  * Render the pending prompts inside a frame. A focused panel accents its held
@@ -8246,6 +8323,10 @@ const LOCAL_COMMANDS = [
8246
8323
  function isSubscriptionMethod(method) {
8247
8324
  return method.id !== "api-key";
8248
8325
  }
8326
+ /** Shown when `!` is submitted and this composition has no `ctx.shell`. */
8327
+ const SHELL_MISSING = "! needs a shell executor in this composition";
8328
+ /** Shown when a second `!` is submitted while one is still running. */
8329
+ const SHELL_BUSY = "A shell command is already running. Press Esc to cancel it first.";
8249
8330
  /** The interactive terminal application; one instance per process. */
8250
8331
  var TuiApp = class {
8251
8332
  deps;
@@ -8355,6 +8436,8 @@ var TuiApp = class {
8355
8436
  escapeQuietUntil = 0;
8356
8437
  /** Until when a second editor `Escape` stops the running turn. */
8357
8438
  stopArmedUntil = 0;
8439
+ /** Abort of the in-flight user `!` command, when one is running. */
8440
+ shellAbort;
8358
8441
  /**
8359
8442
  * How many of the viewport's own first lines the renderer can no longer
8360
8443
  * repaint, from the last frame the guard settled. The transient line
@@ -8423,6 +8506,9 @@ var TuiApp = class {
8423
8506
  this.editor.onSubmit = (text) => {
8424
8507
  this.onSubmit(text);
8425
8508
  };
8509
+ this.editor.onChange = () => {
8510
+ this.syncEditorBorder();
8511
+ };
8426
8512
  this.queue = new Text("", 0, 0);
8427
8513
  this.panel = new Text("", 0, 0);
8428
8514
  this.footer = new FooterBar(() => ({
@@ -8544,6 +8630,7 @@ var TuiApp = class {
8544
8630
  /** Release the terminal and tell the host to exit; later calls are no-ops. */
8545
8631
  stop() {
8546
8632
  if (this.stopped) return;
8633
+ this.dropUserShell();
8547
8634
  this.restoreQueueDraft();
8548
8635
  this.stopped = true;
8549
8636
  this.updateTicker();
@@ -8561,6 +8648,7 @@ var TuiApp = class {
8561
8648
  }
8562
8649
  /** Draw `next` as the terminal's session: clear the transcript and replay its history. */
8563
8650
  bind(next) {
8651
+ this.dropUserShell();
8564
8652
  if (this.queueDraft !== void 0) {
8565
8653
  this.restoreQueueDraft();
8566
8654
  this.editor.setText("");
@@ -9321,7 +9409,17 @@ var TuiApp = class {
9321
9409
  const now = this.deps.now();
9322
9410
  if (now < this.escapeQuietUntil) return { consume: true };
9323
9411
  if (this.editor.isShowingAutocomplete()) return void 0;
9324
- if (this.agent.status !== "running") return { consume: true };
9412
+ if (this.shellAbort !== void 0) {
9413
+ this.shellAbort.abort();
9414
+ return { consume: true };
9415
+ }
9416
+ if (this.agent.status !== "running") {
9417
+ if (this.editor.getText().trimStart().startsWith("!")) {
9418
+ this.editor.setText("");
9419
+ this.syncEditorBorder();
9420
+ }
9421
+ return { consume: true };
9422
+ }
9325
9423
  if (now >= this.stopArmedUntil) {
9326
9424
  this.stopArmedUntil = now + this.showToast(stopTurnToast(this.turn));
9327
9425
  return { consume: true };
@@ -9900,8 +9998,8 @@ var TuiApp = class {
9900
9998
  this.tui.requestRender();
9901
9999
  }
9902
10000
  /**
9903
- * Handle a submitted editor line: a `/` line runs a command, anything else
9904
- * becomes a user message.
10001
+ * Handle a submitted editor line: a `/` line runs a command, a nonempty `!`
10002
+ * / `!!` line runs in the terminal, and anything else becomes a user message.
9905
10003
  * @param raw - the editor text.
9906
10004
  * @param mode - how a message reaches a running Agent: `queue` waits for the next turn, `steer` enters the current one.
9907
10005
  */
@@ -9920,6 +10018,11 @@ var TuiApp = class {
9920
10018
  this.dispatchCommand(text);
9921
10019
  return;
9922
10020
  }
10021
+ const shell = draft === void 0 ? parseUserShellLine(text) : void 0;
10022
+ if (shell !== void 0) {
10023
+ this.runUserShell(shell.command, shell.excluded);
10024
+ return;
10025
+ }
9923
10026
  this.submit(text, mode, draft);
9924
10027
  }
9925
10028
  /**
@@ -9933,6 +10036,100 @@ var TuiApp = class {
9933
10036
  this.notice(`${name} failed: ${describeFailure(error)}`, "error");
9934
10037
  });
9935
10038
  }
10039
+ /**
10040
+ * Run one user-typed shell command in this process and, unless it was `!!`,
10041
+ * inject the result as next-step context for the next admitted request.
10042
+ * @param command - the text after `!` / `!!`.
10043
+ * @param excluded - true when the line used `!!`.
10044
+ */
10045
+ async runUserShell(command, excluded) {
10046
+ if (this.shellAbort !== void 0) {
10047
+ this.notice(SHELL_BUSY, "error");
10048
+ this.editor.setText(excluded ? `!!${command}` : `!${command}`);
10049
+ this.syncEditorBorder();
10050
+ return;
10051
+ }
10052
+ const shell = this.deps.ctx.get("shell");
10053
+ if (shell === void 0) {
10054
+ this.notice(SHELL_MISSING, "error");
10055
+ return;
10056
+ }
10057
+ /* v8 ignore next -- TUI sessions record cwd on create; process cwd is the fallback when a header omitted it */
10058
+ const workdir = this.agent.session.header.cwd ?? this.deps.cwd;
10059
+ const controller = new AbortController();
10060
+ this.shellAbort = controller;
10061
+ try {
10062
+ const result = await shell.run(shell.resolve({
10063
+ command,
10064
+ workdir,
10065
+ signal: controller.signal,
10066
+ sandboxPolicy: {
10067
+ mode: "danger-full-access",
10068
+ workspaceRoot: workdir,
10069
+ sessionId: this.agent.session.id
10070
+ }
10071
+ }));
10072
+ if (!this.userShellCurrent(controller)) return;
10073
+ this.showUserShell(command, result, excluded);
10074
+ } catch (error) {
10075
+ if (!this.userShellCurrent(controller)) return;
10076
+ this.notice(`! failed: ${describeFailure(error)}`, "error");
10077
+ } finally {
10078
+ if (this.shellAbort === controller) this.shellAbort = void 0;
10079
+ }
10080
+ }
10081
+ /**
10082
+ * Whether `controller` is still the in-flight user-shell run on this bound
10083
+ * session. Bind and quit drop the controller so a late settle cannot draw or
10084
+ * inject into the next session.
10085
+ * @param controller - the AbortController created for this run.
10086
+ * @returns true while this run still owns `shellAbort` and the app is up.
10087
+ */
10088
+ userShellCurrent(controller) {
10089
+ return !this.stopped && this.shellAbort === controller;
10090
+ }
10091
+ /**
10092
+ * Detach and abort the in-flight user-shell run, if any. A late settle then
10093
+ * sees a different controller (or a stopped app) and stays silent.
10094
+ */
10095
+ dropUserShell() {
10096
+ const running = this.shellAbort;
10097
+ this.shellAbort = void 0;
10098
+ running?.abort();
10099
+ }
10100
+ /**
10101
+ * Draw one finished user shell run and inject the model-facing notice.
10102
+ * @param command - the text after `!` / `!!`.
10103
+ * @param result - the completed foreground run.
10104
+ * @param excluded - true when the line used `!!`.
10105
+ */
10106
+ showUserShell(command, result, excluded) {
10107
+ this.showBlock(userShellTranscriptRows(command, result));
10108
+ if (excluded) return;
10109
+ const message = createUserMessage({
10110
+ content: [{
10111
+ type: "text",
10112
+ text: userShellContextText(command, result)
10113
+ }],
10114
+ source: {
10115
+ kind: "plugin",
10116
+ plugin: "tui-app",
10117
+ form: "notice",
10118
+ summary: boundContextSummary(`! ${command}`)
10119
+ }
10120
+ });
10121
+ this.submittedIds.add(message.id);
10122
+ this.agent.inject(message);
10123
+ this.refreshQueue();
10124
+ }
10125
+ /**
10126
+ * Recolor the editor border while the draft starts with `!`.
10127
+ */
10128
+ syncEditorBorder() {
10129
+ const palette = this.deps.palette;
10130
+ this.editor.borderColor = this.editor.getText().trimStart().startsWith("!") ? palette.warning : palette.dim;
10131
+ this.tui.requestRender();
10132
+ }
9936
10133
  /** Return an abandoned edit to the ordinary-turn inbox without waking the Agent. */
9937
10134
  restoreQueueDraft() {
9938
10135
  const draft = this.queueDraft;
@@ -10462,7 +10659,8 @@ var TuiApp = class {
10462
10659
  this.notice("queue cleared", "success");
10463
10660
  return;
10464
10661
  }
10465
- const rows = [...inbox.nextTurn.map((message) => `next turn: ${contentText(message.content)}`), ...inbox.nextStep.map((message) => `next step: ${contentText(message.content)}`)];
10662
+ const queued = (messages) => messages.filter((message) => message.source.kind === "user");
10663
+ const rows = [...queued(inbox.nextTurn).map((message) => `next turn: ${contentText(message.content)}`), ...queued(inbox.nextStep).map((message) => `next step: ${contentText(message.content)}`)];
10466
10664
  this.notice(rows.length === 0 ? "nothing is queued" : rows.join("\n"));
10467
10665
  }
10468
10666
  async showSkills() {
@@ -11008,9 +11206,9 @@ var TuiApp = class {
11008
11206
  this.todoTurns = tracked;
11009
11207
  }
11010
11208
  onUserMessage(message) {
11209
+ if (this.submittedIds.has(message.id)) return;
11011
11210
  const source = message.source;
11012
11211
  if (source.kind === "user") {
11013
- if (this.submittedIds.has(message.id)) return;
11014
11212
  const attachments = message.content.filter((block) => block.type !== "text").map((block) => `[${block.type}]`);
11015
11213
  this.chat.addChild(new UserBlock(this.theme, [contentText(message.content), ...attachments].filter((part) => part !== "").join("\n"), this.turn));
11016
11214
  return;
@@ -26,9 +26,10 @@ Examples:
26
26
  dsh --profile tui --resume <session-id> continue an earlier session
27
27
  dsh tui alias of --profile tui
28
28
 
29
- Keys: Enter sends, Esc twice stops the running turn, Ctrl+O folds or unfolds
30
- every tool card and context row, Ctrl+C twice (or Ctrl+D on an empty input)
31
- quits. Type /help for commands.
29
+ Keys: Enter sends, !cmd runs a local shell command the next prompt can read,
30
+ Esc twice stops the running turn, Ctrl+O folds or unfolds every tool card
31
+ and context row, Ctrl+C twice (or Ctrl+D on an empty input) quits. Type
32
+ /help for commands.
32
33
  `);
33
34
  }
34
35
  /**
@@ -86,6 +86,7 @@
86
86
  "@deepseek-ai/dsh-session-stats": "0.1.6-alpha.2",
87
87
  "@deepseek-ai/dsh-session-title": "0.1.6-alpha.2",
88
88
  "@deepseek-ai/dsh-settings": "0.1.6-alpha.2",
89
+ "@deepseek-ai/dsh-shell": "0.1.6-alpha.2",
89
90
  "@deepseek-ai/dsh-subagent": "0.1.6-alpha.2",
90
91
  "@deepseek-ai/dsh-token-meter": "0.1.6-alpha.2",
91
92
  "@deepseek-ai/dsh-tool-todo": "0.1.6-alpha.2",
@@ -114,6 +115,7 @@
114
115
  "@deepseek-ai/dsh-session-stats": "0.1.6-alpha.2",
115
116
  "@deepseek-ai/dsh-session-title": "0.1.6-alpha.2",
116
117
  "@deepseek-ai/dsh-settings": "0.1.6-alpha.2",
118
+ "@deepseek-ai/dsh-shell": "0.1.6-alpha.2",
117
119
  "@deepseek-ai/dsh-subagent": "0.1.6-alpha.2",
118
120
  "@deepseek-ai/dsh-system-prompt": "0.1.6-alpha.2",
119
121
  "@deepseek-ai/dsh-token-meter": "0.1.6-alpha.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
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",