dirac-lang 0.1.90 → 0.1.91
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/cli.js
CHANGED
|
@@ -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.91",
|
|
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-U5L7KXSV.js");
|
|
154
154
|
const shellConfig = loadShellConfig(args);
|
|
155
155
|
const shell = new DiracShell(shellConfig);
|
|
156
156
|
await shell.start();
|
|
@@ -230,7 +230,7 @@ async function main() {
|
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
if (args[0] === "shell") {
|
|
233
|
-
const { DiracShell } = await import("./shell-
|
|
233
|
+
const { DiracShell } = await import("./shell-U5L7KXSV.js");
|
|
234
234
|
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-6Z2THFHB.js");
|
|
235
235
|
const { SessionClient } = await import("./session-client-3VTC5MLO.js");
|
|
236
236
|
const daemonMode = args.includes("--daemon") || args.includes("-d");
|
|
@@ -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:
|
|
@@ -891,6 +892,66 @@ Examples:
|
|
|
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();
|