@este.systems/dsc 0.1.7 → 0.2.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/README.md +111 -31
- package/bin/dsc.mjs +13 -3
- package/dist/agent.js +76 -14
- package/dist/agent.js.map +1 -1
- package/dist/editor.js +37 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.js +5 -60
- package/dist/index.js.map +1 -1
- package/dist/prompt.js +11 -5
- package/dist/prompt.js.map +1 -1
- package/dist/slash.js +59 -0
- package/dist/slash.js.map +1 -0
- package/dist/store.js +44 -0
- package/dist/store.js.map +1 -0
- package/dist/tools.js +145 -1
- package/dist/tools.js.map +1 -1
- package/dist/tui/AgentTaskList.js +31 -0
- package/dist/tui/AgentTaskList.js.map +1 -0
- package/dist/tui/App.js +53 -0
- package/dist/tui/App.js.map +1 -0
- package/dist/tui/ApprovalDialog.js +24 -0
- package/dist/tui/ApprovalDialog.js.map +1 -0
- package/dist/tui/CurrentTurn.js +13 -0
- package/dist/tui/CurrentTurn.js.map +1 -0
- package/dist/tui/History.js +43 -0
- package/dist/tui/History.js.map +1 -0
- package/dist/tui/Input.js +162 -0
- package/dist/tui/Input.js.map +1 -0
- package/dist/tui/Markdown.js +242 -0
- package/dist/tui/Markdown.js.map +1 -0
- package/dist/tui/PromptInput.js +55 -0
- package/dist/tui/PromptInput.js.map +1 -0
- package/dist/tui/QueuedPrompts.js +13 -0
- package/dist/tui/QueuedPrompts.js.map +1 -0
- package/dist/tui/StatusBar.js +50 -0
- package/dist/tui/StatusBar.js.map +1 -0
- package/dist/tui/TaskLine.js +12 -0
- package/dist/tui/TaskLine.js.map +1 -0
- package/dist/tui/useStore.js +17 -0
- package/dist/tui/useStore.js.map +1 -0
- package/dist/tui.js +786 -0
- package/dist/tui.js.map +1 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
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
|
-
`grep`, `glob`, `web_fetch`, `web_search`), keeps per-cwd sessions,
|
|
11
|
-
|
|
12
|
-
|
|
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.
|
|
13
16
|
|
|
14
17
|
## Install
|
|
15
18
|
|
|
@@ -31,11 +34,11 @@ Verify: `node --version` should print `v22.x.x` or higher.
|
|
|
31
34
|
|
|
32
35
|
### Step 2 — install dsc
|
|
33
36
|
|
|
34
|
-
Three options.
|
|
35
|
-
|
|
36
|
-
source.
|
|
37
|
+
Three options. **(A)** is the standard install once the package is on npm.
|
|
38
|
+
Use **(B)** for a frozen tarball you can ship offline, or **(C)** if you'll
|
|
39
|
+
be hacking on the source.
|
|
37
40
|
|
|
38
|
-
**(A) From npm
|
|
41
|
+
**(A) From npm**:
|
|
39
42
|
|
|
40
43
|
```sh
|
|
41
44
|
npm install -g @este.systems/dsc
|
|
@@ -198,15 +201,48 @@ setx DEEPSEEK_API_KEY "sk-..." # cmd.exe (persisted)
|
|
|
198
201
|
## Quick start
|
|
199
202
|
|
|
200
203
|
```sh
|
|
201
|
-
dsc # interactive
|
|
202
|
-
dsc "summarize src/api.ts" # one-shot
|
|
204
|
+
dsc # interactive TUI
|
|
205
|
+
dsc "summarize src/api.ts" # one-shot (runs and exits)
|
|
203
206
|
dsc --yolo "rename Foo to Bar" # skip approval prompts
|
|
204
|
-
dsc -m deepseek-v4-flash # pick a model
|
|
205
207
|
dsc --no-resume # fresh session, ignore prior history
|
|
206
|
-
dsc --
|
|
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
|
|
207
211
|
```
|
|
208
212
|
|
|
209
|
-
##
|
|
213
|
+
## TUI layout
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
── scrollback (selectable, copy/pasteable) ──
|
|
217
|
+
user ← prior turns rendered into <Static>
|
|
218
|
+
assistant ← so they live in normal terminal scrollback
|
|
219
|
+
← tool: ok ← tool results
|
|
220
|
+
...
|
|
221
|
+
── dynamic frame (pinned to bottom) ──
|
|
222
|
+
assistant ← currently-streaming message (rebuilds on
|
|
223
|
+
… every chunk; rich markdown on finalize)
|
|
224
|
+
○ task one ← agent task list, hidden when empty / all done
|
|
225
|
+
◐ task two
|
|
226
|
+
● task three
|
|
227
|
+
→ bash(npm test) ← running tool indicator
|
|
228
|
+
queued (2): ← prompts you typed while busy
|
|
229
|
+
→ run the tests again
|
|
230
|
+
→ and commit
|
|
231
|
+
> _ ← your prompt input
|
|
232
|
+
deepseek-v4-pro · $0.012 ▲1.4K (h:1.1K m:300) ▼820 ctx:9.2K 0:34
|
|
233
|
+
↑ status bar (model · cost · in/out tokens · cache hit/miss · ctx · timer)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The streaming current-turn renders plain text so re-renders stay cheap;
|
|
237
|
+
once the turn finishes it moves into `<Static>` and gets the full
|
|
238
|
+
markdown / table / code-block rendering. Approvals appear as their own
|
|
239
|
+
modal-style yellow-bordered box; the prompt is greyed out underneath
|
|
240
|
+
until you answer.
|
|
241
|
+
|
|
242
|
+
## Slash commands
|
|
243
|
+
|
|
244
|
+
Available in both the TUI and the `--repl` REPL. Type `/` and TAB cycles
|
|
245
|
+
through completions.
|
|
210
246
|
|
|
211
247
|
| Command | What it does |
|
|
212
248
|
|---|---|
|
|
@@ -215,19 +251,28 @@ dsc --resume <id> # resume a specific session id
|
|
|
215
251
|
| `/model [name]` | Show or switch model. Available: `deepseek-v4-pro`, `deepseek-v4-flash`. |
|
|
216
252
|
| `/yolo` | Toggle approval mode (write/edit/bash/web_fetch). |
|
|
217
253
|
| `/reasoning [on\|off]` | Show/hide `reasoning_content` from thinking models. Default on. |
|
|
254
|
+
| `/lang [name\|off]` | Force the model to reply exclusively in a named language. |
|
|
255
|
+
| `/auto-continue [N\|off]` | When the agent hits the per-turn tool-call cap, auto-grant up to N extra 24-call budgets. |
|
|
218
256
|
| `/list` | List sessions in the current cwd. The active session is marked with `*`. |
|
|
219
|
-
| `/resume <#\|id\|last>` | Resume a session by index (from `/list`), id, or `last`. |
|
|
220
|
-
| `/
|
|
257
|
+
| `/resume <#\|id\|name\|last>` | Resume a session by index (from `/list`), id, name, or `last`. |
|
|
258
|
+
| `/save <name>` | Name the current session. Show up in `/list` by name. |
|
|
259
|
+
| `/rename <text>` | Override the "assistant:" label for the current session. |
|
|
260
|
+
| `/queue [clear]` | List or clear the type-ahead queue. |
|
|
261
|
+
| `/audit [path\|show N]` | Print the audit log path, or show the last N entries. |
|
|
221
262
|
| `/transcript` | Print the full conversation, including any messages compaction archived. |
|
|
222
263
|
| `/compact [N]` | Summarize older turns into a synthetic block (kept in the system prompt) and move them to the archive. Keeps the last `N` user turns verbatim (default 4). Cumulative across re-runs. |
|
|
223
264
|
| `/edit [text]` | Open `$VISUAL`/`$EDITOR`/`vi` on a tmp file; the saved content runs as the next prompt. |
|
|
265
|
+
| `/version` | Print version (dsc, Node, platform/arch). |
|
|
266
|
+
| `/help` | Show the in-app help. |
|
|
224
267
|
| `/exit` | Quit. |
|
|
225
268
|
|
|
226
269
|
### Multi-line input
|
|
227
270
|
|
|
228
271
|
End a line with a single `\` to continue on the next line (bash-style).
|
|
229
|
-
`\\` is treated as a literal trailing backslash.
|
|
230
|
-
|
|
272
|
+
`\\` is treated as a literal trailing backslash. The TUI renders the
|
|
273
|
+
accumulated buffer above the active prompt dim with a `… ` marker so
|
|
274
|
+
you can see what's queued. ESC cancels the buffer. For longer or
|
|
275
|
+
paste-heavy drafts, use `/edit`.
|
|
231
276
|
|
|
232
277
|
```
|
|
233
278
|
> please write a function\
|
|
@@ -237,9 +282,18 @@ drafts, use `/edit`.
|
|
|
237
282
|
|
|
238
283
|
### Hotkeys
|
|
239
284
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
prompts (persisted across sessions).
|
|
285
|
+
| Key | Where | What |
|
|
286
|
+
|---|---|---|
|
|
287
|
+
| `Up` / `Down` | Prompt | Recall past prompts (persisted across sessions and across TUI ↔ REPL). |
|
|
288
|
+
| `Tab` | Prompt | Complete a partial `/slash` command. |
|
|
289
|
+
| `Ctrl+A` / `Ctrl+E` | Prompt | Cursor to start / end of line. |
|
|
290
|
+
| `Ctrl+U` / `Ctrl+K` | Prompt | Delete to start / end of line. |
|
|
291
|
+
| `Ctrl+W` | Prompt | Delete the word before the cursor. |
|
|
292
|
+
| `ESC` | Turn busy | Abort the in-flight turn. |
|
|
293
|
+
| `ESC` | Approval | Reject the pending tool call (same as `n`). |
|
|
294
|
+
| `ESC` | Multiline | Clear the accumulated backslash-continuation buffer. |
|
|
295
|
+
| `Ctrl+C` | Turn busy | Abort the in-flight turn. |
|
|
296
|
+
| `Ctrl+C` / `Ctrl+D` | Idle | Exit cleanly. |
|
|
243
297
|
|
|
244
298
|
### Session scoping (per-directory)
|
|
245
299
|
|
|
@@ -274,12 +328,18 @@ the archived messages from `/transcript`.
|
|
|
274
328
|
| `grep(pattern, path?, glob?, case_insensitive?)` | none | ripgrep when available, `grep -rn` fallback. |
|
|
275
329
|
| `glob(pattern, path?)` | none | Node 22+ `fs.glob`, capped at 500. |
|
|
276
330
|
| `web_search(query, count?, freshness?)` | none | Pluggable backends (Brave / Tavily / DuckDuckGo). |
|
|
331
|
+
| `task_create(subject, activeForm?)` | none | Adds a pending task to the user-visible task list. |
|
|
332
|
+
| `task_update(id, status?, subject?, activeForm?)` | none | Moves a task between pending / in_progress / completed. |
|
|
333
|
+
| `task_list()` | none | Returns the current task list with statuses. |
|
|
277
334
|
| `write_file(path, content)` | yes (unless `--yolo`) | Side-by-side diff in the prompt. |
|
|
278
335
|
| `edit_file(path, old_string, new_string, replace_all?)` | yes | Exact substring replace; old_string must be unique unless `replace_all=true`. |
|
|
279
|
-
| `bash(command, description?, timeout_ms?)` | yes | `/bin/sh
|
|
336
|
+
| `bash(command, description?, timeout_ms?)` | yes | `/bin/sh` on Linux/macOS, `cmd.exe` on Windows. Output capped at 16 KB. |
|
|
280
337
|
| `web_fetch(url)` | yes | HTML stripped to text, capped at 50 KB. |
|
|
281
338
|
|
|
282
|
-
Read-only tools never prompt. The rest do unless `--yolo` is on.
|
|
339
|
+
Read-only tools never prompt. The rest do unless `--yolo` is on. The
|
|
340
|
+
`task_*` tools mutate an in-memory list that the TUI renders above the
|
|
341
|
+
prompt; the model is encouraged (via the system prompt) to reach for
|
|
342
|
+
them on non-trivial multi-step asks so the user sees real-time progress.
|
|
283
343
|
|
|
284
344
|
## Sessions and history
|
|
285
345
|
|
|
@@ -462,21 +522,41 @@ Source layout:
|
|
|
462
522
|
|
|
463
523
|
```
|
|
464
524
|
src/
|
|
465
|
-
|
|
466
|
-
|
|
525
|
+
tui.tsx # TUI entry: arg parsing, session + agent wiring, slash dispatcher
|
|
526
|
+
index.ts # readline REPL entry (--repl)
|
|
527
|
+
agent.ts # tool-call loop, AgentEvents emitter, repair logic
|
|
467
528
|
api.ts # DeepSeek client, retry/abort, prompt cache rates
|
|
468
|
-
tools.ts # tool schemas + executors (read/write/edit/bash/grep/glob/web_*)
|
|
469
|
-
approval.ts # confirmWrite/Edit/Bash/Fetch
|
|
529
|
+
tools.ts # tool schemas + executors (read/write/edit/bash/grep/glob/web_*/task_*)
|
|
530
|
+
approval.ts # confirmWrite/Edit/Bash/Fetch — pluggable asker
|
|
470
531
|
audit.ts # JSONL audit logger
|
|
471
532
|
search.ts # Brave / Tavily / DDG dispatch
|
|
472
533
|
compact.ts # /compact summarization routine
|
|
473
534
|
history.ts # session save/load/list/migrate-legacy
|
|
474
|
-
repl_history.ts # ~/.local/state/dsc/history reader/writer
|
|
475
|
-
markdown.ts # streaming markdown→ANSI renderer
|
|
476
|
-
ui.ts # Spinner with stall detection;
|
|
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
|
|
477
538
|
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)
|
|
541
|
+
store.ts # TUI pub/sub state container (history, agentTasks, queue, etc.)
|
|
542
|
+
tui/
|
|
543
|
+
App.tsx # root layout
|
|
544
|
+
History.tsx # <Static> for finalized turns
|
|
545
|
+
CurrentTurn.tsx # in-progress streaming message
|
|
546
|
+
Markdown.tsx # markdown → ink Text-tree (incl. tables)
|
|
547
|
+
AgentTaskList.tsx # bullets above the prompt
|
|
548
|
+
QueuedPrompts.tsx # dim list of pending submissions
|
|
549
|
+
TaskLine.tsx # "→ tool(...)" indicator while a tool runs
|
|
550
|
+
StatusBar.tsx # full-width inverse-video status line
|
|
551
|
+
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
|
|
554
|
+
useStore.ts # selector + equality hook over store.ts
|
|
478
555
|
```
|
|
479
556
|
|
|
480
|
-
The `
|
|
481
|
-
|
|
482
|
-
|
|
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.
|
package/bin/dsc.mjs
CHANGED
|
@@ -11,8 +11,18 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
11
11
|
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
|
-
|
|
15
|
-
|
|
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
|
+
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`);
|
|
16
26
|
|
|
17
27
|
const tsxAvailable = existsSync(tsxBin) || existsSync(tsxBinCmd);
|
|
18
28
|
|
|
@@ -23,7 +33,7 @@ if (tsxAvailable && existsSync(srcEntry)) {
|
|
|
23
33
|
// might contain spaces (e.g. paths in C:\Program Files\...).
|
|
24
34
|
const child = spawn(
|
|
25
35
|
process.platform === "win32" ? tsxBinCmd : tsxBin,
|
|
26
|
-
[srcEntry, ...
|
|
36
|
+
[srcEntry, ...filteredArgv],
|
|
27
37
|
{ stdio: "inherit", shell: process.platform === "win32" },
|
|
28
38
|
);
|
|
29
39
|
child.on("exit", (code, signal) => {
|
package/dist/agent.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { chatStream, computeCostUsd, recordUsage, } from "./api.js";
|
|
2
3
|
import { READ_ONLY_TOOLS, TOOL_SCHEMAS, executeTool } from "./tools.js";
|
|
3
4
|
import { Spinner } from "./ui.js";
|
|
@@ -13,7 +14,36 @@ const BOLD = "\x1b[1m";
|
|
|
13
14
|
const ITALIC = "\x1b[3m";
|
|
14
15
|
const RED = "\x1b[31m";
|
|
15
16
|
const RESET = "\x1b[0m";
|
|
16
|
-
function streamHandlers(spinner, showReasoning, assistantLabel) {
|
|
17
|
+
function streamHandlers(spinner, showReasoning, assistantLabel, events, turnId) {
|
|
18
|
+
// Event-based path: emit structured events; do not touch stdout.
|
|
19
|
+
if (events) {
|
|
20
|
+
let started = false;
|
|
21
|
+
return {
|
|
22
|
+
onContent: (text) => {
|
|
23
|
+
spinner.bump();
|
|
24
|
+
if (!started) {
|
|
25
|
+
events.onAssistantStart(turnId);
|
|
26
|
+
started = true;
|
|
27
|
+
}
|
|
28
|
+
events.onAssistantContent(turnId, text);
|
|
29
|
+
},
|
|
30
|
+
onReasoning: (text) => {
|
|
31
|
+
spinner.bump();
|
|
32
|
+
if (!showReasoning)
|
|
33
|
+
return;
|
|
34
|
+
if (!started) {
|
|
35
|
+
events.onAssistantStart(turnId);
|
|
36
|
+
started = true;
|
|
37
|
+
}
|
|
38
|
+
events.onAssistantReasoning(turnId, text);
|
|
39
|
+
},
|
|
40
|
+
flush: () => {
|
|
41
|
+
// Finalization is signaled by onAssistantFinal from runAgent — there's
|
|
42
|
+
// no "flush at end of stream" event needed for the events path.
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Stdout path (REPL): existing terminal-rendering behavior.
|
|
17
47
|
let contentStarted = false;
|
|
18
48
|
let reasoningStarted = false;
|
|
19
49
|
const renderer = new MarkdownRenderer();
|
|
@@ -57,12 +87,14 @@ function streamHandlers(spinner, showReasoning, assistantLabel) {
|
|
|
57
87
|
};
|
|
58
88
|
}
|
|
59
89
|
export async function runAgent(opts) {
|
|
60
|
-
const { messages, model, stats, toolCtx, signal, onTurn } = opts;
|
|
90
|
+
const { messages, model, stats, toolCtx, signal, onTurn, events } = opts;
|
|
61
91
|
const showReasoning = opts.showReasoning ?? true;
|
|
62
92
|
const assistantLabel = opts.assistantLabel ?? "assistant:";
|
|
63
93
|
// Build the message list to send: drop any leading system entry the caller
|
|
64
94
|
// may have stashed (e.g. from an older session) and prepend a freshly-built
|
|
65
|
-
// one so cwd/date/
|
|
95
|
+
// one so cwd/date/summary/language reflect the current turn. The system
|
|
96
|
+
// prompt is intentionally byte-stable within a session so DeepSeek's
|
|
97
|
+
// prefix cache extends through it and into the message history.
|
|
66
98
|
const conversationMessages = () => messages[0]?.role === "system" ? messages.slice(1) : messages.slice();
|
|
67
99
|
const buildApi = () => [
|
|
68
100
|
{
|
|
@@ -70,7 +102,6 @@ export async function runAgent(opts) {
|
|
|
70
102
|
content: buildSystemPrompt({
|
|
71
103
|
cwd: toolCtx.cwd,
|
|
72
104
|
date: new Date(),
|
|
73
|
-
statusLine: opts.getStatusLine?.(),
|
|
74
105
|
summary: opts.getSummary?.(),
|
|
75
106
|
language: opts.language,
|
|
76
107
|
}),
|
|
@@ -87,8 +118,12 @@ export async function runAgent(opts) {
|
|
|
87
118
|
for (let depth = 0; depth < MAX_TOOL_DEPTH; depth++) {
|
|
88
119
|
stats.prompts += 1;
|
|
89
120
|
const spinner = new Spinner("thinking");
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
// In events mode, the TUI shows its own busy indicator; avoid the
|
|
122
|
+
// terminal-control codes the spinner emits.
|
|
123
|
+
if (!events)
|
|
124
|
+
spinner.start();
|
|
125
|
+
const turnId = randomUUID();
|
|
126
|
+
const handlers = streamHandlers(spinner, showReasoning, assistantLabel, events, turnId);
|
|
92
127
|
let resp;
|
|
93
128
|
try {
|
|
94
129
|
resp = await chatStream({
|
|
@@ -114,6 +149,11 @@ export async function runAgent(opts) {
|
|
|
114
149
|
if (msg.tool_calls && msg.tool_calls.length)
|
|
115
150
|
assistantMsg.tool_calls = msg.tool_calls;
|
|
116
151
|
messages.push(assistantMsg);
|
|
152
|
+
events?.onAssistantFinal(turnId, {
|
|
153
|
+
content,
|
|
154
|
+
reasoning: msg.reasoning_content,
|
|
155
|
+
tool_calls: msg.tool_calls,
|
|
156
|
+
});
|
|
117
157
|
onTurn?.(); // status reflects the just-pushed assistant message
|
|
118
158
|
if (!msg.tool_calls || msg.tool_calls.length === 0) {
|
|
119
159
|
return;
|
|
@@ -123,13 +163,18 @@ export async function runAgent(opts) {
|
|
|
123
163
|
const call = toolCalls[i];
|
|
124
164
|
const name = call.function.name;
|
|
125
165
|
const argsRaw = call.function.arguments ?? "{}";
|
|
126
|
-
|
|
166
|
+
if (events) {
|
|
167
|
+
events.onToolStart(call.id, name, argsRaw);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
process.stdout.write(`${DIM}→ ${name}(${truncate(argsRaw, 200)})${RESET}\n`);
|
|
171
|
+
}
|
|
127
172
|
stats.tool_calls_total += 1;
|
|
128
173
|
stats.tool_calls_by_name[name] = (stats.tool_calls_by_name[name] ?? 0) + 1;
|
|
129
174
|
const toolSpinner = new Spinner(`running ${name}`);
|
|
130
175
|
// Don't spin tools that need approval (interactive prompt).
|
|
131
176
|
const interactive = !READ_ONLY_TOOLS.has(name) && !toolCtx.yolo;
|
|
132
|
-
if (!interactive)
|
|
177
|
+
if (!interactive && !events)
|
|
133
178
|
toolSpinner.start();
|
|
134
179
|
let result;
|
|
135
180
|
let throwAfter = null;
|
|
@@ -158,8 +203,13 @@ export async function runAgent(opts) {
|
|
|
158
203
|
content: result.content,
|
|
159
204
|
});
|
|
160
205
|
onTurn?.(); // status reflects the tool result we just recorded
|
|
161
|
-
|
|
162
|
-
|
|
206
|
+
if (events) {
|
|
207
|
+
events.onToolEnd(call.id, name, result.content, !!result.rejected);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const lead = result.content.startsWith("error:") || result.rejected ? RED : DIM;
|
|
211
|
+
process.stdout.write(`${lead} ${truncate(result.content, 400)}${RESET}\n`);
|
|
212
|
+
}
|
|
163
213
|
if (throwAfter) {
|
|
164
214
|
// Stub-fill any remaining tool_calls before propagating, otherwise
|
|
165
215
|
// the persisted history will still 400 on the next turn.
|
|
@@ -179,16 +229,28 @@ export async function runAgent(opts) {
|
|
|
179
229
|
// whether to grant another budget or stop here.
|
|
180
230
|
if (autoContinues < maxAutoContinue) {
|
|
181
231
|
autoContinues++;
|
|
182
|
-
|
|
232
|
+
const text = `── auto-continue ${autoContinues}/${maxAutoContinue} (${MAX_TOOL_DEPTH * autoContinues} tool calls so far; granting another ${MAX_TOOL_DEPTH})`;
|
|
233
|
+
if (events) {
|
|
234
|
+
events.onNotice(text);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
process.stdout.write(`${DIM}${text}${RESET}\n`);
|
|
238
|
+
}
|
|
183
239
|
continue budgetLoop;
|
|
184
240
|
}
|
|
185
241
|
break budgetLoop;
|
|
186
242
|
}
|
|
187
243
|
// Either auto-continue was off or its budget is exhausted.
|
|
188
244
|
const totalCalls = MAX_TOOL_DEPTH * (autoContinues + 1);
|
|
189
|
-
|
|
190
|
-
?
|
|
191
|
-
:
|
|
245
|
+
const stopText = autoContinues > 0
|
|
246
|
+
? `(stopping after ${autoContinues} auto-continue(s) at ${totalCalls} total tool calls. Send 'continue' to give the agent another budget.)`
|
|
247
|
+
: `(reached MAX_TOOL_DEPTH=${MAX_TOOL_DEPTH}; stopping. Send 'continue' to grant another budget, or set DSC_AUTO_CONTINUE=N / run /auto-continue N to do this automatically.)`;
|
|
248
|
+
if (events) {
|
|
249
|
+
events.onNotice(stopText);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
process.stdout.write(`${DIM}${stopText}${RESET}\n`);
|
|
253
|
+
}
|
|
192
254
|
onTurn?.();
|
|
193
255
|
}
|
|
194
256
|
export function formatCost(stats, model) {
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sour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,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,CAAC,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/editor.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import * as os from "node:os";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
/**
|
|
6
|
+
* Open $VISUAL / $EDITOR (defaulting to `vi`) on a temporary file seeded with
|
|
7
|
+
* `initial`. Returns the saved contents with trailing newlines trimmed, or
|
|
8
|
+
* `null` if the editor failed to launch or read failed.
|
|
9
|
+
*
|
|
10
|
+
* The editor runs with inherited stdio, so the calling process must release
|
|
11
|
+
* the terminal first (e.g. the ink TUI must unmount before calling this).
|
|
12
|
+
*/
|
|
13
|
+
export function openEditor(initial) {
|
|
14
|
+
const editor = process.env.VISUAL || process.env.EDITOR || "vi";
|
|
15
|
+
const tmpDir = mkdtempSync(path.join(os.tmpdir(), "dsc-edit-"));
|
|
16
|
+
const tmpFile = path.join(tmpDir, "prompt.md");
|
|
17
|
+
try {
|
|
18
|
+
writeFileSync(tmpFile, initial, "utf8");
|
|
19
|
+
const r = spawnSync(editor, [tmpFile], { stdio: "inherit" });
|
|
20
|
+
if (r.error)
|
|
21
|
+
return null;
|
|
22
|
+
const content = readFileSync(tmpFile, "utf8");
|
|
23
|
+
return content.replace(/\n+$/, "");
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
try {
|
|
30
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// best-effort
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC;IAChE,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,cAAc;QAChB,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as readline from "node:readline/promises";
|
|
2
2
|
import { stdin as input, stdout as output } from "node:process";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
3
|
import { promises as fsp } from "node:fs";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import { openEditor } from "./editor.js";
|
|
5
|
+
import { completeSlash } from "./slash.js";
|
|
8
6
|
import { AVAILABLE_MODELS, DEFAULT_MODEL, DeepSeekError, configPath, hasApiKey, recordUsage, } from "./api.js";
|
|
9
7
|
import { runAgent, formatCost, formatStatus, estimateContextTokens } from "./agent.js";
|
|
10
8
|
import * as history from "./history.js";
|
|
@@ -314,7 +312,6 @@ async function main() {
|
|
|
314
312
|
void persist();
|
|
315
313
|
},
|
|
316
314
|
showReasoning,
|
|
317
|
-
getStatusLine: currentStatusLine,
|
|
318
315
|
getSummary: () => session.compaction?.summary,
|
|
319
316
|
assistantLabel: session.assistantLabel,
|
|
320
317
|
maxAutoContinue: autoContinue,
|
|
@@ -843,38 +840,10 @@ function summarizeAuditEntry(e) {
|
|
|
843
840
|
// Slash commands the REPL recognizes. Used both for tab completion and as
|
|
844
841
|
// a single source of truth for what's accepted (kept in sync with the if/
|
|
845
842
|
// else chain in main()).
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
"auto-continue",
|
|
849
|
-
"clear",
|
|
850
|
-
"compact",
|
|
851
|
-
"cost",
|
|
852
|
-
"edit",
|
|
853
|
-
"exit",
|
|
854
|
-
"help",
|
|
855
|
-
"lang",
|
|
856
|
-
"list",
|
|
857
|
-
"model",
|
|
858
|
-
"queue",
|
|
859
|
-
"quit",
|
|
860
|
-
"reasoning",
|
|
861
|
-
"rename",
|
|
862
|
-
"resume",
|
|
863
|
-
"save",
|
|
864
|
-
"transcript",
|
|
865
|
-
"version",
|
|
866
|
-
"yolo",
|
|
867
|
-
];
|
|
868
|
-
// readline-style completer: returns [matches, substringMatched]. We complete
|
|
869
|
-
// the slash-command name only; subcommand args (e.g. /resume <name>) are not
|
|
870
|
-
// completed yet — keep it simple and predictable.
|
|
843
|
+
// readline-style completer: returns [matches, substringMatched]. Backs into
|
|
844
|
+
// the shared completeSlash helper so the REPL and TUI complete the same set.
|
|
871
845
|
function completeSlashCommand(line) {
|
|
872
|
-
|
|
873
|
-
return [[], line];
|
|
874
|
-
const partial = line.slice(1);
|
|
875
|
-
if (partial.includes(" "))
|
|
876
|
-
return [[], line]; // past the command word
|
|
877
|
-
const matches = SLASH_COMMANDS.filter((c) => c.startsWith(partial)).map((c) => "/" + c);
|
|
846
|
+
const { matches } = completeSlash(line);
|
|
878
847
|
return [matches, line];
|
|
879
848
|
}
|
|
880
849
|
function renderTranscriptMessage(m, archived) {
|
|
@@ -940,30 +909,6 @@ async function readPromptInput(rl) {
|
|
|
940
909
|
* Empty/whitespace-only results are returned as "" so the caller can decide
|
|
941
910
|
* whether to skip the turn.
|
|
942
911
|
*/
|
|
943
|
-
function openEditor(initial) {
|
|
944
|
-
const editor = process.env.VISUAL || process.env.EDITOR || "vi";
|
|
945
|
-
const tmpDir = mkdtempSync(path.join(os.tmpdir(), "dsc-edit-"));
|
|
946
|
-
const tmpFile = path.join(tmpDir, "prompt.md");
|
|
947
|
-
try {
|
|
948
|
-
writeFileSync(tmpFile, initial, "utf8");
|
|
949
|
-
const r = spawnSync(editor, [tmpFile], { stdio: "inherit" });
|
|
950
|
-
if (r.error)
|
|
951
|
-
return null;
|
|
952
|
-
const content = readFileSync(tmpFile, "utf8");
|
|
953
|
-
return content.replace(/\n+$/, "");
|
|
954
|
-
}
|
|
955
|
-
catch {
|
|
956
|
-
return null;
|
|
957
|
-
}
|
|
958
|
-
finally {
|
|
959
|
-
try {
|
|
960
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
961
|
-
}
|
|
962
|
-
catch {
|
|
963
|
-
// best-effort
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
912
|
main().catch((e) => {
|
|
968
913
|
process.stderr.write(`${RED}fatal: ${e.message}${RESET}\n`);
|
|
969
914
|
process.exit(1);
|