dirac-lang 0.1.51 → 0.1.53
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-BSEXAELC.js → chunk-EXP3R5ZJ.js} +1 -1
- package/dist/{chunk-D2TEBI65.js → chunk-QZGTAT3E.js} +35 -22
- package/dist/cli.js +4 -4
- package/dist/index.js +2 -2
- package/dist/{interpreter-BDXB5X77.js → interpreter-I4SRKXYK.js} +1 -1
- package/dist/{schedule-WF4BAWHX.js → schedule-7ZFCWNEF.js} +1 -1
- package/dist/{shell-QS4PSAF6.js → shell-TYEEQWCC.js} +5 -5
- package/dist/test-runner.js +1 -1
- package/package.json +1 -1
|
@@ -215,6 +215,7 @@ import * as fs from "fs";
|
|
|
215
215
|
import * as path from "path";
|
|
216
216
|
async function executeOutput(session, element) {
|
|
217
217
|
const fileAttr = element.attributes?.file;
|
|
218
|
+
const modeAttr = element.attributes?.mode;
|
|
218
219
|
const filePath = fileAttr ? substituteAttribute(session, fileAttr) : null;
|
|
219
220
|
if (filePath) {
|
|
220
221
|
let content = "";
|
|
@@ -231,7 +232,18 @@ async function executeOutput(session, element) {
|
|
|
231
232
|
if (dir !== "." && !fs.existsSync(dir)) {
|
|
232
233
|
fs.mkdirSync(dir, { recursive: true });
|
|
233
234
|
}
|
|
234
|
-
|
|
235
|
+
const mode = modeAttr || "append";
|
|
236
|
+
if (mode === "overwrite") {
|
|
237
|
+
fs.writeFileSync(filePath, content + "\n", "utf8");
|
|
238
|
+
if (session.debug) {
|
|
239
|
+
console.error(`[OUTPUT] Wrote (overwrite) to ${filePath}: ${content.substring(0, 50)}...`);
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
fs.appendFileSync(filePath, content + "\n", "utf8");
|
|
243
|
+
if (session.debug) {
|
|
244
|
+
console.error(`[OUTPUT] Appended to ${filePath}: ${content.substring(0, 50)}...`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
235
247
|
return;
|
|
236
248
|
}
|
|
237
249
|
if (element.children && element.children.length > 0) {
|
|
@@ -460,12 +472,12 @@ async function executeIf(session, element) {
|
|
|
460
472
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
461
473
|
if (condition) {
|
|
462
474
|
if (thenElement) {
|
|
463
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
475
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
464
476
|
await integrateChildren2(session, thenElement);
|
|
465
477
|
}
|
|
466
478
|
} else {
|
|
467
479
|
if (elseElement) {
|
|
468
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
480
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
469
481
|
await integrateChildren2(session, elseElement);
|
|
470
482
|
}
|
|
471
483
|
}
|
|
@@ -478,7 +490,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
478
490
|
return await evaluateCondition(session, predicateElement);
|
|
479
491
|
}
|
|
480
492
|
const outputLengthBefore = session.output.length;
|
|
481
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
493
|
+
const { integrate: integrate2 } = await import("./interpreter-I4SRKXYK.js");
|
|
482
494
|
await integrate2(session, predicateElement);
|
|
483
495
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
484
496
|
const result = newOutputChunks.join("").trim();
|
|
@@ -501,11 +513,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
501
513
|
}
|
|
502
514
|
const outputLengthBefore = session.output.length;
|
|
503
515
|
const args = [];
|
|
504
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
516
|
+
const { integrate: integrate2 } = await import("./interpreter-I4SRKXYK.js");
|
|
505
517
|
for (const child of condElement.children) {
|
|
506
518
|
if (child.tag.toLowerCase() === "arg") {
|
|
507
519
|
const argOutputStart = session.output.length;
|
|
508
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
520
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
509
521
|
await integrateChildren2(session, child);
|
|
510
522
|
const newChunks = session.output.slice(argOutputStart);
|
|
511
523
|
const argValue = newChunks.join("");
|
|
@@ -1601,7 +1613,7 @@ async function executeTagCheck(session, element) {
|
|
|
1601
1613
|
const executeTag = correctedTag || tagName;
|
|
1602
1614
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1603
1615
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1604
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1616
|
+
const { integrate: integrate2 } = await import("./interpreter-I4SRKXYK.js");
|
|
1605
1617
|
await integrate2(session, elementToExecute);
|
|
1606
1618
|
}
|
|
1607
1619
|
}
|
|
@@ -1610,7 +1622,7 @@ async function executeTagCheck(session, element) {
|
|
|
1610
1622
|
// src/tags/throw.ts
|
|
1611
1623
|
async function executeThrow(session, element) {
|
|
1612
1624
|
const exceptionName = element.attributes?.name || "exception";
|
|
1613
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1625
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
1614
1626
|
const exceptionDom = {
|
|
1615
1627
|
tag: "exception-content",
|
|
1616
1628
|
attributes: { name: exceptionName },
|
|
@@ -1623,7 +1635,7 @@ async function executeThrow(session, element) {
|
|
|
1623
1635
|
// src/tags/try.ts
|
|
1624
1636
|
async function executeTry(session, element) {
|
|
1625
1637
|
setExceptionBoundary(session);
|
|
1626
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1638
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
1627
1639
|
await integrateChildren2(session, element);
|
|
1628
1640
|
unsetExceptionBoundary(session);
|
|
1629
1641
|
}
|
|
@@ -1633,7 +1645,7 @@ async function executeCatch(session, element) {
|
|
|
1633
1645
|
const exceptionName = element.attributes?.name || "exception";
|
|
1634
1646
|
const caughtCount = lookupException(session, exceptionName);
|
|
1635
1647
|
if (caughtCount > 0) {
|
|
1636
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1648
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
1637
1649
|
await integrateChildren2(session, element);
|
|
1638
1650
|
}
|
|
1639
1651
|
flushCurrentException(session);
|
|
@@ -1642,7 +1654,7 @@ async function executeCatch(session, element) {
|
|
|
1642
1654
|
// src/tags/exception.ts
|
|
1643
1655
|
async function executeException(session, element) {
|
|
1644
1656
|
const exceptions = getCurrentExceptions(session);
|
|
1645
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1657
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-I4SRKXYK.js");
|
|
1646
1658
|
for (const exceptionDom of exceptions) {
|
|
1647
1659
|
await integrateChildren2(session, exceptionDom);
|
|
1648
1660
|
}
|
|
@@ -1880,6 +1892,7 @@ var SubroutineRegistry = class {
|
|
|
1880
1892
|
*/
|
|
1881
1893
|
async indexDirectory(dirPath) {
|
|
1882
1894
|
let count = 0;
|
|
1895
|
+
const absoluteDirPath = path3.isAbsolute(dirPath) ? dirPath : path3.resolve(process.cwd(), dirPath);
|
|
1883
1896
|
const scanDir = (dir) => {
|
|
1884
1897
|
const entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
1885
1898
|
for (const entry of entries) {
|
|
@@ -1891,7 +1904,7 @@ var SubroutineRegistry = class {
|
|
|
1891
1904
|
}
|
|
1892
1905
|
}
|
|
1893
1906
|
};
|
|
1894
|
-
scanDir(
|
|
1907
|
+
scanDir(absoluteDirPath);
|
|
1895
1908
|
this.saveIndex();
|
|
1896
1909
|
return count;
|
|
1897
1910
|
}
|
|
@@ -2109,7 +2122,7 @@ async function executeLoadContext(session, element) {
|
|
|
2109
2122
|
query = element.text.trim();
|
|
2110
2123
|
}
|
|
2111
2124
|
if (!query && element.children.length > 0) {
|
|
2112
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2125
|
+
const { integrate: integrate2 } = await import("./interpreter-I4SRKXYK.js");
|
|
2113
2126
|
const beforeOutput = session.output.length;
|
|
2114
2127
|
for (const child of element.children) {
|
|
2115
2128
|
await integrate2(session, child);
|
|
@@ -2151,8 +2164,8 @@ async function executeLoadContext(session, element) {
|
|
|
2151
2164
|
if (shouldImport) {
|
|
2152
2165
|
for (const filePath of fileMap.keys()) {
|
|
2153
2166
|
try {
|
|
2154
|
-
const { resolve:
|
|
2155
|
-
const absolutePath = filePath.startsWith("/") ? filePath :
|
|
2167
|
+
const { resolve: resolve4 } = await import("path");
|
|
2168
|
+
const absolutePath = filePath.startsWith("/") ? filePath : resolve4(process.cwd(), filePath);
|
|
2156
2169
|
const importElement = {
|
|
2157
2170
|
tag: "import",
|
|
2158
2171
|
attributes: { src: absolutePath },
|
|
@@ -2184,8 +2197,8 @@ async function executeLoadContext(session, element) {
|
|
|
2184
2197
|
}
|
|
2185
2198
|
|
|
2186
2199
|
// src/tags/save-subroutine.ts
|
|
2187
|
-
import { writeFileSync as
|
|
2188
|
-
import { resolve as
|
|
2200
|
+
import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, existsSync as existsSync5 } from "fs";
|
|
2201
|
+
import { resolve as resolve3, dirname as dirname4, join as join4 } from "path";
|
|
2189
2202
|
import { homedir as homedir4 } from "os";
|
|
2190
2203
|
async function executeSaveSubroutine(session, element) {
|
|
2191
2204
|
const name = element.attributes.name;
|
|
@@ -2213,7 +2226,7 @@ async function executeSaveSubroutine(session, element) {
|
|
|
2213
2226
|
}
|
|
2214
2227
|
let filePath;
|
|
2215
2228
|
if (file) {
|
|
2216
|
-
filePath =
|
|
2229
|
+
filePath = resolve3(process.cwd(), file);
|
|
2217
2230
|
} else if (pathAttr) {
|
|
2218
2231
|
const targetDir = join4(homedir4(), ".dirac", "lib", pathAttr);
|
|
2219
2232
|
filePath = join4(targetDir, `${name}.di`);
|
|
@@ -2226,7 +2239,7 @@ async function executeSaveSubroutine(session, element) {
|
|
|
2226
2239
|
if (!existsSync5(dir)) {
|
|
2227
2240
|
mkdirSync4(dir, { recursive: true });
|
|
2228
2241
|
}
|
|
2229
|
-
|
|
2242
|
+
writeFileSync4(filePath, content, "utf-8");
|
|
2230
2243
|
emit(session, `Subroutine '${name}' saved to: ${filePath}
|
|
2231
2244
|
`);
|
|
2232
2245
|
if (session.debug) {
|
|
@@ -2362,7 +2375,7 @@ async function executeForeach(session, element) {
|
|
|
2362
2375
|
const parser2 = new DiracParser2();
|
|
2363
2376
|
try {
|
|
2364
2377
|
const fromElement = parser2.parse(fromAttr);
|
|
2365
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2378
|
+
const { integrate: integrate2 } = await import("./interpreter-I4SRKXYK.js");
|
|
2366
2379
|
await integrate2(session, fromElement);
|
|
2367
2380
|
} catch (e) {
|
|
2368
2381
|
session.output = savedOutput;
|
|
@@ -2551,7 +2564,7 @@ async function readAllStdin() {
|
|
|
2551
2564
|
process.stdin.removeAllListeners("data");
|
|
2552
2565
|
process.stdin.removeAllListeners("end");
|
|
2553
2566
|
process.stdin.removeAllListeners("error");
|
|
2554
|
-
return new Promise((
|
|
2567
|
+
return new Promise((resolve4, reject) => {
|
|
2555
2568
|
const chunks = [];
|
|
2556
2569
|
const onData = (chunk) => {
|
|
2557
2570
|
chunks.push(chunk);
|
|
@@ -2561,7 +2574,7 @@ async function readAllStdin() {
|
|
|
2561
2574
|
process.stdin.removeListener("data", onData);
|
|
2562
2575
|
process.stdin.removeListener("end", onEnd);
|
|
2563
2576
|
process.stdin.removeListener("error", onError);
|
|
2564
|
-
|
|
2577
|
+
resolve4(result);
|
|
2565
2578
|
};
|
|
2566
2579
|
const onError = (err) => {
|
|
2567
2580
|
process.stdin.removeListener("data", onData);
|
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-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-EXP3R5ZJ.js";
|
|
8
|
+
import "./chunk-QZGTAT3E.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.
|
|
19
|
+
version: "0.1.53",
|
|
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-
|
|
99
|
+
const { DiracShell } = await import("./shell-TYEEQWCC.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-
|
|
5
|
+
} from "./chunk-EXP3R5ZJ.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QZGTAT3E.js";
|
|
9
9
|
import {
|
|
10
10
|
DiracParser
|
|
11
11
|
} from "./chunk-HRHAMPOB.js";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-UEFKQRYN.js";
|
|
5
5
|
import {
|
|
6
6
|
integrate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QZGTAT3E.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-
|
|
134
|
+
import("./schedule-7ZFCWNEF.js").then(({ stopAllScheduledTasks }) => {
|
|
135
135
|
stopAllScheduledTasks();
|
|
136
136
|
console.log("\nGoodbye!");
|
|
137
137
|
process.exit(0);
|
|
@@ -452,7 +452,7 @@ Examples:
|
|
|
452
452
|
break;
|
|
453
453
|
case "tasks":
|
|
454
454
|
try {
|
|
455
|
-
const { listScheduledTasks } = await import("./schedule-
|
|
455
|
+
const { listScheduledTasks } = await import("./schedule-7ZFCWNEF.js");
|
|
456
456
|
const tasks = listScheduledTasks();
|
|
457
457
|
if (tasks.length === 0) {
|
|
458
458
|
console.log("No scheduled tasks running.");
|
|
@@ -471,7 +471,7 @@ Examples:
|
|
|
471
471
|
console.log("Usage: :stop <task-name>");
|
|
472
472
|
} else {
|
|
473
473
|
try {
|
|
474
|
-
const { stopScheduledTask } = await import("./schedule-
|
|
474
|
+
const { stopScheduledTask } = await import("./schedule-7ZFCWNEF.js");
|
|
475
475
|
const taskName = args[0];
|
|
476
476
|
const stopped = stopScheduledTask(taskName);
|
|
477
477
|
if (stopped) {
|
|
@@ -486,7 +486,7 @@ Examples:
|
|
|
486
486
|
break;
|
|
487
487
|
case "stopall":
|
|
488
488
|
try {
|
|
489
|
-
const { stopAllScheduledTasks } = await import("./schedule-
|
|
489
|
+
const { stopAllScheduledTasks } = await import("./schedule-7ZFCWNEF.js");
|
|
490
490
|
stopAllScheduledTasks();
|
|
491
491
|
console.log("All scheduled tasks stopped.");
|
|
492
492
|
} catch (error) {
|
package/dist/test-runner.js
CHANGED