dirac-lang 0.1.69 → 0.1.70

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.
@@ -2,8 +2,8 @@ import {
2
2
  SessionServer,
3
3
  getSocketPath,
4
4
  isSessionRunning
5
- } from "./chunk-65TBONV6.js";
6
- import "./chunk-QUFYZS2S.js";
5
+ } from "./chunk-2SJHHQ5D.js";
6
+ import "./chunk-WW2OXQZN.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-VC23AJJJ.js";
9
9
  import "./chunk-M57VI7KL.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-QUFYZS2S.js";
3
+ } from "./chunk-WW2OXQZN.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-QUFYZS2S.js";
3
+ } from "./chunk-WW2OXQZN.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
@@ -474,12 +474,12 @@ async function executeIf(session, element) {
474
474
  const condition = await evaluatePredicate(session, conditionElement);
475
475
  if (condition) {
476
476
  if (thenElement) {
477
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
477
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
478
478
  await integrateChildren2(session, thenElement);
479
479
  }
480
480
  } else {
481
481
  if (elseElement) {
482
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
482
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
483
483
  await integrateChildren2(session, elseElement);
484
484
  }
485
485
  }
@@ -492,7 +492,7 @@ async function evaluatePredicate(session, predicateElement) {
492
492
  return await evaluateCondition(session, predicateElement);
493
493
  }
494
494
  const outputLengthBefore = session.output.length;
495
- const { integrate: integrate2 } = await import("./interpreter-N4ERLMWW.js");
495
+ const { integrate: integrate2 } = await import("./interpreter-TKNNX6UX.js");
496
496
  await integrate2(session, predicateElement);
497
497
  const newOutputChunks = session.output.slice(outputLengthBefore);
498
498
  const result = newOutputChunks.join("").trim();
@@ -515,11 +515,11 @@ async function evaluateCondition(session, condElement) {
515
515
  }
516
516
  const outputLengthBefore = session.output.length;
517
517
  const args = [];
518
- const { integrate: integrate2 } = await import("./interpreter-N4ERLMWW.js");
518
+ const { integrate: integrate2 } = await import("./interpreter-TKNNX6UX.js");
519
519
  for (const child of condElement.children) {
520
520
  if (child.tag.toLowerCase() === "arg") {
521
521
  const argOutputStart = session.output.length;
522
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
522
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
523
523
  await integrateChildren2(session, child);
524
524
  const newChunks = session.output.slice(argOutputStart);
525
525
  const argValue = newChunks.join("");
@@ -1740,7 +1740,7 @@ async function executeTagCheck(session, element) {
1740
1740
  const executeTag = correctedTag || tagName;
1741
1741
  console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
1742
1742
  const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
1743
- const { integrate: integrate2 } = await import("./interpreter-N4ERLMWW.js");
1743
+ const { integrate: integrate2 } = await import("./interpreter-TKNNX6UX.js");
1744
1744
  await integrate2(session, elementToExecute);
1745
1745
  }
1746
1746
  }
@@ -1749,7 +1749,7 @@ async function executeTagCheck(session, element) {
1749
1749
  // src/tags/throw.ts
1750
1750
  async function executeThrow(session, element) {
1751
1751
  const exceptionName = element.attributes?.name || "exception";
1752
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
1752
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
1753
1753
  const exceptionDom = {
1754
1754
  tag: "exception-content",
1755
1755
  attributes: { name: exceptionName },
@@ -1762,7 +1762,7 @@ async function executeThrow(session, element) {
1762
1762
  // src/tags/try.ts
1763
1763
  async function executeTry(session, element) {
1764
1764
  setExceptionBoundary(session);
1765
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
1765
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
1766
1766
  await integrateChildren2(session, element);
1767
1767
  unsetExceptionBoundary(session);
1768
1768
  }
@@ -1772,7 +1772,7 @@ async function executeCatch(session, element) {
1772
1772
  const exceptionName = element.attributes?.name || "exception";
1773
1773
  const caughtCount = lookupException(session, exceptionName);
1774
1774
  if (caughtCount > 0) {
1775
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
1775
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
1776
1776
  await integrateChildren2(session, element);
1777
1777
  }
1778
1778
  flushCurrentException(session);
@@ -1781,7 +1781,7 @@ async function executeCatch(session, element) {
1781
1781
  // src/tags/exception.ts
1782
1782
  async function executeException(session, element) {
1783
1783
  const exceptions = getCurrentExceptions(session);
1784
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-N4ERLMWW.js");
1784
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-TKNNX6UX.js");
1785
1785
  for (const exceptionDom of exceptions) {
1786
1786
  await integrateChildren2(session, exceptionDom);
1787
1787
  }
@@ -2046,6 +2046,7 @@ var SubroutineRegistry = class {
2046
2046
  this.index.subroutines = this.index.subroutines.filter((s) => s.filePath !== filePath);
2047
2047
  const subroutines = this.extractSubroutines(ast, filePath);
2048
2048
  this.index.subroutines.push(...subroutines);
2049
+ this.saveIndex();
2049
2050
  return subroutines.length;
2050
2051
  } catch (err) {
2051
2052
  if (process.env.DEBUG_REGISTRY === "1") {
@@ -2242,14 +2243,13 @@ async function executeRegistryStats(session, element) {
2242
2243
  }
2243
2244
 
2244
2245
  // src/tags/load-context.ts
2245
- var registry2 = new SubroutineRegistry();
2246
2246
  async function executeLoadContext(session, element) {
2247
2247
  let query = element.attributes.query;
2248
2248
  if (!query && element.text) {
2249
2249
  query = element.text.trim();
2250
2250
  }
2251
2251
  if (!query && element.children.length > 0) {
2252
- const { integrate: integrate2 } = await import("./interpreter-N4ERLMWW.js");
2252
+ const { integrate: integrate2 } = await import("./interpreter-TKNNX6UX.js");
2253
2253
  const beforeOutput = session.output.length;
2254
2254
  for (const child of element.children) {
2255
2255
  await integrate2(session, child);
@@ -2264,14 +2264,14 @@ async function executeLoadContext(session, element) {
2264
2264
  const limitAttr = element.attributes.limit;
2265
2265
  const shouldImport = element.attributes.import !== "false";
2266
2266
  const outputVar = element.attributes.output;
2267
- const stats = registry2.getStats();
2267
+ const stats = registry.getStats();
2268
2268
  if (stats.totalSubroutines === 0) {
2269
2269
  emit(session, `[load-context] Registry is empty. Use :index <path> or <index-subroutines path="..."> first.
2270
2270
  `);
2271
2271
  return;
2272
2272
  }
2273
2273
  const limit = limitAttr ? parseInt(limitAttr, 10) : 5;
2274
- const results = registry2.search(query, limit);
2274
+ const results = registry.search(query, limit);
2275
2275
  if (results.length === 0) {
2276
2276
  emit(session, `[load-context] No subroutines found for query: "${query}". Try indexing more libraries.
2277
2277
  `);
@@ -2324,7 +2324,7 @@ async function executeLoadContext(session, element) {
2324
2324
  }
2325
2325
 
2326
2326
  // src/tags/save-subroutine.ts
2327
- import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
2327
+ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, existsSync as existsSync5 } from "fs";
2328
2328
  import { resolve as resolve3, dirname as dirname4, join as join4 } from "path";
2329
2329
  import { homedir as homedir4 } from "os";
2330
2330
  async function executeSaveSubroutine(session, element) {
@@ -2352,40 +2352,13 @@ async function executeSaveSubroutine(session, element) {
2352
2352
  content = generateXMLNotation(subroutine);
2353
2353
  }
2354
2354
  let filePath;
2355
- let shouldMerge = false;
2356
2355
  if (file) {
2357
2356
  filePath = resolve3(process.cwd(), file);
2358
2357
  } else if (pathAttr) {
2359
2358
  const targetDir = join4(homedir4(), ".dirac", "lib", pathAttr);
2360
2359
  filePath = join4(targetDir, `${name}.di`);
2361
- } else if (subroutine.sourcePath && existsSync5(subroutine.sourcePath)) {
2362
- const sourceFile = subroutine.sourcePath;
2363
- const sourceContent = readFileSync3(sourceFile, "utf-8");
2364
- const parser = new DiracParser();
2365
- try {
2366
- const ast = parser.parse(sourceContent);
2367
- const subroutineCount = countSubroutines(ast);
2368
- if (subroutineCount === 1) {
2369
- filePath = sourceFile;
2370
- emit(session, `Updating single-subroutine file: ${filePath}
2371
- `);
2372
- } else {
2373
- emit(session, `Source file contains ${subroutineCount} subroutines - creating separate file
2374
- `);
2375
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
2376
- const defaultDir = join4(homedir4(), ".dirac", "lib", timestamp);
2377
- filePath = join4(defaultDir, `${name}.di`);
2378
- }
2379
- } catch (error) {
2380
- emit(session, `Warning: Could not parse source file - creating new file
2381
- `);
2382
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
2383
- const defaultDir = join4(homedir4(), ".dirac", "lib", timestamp);
2384
- filePath = join4(defaultDir, `${name}.di`);
2385
- }
2386
2360
  } else {
2387
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
2388
- const defaultDir = join4(homedir4(), ".dirac", "lib", timestamp);
2361
+ const defaultDir = join4(homedir4(), ".dirac", "lib", "user");
2389
2362
  filePath = join4(defaultDir, `${name}.di`);
2390
2363
  }
2391
2364
  const dir = dirname4(filePath);
@@ -2399,8 +2372,7 @@ async function executeSaveSubroutine(session, element) {
2399
2372
  console.error(`[save-subroutine] Saved '${name}' to: ${filePath}`);
2400
2373
  }
2401
2374
  try {
2402
- const registry3 = new SubroutineRegistry();
2403
- const count = registry3.indexFile(filePath);
2375
+ const count = registry.indexFile(filePath);
2404
2376
  if (session.debug) {
2405
2377
  console.error(`[save-subroutine] Re-indexed ${filePath}: ${count} subroutine(s)`);
2406
2378
  }
@@ -2518,21 +2490,9 @@ function serializeChildrenBraKet(children, indent) {
2518
2490
  function escapeXml3(text) {
2519
2491
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
2520
2492
  }
2521
- function countSubroutines(element) {
2522
- let count = 0;
2523
- if (element.tag === "subroutine") {
2524
- count = 1;
2525
- }
2526
- if (element.children) {
2527
- for (const child of element.children) {
2528
- count += countSubroutines(child);
2529
- }
2530
- }
2531
- return count;
2532
- }
2533
2493
 
2534
2494
  // src/tags/edit-subroutine.ts
2535
- import { writeFileSync as writeFileSync5, readFileSync as readFileSync4, unlinkSync } from "fs";
2495
+ import { writeFileSync as writeFileSync5, readFileSync as readFileSync3, unlinkSync } from "fs";
2536
2496
  import { tmpdir } from "os";
2537
2497
  import { join as join5 } from "path";
2538
2498
  import { spawnSync } from "child_process";
@@ -2572,7 +2532,7 @@ async function executeEditSubroutine(session, element) {
2572
2532
  unlinkSync(tempFile);
2573
2533
  throw new Error(`Editor exited with code ${result.status}`);
2574
2534
  }
2575
- const editedContent = readFileSync4(tempFile, "utf-8");
2535
+ const editedContent = readFileSync3(tempFile, "utf-8");
2576
2536
  unlinkSync(tempFile);
2577
2537
  if (session.debug) {
2578
2538
  console.error(`[edit-subroutine] Editor closed, re-importing subroutine`);
@@ -2645,7 +2605,7 @@ async function executeForeach(session, element) {
2645
2605
  const parser2 = new DiracParser2();
2646
2606
  try {
2647
2607
  const fromElement = parser2.parse(fromAttr);
2648
- const { integrate: integrate2 } = await import("./interpreter-N4ERLMWW.js");
2608
+ const { integrate: integrate2 } = await import("./interpreter-TKNNX6UX.js");
2649
2609
  await integrate2(session, fromElement);
2650
2610
  } catch (e) {
2651
2611
  session.output = savedOutput;
package/dist/cli.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  } from "./chunk-AJSYOXXZ.js";
5
5
  import {
6
6
  execute
7
- } from "./chunk-6SKZC4N7.js";
8
- import "./chunk-QUFYZS2S.js";
7
+ } from "./chunk-3YGHR3R7.js";
8
+ import "./chunk-WW2OXQZN.js";
9
9
  import "./chunk-HRHAMPOB.js";
10
10
  import "./chunk-VC23AJJJ.js";
11
11
  import "./chunk-M57VI7KL.js";
@@ -16,7 +16,7 @@ import "dotenv/config";
16
16
  // package.json
17
17
  var package_default = {
18
18
  name: "dirac-lang",
19
- version: "0.1.68",
19
+ version: "0.1.69",
20
20
  description: "LLM-Augmented Declarative Execution",
21
21
  type: "module",
22
22
  main: "dist/index.js",
@@ -109,7 +109,7 @@ async function main() {
109
109
  const args = process.argv.slice(2);
110
110
  const calledAs = process.argv[1];
111
111
  if (calledAs && calledAs.endsWith("/dish")) {
112
- const { DiracShell } = await import("./shell-BYGHH5YH.js");
112
+ const { DiracShell } = await import("./shell-GYZYKP7V.js");
113
113
  const shellConfig = loadShellConfig(args);
114
114
  const shell = new DiracShell(shellConfig);
115
115
  await shell.start();
@@ -158,11 +158,11 @@ async function main() {
158
158
  if (args[0] === "agent") {
159
159
  const subcommand = args[1];
160
160
  if (subcommand === "daemon") {
161
- const { runAgentDaemon } = await import("./agent-RH5SYOLV.js");
161
+ const { runAgentDaemon } = await import("./agent-YEC64Z37.js");
162
162
  await runAgentDaemon();
163
163
  return;
164
164
  }
165
- const { AgentCLI } = await import("./agent-RH5SYOLV.js");
165
+ const { AgentCLI } = await import("./agent-YEC64Z37.js");
166
166
  const agent = new AgentCLI();
167
167
  switch (subcommand) {
168
168
  case "start":
@@ -189,8 +189,8 @@ async function main() {
189
189
  return;
190
190
  }
191
191
  if (args[0] === "shell") {
192
- const { DiracShell } = await import("./shell-BYGHH5YH.js");
193
- const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-XV4RB5IW.js");
192
+ const { DiracShell } = await import("./shell-GYZYKP7V.js");
193
+ const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-QQGWVEOL.js");
194
194
  const { SessionClient } = await import("./session-client-3VTC5MLO.js");
195
195
  const daemonMode = args.includes("--daemon") || args.includes("-d");
196
196
  const agentMode = args.includes("--agent") || args.includes("-a");
@@ -236,7 +236,7 @@ async function main() {
236
236
  return;
237
237
  }
238
238
  if (args[0] === "daemon") {
239
- const { SessionServer } = await import("./session-server-XV4RB5IW.js");
239
+ const { SessionServer } = await import("./session-server-QQGWVEOL.js");
240
240
  const server = new SessionServer();
241
241
  await server.start();
242
242
  console.log("Session daemon started");
@@ -3,7 +3,7 @@ import {
3
3
  listCronJobs,
4
4
  stopAllCronJobs,
5
5
  stopCronJob
6
- } from "./chunk-QUFYZS2S.js";
6
+ } from "./chunk-WW2OXQZN.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-VC23AJJJ.js";
9
9
  import "./chunk-M57VI7KL.js";
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createLLMAdapter,
3
3
  execute,
4
4
  executeUserCommand
5
- } from "./chunk-6SKZC4N7.js";
5
+ } from "./chunk-3YGHR3R7.js";
6
6
  import {
7
7
  integrate
8
- } from "./chunk-QUFYZS2S.js";
8
+ } from "./chunk-WW2OXQZN.js";
9
9
  import {
10
10
  DiracParser
11
11
  } from "./chunk-HRHAMPOB.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  integrate,
3
3
  integrateChildren
4
- } from "./chunk-QUFYZS2S.js";
4
+ } from "./chunk-WW2OXQZN.js";
5
5
  import "./chunk-HRHAMPOB.js";
6
6
  import "./chunk-VC23AJJJ.js";
7
7
  import "./chunk-M57VI7KL.js";
@@ -3,7 +3,7 @@ import {
3
3
  cancelScheduledRun,
4
4
  executeRunAt,
5
5
  listScheduledRuns
6
- } from "./chunk-QUFYZS2S.js";
6
+ } from "./chunk-WW2OXQZN.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-VC23AJJJ.js";
9
9
  import "./chunk-M57VI7KL.js";
@@ -3,7 +3,7 @@ import {
3
3
  listScheduledTasks,
4
4
  stopAllScheduledTasks,
5
5
  stopScheduledTask
6
- } from "./chunk-QUFYZS2S.js";
6
+ } from "./chunk-WW2OXQZN.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-VC23AJJJ.js";
9
9
  import "./chunk-M57VI7KL.js";
@@ -2,8 +2,8 @@ import {
2
2
  SessionServer,
3
3
  getSocketPath,
4
4
  isSessionRunning
5
- } from "./chunk-65TBONV6.js";
6
- import "./chunk-QUFYZS2S.js";
5
+ } from "./chunk-2SJHHQ5D.js";
6
+ import "./chunk-WW2OXQZN.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-VC23AJJJ.js";
9
9
  import "./chunk-M57VI7KL.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AJSYOXXZ.js";
5
5
  import {
6
6
  integrate
7
- } from "./chunk-QUFYZS2S.js";
7
+ } from "./chunk-WW2OXQZN.js";
8
8
  import {
9
9
  DiracParser
10
10
  } from "./chunk-HRHAMPOB.js";
@@ -271,7 +271,7 @@ var DiracShell = class {
271
271
  } catch (err) {
272
272
  }
273
273
  }
274
- checkUnsavedSubroutines() {
274
+ getUnsavedSubroutines() {
275
275
  const unsaved = [];
276
276
  const excludePaths = [
277
277
  path.join(os.homedir(), ".dirac", "lib"),
@@ -284,7 +284,7 @@ var DiracShell = class {
284
284
  continue;
285
285
  }
286
286
  if (!sub.sourcePath) {
287
- unsaved.push({ name: sub.name, reason: "created in session" });
287
+ unsaved.push(sub.name);
288
288
  } else {
289
289
  const isExcluded = excludePaths.some(
290
290
  (excludePath) => sub.sourcePath.startsWith(excludePath)
@@ -292,28 +292,51 @@ var DiracShell = class {
292
292
  if (isExcluded) {
293
293
  continue;
294
294
  }
295
- if (fs.existsSync(sub.sourcePath)) {
296
- try {
297
- const content = fs.readFileSync(sub.sourcePath, "utf-8");
298
- const parser = new DiracParser();
299
- const ast = parser.parse(content);
300
- const count = this.countSubroutinesInAST(ast);
301
- if (count > 1) {
302
- const shortPath = sub.sourcePath.replace(os.homedir(), "~");
303
- unsaved.push({ name: sub.name, reason: `from multi-sub file (${shortPath})` });
304
- }
305
- } catch (err) {
306
- }
307
- }
308
295
  }
309
296
  }
310
- if (unsaved.length > 0) {
311
- console.log("\n\u26A0\uFE0F Warning: You have unsaved subroutines:");
312
- for (const { name, reason } of unsaved) {
313
- console.log(` - ${name} (${reason})`);
314
- }
315
- console.log('\nUse :save <name> or |save-subroutine name="..."> to persist them.\n');
297
+ return unsaved;
298
+ }
299
+ async promptSaveUnsaved(unsaved) {
300
+ console.log("\n\u26A0\uFE0F Warning: You have unsaved subroutines created in this session:");
301
+ for (const name of unsaved) {
302
+ console.log(` - ${name}`);
316
303
  }
304
+ console.log("\nOptions:");
305
+ console.log(" a - Save all and exit");
306
+ console.log(" n - Exit without saving");
307
+ console.log(" c - Cancel (return to shell)");
308
+ return new Promise((resolve2) => {
309
+ const confirmRl = readline.createInterface({
310
+ input: process.stdin,
311
+ output: process.stdout
312
+ });
313
+ confirmRl.question("\nYour choice [a/n/c]: ", async (answer) => {
314
+ confirmRl.close();
315
+ const choice = answer.trim().toLowerCase();
316
+ if (choice === "a") {
317
+ console.log("\nSaving all unsaved subroutines...\n");
318
+ for (const name of unsaved) {
319
+ try {
320
+ const xml = `<save-subroutine name="${name}" format="xml" />`;
321
+ const ast = this.xmlParser.parse(xml);
322
+ await integrate(this.session, ast);
323
+ if (this.session.output.length > 0) {
324
+ console.log(this.session.output.join(""));
325
+ this.session.output = [];
326
+ }
327
+ } catch (error) {
328
+ console.error(`Error saving ${name}:`, error instanceof Error ? error.message : String(error));
329
+ }
330
+ }
331
+ resolve2(true);
332
+ } else if (choice === "n") {
333
+ resolve2(true);
334
+ } else {
335
+ console.log("\n(Exit canceled - returning to shell)\n");
336
+ resolve2(false);
337
+ }
338
+ });
339
+ });
317
340
  }
318
341
  countSubroutinesInAST(element) {
319
342
  let count = 0;
@@ -327,24 +350,44 @@ var DiracShell = class {
327
350
  }
328
351
  return count;
329
352
  }
353
+ finalizeExit() {
354
+ this.saveHistory();
355
+ if (this.client) {
356
+ this.client.disconnect();
357
+ }
358
+ import("./schedule-G6ZSSQ5W.js").then(({ stopAllScheduledTasks }) => {
359
+ stopAllScheduledTasks();
360
+ console.log("\nGoodbye!");
361
+ process.exit(0);
362
+ }).catch(() => {
363
+ console.log("\nGoodbye!");
364
+ process.exit(0);
365
+ });
366
+ }
330
367
  setupHandlers() {
331
368
  this.rl.on("line", async (input) => {
332
369
  await this.handleInput(input);
333
370
  });
334
- this.rl.on("close", () => {
335
- this.checkUnsavedSubroutines();
336
- this.saveHistory();
337
- if (this.client) {
338
- this.client.disconnect();
371
+ this.rl.on("close", async () => {
372
+ const unsaved = this.getUnsavedSubroutines();
373
+ if (unsaved.length > 0) {
374
+ const shouldExit = await this.promptSaveUnsaved(unsaved);
375
+ if (shouldExit) {
376
+ this.finalizeExit();
377
+ } else {
378
+ this.rl = readline.createInterface({
379
+ input: process.stdin,
380
+ output: process.stdout,
381
+ prompt: "> ",
382
+ historySize: MAX_HISTORY,
383
+ completer: this.completer.bind(this)
384
+ });
385
+ this.setupHandlers();
386
+ this.rl.prompt();
387
+ }
388
+ } else {
389
+ this.finalizeExit();
339
390
  }
340
- import("./schedule-ZGPBTVXG.js").then(({ stopAllScheduledTasks }) => {
341
- stopAllScheduledTasks();
342
- console.log("\nGoodbye!");
343
- process.exit(0);
344
- }).catch(() => {
345
- console.log("\nGoodbye!");
346
- process.exit(0);
347
- });
348
391
  });
349
392
  this.rl.on("SIGINT", () => {
350
393
  if (this.inputBuffer.length > 0) {
@@ -703,7 +746,7 @@ Examples:
703
746
  break;
704
747
  case "tasks":
705
748
  try {
706
- const { listScheduledTasks } = await import("./schedule-ZGPBTVXG.js");
749
+ const { listScheduledTasks } = await import("./schedule-G6ZSSQ5W.js");
707
750
  const tasks = listScheduledTasks();
708
751
  if (tasks.length === 0) {
709
752
  console.log("No scheduled tasks running.");
@@ -722,7 +765,7 @@ Examples:
722
765
  console.log("Usage: :stop <task-name>");
723
766
  } else {
724
767
  try {
725
- const { stopScheduledTask } = await import("./schedule-ZGPBTVXG.js");
768
+ const { stopScheduledTask } = await import("./schedule-G6ZSSQ5W.js");
726
769
  const taskName = args[0];
727
770
  const stopped = stopScheduledTask(taskName);
728
771
  if (stopped) {
@@ -737,7 +780,7 @@ Examples:
737
780
  break;
738
781
  case "stopall":
739
782
  try {
740
- const { stopAllScheduledTasks } = await import("./schedule-ZGPBTVXG.js");
783
+ const { stopAllScheduledTasks } = await import("./schedule-G6ZSSQ5W.js");
741
784
  stopAllScheduledTasks();
742
785
  console.log("All scheduled tasks stopped.");
743
786
  } catch (error) {
@@ -746,7 +789,7 @@ Examples:
746
789
  break;
747
790
  case "crons":
748
791
  try {
749
- const { listCronJobs } = await import("./cron-VEWKZ2ZU.js");
792
+ const { listCronJobs } = await import("./cron-GZ5XXDBY.js");
750
793
  const jobs = listCronJobs();
751
794
  if (jobs.length === 0) {
752
795
  console.log("No cron jobs running.");
@@ -766,7 +809,7 @@ Examples:
766
809
  console.log("Usage: :stopcron <job-name>");
767
810
  } else {
768
811
  try {
769
- const { stopCronJob } = await import("./cron-VEWKZ2ZU.js");
812
+ const { stopCronJob } = await import("./cron-GZ5XXDBY.js");
770
813
  const jobName = args[0];
771
814
  const stopped = stopCronJob(jobName);
772
815
  if (stopped) {
@@ -781,7 +824,7 @@ Examples:
781
824
  break;
782
825
  case "stopallcrons":
783
826
  try {
784
- const { stopAllCronJobs } = await import("./cron-VEWKZ2ZU.js");
827
+ const { stopAllCronJobs } = await import("./cron-GZ5XXDBY.js");
785
828
  stopAllCronJobs();
786
829
  console.log("All cron jobs stopped.");
787
830
  } catch (error) {
@@ -790,7 +833,7 @@ Examples:
790
833
  break;
791
834
  case "scheduled":
792
835
  try {
793
- const { listScheduledRuns } = await import("./run-at-OPGYI26L.js");
836
+ const { listScheduledRuns } = await import("./run-at-ZYUWD64S.js");
794
837
  const runs = listScheduledRuns();
795
838
  if (runs.length === 0) {
796
839
  console.log("No scheduled runs pending.");
@@ -810,7 +853,7 @@ Examples:
810
853
  console.log("Usage: :cancel <run-name>");
811
854
  } else {
812
855
  try {
813
- const { cancelScheduledRun } = await import("./run-at-OPGYI26L.js");
856
+ const { cancelScheduledRun } = await import("./run-at-ZYUWD64S.js");
814
857
  const runName = args[0];
815
858
  const cancelled = cancelScheduledRun(runName);
816
859
  if (cancelled) {
@@ -825,7 +868,7 @@ Examples:
825
868
  break;
826
869
  case "cancelall":
827
870
  try {
828
- const { cancelAllScheduledRuns } = await import("./run-at-OPGYI26L.js");
871
+ const { cancelAllScheduledRuns } = await import("./run-at-ZYUWD64S.js");
829
872
  cancelAllScheduledRuns();
830
873
  console.log("All scheduled runs cancelled.");
831
874
  } catch (error) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-QUFYZS2S.js";
3
+ } from "./chunk-WW2OXQZN.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",