dirac-lang 0.1.63 → 0.1.64
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.63",
|
|
20
20
|
description: "LLM-Augmented Declarative Execution",
|
|
21
21
|
type: "module",
|
|
22
22
|
main: "dist/index.js",
|
|
@@ -145,7 +145,7 @@ async function main() {
|
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
if (args[0] === "shell") {
|
|
148
|
-
const { DiracShell } = await import("./shell-
|
|
148
|
+
const { DiracShell } = await import("./shell-6NG7WK5Z.js");
|
|
149
149
|
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-GEISBLMU.js");
|
|
150
150
|
const { SessionClient } = await import("./session-client-3VTC5MLO.js");
|
|
151
151
|
const daemonMode = args.includes("--daemon") || args.includes("-d");
|
|
@@ -68,6 +68,65 @@ var DiracShell = class {
|
|
|
68
68
|
}
|
|
69
69
|
completer(line) {
|
|
70
70
|
const subroutines = this.client ? this.cachedSubroutines : this.session.subroutines;
|
|
71
|
+
const varMatch = line.match(/\$([a-zA-Z0-9_-]*)$/);
|
|
72
|
+
if (varMatch) {
|
|
73
|
+
const partial = varMatch[1];
|
|
74
|
+
const varNames = Object.keys(this.session.variables || {});
|
|
75
|
+
const commonEnvVars = [
|
|
76
|
+
"HOME",
|
|
77
|
+
"PATH",
|
|
78
|
+
"USER",
|
|
79
|
+
"SHELL",
|
|
80
|
+
"PWD",
|
|
81
|
+
"OLDPWD",
|
|
82
|
+
"TERM",
|
|
83
|
+
"LANG",
|
|
84
|
+
"EDITOR",
|
|
85
|
+
"TMPDIR",
|
|
86
|
+
"PS1"
|
|
87
|
+
];
|
|
88
|
+
const envVarNames = Object.keys(process.env).filter(
|
|
89
|
+
(name) => commonEnvVars.includes(name) || name.startsWith("DIRAC_") || name.startsWith("TELEGRAM_")
|
|
90
|
+
);
|
|
91
|
+
const allVars = [...varNames, ...envVarNames];
|
|
92
|
+
const matches = allVars.filter(
|
|
93
|
+
(name) => name.toLowerCase().startsWith(partial.toLowerCase())
|
|
94
|
+
);
|
|
95
|
+
const completions = matches.map((name) => `$${name}`);
|
|
96
|
+
return [completions, varMatch[0]];
|
|
97
|
+
}
|
|
98
|
+
const pathMatch = line.match(/((?:\.\.?\/|~\/|\/)[^\s]*)$/);
|
|
99
|
+
if (pathMatch) {
|
|
100
|
+
const partial = pathMatch[1];
|
|
101
|
+
try {
|
|
102
|
+
let searchPath = partial;
|
|
103
|
+
if (searchPath.startsWith("~/")) {
|
|
104
|
+
searchPath = path.join(os.homedir(), searchPath.slice(2));
|
|
105
|
+
}
|
|
106
|
+
const dirPath = path.dirname(searchPath);
|
|
107
|
+
const filePrefix = path.basename(searchPath);
|
|
108
|
+
if (fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()) {
|
|
109
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
110
|
+
const matches = entries.filter((entry) => entry.name.startsWith(filePrefix)).map((entry) => {
|
|
111
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
112
|
+
let displayPath = fullPath;
|
|
113
|
+
if (partial.startsWith("~/")) {
|
|
114
|
+
displayPath = "~/" + path.relative(os.homedir(), fullPath);
|
|
115
|
+
} else if (partial.startsWith("./") || partial.startsWith("../")) {
|
|
116
|
+
displayPath = path.relative(process.cwd(), fullPath);
|
|
117
|
+
if (!displayPath.startsWith(".")) {
|
|
118
|
+
displayPath = "./" + displayPath;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return entry.isDirectory() ? displayPath + "/" : displayPath;
|
|
122
|
+
});
|
|
123
|
+
if (matches.length > 0) {
|
|
124
|
+
return [matches, pathMatch[0]];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
71
130
|
const attrMatch = line.match(/\|([a-z0-9_-]+)\s+.*?([a-z0-9_-]*)$/i);
|
|
72
131
|
if (attrMatch) {
|
|
73
132
|
const tagName = attrMatch[1];
|
|
@@ -143,11 +202,57 @@ var DiracShell = class {
|
|
|
143
202
|
const commandMatch = line.match(/:([a-z]*)$/i);
|
|
144
203
|
if (commandMatch) {
|
|
145
204
|
const partial = commandMatch[1];
|
|
146
|
-
const commands = ["help", "quit", "exit", "vars", "subs", "clear", "history", "save", "debug", "llm"];
|
|
205
|
+
const commands = ["help", "quit", "exit", "vars", "subs", "clear", "history", "save", "debug", "llm", "index"];
|
|
147
206
|
const matches = commands.filter((cmd) => cmd.startsWith(partial.toLowerCase()));
|
|
148
207
|
const completions = matches.map((cmd) => `:${cmd}`);
|
|
149
208
|
return [completions, commandMatch[0]];
|
|
150
209
|
}
|
|
210
|
+
if (line.includes("<system>") || line.includes("|system>")) {
|
|
211
|
+
const systemMatch = line.match(/(?:<system>|\\|system>)\s*([a-z]*)$/i);
|
|
212
|
+
if (systemMatch) {
|
|
213
|
+
const partial = systemMatch[1];
|
|
214
|
+
const commonCommands = [
|
|
215
|
+
"ls",
|
|
216
|
+
"cd",
|
|
217
|
+
"pwd",
|
|
218
|
+
"cat",
|
|
219
|
+
"grep",
|
|
220
|
+
"find",
|
|
221
|
+
"echo",
|
|
222
|
+
"cp",
|
|
223
|
+
"mv",
|
|
224
|
+
"rm",
|
|
225
|
+
"mkdir",
|
|
226
|
+
"touch",
|
|
227
|
+
"git",
|
|
228
|
+
"npm",
|
|
229
|
+
"node",
|
|
230
|
+
"python",
|
|
231
|
+
"curl",
|
|
232
|
+
"wget",
|
|
233
|
+
"ssh",
|
|
234
|
+
"scp",
|
|
235
|
+
"tar",
|
|
236
|
+
"gzip",
|
|
237
|
+
"diff",
|
|
238
|
+
"ps",
|
|
239
|
+
"top",
|
|
240
|
+
"kill",
|
|
241
|
+
"chmod",
|
|
242
|
+
"chown",
|
|
243
|
+
"ln",
|
|
244
|
+
"du",
|
|
245
|
+
"df",
|
|
246
|
+
"which",
|
|
247
|
+
"man",
|
|
248
|
+
"history"
|
|
249
|
+
];
|
|
250
|
+
const matches = commonCommands.filter((cmd) => cmd.startsWith(partial.toLowerCase()));
|
|
251
|
+
if (matches.length > 0) {
|
|
252
|
+
return [matches, partial];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
151
256
|
return [[], line];
|
|
152
257
|
}
|
|
153
258
|
loadHistory() {
|