dirac-lang 0.1.46 → 0.1.48

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.46",
19
+ version: "0.1.48",
20
20
  description: "LLM-Augmented Declarative Execution",
21
21
  type: "module",
22
22
  main: "dist/index.js",
@@ -96,7 +96,7 @@ async function main() {
96
96
  process.exit(0);
97
97
  }
98
98
  if (args[0] === "shell") {
99
- const { DiracShell } = await import("./shell-LGNPK4GO.js");
99
+ const { DiracShell } = await import("./shell-P52SBQWW.js");
100
100
  const shellConfig = { debug: false };
101
101
  for (let i = 1; i < args.length; i++) {
102
102
  const arg = args[i];
@@ -39,11 +39,76 @@ var DiracShell = class {
39
39
  input: process.stdin,
40
40
  output: process.stdout,
41
41
  prompt: "> ",
42
- historySize: MAX_HISTORY
42
+ historySize: MAX_HISTORY,
43
+ completer: this.completer.bind(this)
43
44
  });
44
45
  this.loadHistory();
45
46
  this.setupHandlers();
46
47
  }
48
+ completer(line) {
49
+ const attrMatch = line.match(/\|([a-z0-9_-]+)\s+.*?([a-z0-9_-]*)$/i);
50
+ if (attrMatch) {
51
+ const tagName = attrMatch[1];
52
+ const attrPartial = attrMatch[2];
53
+ const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
54
+ if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
55
+ const paramNames = subroutine.parameters.map((p) => p.name);
56
+ const matches = paramNames.filter(
57
+ (name) => name.toLowerCase().startsWith(attrPartial.toLowerCase())
58
+ );
59
+ const completions = matches.map((name) => `${name}=`);
60
+ return [completions, attrPartial];
61
+ }
62
+ }
63
+ const tagCompleteMatch = line.match(/\|([a-z0-9_-]+)$/i);
64
+ if (tagCompleteMatch) {
65
+ const tagName = tagCompleteMatch[1];
66
+ const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
67
+ if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
68
+ const paramSuggestions = subroutine.parameters.map((p) => {
69
+ const required = p.required ? "*" : "";
70
+ const typeInfo = p.type || "string";
71
+ return `${p.name}=${required}${typeInfo}`;
72
+ });
73
+ return [paramSuggestions, ""];
74
+ }
75
+ const subroutineNames = this.session.subroutines.map((sub) => sub.name);
76
+ const matches = subroutineNames.filter(
77
+ (name) => name.toLowerCase().startsWith(tagName.toLowerCase())
78
+ );
79
+ if (matches.length > 0) {
80
+ const completions = matches.map((name) => {
81
+ const sub = this.session.subroutines.find((s) => s.name === name);
82
+ const hasParams = sub && sub.parameters && sub.parameters.length > 0;
83
+ return hasParams ? `|${name} ` : `|${name}>`;
84
+ });
85
+ return [completions, tagCompleteMatch[0]];
86
+ }
87
+ }
88
+ const braketMatch = line.match(/\|([a-z0-9_-]*)$/i);
89
+ if (braketMatch) {
90
+ const partial = braketMatch[1];
91
+ const subroutineNames = this.session.subroutines.map((sub) => sub.name);
92
+ const matches = subroutineNames.filter(
93
+ (name) => name.toLowerCase().startsWith(partial.toLowerCase())
94
+ );
95
+ const completions = matches.map((name) => {
96
+ const subroutine = this.session.subroutines.find((sub) => sub.name === name);
97
+ const hasParams = subroutine && subroutine.parameters && subroutine.parameters.length > 0;
98
+ return hasParams ? `|${name} ` : `|${name}>`;
99
+ });
100
+ return [completions, braketMatch[0]];
101
+ }
102
+ const commandMatch = line.match(/:([a-z]*)$/i);
103
+ if (commandMatch) {
104
+ const partial = commandMatch[1];
105
+ const commands = ["help", "quit", "exit", "vars", "subs", "clear", "history", "save", "debug", "llm"];
106
+ const matches = commands.filter((cmd) => cmd.startsWith(partial.toLowerCase()));
107
+ const completions = matches.map((cmd) => `:${cmd}`);
108
+ return [completions, commandMatch[0]];
109
+ }
110
+ return [[], line];
111
+ }
47
112
  loadHistory() {
48
113
  try {
49
114
  if (fs.existsSync(HISTORY_FILE)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",