dirac-lang 0.1.29 → 0.1.31
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/dist/{chunk-LXF5PGUX.js → chunk-FWD3RMQ7.js} +4 -2
- package/dist/{chunk-YV6QRRMT.js → chunk-MAPD5UUF.js} +2 -2
- package/dist/{chunk-BSQV77YM.js → chunk-SIGINKX3.js} +9 -3
- package/dist/{chunk-VURAZURY.js → chunk-YAGJPLVS.js} +26 -20
- package/dist/cli.js +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/{interpreter-BB4H4XG4.js → interpreter-CEGW4F6U.js} +3 -3
- package/dist/{session-QXKZY7G2.js → session-2OG5LRD4.js} +1 -1
- package/dist/{subroutine-GG66UT4D.js → subroutine-W2MI62EG.js} +2 -2
- package/dist/{tag-validator-ANTK7UTG.js → tag-validator-3GP2CEDC.js} +1 -1
- package/dist/test-runner.js +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerSubroutine
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SIGINKX3.js";
|
|
4
4
|
|
|
5
5
|
// src/tags/subroutine.ts
|
|
6
6
|
function executeSubroutine(session, element) {
|
|
@@ -12,6 +12,7 @@ function executeSubroutine(session, element) {
|
|
|
12
12
|
throw new Error("<subroutine> requires name attribute");
|
|
13
13
|
}
|
|
14
14
|
const description = element.attributes.description;
|
|
15
|
+
const visible = element.attributes.visible === "subroutine" || element.attributes.visible === "both";
|
|
15
16
|
const parameters = [];
|
|
16
17
|
const meta = {};
|
|
17
18
|
function parseMetaField(metaString) {
|
|
@@ -56,7 +57,8 @@ function executeSubroutine(session, element) {
|
|
|
56
57
|
subroutine,
|
|
57
58
|
description,
|
|
58
59
|
parameters.length > 0 ? parameters : void 0,
|
|
59
|
-
Object.keys(meta).length > 0 ? meta : void 0
|
|
60
|
+
Object.keys(meta).length > 0 ? meta : void 0,
|
|
61
|
+
visible
|
|
60
62
|
);
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YAGJPLVS.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-
|
|
11
|
+
} from "./chunk-SIGINKX3.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/llm-adapter.ts
|
|
14
14
|
function createLLMAdapter(session) {
|
|
@@ -151,11 +151,12 @@ function cleanToBoundary(session) {
|
|
|
151
151
|
session.variables = kept;
|
|
152
152
|
session.varBoundary = kept.length;
|
|
153
153
|
}
|
|
154
|
-
function registerSubroutine(session, name, element, description, parameters, meta) {
|
|
154
|
+
function registerSubroutine(session, name, element, description, parameters, meta, visible) {
|
|
155
155
|
session.subroutines.push({
|
|
156
156
|
name,
|
|
157
157
|
element,
|
|
158
158
|
boundary: session.subBoundary,
|
|
159
|
+
visible,
|
|
159
160
|
description,
|
|
160
161
|
parameters,
|
|
161
162
|
meta
|
|
@@ -193,8 +194,13 @@ function setSubroutineBoundary(session) {
|
|
|
193
194
|
function popSubroutinesToBoundary(session) {
|
|
194
195
|
session.subroutines = session.subroutines.slice(0, session.subBoundary);
|
|
195
196
|
}
|
|
196
|
-
function cleanSubroutinesToBoundary(session) {
|
|
197
|
-
|
|
197
|
+
function cleanSubroutinesToBoundary(session, callerSubroutine) {
|
|
198
|
+
const keepNested = callerSubroutine?.attributes.visible === "subroutine" || callerSubroutine?.attributes.visible === "both";
|
|
199
|
+
if (keepNested) {
|
|
200
|
+
session.subBoundary = session.subroutines.length;
|
|
201
|
+
} else {
|
|
202
|
+
session.subroutines = session.subroutines.slice(0, session.subBoundary);
|
|
203
|
+
}
|
|
198
204
|
}
|
|
199
205
|
function substituteVariables(session, text) {
|
|
200
206
|
return text.replace(/ /g, "\n").replace(/ /g, "\r").replace(/	/g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-HRHAMPOB.js";
|
|
4
4
|
import {
|
|
5
5
|
executeSubroutine
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FWD3RMQ7.js";
|
|
7
7
|
import {
|
|
8
|
+
cleanSubroutinesToBoundary,
|
|
8
9
|
cleanToBoundary,
|
|
9
10
|
emit,
|
|
10
11
|
flushCurrentException,
|
|
@@ -18,12 +19,13 @@ import {
|
|
|
18
19
|
pushParameters,
|
|
19
20
|
setBoundary,
|
|
20
21
|
setExceptionBoundary,
|
|
22
|
+
setSubroutineBoundary,
|
|
21
23
|
setVariable,
|
|
22
24
|
substituteAttribute,
|
|
23
25
|
substituteVariables,
|
|
24
26
|
throwException,
|
|
25
27
|
unsetExceptionBoundary
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-SIGINKX3.js";
|
|
27
29
|
|
|
28
30
|
// src/tags/parameters.ts
|
|
29
31
|
async function executeParameters(session, element) {
|
|
@@ -255,7 +257,7 @@ async function executeCall(session, element) {
|
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
259
|
async function registerExtendChain(session, subroutine, currentName) {
|
|
258
|
-
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-
|
|
260
|
+
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-W2MI62EG.js");
|
|
259
261
|
const extendsAttr = subroutine.attributes.extends;
|
|
260
262
|
let parentName;
|
|
261
263
|
if (extendsAttr) {
|
|
@@ -289,6 +291,7 @@ async function registerExtendChain(session, subroutine, currentName) {
|
|
|
289
291
|
}
|
|
290
292
|
async function executeCallInternal(session, subroutine, callElement, isExtendExecution = false) {
|
|
291
293
|
const oldBoundary = setBoundary(session);
|
|
294
|
+
const oldSubBoundary = setSubroutineBoundary(session);
|
|
292
295
|
const wasReturn = session.isReturn;
|
|
293
296
|
session.isReturn = false;
|
|
294
297
|
const oldSubroutineName = session.currentSubroutineName;
|
|
@@ -334,7 +337,9 @@ async function executeCallInternal(session, subroutine, callElement, isExtendExe
|
|
|
334
337
|
session.skipSubroutineRegistration = oldSkipFlag;
|
|
335
338
|
popParameters(session);
|
|
336
339
|
cleanToBoundary(session);
|
|
340
|
+
cleanSubroutinesToBoundary(session, subroutine);
|
|
337
341
|
session.varBoundary = oldBoundary;
|
|
342
|
+
session.subBoundary = oldSubBoundary;
|
|
338
343
|
session.isReturn = wasReturn;
|
|
339
344
|
}
|
|
340
345
|
}
|
|
@@ -379,9 +384,10 @@ async function executeLoop(session, element) {
|
|
|
379
384
|
if (!countAttr) {
|
|
380
385
|
throw new Error("<loop> requires count attribute");
|
|
381
386
|
}
|
|
382
|
-
const
|
|
387
|
+
const substitutedCount = substituteAttribute(session, countAttr);
|
|
388
|
+
const count = parseInt(substitutedCount, 10);
|
|
383
389
|
if (isNaN(count) || count < 0) {
|
|
384
|
-
throw new Error(`Invalid loop count: ${countAttr}`);
|
|
390
|
+
throw new Error(`Invalid loop count: ${countAttr} (evaluated to: ${substitutedCount})`);
|
|
385
391
|
}
|
|
386
392
|
const wasBreak = session.isBreak;
|
|
387
393
|
session.isBreak = false;
|
|
@@ -419,12 +425,12 @@ async function executeIf(session, element) {
|
|
|
419
425
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
420
426
|
if (condition) {
|
|
421
427
|
if (thenElement) {
|
|
422
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
428
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
423
429
|
await integrateChildren2(session, thenElement);
|
|
424
430
|
}
|
|
425
431
|
} else {
|
|
426
432
|
if (elseElement) {
|
|
427
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
433
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
428
434
|
await integrateChildren2(session, elseElement);
|
|
429
435
|
}
|
|
430
436
|
}
|
|
@@ -437,7 +443,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
437
443
|
return await evaluateCondition(session, predicateElement);
|
|
438
444
|
}
|
|
439
445
|
const outputLengthBefore = session.output.length;
|
|
440
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
446
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
441
447
|
await integrate2(session, predicateElement);
|
|
442
448
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
443
449
|
const result = newOutputChunks.join("").trim();
|
|
@@ -460,11 +466,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
460
466
|
}
|
|
461
467
|
const outputLengthBefore = session.output.length;
|
|
462
468
|
const args = [];
|
|
463
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
469
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
464
470
|
for (const child of condElement.children) {
|
|
465
471
|
if (child.tag.toLowerCase() === "arg") {
|
|
466
472
|
const argOutputStart = session.output.length;
|
|
467
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
473
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
468
474
|
await integrateChildren2(session, child);
|
|
469
475
|
const newChunks = session.output.slice(argOutputStart);
|
|
470
476
|
const argValue = newChunks.join("");
|
|
@@ -573,7 +579,7 @@ async function executeLLM(session, element) {
|
|
|
573
579
|
console.error("[LLM] Full prompt sent to LLM (noextra):\n" + prompt + "\n");
|
|
574
580
|
}
|
|
575
581
|
} else {
|
|
576
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
582
|
+
const { getAvailableSubroutines } = await import("./session-2OG5LRD4.js");
|
|
577
583
|
const subroutines = getAvailableSubroutines(session);
|
|
578
584
|
if (session.debug) {
|
|
579
585
|
console.error(
|
|
@@ -700,7 +706,7 @@ ${result}
|
|
|
700
706
|
const parser = new DiracParser();
|
|
701
707
|
let dynamicAST = parser.parse(diracCode);
|
|
702
708
|
if (validateTags) {
|
|
703
|
-
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-
|
|
709
|
+
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-3GP2CEDC.js");
|
|
704
710
|
let validation = await validateDiracCode(session, dynamicAST, { autocorrect });
|
|
705
711
|
let retryCount = 0;
|
|
706
712
|
while (!validation.valid && retryCount < maxRetries) {
|
|
@@ -1230,7 +1236,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
1230
1236
|
return { tag: allowed[bestIdx], score: bestScore };
|
|
1231
1237
|
}
|
|
1232
1238
|
async function executeTagCheck(session, element) {
|
|
1233
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
1239
|
+
const { getAvailableSubroutines } = await import("./session-2OG5LRD4.js");
|
|
1234
1240
|
const subroutines = getAvailableSubroutines(session);
|
|
1235
1241
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
1236
1242
|
console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
|
|
@@ -1323,7 +1329,7 @@ async function executeTagCheck(session, element) {
|
|
|
1323
1329
|
const executeTag = correctedTag || tagName;
|
|
1324
1330
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1325
1331
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1326
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1332
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1327
1333
|
await integrate2(session, elementToExecute);
|
|
1328
1334
|
}
|
|
1329
1335
|
}
|
|
@@ -1332,7 +1338,7 @@ async function executeTagCheck(session, element) {
|
|
|
1332
1338
|
// src/tags/throw.ts
|
|
1333
1339
|
async function executeThrow(session, element) {
|
|
1334
1340
|
const exceptionName = element.attributes?.name || "exception";
|
|
1335
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1341
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1336
1342
|
const exceptionDom = {
|
|
1337
1343
|
tag: "exception-content",
|
|
1338
1344
|
attributes: { name: exceptionName },
|
|
@@ -1345,7 +1351,7 @@ async function executeThrow(session, element) {
|
|
|
1345
1351
|
// src/tags/try.ts
|
|
1346
1352
|
async function executeTry(session, element) {
|
|
1347
1353
|
setExceptionBoundary(session);
|
|
1348
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1354
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1349
1355
|
await integrateChildren2(session, element);
|
|
1350
1356
|
unsetExceptionBoundary(session);
|
|
1351
1357
|
}
|
|
@@ -1355,7 +1361,7 @@ async function executeCatch(session, element) {
|
|
|
1355
1361
|
const exceptionName = element.attributes?.name || "exception";
|
|
1356
1362
|
const caughtCount = lookupException(session, exceptionName);
|
|
1357
1363
|
if (caughtCount > 0) {
|
|
1358
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1364
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1359
1365
|
await integrateChildren2(session, element);
|
|
1360
1366
|
}
|
|
1361
1367
|
flushCurrentException(session);
|
|
@@ -1364,7 +1370,7 @@ async function executeCatch(session, element) {
|
|
|
1364
1370
|
// src/tags/exception.ts
|
|
1365
1371
|
async function executeException(session, element) {
|
|
1366
1372
|
const exceptions = getCurrentExceptions(session);
|
|
1367
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1373
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1368
1374
|
for (const exceptionDom of exceptions) {
|
|
1369
1375
|
await integrateChildren2(session, exceptionDom);
|
|
1370
1376
|
}
|
|
@@ -1453,7 +1459,7 @@ function evaluateCondition2(session, test) {
|
|
|
1453
1459
|
// src/tags/available-subroutines.ts
|
|
1454
1460
|
async function executeAvailableSubroutines(session, element) {
|
|
1455
1461
|
const availableSubroutines = /* @__PURE__ */ new Map();
|
|
1456
|
-
const currentSubroutineName = session.subBoundary
|
|
1462
|
+
const currentSubroutineName = session.subBoundary > 0 && session.subBoundary <= session.subroutines.length ? session.subroutines[session.subBoundary - 1].name : null;
|
|
1457
1463
|
for (let i = session.subroutines.length - 1; i >= session.subBoundary; i--) {
|
|
1458
1464
|
const sub = session.subroutines[i];
|
|
1459
1465
|
if (sub.name === currentSubroutineName) {
|
|
@@ -1504,7 +1510,7 @@ async function executeForeach(session, element) {
|
|
|
1504
1510
|
const parser2 = new DiracParser2();
|
|
1505
1511
|
try {
|
|
1506
1512
|
const fromElement = parser2.parse(fromAttr);
|
|
1507
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1513
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1508
1514
|
await integrate2(session, fromElement);
|
|
1509
1515
|
} catch (e) {
|
|
1510
1516
|
session.output = savedOutput;
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
execute
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-MAPD5UUF.js";
|
|
5
|
+
import "./chunk-YAGJPLVS.js";
|
|
6
6
|
import "./chunk-HRHAMPOB.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-FWD3RMQ7.js";
|
|
8
|
+
import "./chunk-SIGINKX3.js";
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
11
11
|
import "dotenv/config";
|
|
@@ -13,7 +13,7 @@ import "dotenv/config";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "dirac-lang",
|
|
16
|
-
version: "0.1.
|
|
16
|
+
version: "0.1.31",
|
|
17
17
|
description: "LLM-Augmented Declarative Execution",
|
|
18
18
|
type: "module",
|
|
19
19
|
main: "dist/index.js",
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
createLLMAdapter,
|
|
3
3
|
execute,
|
|
4
4
|
executeUserCommand
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MAPD5UUF.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YAGJPLVS.js";
|
|
9
9
|
import {
|
|
10
10
|
DiracParser
|
|
11
11
|
} from "./chunk-HRHAMPOB.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-FWD3RMQ7.js";
|
|
13
13
|
import {
|
|
14
14
|
createSession,
|
|
15
15
|
getAvailableSubroutines,
|
|
16
16
|
getOutput
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-SIGINKX3.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-
|
|
4
|
+
} from "./chunk-YAGJPLVS.js";
|
|
5
5
|
import "./chunk-HRHAMPOB.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-FWD3RMQ7.js";
|
|
7
|
+
import "./chunk-SIGINKX3.js";
|
|
8
8
|
export {
|
|
9
9
|
integrate,
|
|
10
10
|
integrateChildren
|
|
@@ -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-
|
|
52
|
+
const { getAvailableSubroutines } = await import("./session-2OG5LRD4.js");
|
|
53
53
|
const subroutines = getAvailableSubroutines(session);
|
|
54
54
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
55
55
|
const tagName = element.tag;
|
package/dist/test-runner.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YAGJPLVS.js";
|
|
4
4
|
import {
|
|
5
5
|
DiracParser
|
|
6
6
|
} from "./chunk-HRHAMPOB.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-FWD3RMQ7.js";
|
|
8
8
|
import {
|
|
9
9
|
createSession,
|
|
10
10
|
getOutput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-SIGINKX3.js";
|
|
12
12
|
|
|
13
13
|
// src/test-runner.ts
|
|
14
14
|
import fs from "fs";
|