dirac-lang 0.1.90 → 0.1.92
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-OP5VWQN3.js → agent-ZYONE5JH.js} +2 -2
- package/dist/{chunk-B7KLVI42.js → chunk-HKCQJKQC.js} +1 -1
- package/dist/{chunk-R42DSFUB.js → chunk-OHHVPQEJ.js} +1 -1
- package/dist/{chunk-PKLOBITC.js → chunk-ZRYXVVUV.js} +16 -16
- package/dist/cli.js +9 -9
- package/dist/{cron-QRAJN2S2.js → cron-TEN2VZLP.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{interpreter-4XJNFNMA.js → interpreter-WRW3KH2U.js} +1 -1
- package/dist/{run-at-THEZWPTK.js → run-at-EVMKFRM2.js} +1 -1
- package/dist/{schedule-FMQJKZ4Z.js → schedule-6EIX67FE.js} +1 -1
- package/dist/{session-server-6Z2THFHB.js → session-server-Y2RLLKSF.js} +2 -2
- package/dist/{shell-KREANC2A.js → shell-MGGRRK5F.js} +72 -11
- package/dist/test-runner.js +1 -1
- package/package.json +1 -1
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
SessionServer,
|
|
3
3
|
getSocketPath,
|
|
4
4
|
isSessionRunning
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-HKCQJKQC.js";
|
|
6
|
+
import "./chunk-ZRYXVVUV.js";
|
|
7
7
|
import "./chunk-ECAW4X46.js";
|
|
8
8
|
import "./chunk-SLGJRZ3P.js";
|
|
9
9
|
import "./chunk-HRHAMPOB.js";
|
|
@@ -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-WRW3KH2U.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-WRW3KH2U.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-WRW3KH2U.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-WRW3KH2U.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-WRW3KH2U.js");
|
|
536
536
|
await integrateChildren2(session, child);
|
|
537
537
|
const newChunks = session.output.slice(argOutputStart);
|
|
538
538
|
const argValue = newChunks.join("");
|
|
@@ -1175,7 +1175,7 @@ ${executionOutput}
|
|
|
1175
1175
|
${executionOutput}
|
|
1176
1176
|
\`\`\`
|
|
1177
1177
|
|
|
1178
|
-
Please review the output carefully. If the output is correct and complete, respond with ONLY the
|
|
1178
|
+
Please review the output carefully. If the output is correct and complete, respond with ONLY the tag "<DONE />" and nothing else. If the output is incorrect or incomplete, generate corrected Dirac XML code.`;
|
|
1179
1179
|
if (session.debug) {
|
|
1180
1180
|
console.error(`[LLM] Feedback prompt:
|
|
1181
1181
|
${feedbackPrompt}
|
|
@@ -1219,10 +1219,10 @@ ${feedbackPrompt}
|
|
|
1219
1219
|
${result}
|
|
1220
1220
|
`);
|
|
1221
1221
|
}
|
|
1222
|
-
const
|
|
1223
|
-
if (
|
|
1222
|
+
const trimmedResult = result.trim();
|
|
1223
|
+
if (trimmedResult.includes("<DONE />") || trimmedResult.includes("<DONE/>")) {
|
|
1224
1224
|
if (session.debug) {
|
|
1225
|
-
console.error(`[LLM] Feedback loop terminating - LLM indicated completion
|
|
1225
|
+
console.error(`[LLM] Feedback loop terminating - LLM indicated completion with <DONE />
|
|
1226
1226
|
`);
|
|
1227
1227
|
}
|
|
1228
1228
|
break;
|
|
@@ -1788,7 +1788,7 @@ async function executeTagCheck(session, element) {
|
|
|
1788
1788
|
const executeTag = correctedTag || tagName;
|
|
1789
1789
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1790
1790
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1791
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1791
|
+
const { integrate: integrate2 } = await import("./interpreter-WRW3KH2U.js");
|
|
1792
1792
|
await integrate2(session, elementToExecute);
|
|
1793
1793
|
}
|
|
1794
1794
|
}
|
|
@@ -1797,7 +1797,7 @@ async function executeTagCheck(session, element) {
|
|
|
1797
1797
|
// src/tags/throw.ts
|
|
1798
1798
|
async function executeThrow(session, element) {
|
|
1799
1799
|
const exceptionName = element.attributes?.name || "exception";
|
|
1800
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1800
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-WRW3KH2U.js");
|
|
1801
1801
|
const exceptionDom = {
|
|
1802
1802
|
tag: "exception-content",
|
|
1803
1803
|
attributes: { name: exceptionName },
|
|
@@ -1810,7 +1810,7 @@ async function executeThrow(session, element) {
|
|
|
1810
1810
|
// src/tags/try.ts
|
|
1811
1811
|
async function executeTry(session, element) {
|
|
1812
1812
|
setExceptionBoundary(session);
|
|
1813
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1813
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-WRW3KH2U.js");
|
|
1814
1814
|
await integrateChildren2(session, element);
|
|
1815
1815
|
unsetExceptionBoundary(session);
|
|
1816
1816
|
}
|
|
@@ -1820,7 +1820,7 @@ async function executeCatch(session, element) {
|
|
|
1820
1820
|
const exceptionName = element.attributes?.name || "exception";
|
|
1821
1821
|
const caughtCount = lookupException(session, exceptionName);
|
|
1822
1822
|
if (caughtCount > 0) {
|
|
1823
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1823
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-WRW3KH2U.js");
|
|
1824
1824
|
await integrateChildren2(session, element);
|
|
1825
1825
|
}
|
|
1826
1826
|
flushCurrentException(session);
|
|
@@ -1829,7 +1829,7 @@ async function executeCatch(session, element) {
|
|
|
1829
1829
|
// src/tags/exception.ts
|
|
1830
1830
|
async function executeException(session, element) {
|
|
1831
1831
|
const exceptions = getCurrentExceptions(session);
|
|
1832
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1832
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-WRW3KH2U.js");
|
|
1833
1833
|
for (const exceptionDom of exceptions) {
|
|
1834
1834
|
await integrateChildren2(session, exceptionDom);
|
|
1835
1835
|
}
|
|
@@ -2030,7 +2030,7 @@ async function executeLoadContext(session, element) {
|
|
|
2030
2030
|
query = element.text.trim();
|
|
2031
2031
|
}
|
|
2032
2032
|
if (!query && element.children.length > 0) {
|
|
2033
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2033
|
+
const { integrate: integrate2 } = await import("./interpreter-WRW3KH2U.js");
|
|
2034
2034
|
const beforeOutput = session.output.length;
|
|
2035
2035
|
for (const child of element.children) {
|
|
2036
2036
|
await integrate2(session, child);
|
|
@@ -2874,7 +2874,7 @@ async function executeForeach(session, element) {
|
|
|
2874
2874
|
const parser2 = new DiracParser2();
|
|
2875
2875
|
try {
|
|
2876
2876
|
const fromElement = parser2.parse(fromAttr);
|
|
2877
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2877
|
+
const { integrate: integrate2 } = await import("./interpreter-WRW3KH2U.js");
|
|
2878
2878
|
await integrate2(session, fromElement);
|
|
2879
2879
|
} catch (e) {
|
|
2880
2880
|
session.output = savedOutput;
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
execute
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OHHVPQEJ.js";
|
|
5
5
|
import {
|
|
6
6
|
BraKetParser
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZRYXVVUV.js";
|
|
8
8
|
import "./chunk-ECAW4X46.js";
|
|
9
9
|
import "./chunk-SLGJRZ3P.js";
|
|
10
10
|
import "./chunk-HRHAMPOB.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.92",
|
|
20
20
|
description: "LLM-Augmented Declarative Execution",
|
|
21
21
|
type: "module",
|
|
22
22
|
main: "dist/index.js",
|
|
@@ -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-MGGRRK5F.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-ZYONE5JH.js");
|
|
203
203
|
await runAgentDaemon();
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
const { AgentCLI } = await import("./agent-
|
|
206
|
+
const { AgentCLI } = await import("./agent-ZYONE5JH.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-MGGRRK5F.js");
|
|
234
|
+
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-Y2RLLKSF.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-Y2RLLKSF.js");
|
|
281
281
|
const server = new SessionServer();
|
|
282
282
|
await server.start();
|
|
283
283
|
console.log("Session daemon started");
|
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-OHHVPQEJ.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZRYXVVUV.js";
|
|
9
9
|
import "./chunk-ECAW4X46.js";
|
|
10
10
|
import "./chunk-SLGJRZ3P.js";
|
|
11
11
|
import {
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
SessionServer,
|
|
3
3
|
getSocketPath,
|
|
4
4
|
isSessionRunning
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-HKCQJKQC.js";
|
|
6
|
+
import "./chunk-ZRYXVVUV.js";
|
|
7
7
|
import "./chunk-ECAW4X46.js";
|
|
8
8
|
import "./chunk-SLGJRZ3P.js";
|
|
9
9
|
import "./chunk-HRHAMPOB.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BraKetParser,
|
|
4
4
|
integrate
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZRYXVVUV.js";
|
|
6
6
|
import "./chunk-ECAW4X46.js";
|
|
7
7
|
import "./chunk-SLGJRZ3P.js";
|
|
8
8
|
import {
|
|
@@ -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-6EIX67FE.js").then(({ stopAllScheduledTasks }) => {
|
|
362
362
|
stopAllScheduledTasks();
|
|
363
363
|
console.log("\nGoodbye!");
|
|
364
364
|
process.exit(0);
|
|
@@ -542,6 +542,7 @@ Commands:
|
|
|
542
542
|
:scheduled List all scheduled runs (run-at)
|
|
543
543
|
:cancel <name> Cancel a scheduled run
|
|
544
544
|
:cancelall Cancel all scheduled runs
|
|
545
|
+
:save-training Save LLM dialog as training data (opens in editor)
|
|
545
546
|
:exit Exit shell
|
|
546
547
|
|
|
547
548
|
Syntax:
|
|
@@ -762,7 +763,7 @@ Examples:
|
|
|
762
763
|
break;
|
|
763
764
|
case "tasks":
|
|
764
765
|
try {
|
|
765
|
-
const { listScheduledTasks } = await import("./schedule-
|
|
766
|
+
const { listScheduledTasks } = await import("./schedule-6EIX67FE.js");
|
|
766
767
|
const tasks = listScheduledTasks();
|
|
767
768
|
if (tasks.length === 0) {
|
|
768
769
|
console.log("No scheduled tasks running.");
|
|
@@ -781,7 +782,7 @@ Examples:
|
|
|
781
782
|
console.log("Usage: :stop <task-name>");
|
|
782
783
|
} else {
|
|
783
784
|
try {
|
|
784
|
-
const { stopScheduledTask } = await import("./schedule-
|
|
785
|
+
const { stopScheduledTask } = await import("./schedule-6EIX67FE.js");
|
|
785
786
|
const taskName = args[0];
|
|
786
787
|
const stopped = stopScheduledTask(taskName);
|
|
787
788
|
if (stopped) {
|
|
@@ -796,7 +797,7 @@ Examples:
|
|
|
796
797
|
break;
|
|
797
798
|
case "stopall":
|
|
798
799
|
try {
|
|
799
|
-
const { stopAllScheduledTasks } = await import("./schedule-
|
|
800
|
+
const { stopAllScheduledTasks } = await import("./schedule-6EIX67FE.js");
|
|
800
801
|
stopAllScheduledTasks();
|
|
801
802
|
console.log("All scheduled tasks stopped.");
|
|
802
803
|
} catch (error) {
|
|
@@ -805,7 +806,7 @@ Examples:
|
|
|
805
806
|
break;
|
|
806
807
|
case "crons":
|
|
807
808
|
try {
|
|
808
|
-
const { listCronJobs } = await import("./cron-
|
|
809
|
+
const { listCronJobs } = await import("./cron-TEN2VZLP.js");
|
|
809
810
|
const jobs = listCronJobs();
|
|
810
811
|
if (jobs.length === 0) {
|
|
811
812
|
console.log("No cron jobs running.");
|
|
@@ -825,7 +826,7 @@ Examples:
|
|
|
825
826
|
console.log("Usage: :stopcron <job-name>");
|
|
826
827
|
} else {
|
|
827
828
|
try {
|
|
828
|
-
const { stopCronJob } = await import("./cron-
|
|
829
|
+
const { stopCronJob } = await import("./cron-TEN2VZLP.js");
|
|
829
830
|
const jobName = args[0];
|
|
830
831
|
const stopped = stopCronJob(jobName);
|
|
831
832
|
if (stopped) {
|
|
@@ -840,7 +841,7 @@ Examples:
|
|
|
840
841
|
break;
|
|
841
842
|
case "stopallcrons":
|
|
842
843
|
try {
|
|
843
|
-
const { stopAllCronJobs } = await import("./cron-
|
|
844
|
+
const { stopAllCronJobs } = await import("./cron-TEN2VZLP.js");
|
|
844
845
|
stopAllCronJobs();
|
|
845
846
|
console.log("All cron jobs stopped.");
|
|
846
847
|
} catch (error) {
|
|
@@ -849,7 +850,7 @@ Examples:
|
|
|
849
850
|
break;
|
|
850
851
|
case "scheduled":
|
|
851
852
|
try {
|
|
852
|
-
const { listScheduledRuns } = await import("./run-at-
|
|
853
|
+
const { listScheduledRuns } = await import("./run-at-EVMKFRM2.js");
|
|
853
854
|
const runs = listScheduledRuns();
|
|
854
855
|
if (runs.length === 0) {
|
|
855
856
|
console.log("No scheduled runs pending.");
|
|
@@ -869,7 +870,7 @@ Examples:
|
|
|
869
870
|
console.log("Usage: :cancel <run-name>");
|
|
870
871
|
} else {
|
|
871
872
|
try {
|
|
872
|
-
const { cancelScheduledRun } = await import("./run-at-
|
|
873
|
+
const { cancelScheduledRun } = await import("./run-at-EVMKFRM2.js");
|
|
873
874
|
const runName = args[0];
|
|
874
875
|
const cancelled = cancelScheduledRun(runName);
|
|
875
876
|
if (cancelled) {
|
|
@@ -884,13 +885,73 @@ Examples:
|
|
|
884
885
|
break;
|
|
885
886
|
case "cancelall":
|
|
886
887
|
try {
|
|
887
|
-
const { cancelAllScheduledRuns } = await import("./run-at-
|
|
888
|
+
const { cancelAllScheduledRuns } = await import("./run-at-EVMKFRM2.js");
|
|
888
889
|
cancelAllScheduledRuns();
|
|
889
890
|
console.log("All scheduled runs cancelled.");
|
|
890
891
|
} catch (error) {
|
|
891
892
|
console.error("Error cancelling runs:", error instanceof Error ? error.message : String(error));
|
|
892
893
|
}
|
|
893
894
|
break;
|
|
895
|
+
case "save-training":
|
|
896
|
+
try {
|
|
897
|
+
const dialogVar = this.client ? (await this.client.getState()).variables.find((v) => v.name === "__llm_dialog__") : this.session.variables.find((v) => v.name === "__llm_dialog__");
|
|
898
|
+
if (!dialogVar || !dialogVar.value) {
|
|
899
|
+
console.log("No LLM dialog to save");
|
|
900
|
+
break;
|
|
901
|
+
}
|
|
902
|
+
const dialog = typeof dialogVar.value === "string" ? JSON.parse(dialogVar.value) : dialogVar.value;
|
|
903
|
+
if (!Array.isArray(dialog) || dialog.length === 0) {
|
|
904
|
+
console.log("Dialog is empty");
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
const trainingExample = { messages: dialog };
|
|
908
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0] + "-" + Date.now();
|
|
909
|
+
const tempFile = path.join(os.tmpdir(), `dirac-training-${timestamp}.jsonl`);
|
|
910
|
+
fs.writeFileSync(tempFile, JSON.stringify(trainingExample, null, 2), "utf-8");
|
|
911
|
+
console.log("Opening in editor...");
|
|
912
|
+
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
913
|
+
const { spawnSync } = await import("child_process");
|
|
914
|
+
const result = spawnSync(editor, [tempFile], {
|
|
915
|
+
stdio: "inherit",
|
|
916
|
+
shell: true
|
|
917
|
+
});
|
|
918
|
+
if (result.error) {
|
|
919
|
+
fs.unlinkSync(tempFile);
|
|
920
|
+
console.error(`Failed to open editor: ${result.error.message}`);
|
|
921
|
+
break;
|
|
922
|
+
}
|
|
923
|
+
if (result.status !== 0) {
|
|
924
|
+
fs.unlinkSync(tempFile);
|
|
925
|
+
console.error(`Editor exited with code ${result.status}`);
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
const answer = await new Promise((resolve2) => {
|
|
929
|
+
this.rl.question("Save to file (or press Enter to cancel): ", resolve2);
|
|
930
|
+
});
|
|
931
|
+
if (!answer.trim()) {
|
|
932
|
+
fs.unlinkSync(tempFile);
|
|
933
|
+
console.log("Cancelled");
|
|
934
|
+
break;
|
|
935
|
+
}
|
|
936
|
+
let savePath;
|
|
937
|
+
if (answer.startsWith("/") || answer.startsWith("~")) {
|
|
938
|
+
savePath = answer.replace(/^~/, os.homedir());
|
|
939
|
+
} else if (answer.includes("/")) {
|
|
940
|
+
savePath = path.resolve(answer);
|
|
941
|
+
} else {
|
|
942
|
+
const trainingDir = path.join(os.homedir(), ".dirac", "training");
|
|
943
|
+
fs.mkdirSync(trainingDir, { recursive: true });
|
|
944
|
+
savePath = path.join(trainingDir, answer.endsWith(".jsonl") ? answer : `${answer}.jsonl`);
|
|
945
|
+
}
|
|
946
|
+
const editedContent = fs.readFileSync(tempFile, "utf-8");
|
|
947
|
+
const editedData = JSON.parse(editedContent);
|
|
948
|
+
fs.appendFileSync(savePath, JSON.stringify(editedData) + "\n");
|
|
949
|
+
fs.unlinkSync(tempFile);
|
|
950
|
+
console.log(`\u2713 Saved training example to ${savePath}`);
|
|
951
|
+
} catch (error) {
|
|
952
|
+
console.error("Error saving training data:", error instanceof Error ? error.message : String(error));
|
|
953
|
+
}
|
|
954
|
+
break;
|
|
894
955
|
case "exit":
|
|
895
956
|
case "quit":
|
|
896
957
|
this.rl.close();
|
package/dist/test-runner.js
CHANGED