@songtonyli/dsh-cli 0.1.66 → 0.1.68
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 +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +16 -19
- package/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +5 -5
- package/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +16 -19
- package/node_modules/@babel/runtime/helpers/toPrimitive.js +5 -5
- package/node_modules/@babel/runtime/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js +12 -11
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.md +3 -3
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +3 -3
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/exec-shim.js +26 -34
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/index.js +118 -57
- package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +3 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +3 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +955 -567
- package/package.json +2 -2
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { accessSync, constants, existsSync,
|
|
1
|
+
import { accessSync, constants, existsSync, statSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
2
3
|
import { delimiter, isAbsolute, join } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import z from "@deepseek-ai/schemastery";
|
|
5
6
|
import { z as z$1 } from "zod";
|
|
6
7
|
import { CommandDefinitionId } from "@deepseek-ai/dsh-commands/brand";
|
|
7
|
-
import { SandboxUnavailableError, canonicalPath,
|
|
8
|
+
import { SandboxUnavailableError, canonicalPath, nameGlobMatcher } from "@deepseek-ai/dsh-sandbox";
|
|
8
9
|
import { LocalSandboxProvider } from "@deepseek-ai/dsh-sandbox-local";
|
|
9
10
|
import { createHash } from "node:crypto";
|
|
11
|
+
import { mkdir, readdir, rm } from "node:fs/promises";
|
|
10
12
|
import { execFile } from "node:child_process";
|
|
11
13
|
//#region lib/types/secrets.js
|
|
12
14
|
/**
|
|
@@ -18,29 +20,54 @@ import { execFile } from "node:child_process";
|
|
|
18
20
|
*/
|
|
19
21
|
/**
|
|
20
22
|
* Find files and symlinks under `root` whose name matches a hidden-name glob,
|
|
21
|
-
* without following symlinked directories.
|
|
23
|
+
* without following symlinked directories. Sibling directories are read
|
|
24
|
+
* concurrently, so the scan never blocks the event loop on a large workspace.
|
|
22
25
|
* @param root - the canonical workspace root.
|
|
23
26
|
* @param scan - names, depth, and skipped directory names.
|
|
24
|
-
* @returns absolute paths in
|
|
27
|
+
* @returns absolute paths in sorted order; unreadable directories are skipped.
|
|
25
28
|
*/
|
|
26
|
-
function findHiddenFiles(root, scan) {
|
|
29
|
+
async function findHiddenFiles(root, scan) {
|
|
30
|
+
const hidden = nameGlobMatcher(scan.names);
|
|
27
31
|
const found = [];
|
|
28
|
-
const walk = (dir, depth) => {
|
|
32
|
+
const walk = async (dir, depth) => {
|
|
29
33
|
let entries;
|
|
30
34
|
try {
|
|
31
|
-
entries =
|
|
35
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
32
36
|
} catch {
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
39
|
+
const children = [];
|
|
35
40
|
for (const entry of entries) {
|
|
36
41
|
const path = join(dir, entry.name);
|
|
37
42
|
if (entry.isDirectory()) {
|
|
38
|
-
if (depth < scan.maxDepth && !scan.skipDirs.includes(entry.name)) walk(path, depth + 1);
|
|
39
|
-
} else if (
|
|
43
|
+
if (depth < scan.maxDepth && !scan.skipDirs.includes(entry.name)) children.push(walk(path, depth + 1));
|
|
44
|
+
} else if (hidden(entry.name)) found.push(path);
|
|
40
45
|
}
|
|
46
|
+
await Promise.all(children);
|
|
41
47
|
};
|
|
42
|
-
walk(root, 0);
|
|
43
|
-
return found;
|
|
48
|
+
await walk(root, 0);
|
|
49
|
+
return found.sort();
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region lib/types/shim.js
|
|
53
|
+
/** Prefix of the single stderr line the shim writes for {@link SHIM_FAILURE_EXIT}. */
|
|
54
|
+
const SHIM_FAILURE_PREFIX = "dsh-container-exec: ";
|
|
55
|
+
/** Guest path of each container's run directory, a writable bind mount of a host directory. */
|
|
56
|
+
const GUEST_RUN_DIR = "/run/dsh";
|
|
57
|
+
/**
|
|
58
|
+
* Encode a shim invocation as the argument list that follows the shim entry.
|
|
59
|
+
* @param args - the invocation; denylist entries are environment names and never contain commas.
|
|
60
|
+
* @returns `[executable, container, runDir, denylist, '--', ...argv]`.
|
|
61
|
+
*/
|
|
62
|
+
function encodeShimArgs(args) {
|
|
63
|
+
return [
|
|
64
|
+
args.executable,
|
|
65
|
+
args.container,
|
|
66
|
+
args.runDir,
|
|
67
|
+
args.denylist.join(","),
|
|
68
|
+
"--",
|
|
69
|
+
...args.argv
|
|
70
|
+
];
|
|
44
71
|
}
|
|
45
72
|
//#endregion
|
|
46
73
|
//#region lib/types/pool.js
|
|
@@ -51,12 +78,16 @@ function findHiddenFiles(root, scan) {
|
|
|
51
78
|
* that differs; `read-only` mounts it read-only, and `workspace-write` mounts
|
|
52
79
|
* its protected directories (such as `.git`) read-only. Extra read-only
|
|
53
80
|
* directories are mounted at their own paths, and hidden files found at start
|
|
54
|
-
* are masked.
|
|
55
|
-
*
|
|
81
|
+
* are masked. Each container also mounts a private host run directory, named
|
|
82
|
+
* after the container, writable at {@link GUEST_RUN_DIR} for the exec shim's
|
|
83
|
+
* start sentinels. A cached container is re-inspected at most once per
|
|
84
|
+
* `recheckMs` and restarted when gone or when its run directory is gone.
|
|
56
85
|
* @module @deepseek-ai/dsh-sandbox-apple-container/pool
|
|
57
86
|
*/
|
|
58
87
|
/** Label naming the owning DSH process id. */
|
|
59
88
|
const PID_LABEL = "dsh.pid";
|
|
89
|
+
/** Owned container names: a workspace-and-mode hash and the owning process id. */
|
|
90
|
+
const CONTAINER_NAME = /^dsh-[0-9a-f]{12}-(\d+)$/u;
|
|
60
91
|
/** Whether `path` is an existing directory. */
|
|
61
92
|
function isDirectory(path) {
|
|
62
93
|
return statSync(path, { throwIfNoEntry: false })?.isDirectory() === true;
|
|
@@ -71,32 +102,37 @@ var ContainerPool = class {
|
|
|
71
102
|
this.options = options;
|
|
72
103
|
}
|
|
73
104
|
/**
|
|
74
|
-
* Return
|
|
75
|
-
*
|
|
105
|
+
* Return a running container for `policy`, starting one when none is cached
|
|
106
|
+
* or the cached one is gone. Concurrent callers share one start.
|
|
76
107
|
* @param policy - the confined mode and workspace root.
|
|
77
|
-
* @returns the container
|
|
78
|
-
* @throws {Error} when the root cannot be mounted or the runtime fails.
|
|
108
|
+
* @returns the container's entry.
|
|
109
|
+
* @throws {Error} when the root or run directory cannot be mounted or the runtime fails.
|
|
79
110
|
*/
|
|
80
111
|
async ensure(policy) {
|
|
81
112
|
const root = canonicalPath(policy.workspaceRoot);
|
|
82
113
|
if (root.includes(",") || policy.workspaceRoot.includes(",")) throw new Error(`workspace root ${JSON.stringify(policy.workspaceRoot)} contains a comma, which \`container --mount\` cannot express`);
|
|
114
|
+
if (this.options.runRoot.includes(",")) throw new Error(`container run directory ${JSON.stringify(this.options.runRoot)} contains a comma, which \`container --mount\` cannot express; set TMPDIR to a path without one`);
|
|
83
115
|
const key = `${policy.mode}\0${root}`;
|
|
84
116
|
const now = this.options.now();
|
|
85
117
|
let slot = this.slots.get(key);
|
|
86
118
|
if (slot === void 0) {
|
|
87
119
|
const name = `dsh-${createHash("sha256").update(key).digest("hex").slice(0, 12)}-${this.options.pid}`;
|
|
88
|
-
|
|
120
|
+
const entry = {
|
|
89
121
|
mode: policy.mode,
|
|
90
122
|
root,
|
|
91
123
|
name,
|
|
124
|
+
runDir: join(this.options.runRoot, name)
|
|
125
|
+
};
|
|
126
|
+
slot = {
|
|
127
|
+
...entry,
|
|
92
128
|
checkedAt: now,
|
|
93
|
-
ready: this.start(
|
|
129
|
+
ready: this.start(entry, policy.workspaceRoot)
|
|
94
130
|
};
|
|
95
131
|
this.slots.set(key, slot);
|
|
96
132
|
} else if (now - slot.checkedAt >= this.options.recheckMs) {
|
|
97
|
-
const
|
|
133
|
+
const entry = slot;
|
|
98
134
|
slot.checkedAt = now;
|
|
99
|
-
slot.ready = slot.ready.then(() => this.
|
|
135
|
+
slot.ready = slot.ready.then(() => this.recheck(entry, policy.workspaceRoot));
|
|
100
136
|
}
|
|
101
137
|
try {
|
|
102
138
|
await slot.ready;
|
|
@@ -104,42 +140,77 @@ var ContainerPool = class {
|
|
|
104
140
|
if (this.slots.get(key) === slot) this.slots.delete(key);
|
|
105
141
|
throw error;
|
|
106
142
|
}
|
|
107
|
-
return
|
|
143
|
+
return {
|
|
144
|
+
mode: slot.mode,
|
|
145
|
+
root: slot.root,
|
|
146
|
+
name: slot.name,
|
|
147
|
+
runDir: slot.runDir
|
|
148
|
+
};
|
|
108
149
|
}
|
|
109
150
|
/**
|
|
110
151
|
* Every owned container.
|
|
111
152
|
* @returns the entries in first-start order.
|
|
112
153
|
*/
|
|
113
154
|
entries() {
|
|
114
|
-
return [...this.slots.values()].map(({ mode, root, name }) => ({
|
|
155
|
+
return [...this.slots.values()].map(({ mode, root, name, runDir }) => ({
|
|
115
156
|
mode,
|
|
116
157
|
root,
|
|
117
|
-
name
|
|
158
|
+
name,
|
|
159
|
+
runDir
|
|
118
160
|
}));
|
|
119
161
|
}
|
|
120
162
|
/**
|
|
121
|
-
* Delete containers left by DSH processes that no longer exist.
|
|
163
|
+
* Delete containers and run directories left by DSH processes that no longer exist.
|
|
122
164
|
* @param isAlive - whether a process id names a live process.
|
|
123
165
|
*/
|
|
124
166
|
async sweep(isAlive) {
|
|
125
|
-
const stale = (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
167
|
+
const stale = (pid) => Number.isSafeInteger(pid) && pid > 0 && pid !== this.options.pid && !isAlive(pid);
|
|
168
|
+
const containers = (await this.runtime.list()).filter((container) => stale(Number(container.labels[PID_LABEL])));
|
|
169
|
+
await Promise.all(containers.map((container) => this.runtime.remove(container.id)));
|
|
170
|
+
let runDirs;
|
|
171
|
+
try {
|
|
172
|
+
runDirs = await readdir(this.options.runRoot);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
if (error.code === "ENOENT") return;
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
const orphaned = runDirs.filter((name) => stale(Number(CONTAINER_NAME.exec(name)?.[1])));
|
|
178
|
+
await Promise.all(orphaned.map((name) => rm(join(this.options.runRoot, name), {
|
|
179
|
+
recursive: true,
|
|
180
|
+
force: true
|
|
181
|
+
})));
|
|
130
182
|
}
|
|
131
|
-
/** Delete every owned container, after any in-flight start settles. */
|
|
183
|
+
/** Delete every owned container and its run directory, after any in-flight start settles. */
|
|
132
184
|
async dispose() {
|
|
133
185
|
const slots = [...this.slots.values()];
|
|
134
186
|
this.slots.clear();
|
|
135
187
|
await Promise.allSettled(slots.map((slot) => slot.ready));
|
|
136
|
-
await Promise.all(slots.map((slot) =>
|
|
188
|
+
await Promise.all(slots.map(async (slot) => {
|
|
189
|
+
await this.runtime.remove(slot.name);
|
|
190
|
+
await rm(slot.runDir, {
|
|
191
|
+
recursive: true,
|
|
192
|
+
force: true
|
|
193
|
+
});
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Inspect a cached container on the command path; only one that stopped,
|
|
198
|
+
* vanished, or lost its run directory pays for a service check and start.
|
|
199
|
+
*/
|
|
200
|
+
async recheck(entry, lexical) {
|
|
201
|
+
if (isDirectory(entry.runDir) && await this.runtime.state(entry.name) === "running") return;
|
|
202
|
+
await this.start(entry, lexical);
|
|
137
203
|
}
|
|
138
|
-
async start(name, mode, root, lexical) {
|
|
204
|
+
async start({ name, mode, root, runDir }, lexical) {
|
|
205
|
+
const masks = findHiddenFiles(root, this.options.hidden);
|
|
139
206
|
await this.runtime.ensureService();
|
|
140
207
|
const state = await this.runtime.state(name);
|
|
141
|
-
if (state === "running") return;
|
|
142
|
-
if (state
|
|
208
|
+
if (state === "running" && isDirectory(runDir)) return;
|
|
209
|
+
if (state !== "missing") await this.runtime.remove(name);
|
|
210
|
+
await mkdir(runDir, {
|
|
211
|
+
recursive: true,
|
|
212
|
+
mode: 448
|
|
213
|
+
});
|
|
143
214
|
const spellings = (path) => lexical === root ? [path] : [path, join(lexical, path.slice(root.length))];
|
|
144
215
|
const bind = (source, readonly) => spellings(source).map((target) => ({
|
|
145
216
|
source,
|
|
@@ -164,9 +235,14 @@ var ContainerPool = class {
|
|
|
164
235
|
target,
|
|
165
236
|
readonly: true
|
|
166
237
|
})) : [];
|
|
167
|
-
})
|
|
238
|
+
}),
|
|
239
|
+
{
|
|
240
|
+
source: runDir,
|
|
241
|
+
target: GUEST_RUN_DIR,
|
|
242
|
+
readonly: false
|
|
243
|
+
}
|
|
168
244
|
],
|
|
169
|
-
maskedPaths:
|
|
245
|
+
maskedPaths: (await masks).flatMap(spellings)
|
|
170
246
|
});
|
|
171
247
|
}
|
|
172
248
|
};
|
|
@@ -366,24 +442,6 @@ function setSandboxBackend(session, backend) {
|
|
|
366
442
|
session.append("sandbox/backend", { backend });
|
|
367
443
|
}
|
|
368
444
|
//#endregion
|
|
369
|
-
//#region lib/types/shim.js
|
|
370
|
-
/** Prefix of the single stderr line the shim writes for {@link SHIM_FAILURE_EXIT}. */
|
|
371
|
-
const SHIM_FAILURE_PREFIX = "dsh-container-exec: ";
|
|
372
|
-
/**
|
|
373
|
-
* Encode a shim invocation as the argument list that follows the shim entry.
|
|
374
|
-
* @param args - the invocation; denylist entries are environment names and never contain commas.
|
|
375
|
-
* @returns `[executable, container, denylist, '--', ...argv]`.
|
|
376
|
-
*/
|
|
377
|
-
function encodeShimArgs(args) {
|
|
378
|
-
return [
|
|
379
|
-
args.executable,
|
|
380
|
-
args.container,
|
|
381
|
-
args.denylist.join(","),
|
|
382
|
-
"--",
|
|
383
|
-
...args.argv
|
|
384
|
-
];
|
|
385
|
-
}
|
|
386
|
-
//#endregion
|
|
387
445
|
//#region lib/types/index.js
|
|
388
446
|
/**
|
|
389
447
|
* Apple container sandbox backend. Registers as `ctx.sandbox` and routes each
|
|
@@ -562,7 +620,8 @@ var AppleContainerSandboxProvider = class extends LocalSandboxProvider {
|
|
|
562
620
|
names: this.hiddenFiles,
|
|
563
621
|
maxDepth: config.hiddenFilesMaxDepth,
|
|
564
622
|
skipDirs: config.hiddenFilesSkipDirs
|
|
565
|
-
}
|
|
623
|
+
},
|
|
624
|
+
runRoot: join(canonicalPath(tmpdir()), "dsh-container-run")
|
|
566
625
|
});
|
|
567
626
|
ctx.sessionProjections.register({
|
|
568
627
|
key: "sandboxBackend",
|
|
@@ -648,10 +707,12 @@ var AppleContainerSandboxProvider = class extends LocalSandboxProvider {
|
|
|
648
707
|
throw new SandboxUnavailableError(policy.mode, `${messageOf(error)}; run /sandbox local to confine commands on this host instead`);
|
|
649
708
|
}
|
|
650
709
|
signal?.throwIfAborted();
|
|
710
|
+
const { name, runDir } = container;
|
|
651
711
|
return {
|
|
652
712
|
argv: [...shimInvocation(import.meta.url), ...encodeShimArgs({
|
|
653
713
|
executable: this.executable,
|
|
654
|
-
container,
|
|
714
|
+
container: name,
|
|
715
|
+
runDir,
|
|
655
716
|
denylist: this.envDenylist,
|
|
656
717
|
argv
|
|
657
718
|
})],
|
|
@@ -3,7 +3,7 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
3
3
|
import { FsError } from "@deepseek-ai/dsh-fs";
|
|
4
4
|
import { readLangHintForPath as langFromPath } from "@deepseek-ai/dsh-util-code-language";
|
|
5
5
|
import { basename, extname, isAbsolute, relative, resolve } from "node:path";
|
|
6
|
-
import { ESCALATION_TARGETS, approveEscalation, escalationHintMarker, isHiddenIn, isReadableIn,
|
|
6
|
+
import { ESCALATION_TARGETS, approveEscalation, escalationHintMarker, isHiddenIn, isReadableIn, nameGlobMatcher, sandboxDenialMarker, sandboxPermissionsDescription, validateEscalationArgs } from "@deepseek-ai/dsh-sandbox";
|
|
7
7
|
import { structuredPatch } from "diff";
|
|
8
8
|
import { AttachmentError, AttachmentId } from "@deepseek-ai/dsh-attachment";
|
|
9
9
|
//#region lib/types/read-render.js
|
|
@@ -295,7 +295,7 @@ async function resolveAuthorizedReadTarget(ctx, exec, requestedPath, toolName) {
|
|
|
295
295
|
const spelledInside = !requestedPath.split(/[\\/]/u).includes("..") && scope.roots.some((root) => isLexicallyUnder(spelled, root));
|
|
296
296
|
let approved = false;
|
|
297
297
|
if (!spelledInside) {
|
|
298
|
-
if (scope.hiddenNames
|
|
298
|
+
if (nameGlobMatcher(scope.hiddenNames)(basename(spelled))) throw new FsError(hiddenMessage(requestedPath), "FS_SANDBOX_DENIED");
|
|
299
299
|
await approveOutsideRead(ctx, exec, spelled, requestedPath, toolName);
|
|
300
300
|
approved = true;
|
|
301
301
|
}
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
en: 19374746e69c8ca0
|
|
22
22
|
zh: 211dac2851029319
|
|
23
23
|
/deepseek-ai-dsh-tui-app/use-this-package/the-screen:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: 953c900433f4b9ec
|
|
25
|
+
zh: 226a5e2970bb6407
|
|
26
26
|
/deepseek-ai-dsh-tui-app/use-this-package/keys-and-commands:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: e3d6b7f7129c5c18
|
|
28
|
+
zh: 0756929942742c7c
|
|
29
29
|
/deepseek-ai-dsh-tui-app/use-this-package/background-tool-calls:
|
|
30
30
|
en: 322ae3c6d76383ec
|
|
31
31
|
zh: 8c38eee4b57ed8dd
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
en: 1dadc4a2f1560eaa
|
|
109
109
|
zh: dc4697c269bc16b9
|
|
110
110
|
/deepseek-ai-dsh-tui-app/known-limitations-and-deferred-work:
|
|
111
|
-
en:
|
|
112
|
-
zh:
|
|
111
|
+
en: e4a72ada7a62df79
|
|
112
|
+
zh: 361888b9940c4a91
|
|
113
113
|
/deepseek-ai-dsh-tui-app/known-limitations-and-deferred-work/dev-note:
|
|
114
114
|
en: 5629c6159cec997f
|
|
115
115
|
zh: 17f2d7e1f96da7f1
|
|
@@ -40,7 +40,7 @@ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui
|
|
|
40
40
|
|
|
41
41
|
### The screen
|
|
42
42
|
|
|
43
|
-
Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), and a prompt steered or injected into a turn that already had a model step draws dim on a darker band so it recedes behind the turn it joined, assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, and each tool call is a card with a status glyph — a yellow spinner of that tool family's flowers, blooms, and stars while it runs, a green `◆` once done, a red `◆` on failure — the bold tool name, the presenter headline in violet — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. A top-level workflow call also draws its own run beside that card: the name, member count, and
|
|
43
|
+
Every frame is drawn one column in from each edge of the terminal, so no line of the conversation or of the docked chrome touches either side. The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), and a prompt steered or injected into a turn that already had a model step draws dim on a darker band so it recedes behind the turn it joined, assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, and each tool call is a card with a status glyph — a yellow spinner of that tool family's flowers, blooms, and stars while it runs, a green `◆` once done, a red `◆` on failure — the bold tool name, the presenter headline in violet — without the tool name a presenter repeated, so `Read src/app.ts` draws as `read src/app.ts`, and for a shell card the call's own summary, never the command, which the card draws once as its `$` row — a loading row while it runs, and a body folded to `toolPreviewLines` rows. A top-level workflow call also draws its own run beside that card: the name, member count, status, and a ten-cell member progress bar with the settled count, then each phase and the members that started. While a live run runs, its `◇` pulses through a diamond animation and each running member's `○` spins in the subagent family's flowers, one phase ahead of the member before it; a run drawn from a replayed log spins only while its background job is still live, and reduced motion draws the static glyphs. Running groups and groups with a failed, cancelled, or interrupted member open; a clean completion stays closed. Space or Enter on a run or phase folds that level, and Enter on a running member opens its child only while that child is a live direct child of this session. The card appears when the model starts the call, its header first and its rows unrolling beneath it over about `toolRevealFrames` frames; the result rows unroll and float out the same way when the tool answers. An `edit` or `write` diff card fills each added row edge to edge with a green background and each removed row with a red one, the removed rows above the added ones, and paints the `+` and `-` in their own lighter colour so each sign reads against the fill rather than in it; a wrapped row carries the fill on without a second sign; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status glyph, spinning while it runs and a dim `◆` for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt is omitted. A compaction, from `/compact` or automatic, draws as one context block whose accent `⬡` title names its origin and the estimated tokens it replaced and its summary costs, as in `context compacted by /compact · ~6.4k → ~0.9k tokens` or `context compacted automatically in turn 12 · …`; under the title, `compressed` names the item count and turns the summary replaced, each prompt among them (five at most, one row each), and a count of the replies, tool results by tool, context blocks, and earlier summaries, and `preserved` names the system prompt and what each later turn still holds verbatim; both stay drawn while the summary under them folds to `contextPreviewLines` rows like any context block. The checkpoint message itself is not drawn again. A `/compact` attempt the log closes with an error prints `/compact failed · <error>` when the session is redrawn, since the live command reports its own failure; a failed automatic attempt changes nothing and draws nothing, as in the browser. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use warm orange, links and inline code use violet, and quotes stay dim. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
|
|
44
44
|
|
|
45
45
|
Below the transcript sit a spinner while the agent works — `thinking`, `writing`, `calling <tool>`, a retry, or `compacting`, each beside its own braille animation: circling dots, filling lines, an orbiting dot, a sliding bar, or a settling cell — with a bright highlight sweeping across the word, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and latest descendant line while either has a row — completed todo content scratched out and status glyphs colored green, yellow, or cyan, the in-progress one a spinner, at most four todo rows then `+<n> more`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model and entry keys are colored; live turn, context, and todo facts use yellow, violet, and green. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, or `Shift+↑ select · Shift+↓ status` while follow-ups wait, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. Model-request retries appear as notices, the same facts the browser's markers carry.
|
|
46
46
|
|
|
@@ -196,6 +196,7 @@ Typing `/` at the start of the editor completes the terminal's own commands and
|
|
|
196
196
|
| `/changes [turn]` | Browse the files the latest turn changed, or turn `turn`, with their line counts; `Enter` opens one file's turn-start to turn-end comparison |
|
|
197
197
|
| `/subagents` | Browse the subagent sessions under this session; `Enter` opens a readable one as a subagent view and an unreadable one's details |
|
|
198
198
|
| `/parent` | Return from a subagent view to the session it was entered from, or end a `/btw` side agent, like `Ctrl+P` |
|
|
199
|
+
| `/workflows` | Browse this session's workflow runs with their status, settled members, phases, and owning job; `Enter` lists a run's members, `Enter` on a member opens its child as a live view while it runs here and shows its details otherwise, and `Ctrl+K` stops a background run through its job. `/workflows <name>` opens the newest run of that name |
|
|
199
200
|
| `/jobs` | Browse this session's background jobs, the calls moved with `Ctrl+B` and the jobs the agent started, with status and elapsed time; `Enter` shows one job's status and output tail, and `Ctrl+K` stops the highlighted job |
|
|
200
201
|
| `/settings [ns [path value]]` | List namespaces, show one, or set one field; `/settings reset <ns>` restores defaults |
|
|
201
202
|
| `/plugins` | The composed plugins with enablement and lifecycle phase; `/plugins bundles` lists the profile's bundles, `/plugins enable <id>` and `/plugins disable <id>` switch a plugin entry or a bundle, `/plugins add <spec>` installs a bundle, `/plugins remove <name>` removes one |
|
|
@@ -475,7 +476,7 @@ These limits describe the terminal surface as shipped; they are not a general CL
|
|
|
475
476
|
- **Runs through the `dsh` launcher** — starting the profile another way fails at startup, because only the launcher can request the process exit.
|
|
476
477
|
- **A `/btw` side agent is read-only by tool name and sandbox** — `btwTools` must name only tools that read, because the side agent shares the workspace with the working agent; a command tool can read anything the `read-only` sandbox mode allows, and without a confining command executor command tools are hidden. It inherits only what the working session has logged: reply text still streaming is absent. Its log is stored like a subagent session's and hidden from `/resume` and `/sessions`, and Web has no `/btw`.
|
|
477
478
|
- **A moved call stays tied to its turn and returns text** — the tool runtime fuses the turn's signal into every call, so `Esc` on the turn that dispatched a call stops it even after `Ctrl+B`; a job result is a string, so other content blocks of the call's result are named as `[image omitted]` and the like; and moving needs `ctx.jobs` with `dsh-tool-jobs`, which the base profile composes.
|
|
478
|
-
- **Workflow runs show identity and status** — a top-level workflow call draws a run beside its tool card: the name, member count, status, phases, and started members. Running and abnormal groups open; a clean completion stays closed. Space or Enter on a run or phase folds that level. Enter opens a running member only while it is a live direct child of this session, and does not resume a member that has finished. The script stays on the tool card. A background run stays running after its launch turn while its job is live; an unfinished run with no live job is interrupted on replay. Phase and log lines stay on `/jobs`, and the job's return value stays with `job_output`.
|
|
479
|
+
- **Workflow runs show identity and status** — a top-level workflow call draws a run beside its tool card: the name, member count, status, progress, phases, and started members. `/workflows` stops only a background run; a run inside the turn stops with the turn. Running and abnormal groups open; a clean completion stays closed. Space or Enter on a run or phase folds that level. Enter opens a running member only while it is a live direct child of this session, and does not resume a member that has finished. The script stays on the tool card. A background run stays running after its launch turn while its job is live; an unfinished run with no live job is interrupted on replay. Phase and log lines stay on `/jobs`, and the job's return value stays with `job_output`.
|
|
479
480
|
- **`!` is one-shot and not a TTY** — each line is a fresh `ctx.shell.run`; there is no persistent shell or interactive program. The Web composer does not intercept `!`. An optional first prompt on the command line is always a user message.
|
|
480
481
|
|
|
481
482
|
<a id="dev-note"></a>
|
|
@@ -40,7 +40,7 @@ dsh tui --no-open # print sign-in URLs without opening a
|
|
|
40
40
|
|
|
41
41
|
### 屏幕布局
|
|
42
42
|
|
|
43
|
-
每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),而在已有模型步骤的轮次中被引导或注入的提示以暗色文字铺在更深的背景带上,退到它所加入的轮次之后,assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,每次工具调用是一张卡片,含状态符号(运行中为按工具族混合花朵、绽放与星形的黄色旋转指示、完成为绿色 `◆`、失败为红色 `◆`)、粗体工具名、以紫色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。顶层 workflow
|
|
43
|
+
每一帧都从终端左右两边各内缩一列绘制,因此对话记录与停靠的界面组件都不会有任何一行贴到两侧边缘。页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),而在已有模型步骤的轮次中被引导或注入的提示以暗色文字铺在更深的背景带上,退到它所加入的轮次之后,assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,每次工具调用是一张卡片,含状态符号(运行中为按工具族混合花朵、绽放与星形的黄色旋转指示、完成为绿色 `◆`、失败为红色 `◆`)、粗体工具名、以紫色显示的呈现器标题(去掉呈现器重复写出的工具名,因此 `Read src/app.ts` 画成 `read src/app.ts`;shell 卡片取该次调用自身的摘要,绝不取命令,命令只由卡片的 `$` 行绘制一次)、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。顶层 workflow 调用还会在该卡片旁另绘一次运行:运行名、成员数、状态,以及一条十格的成员进度条与已结束数,然后是每个阶段和已启动的成员。实时运行进行中时,其 `◇` 以菱形动画脉动,每个运行中成员的 `○` 以子 agent 族的花朵旋转,相位比前一个成员领先一格;从重放日志绘制的运行只在其后台作业仍存活时旋转,减少动效时绘制静态符号。运行中的层级,以及含失败、取消或中断成员的层级会展开;干净完成的层级保持折叠。在运行或阶段上按 Space 或 Enter 折叠该层,在仍在运行的成员上按 Enter 只会在该子会话是本会话的直接子会话且仍在本进程运行时打开它。卡片在模型开始调用时出现,先画标题,其下各行在约 `toolRevealFrames` 帧内逐行展开;工具回答后,结果行也以同样方式展开并浮出。`edit` 或 `write` diff 卡片把每一新增行整行铺满绿色背景、每一删除行整行铺满红色背景,删除的旧行在上、新增的新行在下,并把 `+` 与 `-` 画成各自更亮的颜色,使符号从填充色中读得出来;折行续行只延续填充色,不再画第二个符号;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样的状态符号,运行中旋转,交给后台的子 agent 则为暗色 `◆`:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词则省略。一次压缩(compaction)——无论来自 `/compact` 还是自动触发——绘制为一个上下文块,其强调色 `⬡` 标题写明来源,以及被替换内容与摘要各自的估算 token 数,如 `context compacted by /compact · ~6.4k → ~0.9k tokens` 或 `context compacted automatically in turn 12 · …`;标题之下,`compressed` 写明摘要替换的条目数与轮次、其中的每条提示(最多五条,每条一行),以及回复、按工具分列的工具结果、上下文块与更早摘要的计数,`preserved` 写明系统提示词以及之后每一轮仍逐字保留的内容;这两部分始终绘出,其下的摘要则像其他上下文块一样折叠到 `contextPreviewLines` 行。检查点消息本身不再重复绘制。日志以错误结束的 `/compact` 尝试会在会话重绘时打印 `/compact failed · <error>`,因为实时运行的命令会自己报告失败;失败的自动尝试不改变任何内容,也不绘制任何内容,与浏览器一致。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用暖橙色,链接与行内代码使用紫色,引用保持暗色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
|
|
44
44
|
|
|
45
45
|
对话记录下方依次是 agent 工作时的旋转指示——`thinking`、`writing`、`calling <tool>`、重试或 `compacting`,各自旁边是它自己的盲文动画:环绕的点、逐行填满的线、绕行的单点、滑动的横条,或沉降又回满的方格——标签单词上带着一道扫过的高亮,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与最新后代行的 activity board(有行时才绘制;已完成内容划掉,状态符号以绿色、黄色或青色显示,进行中的那一项为旋转指示,todo 最多四行其后 `+<n> more`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型与入口按键带有颜色;进行中的轮次、上下文与 todo 信息分别使用黄色、紫色与绿色。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,有 follow-ups 等待时则写作 `Shift+↑ select · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
|
|
46
46
|
|
|
@@ -196,6 +196,7 @@ follow-ups 面板持有键盘时:
|
|
|
196
196
|
| `/changes [turn]` | 浏览最近一轮(或第 `turn` 轮)改动的文件及其行数;`Enter` 打开某个文件从轮次开始到结束的对比 |
|
|
197
197
|
| `/subagents` | 浏览本会话之下的子 agent 会话;`Enter` 把可读的会话作为子 agent 视图打开,对无法读取的会话则打开其详情 |
|
|
198
198
|
| `/parent` | 从子 agent 视图返回进入它之前的会话,或结束 `/btw` 旁路 agent,与 `Ctrl+P` 相同 |
|
|
199
|
+
| `/workflows` | 浏览本会话的工作流运行,附带状态、已结束成员、阶段与所属作业;`Enter` 列出一次运行的成员,在成员上按 `Enter` 时,若它仍在本进程运行则把其子会话作为实时视图打开,否则显示其详情,`Ctrl+K` 通过作业停止后台运行。`/workflows <name>` 打开该名称最新的一次运行 |
|
|
199
200
|
| `/jobs` | 浏览本会话的后台作业,即用 `Ctrl+B` 移走的调用与 agent 启动的作业,附带状态与耗时;`Enter` 显示一个作业的状态与输出末尾,`Ctrl+K` 停止高亮的作业 |
|
|
200
201
|
| `/settings [ns [path value]]` | 列出命名空间、显示某一个或设置某个字段;`/settings reset <ns>` 恢复默认 |
|
|
201
202
|
| `/plugins` | 已组合的插件及其启用状态与生命周期阶段;`/plugins bundles` 列出 profile 的组合包,`/plugins enable <id>` 与 `/plugins disable <id>` 切换某个插件条目或组合包,`/plugins add <spec>` 安装组合包,`/plugins remove <name>` 移除组合包 |
|
|
@@ -475,7 +476,7 @@ The user moved this call to the background. It keeps running as job <id>. You ar
|
|
|
475
476
|
- **通过 `dsh` 启动器运行**——以其他方式启动该 profile 会在启动时失败,因为只有启动器能请求进程退出。
|
|
476
477
|
- **`/btw` 旁路 agent 靠工具名称与沙箱保持只读**——`btwTools` 只能列出读取类工具,因为旁路 agent 与工作 agent 共享工作区;命令工具可以读取 `read-only` 沙箱模式允许的任何内容,而没有会约束命令的执行器时命令工具会被隐藏。它只继承工作会话已记录的内容:仍在流式输出的回复文本不在其中。它的日志像子 agent 会话一样被存储,并在 `/resume` 与 `/sessions` 中隐藏,Web 没有 `/btw`。
|
|
477
478
|
- **被移走的调用仍绑定其轮次并返回文本**——工具运行时把轮次的信号融合进每个调用,因此即便按过 `Ctrl+B`,在派发该调用的轮次上按 `Esc` 仍会停止它;作业结果是字符串,因此调用结果中的其他内容块会被写成 `[image omitted]` 之类;移走调用需要 `ctx.jobs` 与 `dsh-tool-jobs`,base profile 已组合二者。
|
|
478
|
-
- **工作流运行块只显示身份与状态**——顶层 workflow
|
|
479
|
+
- **工作流运行块只显示身份与状态**——顶层 workflow 调用在工具卡片旁另绘运行块:运行名、成员数、状态、进度、阶段和已启动的成员。`/workflows` 只停止后台运行;轮次内的运行随轮次一起停止。运行中与异常的层级默认展开,干净完成的层级保持折叠。在运行或阶段上按 Space 或 Enter 折叠该层。在仍在运行的成员上按 Enter 只会在它是本会话的直接子会话且仍在本进程运行时打开,不会恢复已结束的成员。脚本留在工具卡片上。后台运行在其作业仍存活时,启动轮次结束后仍显示为运行中;重放时没有存活作业的未结束运行显示为 interrupted。阶段与日志行留在 `/jobs`,作业返回值仍由 `job_output` 交给模型。
|
|
479
480
|
- **`!` 是一次性的,也不是 TTY**——每一行都是一次新的 `ctx.shell.run`;没有持久 shell,也不能跑交互式程序。Web 编辑器不拦截 `!`。命令行上的可选首条提示始终是用户消息。
|
|
480
481
|
|
|
481
482
|
<a id="dev-note"></a>
|