@este.systems/dsc 0.3.0 → 0.4.1

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,176 @@
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.1] - 2026-05-17
11
+
12
+ ### Added
13
+ - `/update` on EACCES (Linux / macOS) now offers to do the user-prefix setup itself. The yellow approval dialog asks first; on `y` it runs `mkdir -p ~/.local/{bin,lib}`, `npm config set prefix ~/.local`, and retries the install. If `~/.local/bin` isn't on PATH afterwards, a second dialog offers to append the export line to the detected shell rc (`~/.bashrc` / `~/.bash_profile` / `~/.zshrc` / `~/.config/fish/config.fish`). Idempotent — re-running is safe. Skipping the dialogs leaves the manual one-liner instructions intact.
14
+
15
+ ### Changed
16
+ - README leads the install with a one-time `npm config set prefix ~/.local` + PATH export so `npm install -g` (and `/update`) work without `sudo` on Linux / macOS. Windows already uses a user-owned prefix and is unchanged.
17
+ - `scripts/install.sh` detects a root-owned npm prefix and auto-configures `~/.local` when run as a non-root user. `--system` opts out (use the existing prefix, may need sudo); `--user` forces the switch.
18
+
19
+ ## [0.4.0] - 2026-05-17
20
+
21
+ ### Added
22
+ - `/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.
23
+ - `/api-key` and the welcome panel now point at https://platform.deepseek.com/api_keys when no DeepSeek key is configured.
24
+ - 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.
25
+
26
+ ### Removed
27
+ - 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.
28
+
29
+ ### Changed
30
+ - `bin/dsc.mjs` always routes to `src/tui.tsx` now; the `--repl` branch is gone.
31
+ - 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.
32
+ - 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.
33
+
34
+ ## [0.3.0] - 2026-05-17
35
+
36
+ ### Added
37
+ - `/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.
38
+ - `/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.
39
+ - `/copy` — copy the last assistant message to the OS clipboard (pbcopy / clip / wl-copy / xclip / xsel).
40
+ - `/export [path]` — write the current session JSON to a chosen path for transfer between machines.
41
+ - `/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).
42
+ - One-time welcome panel on first launch, stamped via `$XDG_STATE_HOME/dsc/welcomed` so it doesn't repeat.
43
+ - Inline ghost-text suggest as you type a `/slash` command (dim suffix of the longest match).
44
+ - 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.
45
+ - Approval shortcut `a` (always) auto-approves future calls of the same tool for this session; cleared by `/clear`.
46
+
47
+ ### Changed
48
+ - 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.
49
+ - Slash commands echo into history as user messages so their output is no longer orphaned in scrollback.
50
+
51
+ ## [0.2.5] - 2026-05-17
52
+
53
+ ### Fixed
54
+ - EINVAL when the build / package scripts spawn `npm.cmd` on Windows.
55
+
56
+ ## [0.2.4] - 2026-05-17
57
+
58
+ ### Changed
59
+ - Swapped the busy spinner from Braille to quadrant blocks — Windows console fonts can't render Braille consistently.
60
+
61
+ ## [0.2.3] - 2026-05-17
62
+
63
+ ### Fixed
64
+ - Kill the entire cmd.exe process tree on abort / timeout / grace so PowerShell grandchildren don't leak and keep the agent stuck.
65
+
66
+ ## [0.2.2] - 2026-05-14
67
+
68
+ ### Fixed
69
+ - 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.
70
+
71
+ ### Added
72
+ - Genuinely empty assistant turns (no content, no reasoning, no tool calls) now show a `(model returned no content)` marker instead of disappearing silently.
73
+
74
+ ## [0.2.1] - 2026-05-14
75
+
76
+ ### Added
77
+ - Animated Braille spinner in the status bar while busy; `/compact` now flips `busy` so the spinner shows during compaction too.
78
+
79
+ ### Changed
80
+ - Status-bar task labels are pretty-printed per tool (`bash: npm test`, `edit_file: src/foo.ts`) instead of dumping the raw JSON arguments.
81
+
82
+ ### Fixed
83
+ - Status bar no longer renders one column past the terminal width (off-by-one in the padding math).
84
+
85
+ ## [0.2.0] - 2026-05-13
86
+
87
+ ### Added
88
+ - 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`.
89
+ - 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.
90
+ - 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.
91
+ - Visible type-ahead queue (dim, above the prompt) instead of just a `queued:N` count in the status bar.
92
+ - Reasoning rendered as a dedicated "thinking" block (dim italic, indented) instead of dangling under the assistant header.
93
+ - Native one-shot mode in the TUI: `dsc "prompt"` runs the agent against stdout and exits without rendering ink.
94
+ - TUI slash commands: `/help`, `/clear`, `/list`, `/resume`, `/save`, `/rename`, `/model`, `/yolo`, `/reasoning`, `/cost`, `/version`, `/lang`, `/auto-continue`, `/queue`, `/audit`, `/transcript`, `/compact`, `/edit`, `/exit`.
95
+ - ESC aborts the in-flight turn; Ctrl+D / Ctrl+C exit semantics.
96
+ - Multiline input via backslash continuation, with the accumulated buffer rendered dim above the prompt; ESC clears it.
97
+ - `/edit` unmounts ink, opens `$EDITOR`, and remounts.
98
+ - Markdown rendering (headings, code fences, lists, blockquotes, tables, inline bold / italic / code / links) applied to finalized assistant messages.
99
+
100
+ ### Changed
101
+ - 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.
102
+ - User prompts in history render with a subtle bright-black background and no role label.
103
+
104
+ ## [0.1.7] - 2026-05-12
105
+
106
+ ### Added
107
+ - `--version` / `-v` CLI flag and `/version` slash command — prints dsc version + Node + platform/arch.
108
+
109
+ ## [0.1.6] - 2026-05-12
110
+
111
+ ### Changed
112
+ - 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."
113
+
114
+ ## [0.1.5] - 2026-05-12
115
+
116
+ ### Fixed
117
+ - Bash and `which` on Windows. `spawn("/bin/sh", ...)` was broken — switched to `spawn(command, [], { shell: true })`. Use `where` on Windows, `which` elsewhere.
118
+
119
+ ## [0.1.4] - 2026-05-12
120
+
121
+ ### Fixed
122
+ - TDZ crash on startup: hoisted the `promptQueue` declaration before `currentStatusLine` references it.
123
+
124
+ ## [0.1.3] - 2026-05-12
125
+
126
+ ### Fixed
127
+ - Windows-only `ERR_UNSUPPORTED_ESM_URL_SCHEME` in `bin/dsc.mjs`. `await import("C:\\...")` parses `C:` as a URL scheme; use `pathToFileURL()` instead.
128
+
129
+ ## [0.1.2] - 2026-05-12
130
+
131
+ ### Added
132
+ - `/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`.
133
+ - `/lang [name|off]` — force the model to reply exclusively in a named language; persisted per session.
134
+ - Type-ahead prompt queue — captured lines pile up while a turn is running and drain in order afterwards.
135
+ - `deepseek.json.example` settings template.
136
+
137
+ ## [0.1.1] - 2026-05-11
138
+
139
+ ### Changed
140
+ - README polish: npm / license / node version badges; per-platform install steps for Linux / macOS / Windows.
141
+
142
+ ## [0.1.0] - 2026-05-10
143
+
144
+ Initial public release.
145
+
146
+ ### Added
147
+ - Readline REPL with streaming responses from DeepSeek's API.
148
+ - Tool surface: `bash`, `read_file`, `write_file`, `edit_file`, `grep`, `glob`, `web_fetch`, `web_search` (Brave / Tavily / DuckDuckGo).
149
+ - Per-cwd session persistence under `~/.local/share/dsc/sessions/` keyed by id, with auto-resume by directory.
150
+ - JSONL audit log of every tool call under `~/.local/state/dsc/audit.log`.
151
+ - Up-arrow prompt history shared across sessions under `~/.local/state/dsc/history`.
152
+ - Slash commands: `/clear`, `/cost`, `/model`, `/yolo`, `/reasoning`, `/list`, `/resume`, `/save`, `/rename`, `/audit`, `/transcript`, `/compact`, `/edit`, `/exit`.
153
+ - `/compact` summarizes older turns into a synthetic block kept in the system prompt; the original messages move to `archivedMessages` so `/transcript` still shows them.
154
+ - ESC interrupts the running turn.
155
+ - Backslash continuation for multi-line input.
156
+ - DECSTBM-pinned status bar.
157
+ - Cross-platform packaging (`npm pack` + per-OS installer scripts).
158
+
159
+ [Unreleased]: https://github.com/EsteSystems/dsc/compare/v0.4.1...HEAD
160
+ [0.4.1]: https://github.com/EsteSystems/dsc/compare/v0.4.0...v0.4.1
161
+ [0.4.0]: https://github.com/EsteSystems/dsc/compare/v0.3.0...v0.4.0
162
+ [0.3.0]: https://github.com/EsteSystems/dsc/compare/v0.2.5...v0.3.0
163
+ [0.2.5]: https://github.com/EsteSystems/dsc/compare/v0.2.4...v0.2.5
164
+ [0.2.4]: https://github.com/EsteSystems/dsc/compare/v0.2.3...v0.2.4
165
+ [0.2.3]: https://github.com/EsteSystems/dsc/compare/v0.2.2...v0.2.3
166
+ [0.2.2]: https://github.com/EsteSystems/dsc/compare/v0.2.1...v0.2.2
167
+ [0.2.1]: https://github.com/EsteSystems/dsc/compare/v0.2.0...v0.2.1
168
+ [0.2.0]: https://github.com/EsteSystems/dsc/compare/v0.1.7...v0.2.0
169
+ [0.1.7]: https://github.com/EsteSystems/dsc/compare/v0.1.6...v0.1.7
170
+ [0.1.6]: https://github.com/EsteSystems/dsc/compare/v0.1.5...v0.1.6
171
+ [0.1.5]: https://github.com/EsteSystems/dsc/compare/v0.1.4...v0.1.5
172
+ [0.1.4]: https://github.com/EsteSystems/dsc/compare/v0.1.3...v0.1.4
173
+ [0.1.3]: https://github.com/EsteSystems/dsc/compare/v0.1.2...v0.1.3
174
+ [0.1.2]: https://github.com/EsteSystems/dsc/compare/v0.1.1...v0.1.2
175
+ [0.1.1]: https://github.com/EsteSystems/dsc/compare/v0.1.0...v0.1.1
176
+ [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
 
@@ -40,10 +40,35 @@ be hacking on the source.
40
40
 
41
41
  **(A) From npm**:
42
42
 
43
+ On most Linux / macOS installs, `npm`'s global directory is `/usr/local`,
44
+ which is root-owned. Before installing any global npm tool — not just
45
+ dsc — point npm at a user-owned directory so `npm install -g` (and dsc's
46
+ `/update`) work without `sudo`:
47
+
48
+ ```sh
49
+ # One-time setup. Skip if you've done this for another npm tool.
50
+ npm config set prefix ~/.local
51
+
52
+ # Add this to ~/.bashrc / ~/.zshrc and reopen the terminal:
53
+ export PATH="$HOME/.local/bin:$PATH"
54
+ ```
55
+
56
+ Then:
57
+
43
58
  ```sh
