dsh-code 0.4.0 → 0.6.0

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.
Files changed (49) hide show
  1. package/README.en.md +217 -0
  2. package/README.md +216 -67
  3. package/bin/deepseek.mjs +70 -0
  4. package/cordis.patch.yml +62 -6
  5. package/lib/devtools-CdTl3MNy.mjs +3643 -0
  6. package/lib/index.mjs +27467 -673
  7. package/lib/rolldown-runtime-CMFfr-1z.mjs +26 -0
  8. package/lib/startup.mjs +34 -17
  9. package/lib/types/app.d.ts +29 -1
  10. package/lib/types/commands.d.ts +2 -0
  11. package/lib/types/history.d.ts +79 -0
  12. package/lib/types/index.d.ts +5 -5
  13. package/lib/types/internals.d.ts +2 -0
  14. package/lib/types/kernel-panels.d.ts +48 -0
  15. package/lib/types/plugin-inventory.d.ts +11 -0
  16. package/lib/types/presets.d.ts +32 -0
  17. package/lib/types/render/animations.d.ts +10 -1
  18. package/lib/types/render/inspector.d.ts +6 -0
  19. package/lib/types/render/projection.d.ts +21 -1
  20. package/lib/types/render/status.d.ts +131 -14
  21. package/lib/types/render/text.d.ts +9 -0
  22. package/lib/types/session-directory.d.ts +54 -0
  23. package/lib/types/session-switch.d.ts +17 -0
  24. package/lib/types/skills.d.ts +2 -0
  25. package/lib/types/startup.d.ts +11 -1
  26. package/package.json +117 -112
  27. package/src/app.ts +2543 -1969
  28. package/src/commands.ts +15 -1
  29. package/src/history.ts +136 -0
  30. package/src/index.ts +550 -155
  31. package/src/internals.ts +5 -0
  32. package/src/kernel-panels.ts +419 -0
  33. package/src/plugin-inventory.ts +47 -0
  34. package/src/presets.ts +64 -0
  35. package/src/render/animations.ts +14 -1
  36. package/src/render/export.ts +4 -0
  37. package/src/render/inspector.ts +23 -5
  38. package/src/render/lines.ts +21 -10
  39. package/src/render/markdown.ts +15 -1
  40. package/src/render/projection.ts +71 -8
  41. package/src/render/status.ts +522 -65
  42. package/src/render/text.ts +34 -6
  43. package/src/session-directory.ts +102 -0
  44. package/src/session-switch.ts +58 -0
  45. package/src/skills.ts +20 -7
  46. package/src/startup.ts +38 -20
  47. package/src/whale-glyph.ts +23 -23
  48. package/README.zh.md +0 -65
  49. package/src/pictures/1.png +0 -0
