acryl 0.1.18 → 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 +81 -107
- package/lib/bin.js.map +1 -1
- package/lib/index.js +65 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -2
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,37 +37,6 @@ 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
|
|
@@ -318,6 +288,69 @@ function createAcrylSessionBridge(ctx, options) {
|
|
|
318
288
|
}
|
|
319
289
|
});
|
|
320
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
|
+
}
|
|
321
354
|
const dshInstallAnchor = createRequire(import.meta.url).resolve("@deepseek-ai/dsh/package.json");
|
|
322
355
|
const profileRoot = "[]\n";
|
|
323
356
|
/** Boot one normal pinned-Harness ACRYL profile in a single Cordis root. */
|
|
@@ -335,6 +368,7 @@ async function bootAcrylHarnessProfile(options) {
|
|
|
335
368
|
]);
|
|
336
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");
|
|
337
370
|
const ctx = await boot("acryl", rootConfig, patches, options.prepare);
|
|
371
|
+
if (ctx.tools) installAcrylWorkspaceStatusTool(ctx);
|
|
338
372
|
let disposed = false;
|
|
339
373
|
return Object.freeze({
|
|
340
374
|
ctx,
|
|
@@ -346,49 +380,6 @@ async function bootAcrylHarnessProfile(options) {
|
|
|
346
380
|
}
|
|
347
381
|
});
|
|
348
382
|
}
|
|
349
|
-
/**
|
|
350
|
-
* Boot the DSH browser surface (the `web` profile: `dsh-base` + `dsh-web-app`)
|
|
351
|
-
* as one normal ACRYL runtime, so `pnpm acryl-web` serves the same DSH
|
|
352
|
-
* HTTP/WebSocket seam the web surface always uses. The shipped Web profile
|
|
353
|
-
* already owns its system prompt, agent-preset roster, and session stats, so
|
|
354
|
-
* the shared factory contributes only the missing authorization seam here.
|
|
355
|
-
*/
|
|
356
|
-
async function bootAcrylWebProfile(options = {}) {
|
|
357
|
-
const profileName = "web";
|
|
358
|
-
initProfile(resolveProfileDir(profileName), DEFAULT_PROFILE_BUNDLES);
|
|
359
|
-
healProfilesModuleFallback(dshInstallAnchor);
|
|
360
|
-
const profile = loadProfile("web", profileName, dshInstallAnchor);
|
|
361
|
-
const rootConfig = join(profile.dir, "cordis.yml");
|
|
362
|
-
writeFileSync(rootConfig, profileRoot);
|
|
363
|
-
const patches = structuredClone([
|
|
364
|
-
...profile.layers.flatMap((layer) => layer.patches),
|
|
365
|
-
...createAcrylCodingCapabilityPatches(/* @__PURE__ */ new Set(["web"])),
|
|
366
|
-
...profile.patches
|
|
367
|
-
]);
|
|
368
|
-
const cmdlineArgs = options.cmdlineArgs ?? [];
|
|
369
|
-
const ctx = await boot("web", rootConfig, patches, (hostCtx) => {
|
|
370
|
-
provideCmdline(hostCtx, {
|
|
371
|
-
args: [...cmdlineArgs],
|
|
372
|
-
exit: (code) => {
|
|
373
|
-
process.exitCode = code;
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
return options.prepare?.(hostCtx);
|
|
377
|
-
});
|
|
378
|
-
const startup = ctx.get("webStartup");
|
|
379
|
-
const url = `http://${startup?.host ?? "127.0.0.1"}:${startup?.port ?? 3080}`;
|
|
380
|
-
let disposed = false;
|
|
381
|
-
return Object.freeze({
|
|
382
|
-
ctx,
|
|
383
|
-
url,
|
|
384
|
-
profileDirectory: profile.dir,
|
|
385
|
-
async dispose() {
|
|
386
|
-
if (disposed) return;
|
|
387
|
-
disposed = true;
|
|
388
|
-
await ctx.fiber.dispose();
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
383
|
//#endregion
|
|
393
384
|
//#region src/host/direct.ts
|
|
394
385
|
/** Start one normal local Harness runtime for this terminal surface. */
|
|
@@ -5889,24 +5880,19 @@ function parseAcrylArgs(args) {
|
|
|
5889
5880
|
}
|
|
5890
5881
|
//#endregion
|
|
5891
5882
|
//#region src/cli/run.ts
|
|
5892
|
-
/**
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
process.stdout.write(`ACRYL web: ${url}\n`);
|
|
5902
|
-
await stopped;
|
|
5903
|
-
await runtime.dispose();
|
|
5904
|
-
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.");
|
|
5905
5892
|
}
|
|
5906
5893
|
const defaults = {
|
|
5907
5894
|
startDirectHost,
|
|
5908
5895
|
runTui: runAcrylTui,
|
|
5909
|
-
runWeb: serveWeb,
|
|
5910
5896
|
exit: (code) => {
|
|
5911
5897
|
process.exitCode = code;
|
|
5912
5898
|
},
|
|
@@ -5922,8 +5908,8 @@ function statusLine(host) {
|
|
|
5922
5908
|
});
|
|
5923
5909
|
}
|
|
5924
5910
|
/**
|
|
5925
|
-
* Run the
|
|
5926
|
-
*
|
|
5911
|
+
* Run the ACRYL terminal host. `--json` is a short-lived, scriptable
|
|
5912
|
+
* readiness probe; interactive mode mounts the pi-tui session via the
|
|
5927
5913
|
* runtime bridge until a normal exit, then prints a resumable session id.
|
|
5928
5914
|
*/
|
|
5929
5915
|
async function runAcryl(args, supplied = {}) {
|
|
@@ -5940,8 +5926,6 @@ async function runAcryl(args, supplied = {}) {
|
|
|
5940
5926
|
"",
|
|
5941
5927
|
"Commands:",
|
|
5942
5928
|
" tui Run the terminal client (default)",
|
|
5943
|
-
" web Serve the local ACRYL web runtime",
|
|
5944
|
-
" gui [reserved] launch the Desktop surface (not wired in this build)",
|
|
5945
5929
|
"",
|
|
5946
5930
|
"Options:",
|
|
5947
5931
|
" -h, --help Show this help",
|
|
@@ -5949,6 +5933,9 @@ async function runAcryl(args, supplied = {}) {
|
|
|
5949
5933
|
" --json Emit machine-readable output",
|
|
5950
5934
|
" --profile <name> Use a named ACRYL profile",
|
|
5951
5935
|
" --resume <id> Resume a session",
|
|
5936
|
+
"",
|
|
5937
|
+
"The browser (`acryl web`) and Electron (`acryl gui`) surfaces are ",
|
|
5938
|
+
"separate distributions. Install them individually.",
|
|
5952
5939
|
""
|
|
5953
5940
|
].join("\n"));
|
|
5954
5941
|
return;
|
|
@@ -5957,21 +5944,8 @@ async function runAcryl(args, supplied = {}) {
|
|
|
5957
5944
|
dependencies.write(ACRYL_VERSION);
|
|
5958
5945
|
return;
|
|
5959
5946
|
}
|
|
5960
|
-
if (invocation.command === "
|
|
5961
|
-
if (invocation.command === "
|
|
5962
|
-
if (invocation.json) {
|
|
5963
|
-
const host = await bootAcrylWebProfile({ cmdlineArgs: [] });
|
|
5964
|
-
try {
|
|
5965
|
-
dependencies.write(host.url);
|
|
5966
|
-
} finally {
|
|
5967
|
-
await host.dispose();
|
|
5968
|
-
}
|
|
5969
|
-
return;
|
|
5970
|
-
}
|
|
5971
|
-
const result = await dependencies.runWeb({ profile: invocation.profile ?? "web" });
|
|
5972
|
-
dependencies.write(`serving at ${result.url}`);
|
|
5973
|
-
return;
|
|
5974
|
-
}
|
|
5947
|
+
if (invocation.command === "web") throw surfaceError("web");
|
|
5948
|
+
if (invocation.command === "gui") throw surfaceError("gui");
|
|
5975
5949
|
if (invocation.json) {
|
|
5976
5950
|
const host = await dependencies.startDirectHost({ profile: invocation.profile ?? "acryl" });
|
|
5977
5951
|
try {
|