44
59
  npm install -g @este.systems/dsc
45
60
  ```
46
61
 
62
+ **Windows** users already get a user-owned prefix by default (`%APPDATA%\npm`).
63
+ Skip the `npm config set prefix` step and run the install directly.
64
+
65
+ After install, run `dsc`. On a fresh machine the TUI greets you with a
66
+ one-time welcome card and points you at `/api-key sk-...` for the
67
+ initial key save. To upgrade later, run `/update` inside the TUI (or
68
+ `npm install -g @este.systems/dsc@latest` from outside) — dsc also
69
+ checks npm in the background once a day and surfaces a one-line notice
70
+ when a newer version is published.
71
+
47
72
  **(B) From a local tarball** *(works on all platforms with the same npm)*:
48
73
 
49
74
  ```sh
@@ -56,7 +81,8 @@ npm run package # produces pkg/<name>-<version>.tgz
56
81
  then on **Linux / macOS**:
57
82
 
58
83
  ```sh
59
- scripts/install.sh
84
+ scripts/install.sh # auto-configures user prefix if needed
85
+ scripts/install.sh --system # use existing prefix (may need sudo)
60
86
  ```
61
87
 
62
88
  or on **Windows PowerShell**:
@@ -65,8 +91,10 @@ or on **Windows PowerShell**:
65
91
  .\scripts\install.ps1
