acryl 0.1.11 → 0.1.12

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.
Files changed (53) hide show
  1. package/lib/bin.js +325 -6
  2. package/package.json +1 -1
  3. package/lib/bin.js.map +0 -1
  4. package/lib/index.js +0 -5051
  5. package/lib/index.js.map +0 -1
  6. package/lib/types/bin.d.ts +0 -4
  7. package/lib/types/cli/grammar.d.ts +0 -9
  8. package/lib/types/cli/node-launcher.d.ts +0 -9
  9. package/lib/types/cli/run.d.ts +0 -32
  10. package/lib/types/host/direct.d.ts +0 -18
  11. package/lib/types/index.d.ts +0 -3
  12. package/lib/types/markdown.d.ts +0 -28
  13. package/lib/types/render.d.ts +0 -78
  14. package/lib/types/sessionId.d.ts +0 -12
  15. package/lib/types/tui/CustomEditor.d.ts +0 -51
  16. package/lib/types/tui/Spinner.d.ts +0 -18
  17. package/lib/types/tui/TuiApp.d.ts +0 -64
  18. package/lib/types/tui/actions.d.ts +0 -85
  19. package/lib/types/tui/agentPresets/AgentPresetsOverlay.d.ts +0 -19
  20. package/lib/types/tui/agentPresets/types.d.ts +0 -18
  21. package/lib/types/tui/bannerText.d.ts +0 -19
  22. package/lib/types/tui/commands.d.ts +0 -54
  23. package/lib/types/tui/context/ContextOverlay.d.ts +0 -17
  24. package/lib/types/tui/fileIndex.d.ts +0 -17
  25. package/lib/types/tui/fileMention.d.ts +0 -31
  26. package/lib/types/tui/interaction/ApprovalOverlay.d.ts +0 -18
  27. package/lib/types/tui/interaction/QuestionOverlay.d.ts +0 -26
  28. package/lib/types/tui/interaction/types.d.ts +0 -36
  29. package/lib/types/tui/liveText.d.ts +0 -60
  30. package/lib/types/tui/logoArt.generated.d.ts +0 -9
  31. package/lib/types/tui/miniTextField.d.ts +0 -20
  32. package/lib/types/tui/modelProfile/ModelProfileOverlay.d.ts +0 -48
  33. package/lib/types/tui/modelProfile/types.d.ts +0 -63
  34. package/lib/types/tui/piTheme.d.ts +0 -10
  35. package/lib/types/tui/plugins/PluginsOverlay.d.ts +0 -22
  36. package/lib/types/tui/plugins/types.d.ts +0 -18
  37. package/lib/types/tui/promptAutocomplete.d.ts +0 -29
  38. package/lib/types/tui/statsFormat.d.ts +0 -89
  39. package/lib/types/tui/store.d.ts +0 -246
  40. package/lib/types/tui/text.d.ts +0 -21
  41. package/lib/types/tui/theme.d.ts +0 -35
  42. package/lib/types/tui/toolCards/ToolCardsOverlay.d.ts +0 -33
  43. package/lib/types/tui/trajectory/TrajectoryDetail.d.ts +0 -13
  44. package/lib/types/tui/trajectory/TrajectoryLedger.d.ts +0 -9
  45. package/lib/types/tui/trajectory/TrajectoryOverlay.d.ts +0 -39
  46. package/lib/types/tui/trajectory/detail.d.ts +0 -10
  47. package/lib/types/tui/trajectory/layout.d.ts +0 -16
  48. package/lib/types/tui/trajectory/types.d.ts +0 -74
  49. package/lib/types/tui-app/session.d.ts +0 -21
  50. package/lib/types/version.d.ts +0 -2
  51. package/lib/types/yly/yly-frames.generated.d.ts +0 -18
  52. package/lib/types/yly/yly-pet.d.ts +0 -46
  53. package/lib/types/yly/yly-programs.d.ts +0 -41
package/lib/bin.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
3
  import { fileURLToPath } from "node:url";
4
- import { realpathSync } from "node:fs";
5
- import { join, relative, resolve } from "node:path";
4
+ import { existsSync, realpathSync, writeFileSync } from "node:fs";
5
+ import { dirname, join, relative, resolve } from "node:path";
6
6
  import { spawn } from "node:child_process";
7
7
  import { randomUUID } from "node:crypto";
8
- import { bootAcrylHarnessProfile, bootAcrylWebProfile, createAcrylSessionBridge } from "acryl-harness-runtime";
9
8
  import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
