dirac-lang 0.1.73 → 0.1.75

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/README.md CHANGED
@@ -258,7 +258,7 @@ npm install -g dirac-lang
258
258
 
259
259
  ## PAUL: The Human-Friendly Dirac Dialect
260
260
 
261
- Diracs XML-based language is designed for robust machine execution and symbolic reasoning. For human authors, we introduce **PAUL** (Programming AI Utility Language)—a concise, bra/ket-inspired notation for writing Dirac programs quickly and intuitively.
261
+ Dirac's XML-based language is designed for robust machine execution and symbolic reasoning. For human authors, we introduce **PAUL** (Pattern Action Utility Language)—a concise, bra/ket-inspired notation for writing Dirac programs quickly and intuitively.
262
262
 
263
263
  - PAUL uses bra/ket syntax and positional arguments for readability.
264
264
  - It is ideal for human editing, rapid prototyping, and LLM prompts.
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.72",
19
+ version: "0.1.74",
20
20
  description: "LLM-Augmented Declarative Execution",
21
21
  type: "module",
22
22
  main: "dist/index.js",
@@ -91,15 +91,44 @@ function loadShellConfig(args = []) {
91
91
  }
92
92
  }
93
93
  if (!shellConfig.llmProvider) {
94
- const defaultConfigPath = resolve(process.cwd(), "config.yml");
95
- if (fs.existsSync(defaultConfigPath)) {
96
- try {
97
- const configData = yaml.load(fs.readFileSync(defaultConfigPath, "utf-8"));
98
- shellConfig.llmProvider = shellConfig.llmProvider || configData.llmProvider;
99
- shellConfig.llmModel = shellConfig.llmModel || configData.llmModel;
100
- shellConfig.customLLMUrl = shellConfig.customLLMUrl || configData.customLLMUrl;
101
- shellConfig.initScript = shellConfig.initScript || configData.initScript;
102
- } catch (err) {
94
+ const configPaths = [
95
+ resolve(process.cwd(), "config.yml"),
96
+ resolve(process.env.HOME || "~", ".dirac", "config.yml")
97
+ ];
98
+ for (const configPath of configPaths) {
99
+ if (fs.existsSync(configPath)) {
100
+ try {
101
+ const configData = yaml.load(fs.readFileSync(configPath, "utf-8"));
102
+ shellConfig.llmProvider = shellConfig.llmProvider || configData.llmProvider;
103
+ shellConfig.llmModel = shellConfig.llmModel || configData.llmModel;
104
+ shellConfig.customLLMUrl = shellConfig.customLLMUrl || configData.customLLMUrl;
105
+ if (configData.initScript && !shellConfig.initScript) {
106
+ const configDir = configPath.substring(0, configPath.lastIndexOf("/"));
107
+ shellConfig.initScript = resolve(configDir, configData.initScript);
108
+ }
109
+ break;
110
+ } catch (err) {
111
+ }
112
+ }
113
+ }
114
+ }
115
+ if (!shellConfig.llmProvider) {
116
+ shellConfig.llmProvider = process.env.LLM_PROVIDER;
117
+ shellConfig.llmModel = process.env.LLM_MODEL;
118
+ shellConfig.customLLMUrl = process.env.CUSTOM_LLM_URL;
119
+ if (!shellConfig.llmProvider) {
120
+ if (process.env.ANTHROPIC_API_KEY) {
121
+ shellConfig.llmProvider = "anthropic";
122
+ shellConfig.llmModel = shellConfig.llmModel || "claude-sonnet-4-20250514";
123
+ } else if (process.env.OPENAI_API_KEY) {
124
+ shellConfig.llmProvider = "openai";
125
+ shellConfig.llmModel = shellConfig.llmModel || "gpt-4o";
126
+ }
127
+ }
128
+ if (!shellConfig.initScript) {
129
+ const globalInitScript = resolve(process.env.HOME || "~", ".dirac", "shell-init.di");
130
+ if (fs.existsSync(globalInitScript)) {
131
+ shellConfig.initScript = globalInitScript;
103
132
  }
104
133
  }
105
134
  }
@@ -109,7 +138,7 @@ async function main() {
109
138
  const args = process.argv.slice(2);
110
139
  const calledAs = process.argv[1];
111
140
  if (calledAs && calledAs.endsWith("/dish")) {
112
- const { DiracShell } = await import("./shell-EB5Z2U45.js");
141
+ const { DiracShell } = await import("./shell-63M4JYYI.js");
113
142
  const shellConfig = loadShellConfig(args);
114
143
  const shell = new DiracShell(shellConfig);
115
144
  await shell.start();
@@ -189,7 +218,7 @@ async function main() {
189
218
  return;
190
219
  }
191
220
  if (args[0] === "shell") {
192
- const { DiracShell } = await import("./shell-EB5Z2U45.js");
221
+ const { DiracShell } = await import("./shell-63M4JYYI.js");
193
222
  const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-K6OZRYTZ.js");
194
223
  const { SessionClient } = await import("./session-client-3VTC5MLO.js");
195
224
  const daemonMode = args.includes("--daemon") || args.includes("-d");
@@ -967,7 +967,9 @@ Examples:
967
967
  console.log(`LLM: ${this.config.llmProvider} (${this.config.llmModel || "default"})
968
968
  `);
969
969
  } else {
970
- console.log("Warning: No LLM provider configured. Set LLM_PROVIDER environment variable.\n");
970
+ console.log("No LLM provider configured.");
971
+ console.log("Set ANTHROPIC_API_KEY or OPENAI_API_KEY environment variable,");
972
+ console.log("or create ~/.dirac/config.yml with llmProvider and llmModel.\n");
971
973
  }
972
974
  if (this.config.initScript) {
973
975
  await this.runInitScript(this.config.initScript);
@@ -978,8 +980,6 @@ Examples:
978
980
  try {
979
981
  const resolvedPath = path.isAbsolute(scriptPath) ? scriptPath : path.join(process.cwd(), scriptPath);
980
982
  if (!fs.existsSync(resolvedPath)) {
981
- console.log(`Init script not found: ${scriptPath}
982
- `);
983
983
  return;
984
984
  }
985
985
  console.log(`Loading init script: ${scriptPath}`);
@@ -1024,24 +1024,50 @@ async function main() {
1024
1024
  let config = {
1025
1025
  debug: process.env.DEBUG === "1"
1026
1026
  };
1027
- const configPath = path.join(process.cwd(), "config.yml");
1028
- if (fs.existsSync(configPath)) {
1029
- try {
1030
- const configData = yaml.load(fs.readFileSync(configPath, "utf-8"));
1031
- config = {
1032
- ...config,
1033
- llmProvider: configData.llmProvider || process.env.LLM_PROVIDER,
1034
- llmModel: configData.llmModel || process.env.LLM_MODEL,
1035
- customLLMUrl: configData.customLLMUrl || process.env.CUSTOM_LLM_URL,
1036
- initScript: configData.initScript
1037
- };
1038
- } catch (err) {
1039
- console.error("Warning: Could not load config.yml");
1027
+ const configPaths = [
1028
+ path.join(process.cwd(), "config.yml"),
1029
+ path.join(process.env.HOME || "~", ".dirac", "config.yml")
1030
+ ];
1031
+ let configLoaded = false;
1032
+ for (const configPath of configPaths) {
1033
+ if (fs.existsSync(configPath)) {
1034
+ try {
1035
+ const configData = yaml.load(fs.readFileSync(configPath, "utf-8"));
1036
+ let initScript = configData.initScript;
1037
+ if (initScript) {
1038
+ const configDir = path.dirname(configPath);
1039
+ initScript = path.resolve(configDir, initScript);
1040
+ }
1041
+ config = {
1042
+ ...config,
1043
+ llmProvider: configData.llmProvider || process.env.LLM_PROVIDER,
1044
+ llmModel: configData.llmModel || process.env.LLM_MODEL,
1045
+ customLLMUrl: configData.customLLMUrl || process.env.CUSTOM_LLM_URL,
1046
+ initScript
1047
+ };
1048
+ configLoaded = true;
1049
+ break;
1050
+ } catch (err) {
1051
+ }
1040
1052
  }
1041
- } else {
1053
+ }
1054
+ if (!configLoaded) {
1042
1055
  config.llmProvider = process.env.LLM_PROVIDER;
1043
1056
  config.llmModel = process.env.LLM_MODEL;
1044
1057
  config.customLLMUrl = process.env.CUSTOM_LLM_URL;
1058
+ if (!config.llmProvider) {
1059
+ if (process.env.ANTHROPIC_API_KEY) {
1060
+ config.llmProvider = "anthropic";
1061
+ config.llmModel = config.llmModel || "claude-sonnet-4-20250514";
1062
+ } else if (process.env.OPENAI_API_KEY) {
1063
+ config.llmProvider = "openai";
1064
+ config.llmModel = config.llmModel || "gpt-4o";
1065
+ }
1066
+ }
1067
+ const globalInitScript = path.join(process.env.HOME || "~", ".dirac", "shell-init.di");
1068
+ if (fs.existsSync(globalInitScript)) {
1069
+ config.initScript = globalInitScript;
1070
+ }
1045
1071
  }
1046
1072
  const shell = new DiracShell(config);
1047
1073
  await shell.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.73",
3
+ "version": "0.1.75",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",