package/README.en.md ADDED
@@ -0,0 +1,217 @@
1
+ # DSH-Code
2
+
3
+ English | [中文](README.md)
4
+
5
+ <p align="center"><img src="docs/pictures/1.png" width="95%" alt="DSH-Code terminal with slash-command completion"></p>
6
+
7
+ <p align="center"><img alt="Typing SVG" src="https://readme-typing-svg.herokuapp.com?font=JetBrains+Mono&amp;weight=500&amp;size=22&amp;duration=4000&amp;pause=700&amp;color=4176E6&amp;center=true&amp;vCenter=true&amp;width=680&amp;lines=DeepSeek+Harness+Code;DSH+%E5%86%85%E6%A0%B8%E7%9A%84%E7%BB%88%E7%AB%AF%E7%BC%96%E7%A0%81%E7%95%8C%E9%9D%A2"></p>
8
+ <p align="center">
9
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img alt="DeepSeek Harness" src="https://img.shields.io/badge/DeepSeek-Harness-4176E6?style=for-the-badge&amp;logo=deepseek&amp;logoColor=white&amp;labelColor=1c1917"></a>
10
+ <a href="https://github.com/UNLINEARITY/dsh-code/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/UNLINEARITY/dsh-code?label=Stars&amp;style=for-the-badge&amp;logo=github&amp;logoColor=white&amp;color=4176E6&amp;labelColor=1c1917"></a>
11
+ <a href="https://www.npmjs.com/package/dsh-code"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-code?label=npm&amp;style=for-the-badge&amp;logo=npm&amp;color=cb3837&amp;labelColor=1c1917"></a>
12
+ <a href="https://github.com/UNLINEARITY/dsh-code/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/UNLINEARITY/dsh-code?label=License&amp;style=for-the-badge&amp;logo=opensourceinitiative&amp;color=4176E6&amp;labelColor=1c1917"></a>
13
+ </p>
14
+
15
+ **DSH-Code is a terminal coding interface for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`).** It runs as an out-of-tree bundle over the official `@deepseek-ai/dsh-base` and uses the same Agent, Session, tool, command, skill, permission, sandbox, compaction, and plugin services as the Harness Web UI.
16
+
17
+ DSH-Code does not implement a separate agent loop. It adds a coding-focused TUI to the DSH runtime, drawing on the session handling of [Codex CLI](https://github.com/openai/codex) and the terminal interaction patterns of [Claude Code](https://code.claude.com/docs/en/overview).
18
+
19
+ ---
20
+
21
+ ## 1. Overview
22
+
23
+ DeepSeek Harness treats models, tools, storage, policies, and interfaces as plugins registered through Cordis. Durable session events record the conversation and runtime state needed for replay.
24
+
25
+ DSH-Code keeps that structure and adds a terminal workflow for coding tasks.
26
+
27
+ | Reference | Used in DSH-Code |
28
+ | --- | --- |
29
+ | **DeepSeek Harness** | Plugin composition, scoped services, Agent Presets, durable sessions, tools, skills, policies, sandboxing, and delegation |
30
+ | **Codex CLI** | Session navigation, bounded overlays, history inspection, stable bottom layout, and resize handling |
31
+ | **Claude Code** | Slash-command discovery, thinking folds, approvals, questions, and turn steering |
32
+
33
+ The interface follows familiar terminal conventions, while runtime behavior continues to come from DSH services and configuration.
34
+
35
+ ## 2. Quick start
36
+
37
+ Requires Node `^22.19 || >=24`, the preview `dsh` CLI, and `DEEPSEEK_API_KEY`.
38
+
39
+ ```sh
40
+ npm install -g @deepseek-ai/dsh@next dsh-code
41
+ npm install -g pnpm
42
+ dsh plugin --profile cli add dsh-code
43
+ ```
44
+
45
+ Available launch commands:
46
+
47
+ ```sh
48
+ deepseek
49
+ dsh --profile cli
50
+ dsh-code
51
+ ```
52
+
53
+ `dsh --profile cli`, `deepseek`, and `dsh-code` are parallel launch commands. `deepseek` and `dsh-code` are global aliases for `dsh --profile cli`; all following arguments are forwarded, for example `deepseek --resume abc123`.
54
+
55
+ > DeepSeek Harness is currently a developer preview and may introduce compatibility-breaking changes. DSH-Code tracks that evolving plugin surface.
56
+
57
+ For installation, native-module, and plugin-loading issues, see the [troubleshooting guide](docs/problems.md).
58
+
59
+ ## 3. Terminal interaction
60
+
61
+ ### Basics
62
+
63
+ DSH-Code keeps one Ink owner for the lifetime of the process. `/new` and `/resume` replace the active Agent, not the terminal itself. If a switch is requested while the Agent is busy, it waits for the turn to finish; the newest request wins, and a failed target leaves the current session untouched.
64
+
65
+ Dynamic content is deliberately bounded. Streaming output, thinking, approvals, questions, `/help`, `/model`, `/mode`, `/resume`, `/plugin`, and Ctrl+O all share terminal-aware viewport rules. The composer remains immediately above the status line. After a resize, the screen is redrawn from the stored transcript once the new width settles.
66
+
67
+ Use `/mode` before the first turn to inspect or select the session's Agent Preset.
68
+
69
+ <p align="center"><img src="docs/pictures/2.png" width="95%" alt="Per-session Agent Preset picker"></p>
70
+
71
+ Use `/resume` to search persisted sessions without restarting the TUI.
72
+
73
+ <p align="center"><img src="docs/pictures/3.png" width="95%" alt="Searchable session resume picker"></p>
74
+
75
+ ### Common commands
76
+
77
+ ```sh
78
+ dsh --profile cli # start a fresh standard session
79
+ dsh --profile cli --mode code # start with an Agent Preset
80
+ dsh --profile cli --continue # resume the newest session for this directory
81
+ dsh --profile cli --resume abc123 # resume by id or unique prefix
82
+ dsh --profile cli --session my-id # start a fresh session with an explicit id
83
+ ```
84
+
85
+ Inside the TUI:
86
+
87
+ | Action | Purpose |
88
+ | --- | --- |
89
+ | `/new [preset]` | Create and enter another session without restarting the terminal |
90
+ | `/resume [id\|prefix]` | Search root sessions or all conversations; filter by cwd, order, and density |
91
+ | `/mode [preset]` | Inspect or select the blank session's Agent composition |
92
+ | `/model` | Switch among models advertised by the live LLM registry |
93
+ | `/plugin [query]` | Inspect loader entries, enabled state, module identity, and fiber phase |
94
+ | `/permission <name>` | Change the permission preset; Shift+Tab cycles presets |
95
+ | `/help` | Browse local commands, Harness commands, skills, and key bindings |
96
+ | `Ctrl+O` | Open the exclusive history detail view; switch entries and scroll all content |
97
+ | `Ctrl+R` | Fold or reveal model reasoning |
98
+ | `@` | Mention workspace files or bounded snapshots of persisted sessions |
99
+ | `Esc` / `Ctrl+C` | Close the topmost surface or interrupt the active turn |
100
+
101
+ ## 4. Features
102
+
103
+ ### 1. Agent and extensions
104
+
105
+ - Per-session Agent Presets for tools, prompt sections, skills, compaction, plan mode, and delegation
106
+ - Live slash-command and skill discovery from shared Harness registries
107
+ - Read-only Cordis loader diagnostics through `/plugin`
108
+ - Model routing through the live LLM registry, restored per persisted session
109
+ - Plans, goals, todos, permissions, sandbox state, subagents, and runtime steering
110
+
111
+ ### 2. Sessions and context
112
+
113
+ - `/new`, `/resume`, `--continue`, and explicit session identifiers without remounting Ink
114
+ - Codex-style searchable resume panel with root/all-conversation, cwd, order, and density filters
115
+ - Bare launches defer session creation until your first real input; quitting early leaves nothing behind
116
+ - Global input recall: Up/Down walks past prompts across sessions, and `/history` searches and fills the composer
117
+ - Lazy title snapshots and explicitly loaded, fully scrollable transcripts
118
+ - Read-only subagent conversation inspection and bounded `@` session references
119
+ - Markdown export, persistent titles, context occupancy, cache, token, TTFT, and timing metrics
120
+
121
+ ### 3. Approvals and interaction
122
+
123
+ - One-shot tool approval bar for sandbox escalation and hook `ask` decisions
124
+ - Structured `ask_user_question` and plan-review menus with multi-select and custom answers
125
+ - Turn steering at the next step boundary plus explicit interruption semantics
126
+ - Independent Agent mode, plan state, permission preset, goal, and sandbox indicators
127
+
128
+ ### 4. Terminal rendering
129
+
130
+ - Append-only settled transcript with bounded mutable streaming output
131
+ - Folded thinking, terminal Markdown, compact tool summaries, and full structured details
132
+ - Two-row status bar with mode and context on the second row, a blue context-occupancy meter, and all-blue accents
133
+ - Submissions while a turn runs appear immediately as ordinary prompt rows; Delete cancels the newest queued message, and busy states use the web StateDot chase animation
134
+ - Replies align with the input cursor, and the welcome wordmark is brighter
135
+ - Ctrl+O exclusive history inspection with entry navigation and complete vertical scrolling
136
+ - Width-safe CJK/control-character handling, compact-terminal degradation, and debounced resize replay
137
+ - Stable bottom order: content or panel → notice → composer → status
138
+
139
+ ## 5. How DSH-Code integrates with DSH
140
+
141
+ ### 1. Runtime composition
142
+
143
+ DSH-Code reads the live Harness registries instead of maintaining separate copies. Model adapters, tool providers, skill sources, commands, permission policies, persistence backends, sandboxes, and subagent providers can be added or replaced through DSH composition.
144
+
145
+ `/plugin` provides a read-only view of the current Cordis loader state.
146
+
147
+ ### 2. Session-scoped Agent Presets
148
+
149
+ The Host owns shared infrastructure—registries, persistence, session queries, permissions, and sandbox policy—while each session receives an isolated Agent scope composed from an **Agent Preset**:
150
+
151
+ - `standard` — the full general-purpose coding agent
152
+ - `code` — Code Mode / PTC-oriented multi-operation workflows
153
+ - `minimal` — only persistent shell access and `str_replace_editor`
154
+ - `cordis` — the full agent plus runtime inspection and preset-authoring guidance
155
+ - user presets — your own tools, prompt sections, skills, compaction, plan mode, and subagent behavior
156
+
157
+ Use `/mode` before the first turn or start directly with `--mode <preset>`. The selected preset is written to the session and restored on resume.
158
+
159
+ ### 3. Session history and replay
160
+
161
+ Prompts, streamed chunks, tool calls and results, model choices, plan state, permissions, titles, and preset selections are projected from durable Session events. Resume, export, history inspection, context accounting, and terminal replay use the same record.
162
+
163
+ React state is limited to temporary interface details such as the input draft, cursor, open panel, selection, and scroll position.
164
+
165
+ ```text
166
+ dsh profile
167
+ └─ Host plane: registries · persistence · query · permissions · sandbox
168
+ ├─ Agent session A + preset code
169
+ ├─ Agent session B + preset minimal
170
+ └─ DSH-Code TUI
171
+ durable events → pure projection → append-only transcript
172
+ └→ bounded panels → composer → status
173
+ ```
174
+
175
+ ## 6. Development
176
+
177
+ ```sh
178
+ pnpm install
179
+ pnpm test
180
+ pnpm typecheck
181
+ pnpm build
182
+ pnpm run gen:whale # regenerate src/whale-glyph.ts from the vendored logo path
183
+ ```
184
+
185
+ The whale glyph is generated from the DeepSeek FishLogo geometry vendored in `scripts/fish-logo.ts` (source: DeepSeek Harness, MIT).
186
+
187
+ ### 1. Source development installation
188
+
189
+ For a local checkout:
190
+
191
+ ```sh
192
+ dsh plugin --profile cli add file:C:/path/to/dsh-code
193
+ ```
194
+
195
+ GitHub installation is available for source development:
196
+
197
+ ```sh
198
+ dsh plugin --profile cli add github:unlinearity/dsh-code
199
+ ```
200
+
201
+ The Git package builds during installation. If pnpm asks for an `allowBuilds` entry, copy the complete entry it prints into `~/.dsh/profiles/cli/pnpm-workspace.yaml`, then run the command again. The key includes the Git URL and commit, so do not replace it with only `dsh-code`.
202
+
203
+ ### 2. References
204
+
205
+ - Runtime services, events, plugin scopes, and persistence follow **DeepSeek Harness**.
206
+ - Session navigation, popup sizing, scrollback, bottom-pane layout, and resize behavior refer to **Codex CLI**.
207
+ - Slash discovery, turn steering, thinking folds, approvals, and question flows refer to **Claude Code**.
208
+
209
+ DSH-Code is an independent MIT-licensed community project and is not affiliated with OpenAI or Anthropic.
210
+
211
+ Communities:
212
+ - [Linux DO](https://linux.do/): Learn AI, head to L Station!
213
+ - [Deepseek harness](https://www.deepseek.com/harness): DSH official website.
214
+
215
+ ## License
216
+
217
+ [MIT](LICENSE). The vendored FishLogo geometry is from DeepSeek Harness (MIT).
package/README.md CHANGED
@@ -1,67 +1,216 @@
1
- # dsh-code
2
-
3
- English | [中文](README.zh.md)
4
-
5
- A Claude-Code-style interactive terminal (TUI) bundle for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`), installed as an out-of-tree plugin bundle over the official `@deepseek-ai/dsh-base` — the same plugin ecosystem the official web surface composes, nothing forked.
6
-
7
- <p align='center'><img src='src\pictures\1.png' width=95%></p>
8
-
9
- ## What you get
10
-
11
- - DeepSeek-blue banner: the whale wordmark rasterized half-block from the exact FishLogo path, in a compact content-hugging header
12
- - Live transcript streamed from the durable session log: user prompts, streaming assistant text, compact tool-call and slash-command rows with running/done/error marks, todo snapshots
13
- - **Tool approval y/n bar**: when the agent asks for permission (a sandbox escalation, a hook's `ask` decision), an amber bar shows the reason plus the paired command line; `y` allows once, `n` rejects
14
- - **`/model` panel**: list every provider route the live `llm` registry advertises, switch the session's model for the next step; a resumed session restores its own last model
15
- - **Session resume**: `--resume <id|prefix>` continues a persisted session, `--continue` picks the newest one for the working directory; the full transcript replays from the log and appends to the same durable session
16
- - **Slash-command passthrough**: every command registered in the shared `ctx.commands` registry (the same surface the web composer dispatches) is executable from the terminal, with a completion menu on `/`; user-invocable skills join the same menu (marked `skill`), and an unknown `/name` falls through to the prompt so the host's skill injection picks it up
17
- - **Todo panel**: the live todo list renders inline with done/active/pending counts and three-state markers, cleared at each fresh turn (mirroring the web TodoPanel)
18
- - **Thinking lines**: model reasoning renders as a Claude-Code-style `✻` fold — collapsed to a dim marker with a character count, expanded to dim-italic text, live-streamed while the model thinks; Ctrl+R toggles globally
19
- - **Terminal markdown**: assistant replies render through a pure GFM-subset renderer (headings, fenced/inline code, emphasis, lists, quotes, links) wrapped to the terminal width; streaming stays plain until the message settles
20
- - **Ctrl+O history inspector**: browse one retained transcript entry at a time without replacing the composer or status footer; ←/→ switches entries, ↑/↓ and PageUp/PageDown scroll the complete content, and `g`/`G` jump to either end
21
- - **Structured tool details**: persisted edit/write diffs, numbered read windows, web-search sources, fetch summaries, and bounded raw output remain compact in the transcript and expand into their full presentation inside Ctrl+O
22
- - **ask_user_question bar**: the model's questions appear as an option menu (↑/↓, space multi-select, `c` custom answer, Esc interrupts); plan reviews (`exit_plan_mode`) arrive through the same bar with the approve option highlighted
23
- - **@ mentions**: `@` completion over workspace files and persisted sessions; session mentions expand into bounded read-only snapshots injected as sourced context before the prompt
24
- - **Plan mode and permissions**: `⧉ plan` and `⛨ <preset>` badges in the status line; `/permission <name>` switches the session preset, Shift+Tab cycles through them (the registry's own `/plan` command enables plan mode)
25
- - **Local terminal workflows**: `/help` opens the complete key/command/skill surface, `/export` writes the folded transcript to Markdown, `/title` pins a session title, Ctrl+K deletes to end of line, Ctrl+L redraws the terminal, and bare workspace paths participate in Tab completion
26
- - Input with history (↑/↓), cursor editing (←/→, Ctrl+A/E/U), Tab completion for slash commands, skills, and @ mentions; submitting while the agent runs steers the live turn (consumed at the next step boundary), `Esc` or Ctrl+C interrupts it, Ctrl+C on an empty idle input exits, Ctrl+D refuses to exit mid-turn
27
- - A blended status line: Claude-Code-style identity facts (model, working directory, git branch, title/session, plan, permission preset, goal and sandbox overrides) beside the web composer's figures (turns/steps, llm and tool wall time, TTFT, decode tok/s, context occupancy, cache hit, token totals)
28
- - Bounded live rendering: streaming output, Ctrl+O, `/help`, `/model`, approvals, and question/plan-review panels stay within terminal-aware viewports; the composer remains directly above its status footer, and a debounced resize reflows the screen once at the settled width
29
-
30
- ## Install
31
-
32
- Requires Node `^22.19 || >=24` and the `dsh` CLI (`npm i -g @deepseek-ai/dsh@next`).
33
-
34
- ```sh
35
- dsh plugin --profile cli add dsh-code # from npm, once published
36
- dsh plugin --profile cli add github:unlinearity/dsh-code # track this repo
37
- dsh plugin --profile cli add file:C:/path/to/dsh-code # local checkout
38
- ```
39
-
40
- Then:
41
-
42
- ```sh
43
- dsh --profile cli # fresh session
44
- dsh --profile cli --continue # resume the newest session in this directory
45
- dsh --profile cli --resume abc123 # resume by session id or unique prefix
46
- dsh --profile cli --session my-id # fresh session under an explicit id
47
- ```
48
-
49
- Set `DEEPSEEK_API_KEY` in your environment (or a `.env` in the launch directory or `$DSH_HOME`).
50
-
51
- Git-hosted plugins build on install via their install scripts, which pnpm blocks until allowed: if an `add` fails, append the key it prints under `allowBuilds` in `~/.dsh/profiles/cli/pnpm-workspace.yaml` and re-run.
52
-
53
- ## Develop
54
-
55
- ```sh
56
- pnpm install
57
- pnpm test # vitest unit tests
58
- pnpm typecheck
59
- pnpm build # tsdown bundles lib/*.mjs, tsc emits lib/types
60
- pnpm run gen:whale # regenerate src/whale-glyph.ts from the vendored logo path
61
- ```
62
-
63
- The whale glyph is generated from the DeepSeek fish-logo path vendored in `scripts/fish-logo.ts` (source: [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness), MIT).
64
-
65
- ## License
66
-
67
- [MIT](LICENSE). The vendored fish-logo geometry is from DeepSeek Harness (MIT).
1
+ # DSH-Code
2
+
3
+ [English](README.en.md) | 中文
4
+
5
+ <p align="center"><img src="docs/pictures/1.png" width="95%" alt="带斜杠命令补全的 DSH-Code 终端"></p>
6
+
7
+ <p align="center"><img alt="Typing SVG" src="https://readme-typing-svg.herokuapp.com?font=JetBrains+Mono&amp;weight=500&amp;size=22&amp;duration=4000&amp;pause=700&amp;color=4176E6&amp;center=true&amp;vCenter=true&amp;width=680&amp;lines=DeepSeek+Harness+Code;DSH+%E5%86%85%E6%A0%B8%E7%9A%84%E7%BB%88%E7%AB%AF%E7%BC%96%E7%A0%81%E7%95%8C%E9%9D%A2"></p>
8
+ <p align="center">
9
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img alt="DeepSeek Harness" src="https://img.shields.io/badge/DeepSeek-Harness-4176E6?style=for-the-badge&amp;logo=deepseek&amp;logoColor=white&amp;labelColor=1c1917"></a>
10
+ <a href="https://github.com/UNLINEARITY/dsh-code/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/UNLINEARITY/dsh-code?label=Stars&amp;style=for-the-badge&amp;logo=github&amp;logoColor=white&amp;color=4176E6&amp;labelColor=1c1917"></a>
11
+ <a href="https://www.npmjs.com/package/dsh-code"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-code?label=npm&amp;style=for-the-badge&amp;logo=npm&amp;color=cb3837&amp;labelColor=1c1917"></a>
12
+ <a href="https://github.com/UNLINEARITY/dsh-code/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/UNLINEARITY/dsh-code?label=License&amp;style=for-the-badge&amp;logo=opensourceinitiative&amp;color=4176E6&amp;labelColor=1c1917"></a>
13
+ </p>
14
+
15
+ **DSH-Code [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)的终端编码界面。** 它以树外 bundle 的形式组合在官方 `@deepseek-ai/dsh-base` 之上,与 Harness Web UI 使用同一套 Agent、Session、工具、命令、技能、权限、sandbox、上下文压缩与插件服务。
16
+
17
+ DSH-Code 没有另外实现一套 Agent loop,而是在 DSH 运行时上增加面向编码工作的 TUI。会话处理参考 [Codex CLI](https://github.com/openai/codex),终端交互参考 [Claude Code](https://code.claude.com/docs/en/overview)
18
+
19
+ ---
20
+
21
+ ## 一、项目概览
22
+
23
+ DeepSeek Harness 将模型、工具、存储、策略和界面作为插件,通过 Cordis 注册。持久化会话事件记录恢复对话与运行状态所需的信息。
24
+
25
+ DSH-Code 保留这套结构,并补充适合编码任务的终端工作流。
26
+
27
+ | 参考项目 | DSH-Code 使用的机制 |
28
+ | --- | --- |
29
+ | **DeepSeek Harness** | 插件组合、作用域服务、Agent Preset、持久会话、工具、技能、策略、sandbox 与委派 |
30
+ | **Codex CLI** | 会话导航、有界浮层、历史检查、稳定底部布局与缩放处理 |
31
+ | **Claude Code** | 斜杠命令发现、思考折叠、审批、提问与 turn steering |
32
+
33
+ 界面采用开发者熟悉的终端操作方式,运行行为仍由 DSH 服务和配置决定。
34
+
35
+ ## 二、快速开始
36
+
37
+ 需要 Node `^22.19 || >=24`、预览版 `dsh` CLI,以及 `DEEPSEEK_API_KEY`。
38
+
39
+ ```sh
40
+ npm install -g @deepseek-ai/dsh@next dsh-code
41
+ npm install -g pnpm
42
+ dsh plugin --profile cli add dsh-code
43
+ ```
44
+
45
+ 可用的启动指令:
46
+ ```sh
47
+ deepseek
48
+ dsh --profile cli
49
+ dsh-code
50
+ ```
51
+
52
+ `dsh --profile cli`、`deepseek` 与 `dsh-code` 是并列的启动命令。`deepseek` 与 `dsh-code` 都是 `dsh --profile cli` 的全局别名,后续参数会原样转发,例如 `deepseek --resume abc123`。
53
+
54
+ > DeepSeek Harness 目前仍处于 developer preview,可能出现破坏兼容性的变化;DSH-Code 会持续跟随其插件接口演进。
55
+
56
+ 安装、原生模块和插件加载问题,请查看[常见问题与排障](docs/problems.md)。
57
+
58
+ ## 三、终端交互
59
+
60
+ ### 基础
61
+
62
+ DSH-Code 在整个进程中只保留一个 Ink owner。`/new` 和 `/resume` 替换的是活动 Agent,而不是终端本身。若 Agent 忙碌,切换会等待当前 turn 自然结束;最新请求优先,目标加载失败也不会破坏当前会话。
63
+
64
+ 所有动态内容都受到明确的视口约束。流式输出、思考过程、审批、问题、`/help`、`/model`、`/mode`、`/resume`、`/plugin` 与 Ctrl+O 使用统一的终端预算。输入框始终紧贴状态栏上方;终端宽度稳定后,界面会根据保存的会话记录重新绘制一次。
65
+
66
+ 在第一次 turn 之前使用 `/mode`,查看或选择当前会话的 Agent Preset。
67
+
68
+ <p align="center"><img src="docs/pictures/2.png" width="95%" alt="每会话 Agent Preset 选择器"></p>
69
+
70
+ 使用 `/resume` 搜索持久会话,无需重新启动 TUI。
71
+
72
+ <p align="center"><img src="docs/pictures/3.png" width="95%" alt="可搜索的会话恢复选择器"></p>
73
+
74
+ ### 常用命令
75
+
76
+ ```sh
77
+ dsh --profile cli # 新建 standard 会话
78
+ dsh --profile cli --mode code # 使用 Agent Preset 启动
79
+ dsh --profile cli --continue # 恢复当前目录最新会话
80
+ dsh --profile cli --resume abc123 # 按 id 或唯一前缀恢复持久会话
81
+ dsh --profile cli --session my-id # 使用指定 id 新建会话
82
+ ```
83
+
84
+ 进入 TUI 后:
85
+
86
+ | 操作 | 用途 |
87
+ | --- | --- |
88
+ | `/new [preset]` | 不重启终端,创建并进入另一个会话 |
89
+ | `/resume [id\|前缀]` | 搜索根会话或全部对话,并按 cwd、排序和密度筛选 |
90
+ | `/mode [preset]` | 检查或选择空会话的 Agent 组合 |
91
+ | `/model` | 在实时 LLM 注册表提供的模型间切换 |
92
+ | `/plugin [query]` | 检查 loader 条目、启用状态、模块身份和 fiber 阶段 |
93
+ | `/permission <name>` | 切换权限预设;Shift+Tab 可循环切换 |
94
+ | `/help` | 浏览本地命令、Harness 命令、技能和快捷键 |
95
+ | `Ctrl+O` | 打开独占历史详情视图,切换条目并滚动完整内容 |
96
+ | `Ctrl+R` | 折叠或展开模型思考过程 |
97
+ | `@` | 引用工作区文件或持久会话的有界快照 |
98
+ | `Esc` / `Ctrl+C` | 关闭最上层界面或中断当前 turn |
99
+
100
+ ## 四、功能
101
+
102
+ ### 1. Agent 与扩展
103
+
104
+ - 每会话 Agent Preset:组合工具、提示词、技能、上下文压缩、plan mode 与委派能力
105
+ - 从共享 Harness 注册表实时发现斜杠命令和用户技能
106
+ - 通过 `/plugin` 只读诊断 Cordis loader
107
+ - 从实时 LLM 注册表路由模型,并按持久会话恢复选择
108
+ - 支持 plan、goal、todo、权限、sandbox、subagent 与运行中 steering
109
+
110
+ ### 2. 会话与上下文
111
+
112
+ - `/new`、`/resume`、`--continue` 与显式 session id,且无需重新挂载 Ink
113
+ - Codex 风格可搜索恢复面板,支持根/全部对话、cwd、排序和密度筛选
114
+ - 裸启动延迟到首次真实输入才创建会话,未输入即退出零残留
115
+ - 全局输入历史:Up/Down 跨会话召回,`/history` 搜索面板回填输入框
116
+ - 标题快照按需折叠,完整转录仅在显式请求时加载并支持全量滚动
117
+ - subagent 对话只读检查,以及通过 `@` 注入有界会话引用
118
+ - Markdown 导出、持久标题、上下文占用、缓存、token、TTFT 与耗时指标
119
+
120
+ ### 3. 审批与交互
121
+
122
+ - sandbox 升级与 hook `ask` 决策的一次性工具审批条
123
+ - 结构化 `ask_user_question` 与 plan review 菜单,支持多选和自定义答案
124
+ - 在下一个 step 边界进行 turn steering,并提供明确的中断语义
125
+ - Agent mode、plan、权限 preset、goal 与 sandbox 状态相互独立
126
+
127
+ ### 4. 终端渲染
128
+
129
+ - 已落定历史只追加,流式可变区域严格有界
130
+ - 思考折叠、终端 Markdown、紧凑工具摘要与完整结构化详情
131
+ - 双行状态栏:mode 与 context 在第二行,context 为蓝色进度条,全蓝强调
132
+ - 运行中提交即时显示为普通提示词行,Delete 取消排队消息,busy 使用 web StateDot 八点追逐动画
133
+ - 回复与输入框光标对齐,欢迎头字标提亮
134
+ - Ctrl+O 独占历史检查,支持切换条目与完整纵向滚动
135
+ - CJK/控制字符宽度安全、短终端主动降级、缩放防抖重放
136
+ - 固定底部顺序:内容或面板 → notice → 输入框 → 状态栏
137
+
138
+ ## 五、DSH-Code 如何接入 DSH
139
+
140
+ ### 1. 运行时组合
141
+
142
+ DSH-Code 读取 Harness 的实时注册表,不在本地维护另一套副本。模型适配器、工具 provider、技能来源、命令、权限策略、持久化后端、sandbox 和 subagent provider 都可以通过 DSH composition 添加或替换。
143
+
144
+ `/plugin` 提供当前 Cordis loader 状态的只读视图。
145
+
146
+ ### 2. 会话级 Agent Preset
147
+
148
+ Host 持有共享基础设施——注册表、持久化、会话查询、权限和 sandbox 策略;每个会话则获得一个隔离的 Agent scope,并由 **Agent Preset** 进行组合:
149
+
150
+ - `standard`——功能完整的通用编码 Agent
151
+ - `code`——面向 Code Mode / PTC 的多操作工作流
152
+ - `minimal`——只保留持久 shell 和 `str_replace_editor`
153
+ - `cordis`——完整 Agent,加上运行时检查与 Preset 编写指导
154
+ - 用户预设——自行定义工具、提示词段落、技能、上下文压缩、plan mode 与 subagent 行为
155
+
156
+ 在第一次 turn 之前使用 `/mode`,或通过 `--mode <preset>` 直接启动。选中的 preset 会写入会话,并在恢复时还原。
157
+
158
+ ### 3. 会话记录与恢复
159
+
160
+ 提示词、流式 chunk、工具调用与结果、模型选择、plan 状态、权限、标题和 preset 选择都由持久 Session 事件投影得到。会话恢复、导出、历史检查、上下文统计和终端重放使用同一份记录。
161
+
162
+ React state 只保存输入草稿、光标、当前面板、选中项和滚动位置等临时界面状态。
163
+
164
+ ```text
165
+ dsh profile
166
+ └─ Host plane:注册表 · 持久化 · 查询 · 权限 · sandbox
167
+ ├─ Agent 会话 A + preset code
168
+ ├─ Agent 会话 B + preset minimal
169
+ └─ DSH-Code TUI
170
+ 持久事件 → 纯投影 → 只追加的历史转录
171
+ └→ 有界面板 → 输入框 → 状态栏
172
+ ```
173
+
174
+ ## 六、开发
175
+
176
+ ```sh
177
+ pnpm install
178
+ pnpm test
179
+ pnpm typecheck
180
+ pnpm build
181
+ pnpm run gen:whale # 从 vendored Logo 路径重新生成 src/whale-glyph.ts
182
+ ```
183
+
184
+ 鲸鱼字形由 `scripts/fish-logo.ts` 中 vendored 的 DeepSeek FishLogo 几何数据生成(来源:DeepSeek Harness,MIT)。
185
+
186
+ ### 1. 源码开发安装
187
+
188
+ 本地 checkout 可使用:
189
+
190
+ ```sh
191
+ dsh plugin --profile cli add file:C:/path/to/dsh-code
192
+ ```
193
+
194
+ GitHub 安装可用于源码开发:
195
+
196
+ ```sh
197
+ dsh plugin --profile cli add github:unlinearity/dsh-code
198
+ ```
199
+
200
+ Git 包会在安装阶段构建。若 pnpm 要求添加 `allowBuilds`,请把它输出的完整条目复制到 `~/.dsh/profiles/cli/pnpm-workspace.yaml`,再重新执行命令。该键包含 Git URL 与 commit,不能只写 `dsh-code`。
201
+
202
+ ### 2. 参考
203
+
204
+ - 运行时服务、事件、插件作用域和持久化模型遵循 **DeepSeek Harness**。
205
+ - 会话导航、浮层尺寸、scrollback、底部布局与缩放处理参考 **Codex CLI**。
206
+ - 斜杠发现、turn steering、思考折叠、审批和提问流程参考 **Claude Code**。
207
+
208
+ DSH-Code 是独立的 MIT 社区项目,与 OpenAI 或 Anthropic 无隶属关系。
209
+
210
+ 社区:
211
+ - [Linux DO](https://linux.do/):学 AI,上 L 站!
212
+ - [Deepseek harness](https://www.deepseek.com/harness): DSH 官方网站
213
+
214
+ ## 许可
215
+
216
+ [MIT](LICENSE)。vendored FishLogo 几何数据来自 DeepSeek Harness(MIT)。
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'node:child_process'
4
+ import { existsSync, realpathSync } from 'node:fs'
5
+ import { createRequire } from 'node:module'
6
+ import { join, resolve } from 'node:path'
7
+ import { fileURLToPath, pathToFileURL } from 'node:url'
8
+
9
+ const packageRequire = createRequire(import.meta.url)
10
+
11
+ /** Arguments required to boot DSH-Code's conventional profile. */
12
+ export const profileArgs = (args = []) => ['--profile', 'cli', ...args]
13
+
14
+ /** Npm global-prefix roots that may contain DSH when this launcher is globally linked to a checkout. */
15
+ export function globalDshRoots() {
16
+ return [...new Set([
17
+ process.env.npm_config_prefix,
18
+ process.env.APPDATA === undefined ? undefined : join(process.env.APPDATA, 'npm'),
19
+ process.env.PREFIX,
20
+ ].filter(Boolean))]
21
+ }
22
+
23
+ /** Resolve the DSH entrypoint without passing user arguments through a Windows shell. */
24
+ export function dshCommand(args, {
25
+ platform = process.platform,
26
+ moduleUrl = import.meta.url,
27
+ fileExists = existsSync,
28
+ roots = globalDshRoots(),
29
+ resolvePackage = packageRequire.resolve,
30
+ } = {}) {
31
+ if (platform !== 'win32') return { command: 'dsh', args: profileArgs(args) }
32
+ const adjacentEntrypoint = fileURLToPath(new URL('../../@deepseek-ai/dsh/lib/bin.js', moduleUrl))
33
+ if (fileExists(adjacentEntrypoint)) return { command: process.execPath, args: [adjacentEntrypoint, ...profileArgs(args)] }
34
+ for (const root of roots) {
35
+ try {
36
+ const entrypoint = resolvePackage('@deepseek-ai/dsh/lib/bin.js', { paths: [root] })
37
+ return { command: process.execPath, args: [entrypoint, ...profileArgs(args)] }
38
+ } catch {
39
+ // The next configured global prefix may own DSH instead.
40
+ }
41
+ }
42
+ return undefined
43
+ }
44
+
45
+ /** Launch the installed DSH CLI while preserving its exit status and stdio. */
46
+ export function launchDsh(args = process.argv.slice(2), spawnProcess = spawn, resolveCommand = dshCommand) {
47
+ const command = resolveCommand(args)
48
+ if (command === undefined) {
49
+ console.error('dsh-code: @deepseek-ai/dsh must be installed globally beside dsh-code; run: npm install -g @deepseek-ai/dsh@next dsh-code')
50
+ process.exitCode = 1
51
+ return undefined
52
+ }
53
+ const child = spawnProcess(command.command, command.args, {
54
+ stdio: 'inherit',
55
+ })
56
+
57
+ child.once('error', error => {
58
+ console.error(`dsh-code: could not start dsh: ${error.message}`)
59
+ process.exitCode = 1
60
+ })
61
+ child.once('exit', (code, signal) => {
62
+ process.exitCode = code ?? (signal === null ? 0 : 1)
63
+ })
64
+ return child
65
+ }
66
+
67
+ const entrypoint = process.argv[1]
68
+ if (entrypoint !== undefined && pathToFileURL(realpathSync(resolve(entrypoint))).href === import.meta.url) {
69
+ launchDsh()
70
+ }