dirac-lang 0.1.47 → 0.1.49

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.
@@ -144,8 +144,9 @@ function createSession(config = {}) {
144
144
  isBreak: false,
145
145
  skipSubroutineRegistration: false,
146
146
  debug: config.debug || false,
147
- currentFile: config.filePath
147
+ currentFile: config.filePath,
148
148
  // Set current file from config for proper relative import resolution
149
+ libraryPaths: config.libraryPaths || []
149
150
  };
150
151
  }
151
152
  function setVariable(session, name, value, visible = false) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-TXL3RV74.js";
3
+ } from "./chunk-IWNHCL6E.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
@@ -8,7 +8,7 @@ import {
8
8
  createSession,
9
9
  getAvailableSubroutines,
10
10
  getOutput
11
- } from "./chunk-GLXVY235.js";
11
+ } from "./chunk-A4SFB5W4.js";
12
12
 
13
13
  // src/utils/llm-adapter.ts
14
14
  function createLLMAdapter(session) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-HRHAMPOB.js";
4
4
  import {
5
5
  executeSubroutine
6
- } from "./chunk-4QLTSCDG.js";
6
+ } from "./chunk-ZY37RS4P.js";
7
7
  import {
8
8
  cleanSubroutinesToBoundary,
9
9
  cleanToBoundary,
@@ -26,7 +26,7 @@ import {
26
26
  substituteVariables,
27
27
  throwException,
28
28
  unsetExceptionBoundary
29
- } from "./chunk-GLXVY235.js";
29
+ } from "./chunk-A4SFB5W4.js";
30
30
 
31
31
  // src/tags/parameters.ts
32
32
  async function executeParameters(session, element) {
@@ -270,7 +270,7 @@ async function executeCall(session, element) {
270
270
  }
271
271
  }
