dirac-lang 0.1.30 → 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-QPYWRBBT.js → chunk-MAPD5UUF.js} +2 -2
- package/dist/{chunk-BSQV77YM.js → chunk-SIGINKX3.js} +9 -3
- package/dist/{chunk-Y57EPVOA.js → chunk-YAGJPLVS.js} +23 -18
- package/dist/cli.js +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/{interpreter-NNPKC43F.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
|
}
|
|
@@ -420,12 +425,12 @@ async function executeIf(session, element) {
|
|
|
420
425
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
421
426
|
if (condition) {
|
|
422
427
|
if (thenElement) {
|
|
423
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
428
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
424
429
|
await integrateChildren2(session, thenElement);
|
|
425
430
|
}
|
|
426
431
|
} else {
|
|
427
432
|
if (elseElement) {
|
|
428
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
433
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
429
434
|
await integrateChildren2(session, elseElement);
|
|
430
435
|
}
|
|
431
436
|
}
|
|
@@ -438,7 +443,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
438
443
|
return await evaluateCondition(session, predicateElement);
|
|
439
444
|
}
|
|
440
445
|
const outputLengthBefore = session.output.length;
|
|
441
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
446
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
442
447
|
await integrate2(session, predicateElement);
|
|
443
448
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
444
449
|
const result = newOutputChunks.join("").trim();
|
|
@@ -461,11 +466,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
461
466
|
}
|
|
462
467
|
const outputLengthBefore = session.output.length;
|
|
463
468
|
const args = [];
|
|
464
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
469
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
465
470
|
for (const child of condElement.children) {
|
|
466
471
|
if (child.tag.toLowerCase() === "arg") {
|
|
467
472
|
const argOutputStart = session.output.length;
|
|
468
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
473
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
469
474
|
await integrateChildren2(session, child);
|
|
470
475
|
const newChunks = session.output.slice(argOutputStart);
|
|
471
476
|
const argValue = newChunks.join("");
|
|
@@ -574,7 +579,7 @@ async function executeLLM(session, element) {
|
|
|
574
579
|
console.error("[LLM] Full prompt sent to LLM (noextra):\n" + prompt + "\n");
|
|
575
580
|
}
|
|
576
581
|
} else {
|
|
577
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
582
|
+
const { getAvailableSubroutines } = await import("./session-2OG5LRD4.js");
|
|
578
583
|
const subroutines = getAvailableSubroutines(session);
|
|
579
584
|
if (session.debug) {
|
|
580
585
|
console.error(
|
|
@@ -701,7 +706,7 @@ ${result}
|
|
|
701
706
|
const parser = new DiracParser();
|
|
702
707
|
let dynamicAST = parser.parse(diracCode);
|
|
703
708
|
if (validateTags) {
|
|
704
|
-
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-
|
|
709
|
+
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-3GP2CEDC.js");
|
|
705
710
|
let validation = await validateDiracCode(session, dynamicAST, { autocorrect });
|
|
706
711
|
let retryCount = 0;
|
|
707
712
|
while (!validation.valid && retryCount < maxRetries) {
|
|
@@ -1231,7 +1236,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
1231
1236
|
return { tag: allowed[bestIdx], score: bestScore };
|
|
1232
1237
|
}
|
|
1233
1238
|
async function executeTagCheck(session, element) {
|
|
1234
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
1239
|
+
const { getAvailableSubroutines } = await import("./session-2OG5LRD4.js");
|
|
1235
1240
|
const subroutines = getAvailableSubroutines(session);
|
|
1236
1241
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
1237
1242
|
console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
|
|
@@ -1324,7 +1329,7 @@ async function executeTagCheck(session, element) {
|
|
|
1324
1329
|
const executeTag = correctedTag || tagName;
|
|
1325
1330
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1326
1331
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1327
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1332
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1328
1333
|
await integrate2(session, elementToExecute);
|
|
1329
1334
|
}
|
|
1330
1335
|
}
|
|
@@ -1333,7 +1338,7 @@ async function executeTagCheck(session, element) {
|
|
|
1333
1338
|
// src/tags/throw.ts
|
|
1334
1339
|
async function executeThrow(session, element) {
|
|
1335
1340
|
const exceptionName = element.attributes?.name || "exception";
|
|
1336
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1341
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1337
1342
|
const exceptionDom = {
|
|
1338
1343
|
tag: "exception-content",
|
|
1339
1344
|
attributes: { name: exceptionName },
|
|
@@ -1346,7 +1351,7 @@ async function executeThrow(session, element) {
|
|
|
1346
1351
|
// src/tags/try.ts
|
|
1347
1352
|
async function executeTry(session, element) {
|
|
1348
1353
|
setExceptionBoundary(session);
|
|
1349
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1354
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1350
1355
|
await integrateChildren2(session, element);
|
|
1351
1356
|
unsetExceptionBoundary(session);
|
|
1352
1357
|
}
|
|
@@ -1356,7 +1361,7 @@ async function executeCatch(session, element) {
|
|
|
1356
1361
|
const exceptionName = element.attributes?.name || "exception";
|
|
1357
1362
|
const caughtCount = lookupException(session, exceptionName);
|
|
1358
1363
|
if (caughtCount > 0) {
|
|
1359
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1364
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1360
1365
|
await integrateChildren2(session, element);
|
|
1361
1366
|
}
|
|
1362
1367
|
flushCurrentException(session);
|
|
@@ -1365,7 +1370,7 @@ async function executeCatch(session, element) {
|
|
|
1365
1370
|
// src/tags/exception.ts
|
|
1366
1371
|
async function executeException(session, element) {
|
|
1367
1372
|
const exceptions = getCurrentExceptions(session);
|
|
1368
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1373
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1369
1374
|
for (const exceptionDom of exceptions) {
|
|
1370
1375
|
await integrateChildren2(session, exceptionDom);
|
|
1371
1376
|
}
|
|
@@ -1454,7 +1459,7 @@ function evaluateCondition2(session, test) {
|
|
|
1454
1459
|
// src/tags/available-subroutines.ts
|
|
1455
1460
|
async function executeAvailableSubroutines(session, element) {
|
|
1456
1461
|
const availableSubroutines = /* @__PURE__ */ new Map();
|
|
1457
|
-
const currentSubroutineName = session.subBoundary
|
|
1462
|
+
const currentSubroutineName = session.subBoundary > 0 && session.subBoundary <= session.subroutines.length ? session.subroutines[session.subBoundary - 1].name : null;
|
|
1458
1463
|
for (let i = session.subroutines.length - 1; i >= session.subBoundary; i--) {
|
|
1459
1464
|
const sub = session.subroutines[i];
|
|
1460
1465
|
if (sub.name === currentSubroutineName) {
|
|
@@ -1505,7 +1510,7 @@ async function executeForeach(session, element) {
|
|
|
1505
1510
|
const parser2 = new DiracParser2();
|
|
1506
1511
|
try {
|
|
1507
1512
|
const fromElement = parser2.parse(fromAttr);
|
|
1508
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1513
|
+
const { integrate: integrate2 } = await import("./interpreter-CEGW4F6U.js");
|
|
1509
1514
|
await integrate2(session, fromElement);
|
|
1510
1515
|
} catch (e) {
|
|
1511
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";
|