acryl 0.1.17 → 0.1.19
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/lib/bin.js +131 -132
- package/lib/bin.js.map +1 -1
- package/lib/index.js +117 -31
- package/lib/index.js.map +1 -1
- package/package.json +12 -526
package/lib/bin.js
CHANGED
|
@@ -8,6 +8,7 @@ import { randomUUID } from "node:crypto";
|
|
|
8
8
|
import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
9
9
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
10
10
|
import { DEFAULT_PROFILE_BUNDLES, boot, composeEntries, healProfilesModuleFallback, initProfile, loadProfile, resolveProfileDir } from "@deepseek-ai/dsh-app-boot";
|
|
11
|
+
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
11
12
|
import { diffLines } from "diff";
|
|
12
13
|
import { Container, Editor, HStack, Key, KeybindingsManager, ProcessTerminal, ScrollView, TUI_KEYBINDINGS, Text, TuiAltScreen, VStack, matchesKey, setKeybindings, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
13
14
|
import { readdir } from "node:fs/promises";
|
|
@@ -36,40 +37,58 @@ async function relaunchWithExposedInternals(input) {
|
|
|
36
37
|
process.exitCode = exitCode;
|
|
37
38
|
return true;
|
|
38
39
|
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region ../node_modules/.pnpm/@deepseek-ai+dsh-cmdline@0.1.1-rc.2_@deepseek-ai+cordis-plugin-loader@1.0.2_@deepseek-a_1bc57e8c58566d7b9c3fbf261d0f481e/node_modules/@deepseek-ai/dsh-cmdline/lib/index.js
|
|
41
|
-
/**
|
|
42
|
-
* @deepseek-ai/dsh-cmdline — the command line a dsh launcher hands to the app
|
|
43
|
-
* it boots.
|
|
44
|
-
*
|
|
45
|
-
* The launcher parses only its own flags (`--profile`, `--patch`, the config
|
|
46
|
-
* dumps) and hands everything after them to the tree verbatim through the
|
|
47
|
-
* {@link CmdlineArgs} service, so an app owns its flag family, its `--help`
|
|
48
|
-
* text, and its parse errors instead of the launcher knowing them.
|
|
49
|
-
*
|
|
50
|
-
* Any app plugin can inject `cmdlineArgs` and call {@link parseCmdline}. A
|
|
51
|
-
* provider may publish the parsed values as its own service from its program's
|
|
52
|
-
* commander action, and ordinary rows
|
|
53
|
-
* can inject that service and read it from lazily resolved config —
|
|
54
|
-
* `port: !!js ctx.webStartup.port ?? 3080` — so a flag beats the value written
|
|
55
|
-
* beside it. No row has launcher-level command-line status.
|
|
56
|
-
* @module @deepseek-ai/dsh-cmdline
|
|
57
|
-
*/
|
|
58
|
-
/**
|
|
59
|
-
* Provide the command line and the exit request on a host context before any
|
|
60
|
-
* tree entry mounts. Both are launcher facts, not config: an embedding host
|
|
61
|
-
* with no command line provides an empty argument list.
|
|
62
|
-
* @param ctx - the host context the tree will mount under.
|
|
63
|
-
* @param host - the invocation's arguments and its exit request.
|
|
64
|
-
*/
|
|
65
|
-
function provideCmdline(ctx, host) {
|
|
66
|
-
const snapshot = Object.freeze([...host.args]);
|
|
67
|
-
ctx.provide("cmdlineArgs", { get: () => snapshot });
|
|
68
|
-
ctx.provide("appExit", host.exit);
|
|
69
|
-
}
|
|
70
40
|
process.stdout, process.stderr;
|
|
71
41
|
//#endregion
|
|
72
42
|
//#region ../acryl-harness-runtime/lib/index.mjs
|
|
43
|
+
const shippedPresetsDir = join(resolve(dirname(fileURLToPath(import.meta.url)), "../.."), "deepseek-harness", "packages", "preset", "agent-presets", "presets");
|
|
44
|
+
const authorizationCapabilityPatches = [{
|
|
45
|
+
id: "system-prompt",
|
|
46
|
+
name: "@deepseek-ai/dsh-system-prompt",
|
|
47
|
+
config: { persona: "You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}." }
|
|
48
|
+
}, { insert: [
|
|
49
|
+
{
|
|
50
|
+
id: "agent-presets",
|
|
51
|
+
name: "@deepseek-ai/dsh-agent-presets",
|
|
52
|
+
config: {
|
|
53
|
+
default: "standard",
|
|
54
|
+
roots: existsSync(shippedPresetsDir) ? [{
|
|
55
|
+
path: shippedPresetsDir,
|
|
56
|
+
trust: "system"
|
|
57
|
+
}] : [],
|
|
58
|
+
includeShippedRoot: false,
|
|
59
|
+
includeUserRoot: true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "session-stats",
|
|
64
|
+
name: "@deepseek-ai/dsh-session-stats"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "authorization",
|
|
68
|
+
name: "@deepseek-ai/dsh-authorization"
|
|
69
|
+
}
|
|
70
|
+
] }];
|
|
71
|
+
const NON_TUI_SHARED_ROW_IDS = /* @__PURE__ */ new Set(["authorization"]);
|
|
72
|
+
function selectNonTuiCapabilityPatches(patches) {
|
|
73
|
+
return patches.flatMap((patch) => {
|
|
74
|
+
if (!("insert" in patch) || !Array.isArray(patch.insert)) return [];
|
|
75
|
+
const insert = patch.insert.filter((row) => NON_TUI_SHARED_ROW_IDS.has(row.id));
|
|
76
|
+
return insert.length === 0 ? [] : [{ insert }];
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const ACRYL_CODING_CAPABILITIES = [{
|
|
80
|
+
id: "authorization",
|
|
81
|
+
surfaces: [
|
|
82
|
+
"tui",
|
|
83
|
+
"web",
|
|
84
|
+
"desktop"
|
|
85
|
+
],
|
|
86
|
+
loaderPatches: authorizationCapabilityPatches
|
|
87
|
+
}];
|
|
88
|
+
function createAcrylCodingCapabilityPatches(surfaces) {
|
|
89
|
+
const includeSharedCodingRows = surfaces.has("tui");
|
|
90
|
+
return structuredClone(ACRYL_CODING_CAPABILITIES.filter((capability) => capability.surfaces.some((surface) => surfaces.has(surface))).flatMap((capability) => includeSharedCodingRows ? capability.loaderPatches : selectNonTuiCapabilityPatches(capability.loaderPatches)));
|
|
91
|
+
}
|
|
73
92
|
function contentText(content) {
|
|
74
93
|
return content.filter((block) => {
|
|
75
94
|
return block.type === "text" && typeof block.text === "string";
|
|
@@ -269,36 +288,71 @@ function createAcrylSessionBridge(ctx, options) {
|
|
|
269
288
|
}
|
|
270
289
|
});
|
|
271
290
|
}
|
|
291
|
+
/** Canonical tool name exposed to the model. */
|
|
292
|
+
const TOOL_NAME = "acryl_workspace_status";
|
|
293
|
+
/** Read the ACRYL workspace/profile context the agent is running under. */
|
|
294
|
+
function readWorkspaceContext() {
|
|
295
|
+
return {
|
|
296
|
+
cwd: process.cwd(),
|
|
297
|
+
dshHome: process.env.DSH_HOME ?? "",
|
|
298
|
+
profile: process.env.ACRYL_PROFILE ?? "",
|
|
299
|
+
surface: process.env.ACRYL_SURFACE ?? ""
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/** Render one line of the model-facing text from the canonical context value. */
|
|
303
|
+
function fmt(label, value, prefix) {
|
|
304
|
+
return `${prefix} ${label}: ${value}`;
|
|
305
|
+
}
|
|
306
|
+
/** Register the `acryl_workspace_status` tool on `ctx.tools`. Returns a disposer. */
|
|
307
|
+
function installAcrylWorkspaceStatusTool(ctx) {
|
|
308
|
+
const tool = defineTool({
|
|
309
|
+
name: TOOL_NAME,
|
|
310
|
+
description: "Report the ACRYL workspace context the agent is operating in: current working directory, DSH home, active ACRYL profile, and presentation surface. Use it to confirm which project/profile a session is bound to before acting.",
|
|
311
|
+
parameters: {},
|
|
312
|
+
output: {
|
|
313
|
+
schema: {
|
|
314
|
+
type: "object",
|
|
315
|
+
additionalProperties: false,
|
|
316
|
+
properties: {
|
|
317
|
+
cwd: {
|
|
318
|
+
type: "string",
|
|
319
|
+
required: true
|
|
320
|
+
},
|
|
321
|
+
dshHome: {
|
|
322
|
+
type: "string",
|
|
323
|
+
required: true
|
|
324
|
+
},
|
|
325
|
+
profile: {
|
|
326
|
+
type: "string",
|
|
327
|
+
required: true
|
|
328
|
+
},
|
|
329
|
+
surface: {
|
|
330
|
+
type: "string",
|
|
331
|
+
required: true
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
render(_args, value) {
|
|
336
|
+
const v = value;
|
|
337
|
+
return [{
|
|
338
|
+
type: "text",
|
|
339
|
+
text: ["ACRYL workspace context:", ...[
|
|
340
|
+
fmt("cwd", v.cwd, "-"),
|
|
341
|
+
fmt("dshHome", v.dshHome || "<unset>", "-"),
|
|
342
|
+
fmt("profile", v.profile || "<default>", "-"),
|
|
343
|
+
fmt("surface", v.surface || "<tui>", "-")
|
|
344
|
+
]].join("\n")
|
|
345
|
+
}];
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
async execute(_args, _exec) {
|
|
349
|
+
return readWorkspaceContext();
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return ctx.tools.register(tool);
|
|
353
|
+
}
|
|
272
354
|
const dshInstallAnchor = createRequire(import.meta.url).resolve("@deepseek-ai/dsh/package.json");
|
|
273
355
|
const profileRoot = "[]\n";
|
|
274
|
-
const shippedPresetsDir = join(resolve(dirname(fileURLToPath(import.meta.url)), "../.."), "deepseek-harness", "packages", "preset", "agent-presets", "presets");
|
|
275
|
-
const ACRYL_RUNTIME_ROWS = [{
|
|
276
|
-
id: "system-prompt",
|
|
277
|
-
name: "@deepseek-ai/dsh-system-prompt",
|
|
278
|
-
config: { persona: "You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}." }
|
|
279
|
-
}, { insert: [
|
|
280
|
-
{
|
|
281
|
-
id: "agent-presets",
|
|
282
|
-
name: "@deepseek-ai/dsh-agent-presets",
|
|
283
|
-
config: {
|
|
284
|
-
default: "standard",
|
|
285
|
-
roots: existsSync(shippedPresetsDir) ? [{
|
|
286
|
-
path: shippedPresetsDir,
|
|
287
|
-
trust: "system"
|
|
288
|
-
}] : [],
|
|
289
|
-
includeShippedRoot: false,
|
|
290
|
-
includeUserRoot: true
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
id: "session-stats",
|
|
295
|
-
name: "@deepseek-ai/dsh-session-stats"
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
id: "authorization",
|
|
299
|
-
name: "@deepseek-ai/dsh-authorization"
|
|
300
|
-
}
|
|
301
|
-
] }];
|
|
302
356
|
/** Boot one normal pinned-Harness ACRYL profile in a single Cordis root. */
|
|
303
357
|
async function bootAcrylHarnessProfile(options) {
|
|
304
358
|
if (options.profile.trim() === "") throw new Error("ACRYL Harness profile must not be empty");
|
|
@@ -309,11 +363,12 @@ async function bootAcrylHarnessProfile(options) {
|
|
|
309
363
|
writeFileSync(rootConfig, profileRoot);
|
|
310
364
|
const patches = structuredClone([
|
|
311
365
|
...profile.layers.flatMap((layer) => layer.patches),
|
|
312
|
-
...
|
|
366
|
+
...createAcrylCodingCapabilityPatches(/* @__PURE__ */ new Set(["tui"])),
|
|
313
367
|
...profile.patches
|
|
314
368
|
]);
|
|
315
369
|
if (composeEntries([patches]).find((entry) => entry.id === "hmr")?.disabled !== true && !process.execArgv.includes("--expose-internals")) throw new Error("ACRYL profile enables Cordis HMR and must be launched with Node --expose-internals");
|
|
316
370
|
const ctx = await boot("acryl", rootConfig, patches, options.prepare);
|
|
371
|
+
if (ctx.tools) installAcrylWorkspaceStatusTool(ctx);
|
|
317
372
|
let disposed = false;
|
|
318
373
|
return Object.freeze({
|
|
319
374
|
ctx,
|
|
@@ -325,45 +380,6 @@ async function bootAcrylHarnessProfile(options) {
|
|
|
325
380
|
}
|
|
326
381
|
});
|
|
327
382
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Boot the DSH browser surface (the `web` profile: `dsh-base` + `dsh-web-app`)
|
|
330
|
-
* as one normal ACRYL runtime, so `pnpm acryl-web` serves the same DSH
|
|
331
|
-
* HTTP/WebSocket seam the web surface always uses. The web profile already
|
|
332
|
-
* composes the persona/agent rows ACRYL's terminal surface adds, so no
|
|
333
|
-
* ACRYL_RUNTIME_ROWS are re-inserted (that would duplicate `system-prompt`).
|
|
334
|
-
*/
|
|
335
|
-
async function bootAcrylWebProfile(options = {}) {
|
|
336
|
-
const profileName = "web";
|
|
337
|
-
initProfile(resolveProfileDir(profileName), DEFAULT_PROFILE_BUNDLES);
|
|
338
|
-
healProfilesModuleFallback(dshInstallAnchor);
|
|
339
|
-
const profile = loadProfile("web", profileName, dshInstallAnchor);
|
|
340
|
-
const rootConfig = join(profile.dir, "cordis.yml");
|
|
341
|
-
writeFileSync(rootConfig, profileRoot);
|
|
342
|
-
const patches = structuredClone([...profile.layers.flatMap((layer) => layer.patches), ...profile.patches]);
|
|
343
|
-
const cmdlineArgs = options.cmdlineArgs ?? [];
|
|
344
|
-
const ctx = await boot("web", rootConfig, patches, (hostCtx) => {
|
|
345
|
-
provideCmdline(hostCtx, {
|
|
346
|
-
args: [...cmdlineArgs],
|
|
347
|
-
exit: (code) => {
|
|
348
|
-
process.exitCode = code;
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
return options.prepare?.(hostCtx);
|
|
352
|
-
});
|
|
353
|
-
const startup = ctx.get("webStartup");
|
|
354
|
-
const url = `http://${startup?.host ?? "127.0.0.1"}:${startup?.port ?? 3080}`;
|
|
355
|
-
let disposed = false;
|
|
356
|
-
return Object.freeze({
|
|
357
|
-
ctx,
|
|
358
|
-
url,
|
|
359
|
-
profileDirectory: profile.dir,
|
|
360
|
-
async dispose() {
|
|
361
|
-
if (disposed) return;
|
|
362
|
-
disposed = true;
|
|
363
|
-
await ctx.fiber.dispose();
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
383
|
//#endregion
|
|
368
384
|
//#region src/host/direct.ts
|
|
369
385
|
/** Start one normal local Harness runtime for this terminal surface. */
|
|
@@ -5864,24 +5880,19 @@ function parseAcrylArgs(args) {
|
|
|
5864
5880
|
}
|
|
5865
5881
|
//#endregion
|
|
5866
5882
|
//#region src/cli/run.ts
|
|
5867
|
-
/**
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
process.stdout.write(`ACRYL web: ${url}\n`);
|
|
5877
|
-
await stopped;
|
|
5878
|
-
await runtime.dispose();
|
|
5879
|
-
return { url };
|
|
5883
|
+
/**
|
|
5884
|
+
* The `acryl` CLI is the terminal surface only. The browser (`acryl web`) and
|
|
5885
|
+
* Electron (`acryl gui`) surfaces are separate distributions and are NOT wired
|
|
5886
|
+
* into this package, so the CLI stays lightweight and does not pull the
|
|
5887
|
+
* `dsh-web-app` / host / client bundle into its publish closure.
|
|
5888
|
+
*/
|
|
5889
|
+
function surfaceError(command) {
|
|
5890
|
+
if (command === "web") return /* @__PURE__ */ new Error("`acryl web` is served by the separate `acryl-web` distribution. Install it separately; the `acryl` CLI is the terminal (TUI) surface only.");
|
|
5891
|
+
return /* @__PURE__ */ new Error("`acryl gui` (Electron Desktop) is a separate distribution and is not wired into the `acryl` CLI package. Use the desktop installer.");
|
|
5880
5892
|
}
|
|
5881
5893
|
const defaults = {
|
|
5882
5894
|
startDirectHost,
|
|
5883
5895
|
runTui: runAcrylTui,
|
|
5884
|
-
runWeb: serveWeb,
|
|
5885
5896
|
exit: (code) => {
|
|
5886
5897
|
process.exitCode = code;
|
|
5887
5898
|
},
|
|
@@ -5897,8 +5908,8 @@ function statusLine(host) {
|
|
|
5897
5908
|
});
|
|
5898
5909
|
}
|
|
5899
5910
|
/**
|
|
5900
|
-
* Run the
|
|
5901
|
-
*
|
|
5911
|
+
* Run the ACRYL terminal host. `--json` is a short-lived, scriptable
|
|
5912
|
+
* readiness probe; interactive mode mounts the pi-tui session via the
|
|
5902
5913
|
* runtime bridge until a normal exit, then prints a resumable session id.
|
|
5903
5914
|
*/
|
|
5904
5915
|
async function runAcryl(args, supplied = {}) {
|
|
@@ -5915,8 +5926,6 @@ async function runAcryl(args, supplied = {}) {
|
|
|
5915
5926
|
"",
|
|
5916
5927
|
"Commands:",
|
|
5917
5928
|
" tui Run the terminal client (default)",
|
|
5918
|
-
" web Serve the local ACRYL web runtime",
|
|
5919
|
-
" gui [reserved] launch the Desktop surface (not wired in this build)",
|
|
5920
5929
|
"",
|
|
5921
5930
|
"Options:",
|
|
5922
5931
|
" -h, --help Show this help",
|
|
@@ -5924,6 +5933,9 @@ async function runAcryl(args, supplied = {}) {
|
|
|
5924
5933
|
" --json Emit machine-readable output",
|
|
5925
5934
|
" --profile <name> Use a named ACRYL profile",
|
|
5926
5935
|
" --resume <id> Resume a session",
|
|
5936
|
+
"",
|
|
5937
|
+
"The browser (`acryl web`) and Electron (`acryl gui`) surfaces are ",
|
|
5938
|
+
"separate distributions. Install them individually.",
|
|
5927
5939
|
""
|
|
5928
5940
|
].join("\n"));
|
|
5929
5941
|
return;
|
|
@@ -5932,21 +5944,8 @@ async function runAcryl(args, supplied = {}) {
|
|
|
5932
5944
|
dependencies.write(ACRYL_VERSION);
|
|
5933
5945
|
return;
|
|
5934
5946
|
}
|
|
5935
|
-
if (invocation.command === "
|
|
5936
|
-
if (invocation.command === "
|
|
5937
|
-
if (invocation.json) {
|
|
5938
|
-
const host = await bootAcrylWebProfile({ cmdlineArgs: [] });
|
|
5939
|
-
try {
|
|
5940
|
-
dependencies.write(host.url);
|
|
5941
|
-
} finally {
|
|
5942
|
-
await host.dispose();
|
|
5943
|
-
}
|
|
5944
|
-
return;
|
|
5945
|
-
}
|
|
5946
|
-
const result = await dependencies.runWeb({ profile: invocation.profile ?? "web" });
|
|
5947
|
-
dependencies.write(`serving at ${result.url}`);
|
|
5948
|
-
return;
|
|
5949
|
-
}
|
|
5947
|
+
if (invocation.command === "web") throw surfaceError("web");
|
|
5948
|
+
if (invocation.command === "gui") throw surfaceError("gui");
|
|
5950
5949
|
if (invocation.json) {
|
|
5951
5950
|
const host = await dependencies.startDirectHost({ profile: invocation.profile ?? "acryl" });
|
|
5952
5951
|
try {
|