272
272
  async function registerExtendChain(session, subroutine, currentName) {
273
- const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-V4D4LQIH.js");
273
+ const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-VIACWZPF.js");
274
274
  const extendsAttr = subroutine.attributes.extends;
275
275
  let parentName;
276
276
  if (extendsAttr) {
@@ -460,12 +460,12 @@ async function executeIf(session, element) {
460
460
  const condition = await evaluatePredicate(session, conditionElement);
461
461
  if (condition) {
462
462
  if (thenElement) {
463
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
463
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
464
464
  await integrateChildren2(session, thenElement);
465
465
  }
466
466
  } else {
467
467
  if (elseElement) {
468
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
468
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
469
469
  await integrateChildren2(session, elseElement);
470
470
  }
471
471
  }
@@ -478,7 +478,7 @@ async function evaluatePredicate(session, predicateElement) {
478
478
  return await evaluateCondition(session, predicateElement);
479
479
  }
480
480
  const outputLengthBefore = session.output.length;
481
- const { integrate: integrate2 } = await import("./interpreter-XH3RFKVP.js");
481
+ const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
482
482
  await integrate2(session, predicateElement);
483
483
  const newOutputChunks = session.output.slice(outputLengthBefore);
484
484
  const result = newOutputChunks.join("").trim();
@@ -501,11 +501,11 @@ async function evaluateCondition(session, condElement) {
501
501
  }
502
502
  const outputLengthBefore = session.output.length;
503
503
  const args = [];
504
- const { integrate: integrate2 } = await import("./interpreter-XH3RFKVP.js");
504
+ const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
505
505
  for (const child of condElement.children) {
506
506
  if (child.tag.toLowerCase() === "arg") {
507
507
  const argOutputStart = session.output.length;
508
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
508
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
509
509
  await integrateChildren2(session, child);
510
510
  const newChunks = session.output.slice(argOutputStart);
511
511
  const argValue = newChunks.join("");
@@ -725,7 +725,7 @@ async function executeLLM(session, element) {
725
725
  let systemPrompt = "";
726
726
  let currentUserPrompt = userPrompt;
727
727
  if (!noExtra) {
728
- const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-UBATJEND.js");
728
+ const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-5PEIMBGV.js");
729
729
  const subroutines = getAvailableSubroutines2(session);
730
730
  if (session.debug) {
731
731
  console.error(
@@ -897,7 +897,7 @@ ${result}
897
897
  const parser = new DiracParser();
898
898
  let dynamicAST = parser.parse(diracCode);
899
899
  if (validateTags) {
900
- const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-3RLLFTY6.js");
900
+ const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-AZXYIKQV.js");
901
901
  let validation = await validateDiracCode(session, dynamicAST, { autocorrect });
902
902
  let retryCount = 0;
903
903
  while (!validation.valid && retryCount < maxRetries) {
@@ -1119,10 +1119,21 @@ async function executeExecute(session, element) {
1119
1119
  if (!diracCode) {
1120
1120
  throw new Error(`<execute> source variable '${sourceAttr}' not found`);
1121
1121
  }
1122
- } else if (element.text) {
1123
- diracCode = substituteVariables(session, element.text);
1124
1122
  } else {
1125
- throw new Error("<execute> requires source attribute or text content");
1123
+ const hasElementChildren = element.children.some((child) => child.tag !== "");
1124
+ if (hasElementChildren) {
1125
+ const beforeOutput = session.output.length;
1126
+ for (const child of element.children) {
1127
+ await integrate(session, child);
1128
+ }
1129
+ const childOutput = session.output.slice(beforeOutput);
1130
+ diracCode = childOutput.join("");
1131
+ session.output = session.output.slice(0, beforeOutput);
1132
+ } else if (element.text) {
1133
+ diracCode = substituteVariables(session, element.text);
1134
+ } else {
1135
+ throw new Error("<execute> requires source attribute or text content");
1136
+ }
1126
1137
  }
1127
1138
  if (session.debug) {
1128
1139
  console.error(`[EXECUTE] Interpreting dynamic code:
@@ -1145,10 +1156,57 @@ ${diracCode}
1145
1156
  // src/tags/import.ts
1146
1157
  import { readFileSync, existsSync as existsSync3 } from "fs";
1147
1158
  import { resolve, dirname as dirname2, join as join2 } from "path";
1148
- function resolveImportPath(src, currentDir) {
1149
- if (src.startsWith("./") || src.startsWith("../") || src.startsWith("/")) {
1150
- const resolved2 = resolve(currentDir, src);
1151
- return resolved2.endsWith(".di") ? resolved2 : resolved2 + ".di";
1159
+ import { homedir as homedir2 } from "os";
1160
+ function resolveImportPath(src, currentDir, libraryPaths = []) {
1161
+ const ensureDiExtension = (path4) => path4.endsWith(".di") ? path4 : path4 + ".di";
1162
+ const tryResolveInBase = (basePath, modulePath) => {
1163
+ const fullPath = join2(basePath, modulePath);
1164
+ const withExtension = ensureDiExtension(fullPath);
1165
+ if (existsSync3(withExtension)) {
1166
+ return withExtension;
1167
+ }
1168
+ return null;
1169
+ };
1170
+ if (src.startsWith("/")) {
1171
+ const resolved = ensureDiExtension(src);
1172
+ if (existsSync3(resolved)) {
1173
+ return resolved;
1174
+ }
1175
+ throw new Error(`Absolute path not found: ${resolved}`);
1176
+ }
1177
+ if (src.startsWith("~/")) {
1178
+ const expanded = join2(homedir2(), src.slice(2));
1179
+ const resolved = ensureDiExtension(expanded);
1180
+ if (existsSync3(resolved)) {
1181
+ return resolved;
1182
+ }
1183
+ throw new Error(`Home path not found: ${resolved}`);
1184
+ }
1185
+ if (src.startsWith("./") || src.startsWith("../")) {
1186
+ const resolved = resolve(currentDir, src);
1187
+ const withExtension = ensureDiExtension(resolved);
1188
+ if (existsSync3(withExtension)) {
1189
+ return withExtension;
1190
+ }
1191
+ throw new Error(`Relative path not found: ${withExtension}`);
1192
+ }
1193
+ const diracLibs = process.env.DIRAC_LIBS;
1194
+ if (diracLibs) {
1195
+ const libPaths = diracLibs.split(":").filter((p) => p.trim());
1196
+ for (const libPath of libPaths) {
1197
+ const expandedLibPath = libPath.startsWith("~") ? join2(homedir2(), libPath.slice(1)) : libPath;
1198
+ const resolved = tryResolveInBase(expandedLibPath, src);
1199
+ if (resolved) {
1200
+ return resolved;
1201
+ }
1202
+ }
1203
+ }
1204
+ for (const libPath of libraryPaths) {
1205
+ const expandedLibPath = libPath.startsWith("~") ? join2(homedir2(), libPath.slice(1)) : libPath;
1206
+ const resolved = tryResolveInBase(expandedLibPath, src);
1207
+ if (resolved) {
1208
+ return resolved;
1209
+ }
1152
1210
  }
1153
1211
  let searchDir = currentDir;
1154
1212
  while (true) {
@@ -1175,7 +1233,7 @@ function resolveImportPath(src, currentDir) {
1175
1233
  return fallback;
1176
1234
  }
1177
1235
  }
1178
- throw new Error(`Package "${src}" found but no entry point (.di file) available`);
1236
+ throw new Error(`Package "${src}" found in node_modules but no entry point (.di file) available`);
1179
1237
  }
1180
1238
  const parentDir = dirname2(searchDir);
1181
1239
  if (parentDir === searchDir) {
@@ -1183,8 +1241,16 @@ function resolveImportPath(src, currentDir) {
1183
1241
  }
1184
1242
  searchDir = parentDir;
1185
1243
  }
1186
- const resolved = resolve(currentDir, src);
1187
- return resolved.endsWith(".di") ? resolved : resolved + ".di";
1244
+ throw new Error(`Module not found: ${src}
1245
+ Searched in:
1246
+ - Absolute/Home paths
1247
+ - Relative to: ${currentDir}
1248
+ - DIRAC_LIBS: ${diracLibs || "(not set)"}
1249
+ - libraryPaths: ${libraryPaths.join(", ") || "(none)"}
1250
+ - node_modules (walked up from ${currentDir})
1251
+
1252
+ Hint: Set DIRAC_LIBS environment variable for development (e.g., export DIRAC_LIBS=~/diraclang)
1253
+ Or add libraryPaths to config.yml for project-specific paths`);
1188
1254
  }
1189
1255
  async function executeImport(session, element) {
1190
1256
  const srcAttr = element.attributes.src;
@@ -1193,9 +1259,10 @@ async function executeImport(session, element) {
1193
1259
  }
1194
1260
  const src = substituteAttribute(session, srcAttr);
1195
1261
  const currentDir = session.currentFile ? dirname2(session.currentFile) : process.cwd();
1196
- const importPath = resolveImportPath(src, currentDir);
1262
+ const libraryPaths = session.libraryPaths || [];
1263
+ const importPath = resolveImportPath(src, currentDir, libraryPaths);
1197
1264
  if (session.debug) {
1198
- console.error(`[IMPORT] Loading: ${importPath}`);
1265
+ console.error(`[IMPORT] Resolved: ${src} -> ${importPath}`);
1199
1266
  }
1200
1267
  if (!session.importedFiles) {
1201
1268
  session.importedFiles = /* @__PURE__ */ new Set();
@@ -1441,7 +1508,7 @@ async function getBestTagMatch(candidate, allowed) {
1441
1508
  return { tag: allowed[bestIdx], score: bestScore };
1442
1509
  }
1443
1510
  async function executeTagCheck(session, element) {
1444
- const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-UBATJEND.js");
1511
+ const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-5PEIMBGV.js");
1445
1512
  const subroutines = getAvailableSubroutines2(session);
1446
1513
  const allowed = new Set(subroutines.map((s) => s.name));
1447
1514
  console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
@@ -1534,7 +1601,7 @@ async function executeTagCheck(session, element) {
1534
1601
  const executeTag = correctedTag || tagName;
1535
1602
  console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
1536
1603
  const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
1537
- const { integrate: integrate2 } = await import("./interpreter-XH3RFKVP.js");
1604
+ const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
1538
1605
  await integrate2(session, elementToExecute);
1539
1606
  }
1540
1607
  }
@@ -1543,7 +1610,7 @@ async function executeTagCheck(session, element) {
1543
1610
  // src/tags/throw.ts
1544
1611
  async function executeThrow(session, element) {
1545
1612
  const exceptionName = element.attributes?.name || "exception";
1546
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
1613
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1547
1614
  const exceptionDom = {
1548
1615
  tag: "exception-content",
1549
1616
  attributes: { name: exceptionName },
@@ -1556,7 +1623,7 @@ async function executeThrow(session, element) {
1556
1623
  // src/tags/try.ts
1557
1624
  async function executeTry(session, element) {
1558
1625
  setExceptionBoundary(session);
1559
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
1626
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1560
1627
  await integrateChildren2(session, element);
1561
1628
  unsetExceptionBoundary(session);
1562
1629
  }
@@ -1566,7 +1633,7 @@ async function executeCatch(session, element) {
1566
1633
  const exceptionName = element.attributes?.name || "exception";
1567
1634
  const caughtCount = lookupException(session, exceptionName);
1568
1635
  if (caughtCount > 0) {
1569
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
1636
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1570
1637
  await integrateChildren2(session, element);
1571
1638
  }
1572
1639
  flushCurrentException(session);
@@ -1575,7 +1642,7 @@ async function executeCatch(session, element) {
1575
1642
  // src/tags/exception.ts
1576
1643
  async function executeException(session, element) {
1577
1644
  const exceptions = getCurrentExceptions(session);
1578
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-XH3RFKVP.js");
1645
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1579
1646
  for (const exceptionDom of exceptions) {
1580
1647
  await integrateChildren2(session, exceptionDom);
1581
1648
  }
@@ -2038,7 +2105,7 @@ async function executeLoadContext(session, element) {
2038
2105
  query = element.text.trim();
2039
2106
  }
2040
2107
  if (!query && element.children.length > 0) {
2041
- const { integrate: integrate2 } = await import("./interpreter-XH3RFKVP.js");
2108
+ const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
2042
2109
  const beforeOutput = session.output.length;
2043
2110
  for (const child of element.children) {
2044
2111
  await integrate2(session, child);
@@ -2107,7 +2174,7 @@ async function executeLoadContext(session, element) {
2107
2174
  parameters: s.parameters.map((p) => p.name),
2108
2175
  filePath: s.filePath
2109
2176
  }));
2110
- const { setVariable: setVariable2 } = await import("./session-UBATJEND.js");
2177
+ const { setVariable: setVariable2 } = await import("./session-5PEIMBGV.js");
2111
2178
  setVariable2(session, outputVar, JSON.stringify(summary, null, 2), false);
2112
2179
  }
2113
2180
  }
@@ -2115,7 +2182,7 @@ async function executeLoadContext(session, element) {
2115
2182
  // src/tags/save-subroutine.ts
2116
2183
  import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync4, existsSync as existsSync5 } from "fs";
2117
2184
  import { resolve as resolve2, dirname as dirname4, join as join4 } from "path";
2118
- import { homedir as homedir3 } from "os";
2185
+ import { homedir as homedir4 } from "os";
2119
2186
  async function executeSaveSubroutine(session, element) {
2120
2187
  const name = element.attributes.name;
2121
2188
  const file = element.attributes.file;
@@ -2144,11 +2211,11 @@ async function executeSaveSubroutine(session, element) {
2144
2211
  if (file) {
2145
2212
  filePath = resolve2(process.cwd(), file);
2146
2213
  } else if (pathAttr) {
2147
- const targetDir = join4(homedir3(), ".dirac", "lib", pathAttr);
2214
+ const targetDir = join4(homedir4(), ".dirac", "lib", pathAttr);
2148
2215
  filePath = join4(targetDir, `${name}.di`);
2149
2216
  } else {
2150
2217
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
2151
- const defaultDir = join4(homedir3(), ".dirac", "lib", timestamp);
2218
+ const defaultDir = join4(homedir4(), ".dirac", "lib", timestamp);
2152
2219
  filePath = join4(defaultDir, `${name}.di`);
2153
2220
  }
2154
2221
  const dir = dirname4(filePath);
@@ -2291,7 +2358,7 @@ async function executeForeach(session, element) {
2291
2358
  const parser2 = new DiracParser2();
2292
2359
  try {
2293
2360
  const fromElement = parser2.parse(fromAttr);
2294
- const { integrate: integrate2 } = await import("./interpreter-XH3RFKVP.js");
2361
+ const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
2295
2362
  await integrate2(session, fromElement);
2296
2363
  } catch (e) {
2297
2364
  session.output = savedOutput;
@@ -2721,25 +2788,38 @@ async function executeSchedule(session, element) {
2721
2788
  }
2722
2789
  const taskElement = element;
2723
2790
  console.log(`[schedule] Starting task "${name}" (every ${intervalSeconds}s)`);
2724
- executeTask(session, taskElement, name).catch((err) => {
2791
+ let isRunning = false;
2792
+ executeTask(session, taskElement, name, () => isRunning, (value) => {
2793
+ isRunning = value;
2794
+ }).catch((err) => {
2725
2795
  console.error(`[schedule] Error in task "${name}":`, err.message);
2726
2796
  });
2727
2797
  const intervalId = setInterval(() => {
2728
- executeTask(session, taskElement, name).catch((err) => {
2798
+ executeTask(session, taskElement, name, () => isRunning, (value) => {
2799
+ isRunning = value;
2800
+ }).catch((err) => {
2729
2801
  console.error(`[schedule] Error in task "${name}":`, err.message);
2730
2802
  });
2731
2803
  }, intervalMs);
2732
2804
  scheduledTasks.set(name, {
2733
2805
  name,
2734
2806
  intervalId,
2735
- interval: intervalSeconds
2807
+ interval: intervalSeconds,
2808
+ isRunning: false
2736
2809
  });
2737
2810
  }
2738
- async function executeTask(session, element, name) {
2811
+ async function executeTask(session, element, name, getIsRunning, setIsRunning) {
2812
+ if (getIsRunning()) {
2813
+ console.log(`[schedule] Skipping task "${name}" - previous execution still running`);
2814
+ return;
2815
+ }
2816
+ setIsRunning(true);
2739
2817
  try {
2740
2818
  await integrateChildren(session, element);
2741
2819
  } catch (error) {
2742
2820
  console.error(`[schedule] Task "${name}" failed:`, error.message);
2821
+ } finally {
2822
+ setIsRunning(false);
2743
2823
  }
2744
2824
  }
2745
2825
  function stopScheduledTask(name) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerSubroutine
3
- } from "./chunk-GLXVY235.js";
3
+ } from "./chunk-A4SFB5W4.js";
4
4
 
5
5
  // src/tags/subroutine.ts
6
6
  function executeSubroutine(session, element) {
package/dist/cli.js CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-UEFKQRYN.js";
5
5
  import {
6
6
  execute
7
- } from "./chunk-TISVDOGD.js";
8
- import "./chunk-TXL3RV74.js";
7
+ } from "./chunk-GKUTLPQJ.js";
8
+ import "./chunk-IWNHCL6E.js";
9
9
  import "./chunk-HRHAMPOB.js";
10
- import "./chunk-4QLTSCDG.js";
11
- import "./chunk-GLXVY235.js";
10
+ import "./chunk-ZY37RS4P.js";
11
+ import "./chunk-A4SFB5W4.js";
12
12
 
13
13
  // src/cli.ts
14
14
  import "dotenv/config";
@@ -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.47",
19
+ version: "0.1.48",
20
20
  description: "LLM-Augmented Declarative Execution",
21
21
  type: "module",
22
22
  main: "dist/index.js",
@@ -96,7 +96,7 @@ async function main() {
96
96
  process.exit(0);
97
97
  }
98
98
  if (args[0] === "shell") {
99
- const { DiracShell } = await import("./shell-TNQMOYFR.js");
99
+ const { DiracShell } = await import("./shell-S5BLB32A.js");
100
100
  const shellConfig = { debug: false };
101
101
  for (let i = 1; i < args.length; i++) {
102
102
  const arg = args[i];
package/dist/index.d.ts CHANGED
@@ -84,6 +84,7 @@ interface DiracSession {
84
84
  debug: boolean;
85
85
  currentFile?: string;
86
86
  importedFiles?: Set<string>;
87
+ libraryPaths?: string[];
87
88
  }
88
89
  interface DiracConfig {
89
90
  apiKey?: string;
@@ -96,6 +97,7 @@ interface DiracConfig {
96
97
  llmModel?: string;
97
98
  customLLMUrl?: string;
98
99
  initScript?: string;
100
+ libraryPaths?: string[];
99
101
  }
100
102
 
101
103
  /**
package/dist/index.js CHANGED
@@ -2,19 +2,19 @@ import {
2
2
  createLLMAdapter,
3
3
  execute,
4
4
  executeUserCommand
5
- } from "./chunk-TISVDOGD.js";
5
+ } from "./chunk-GKUTLPQJ.js";
6
6
  import {
7
7
  integrate
8
- } from "./chunk-TXL3RV74.js";
8
+ } from "./chunk-IWNHCL6E.js";
9
9
  import {
10
10
  DiracParser
11
11
  } from "./chunk-HRHAMPOB.js";
12
- import "./chunk-4QLTSCDG.js";
12
+ import "./chunk-ZY37RS4P.js";
13
13
  import {
14
14
  createSession,
15
15
  getAvailableSubroutines,
16
16
  getOutput
17
- } from "./chunk-GLXVY235.js";
17
+ } from "./chunk-A4SFB5W4.js";
18
18
  export {
19
19
  DiracParser,
20
20
  createLLMAdapter,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  integrate,
3
3
  integrateChildren
4
- } from "./chunk-TXL3RV74.js";
4
+ } from "./chunk-IWNHCL6E.js";
5
5
  import "./chunk-HRHAMPOB.js";
6
- import "./chunk-4QLTSCDG.js";
7
- import "./chunk-GLXVY235.js";
6
+ import "./chunk-ZY37RS4P.js";
7
+ import "./chunk-A4SFB5W4.js";
8
8
  export {
9
9
  integrate,
10
10
  integrateChildren
@@ -3,10 +3,10 @@ import {
3
3
  listScheduledTasks,
4
4
  stopAllScheduledTasks,
5
5
  stopScheduledTask
6
- } from "./chunk-TXL3RV74.js";
6
+ } from "./chunk-IWNHCL6E.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
- import "./chunk-4QLTSCDG.js";
9
- import "./chunk-GLXVY235.js";
8
+ import "./chunk-ZY37RS4P.js";
9
+ import "./chunk-A4SFB5W4.js";
10
10
  export {
11
11
  executeSchedule,
12
12
  listScheduledTasks,
@@ -26,7 +26,7 @@ import {
26
26
  substituteVariables,
27
27
  throwException,
28
28
  unsetExceptionBoundary
29
- } from "./chunk-GLXVY235.js";
29
+ } from "./chunk-A4SFB5W4.js";
30
30
  export {
31
31
  cleanSubroutinesToBoundary,
32
32
  cleanToBoundary,
@@ -4,14 +4,14 @@ import {
4
4
  } from "./chunk-UEFKQRYN.js";
5
5
  import {
6
6
  integrate
7
- } from "./chunk-TXL3RV74.js";
7
+ } from "./chunk-IWNHCL6E.js";
8
8
  import {
9
9
  DiracParser
10
10
  } from "./chunk-HRHAMPOB.js";
11
- import "./chunk-4QLTSCDG.js";
11
+ import "./chunk-ZY37RS4P.js";
12
12
  import {
13
13
  createSession
14
- } from "./chunk-GLXVY235.js";
14
+ } from "./chunk-A4SFB5W4.js";
15
15
 
16
16
  // src/shell.ts
17
17
  import * as readline from "readline";
@@ -46,6 +46,45 @@ var DiracShell = class {
46
46
  this.setupHandlers();
47
47
  }
48
48
  completer(line) {
49
+ const attrMatch = line.match(/\|([a-z0-9_-]+)\s+.*?([a-z0-9_-]*)$/i);
50
+ if (attrMatch) {
51
+ const tagName = attrMatch[1];
52
+ const attrPartial = attrMatch[2];
53
+ const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
54
+ if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
55
+ const paramNames = subroutine.parameters.map((p) => p.name);
56
+ const matches = paramNames.filter(
57
+ (name) => name.toLowerCase().startsWith(attrPartial.toLowerCase())
58
+ );
59
+ const completions = matches.map((name) => `${name}=`);
60
+ return [completions, attrPartial];
61
+ }
62
+ }
63
+ const tagCompleteMatch = line.match(/\|([a-z0-9_-]+)$/i);
64
+ if (tagCompleteMatch) {
65
+ const tagName = tagCompleteMatch[1];
66
+ const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
67
+ if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
68
+ const paramSuggestions = subroutine.parameters.map((p) => {
69
+ const required = p.required ? "*" : "";
70
+ const typeInfo = p.type || "string";
71
+ return `${p.name}=${required}${typeInfo}`;
72
+ });
73
+ return [paramSuggestions, ""];
74
+ }
75
+ const subroutineNames = this.session.subroutines.map((sub) => sub.name);
76
+ const matches = subroutineNames.filter(
77
+ (name) => name.toLowerCase().startsWith(tagName.toLowerCase())
78
+ );
79
+ if (matches.length > 0) {
80
+ const completions = matches.map((name) => {
81
+ const sub = this.session.subroutines.find((s) => s.name === name);
82
+ const hasParams = sub && sub.parameters && sub.parameters.length > 0;
83
+ return hasParams ? `|${name} ` : `|${name}>`;
84
+ });
85
+ return [completions, tagCompleteMatch[0]];
86
+ }
87
+ }
49
88
  const braketMatch = line.match(/\|([a-z0-9_-]*)$/i);
50
89
  if (braketMatch) {
51
90
  const partial = braketMatch[1];
@@ -53,7 +92,11 @@ var DiracShell = class {
53
92
  const matches = subroutineNames.filter(
54
93
  (name) => name.toLowerCase().startsWith(partial.toLowerCase())
55
94
  );
56
- const completions = matches.map((name) => `|${name}>`);
95
+ const completions = matches.map((name) => {
96
+ const subroutine = this.session.subroutines.find((sub) => sub.name === name);
97
+ const hasParams = subroutine && subroutine.parameters && subroutine.parameters.length > 0;
98
+ return hasParams ? `|${name} ` : `|${name}>`;
99
+ });
57
100
  return [completions, braketMatch[0]];
58
101
  }
59
102
  const commandMatch = line.match(/:([a-z]*)$/i);
@@ -88,7 +131,7 @@ var DiracShell = class {
88
131
  });
89
132
  this.rl.on("close", () => {
90
133
  this.saveHistory();
91
- import("./schedule-5HZCREEP.js").then(({ stopAllScheduledTasks }) => {
134
+ import("./schedule-TRNPB73K.js").then(({ stopAllScheduledTasks }) => {
92
135
  stopAllScheduledTasks();
93
136
  console.log("\nGoodbye!");
94
137
  process.exit(0);
@@ -402,7 +445,7 @@ Examples:
402
445
  break;
403
446
  case "tasks":
404
447
  try {
405
- const { listScheduledTasks } = await import("./schedule-5HZCREEP.js");
448
+ const { listScheduledTasks } = await import("./schedule-TRNPB73K.js");
406
449
  const tasks = listScheduledTasks();
407
450
  if (tasks.length === 0) {
408
451
  console.log("No scheduled tasks running.");
@@ -421,7 +464,7 @@ Examples:
421
464
  console.log("Usage: :stop <task-name>");
422
465
  } else {
423
466
  try {
424
- const { stopScheduledTask } = await import("./schedule-5HZCREEP.js");
467
+ const { stopScheduledTask } = await import("./schedule-TRNPB73K.js");
425
468
  const taskName = args[0];
426
469
  const stopped = stopScheduledTask(taskName);
427
470
  if (stopped) {
@@ -436,7 +479,7 @@ Examples:
436
479
  break;
437
480
  case "stopall":
438
481
  try {
439
- const { stopAllScheduledTasks } = await import("./schedule-5HZCREEP.js");
482
+ const { stopAllScheduledTasks } = await import("./schedule-TRNPB73K.js");
440
483
  stopAllScheduledTasks();
441
484
  console.log("All scheduled tasks stopped.");
442
485
  } catch (error) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeSubroutine
3
- } from "./chunk-4QLTSCDG.js";
4
- import "./chunk-GLXVY235.js";
3
+ } from "./chunk-ZY37RS4P.js";
4
+ import "./chunk-A4SFB5W4.js";
5
5
  export {
6
6
  executeSubroutine
7
7
  };
@@ -49,7 +49,7 @@ async function getBestTagMatch(candidate, allowed) {
49
49
  }
50
50
  async function validateTag(session, element, options = {}) {
51
51
  const { autocorrect = false, similarityCutoff = SIMILARITY_CUTOFF } = options;
52
- const { getAvailableSubroutines } = await import("./session-UBATJEND.js");
52
+ const { getAvailableSubroutines } = await import("./session-5PEIMBGV.js");
53
53
  const subroutines = getAvailableSubroutines(session);
54
54
  const allowed = new Set(subroutines.map((s) => s.name));
55
55
  const tagName = element.tag;
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-TXL3RV74.js";
3
+ } from "./chunk-IWNHCL6E.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
7
- import "./chunk-4QLTSCDG.js";
7
+ import "./chunk-ZY37RS4P.js";
8
8
  import {
9
9
  createSession,
10
10
  getOutput
11
- } from "./chunk-GLXVY235.js";
11
+ } from "./chunk-A4SFB5W4.js";
12
12
 
13
13
  // src/test-runner.ts
14
14
  import fs from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",