66
92
  ```
67
93
 
68
- Both wrappers just call `npm install -g pkg/*.tgz` after auto-finding the
69
- tarball.
94
+ The Linux / macOS wrapper checks whether `npm config get prefix` points
95
+ at a user-writable directory. If not — and you aren't root — it sets up
96
+ `~/.local` and adds a PATH hint before installing. Pass `--system` to
97
+ opt out.
70
98
 
71
99
  **(C) From source for development** *(live edits, no rebuild step)*:
72
100
 
@@ -94,8 +122,21 @@ to your `PATH` and reopen the terminal.
94
122
 
95
123
  ## API key
96
124
 
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:
125
+ **Easiest path** launch dsc and use the slash command:
126
+
127
+ ```
128
+ > /api-key sk-...
129
+ ```
130
+
131
+ That writes `~/.config/deepseek/deepseek.json` with `0600` perms,
132
+ preserving any other fields (e.g. search-provider keys) already in the
133
+ file. You can also set `$DEEPSEEK_API_KEY` in your shell — it takes
134
+ priority over the file.
135
+
136
+ The rest of this section walks through the manual file setup if you'd
137
+ rather do it yourself. A ready-to-edit template lives at the repo
138
+ root: **[`deepseek.json.example`](deepseek.json.example)**. Copy it to
139
+ the config path below and replace the placeholder values:
99
140
 
100
141
  ```sh
101
142
  # Linux / macOS:
@@ -205,9 +246,8 @@ dsc # interactive TUI
205
246
  dsc "summarize src/api.ts" # one-shot (runs and exits)
206
247
  dsc --yolo "rename Foo to Bar" # skip approval prompts
207
248
  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
249
+ dsc -m deepseek-v4-flash # pick a model for this launch
250
+ dsc --resume <id> # resume a specific session by id
211
251
  ```
212
252
 
213
253
  ## TUI layout
@@ -241,12 +281,18 @@ until you answer.
241
281
 
242
282
  ## Slash commands
243
283
 
244
- Available in both the TUI and the `--repl` REPL. Type `/` and TAB cycles
245
- through completions.
284
+ Type `/` and TAB completes to the longest unique prefix; an inline dim
285
+ ghost-text suggestion previews the match as you type.
246
286
 
247
287
  | Command | What it does |
248
288
  |---|---|
249
- | `/clear` | Start a new session. Old session stays on disk. |
289
+ | `/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. When unset, prints the DeepSeek signup URL. |
290
+ | `/search-key [provider] [key]` | Show / save search-provider keys. No-arg lists `brave` and `tavily` with status + signup URLs. With a provider, shows just that one. With a key, saves under `search.<provider>.api_key`. |
291
+ | `/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. |
292
+ | `/copy` | Copy the most recent assistant response to the OS clipboard (pbcopy / clip / wl-copy / xclip / xsel). |
293
+ | `/export [path]` | Write the current session JSON to `path` (default: cwd, with a `<name|id>-<date>.json` filename). |
294
+ | `/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). |
295
+ | `/clear` | Start a new session. Old session stays on disk. Also drops per-tool "always" approvals. |
250
296
  | `/cost` | Show token usage and estimated cost so far. |
251
297
  | `/model [name]` | Show or switch model. Available: `deepseek-v4-pro`, `deepseek-v4-flash`. |
252
298
  | `/yolo` | Toggle approval mode (write/edit/bash/web_fetch). |
@@ -284,17 +330,28 @@ paste-heavy drafts, use `/edit`.
284
330
 
285
331
  | Key | Where | What |
286
332
  |---|---|---|
287
- | `Up` / `Down` | Prompt | Recall past prompts (persisted across sessions and across TUI ↔ REPL). |
288
- | `Tab` | Prompt | Complete a partial `/slash` command. |
333
+ | `Up` / `Down` | Prompt | Recall past prompts (persisted across sessions in `~/.local/state/dsc/history`). |
334
+ | `Tab` | Prompt | Complete a partial `/slash` command. The TUI also previews the match as dim ghost text inline. |
289
335
  | `Ctrl+A` / `Ctrl+E` | Prompt | Cursor to start / end of line. |
290
336
  | `Ctrl+U` / `Ctrl+K` | Prompt | Delete to start / end of line. |
291
337
  | `Ctrl+W` | Prompt | Delete the word before the cursor. |
338
+ | `y` | Approval | Approve this call. |
339
+ | `a` | Approval | Approve this call **and** auto-approve future calls of the same tool for the rest of this session (cleared by `/clear`). |
340
+ | `n` / `ESC` | Approval | Reject. |
292
341
  | `ESC` | Turn busy | Abort the in-flight turn. |
293
- | `ESC` | Approval | Reject the pending tool call (same as `n`). |
294
342
  | `ESC` | Multiline | Clear the accumulated backslash-continuation buffer. |
295
343
  | `Ctrl+C` | Turn busy | Abort the in-flight turn. |
296
344
  | `Ctrl+C` / `Ctrl+D` | Idle | Exit cleanly. |
297
345
 
346
+ ### Agent task list
347
+
348
+ Non-trivial multi-step requests trigger the model to reach for the
349
+ `task_create` / `task_update` / `task_list` tools. The TUI renders the
350
+ list above the prompt as `○ pending` / `◐ in-progress` / `● completed`
351
+ bullets so you can watch the agent's plan execute. Hidden once every
352
+ task is `completed`. Lives only in memory — cleared by `/clear` and on
353
+ exit.
354
+
298
355
  ### Session scoping (per-directory)
299
356
 
300
357
  Sessions are tied to the directory you launched dsc from — that's how
@@ -331,12 +388,13 @@ the archived messages from `/transcript`.
331
388
  | `task_create(subject, activeForm?)` | none | Adds a pending task to the user-visible task list. |
332
389
  | `task_update(id, status?, subject?, activeForm?)` | none | Moves a task between pending / in_progress / completed. |
333
390
  | `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. |
391
+ | `write_file(path, content)` | yes (unless `--yolo`) | Side-by-side diff inside the approval dialog. |
335
392
  | `edit_file(path, old_string, new_string, replace_all?)` | yes | Exact substring replace; old_string must be unique unless `replace_all=true`. |
336
393
  | `bash(command, description?, timeout_ms?)` | yes | `/bin/sh` on Linux/macOS, `cmd.exe` on Windows. Output capped at 16 KB. |
337
394
  | `web_fetch(url)` | yes | HTML stripped to text, capped at 50 KB. |
338
395
 
339
- Read-only tools never prompt. The rest do unless `--yolo` is on. The
396
+ Read-only tools never prompt. The rest do unless `--yolo` is on or
397
+ you've previously said `a` (always) for that tool this session. The
340
398
  `task_*` tools mutate an in-memory list that the TUI renders above the
341
399
  prompt; the model is encouraged (via the system prompt) to reach for
342
400
  them on non-trivial multi-step asks so the user sees real-time progress.
@@ -479,20 +537,25 @@ The package is configured to publish as `@este.systems/dsc` with public
479
537
  access. To release:
480
538
 
481
539
  ```sh
482
- # 1. Bump the version (semver). For a pre-1.0 patch:
540
+ # 1. Roll the `## [Unreleased]` section in CHANGELOG.md into a dated
541
+ # `## [X.Y.Z] - YYYY-MM-DD` header and add the compare link at the
542
+ # bottom. Commit the changelog edit before npm version so the bump
543
+ # commit and the changelog entry land in the same release.
544
+
545
+ # 2. Bump the version (semver). For a pre-1.0 patch:
483
546
  npm version patch # → 0.1.1, also creates a git tag
484
547
 
485
- # 2. Make sure you're logged in to npm:
548
+ # 3. Make sure you're logged in to npm:
486
549
  npm whoami # should print your username
487
550
  npm login # if not
488
551
 
489
- # 3. (Optional) preview the tarball:
552
+ # 4. (Optional) preview the tarball:
490
553
  npm pack --dry-run
491
554
 
492
- # 4. Publish:
555
+ # 5. Publish:
493
556
  npm publish # respects publishConfig.access=public
494
557
 
495
- # 5. Push the version-bump commit and tag:
558
+ # 6. Push the version-bump commit and tag:
496
559
  git push --follow-tags
497
560
  ```
498
561
 
@@ -522,41 +585,42 @@ Source layout:
522
585
 
523
586
  ```
524
587
  src/
525
- tui.tsx # TUI entry: arg parsing, session + agent wiring, slash dispatcher
526
- index.ts # readline REPL entry (--repl)
588
+ tui.tsx # entry: arg parsing, session + agent wiring, slash dispatcher
527
589
  agent.ts # tool-call loop, AgentEvents emitter, repair logic
528
- api.ts # DeepSeek client, retry/abort, prompt cache rates
590
+ api.ts # DeepSeek client, retry/abort, prompt cache rates, saveApiKey
529
591
  tools.ts # tool schemas + executors (read/write/edit/bash/grep/glob/web_*/task_*)
