dirac-lang 0.1.3 → 0.1.5
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 +73 -11
- package/package.json +1 -1
- package/src/cli.ts +35 -13
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,51 @@ import "./chunk-NDIRTD3D.js";
|
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import "dotenv/config";
|
|
9
|
+
|
|
10
|
+
// package.json
|
|
11
|
+
var package_default = {
|
|
12
|
+
name: "dirac-lang",
|
|
13
|
+
version: "0.1.5",
|
|
14
|
+
description: "LLM-Augmented Declarative Execution",
|
|
15
|
+
type: "module",
|
|
16
|
+
main: "dist/index.js",
|
|
17
|
+
types: "dist/index.d.ts",
|
|
18
|
+
bin: {
|
|
19
|
+
dirac: "dist/cli.js"
|
|
20
|
+
},
|
|
21
|
+
scripts: {
|
|
22
|
+
dev: "tsx src/cli.ts",
|
|
23
|
+
build: "tsup src/index.ts src/cli.ts --format esm --dts --clean",
|
|
24
|
+
test: "vitest",
|
|
25
|
+
typecheck: "tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
keywords: [
|
|
28
|
+
"llm",
|
|
29
|
+
"declarative",
|
|
30
|
+
"dirac",
|
|
31
|
+
"bra-ket"
|
|
32
|
+
],
|
|
33
|
+
author: "Zhi Wang",
|
|
34
|
+
license: "MIT",
|
|
35
|
+
dependencies: {
|
|
36
|
+
"@anthropic-ai/sdk": "^0.30.1",
|
|
37
|
+
dotenv: "^17.2.3",
|
|
38
|
+
"fast-xml-parser": "^4.3.5",
|
|
39
|
+
"js-yaml": "^4.1.1",
|
|
40
|
+
mongodb: "^7.0.0",
|
|
41
|
+
openai: "^6.16.0"
|
|
42
|
+
},
|
|
43
|
+
devDependencies: {
|
|
44
|
+
"@types/js-yaml": "^4.0.9",
|
|
45
|
+
"@types/node": "^20.11.0",
|
|
46
|
+
tsup: "^8.0.1",
|
|
47
|
+
tsx: "^4.7.0",
|
|
48
|
+
typescript: "^5.3.3",
|
|
49
|
+
vitest: "^1.2.0"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/cli.ts
|
|
9
54
|
import fs from "fs";
|
|
10
55
|
import yaml from "js-yaml";
|
|
11
56
|
import { resolve, extname } from "path";
|
|
@@ -176,19 +221,30 @@ var BraKetParser = class {
|
|
|
176
221
|
// src/cli.ts
|
|
177
222
|
async function main() {
|
|
178
223
|
const args = process.argv.slice(2);
|
|
224
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
225
|
+
console.log("Usage: dirac <file.di|file.bk>");
|
|
226
|
+
console.log("");
|
|
227
|
+
console.log("File formats:");
|
|
228
|
+
console.log(" .di XML notation (verbose)");
|
|
229
|
+
console.log(" .bk Bra-ket notation (compact)");
|
|
230
|
+
console.log("");
|
|
231
|
+
console.log("Options:");
|
|
232
|
+
console.log(" --help, -h Show this help message");
|
|
233
|
+
console.log(" --version, -v Show version");
|
|
234
|
+
console.log(" --debug Enable debug output");
|
|
235
|
+
console.log(" --emit-xml Output intermediate XML (for .bk files)");
|
|
236
|
+
console.log(" --model <name> Set default LLM model");
|
|
237
|
+
console.log(" --max-llm <n> Maximum LLM calls (default: 100)");
|
|
238
|
+
console.log(" --max-depth <n> Maximum recursion depth (default: 50)");
|
|
239
|
+
process.exit(0);
|
|
240
|
+
}
|
|
241
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
242
|
+
console.log(package_default.version);
|
|
243
|
+
process.exit(0);
|
|
244
|
+
}
|
|
179
245
|
if (args.length === 0) {
|
|
180
246
|
console.error("Usage: dirac <file.di|file.bk>");
|
|
181
|
-
console.error("");
|
|
182
|
-
console.error("File formats:");
|
|
183
|
-
console.error(" .di XML notation (verbose)");
|
|
184
|
-
console.error(" .bk Bra-ket notation (compact)");
|
|
185
|
-
console.error("");
|
|
186
|
-
console.error("Options:");
|
|
187
|
-
console.error(" --debug Enable debug output");
|
|
188
|
-
console.error(" --emit-xml Output intermediate XML (for .bk files)");
|
|
189
|
-
console.error(" --model <name> Set default LLM model");
|
|
190
|
-
console.error(" --max-llm <n> Maximum LLM calls (default: 100)");
|
|
191
|
-
console.error(" --max-depth <n> Maximum recursion depth (default: 50)");
|
|
247
|
+
console.error("Try dirac --help for more information.");
|
|
192
248
|
process.exit(1);
|
|
193
249
|
}
|
|
194
250
|
const config = {};
|
|
@@ -215,6 +271,12 @@ async function main() {
|
|
|
215
271
|
filePath = arg;
|
|
216
272
|
}
|
|
217
273
|
}
|
|
274
|
+
if (!configFile) {
|
|
275
|
+
const defaultConfigPath = resolve(process.cwd(), "config.yml");
|
|
276
|
+
if (fs.existsSync(defaultConfigPath)) {
|
|
277
|
+
configFile = defaultConfigPath;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
218
280
|
if (configFile) {
|
|
219
281
|
try {
|
|
220
282
|
const loadedConfig = yaml.load(fs.readFileSync(resolve(configFile), "utf8")) || {};
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import 'dotenv/config';
|
|
8
|
+
import pkg from '../package.json' assert { type: 'json' };
|
|
8
9
|
import fs from 'fs';
|
|
9
10
|
import yaml from 'js-yaml';
|
|
10
11
|
import { resolve, extname } from 'path';
|
|
@@ -13,20 +14,35 @@ import { BraKetParser } from './runtime/braket-parser.js';
|
|
|
13
14
|
|
|
14
15
|
async function main() {
|
|
15
16
|
const args = process.argv.slice(2);
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
// --help option
|
|
19
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
20
|
+
console.log('Usage: dirac <file.di|file.bk>');
|
|
21
|
+
console.log('');
|
|
22
|
+
console.log('File formats:');
|
|
23
|
+
console.log(' .di XML notation (verbose)');
|
|
24
|
+
console.log(' .bk Bra-ket notation (compact)');
|
|
25
|
+
console.log('');
|
|
26
|
+
console.log('Options:');
|
|
27
|
+
console.log(' --help, -h Show this help message');
|
|
28
|
+
console.log(' --version, -v Show version');
|
|
29
|
+
console.log(' --debug Enable debug output');
|
|
30
|
+
console.log(' --emit-xml Output intermediate XML (for .bk files)');
|
|
31
|
+
console.log(' --model <name> Set default LLM model');
|
|
32
|
+
console.log(' --max-llm <n> Maximum LLM calls (default: 100)');
|
|
33
|
+
console.log(' --max-depth <n> Maximum recursion depth (default: 50)');
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// --version option
|
|
38
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
39
|
+
console.log(pkg.version);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
17
43
|
if (args.length === 0) {
|
|
18
44
|
console.error('Usage: dirac <file.di|file.bk>');
|
|
19
|
-
console.error('');
|
|
20
|
-
console.error('File formats:');
|
|
21
|
-
console.error(' .di XML notation (verbose)');
|
|
22
|
-
console.error(' .bk Bra-ket notation (compact)');
|
|
23
|
-
console.error('');
|
|
24
|
-
console.error('Options:');
|
|
25
|
-
console.error(' --debug Enable debug output');
|
|
26
|
-
console.error(' --emit-xml Output intermediate XML (for .bk files)');
|
|
27
|
-
console.error(' --model <name> Set default LLM model');
|
|
28
|
-
console.error(' --max-llm <n> Maximum LLM calls (default: 100)');
|
|
29
|
-
console.error(' --max-depth <n> Maximum recursion depth (default: 50)');
|
|
45
|
+
console.error('Try dirac --help for more information.');
|
|
30
46
|
process.exit(1);
|
|
31
47
|
}
|
|
32
48
|
|
|
@@ -58,7 +74,13 @@ async function main() {
|
|
|
58
74
|
}
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
// Load config from YAML file if specified
|
|
77
|
+
// Load config from YAML file if specified, or use ./config.yml if present
|
|
78
|
+
if (!configFile) {
|
|
79
|
+
const defaultConfigPath = resolve(process.cwd(), 'config.yml');
|
|
80
|
+
if (fs.existsSync(defaultConfigPath)) {
|
|
81
|
+
configFile = defaultConfigPath;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
62
84
|
if (configFile) {
|
|
63
85
|
try {
|
|
64
86
|
const loadedConfig = yaml.load(fs.readFileSync(resolve(configFile), 'utf8')) || {};
|