dirac-lang 0.1.49 → 0.1.51

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-IWNHCL6E.js";
3
+ } from "./chunk-D2TEBI65.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
@@ -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-54YLI2PC.js");
463
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.js");
464
464
  await integrateChildren2(session, thenElement);
465
465
  }
466
466
  } else {
467
467
  if (elseElement) {
468
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
468
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.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-54YLI2PC.js");
481
+ const { integrate: integrate2 } = await import("./interpreter-BDXB5X77.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-54YLI2PC.js");
504
+ const { integrate: integrate2 } = await import("./interpreter-BDXB5X77.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-54YLI2PC.js");
508
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.js");
509
509
  await integrateChildren2(session, child);
510
510
  const newChunks = session.output.slice(argOutputStart);
511
511
  const argValue = newChunks.join("");
@@ -939,9 +939,9 @@ Please fix these errors and generate valid Dirac XML again. Remember to only use
939
939
  }
940
940
  dialogHistory.push({ role: "assistant", content: result });
941
941
  if (contextVar) {
942
- setVariable(session, contextVar, dialogHistory, true);
942
+ setVariable(session, contextVar, JSON.stringify(dialogHistory), true);
943
943
  } else if (saveDialog) {
944
- setVariable(session, "__llm_dialog__", dialogHistory, true);
944
+ setVariable(session, "__llm_dialog__", JSON.stringify(dialogHistory), true);
945
945
  }
946
946
  if (session.debug) {
947
947
  console.error(`[LLM] Retry ${retryCount} response:
@@ -1025,9 +1025,9 @@ ${feedbackPrompt}
1025
1025
  }
1026
1026
  dialogHistory.push({ role: "assistant", content: result });
1027
1027
  if (contextVar) {
1028
- setVariable(session, contextVar, dialogHistory, true);
1028
+ setVariable(session, contextVar, JSON.stringify(dialogHistory), true);
1029
1029
  } else if (saveDialog) {
1030
- setVariable(session, "__llm_dialog__", dialogHistory, true);
1030
+ setVariable(session, "__llm_dialog__", JSON.stringify(dialogHistory), true);
1031
1031
  }
1032
1032
  if (session.debug) {
1033
1033
  console.error(`[LLM] Feedback response:
@@ -1601,7 +1601,7 @@ async function executeTagCheck(session, element) {
1601
1601
  const executeTag = correctedTag || tagName;
1602
1602
  console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
1603
1603
  const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
1604
- const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
1604
+ const { integrate: integrate2 } = await import("./interpreter-BDXB5X77.js");
1605
1605
  await integrate2(session, elementToExecute);
1606
1606
  }
1607
1607
  }
@@ -1610,7 +1610,7 @@ async function executeTagCheck(session, element) {
1610
1610
  // src/tags/throw.ts
1611
1611
  async function executeThrow(session, element) {
1612
1612
  const exceptionName = element.attributes?.name || "exception";
1613
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1613
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.js");
1614
1614
  const exceptionDom = {
1615
1615
  tag: "exception-content",
1616
1616
  attributes: { name: exceptionName },
@@ -1623,7 +1623,7 @@ async function executeThrow(session, element) {
1623
1623
  // src/tags/try.ts
1624
1624
  async function executeTry(session, element) {
1625
1625
  setExceptionBoundary(session);
1626
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1626
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.js");
1627
1627
  await integrateChildren2(session, element);
1628
1628
  unsetExceptionBoundary(session);
1629
1629
  }
@@ -1633,7 +1633,7 @@ async function executeCatch(session, element) {
1633
1633
  const exceptionName = element.attributes?.name || "exception";
1634
1634
  const caughtCount = lookupException(session, exceptionName);
1635
1635
  if (caughtCount > 0) {
1636
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1636
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.js");
1637
1637
  await integrateChildren2(session, element);
1638
1638
  }
1639
1639
  flushCurrentException(session);
@@ -1642,7 +1642,7 @@ async function executeCatch(session, element) {
1642
1642
  // src/tags/exception.ts
1643
1643
  async function executeException(session, element) {
1644
1644
  const exceptions = getCurrentExceptions(session);
1645
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-54YLI2PC.js");
1645
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-BDXB5X77.js");
1646
1646
  for (const exceptionDom of exceptions) {
1647
1647
  await integrateChildren2(session, exceptionDom);
1648
1648
  }
@@ -1971,14 +1971,18 @@ var SubroutineRegistry = class {
1971
1971
  }
1972
1972
  let tokenMatchCount = 0;
1973
1973
  for (const queryToken of queryTokens) {
1974
+ if (queryToken.length <= 2) {
1975
+ continue;
1976
+ }
1974
1977
  if (nameTokens.some((nt) => nt === queryToken)) {
1975
1978
  score += 40;
1976
1979
  tokenMatchCount++;
1977
- } else if (nameTokens.some((nt) => nt.includes(queryToken))) {
1980
+ } else if (nameTokens.some((nt) => nt.startsWith(queryToken))) {
1978
1981
  score += 20;
1979
1982
  tokenMatchCount++;
1980
1983
  }
1981
- if (lowerDesc.includes(queryToken)) {
1984
+ const descWords = lowerDesc.split(/[\s\-_]+/);
1985
+ if (descWords.some((w) => w === queryToken || w.startsWith(queryToken))) {
1982
1986
  score += 15;
1983
1987
  tokenMatchCount++;
1984
1988
  }
@@ -1987,7 +1991,7 @@ var SubroutineRegistry = class {
1987
1991
  if (lowerParamName === queryToken) {
1988
1992
  score += 10;
1989
1993
  tokenMatchCount++;
1990
- } else if (lowerParamName.includes(queryToken)) {
1994
+ } else if (lowerParamName.startsWith(queryToken)) {
1991
1995
  score += 5;
1992
1996
  }
1993
1997
  }
@@ -2105,7 +2109,7 @@ async function executeLoadContext(session, element) {
2105
2109
  query = element.text.trim();
2106
2110
  }
2107
2111
  if (!query && element.children.length > 0) {
2108
- const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
2112
+ const { integrate: integrate2 } = await import("./interpreter-BDXB5X77.js");
2109
2113
  const beforeOutput = session.output.length;
2110
2114
  for (const child of element.children) {
2111
2115
  await integrate2(session, child);
@@ -2358,7 +2362,7 @@ async function executeForeach(session, element) {
2358
2362
  const parser2 = new DiracParser2();
2359
2363
  try {
2360
2364
  const fromElement = parser2.parse(fromAttr);
2361
- const { integrate: integrate2 } = await import("./interpreter-54YLI2PC.js");
2365
+ const { integrate: integrate2 } = await import("./interpreter-BDXB5X77.js");
2362
2366
  await integrate2(session, fromElement);
2363
2367
  } catch (e) {
2364
2368
  session.output = savedOutput;
package/dist/cli.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  } from "./chunk-UEFKQRYN.js";
5
5
  import {
6
6
  execute
7
- } from "./chunk-GKUTLPQJ.js";
8
- import "./chunk-IWNHCL6E.js";
7
+ } from "./chunk-BSEXAELC.js";
8
+ import "./chunk-D2TEBI65.js";
9
9
  import "./chunk-HRHAMPOB.js";
10
10
  import "./chunk-ZY37RS4P.js";
11
11
  import "./chunk-A4SFB5W4.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.48",
19
+ version: "0.1.51",
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-S5BLB32A.js");
99
+ const { DiracShell } = await import("./shell-QS4PSAF6.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.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createLLMAdapter,
3
3
  execute,
4
4
  executeUserCommand
5
- } from "./chunk-GKUTLPQJ.js";
5
+ } from "./chunk-BSEXAELC.js";
6
6
  import {
7
7
  integrate
8
- } from "./chunk-IWNHCL6E.js";
8
+ } from "./chunk-D2TEBI65.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-IWNHCL6E.js";
4
+ } from "./chunk-D2TEBI65.js";
5
5
  import "./chunk-HRHAMPOB.js";
6
6
  import "./chunk-ZY37RS4P.js";
7
7
  import "./chunk-A4SFB5W4.js";
@@ -3,7 +3,7 @@ import {
3
3
  listScheduledTasks,
4
4
  stopAllScheduledTasks,
5
5
  stopScheduledTask
6
- } from "./chunk-IWNHCL6E.js";
6
+ } from "./chunk-D2TEBI65.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-ZY37RS4P.js";
9
9
  import "./chunk-A4SFB5W4.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-UEFKQRYN.js";
5
5
  import {
6
6
  integrate
7
- } from "./chunk-IWNHCL6E.js";
7
+ } from "./chunk-D2TEBI65.js";
8
8
  import {
9
9
  DiracParser
10
10
  } from "./chunk-HRHAMPOB.js";
@@ -131,7 +131,7 @@ var DiracShell = class {
131
131
  });
132
132
  this.rl.on("close", () => {
133
133
  this.saveHistory();
134
- import("./schedule-TRNPB73K.js").then(({ stopAllScheduledTasks }) => {
134
+ import("./schedule-WF4BAWHX.js").then(({ stopAllScheduledTasks }) => {
135
135
  stopAllScheduledTasks();
136
136
  console.log("\nGoodbye!");
137
137
  process.exit(0);
@@ -159,6 +159,13 @@ var DiracShell = class {
159
159
  this.rl.prompt();
160
160
  return;
161
161
  }
162
+ if (this.inputBuffer.length === 0 && input.trim().startsWith("?")) {
163
+ const rest = input.trim().substring(1).trim();
164
+ input = rest ? `|ai>${rest}` : `|ai>`;
165
+ if (this.config.debug) {
166
+ console.log(`[mapped: ? -> ${input}]`);
167
+ }
168
+ }
162
169
  if (this.inputBuffer.length === 0 && !this.isDiracSyntax(input)) {
163
170
  await this.executeShellCommand(input);
164
171
  this.rl.prompt();
@@ -445,7 +452,7 @@ Examples:
445
452
  break;
446
453
  case "tasks":
447
454
  try {
448
- const { listScheduledTasks } = await import("./schedule-TRNPB73K.js");
455
+ const { listScheduledTasks } = await import("./schedule-WF4BAWHX.js");
449
456
  const tasks = listScheduledTasks();
450
457
  if (tasks.length === 0) {
451
458
  console.log("No scheduled tasks running.");
@@ -464,7 +471,7 @@ Examples:
464
471
  console.log("Usage: :stop <task-name>");
465
472
  } else {
466
473
  try {
467
- const { stopScheduledTask } = await import("./schedule-TRNPB73K.js");
474
+ const { stopScheduledTask } = await import("./schedule-WF4BAWHX.js");
468
475
  const taskName = args[0];
469
476
  const stopped = stopScheduledTask(taskName);
470
477
  if (stopped) {
@@ -479,7 +486,7 @@ Examples:
479
486
  break;
480
487
  case "stopall":
481
488
  try {
482
- const { stopAllScheduledTasks } = await import("./schedule-TRNPB73K.js");
489
+ const { stopAllScheduledTasks } = await import("./schedule-WF4BAWHX.js");
483
490
  stopAllScheduledTasks();
484
491
  console.log("All scheduled tasks stopped.");
485
492
  } catch (error) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-IWNHCL6E.js";
3
+ } from "./chunk-D2TEBI65.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.49",
3
+ "version": "0.1.51",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",