@songtonyli/dsh-cli 0.1.44 → 0.1.45

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.44; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.45; `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.44 (deepseek-harness 0.1.7-rc.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.45 (deepseek-harness 0.1.7-rc.2)')
22
22
  process.exit(0)
23
23
  }
24
24
 
@@ -47,10 +47,10 @@
47
47
  "micromark-extension-gfm": "^3.0.0",
48
48
  "micromark-util-sanitize-uri": "^2.0.1",
49
49
  "simple-icons": "16.31.0",
50
- "@deepseek-ai/dsh-client-store": "0.1.7-rc.2",
51
- "@deepseek-ai/dsh-util-code-language": "0.1.7-rc.2",
52
50
  "@deepseek-ai/cordis": "~4.0.4",
53
- "@deepseek-ai/dsh-util-workspace-path": "0.1.7-rc.2"
51
+ "@deepseek-ai/dsh-util-workspace-path": "0.1.7-rc.2",
52
+ "@deepseek-ai/dsh-client-store": "0.1.7-rc.2",
53
+ "@deepseek-ai/dsh-util-code-language": "0.1.7-rc.2"
54
54
  },
55
55
  "files": [
56
56
  "lib/index.js",
@@ -167,7 +167,7 @@ window.__ModuleLoader__.load({
167
167
  const SCROLLBAR_LINGER_MS = 2e3;
168
168
  /** Format complete-build metadata for the local brand badge. */
169
169
  function localBuildVersion() {
170
- return `0.1.7-rc.2-c9b1f41` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
170
+ return `0.1.7-rc.2-08040bb-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 }) {
@@ -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.7-rc.2",
28
- "@deepseek-ai/cordis": "~4.0.4"
27
+ "@deepseek-ai/cordis": "~4.0.4",
28
+ "@deepseek-ai/dsh-client-store": "0.1.7-rc.2"
29
29
  },
