dirac-lang 0.1.98 → 0.1.99
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/{agent-5Q5MQOV2.js → agent-3SJF56JW.js} +5 -5
- package/dist/{chunk-LAEYP4OQ.js → chunk-3VCKPUTQ.js} +20 -20
- package/dist/{chunk-SLGJRZ3P.js → chunk-53QJQ2CC.js} +1 -1
- package/dist/{chunk-ECAW4X46.js → chunk-EAM7IZWA.js} +1 -1
- package/dist/{chunk-MYWEN36N.js → chunk-EE3YBMAD.js} +2 -2
- package/dist/{chunk-33DMGFRM.js → chunk-R6R6OHPA.js} +2 -2
- package/dist/{chunk-PPH7KYKH.js → chunk-ZYSWVMID.js} +6 -0
- package/dist/cli.js +11 -11
- package/dist/{cron-VCUFU2WU.js → cron-TTPFON3Y.js} +4 -4
- package/dist/index.js +5 -5
- package/dist/interpreter-ENHZAIWT.js +12 -0
- package/dist/{run-at-P43PK5JU.js → run-at-A3CJX4TR.js} +4 -4
- package/dist/{schedule-3EJJHG3B.js → schedule-OYEKDXZV.js} +4 -4
- package/dist/{session-IH5LO7FS.js → session-6WX5O74B.js} +3 -1
- package/dist/{session-server-N53QIJO5.js → session-server-LMDDND5E.js} +5 -5
- package/dist/{shell-KNEQHL3Y.js → shell-PV6KIJL5.js} +147 -15
- package/dist/{subroutine-7JJKHTV4.js → subroutine-O3YGYHRZ.js} +2 -2
- package/dist/{subroutine-index-RVJSWWJ7.js → subroutine-index-GB3OSH56.js} +2 -2
- package/dist/subroutine-serializer-LNFHABUC.js +160 -0
- package/dist/{tag-validator-DS7OCXCG.js → tag-validator-QS7T4GFE.js} +1 -1
- package/dist/test-runner.js +4 -4
- package/lib/native-tags.di +2 -1
- package/package.json +1 -1
- package/dist/interpreter-D6ZF3OJA.js +0 -12
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
SessionServer,
|
|
3
3
|
getSocketPath,
|
|
4
4
|
isSessionRunning
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-R6R6OHPA.js";
|
|
6
|
+
import "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
8
8
|
import "./chunk-HRHAMPOB.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
|
|
12
12
|
// src/agent.ts
|
|
13
13
|
import fs from "fs";
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
executeRegistryStats,
|
|
4
4
|
executeSearchSubroutines,
|
|
5
5
|
registry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-53QJQ2CC.js";
|
|
7
7
|
import {
|
|
8
8
|
DiracParser
|
|
9
9
|
} from "./chunk-HRHAMPOB.js";
|
|
10
10
|
import {
|
|
11
11
|
executeSubroutine
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-EAM7IZWA.js";
|
|
13
13
|
import {
|
|
14
14
|
CustomLLMProvider,
|
|
15
15
|
OllamaProvider,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
substituteVariables,
|
|
35
35
|
throwException,
|
|
36
36
|
unsetExceptionBoundary
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-ZYSWVMID.js";
|
|
38
38
|
|
|
39
39
|
// src/tags/parameters.ts
|
|
40
40
|
async function executeParameters(session, element) {
|
|
@@ -297,7 +297,7 @@ async function executeCall(session, element) {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
async function registerExtendChain(session, subroutine, currentName) {
|
|
300
|
-
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-
|
|
300
|
+
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-O3YGYHRZ.js");
|
|
301
301
|
const extendsAttr = subroutine.attributes.extends;
|
|
302
302
|
let parentName;
|
|
303
303
|
if (extendsAttr) {
|
|
@@ -487,12 +487,12 @@ async function executeIf(session, element) {
|
|
|
487
487
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
488
488
|
if (condition) {
|
|
489
489
|
if (thenElement) {
|
|
490
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
490
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
491
491
|
await integrateChildren2(session, thenElement);
|
|
492
492
|
}
|
|
493
493
|
} else {
|
|
494
494
|
if (elseElement) {
|
|
495
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
495
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
496
496
|
await integrateChildren2(session, elseElement);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
@@ -505,7 +505,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
505
505
|
return await evaluateCondition(session, predicateElement);
|
|
506
506
|
}
|
|
507
507
|
const outputLengthBefore = session.output.length;
|
|
508
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
508
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
509
509
|
await integrate2(session, predicateElement);
|
|
510
510
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
511
511
|
const result = newOutputChunks.join("").trim();
|
|
@@ -528,11 +528,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
528
528
|
}
|
|
529
529
|
const outputLengthBefore = session.output.length;
|
|
530
530
|
const args = [];
|
|
531
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
531
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
532
532
|
for (const child of condElement.children) {
|
|
533
533
|
if (child.tag.toLowerCase() === "arg") {
|
|
534
534
|
const argOutputStart = session.output.length;
|
|
535
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
535
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
536
536
|
await integrateChildren2(session, child);
|
|
537
537
|
const newChunks = session.output.slice(argOutputStart);
|
|
538
538
|
const argValue = newChunks.join("");
|
|
@@ -852,7 +852,7 @@ async function executeLLM(session, element) {
|
|
|
852
852
|
let systemPrompt = "";
|
|
853
853
|
let currentUserPrompt = userPrompt;
|
|
854
854
|
if (!noExtra) {
|
|
855
|
-
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-
|
|
855
|
+
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-6WX5O74B.js");
|
|
856
856
|
const allSubroutines = getAvailableSubroutines2(session);
|
|
857
857
|
if (session.debug) {
|
|
858
858
|
console.error(`[LLM] Total subroutines from session: ${allSubroutines.length}`);
|
|
@@ -1098,7 +1098,7 @@ ${result}
|
|
|
1098
1098
|
if (session.debug) {
|
|
1099
1099
|
console.error(`[LLM] Validation enabled, autocorrect: ${autocorrect}`);
|
|
1100
1100
|
}
|
|
1101
|
-
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-
|
|
1101
|
+
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-QS7T4GFE.js");
|
|
1102
1102
|
let validation = await validateDiracCode(session, dynamicAST, { autocorrect, deepValidation: true });
|
|
1103
1103
|
console.error(`[LLM] Iteration ${iteration}: Validation complete - valid: ${validation.valid}, errors: ${validation.errorMessages.length}`);
|
|
1104
1104
|
if (session.debug) {
|
|
@@ -1968,7 +1968,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
1968
1968
|
return { tag: allowed[bestIdx], score: bestScore };
|
|
1969
1969
|
}
|
|
1970
1970
|
async function executeTagCheck(session, element) {
|
|
1971
|
-
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-
|
|
1971
|
+
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-6WX5O74B.js");
|
|
1972
1972
|
const subroutines = getAvailableSubroutines2(session);
|
|
1973
1973
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
1974
1974
|
console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
|
|
@@ -2061,7 +2061,7 @@ async function executeTagCheck(session, element) {
|
|
|
2061
2061
|
const executeTag = correctedTag || tagName;
|
|
2062
2062
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
2063
2063
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
2064
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2064
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2065
2065
|
await integrate2(session, elementToExecute);
|
|
2066
2066
|
}
|
|
2067
2067
|
}
|
|
@@ -2070,7 +2070,7 @@ async function executeTagCheck(session, element) {
|
|
|
2070
2070
|
// src/tags/throw.ts
|
|
2071
2071
|
async function executeThrow(session, element) {
|
|
2072
2072
|
const exceptionName = element.attributes?.name || "exception";
|
|
2073
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2073
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2074
2074
|
const exceptionDom = {
|
|
2075
2075
|
tag: "exception-content",
|
|
2076
2076
|
attributes: { name: exceptionName },
|
|
@@ -2083,7 +2083,7 @@ async function executeThrow(session, element) {
|
|
|
2083
2083
|
// src/tags/try.ts
|
|
2084
2084
|
async function executeTry(session, element) {
|
|
2085
2085
|
setExceptionBoundary(session);
|
|
2086
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2086
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2087
2087
|
await integrateChildren2(session, element);
|
|
2088
2088
|
unsetExceptionBoundary(session);
|
|
2089
2089
|
}
|
|
@@ -2093,7 +2093,7 @@ async function executeCatch(session, element) {
|
|
|
2093
2093
|
const exceptionName = element.attributes?.name || "exception";
|
|
2094
2094
|
const caughtCount = lookupException(session, exceptionName);
|
|
2095
2095
|
if (caughtCount > 0) {
|
|
2096
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2096
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2097
2097
|
await integrateChildren2(session, element);
|
|
2098
2098
|
}
|
|
2099
2099
|
flushCurrentException(session);
|
|
@@ -2102,7 +2102,7 @@ async function executeCatch(session, element) {
|
|
|
2102
2102
|
// src/tags/exception.ts
|
|
2103
2103
|
async function executeException(session, element) {
|
|
2104
2104
|
const exceptions = getCurrentExceptions(session);
|
|
2105
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2105
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2106
2106
|
for (const exceptionDom of exceptions) {
|
|
2107
2107
|
await integrateChildren2(session, exceptionDom);
|
|
2108
2108
|
}
|
|
@@ -2303,7 +2303,7 @@ async function executeLoadContext(session, element) {
|
|
|
2303
2303
|
query = element.text.trim();
|
|
2304
2304
|
}
|
|
2305
2305
|
if (!query && element.children.length > 0) {
|
|
2306
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2306
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2307
2307
|
const beforeOutput = session.output.length;
|
|
2308
2308
|
for (const child of element.children) {
|
|
2309
2309
|
await integrate2(session, child);
|
|
@@ -2372,7 +2372,7 @@ async function executeLoadContext(session, element) {
|
|
|
2372
2372
|
parameters: s.parameters.map((p) => p.name),
|
|
2373
2373
|
filePath: s.filePath
|
|
2374
2374
|
}));
|
|
2375
|
-
const { setVariable: setVariable2 } = await import("./session-
|
|
2375
|
+
const { setVariable: setVariable2 } = await import("./session-6WX5O74B.js");
|
|
2376
2376
|
setVariable2(session, outputVar, JSON.stringify(summary, null, 2), false);
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
@@ -3147,7 +3147,7 @@ async function executeForeach(session, element) {
|
|
|
3147
3147
|
const parser2 = new DiracParser2();
|
|
3148
3148
|
try {
|
|
3149
3149
|
const fromElement = parser2.parse(fromAttr);
|
|
3150
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
3150
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
3151
3151
|
await integrate2(session, fromElement);
|
|
3152
3152
|
} catch (e) {
|
|
3153
3153
|
session.output = savedOutput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3VCKPUTQ.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-ZYSWVMID.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/llm-adapter.ts
|
|
14
14
|
function createLLMAdapter(session) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
4
4
|
import {
|
|
5
5
|
DiracParser
|
|
6
6
|
} from "./chunk-HRHAMPOB.js";
|
|
7
7
|
import {
|
|
8
8
|
createSession
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZYSWVMID.js";
|
|
10
10
|
|
|
11
11
|
// src/session-server.ts
|
|
12
12
|
import net from "net";
|
|
@@ -260,6 +260,11 @@ function cleanSubroutinesToBoundary(session, callerSubroutine) {
|
|
|
260
260
|
session.subroutines = session.subroutines.slice(0, session.subBoundary);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
+
function removeSubroutine(session, name) {
|
|
264
|
+
const initialLength = session.subroutines.length;
|
|
265
|
+
session.subroutines = session.subroutines.filter((s) => s.name !== name);
|
|
266
|
+
return session.subroutines.length < initialLength;
|
|
267
|
+
}
|
|
263
268
|
function substituteVariables(session, text) {
|
|
264
269
|
return text.replace(/ /g, "\n").replace(/ /g, "\r").replace(/	/g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
265
270
|
}
|
|
@@ -351,6 +356,7 @@ export {
|
|
|
351
356
|
setSubroutineBoundary,
|
|
352
357
|
popSubroutinesToBoundary,
|
|
353
358
|
cleanSubroutinesToBoundary,
|
|
359
|
+
removeSubroutine,
|
|
354
360
|
substituteVariables,
|
|
355
361
|
emit,
|
|
356
362
|
getOutput,
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
execute
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EE3YBMAD.js";
|
|
5
5
|
import {
|
|
6
6
|
BraKetParser
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
8
|
+
import "./chunk-53QJQ2CC.js";
|
|
9
9
|
import "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-EAM7IZWA.js";
|
|
11
|
+
import "./chunk-ZYSWVMID.js";
|
|
12
12
|
|
|
13
13
|
// src/cli.ts
|
|
14
14
|
import "dotenv/config";
|
|
@@ -150,7 +150,7 @@ async function main() {
|
|
|
150
150
|
const args = process.argv.slice(2);
|
|
151
151
|
const calledAs = process.argv[1];
|
|
152
152
|
if (calledAs && calledAs.endsWith("/dish")) {
|
|
153
|
-
const { DiracShell } = await import("./shell-
|
|
153
|
+
const { DiracShell } = await import("./shell-PV6KIJL5.js");
|
|
154
154
|
const shellConfig = loadShellConfig(args);
|
|
155
155
|
const shell = new DiracShell(shellConfig);
|
|
156
156
|
await shell.start();
|
|
@@ -199,11 +199,11 @@ async function main() {
|
|
|
199
199
|
if (args[0] === "agent") {
|
|
200
200
|
const subcommand = args[1];
|
|
201
201
|
if (subcommand === "daemon") {
|
|
202
|
-
const { runAgentDaemon } = await import("./agent-
|
|
202
|
+
const { runAgentDaemon } = await import("./agent-3SJF56JW.js");
|
|
203
203
|
await runAgentDaemon();
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
const { AgentCLI } = await import("./agent-
|
|
206
|
+
const { AgentCLI } = await import("./agent-3SJF56JW.js");
|
|
207
207
|
const agent = new AgentCLI();
|
|
208
208
|
switch (subcommand) {
|
|
209
209
|
case "start":
|
|
@@ -230,8 +230,8 @@ async function main() {
|
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
if (args[0] === "shell") {
|
|
233
|
-
const { DiracShell } = await import("./shell-
|
|
234
|
-
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-
|
|
233
|
+
const { DiracShell } = await import("./shell-PV6KIJL5.js");
|
|
234
|
+
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-LMDDND5E.js");
|
|
235
235
|
const { SessionClient } = await import("./session-client-3VTC5MLO.js");
|
|
236
236
|
const daemonMode = args.includes("--daemon") || args.includes("-d");
|
|
237
237
|
const agentMode = args.includes("--agent") || args.includes("-a");
|
|
@@ -277,7 +277,7 @@ async function main() {
|
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
if (args[0] === "daemon") {
|
|
280
|
-
const { SessionServer } = await import("./session-server-
|
|
280
|
+
const { SessionServer } = await import("./session-server-LMDDND5E.js");
|
|
281
281
|
const server = new SessionServer();
|
|
282
282
|
await server.start();
|
|
283
283
|
console.log("Session daemon started");
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
listCronJobs,
|
|
4
4
|
stopAllCronJobs,
|
|
5
5
|
stopCronJob
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
8
8
|
import "./chunk-HRHAMPOB.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
executeCron,
|
|
13
13
|
listCronJobs,
|
package/dist/index.js
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
createLLMAdapter,
|
|
3
3
|
execute,
|
|
4
4
|
executeUserCommand
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EE3YBMAD.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
9
|
+
import "./chunk-53QJQ2CC.js";
|
|
10
10
|
import {
|
|
11
11
|
DiracParser
|
|
12
12
|
} from "./chunk-HRHAMPOB.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-EAM7IZWA.js";
|
|
14
14
|
import {
|
|
15
15
|
createSession,
|
|
16
16
|
getAvailableSubroutines,
|
|
17
17
|
getOutput
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ZYSWVMID.js";
|
|
19
19
|
export {
|
|
20
20
|
DiracParser,
|
|
21
21
|
createLLMAdapter,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
cancelScheduledRun,
|
|
4
4
|
executeRunAt,
|
|
5
5
|
listScheduledRuns
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
8
8
|
import "./chunk-HRHAMPOB.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
cancelAllScheduledRuns,
|
|
13
13
|
cancelScheduledRun,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
listScheduledTasks,
|
|
4
4
|
stopAllScheduledTasks,
|
|
5
5
|
stopScheduledTask
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
8
8
|
import "./chunk-HRHAMPOB.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
executeSchedule,
|
|
13
13
|
listScheduledTasks,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
popToBoundary,
|
|
19
19
|
pushParameters,
|
|
20
20
|
registerSubroutine,
|
|
21
|
+
removeSubroutine,
|
|
21
22
|
setBoundary,
|
|
22
23
|
setExceptionBoundary,
|
|
23
24
|
setSubroutineBoundary,
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
substituteVariables,
|
|
27
28
|
throwException,
|
|
28
29
|
unsetExceptionBoundary
|
|
29
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ZYSWVMID.js";
|
|
30
31
|
export {
|
|
31
32
|
cleanSubroutinesToBoundary,
|
|
32
33
|
cleanToBoundary,
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
popToBoundary,
|
|
48
49
|
pushParameters,
|
|
49
50
|
registerSubroutine,
|
|
51
|
+
removeSubroutine,
|
|
50
52
|
setBoundary,
|
|
51
53
|
setExceptionBoundary,
|
|
52
54
|
setSubroutineBoundary,
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
SessionServer,
|
|
3
3
|
getSocketPath,
|
|
4
4
|
isSessionRunning
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-R6R6OHPA.js";
|
|
6
|
+
import "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
8
8
|
import "./chunk-HRHAMPOB.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
SessionServer,
|
|
13
13
|
getSocketPath,
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BraKetParser,
|
|
4
4
|
integrate
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
6
|
+
import "./chunk-53QJQ2CC.js";
|
|
7
7
|
import {
|
|
8
8
|
DiracParser
|
|
9
9
|
} from "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-EAM7IZWA.js";
|
|
11
11
|
import {
|
|
12
12
|
createSession
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZYSWVMID.js";
|
|
14
14
|
|
|
15
15
|
// src/shell.ts
|
|
16
16
|
import * as readline from "readline";
|
|
@@ -358,7 +358,7 @@ var DiracShell = class {
|
|
|
358
358
|
if (this.client) {
|
|
359
359
|
this.client.disconnect();
|
|
360
360
|
}
|
|
361
|
-
import("./schedule-
|
|
361
|
+
import("./schedule-OYEKDXZV.js").then(({ stopAllScheduledTasks }) => {
|
|
362
362
|
stopAllScheduledTasks();
|
|
363
363
|
console.log("\nGoodbye!");
|
|
364
364
|
process.exit(0);
|
|
@@ -541,6 +541,8 @@ Commands:
|
|
|
541
541
|
:search <query> Search indexed subroutines
|
|
542
542
|
:load <query> Load context (search and import subroutines)
|
|
543
543
|
:save <name> [file] Save subroutine (default: ~/.dirac/lib/TIMESTAMP/name.di)
|
|
544
|
+
:edit <name> Edit subroutine in external editor
|
|
545
|
+
:remove <name> Remove subroutine from session stack (not from disk)
|
|
544
546
|
:stats Show registry statistics
|
|
545
547
|
:tasks List all scheduled tasks
|
|
546
548
|
:stop <name> Stop a scheduled task
|
|
@@ -552,6 +554,7 @@ Commands:
|
|
|
552
554
|
:cancel <name> Cancel a scheduled run
|
|
553
555
|
:cancelall Cancel all scheduled runs
|
|
554
556
|
:save-training [mode=full|pruned|both] Save LLM dialog as training data (opens in editor)
|
|
557
|
+
:save-subroutine-training <name> Save subroutine as training data with description
|
|
555
558
|
:exit Exit shell
|
|
556
559
|
|
|
557
560
|
Syntax:
|
|
@@ -758,6 +761,49 @@ Examples:
|
|
|
758
761
|
}
|
|
759
762
|
}
|
|
760
763
|
break;
|
|
764
|
+
case "edit":
|
|
765
|
+
if (args.length === 0) {
|
|
766
|
+
console.log("Usage: :edit <subroutine-name>");
|
|
767
|
+
console.log(" Opens the subroutine in your default editor ($EDITOR or vi)");
|
|
768
|
+
console.log("Examples:");
|
|
769
|
+
console.log(" :edit greet # edit greet subroutine in default editor");
|
|
770
|
+
console.log(" Use :save after editing to persist changes to disk");
|
|
771
|
+
} else {
|
|
772
|
+
const subName = args[0];
|
|
773
|
+
try {
|
|
774
|
+
const xml = `<edit-subroutine name="${subName}" />`;
|
|
775
|
+
const ast = this.xmlParser.parse(xml);
|
|
776
|
+
await integrate(this.session, ast);
|
|
777
|
+
if (this.session.output.length > 0) {
|
|
778
|
+
console.log(this.session.output.join(""));
|
|
779
|
+
}
|
|
780
|
+
} catch (error) {
|
|
781
|
+
console.error("Error editing subroutine:", error instanceof Error ? error.message : String(error));
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
break;
|
|
785
|
+
case "remove":
|
|
786
|
+
if (args.length === 0) {
|
|
787
|
+
console.log("Usage: :remove <subroutine-name>");
|
|
788
|
+
console.log(" Removes all instances of the subroutine from the session stack");
|
|
789
|
+
console.log(" Note: This does NOT delete the subroutine from disk");
|
|
790
|
+
console.log("Examples:");
|
|
791
|
+
console.log(" :remove greet # remove greet subroutine from session");
|
|
792
|
+
} else {
|
|
793
|
+
const subName = args[0];
|
|
794
|
+
try {
|
|
795
|
+
const { removeSubroutine } = await import("./session-6WX5O74B.js");
|
|
796
|
+
const removed = removeSubroutine(this.session, subName);
|
|
797
|
+
if (removed) {
|
|
798
|
+
console.log(`Removed subroutine '${subName}' from session stack`);
|
|
799
|
+
} else {
|
|
800
|
+
console.log(`Subroutine '${subName}' not found in session`);
|
|
801
|
+
}
|
|
802
|
+
} catch (error) {
|
|
803
|
+
console.error("Error removing subroutine:", error instanceof Error ? error.message : String(error));
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
break;
|
|
761
807
|
case "stats":
|
|
762
808
|
try {
|
|
763
809
|
const xml = "<registry-stats />";
|
|
@@ -772,7 +818,7 @@ Examples:
|
|
|
772
818
|
break;
|
|
773
819
|
case "tasks":
|
|
774
820
|
try {
|
|
775
|
-
const { listScheduledTasks } = await import("./schedule-
|
|
821
|
+
const { listScheduledTasks } = await import("./schedule-OYEKDXZV.js");
|
|
776
822
|
const tasks = listScheduledTasks();
|
|
777
823
|
if (tasks.length === 0) {
|
|
778
824
|
console.log("No scheduled tasks running.");
|
|
@@ -791,7 +837,7 @@ Examples:
|
|
|
791
837
|
console.log("Usage: :stop <task-name>");
|
|
792
838
|
} else {
|
|
793
839
|
try {
|
|
794
|
-
const { stopScheduledTask } = await import("./schedule-
|
|
840
|
+
const { stopScheduledTask } = await import("./schedule-OYEKDXZV.js");
|
|
795
841
|
const taskName = args[0];
|
|
796
842
|
const stopped = stopScheduledTask(taskName);
|
|
797
843
|
if (stopped) {
|
|
@@ -806,7 +852,7 @@ Examples:
|
|
|
806
852
|
break;
|
|
807
853
|
case "stopall":
|
|
808
854
|
try {
|
|
809
|
-
const { stopAllScheduledTasks } = await import("./schedule-
|
|
855
|
+
const { stopAllScheduledTasks } = await import("./schedule-OYEKDXZV.js");
|
|
810
856
|
stopAllScheduledTasks();
|
|
811
857
|
console.log("All scheduled tasks stopped.");
|
|
812
858
|
} catch (error) {
|
|
@@ -815,7 +861,7 @@ Examples:
|
|
|
815
861
|
break;
|
|
816
862
|
case "crons":
|
|
817
863
|
try {
|
|
818
|
-
const { listCronJobs } = await import("./cron-
|
|
864
|
+
const { listCronJobs } = await import("./cron-TTPFON3Y.js");
|
|
819
865
|
const jobs = listCronJobs();
|
|
820
866
|
if (jobs.length === 0) {
|
|
821
867
|
console.log("No cron jobs running.");
|
|
@@ -835,7 +881,7 @@ Examples:
|
|
|
835
881
|
console.log("Usage: :stopcron <job-name>");
|
|
836
882
|
} else {
|
|
837
883
|
try {
|
|
838
|
-
const { stopCronJob } = await import("./cron-
|
|
884
|
+
const { stopCronJob } = await import("./cron-TTPFON3Y.js");
|
|
839
885
|
const jobName = args[0];
|
|
840
886
|
const stopped = stopCronJob(jobName);
|
|
841
887
|
if (stopped) {
|
|
@@ -850,7 +896,7 @@ Examples:
|
|
|
850
896
|
break;
|
|
851
897
|
case "stopallcrons":
|
|
852
898
|
try {
|
|
853
|
-
const { stopAllCronJobs } = await import("./cron-
|
|
899
|
+
const { stopAllCronJobs } = await import("./cron-TTPFON3Y.js");
|
|
854
900
|
stopAllCronJobs();
|
|
855
901
|
console.log("All cron jobs stopped.");
|
|
856
902
|
} catch (error) {
|
|
@@ -859,7 +905,7 @@ Examples:
|
|
|
859
905
|
break;
|
|
860
906
|
case "scheduled":
|
|
861
907
|
try {
|
|
862
|
-
const { listScheduledRuns } = await import("./run-at-
|
|
908
|
+
const { listScheduledRuns } = await import("./run-at-A3CJX4TR.js");
|
|
863
909
|
const runs = listScheduledRuns();
|
|
864
910
|
if (runs.length === 0) {
|
|
865
911
|
console.log("No scheduled runs pending.");
|
|
@@ -879,7 +925,7 @@ Examples:
|
|
|
879
925
|
console.log("Usage: :cancel <run-name>");
|
|
880
926
|
} else {
|
|
881
927
|
try {
|
|
882
|
-
const { cancelScheduledRun } = await import("./run-at-
|
|
928
|
+
const { cancelScheduledRun } = await import("./run-at-A3CJX4TR.js");
|
|
883
929
|
const runName = args[0];
|
|
884
930
|
const cancelled = cancelScheduledRun(runName);
|
|
885
931
|
if (cancelled) {
|
|
@@ -894,13 +940,99 @@ Examples:
|
|
|
894
940
|
break;
|
|
895
941
|
case "cancelall":
|
|
896
942
|
try {
|
|
897
|
-
const { cancelAllScheduledRuns } = await import("./run-at-
|
|
943
|
+
const { cancelAllScheduledRuns } = await import("./run-at-A3CJX4TR.js");
|
|
898
944
|
cancelAllScheduledRuns();
|
|
899
945
|
console.log("All scheduled runs cancelled.");
|
|
900
946
|
} catch (error) {
|
|
901
947
|
console.error("Error cancelling runs:", error instanceof Error ? error.message : String(error));
|
|
902
948
|
}
|
|
903
949
|
break;
|
|
950
|
+
case "save-subroutine-training":
|
|
951
|
+
if (args.length === 0) {
|
|
952
|
+
console.log("Usage: :save-subroutine-training <subroutine-name>");
|
|
953
|
+
console.log(" Saves a subroutine as training data (opens in editor)");
|
|
954
|
+
console.log(" You will be prompted to provide a description for the training example");
|
|
955
|
+
console.log("Examples:");
|
|
956
|
+
console.log(" :save-subroutine-training greet");
|
|
957
|
+
} else {
|
|
958
|
+
const subName = args[0];
|
|
959
|
+
try {
|
|
960
|
+
let subroutine = void 0;
|
|
961
|
+
const subroutines = this.client ? (await this.client.getState()).subroutines || [] : this.session.subroutines;
|
|
962
|
+
for (let i = subroutines.length - 1; i >= 0; i--) {
|
|
963
|
+
if (subroutines[i].name === subName) {
|
|
964
|
+
subroutine = subroutines[i];
|
|
965
|
+
break;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
if (!subroutine) {
|
|
969
|
+
console.log(`Subroutine '${subName}' not found in session`);
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
const description = await new Promise((resolve2) => {
|
|
973
|
+
this.rl.question(`Enter description (user's request that would generate this subroutine): `, resolve2);
|
|
974
|
+
});
|
|
975
|
+
if (!description.trim()) {
|
|
976
|
+
console.log("Cancelled (no description provided)");
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
const { serializeSubroutineForTraining } = await import("./subroutine-serializer-LNFHABUC.js");
|
|
980
|
+
const subroutineContent = serializeSubroutineForTraining(subroutine);
|
|
981
|
+
const trainingExample = {
|
|
982
|
+
messages: [
|
|
983
|
+
{ role: "user", content: description.trim() },
|
|
984
|
+
{ role: "assistant", content: subroutineContent }
|
|
985
|
+
]
|
|
986
|
+
};
|
|
987
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0] + "-" + Date.now();
|
|
988
|
+
const tempFile = path.join(os.tmpdir(), `dirac-subroutine-training-${timestamp}.jsonl`);
|
|
989
|
+
const tempContent = JSON.stringify(trainingExample, null, 2);
|
|
990
|
+
fs.writeFileSync(tempFile, tempContent, "utf-8");
|
|
991
|
+
console.log("Opening in editor...");
|
|
992
|
+
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
993
|
+
const { spawnSync } = await import("child_process");
|
|
994
|
+
const result = spawnSync(editor, [tempFile], {
|
|
995
|
+
stdio: "inherit",
|
|
996
|
+
shell: true
|
|
997
|
+
});
|
|
998
|
+
if (result.error) {
|
|
999
|
+
fs.unlinkSync(tempFile);
|
|
1000
|
+
console.error(`Failed to open editor: ${result.error.message}`);
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
if (result.status !== 0) {
|
|
1004
|
+
fs.unlinkSync(tempFile);
|
|
1005
|
+
console.error(`Editor exited with code ${result.status}`);
|
|
1006
|
+
break;
|
|
1007
|
+
}
|
|
1008
|
+
const answer = await new Promise((resolve2) => {
|
|
1009
|
+
this.rl.question("Save to file (or press Enter to cancel): ", resolve2);
|
|
1010
|
+
});
|
|
1011
|
+
if (!answer.trim()) {
|
|
1012
|
+
fs.unlinkSync(tempFile);
|
|
1013
|
+
console.log("Cancelled");
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
let savePath;
|
|
1017
|
+
if (answer.startsWith("/") || answer.startsWith("~")) {
|
|
1018
|
+
savePath = answer.replace(/^~/, os.homedir());
|
|
1019
|
+
} else if (answer.includes("/")) {
|
|
1020
|
+
savePath = path.resolve(answer);
|
|
1021
|
+
} else {
|
|
1022
|
+
const trainingDir = path.join(os.homedir(), ".dirac", "training");
|
|
1023
|
+
fs.mkdirSync(trainingDir, { recursive: true });
|
|
1024
|
+
savePath = path.join(trainingDir, answer.endsWith(".jsonl") ? answer : `${answer}.jsonl`);
|
|
1025
|
+
}
|
|
1026
|
+
const editedContent = fs.readFileSync(tempFile, "utf-8");
|
|
1027
|
+
const editedData = JSON.parse(editedContent);
|
|
1028
|
+
fs.appendFileSync(savePath, JSON.stringify(editedData) + "\n");
|
|
1029
|
+
console.log(`\u2713 Saved training example for '${subName}' to ${savePath}`);
|
|
1030
|
+
fs.unlinkSync(tempFile);
|
|
1031
|
+
} catch (error) {
|
|
1032
|
+
console.error("Error saving subroutine training data:", error instanceof Error ? error.message : String(error));
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
break;
|
|
904
1036
|
case "save-training":
|
|
905
1037
|
try {
|
|
906
1038
|
const fullCommand = cmd.slice(1);
|
|
@@ -1162,7 +1294,7 @@ ${JSON.stringify(prunedExample, null, 2)}`;
|
|
|
1162
1294
|
console.log("Set ANTHROPIC_API_KEY or OPENAI_API_KEY environment variable,");
|
|
1163
1295
|
console.log("or create ~/.dirac/config.yml with llmProvider and llmModel.\n");
|
|
1164
1296
|
}
|
|
1165
|
-
const { registry } = await import("./subroutine-index-
|
|
1297
|
+
const { registry } = await import("./subroutine-index-GB3OSH56.js");
|
|
1166
1298
|
const wasIndexed = await registry.autoIndexStdlib();
|
|
1167
1299
|
await this.loadEssentialSubroutines();
|
|
1168
1300
|
if (this.config.initScript) {
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
executeRegistryStats,
|
|
4
4
|
executeSearchSubroutines,
|
|
5
5
|
registry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-53QJQ2CC.js";
|
|
7
7
|
import "./chunk-HRHAMPOB.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-ZYSWVMID.js";
|
|
9
9
|
export {
|
|
10
10
|
executeIndexSubroutines,
|
|
11
11
|
executeRegistryStats,
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// src/utils/subroutine-serializer.ts
|
|
2
|
+
function serializeSubroutineForTraining(sub) {
|
|
3
|
+
const lines = [];
|
|
4
|
+
serializeElement(sub.element, lines, "");
|
|
5
|
+
return lines.join("\n");
|
|
6
|
+
}
|
|
7
|
+
function serializeSubroutineToXML(sub) {
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push("<!-- Editing subroutine: " + sub.name + " -->");
|
|
10
|
+
lines.push("");
|
|
11
|
+
serializeElement(sub.element, lines, "");
|
|
12
|
+
return lines.join("\n");
|
|
13
|
+
}
|
|
14
|
+
function serializeElement(el, lines, indent) {
|
|
15
|
+
if (!el.tag || el.tag === "") {
|
|
16
|
+
if (el.text) {
|
|
17
|
+
let lastIdx = lines.length - 1;
|
|
18
|
+
if (lastIdx >= 0 && !lines[lastIdx].endsWith(">")) {
|
|
19
|
+
lines[lastIdx] += el.text;
|
|
20
|
+
} else {
|
|
21
|
+
lines.push(indent + el.text);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let tag = `${indent}<${el.tag}`;
|
|
27
|
+
if (el.attributes) {
|
|
28
|
+
for (const [key, value] of Object.entries(el.attributes)) {
|
|
29
|
+
if (typeof value === "string") {
|
|
30
|
+
tag += ` ${key}="${value.replace(/"/g, """)}"`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const hasChildren = el.children && el.children.length > 0;
|
|
35
|
+
if (!hasChildren) {
|
|
36
|
+
let lastIdx = lines.length - 1;
|
|
37
|
+
if (lastIdx >= 0 && !lines[lastIdx].endsWith(">") && !lines[lastIdx].trim().startsWith("<")) {
|
|
38
|
+
lines[lastIdx] += tag.slice(indent.length) + " />";
|
|
39
|
+
} else {
|
|
40
|
+
lines.push(tag + " />");
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
let lastIdx = lines.length - 1;
|
|
44
|
+
const shouldInline = lastIdx >= 0 && !lines[lastIdx].endsWith(">");
|
|
45
|
+
if (shouldInline) {
|
|
46
|
+
lines[lastIdx] += tag.slice(indent.length) + ">";
|
|
47
|
+
} else {
|
|
48
|
+
lines.push(tag + ">");
|
|
49
|
+
}
|
|
50
|
+
let allInline = true;
|
|
51
|
+
for (let i = 0; i < el.children.length; i++) {
|
|
52
|
+
const child = el.children[i];
|
|
53
|
+
if (!child.tag || child.tag === "") {
|
|
54
|
+
if (child.text) {
|
|
55
|
+
lastIdx = lines.length - 1;
|
|
56
|
+
lines[lastIdx] += child.text;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
const isComplex = child.children && child.children.length > 0;
|
|
60
|
+
if (isComplex) {
|
|
61
|
+
allInline = false;
|
|
62
|
+
serializeElement(child, lines, indent + " ");
|
|
63
|
+
} else {
|
|
64
|
+
let childTag = `<${child.tag}`;
|
|
65
|
+
if (child.attributes) {
|
|
66
|
+
for (const [key, value] of Object.entries(child.attributes)) {
|
|
67
|
+
if (typeof value === "string") {
|
|
68
|
+
childTag += ` ${key}="${value.replace(/"/g, """)}"`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
childTag += " />";
|
|
73
|
+
lastIdx = lines.length - 1;
|
|
74
|
+
lines[lastIdx] += childTag;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
lastIdx = lines.length - 1;
|
|
79
|
+
if (allInline && lines[lastIdx].indexOf("<") > 0) {
|
|
80
|
+
lines[lastIdx] += `</${el.tag}>`;
|
|
81
|
+
} else {
|
|
82
|
+
lines.push(`${indent}</${el.tag}>`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function serializeSubroutineToBraKet(sub) {
|
|
87
|
+
const lines = [];
|
|
88
|
+
lines.push("<!-- Editing subroutine: " + sub.name + " -->");
|
|
89
|
+
lines.push("");
|
|
90
|
+
serializeElementToBraKet(sub.element, lines, 0);
|
|
91
|
+
return lines.join("\n");
|
|
92
|
+
}
|
|
93
|
+
function serializeElementToBraKet(el, lines, indent) {
|
|
94
|
+
const indentStr = " ".repeat(indent);
|
|
95
|
+
if (!el.tag || el.tag === "") {
|
|
96
|
+
if (el.text) {
|
|
97
|
+
lines.push(indentStr + el.text);
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (el.tag === "subroutine") {
|
|
102
|
+
const name = el.attributes?.name || "unnamed";
|
|
103
|
+
let braLine = `${indentStr}<${name}|`;
|
|
104
|
+
if (el.attributes) {
|
|
105
|
+
for (const [key, value] of Object.entries(el.attributes)) {
|
|
106
|
+
if (key === "name") continue;
|
|
107
|
+
const needsQuotes = typeof value === "string" && (value.includes(" ") || value.includes("="));
|
|
108
|
+
braLine += ` ${key}=${needsQuotes ? '"' + value + '"' : value}`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
lines.push(braLine);
|
|
112
|
+
if (el.children && el.children.length > 0) {
|
|
113
|
+
for (const child of el.children) {
|
|
114
|
+
serializeElementToBraKet(child, lines, indent + 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let ketLine = `${indentStr}|${el.tag}`;
|
|
120
|
+
if (el.attributes) {
|
|
121
|
+
for (const [key, value] of Object.entries(el.attributes)) {
|
|
122
|
+
if (typeof value === "string") {
|
|
123
|
+
const needsQuotes = value.includes(" ") || value.includes("=");
|
|
124
|
+
ketLine += ` ${key}=${needsQuotes ? '"' + value + '"' : value}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
ketLine += ">";
|
|
129
|
+
if (el.children && el.children.length > 0) {
|
|
130
|
+
const hasComplexChildren = el.children.some(
|
|
131
|
+
(c) => c.tag && c.tag !== "variable" && (c.children?.length > 0 || c.tag === "subroutine")
|
|
132
|
+
);
|
|
133
|
+
if (!hasComplexChildren) {
|
|
134
|
+
let inlineContent = "";
|
|
135
|
+
for (const child of el.children) {
|
|
136
|
+
if (!child.tag || child.tag === "") {
|
|
137
|
+
inlineContent += child.text || "";
|
|
138
|
+
} else if (child.tag === "variable") {
|
|
139
|
+
const varName = child.attributes?.name || "";
|
|
140
|
+
inlineContent += `|variable name=${varName}>`;
|
|
141
|
+
} else {
|
|
142
|
+
inlineContent += `|${child.tag}>`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
lines.push(ketLine + inlineContent);
|
|
146
|
+
} else {
|
|
147
|
+
lines.push(ketLine);
|
|
148
|
+
for (const child of el.children) {
|
|
149
|
+
serializeElementToBraKet(child, lines, indent + 1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
lines.push(ketLine);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
serializeSubroutineForTraining,
|
|
158
|
+
serializeSubroutineToBraKet,
|
|
159
|
+
serializeSubroutineToXML
|
|
160
|
+
};
|
|
@@ -109,7 +109,7 @@ async function validateNestedTags(session, element, options = {}) {
|
|
|
109
109
|
async function validateTag(session, element, options = {}) {
|
|
110
110
|
const { autocorrect = false, similarityCutoff = SIMILARITY_CUTOFF, deepValidation = false } = options;
|
|
111
111
|
console.error(`[VALIDATE] Tag: <${element.tag}>, autocorrect: ${autocorrect}, attributes:`, Object.keys(element.attributes));
|
|
112
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
112
|
+
const { getAvailableSubroutines } = await import("./session-6WX5O74B.js");
|
|
113
113
|
const subroutines = getAvailableSubroutines(session);
|
|
114
114
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
115
115
|
const tagName = element.tag;
|
package/dist/test-runner.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
4
|
+
import "./chunk-53QJQ2CC.js";
|
|
5
5
|
import {
|
|
6
6
|
DiracParser
|
|
7
7
|
} from "./chunk-HRHAMPOB.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-EAM7IZWA.js";
|
|
9
9
|
import {
|
|
10
10
|
createSession,
|
|
11
11
|
getOutput
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZYSWVMID.js";
|
|
13
13
|
|
|
14
14
|
// src/test-runner.ts
|
|
15
15
|
import fs from "fs";
|
package/lib/native-tags.di
CHANGED
|
@@ -219,7 +219,8 @@
|
|
|
219
219
|
meta-hide-from-llm="true"
|
|
220
220
|
description="Edit subroutine definition in external editor"
|
|
221
221
|
param-name="string:required:Subroutine name to edit"
|
|
222
|
-
param-editor="string:optional:Editor command (default: $EDITOR or vi)"
|
|
222
|
+
param-editor="string:optional:Editor command (default: $EDITOR or vi)"
|
|
223
|
+
param-format="string:optional:format (braket or xml, default:braket)">
|
|
223
224
|
<!-- Opens subroutine in temp file with editor (blocking) -->
|
|
224
225
|
<!-- After save/exit, automatically re-imports into session -->
|
|
225
226
|
<!-- Changes take effect immediately but are NOT saved to disk -->
|
package/package.json
CHANGED