530
- approval.ts # confirmWrite/Edit/Bash/Fetch pluggable asker
592
+ approval.ts # confirm{Write,Edit,Bash,Fetch} + ApprovalPayload + 3-state answer
531
593
  audit.ts # JSONL audit logger
532
594
  search.ts # Brave / Tavily / DDG dispatch
533
595
  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
596
+ history.ts # session save/load/list, /export, /import, migrate-legacy
597
+ repl_history.ts # ~/.local/state/dsc/history reader/writer (prompt recall)
598
+ ui.ts # Spinner used by one-shot mode
538
599
  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)
600
+ editor.ts # $EDITOR launcher for /edit
601
+ slash.ts # SLASH_COMMANDS list + TAB-completion helper
541
602
  store.ts # TUI pub/sub state container (history, agentTasks, queue, etc.)
603
+ update.ts # npm registry probe + `npm install -g` runner for /update
604
+ clipboard.ts # cross-platform clipboard write (pbcopy / clip / wl-copy / xclip / xsel)
542
605
  tui/
543
606
  App.tsx # root layout
544
607
  History.tsx # <Static> for finalized turns
545
608
  CurrentTurn.tsx # in-progress streaming message
546
609
  Markdown.tsx # markdown → ink Text-tree (incl. tables)
547
- AgentTaskList.tsx # bullets above the prompt
610
+ AgentTaskList.tsx # task_* bullets above the prompt
548
611
  QueuedPrompts.tsx # dim list of pending submissions
549
612
  TaskLine.tsx # "→ tool(...)" indicator while a tool runs
550
- StatusBar.tsx # full-width inverse-video status line
613
+ StatusBar.tsx # full-width inverse-video status line w/ busy spinner
551
614
  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
615
+ Input.tsx # custom controlled input (cursor, history, TAB + ghost suggest)
616
+ ApprovalDialog.tsx # yellow-bordered modal with inline diff/command preview
554
617
  useStore.ts # selector + equality hook over store.ts
555
618
  ```
556
619
 
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.
620
+ The agent loop in `agent.ts` supports two output modes via a single
621
+ flag. With an `events` callback set (the interactive TUI), it emits
622
+ structured events — assistant start/content/reasoning/final, tool
623
+ start/end, notice that the TUI pipes into the store. Without
624
+ `events` (one-shot mode), it writes the same information directly to
625
+ stdout as plain text. Same loop, same tool plumbing, just two thin
626
+ 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,O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cachedConfig = undefined;
170
170
  return p;
171
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
+ }
172
217
  export async function chat(opts) {
173
218
  const apiKey = getApiKey();
174
219
  const body = {