9
+ import { SessionId } from "@deepseek-ai/dsh-session";
10
+ import { DEFAULT_PROFILE_BUNDLES, boot, composeEntries, healProfilesModuleFallback, initProfile, loadProfile, resolveProfileDir } from "@deepseek-ai/dsh-app-boot";
10
11
  import { diffLines } from "diff";
11
12
  import { Container, Editor, HStack, Key, KeybindingsManager, ProcessTerminal, ScrollView, TUI_KEYBINDINGS, Text, TuiAltScreen, VStack, matchesKey, setKeybindings, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
12
13
  import { readdir } from "node:fs/promises";
13
14
  import { ManualCompactionError } from "@deepseek-ai/dsh-compaction";
14
15
  import { GoalError } from "@deepseek-ai/dsh-goal";
15
- import { SessionId } from "@deepseek-ai/dsh-session";
16
16
  //#region src/cli/node-launcher.ts
17
17
  /** Return the child Node invocation required to expose Cordis HMR internals. */
18
18
  function exposedInternalsInvocation(input) {
@@ -37,6 +37,327 @@ async function relaunchWithExposedInternals(input) {
37
37
  return true;
38
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
+ process.stdout, process.stderr;
71
+ //#endregion
72
+ //#region ../acryl-harness-runtime/lib/index.mjs
73
+ function contentText(content) {
74
+ return content.filter((block) => {
75
+ return block.type === "text" && typeof block.text === "string";
76
+ }).map((block) => block.text).join("");
77
+ }
78
+ function transcript(events) {
79
+ const items = [];
80
+ for (const event of events) {
81
+ if (event.type === "user/message" && event.data.source.kind === "user") {
82
+ const text = contentText(event.data.content);
83
+ if (text !== "") items.push(Object.freeze({
84
+ id: `event-${event.seq}`,
85
+ author: "user",
86
+ text
87
+ }));
88
+ }
89
+ if (event.type === "assistant/message") {
90
+ const text = contentText(event.data.message.content);
91
+ if (text !== "") items.push(Object.freeze({
92
+ id: `event-${event.seq}`,
93
+ author: "assistant",
94
+ text
95
+ }));
96
+ }
97
+ }
98
+ return Object.freeze(items);
99
+ }
100
+ function tools(events) {
101
+ const current = /* @__PURE__ */ new Map();
102
+ for (const event of events) {
103
+ if (event.type === "tool/call") current.set(event.data.callId, Object.freeze({
104
+ callId: event.data.callId,
105
+ name: event.data.name,
106
+ status: "running"
107
+ }));
108
+ if (event.type === "tool/result") {
109
+ const callId = event.data.message.source.callId;
110
+ const existing = current.get(callId);
111
+ if (existing !== void 0) current.set(callId, Object.freeze({
112
+ ...existing,
113
+ status: "succeeded"
114
+ }));
115
+ }
116
+ }
117
+ return Object.freeze([...current.values()]);
118
+ }
119
+ function status(agent) {
120
+ return agent.status === "running" ? "running" : "idle";
121
+ }
122
+ /**
123
+ * Runtime-owned adapter over one native DSH agent/session. It creates or resumes
124
+ * the native agent and derives every presentation value from its durable log.
125
+ */
126
+ function createAcrylSessionBridge(ctx, options) {
127
+ const handles = /* @__PURE__ */ new Map();
128
+ const subscribers = /* @__PURE__ */ new Map();
129
+ const eventListeners = /* @__PURE__ */ new Map();
130
+ let disposed = false;
131
+ const notify = (sessionId) => {
132
+ const listeners = subscribers.get(sessionId);
133
+ if (listeners === void 0) return;
134
+ snapshot(sessionId).then((next) => {
135
+ for (const listener of listeners) try {
136
+ listener(next);
137
+ } catch {}
138
+ });
139
+ };
140
+ const offSessionEvent = ctx.on("session/event", (session, event) => {
141
+ if (!handles.has(session.id)) return;
142
+ notify(session.id);
143
+ const listeners = eventListeners.get(session.id);
144
+ if (listeners === void 0) return;
145
+ for (const listener of listeners) try {
146
+ listener(event);
147
+ } catch {}
148
+ });
149
+ const snapshot = async (sessionId) => {
150
+ const agent = agentFor(sessionId);
151
+ return Object.freeze({
152
+ profile: options.profile,
153
+ generationId: options.generationId,
154
+ attachment: options.attachment,
155
+ sessionId: agent.id,
156
+ agentStatus: status(agent),
157
+ transcript: transcript(agent.session.events),
158
+ tools: tools(agent.session.events)
159
+ });
160
+ };
161
+ const agentFor = (sessionId) => {
162
+ if (disposed) throw new Error("ACRYL session bridge is disposed");
163
+ const handle = handles.get(sessionId);
164
+ if (handle === void 0) throw new Error(`ACRYL session ${sessionId} is not active`);
165
+ return handle.agent;
166
+ };
167
+ return Object.freeze({
168
+ async open(resumeSessionId) {
169
+ if (disposed) throw new Error("ACRYL session bridge is disposed");
170
+ if (handles.size !== 0) throw new Error("ACRYL session bridge already has an active session");
171
+ const defaultModel = ctx.get("agentDefaultModel");
172
+ if (defaultModel === void 0) throw new Error("ACRYL profile has no default agent model");
173
+ const selection = defaultModel.currentSelection();
174
+ const handle = resumeSessionId === void 0 ? await ctx.agents.create({
175
+ sessionId: SessionId(`acryl-session-${crypto.randomUUID()}`),
176
+ meta: { cwd: options.cwd },
177
+ agentOptions: {
178
+ provider: selection.provider,
179
+ model: selection.model
180
+ }
181
+ }) : await ctx.agents.resume({
182
+ resumeSessionId: SessionId(resumeSessionId),
183
+ agentOptions: {
184
+ provider: selection.provider,
185
+ model: selection.model
186
+ }
187
+ });
188
+ handles.set(handle.agent.id, handle);
189
+ return handle.agent.id;
190
+ },
191
+ snapshot,
192
+ events(sessionId) {
193
+ return agentFor(sessionId).session.events;
194
+ },
195
+ async subscribe(sessionId, listener, _onError) {
196
+ agentFor(sessionId);
197
+ const listeners = subscribers.get(sessionId) ?? /* @__PURE__ */ new Set();
198
+ subscribers.set(sessionId, listeners);
199
+ listeners.add(listener);
200
+ try {
201
+ listener(await snapshot(sessionId));
202
+ } catch {}
203
+ let active = true;
204
+ return Object.freeze({
205
+ whenError() {
206
+ return new Promise(() => {});
207
+ },
208
+ async dispose() {
209
+ if (!active) return;
210
+ active = false;
211
+ listeners.delete(listener);
212
+ if (listeners.size === 0) subscribers.delete(sessionId);
213
+ }
214
+ });
215
+ },
216
+ async subscribeEvents(sessionId, listener) {
217
+ agentFor(sessionId);
218
+ const listeners = eventListeners.get(sessionId) ?? /* @__PURE__ */ new Set();
219
+ eventListeners.set(sessionId, listeners);
220
+ listeners.add(listener);
221
+ let active = true;
222
+ return Object.freeze({ async dispose() {
223
+ if (!active) return;
224
+ active = false;
225
+ listeners.delete(listener);
226
+ if (listeners.size === 0) eventListeners.delete(sessionId);
227
+ } });
228
+ },
229
+ async submitPrompt(input) {
230
+ const agent = agentFor(input.sessionId);
231
+ if (input.text.trim() === "") throw new Error("ACRYL prompt must not be empty");
232
+ const accepted = new Promise((resolve) => {
233
+ const off = ctx.on("session/event", (session, event) => {
234
+ if (session !== agent.session || event.type !== "user/message") return;
235
+ off();
236
+ resolve();
237
+ });
238
+ });
239
+ agent.followup(createUserMessage({
240
+ content: [{
241
+ type: "text",
242
+ text: input.text
243
+ }],
244
+ source: { kind: "user" }
245
+ }));
246
+ await accepted;
247
+ },
248
+ async cancel(sessionId) {
249
+ agentFor(sessionId).cancel({ kind: "user" });
250
+ },
251
+ async dispose() {
252
+ if (disposed) return;
253
+ disposed = true;
254
+ offSessionEvent();
255
+ subscribers.clear();
256
+ eventListeners.clear();
257
+ const activeHandles = [...handles.values()];
258
+ handles.clear();
259
+ const sessions = ctx.get("sessions");
260
+ for (const handle of activeHandles) {
261
+ try {
262
+ await handle.agent.whenIdle();
263
+ } catch {}
264
+ try {
265
+ await sessions?.flush(handle.agent.session);
266
+ } catch {}
267
+ }
268
+ await Promise.all(activeHandles.map((handle) => handle.dispose()));
269
+ }
270
+ });
271
+ }
272
+ const dshInstallAnchor = createRequire(import.meta.url).resolve("@deepseek-ai/dsh/package.json");
273
+ 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
+ id: "agent-presets",
281
+ name: "@deepseek-ai/dsh-agent-presets",
282
+ config: {
283
+ default: "standard",
284
+ roots: existsSync(shippedPresetsDir) ? [{
285
+ path: shippedPresetsDir,
286
+ trust: "system"
287
+ }] : [],
288
+ includeShippedRoot: false,
289
+ includeUserRoot: true
290
+ }
291
+ }, {
292
+ id: "session-stats",
293
+ name: "@deepseek-ai/dsh-session-stats"
294
+ }] }];
295
+ /** Boot one normal pinned-Harness ACRYL profile in a single Cordis root. */
296
+ async function bootAcrylHarnessProfile(options) {
297
+ if (options.profile.trim() === "") throw new Error("ACRYL Harness profile must not be empty");
298
+ initProfile(resolveProfileDir(options.profile), DEFAULT_PROFILE_BUNDLES);
299
+ healProfilesModuleFallback(dshInstallAnchor);
300
+ const profile = loadProfile("acryl", options.profile, dshInstallAnchor);
301
+ const rootConfig = join(profile.dir, "cordis.yml");
302
+ writeFileSync(rootConfig, profileRoot);
303
+ const patches = structuredClone([
304
+ ...profile.layers.flatMap((layer) => layer.patches),
305
+ ...ACRYL_RUNTIME_ROWS,
306
+ ...profile.patches
307
+ ]);
308
+ 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");
309
+ const ctx = await boot("acryl", rootConfig, patches, options.prepare);
310
+ let disposed = false;
311
+ return Object.freeze({
312
+ ctx,
313
+ profileDirectory: profile.dir,
314
+ async dispose() {
315
+ if (disposed) return;
316
+ disposed = true;
317
+ await ctx.fiber.dispose();
318
+ }
319
+ });
320
+ }
321
+ /**
322
+ * Boot the DSH browser surface (the `web` profile: `dsh-base` + `dsh-web-app`)
323
+ * as one normal ACRYL runtime, so `pnpm acryl-web` serves the same DSH
324
+ * HTTP/WebSocket seam the web surface always uses. The web profile already
325
+ * composes the persona/agent rows ACRYL's terminal surface adds, so no
326
+ * ACRYL_RUNTIME_ROWS are re-inserted (that would duplicate `system-prompt`).
327
+ */
328
+ async function bootAcrylWebProfile(options = {}) {
329
+ const profileName = "web";
330
+ initProfile(resolveProfileDir(profileName), DEFAULT_PROFILE_BUNDLES);
331
+ healProfilesModuleFallback(dshInstallAnchor);
332
+ const profile = loadProfile("web", profileName, dshInstallAnchor);
333
+ const rootConfig = join(profile.dir, "cordis.yml");
334
+ writeFileSync(rootConfig, profileRoot);
335
+ const patches = structuredClone([...profile.layers.flatMap((layer) => layer.patches), ...profile.patches]);
336
+ const cmdlineArgs = options.cmdlineArgs ?? [];
337
+ const ctx = await boot("web", rootConfig, patches, (hostCtx) => {
338
+ provideCmdline(hostCtx, {
339
+ args: [...cmdlineArgs],
340
+ exit: (code) => {
341
+ process.exitCode = code;
342
+ }
343
+ });
344
+ return options.prepare?.(hostCtx);
345
+ });
346
+ const startup = ctx.get("webStartup");
347
+ const url = `http://${startup?.host ?? "127.0.0.1"}:${startup?.port ?? 3080}`;
348
+ let disposed = false;
349
+ return Object.freeze({
350
+ ctx,
351
+ url,
352
+ profileDirectory: profile.dir,
353
+ async dispose() {
354
+ if (disposed) return;
355
+ disposed = true;
356
+ await ctx.fiber.dispose();
357
+ }
358
+ });
359
+ }
360
+ //#endregion
40
361
  //#region src/host/direct.ts
41
362
  /** Start one normal local Harness runtime for this terminal surface. */
42
363
  /**
@@ -5185,5 +5506,3 @@ if (isEntrypoint()) (async () => {
5185
5506
  });
5186
5507
  //#endregion
5187
5508
  export { parseAcrylArgs, runAcryl };
5188
-
5189
- //# sourceMappingURL=bin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acryl",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "ACRYL local-first coding-agent workspace CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",