30
30
  "files": [
31
31
  "lib/index.js",
@@ -18,14 +18,14 @@
18
18
  en: 192bbbb187278f91
19
19
  zh: 1f7e5632c15bdcf7
20
20
  /deepseek-ai-dsh-tui-app/use-this-package/starting-and-resuming:
21
- en: 847fde63152cd543
22
- zh: bcabc58850804e14
21
+ en: be0e9f07314547a5
22
+ zh: e55e8e668b3f703f
23
23
  /deepseek-ai-dsh-tui-app/use-this-package/the-screen:
24
24
  en: f46aab5ea9d40e5d
25
25
  zh: c2b21f7d6faa40a4
26
26
  /deepseek-ai-dsh-tui-app/use-this-package/keys-and-commands:
27
- en: 144dbbfb32211390
28
- zh: b0999e01748b7a05
27
+ en: 99188e75ab3d7d84
28
+ zh: 4c1575148f12c16f
29
29
  /deepseek-ai-dsh-tui-app/use-this-package/subscription-sign-in:
30
30
  en: 7c1b0e685a3a9415
31
31
  zh: 49f3bdc3e99d6259
@@ -42,17 +42,17 @@
42
42
  en: f124d406565fef39
43
43
  zh: 90344b5eec319cad
44
44
  /deepseek-ai-dsh-tui-app/understand-the-implementation/run-flow:
45
- en: 62a36804976ea19a
46
- zh: 4feac1647d3ffe39
45
+ en: 244caa693b65b28f
46
+ zh: 20bd432745c5a9b1
47
47
  /deepseek-ai-dsh-tui-app/understand-the-implementation/rendering-model:
48
- en: 4fca4aa5d993ccbc
49
- zh: 8740f83134db5207
48
+ en: 192d3daab8c51a4e
49
+ zh: 7960dc941f40ccc5
50
50
  /deepseek-ai-dsh-tui-app/understand-the-implementation/patch-surface-over-base:
51
51
  en: 142f04bf29e981dd
52
52
  zh: a1689297b06c9ca6
53
53
  /deepseek-ai-dsh-tui-app/understand-the-implementation/source-map:
54
- en: 1c9ccdc98a9612d0
55
- zh: 6a6b5426f34e4765
54
+ en: 6910be5a539fb133
55
+ zh: b004b911c5757e6a
56
56
  /deepseek-ai-dsh-tui-app/understand-the-implementation/invariant-ownership:
57
57
  en: 0ddf6de8928026d5
58
58
  zh: 24feedcbb9e9d676
@@ -77,9 +77,21 @@
77
77
  /deepseek-ai-dsh-tui-app/model-experience/user-typed-shell-command/kv-cache-effect:
78
78
  en: 5b83189b640899dd
79
79
  zh: 232c1ef2f192bd4c
80
+ /deepseek-ai-dsh-tui-app/model-experience/side-question:
81
+ en: ac6516adff6e6ea3
82
+ zh: 6ecac977743e7bee
83
+ /deepseek-ai-dsh-tui-app/model-experience/side-question/what-the-model-sees:
84
+ en: 87691f2e4225a1ba
85
+ zh: 3b838561c2ac5fe2
86
+ /deepseek-ai-dsh-tui-app/model-experience/side-question/token-effect:
87
+ en: 5c6d016f2f7f1608
88
+ zh: 3eb76252a08d51e9
89
+ /deepseek-ai-dsh-tui-app/model-experience/side-question/kv-cache-effect:
90
+ en: c3792aed799617f8
91
+ zh: 4efaf1d8ae59ff5b
80
92
  /deepseek-ai-dsh-tui-app/known-limitations-and-deferred-work:
81
- en: 3cd90cc557ebd7f6
82
- zh: a54bb26156f80a7c
93
+ en: 6f34cd31df3d1797
94
+ zh: c7019e2aa9ed3dde
83
95
  /deepseek-ai-dsh-tui-app/known-limitations-and-deferred-work/dev-note:
84
96
  en: 5629c6159cec997f
85
97
  zh: 17f2d7e1f96da7f1
@@ -36,7 +36,7 @@ dsh tui --resume <session-id> # continue an earlier session
36
36
  dsh tui --no-open # print sign-in URLs without opening a browser
37
37
  ```
38
38
 
39
- On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new` and `/clear` each start a fresh empty one while the previous session stays on disk for `/resume`, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
39
+ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input and continues with that session's last model, or the launch default when the log has no request header; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new` and `/clear` each start a fresh empty one while the previous session stays on disk for `/resume`, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
40
40
 
41
41
  ### The screen
42
42
 
@@ -248,11 +248,11 @@ The runner is a direct driver over the core API carrier, like `dsh-headless`, th
248
248
 
249
249
  ### Run flow
250
250
 
251
- The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with four operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` takes the Agent write handle first and then observes the live Session through `ctx.sessionQuery` so bind draws every persisted event including resume closers, 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, and `observe` opens a subagent session without releasing the bound one — a resident subagent Agent is read live and its release does nothing, and any other session is resumed. Every operation except a resident `observe` 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.
251
+ The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with four operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` takes the Agent write handle first and then observes the live Session through `ctx.sessionQuery` so bind draws every persisted event including resume closers, 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, and `observe` opens a subagent session without releasing the bound one — a resident subagent Agent is read live and its release does nothing, and any other session is resumed. Every operation except a resident `observe` installs a `ModelSelectionRef` in the Agent's scoped setup so `/model` changes the next request; `resume` passes the launch default as AgentOptions so assemble has a `{{model}}` value, then overlays the log's last request header onto the selection when one exists, else keeps that default. 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.
252
252
 
253
253
  ### Rendering model
254
254
 
255
- Durable facts come from the session log: `system/message` (a nonempty prompt draws in full; an empty rendering is omitted), `user/message` (own submissions are drawn once and their echo skipped by message id; injected context — instructions, catalogs, snapshots, notices, relays, recalls, and undeclared forms — draws in full as a dim `⬡` row, a snapshot as one named contribution per part; compaction replacements and tool or model sources are omitted), `assistant/message` (which replaces the streamed block with the committed text and folds usage into the footer), `tool/call` and `tool/result` (drawn through the tool's `presentCall` and `presentResult` views when it declares them, with a raw-argument and raw-result fallback), `turn/end` notices, `workspace/changes` (one notice with the turn's file and line counts while the Host still holds the summary), `session/title` (header), `permission/preset` (footer), and `todo/write` under the enclosing `turn/start` (the turns one todo item's page reports; the list carries no per-item identity, so a reworded item counts as a new one; the same write refreshes the activity board from the `todos` projection). A descendant `tool/call`, `tool/result`, or `turn/end`, and a `subagent/start` or `subagent/end` for the bound parent, replace that board's one-line summary — tool title or first result row, never child assistant prose; `turn/end` on the bound session and bind clear the board. Live incrementality comes from `agent/assistant-stream` text, reasoning, tool-call, and usage deltas: a card is mounted when the model names the tool, and the working spinner follows that stream plus durable `tool/call` / `tool/result` so it says `thinking`, `writing`, or `calling <tool>` with live `↑` send and `↓` receive for that call. Session facts outside the log come from the same services the browser reads: `sessionTitle`, `permissionPresets`, `sessionQuery` for the picker, `/deliverables`, and subagent details, `sessionProjections` for the footer, `/status`, `/todos`, and `/outline`, `fileReferences` and `sessionReferenceResolver` for `@` completion, `attachments`, `skills`, `authorization`, `settings`, `subagents`, and the Loader's entries for `/plugins`. Modal prompts are process-local presentation and are never logged.
255
+ Durable facts come from the session log: `system/message` (a nonempty prompt draws in full; an empty rendering is omitted), `user/message` (own submissions are drawn once and their echo skipped by message id; injected context — instructions, catalogs, snapshots, notices, relays, recalls, and undeclared forms — draws in full as a dim `⬡` row, a snapshot as one named contribution per part; compaction replacements and tool or model sources are omitted), `assistant/message` (which replaces the streamed block with the committed text and folds usage into the footer), `tool/call` and `tool/result` (drawn through the tool's `presentCall` and `presentResult` views when it declares them, with a raw-argument and raw-result fallback), `turn/end` notices, `workspace/changes` (one notice with the turn's file and line counts while the Host still holds the summary), `session/title` (header), `permission/preset` (footer), and `todo/write` under the enclosing `turn/start` (the turns one todo item's page reports; the list carries no per-item identity, so a reworded item counts as a new one; the same write refreshes the activity board from the `todos` projection). A descendant `tool/call`, `tool/result`, or `turn/end`, and a `subagent/start` or `subagent/end` for the bound parent, replace that board's one-line summary — tool title or first result row, never child assistant prose; `turn/end` on the bound session and bind clear the board. Live incrementality comes from `agent/assistant-stream` text, reasoning, tool-call, and usage deltas: a card is mounted when the model names the tool, and the working spinner follows that stream plus durable `tool/call` / `tool/result` so it says `thinking`, `writing`, or `calling <tool>` with live `↑` send and `↓` receive for that call. Session facts outside the log come from the same services the browser reads: `sessionTitle`, `permissionPresets`, `sessionQuery` for the picker identities, the live or cached `title` projection for picker titles, `/deliverables`, and subagent details, `sessionProjections` for the footer, `/status`, `/todos`, and `/outline`, `fileReferences` and `sessionReferenceResolver` for `@` completion, `attachments`, `skills`, `authorization`, `settings`, `subagents`, and the Loader's entries for `/plugins`. Modal prompts are process-local presentation and are never logged.
256
256
 
257
257
  ### Patch surface over base
258
258
 
@@ -263,10 +263,12 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
263
263
  | File | Role |
264
264
  |---|---|
265
265
  | [`src/index.ts`](src/index.ts) | The `tui-app` plugin: the session host (create, resume, fork, observe), resume observation, quit flow, exit mapping |
266
+ | [`src/resume-model.ts`](src/resume-model.ts) | Resume-time model selection from the last request header or the launch default |
267
+ | [`tests/resume-model.spec.ts`](tests/resume-model.spec.ts) | Resume restores the last logged route, else the launch default |
266
268
  | [`src/startup.ts`](src/startup.ts) | The `tui-app-startup` provider: prompt positional, `--resume`, `--no-open`, and `--help` |
267
269
  | [`src/app.ts`](src/app.ts) | The terminal application: layout, the key router, commands, session binding, seams, log and stream folding, the activity board above the editor, the stop arm, the transient line it mounts, the terminal handover the reader runs on, and prefix-on-submit `!` / `!!` |
268
270
  | [`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 |
269
- | [`src/sessions.ts`](src/sessions.ts) | The persisted-session list and picker rows shared by `/resume` and `/sessions` |
271
+ | [`src/sessions.ts`](src/sessions.ts) | The persisted-session list and picker rows shared by `/resume` and `/sessions`; titles come from the live or cached title projection |
270
272
  | [`src/effort.ts`](src/effort.ts) | Reasoning-effort names and picker rows shared by `/model`, `/effort`, and editor `Shift+Tab` |
271
273
  | [`src/permission.ts`](src/permission.ts) | Permission-preset names and picker rows for `/permission` |
272
274
  | [`src/attach.ts`](src/attach.ts) | `/attach`: local files into image or file blocks through the attachment store |
@@ -324,7 +326,8 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
324
326
  | [`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 |
325
327
  | [`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 |
326
328
  | [`tests/context.spec.ts`](tests/context.spec.ts) | Projection of system prompts and injected context into transcript sections |
327
- | [`tests/index.spec.ts`](tests/index.spec.ts) | Creation, resume paging, fork cut, session switching, quit flow, and failure reporting |
329
+ | [`tests/sessions.spec.ts`](tests/sessions.spec.ts) | Session picker listing: newest first, live or cached titles, hidden subagents |
330
+ | [`tests/index.spec.ts`](tests/index.spec.ts) | Creation, resume paging, resume model assembly, fork cut, session switching, quit flow, and failure reporting |
328
331
  | [`tests/startup.spec.ts`](tests/startup.spec.ts) | Command-line parsing over a real Loader tree |
329
332
  | [`tests/shortcuts.spec.ts`](tests/shortcuts.spec.ts) | `?` on an empty input and inside a draft, `Ctrl+T` from any region, `Ctrl+P` at the root session, and the `Ctrl+L` redraw |
330
333
  | [`tests/subagents.spec.ts`](tests/subagents.spec.ts) | The live subagent panel's rows, walk, and listing refresh, and the subagent view it and `/subagents` open, left through `/parent` and `Ctrl+P` and released on a session switch and on quit |
@@ -36,7 +36,7 @@ dsh tui --resume <session-id> # continue an earlier session
36
36
  dsh tui --no-open # print sign-in URLs without opening a browser
37
37
  ```
38
38
 
39
- 退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史;在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new` 与 `/clear` 都会开始一个空的新会话且先前会话仍留在磁盘上可用 `/resume` 恢复,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
39
+ 退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史,并沿用该会话上次使用的模型;日志里还没有请求头时则使用启动默认模型。在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new` 与 `/clear` 都会开始一个空的新会话且先前会话仍留在磁盘上可用 `/resume` 恢复,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
40
40
 
41
41
  ### 屏幕布局
42
42
 
@@ -248,11 +248,11 @@ runner 与 `dsh-headless` 一样是核心 API 载体之上的直接驱动器,
248
248
 
249
249
  ### 运行流程
250
250
 
251
- runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含四个操作的会话宿主:`create` 用共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume` 先拿到 Agent 写句柄,再经 `ctx.sessionQuery` 观察实时 Session,使 bind 画出每条持久化事件(包括恢复时的闭合事件),`fork` 通过 `ctx.sessionQuery` 观察源会话、在所选(默认最后一个)`turn/end` 之后直到下一个 `turn/start` 处切割,并创建带 `parentSession` 与 `isSeeded` 元数据的种子 Agent,`observe` 打开子 agent 会话而不释放已绑定的会话——常驻的子 agent Agent 被实时读取、释放它什么也不做,其他会话则被恢复。除常驻会话的 `observe` 外,每个操作都在 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` 运行;`!` 注入一条下一步通知,`!!` 只留在本地。
251
+ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含四个操作的会话宿主:`create` 用共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume` 先拿到 Agent 写句柄,再经 `ctx.sessionQuery` 观察实时 Session,使 bind 画出每条持久化事件(包括恢复时的闭合事件),`fork` 通过 `ctx.sessionQuery` 观察源会话、在所选(默认最后一个)`turn/end` 之后直到下一个 `turn/start` 处切割,并创建带 `parentSession` 与 `isSeeded` 元数据的种子 Agent,`observe` 打开子 agent 会话而不释放已绑定的会话——常驻的子 agent Agent 被实时读取、释放它什么也不做,其他会话则被恢复。除常驻会话的 `observe` 外,每个操作都在 Agent 的作用域 setup 中安装 `ModelSelectionRef`,因此 `/model` 会改变下一次请求;`resume` 把启动默认作为 AgentOptions 传入,使组装时 `{{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` 运行;`!` 注入一条下一步通知,`!!` 只留在本地。
252
252
 
253
253
  ### 渲染模型
254
254
 
255
- 持久事实来自会话日志:`system/message`(非空提示词完整画出;空的绘制则省略)、`user/message`(自己提交的消息只绘制一次,其回显按消息 id 跳过;注入的上下文——instructions、catalogs、snapshots、notices、relays、recalls 以及未声明的形式——以暗色 `⬡` 行完整画出,快照按具名贡献各成一部分;压缩替换以及工具或模型来源则省略)、`assistant/message`(用已提交文本替换流式块,并把用量折入页脚)、`tool/call` 与 `tool/result`(工具声明 `presentCall` 与 `presentResult` 视图时据此绘制,否则回退到原始参数与原始结果)、`turn/end` 通知、`workspace/changes`(在 Host 仍保存摘要时,以一行通知给出该轮的文件数与行数)、`session/title`(页眉)、`permission/preset`(页脚),以及所属 `turn/start` 之下的 `todo/write`(某条 todo 的详情页所报告的轮次;该列表不带逐条标识,因此改写措辞的条目算作新条目;同一次写入还从 `todos` 投影刷新 activity board)。后代会话的 `tool/call`、`tool/result` 或 `turn/end`,以及绑定父会话的 `subagent/start` / `subagent/end`,会替换该板上的一行摘要——工具标题或结果首行,从不使用子会话的 assistant 正文;绑定会话的 `turn/end` 与 bind 会清空该板。实时增量来自 `agent/assistant-stream` 的文本、推理、工具调用与用量增量:模型一报出工具名就挂上卡片,工作时的旋转指示跟随该流以及持久的 `tool/call` / `tool/result`,从而标出 `thinking`、`writing` 或 `calling <tool>`,并带着该次调用的实时 `↑` 发送与 `↓` 接收。日志之外的会话事实来自浏览器读取的同一批服务:`sessionTitle`、`permissionPresets`、供选择器、`/deliverables` 与子 agent 详情使用的 `sessionQuery`、供页脚、`/status`、`/todos` 与 `/outline` 使用的 `sessionProjections`、供 `@` 补全使用的 `fileReferences` 与 `sessionReferenceResolver`、`attachments`、`skills`、`authorization`、`settings`、`subagents`,以及供 `/plugins` 使用的 Loader 条目。模态提示是进程本地的呈现,从不写入日志。
255
+ 持久事实来自会话日志:`system/message`(非空提示词完整画出;空的绘制则省略)、`user/message`(自己提交的消息只绘制一次,其回显按消息 id 跳过;注入的上下文——instructions、catalogs、snapshots、notices、relays、recalls 以及未声明的形式——以暗色 `⬡` 行完整画出,快照按具名贡献各成一部分;压缩替换以及工具或模型来源则省略)、`assistant/message`(用已提交文本替换流式块,并把用量折入页脚)、`tool/call` 与 `tool/result`(工具声明 `presentCall` 与 `presentResult` 视图时据此绘制,否则回退到原始参数与原始结果)、`turn/end` 通知、`workspace/changes`(在 Host 仍保存摘要时,以一行通知给出该轮的文件数与行数)、`session/title`(页眉)、`permission/preset`(页脚),以及所属 `turn/start` 之下的 `todo/write`(某条 todo 的详情页所报告的轮次;该列表不带逐条标识,因此改写措辞的条目算作新条目;同一次写入还从 `todos` 投影刷新 activity board)。后代会话的 `tool/call`、`tool/result` 或 `turn/end`,以及绑定父会话的 `subagent/start` / `subagent/end`,会替换该板上的一行摘要——工具标题或结果首行,从不使用子会话的 assistant 正文;绑定会话的 `turn/end` 与 bind 会清空该板。实时增量来自 `agent/assistant-stream` 的文本、推理、工具调用与用量增量:模型一报出工具名就挂上卡片,工作时的旋转指示跟随该流以及持久的 `tool/call` / `tool/result`,从而标出 `thinking`、`writing` 或 `calling <tool>`,并带着该次调用的实时 `↑` 发送与 `↓` 接收。日志之外的会话事实来自浏览器读取的同一批服务:`sessionTitle`、`permissionPresets`、供选择器身份、`/deliverables` 与子 agent 详情使用的 `sessionQuery`、供选择器标题使用的实时或缓存 `title` 投影、供页脚、`/status`、`/todos` 与 `/outline` 使用的 `sessionProjections`、供 `@` 补全使用的 `fileReferences` 与 `sessionReferenceResolver`、`attachments`、`skills`、`authorization`、`settings`、`subagents`,以及供 `/plugins` 使用的 Loader 条目。模态提示是进程本地的呈现,从不写入日志。
256
256
 
257
257
  ### 基于 base 的 patch 面
258
258
 
@@ -263,10 +263,12 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
263
263
  | 文件 | 职责 |
264
264
  |---|---|
265
265
  | [`src/index.ts`](src/index.ts) | `tui-app` 插件:会话宿主(创建、恢复、fork、观察)、恢复观察、退出流程、退出码映射 |
266
+ | [`src/resume-model.ts`](src/resume-model.ts) | 恢复时的模型选择:来自最后一条请求头,否则为启动默认 |
267
+ | [`tests/resume-model.spec.ts`](tests/resume-model.spec.ts) | 恢复沿用上次记录的路由,没有请求头时则用启动默认 |
266
268
  | [`src/startup.ts`](src/startup.ts) | `tui-app-startup` 提供方:提示位置参数、`--resume`、`--no-open` 与 `--help` |
267
269
  | [`src/app.ts`](src/app.ts) | 终端应用:布局、按键路由、命令、会话绑定、接缝、日志与流的折叠、编辑器上方的 activity board、停止装填、它挂载的临时提示行、阅读器所依托的终端交接,以及提交时解析的 `!` / `!!` |
268
270
  | [`src/keys.ts`](src/keys.ts) | 按键模型:各焦点区域、一次按键在每个区域中的含义、它们逐级收缩的按键提示、进入用的按键、`/help` 的各行,以及交接窗口 |
269
- | [`src/sessions.ts`](src/sessions.ts) | `/resume` 与 `/sessions` 共用的持久化会话列表及选择器行 |
271
+ | [`src/sessions.ts`](src/sessions.ts) | `/resume` 与 `/sessions` 共用的持久化会话列表及选择器行;标题来自实时或缓存的 title 投影 |
270
272
  | [`src/effort.ts`](src/effort.ts) | `/model`、`/effort` 与编辑器 `Shift+Tab` 共用的推理强度名称及选择器行 |
271
273
  | [`src/permission.ts`](src/permission.ts) | `/permission` 的权限预设名称及选择器行 |
272
274
  | [`src/attach.ts`](src/attach.ts) | `/attach`:本地文件经附件存储成为图片或文件块 |
@@ -324,7 +326,8 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
324
326
  | [`tests/panels.spec.ts`](tests/panels.spec.ts) | 状态页脚与报告、可导航的子 agent 与 todo 列表、目录命令、命令提示与审批详情 |
325
327
  | [`tests/transcript-focus.spec.ts`](tests/transcript-focus.spec.ts) | 走遍对话记录、区域序列、检视面板、实时会话上的阅读器连同它接管与交还的终端,以及重绘窗口内的原地标记条 |
326
328
  | [`tests/context.spec.ts`](tests/context.spec.ts) | 把系统提示词与注入上下文投影为对话记录小节 |
327
- | [`tests/index.spec.ts`](tests/index.spec.ts) | 创建、恢复分页、fork 切割、会话切换、退出流程与失败报告 |
329
+ | [`tests/sessions.spec.ts`](tests/sessions.spec.ts) | 会话选择器列表:最新在前、实时或缓存标题、隐藏子 agent |
330
+ | [`tests/index.spec.ts`](tests/index.spec.ts) | 创建、恢复分页、恢复时的模型组装、fork 切割、会话切换、退出流程与失败报告 |
328
331
  | [`tests/startup.spec.ts`](tests/startup.spec.ts) | 基于真实 Loader 配置树的命令行解析 |
329
332
  | [`tests/shortcuts.spec.ts`](tests/shortcuts.spec.ts) | 空输入与草稿中的 `?`、任一区域的 `Ctrl+T`、根会话上的 `Ctrl+P`,以及 `Ctrl+L` 重绘 |
330
333
  | [`tests/subagents.spec.ts`](tests/subagents.spec.ts) | 实时子 agent 面板的各行、走查与列表刷新,以及它与 `/subagents` 打开的子 agent 视图:经 `/parent` 与 `Ctrl+P` 离开,并在会话切换与退出时释放 |
@@ -20,6 +20,32 @@ import { Readable } from "node:stream";
20
20
  import { pipeline } from "node:stream/promises";
21
21
  import { DEFAULT_SESSION_LOG_COMPRESSION_LEVEL, flushLiveSessionLog, readSessionLogText, sessionLogExportDeps, sessionLogZipFilename, streamSessionLogZip } from "@deepseek-ai/dsh-session-log-export";
22
22
  import { planReviewOptions } from "@deepseek-ai/dsh-user-questions";
23
+ //#region lib/types/resume-model.js
24
+ /**
25
+ * Resume-time model selection: the last logged route, else the launch default.
26
+ * @module @deepseek-ai/dsh-tui-app/resume-model
27
+ */
28
+ /**
29
+ * The model the next resumed request should assemble with.
30
+ *
31
+ * A logged header supplies the conversation's last provider, model, and any
32
+ * effort the adapter did not default. An adapter-defaulted effort is omitted
33
+ * so an unchanged default does not read as a request change. A log with no
34
+ * header uses `fallback`, the same launch default a fresh session starts from.
35
+ *
36
+ * @param logged - the Session's last request header, or undefined before one exists.
37
+ * @param fallback - the composed default-model selection.
38
+ * @returns the selection installed for prompt assembly and request routing.
39
+ */
40
+ function resumeModelSelection(logged, fallback) {
41
+ if (logged === void 0) return fallback;
42
+ return {
43
+ provider: logged.config.provider,
44
+ model: logged.config.model,
45
+ ...logged.config.reasoningEffort === void 0 || logged.adapterDefaults?.reasoningEffort === true ? {} : { reasoningEffort: logged.config.reasoningEffort }
46
+ };
47
+ }
48
+ //#endregion
23
49
  //#region ../../credentials/authorization/src/index.ts
24
50
  /** Stable error taxonomy for authorization failures. */
25
51
  var AuthorizationError = class extends HarnessError {
@@ -10194,6 +10220,13 @@ var GuardedMainScreen = class extends TuiMainScreen {
10194
10220
  */
10195
10221
  /**
10196
10222
  * List persisted sessions newest first, with their titles; subagent sessions are excluded.
10223
+ *
10224
+ * Titles come from the live `title` projection or the durable projection
10225
+ * cache, the same values the browser list uses. The picker does not load
10226
+ * session logs, so a large corpus stays a listing of headers plus cached
10227
+ * rows. A session whose title is not yet cached shows its id until a later
10228
+ * listing after the cache has the row.
10229
+ *
10197
10230
  * @param ctx - plugin context carrying the session query engine.
10198
10231
  * @param currentId - the session the terminal drives, marked in the result.
10199
10232
  * @param signal - cancels the listing.
@@ -10202,19 +10235,13 @@ var GuardedMainScreen = class extends TuiMainScreen {
10202
10235
  async function listSessionChoices(ctx, currentId, signal) {
10203
10236
  const query = ctx.get("sessionQuery");
10204
10237
  if (query === void 0) return [];
10205
- const records = (await query.listSessions(signal)).filter((record) => record.header.origin === void 0).sort((left, right) => right.header.createdAt - left.header.createdAt);
10206
- const titles = await query.readTitleSnapshots(records.map((record) => record.header.id), signal);
10207
- return records.map((record, index) => {
10208
- const observed = titles[index];
10209
- const title = observed?.status === "fulfilled" ? observed.value.title?.title : void 0;
10210
- return {
10211
- id: record.header.id,
10212
- title,
10213
- cwd: record.header.cwd,
10214
- createdAt: record.header.createdAt,
10215
- current: record.header.id === currentId
10216
- };
10217
- });
10238
+ return (await query.listSessions(signal)).filter((record) => record.header.origin === void 0).sort((left, right) => right.header.createdAt - left.header.createdAt).map((record) => ({
10239
+ id: record.header.id,
10240
+ title: sessionListTitle(ctx, record.header),
10241
+ cwd: record.header.cwd,
10242
+ createdAt: record.header.createdAt,
10243
+ current: record.header.id === currentId
10244
+ }));
10218
10245
  }
10219
10246
  /**
10220
10247
  * The picker row for one session: title or id, then the workspace and date.
@@ -10230,6 +10257,22 @@ function describeSession(choice) {
10230
10257
  description: parts.join(" · ")
10231
10258
  };
10232
10259
  }
10260
+ /**
10261
+ * Latest title for a listed session without reading its log.
10262
+ * @param ctx - plugin context carrying live projections and the optional cache.
10263
+ * @param header - the listed session's header.
10264
+ * @returns the title text, or undefined when neither source has one.
10265
+ */
10266
+ function sessionListTitle(ctx, header) {
10267
+ const live = ctx.get("sessions")?.get(header.id);
10268
+ if (live !== void 0) {
10269
+ const title = ctx.get("sessionProjections")?.snapshot(live, ["title"]).values.title;
10270
+ if (typeof title === "string" && title !== "") return title;
10271
+ }
10272
+ const cache = ctx.get("sessionProjectionCache");
10273
+ const title = (cache?.cachedSnapshot(header) ?? cache?.cachedPredecessorTitle(header))?.values.title;
10274
+ return typeof title === "string" && title !== "" ? title : void 0;
10275
+ }
10233
10276
  /** Two-space indentation per nesting level, as the `/subagents` rows indent. */
10234
10277
  const DEPTH_INDENT = " ";
10235
10278
  /** What separates two facts inside one row, and two parts of the heading. */
@@ -14846,6 +14889,9 @@ async function forkSeed(ctx, id, turn) {
14846
14889
  /**
14847
14890
  * The terminal's session host over the core Agent registry. Every Agent gets
14848
14891
  * the model selection installed so `/model` applies from the next request.
14892
+ * Resume passes the launch default as AgentOptions so assemble has a
14893
+ * `{{model}}` value, then overlays the log's last request header onto the
14894
+ * selection when one exists, else keeps that default.
14849
14895
  * @param ctx - plugin context.
14850
14896
  * @param core - the injected services.
14851
14897
  * @param cwd - the workspace root recorded on new sessions.
@@ -14893,13 +14939,19 @@ function sessionHost(ctx, core, cwd) {
14893
14939
  });
14894
14940
  }, seed ?? []);
14895
14941
  const resume = async (id) => {
14942
+ const fallback = defaultModel.currentSelection();
14896
14943
  const selection = {
14897
- current: void 0,
14944
+ current: fallback,
14898
14945
  assembled: void 0
14899
14946
  };
14900
14947
  const handle = await agents.resume({
14901
14948
  resumeSessionId: id,
14902
- setup: (agentCtx) => {
14949
+ agentOptions: {
14950
+ provider: fallback.provider,
14951
+ model: fallback.model
14952
+ },
14953
+ setup: (agentCtx, agent) => {
14954
+ selection.current = resumeModelSelection(agent.session.requestHeader(), fallback);
14903
14955
  installModelSelection(agentCtx, selection);
14904
14956
  }
14905
14957
  });
@@ -82,6 +82,7 @@
82
82
  "@deepseek-ai/dsh-session": "0.1.7-rc.2",
83
83
  "@deepseek-ai/dsh-session-persistence": "0.1.7-rc.2",
84
84
  "@deepseek-ai/dsh-session-projection": "0.1.7-rc.2",
85
+ "@deepseek-ai/dsh-session-projection-cache": "0.1.7-rc.2",
85
86
  "@deepseek-ai/dsh-session-query": "0.1.7-rc.2",
86
87
  "@deepseek-ai/dsh-session-stats": "0.1.7-rc.2",
87
88
  "@deepseek-ai/dsh-session-title": "0.1.7-rc.2",
@@ -111,6 +112,7 @@
111
112
  "@deepseek-ai/dsh-session": "0.1.7-rc.2",
112
113
  "@deepseek-ai/dsh-session-persistence": "0.1.7-rc.2",
113
114
  "@deepseek-ai/dsh-session-projection": "0.1.7-rc.2",
115
+ "@deepseek-ai/dsh-session-projection-cache": "0.1.7-rc.2",
114
116
  "@deepseek-ai/dsh-session-query": "0.1.7-rc.2",
115
117
  "@deepseek-ai/dsh-session-stats": "0.1.7-rc.2",
116
118
  "@deepseek-ai/dsh-session-title": "0.1.7-rc.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
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",