@este.systems/dsc 0.2.2 → 0.4.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,166 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.4.0] - 2026-05-17
11
+
12
+ ### Added
13
+ - `/search-key [provider] [key]` — list/save search-provider API keys (Brave, Tavily) and print signup URLs so the user knows where to get one. Mirrors `/api-key`'s shape.
14
+ - `/api-key` and the welcome panel now point at https://platform.deepseek.com/api_keys when no DeepSeek key is configured.
15
+ - System prompt + bash tool description teach the model about Windows package managers (winget / scoop) and Node version managers (nvm-windows / fnm). Stops the model from suggesting `apt install` on Windows.
16
+
17
+ ### Removed
18
+ - The readline REPL is gone. The TUI has been the default entry for five releases; the `--repl` opt-out and its supporting code (`src/index.ts`, the DECSTBM `StatusBar` in `src/ui.ts`, the streaming markdown→ANSI renderer in `src/markdown.ts`) are deleted. One-shot mode (`dsc "prompt"`) is unchanged — the TUI's stdout adapter still handles it.
19
+
20
+ ### Changed
21
+ - `bin/dsc.mjs` always routes to `src/tui.tsx` now; the `--repl` branch is gone.
22
+ - TUI's arg parser absorbs the flags the REPL used to handle: `--model` / `-m <name>` and `--resume [id]`. Unknown flags now error with a clear message instead of being silently ignored.
23
+ - One-shot output is plain text — the agent no longer routes its stdout writes through the ANSI markdown renderer. Cleaner pipes; fewer escape codes in scripted use.
24
+
25
+ ## [0.3.0] - 2026-05-17
26
+
27
+ ### Added
28
+ - `/api-key [key]` — save the DeepSeek key to the config file, or report where the current key is coming from (env / file / unset). Boot no longer hard-exits when no key is configured; a one-line in-app prompt points at the slash command.
29
+ - `/update` — force-check npm for a newer release and install it; the TUI also runs a cached once-a-day check on startup and surfaces a passive "X available" notice when behind.
30
+ - `/copy` — copy the last assistant message to the OS clipboard (pbcopy / clip / wl-copy / xclip / xsel).
31
+ - `/export [path]` — write the current session JSON to a chosen path for transfer between machines.
32
+ - `/import <path> [--keep-cwd]` — load a session JSON; rebinds cwd to the current directory by default so auto-resume picks it up. Collisions get a fresh id (no overwrites).
33
+ - One-time welcome panel on first launch, stamped via `$XDG_STATE_HOME/dsc/welcomed` so it doesn't repeat.
34
+ - Inline ghost-text suggest as you type a `/slash` command (dim suffix of the longest match).
35
+ - Truncation marker on long tool output — `(N more chars / M more lines, full output sent to model)` — so the user knows the gap is rendering, not data loss.
36
+ - Approval shortcut `a` (always) auto-approves future calls of the same tool for this session; cleared by `/clear`.
37
+
38
+ ### Changed
39
+ - Approval dialog renders the diff / command / URL preview **inline** in the yellow box (24-line cap, structural per-line coloring, "(N more)" tail). No more raw ANSI bleed above the ink frame.
40
+ - Slash commands echo into history as user messages so their output is no longer orphaned in scrollback.
41
+
42
+ ## [0.2.5] - 2026-05-17
43
+
44
+ ### Fixed
45
+ - EINVAL when the build / package scripts spawn `npm.cmd` on Windows.
46
+
47
+ ## [0.2.4] - 2026-05-17
48
+
49
+ ### Changed
50
+ - Swapped the busy spinner from Braille to quadrant blocks — Windows console fonts can't render Braille consistently.
51
+
52
+ ## [0.2.3] - 2026-05-17
53
+
54
+ ### Fixed
55
+ - Kill the entire cmd.exe process tree on abort / timeout / grace so PowerShell grandchildren don't leak and keep the agent stuck.
56
+
57
+ ## [0.2.2] - 2026-05-14
58
+
59
+ ### Fixed
60
+ - Windows bash hang: grandchildren inheriting stdio kept `child.on("close")` from firing, leaving the tool Promise pending forever. Now spawns with `stdio:["ignore","pipe","pipe"]` + `windowsHide:true`, listens on both `exit` and `close`, and force-settles 500 ms after `exit` if `close` hasn't arrived.
61
+
62
+ ### Added
63
+ - Genuinely empty assistant turns (no content, no reasoning, no tool calls) now show a `(model returned no content)` marker instead of disappearing silently.
64
+
65
+ ## [0.2.1] - 2026-05-14
66
+
67
+ ### Added
68
+ - Animated Braille spinner in the status bar while busy; `/compact` now flips `busy` so the spinner shows during compaction too.
69
+
70
+ ### Changed
71
+ - Status-bar task labels are pretty-printed per tool (`bash: npm test`, `edit_file: src/foo.ts`) instead of dumping the raw JSON arguments.
72
+
73
+ ### Fixed
74
+ - Status bar no longer renders one column past the terminal width (off-by-one in the padding math).
75
+
76
+ ## [0.2.0] - 2026-05-13
77
+
78
+ ### Added
79
+ - Brand-new TUI built on [ink](https://github.com/vadimdemedes/ink) as the default entry. Prompt + status bar pin to the bottom; finalized turns live in normal scrollback so they stay selectable. The readline REPL stays available behind `--repl`.
80
+ - Custom prompt input with cursor movement, Emacs-style line-edit shortcuts (Ctrl+A/E/U/K/W), Up/Down history shared with the REPL, TAB completion, paste tolerance.
81
+ - Agent task list — three new tools (`task_create`, `task_update`, `task_list`) backed by an in-memory list; the TUI renders ○ pending / ◐ in-progress / ● completed bullets above the prompt.
82
+ - Visible type-ahead queue (dim, above the prompt) instead of just a `queued:N` count in the status bar.
83
+ - Reasoning rendered as a dedicated "thinking" block (dim italic, indented) instead of dangling under the assistant header.
84
+ - Native one-shot mode in the TUI: `dsc "prompt"` runs the agent against stdout and exits without rendering ink.
85
+ - TUI slash commands: `/help`, `/clear`, `/list`, `/resume`, `/save`, `/rename`, `/model`, `/yolo`, `/reasoning`, `/cost`, `/version`, `/lang`, `/auto-continue`, `/queue`, `/audit`, `/transcript`, `/compact`, `/edit`, `/exit`.
86
+ - ESC aborts the in-flight turn; Ctrl+D / Ctrl+C exit semantics.
87
+ - Multiline input via backslash continuation, with the accumulated buffer rendered dim above the prompt; ESC clears it.
88
+ - `/edit` unmounts ink, opens `$EDITOR`, and remounts.
89
+ - Markdown rendering (headings, code fences, lists, blockquotes, tables, inline bold / italic / code / links) applied to finalized assistant messages.
90
+
91
+ ### Changed
92
+ - System prompt no longer embeds the per-turn status line (cost / tokens / session timer). That string changed every turn and broke DeepSeek's prefix cache for the *entire* message history — every prior message got re-billed as a miss. Removing it restores cache hits across long sessions.
93
+ - User prompts in history render with a subtle bright-black background and no role label.
94
+
95
+ ## [0.1.7] - 2026-05-12
96
+
97
+ ### Added
98
+ - `--version` / `-v` CLI flag and `/version` slash command — prints dsc version + Node + platform/arch.
99
+
100
+ ## [0.1.6] - 2026-05-12
101
+
102
+ ### Changed
103
+ - Strengthened the bash tool description with explicit POSIX↔Windows command pairs (ls↔dir, cat↔type, rm↔del, mv↔move) and a system-prompt rule "Never refuse to run shell commands because of the platform."
104
+
105
+ ## [0.1.5] - 2026-05-12
106
+
107
+ ### Fixed
108
+ - Bash and `which` on Windows. `spawn("/bin/sh", ...)` was broken — switched to `spawn(command, [], { shell: true })`. Use `where` on Windows, `which` elsewhere.
109
+
110
+ ## [0.1.4] - 2026-05-12
111
+
112
+ ### Fixed
113
+ - TDZ crash on startup: hoisted the `promptQueue` declaration before `currentStatusLine` references it.
114
+
115
+ ## [0.1.3] - 2026-05-12
116
+
117
+ ### Fixed
118
+ - Windows-only `ERR_UNSUPPORTED_ESM_URL_SCHEME` in `bin/dsc.mjs`. `await import("C:\\...")` parses `C:` as a URL scheme; use `pathToFileURL()` instead.
119
+
120
+ ## [0.1.2] - 2026-05-12
121
+
122
+ ### Added
123
+ - `/auto-continue [N|off]` — when the agent hits `MAX_TOOL_DEPTH` without converging, auto-grant up to N more 24-call budgets instead of stopping. Initial value comes from `DSC_AUTO_CONTINUE`.
124
+ - `/lang [name|off]` — force the model to reply exclusively in a named language; persisted per session.
125
+ - Type-ahead prompt queue — captured lines pile up while a turn is running and drain in order afterwards.
126
+ - `deepseek.json.example` settings template.
127
+
128
+ ## [0.1.1] - 2026-05-11
129
+
130
+ ### Changed
131
+ - README polish: npm / license / node version badges; per-platform install steps for Linux / macOS / Windows.
132
+
133
+ ## [0.1.0] - 2026-05-10
134
+
135
+ Initial public release.
136
+
137
+ ### Added
138
+ - Readline REPL with streaming responses from DeepSeek's API.
139
+ - Tool surface: `bash`, `read_file`, `write_file`, `edit_file`, `grep`, `glob`, `web_fetch`, `web_search` (Brave / Tavily / DuckDuckGo).
140
+ - Per-cwd session persistence under `~/.local/share/dsc/sessions/` keyed by id, with auto-resume by directory.
141
+ - JSONL audit log of every tool call under `~/.local/state/dsc/audit.log`.
142
+ - Up-arrow prompt history shared across sessions under `~/.local/state/dsc/history`.
143
+ - Slash commands: `/clear`, `/cost`, `/model`, `/yolo`, `/reasoning`, `/list`, `/resume`, `/save`, `/rename`, `/audit`, `/transcript`, `/compact`, `/edit`, `/exit`.
144
+ - `/compact` summarizes older turns into a synthetic block kept in the system prompt; the original messages move to `archivedMessages` so `/transcript` still shows them.
145
+ - ESC interrupts the running turn.
146
+ - Backslash continuation for multi-line input.
147
+ - DECSTBM-pinned status bar.
148
+ - Cross-platform packaging (`npm pack` + per-OS installer scripts).
149
+
150
+ [Unreleased]: https://github.com/EsteSystems/dsc/compare/v0.4.0...HEAD
151
+ [0.4.0]: https://github.com/EsteSystems/dsc/compare/v0.3.0...v0.4.0
152
+ [0.3.0]: https://github.com/EsteSystems/dsc/compare/v0.2.5...v0.3.0
153
+ [0.2.5]: https://github.com/EsteSystems/dsc/compare/v0.2.4...v0.2.5
154
+ [0.2.4]: https://github.com/EsteSystems/dsc/compare/v0.2.3...v0.2.4
155
+ [0.2.3]: https://github.com/EsteSystems/dsc/compare/v0.2.2...v0.2.3
156
+ [0.2.2]: https://github.com/EsteSystems/dsc/compare/v0.2.1...v0.2.2
157
+ [0.2.1]: https://github.com/EsteSystems/dsc/compare/v0.2.0...v0.2.1
158
+ [0.2.0]: https://github.com/EsteSystems/dsc/compare/v0.1.7...v0.2.0
159
+ [0.1.7]: https://github.com/EsteSystems/dsc/compare/v0.1.6...v0.1.7
160
+ [0.1.6]: https://github.com/EsteSystems/dsc/compare/v0.1.5...v0.1.6
161
+ [0.1.5]: https://github.com/EsteSystems/dsc/compare/v0.1.4...v0.1.5
162
+ [0.1.4]: https://github.com/EsteSystems/dsc/compare/v0.1.3...v0.1.4
163
+ [0.1.3]: https://github.com/EsteSystems/dsc/compare/v0.1.2...v0.1.3
164
+ [0.1.2]: https://github.com/EsteSystems/dsc/compare/v0.1.1...v0.1.2
165
+ [0.1.1]: https://github.com/EsteSystems/dsc/compare/v0.1.0...v0.1.1
166
+ [0.1.0]: https://github.com/EsteSystems/dsc/releases/tag/v0.1.0
package/README.md CHANGED
@@ -8,11 +8,11 @@
8
8
  A CLI coding agent for [DeepSeek](https://api-docs.deepseek.com/).
9
9
  Streams responses, calls tools (`bash`, `read_file`, `write_file`, `edit_file`,
10
10
  `grep`, `glob`, `web_fetch`, `web_search`, `task_*`), keeps per-cwd sessions,
11
- and runs as a [ink](https://github.com/vadimdemedes/ink)-based TUI by default
12
- — prompt + status bar pinned at the bottom, finalized turns kept in normal
13
- scrollback so they stay selectable and copy/paste-able. A readline REPL is
14
- still available via `--repl` for scripted one-shots or terminals that don't
15
- like ink.
11
+ and runs as a [ink](https://github.com/vadimdemedes/ink)-based TUI prompt +
12
+ status bar pinned at the bottom, finalized turns kept in normal scrollback so
13
+ they stay selectable and copy/paste-able. One-shot mode (`dsc "prompt"`) runs
14
+ the agent against stdout and exits without rendering ink, so it pipes cleanly
15
+ into scripts.
16
16
 
17
17
  ## Install
18
18
 
@@ -44,6 +44,13 @@ be hacking on the source.
44
44
  npm install -g @este.systems/dsc
45
45
  ```
46
46
 
47
+ After install, run `dsc`. On a fresh machine the TUI greets you with a
48
+ one-time welcome card and points you at `/api-key sk-...` for the
49
+ initial key save. To upgrade later, run `/update` inside the TUI (or
50
+ `npm install -g @este.systems/dsc@latest` from outside) — dsc also
51
+ checks npm in the background once a day and surfaces a one-line notice
52
+ when a newer version is published.
53
+
47
54
  **(B) From a local tarball** *(works on all platforms with the same npm)*:
48
55
 
49
56
  ```sh
@@ -94,8 +101,21 @@ to your `PATH` and reopen the terminal.
94
101
 
95
102
  ## API key
96
103
 
97
- A ready-to-edit template lives at the repo root: **[`deepseek.json.example`](deepseek.json.example)**.
98
- Copy it to the config path below and replace the placeholder values:
104
+ **Easiest path** launch dsc and use the slash command:
105
+
106
+ ```
107
+ > /api-key sk-...
108
+ ```
109
+
110
+ That writes `~/.config/deepseek/deepseek.json` with `0600` perms,
111
+ preserving any other fields (e.g. search-provider keys) already in the
112
+ file. You can also set `$DEEPSEEK_API_KEY` in your shell — it takes
113
+ priority over the file.
114
+
115
+ The rest of this section walks through the manual file setup if you'd
116
+ rather do it yourself. A ready-to-edit template lives at the repo
117
+ root: **[`deepseek.json.example`](deepseek.json.example)**. Copy it to
118
+ the config path below and replace the placeholder values:
99
119
 
100
120
  ```sh
101
121
  # Linux / macOS:
@@ -205,9 +225,8 @@ dsc # interactive TUI
205
225
  dsc "summarize src/api.ts" # one-shot (runs and exits)
206
226
  dsc --yolo "rename Foo to Bar" # skip approval prompts
207
227
  dsc --no-resume # fresh session, ignore prior history
208
- dsc --repl # readline REPL instead of TUI
209
- dsc --repl -m deepseek-v4-flash # REPL-only: pick a model
210
- dsc --repl --resume <id> # REPL-only: resume a specific session
228
+ dsc -m deepseek-v4-flash # pick a model for this launch
229
+ dsc --resume <id> # resume a specific session by id
211
230
  ```
212
231
 
213
232
  ## TUI layout
@@ -241,12 +260,17 @@ until you answer.
241
260
 
242
261
  ## Slash commands
243
262
 
244
- Available in both the TUI and the `--repl` REPL. Type `/` and TAB cycles
245
- through completions.
263
+ Type `/` and TAB completes to the longest unique prefix; an inline dim
264
+ ghost-text suggestion previews the match as you type.
246
265
 
247
266
  | Command | What it does |
248
267
  |---|---|
249
- | `/clear` | Start a new session. Old session stays on disk. |
268
+ | `/api-key [key]` | Show where the key is loaded from (env / config file / unset). With a key arg, write it to `~/.config/deepseek/deepseek.json` with `0600` perms. |
269
+ | `/update` | Force-check npm for a newer release and install it (`npm install -g @este.systems/dsc@latest`). The TUI also checks once a day in the background and surfaces a one-line "X available" notice when behind. |
270
+ | `/copy` | Copy the most recent assistant response to the OS clipboard (pbcopy / clip / wl-copy / xclip / xsel). |
271
+ | `/export [path]` | Write the current session JSON to `path` (default: cwd, with a `<name|id>-<date>.json` filename). |
272
+ | `/import <path> [--keep-cwd]` | Load a session from a JSON file as the active session. Rebinds cwd to the current directory by default so auto-resume picks it up here; `--keep-cwd` preserves the original. Mints a fresh id on collision (no overwrites). |
273
+ | `/clear` | Start a new session. Old session stays on disk. Also drops per-tool "always" approvals. |
250
274
  | `/cost` | Show token usage and estimated cost so far. |
251
275
  | `/model [name]` | Show or switch model. Available: `deepseek-v4-pro`, `deepseek-v4-flash`. |
252
276
  | `/yolo` | Toggle approval mode (write/edit/bash/web_fetch). |
@@ -284,17 +308,28 @@ paste-heavy drafts, use `/edit`.
284
308
 
285
309
  | Key | Where | What |
286
310
  |---|---|---|
287
- | `Up` / `Down` | Prompt | Recall past prompts (persisted across sessions and across TUI ↔ REPL). |
288
- | `Tab` | Prompt | Complete a partial `/slash` command. |
311
+ | `Up` / `Down` | Prompt | Recall past prompts (persisted across sessions in `~/.local/state/dsc/history`). |
312
+ | `Tab` | Prompt | Complete a partial `/slash` command. The TUI also previews the match as dim ghost text inline. |
289
313
  | `Ctrl+A` / `Ctrl+E` | Prompt | Cursor to start / end of line. |
290
314
  | `Ctrl+U` / `Ctrl+K` | Prompt | Delete to start / end of line. |
291
315
  | `Ctrl+W` | Prompt | Delete the word before the cursor. |
316
+ | `y` | Approval | Approve this call. |
317
+ | `a` | Approval | Approve this call **and** auto-approve future calls of the same tool for the rest of this session (cleared by `/clear`). |
318
+ | `n` / `ESC` | Approval | Reject. |
292
319
  | `ESC` | Turn busy | Abort the in-flight turn. |
293
- | `ESC` | Approval | Reject the pending tool call (same as `n`). |
294
320
  | `ESC` | Multiline | Clear the accumulated backslash-continuation buffer. |
295
321
  | `Ctrl+C` | Turn busy | Abort the in-flight turn. |
296
322
  | `Ctrl+C` / `Ctrl+D` | Idle | Exit cleanly. |
297
323
 
324
+ ### Agent task list
325
+
326
+ Non-trivial multi-step requests trigger the model to reach for the
327
+ `task_create` / `task_update` / `task_list` tools. The TUI renders the
328
+ list above the prompt as `○ pending` / `◐ in-progress` / `● completed`
329
+ bullets so you can watch the agent's plan execute. Hidden once every
330
+ task is `completed`. Lives only in memory — cleared by `/clear` and on
331
+ exit.
332
+
298
333
  ### Session scoping (per-directory)
299
334
 
300
335
  Sessions are tied to the directory you launched dsc from — that's how
@@ -331,12 +366,13 @@ the archived messages from `/transcript`.
331
366
  | `task_create(subject, activeForm?)` | none | Adds a pending task to the user-visible task list. |
332
367
  | `task_update(id, status?, subject?, activeForm?)` | none | Moves a task between pending / in_progress / completed. |
333
368
  | `task_list()` | none | Returns the current task list with statuses. |
334
- | `write_file(path, content)` | yes (unless `--yolo`) | Side-by-side diff in the prompt. |
369
+ | `write_file(path, content)` | yes (unless `--yolo`) | Side-by-side diff inside the approval dialog. |
335
370
  | `edit_file(path, old_string, new_string, replace_all?)` | yes | Exact substring replace; old_string must be unique unless `replace_all=true`. |
336
371
  | `bash(command, description?, timeout_ms?)` | yes | `/bin/sh` on Linux/macOS, `cmd.exe` on Windows. Output capped at 16 KB. |
337
372
  | `web_fetch(url)` | yes | HTML stripped to text, capped at 50 KB. |
338
373
 
339
- Read-only tools never prompt. The rest do unless `--yolo` is on. The
374
+ Read-only tools never prompt. The rest do unless `--yolo` is on or
375
+ you've previously said `a` (always) for that tool this session. The
340
376
  `task_*` tools mutate an in-memory list that the TUI renders above the
341
377
  prompt; the model is encouraged (via the system prompt) to reach for
342
378
  them on non-trivial multi-step asks so the user sees real-time progress.
@@ -479,20 +515,25 @@ The package is configured to publish as `@este.systems/dsc` with public
479
515
  access. To release:
480
516
 
481
517
  ```sh
482
- # 1. Bump the version (semver). For a pre-1.0 patch:
518
+ # 1. Roll the `## [Unreleased]` section in CHANGELOG.md into a dated
519
+ # `## [X.Y.Z] - YYYY-MM-DD` header and add the compare link at the
520
+ # bottom. Commit the changelog edit before npm version so the bump
521
+ # commit and the changelog entry land in the same release.
522
+
523
+ # 2. Bump the version (semver). For a pre-1.0 patch:
483
524
  npm version patch # → 0.1.1, also creates a git tag
484
525
 
485
- # 2. Make sure you're logged in to npm:
526
+ # 3. Make sure you're logged in to npm:
486
527
  npm whoami # should print your username
487
528
  npm login # if not
488
529
 
489
- # 3. (Optional) preview the tarball:
530
+ # 4. (Optional) preview the tarball:
490
531
  npm pack --dry-run
491
532
 
492
- # 4. Publish:
533
+ # 5. Publish:
493
534
  npm publish # respects publishConfig.access=public
494
535
 
495
- # 5. Push the version-bump commit and tag:
536
+ # 6. Push the version-bump commit and tag:
496
537
  git push --follow-tags
497
538
  ```
498
539
 
@@ -522,41 +563,42 @@ Source layout:
522
563
 
523
564
  ```
524
565
  src/
525
- tui.tsx # TUI entry: arg parsing, session + agent wiring, slash dispatcher
526
- index.ts # readline REPL entry (--repl)
566
+ tui.tsx # entry: arg parsing, session + agent wiring, slash dispatcher
527
567
  agent.ts # tool-call loop, AgentEvents emitter, repair logic
528
- api.ts # DeepSeek client, retry/abort, prompt cache rates
568
+ api.ts # DeepSeek client, retry/abort, prompt cache rates, saveApiKey
529
569
  tools.ts # tool schemas + executors (read/write/edit/bash/grep/glob/web_*/task_*)
530
- approval.ts # confirmWrite/Edit/Bash/Fetch pluggable asker
570
+ approval.ts # confirm{Write,Edit,Bash,Fetch} + ApprovalPayload + 3-state answer
531
571
  audit.ts # JSONL audit logger
532
572
  search.ts # Brave / Tavily / DDG dispatch
533
573
  compact.ts # /compact summarization routine
534
- history.ts # session save/load/list/migrate-legacy
535
- repl_history.ts # ~/.local/state/dsc/history reader/writer (shared)
536
- markdown.ts # REPL streaming markdown→ANSI renderer
537
- ui.ts # REPL: Spinner with stall detection; DECSTBM StatusBar
574
+ history.ts # session save/load/list, /export, /import, migrate-legacy
575
+ repl_history.ts # ~/.local/state/dsc/history reader/writer (prompt recall)
576
+ ui.ts # Spinner used by one-shot mode
538
577
  prompt.ts # SYSTEM_PROMPT + buildSystemPrompt
539
- editor.ts # $EDITOR launcher (shared by /edit in both front-ends)
540
- slash.ts # SLASH_COMMANDS list + TAB-completion helper (shared)
578
+ editor.ts # $EDITOR launcher for /edit
579
+ slash.ts # SLASH_COMMANDS list + TAB-completion helper
541
580
  store.ts # TUI pub/sub state container (history, agentTasks, queue, etc.)
581
+ update.ts # npm registry probe + `npm install -g` runner for /update
582
+ clipboard.ts # cross-platform clipboard write (pbcopy / clip / wl-copy / xclip / xsel)
542
583
  tui/
543
584
  App.tsx # root layout
544
585
  History.tsx # <Static> for finalized turns
545
586
  CurrentTurn.tsx # in-progress streaming message
546
587
  Markdown.tsx # markdown → ink Text-tree (incl. tables)
547
- AgentTaskList.tsx # bullets above the prompt
588
+ AgentTaskList.tsx # task_* bullets above the prompt
548
589
  QueuedPrompts.tsx # dim list of pending submissions
549
590
  TaskLine.tsx # "→ tool(...)" indicator while a tool runs
550
- StatusBar.tsx # full-width inverse-video status line
591
+ StatusBar.tsx # full-width inverse-video status line w/ busy spinner
551
592
  PromptInput.tsx # backslash-continuation buffer + prompt char
552
- Input.tsx # custom controlled input (cursor, history, TAB)
553
- ApprovalDialog.tsx # yellow-bordered modal for tool approvals
593
+ Input.tsx # custom controlled input (cursor, history, TAB + ghost suggest)
594
+ ApprovalDialog.tsx # yellow-bordered modal with inline diff/command preview
554
595
  useStore.ts # selector + equality hook over store.ts
555
596
  ```
556
597
 
557
- The agent loop in `agent.ts` is shared between front-ends. When called
558
- with an `events` callback set it emits structured events (assistant
559
- start/content/reasoning/final, tool start/end, notice) that the TUI
560
- pipes into the store; when called without `events` it writes the same
561
- information directly to stdout that's what the REPL and the TUI
562
- one-shot mode use.
598
+ The agent loop in `agent.ts` supports two output modes via a single
599
+ flag. With an `events` callback set (the interactive TUI), it emits
600
+ structured events — assistant start/content/reasoning/final, tool
601
+ start/end, notice that the TUI pipes into the store. Without
602
+ `events` (one-shot mode), it writes the same information directly to
603
+ stdout as plain text. Same loop, same tool plumbing, just two thin
604
+ output adapters.
package/bin/dsc.mjs CHANGED
@@ -12,18 +12,9 @@ const pkgRoot = dirname(here);
12
12
  const tsxBin = join(pkgRoot, "node_modules", ".bin", "tsx");
13
13
  const tsxBinCmd = process.platform === "win32" ? tsxBin + ".cmd" : tsxBin;
14
14
 
15
- // Pick the entry. TUI (ink) is the default and handles its own one-shot
16
- // mode now (`dsc "prompt"` runs the agent against stdout and exits without
17
- // ever rendering ink). `--repl` opts into the readline REPL when the user
18
- // explicitly wants it.
19
15
  const argv = process.argv.slice(2);
20
- const wantsRepl = argv.includes("--repl");
21
- const filteredArgv = argv.filter((a) => a !== "--repl");
22
-
23
- const entryName = wantsRepl ? "index" : "tui";
24
- const srcEntry = join(pkgRoot, "src", wantsRepl ? "index.ts" : "tui.tsx");
25
- const distEntry = join(pkgRoot, "dist", `${entryName}.js`);
26
-
16
+ const srcEntry = join(pkgRoot, "src", "tui.tsx");
17
+ const distEntry = join(pkgRoot, "dist", "tui.js");
27
18
  const tsxAvailable = existsSync(tsxBin) || existsSync(tsxBinCmd);
28
19
 
29
20
  if (tsxAvailable && existsSync(srcEntry)) {
@@ -33,7 +24,7 @@ if (tsxAvailable && existsSync(srcEntry)) {
33
24
  // might contain spaces (e.g. paths in C:\Program Files\...).
34
25
  const child = spawn(
35
26
  process.platform === "win32" ? tsxBinCmd : tsxBin,
36
- [srcEntry, ...filteredArgv],
27
+ [srcEntry, ...argv],
37
28
  { stdio: "inherit", shell: process.platform === "win32" },
38
29
  );
39
30
  child.on("exit", (code, signal) => {
package/dist/agent.js CHANGED
@@ -2,7 +2,6 @@ import { randomUUID } from "node:crypto";
2
2
  import { chatStream, computeCostUsd, recordUsage, } from "./api.js";
3
3
  import { READ_ONLY_TOOLS, TOOL_SCHEMAS, executeTool } from "./tools.js";
4
4
  import { Spinner } from "./ui.js";
5
- import { MarkdownRenderer } from "./markdown.js";
6
5
  import { buildSystemPrompt } from "./prompt.js";
7
6
  // How many tool calls we let the agent chain in one user turn before we stop
8
7
  // it. Set high enough that real coding tasks (read several files, search, run
@@ -43,10 +42,12 @@ function streamHandlers(spinner, showReasoning, assistantLabel, events, turnId)
43
42
  },
44
43
  };
45
44
  }
46
- // Stdout path (REPL): existing terminal-rendering behavior.
45
+ // Stdout path: used by `dsc "prompt"` one-shot mode. The interactive
46
+ // TUI always passes `events`, so this branch never runs there. Output
47
+ // is plain text — no ANSI markdown styling — because one-shot output
48
+ // typically gets piped to other tools where escape codes are noise.
47
49
  let contentStarted = false;
48
50
  let reasoningStarted = false;
49
- const renderer = new MarkdownRenderer();
50
51
  return {
51
52
  onContent: (text) => {
52
53
  spinner.bump();
@@ -59,7 +60,7 @@ function streamHandlers(spinner, showReasoning, assistantLabel, events, turnId)
59
60
  process.stdout.write(`${BOLD}${assistantLabel}${RESET} `);
60
61
  contentStarted = true;
61
62
  }
62
- process.stdout.write(renderer.push(text));
63
+ process.stdout.write(text);
63
64
  },
64
65
  onReasoning: (text) => {
65
66
  spinner.bump();
@@ -77,7 +78,6 @@ function streamHandlers(spinner, showReasoning, assistantLabel, events, turnId)
77
78
  },
78
79
  flush: () => {
79
80
  if (contentStarted) {
80
- process.stdout.write(renderer.flush());
81
81
  process.stdout.write("\n");
82
82
  }
83
83
  else if (reasoningStarted) {
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,GAKZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA8BhD,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG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C,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1D,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;YACpC,IAAI,EAAE;gBAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrB,CAAC,EAAE,CAAC;QACN,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;gBACrB,GAAG,CAAC,IAAI,CAAC;oBACP,IAAI,EAAE,MAAM;oBACZ,YAAY,EAAE,EAAE,CAAC,EAAE;oBACnB,OAAO,EAAE,iDAAiD;iBAC3D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,6CAA6C;IAC1D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/api.js CHANGED
@@ -17,6 +17,7 @@ export class DeepSeekError extends Error {
17
17
  }
18
18
  }
19
19
  import { readFileSync } from "node:fs";
20
+ import { promises as fsp } from "node:fs";
20
21
  import { homedir } from "node:os";
21
22
  import * as nodePath from "node:path";
22
23
  export function configPath() {
@@ -106,6 +107,113 @@ export function hasApiKey() {
106
107
  return false;
107
108
  }
108
109
  }
110
+ /**
111
+ * Returns "env" when the env var DEEPSEEK_API_KEY is set, "file" when the
112
+ * config file has a key, or null when neither is set. Lets the UI explain
113
+ * to the user where the key is coming from without leaking it.
114
+ */
115
+ export function apiKeySource() {
116
+ if (process.env.DEEPSEEK_API_KEY)
117
+ return "env";
118
+ try {
119
+ return readKeyFromFile() !== null ? "file" : null;
120
+ }
121
+ catch {
122
+ return null;
123
+ }
124
+ }
125
+ /**
126
+ * Merge `key` into the config file at `configPath()`, creating the file +
127
+ * parent directory if needed. Preserves any other fields already in the
128
+ * file (e.g. `search` provider settings). Writes with 0600 permissions so
129
+ * other users on the box can't read the key.
130
+ *
131
+ * Invalidates the in-memory caches so the next getApiKey() picks up the
132
+ * new value without a restart.
133
+ */
134
+ export async function saveApiKey(key) {
135
+ const trimmed = key.trim();
136
+ if (!trimmed)
137
+ throw new DeepSeekError("api key is empty");
138
+ const p = configPath();
139
+ await fsp.mkdir(nodePath.dirname(p), { recursive: true });
140
+ let existing = {};
141
+ try {
142
+ let txt = await fsp.readFile(p, "utf8");
143
+ if (txt.charCodeAt(0) === 0xfeff)
144
+ txt = txt.slice(1);
145
+ const parsed = JSON.parse(txt);
146
+ if (parsed && typeof parsed === "object") {
147
+ existing = parsed;
148
+ }
149
+ }
150
+ catch {
151
+ // missing or unparseable — start fresh; we'd rather overwrite a broken
152
+ // file than silently fail the save
153
+ }
154
+ existing.api_key = trimmed;
155
+ // mode on the write is honored on POSIX; Windows ignores it but inherits
156
+ // the directory ACL. Best-effort chmod afterwards in case the file
157
+ // already existed with looser perms.
158
+ await fsp.writeFile(p, JSON.stringify(existing, null, 2), {
159
+ encoding: "utf8",
160
+ mode: 0o600,
161
+ });
162
+ try {
163
+ await fsp.chmod(p, 0o600);
164
+ }
165
+ catch {
166
+ // POSIX-only; ignore failures on Windows.
167
+ }
168
+ _cachedKey = undefined;
169
+ _cachedConfig = undefined;
170
+ return p;
171
+ }
172
+ /**
173
+ * Save a search-provider key (brave/tavily) into the config file.
174
+ * Merges into `search.<provider>.api_key`, preserving any other fields
175
+ * already in `search` (e.g. `provider`, the *other* provider's key).
176
+ * Returns the path written to.
177
+ */
178
+ export async function saveSearchKey(provider, key) {
179
+ const trimmed = key.trim();
180
+ if (!trimmed)
181
+ throw new DeepSeekError("api key is empty");
182
+ const p = configPath();
183
+ await fsp.mkdir(nodePath.dirname(p), { recursive: true });
184
+ let existing = {};
185
+ try {
186
+ let txt = await fsp.readFile(p, "utf8");
187
+ if (txt.charCodeAt(0) === 0xfeff)
188
+ txt = txt.slice(1);
189
+ const parsed = JSON.parse(txt);
190
+ if (parsed && typeof parsed === "object") {
191
+ existing = parsed;
192
+ }
193
+ }
194
+ catch {
195
+ // missing or unparseable — start fresh
196
+ }
197
+ const search = existing.search && typeof existing.search === "object"
198
+ ? existing.search
199
+ : {};
200
+ const sub = search[provider] && typeof search[provider] === "object"
201
+ ? search[provider]
202
+ : {};
203
+ sub.api_key = trimmed;
204
+ search[provider] = sub;
205
+ existing.search = search;
206
+ await fsp.writeFile(p, JSON.stringify(existing, null, 2), {
207
+ encoding: "utf8",
208
+ mode: 0o600,
209
+ });
210
+ try {
211
+ await fsp.chmod(p, 0o600);
212
+ }
213
+ catch { }
214
+ _cachedConfig = undefined;
215
+ return p;
216
+ }
109
217
  export async function chat(opts) {
110
218
  const apiKey = getApiKey();
111
219
  const body = {