dirac-lang 0.1.78 → 0.1.79

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
@@ -30,7 +30,8 @@ var package_default = {
30
30
  ".": "./dist/index.js"
31
31
  },
32
32
  files: [
33
- "dist/"
33
+ "dist/",
34
+ "lib/"
34
35
  ],
35
36
  scripts: {
36
37
  dev: "tsx src/cli.ts",
@@ -130,6 +131,11 @@ function loadShellConfig(args = []) {
130
131
  const globalInitScript = resolve(process.env.HOME || "~", ".dirac", "shell-init.di");
131
132
  if (fs.existsSync(globalInitScript)) {
132
133
  shellConfig.initScript = globalInitScript;
134
+ } else {
135
+ const packagedInitScript = new URL("../lib/shell-init.di", import.meta.url).pathname;
136
+ if (fs.existsSync(packagedInitScript)) {
137
+ shellConfig.initScript = packagedInitScript;
138
+ }
133
139
  }
134
140
  }
135
141
  }
@@ -139,7 +145,7 @@ async function main() {
139
145
  const args = process.argv.slice(2);
140
146
  const calledAs = process.argv[1];
141
147
  if (calledAs && calledAs.endsWith("/dish")) {
142
- const { DiracShell } = await import("./shell-IUWCSKPG.js");
148
+ const { DiracShell } = await import("./shell-W6NOJBXV.js");
143
149
  const shellConfig = loadShellConfig(args);
144
150
  const shell = new DiracShell(shellConfig);
145
151
  await shell.start();
@@ -219,7 +225,7 @@ async function main() {
219
225
  return;
220
226
  }
221
227
  if (args[0] === "shell") {
222
- const { DiracShell } = await import("./shell-IUWCSKPG.js");
228
+ const { DiracShell } = await import("./shell-W6NOJBXV.js");
223
229
  const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-IDEV4CXY.js");
224
230
  const { SessionClient } = await import("./session-client-3VTC5MLO.js");
225
231
  const daemonMode = args.includes("--daemon") || args.includes("-d");
@@ -973,12 +973,57 @@ Examples:
973
973
  console.log("or create ~/.dirac/config.yml with llmProvider and llmModel.\n");
974
974
  }
975
975
  const { registry } = await import("./subroutine-index-7B5YXKAA.js");
976
- await registry.autoIndexStdlib();
976
+ const wasIndexed = await registry.autoIndexStdlib();
977
+ await this.loadEssentialSubroutines();
977
978
  if (this.config.initScript) {
978
979
  await this.runInitScript(this.config.initScript);
979
980
  }
980
981
  this.rl.prompt();
981
982
  }
983
+ /**
984
+ * Load essential stdlib subroutines into the session
985
+ * This ensures basic helpers are available even without an init script
986
+ */
987
+ async loadEssentialSubroutines() {
988
+ try {
989
+ const { createRequire } = await import("module");
990
+ const require2 = createRequire(import.meta.url);
991
+ const stdlibPackagePath = require2.resolve("dirac-stdlib/package.json");
992
+ const stdlibLibPath = path.join(path.dirname(stdlibPackagePath), "lib");
993
+ const essentialFiles = [
994
+ "ai.di",
995
+ // AI helper subroutines
996
+ "index.di"
997
+ // Core utilities
998
+ ];
999
+ let loadedCount = 0;
1000
+ for (const file of essentialFiles) {
1001
+ const filePath = path.join(stdlibLibPath, file);
1002
+ if (fs.existsSync(filePath)) {
1003
+ try {
1004
+ const content = fs.readFileSync(filePath, "utf-8");
1005
+ const parser = new BraKetParser();
1006
+ const xml = parser.parse(content);
1007
+ const ast = this.xmlParser.parse(xml);
1008
+ await integrate(this.session, ast);
1009
+ loadedCount++;
1010
+ } catch (err) {
1011
+ if (this.config.debug) {
1012
+ console.error(`Failed to load ${file}:`, err);
1013
+ }
1014
+ }
1015
+ }
1016
+ }
1017
+ if (loadedCount > 0 && this.config.debug) {
1018
+ console.log(`Loaded ${loadedCount} essential stdlib file(s)
1019
+ `);
1020
+ }
1021
+ } catch (err) {
1022
+ if (this.config.debug) {
1023
+ console.error("Could not load essential subroutines:", err);
1024
+ }
1025
+ }
1026
+ }
982
1027
  async runInitScript(scriptPath) {
983
1028
  try {
984
1029
  const resolvedPath = path.isAbsolute(scriptPath) ? scriptPath : path.join(process.cwd(), scriptPath);
package/lib/ai.di ADDED
@@ -0,0 +1,64 @@
1
+ <!-- Exported subroutine -->
2
+
3
+ <subroutine name="ai"
4
+ description="AI assistant with context loading (internal wrapper - use llm tag directly instead)">
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ <load-context>
13
+
14
+
15
+
16
+
17
+
18
+
19
+ <parameters select="*" />
20
+
21
+
22
+
23
+
24
+
25
+
26
+ </load-context>
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ <llm execute="true" save-dialog="true" show="boundary" feedback="true">
35
+
36
+
37
+
38
+
39
+
40
+
41
+ <parameters select="*" />
42
+
43
+
44
+
45
+
46
+
47
+
48
+ </llm>
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ </subroutine>
@@ -0,0 +1,463 @@
1
+ <!--
2
+ Native Tag Interface for DIRAC
3
+
4
+ This file provides stub definitions for all native (built-in) DIRAC tags.
5
+ These definitions enable native tags to appear in :subs list and provide
6
+ parameter documentation without affecting native tag execution.
7
+
8
+ IMPORTANT: These are interface definitions only - actual execution is handled
9
+ by the native tag implementations in src/tags/*.ts. The interpreter checks
10
+ native tags first (switch statement), then subroutines (default case), so
11
+ these definitions serve as documentation and never execute.
12
+
13
+ Generated from DIRAC tag implementations.
14
+ -->
15
+
16
+ <!-- ============================================================
17
+ VARIABLES & VALUES
18
+ ============================================================ -->
19
+
20
+ <subroutine name="defvar"
21
+ description="Define a new variable with optional visibility"
22
+ param-name="string:required:Variable name"
23
+ param-value="string:optional:Initial value (or use children/text)"
24
+ param-visible="string:optional:Visibility flag|true|false|variable|both"
25
+ param-literal="flag:optional:Store children as literal XML without execution"
26
+ param-trim="string:optional:Trim whitespace from value|true|false">
27
+ </subroutine>
28
+
29
+ <subroutine name="assign"
30
+ description="Assign new value to existing variable"
31
+ param-name="string:required:Variable name to update"
32
+ param-value="string:optional:New value (or use children/text)"
33
+ param-type="string:optional:Assignment type|cat"
34
+ param-trim="string:optional:Trim whitespace from value|true|false">
35
+ <!-- Use type="cat" to concatenate to existing value -->
36
+ <!-- Example: <assign name="str" type="cat">more text</assign> -->
37
+ </subroutine>
38
+
39
+ <subroutine name="variable"
40
+ description="Retrieve and output variable value"
41
+ param-name="string:required:Variable name to retrieve">
42
+ <!-- Use $varname in attributes or ${varname} in text for substitution -->
43
+ </subroutine>
44
+
45
+ <subroutine name="environment"
46
+ description="Read environment variable value"
47
+ param-name="string:required:Environment variable name">
48
+ </subroutine>
49
+
50
+ <!-- ============================================================
51
+ OUTPUT & I/O
52
+ ============================================================ -->
53
+
54
+ <subroutine name="output"
55
+ description="Emit content to stdout or file"
56
+ param-file="string:optional:File path for writing output">
57
+ <!-- Children are executed and output captured -->
58
+ </subroutine>
59
+
60
+ <subroutine name="input"
61
+ description="Read from stdin or file"
62
+ param-source="string:required:Input source|stdin|file"
63
+ param-mode="string:optional:Reading mode (default: all)|all|line"
64
+ param-path="string:optional:File path (required when source=file)">
65
+ <!-- Use mode="line" for line-by-line reading -->
66
+ </subroutine>
67
+
68
+ <!-- ============================================================
69
+ CONTROL FLOW
70
+ ============================================================ -->
71
+
72
+ <subroutine name="if"
73
+ description="Conditional execution with cond/then/else children"
74
+ visible="subroutine">
75
+ <!-- <if> -->
76
+ <!-- <cond><expr eval="eq"><arg>$x</arg><arg>5</arg></expr></cond> -->
77
+ <!-- <then><output>x is 5</output></then> -->
78
+ <!-- <else><output>x is not 5</output></else> -->
79
+ <!-- </if> -->
80
+ <!-- First child can be condition element; then/do and else are optional -->
81
+ </subroutine>
82
+
83
+ <subroutine name="test-if"
84
+ description="Attribute-based conditional execution"
85
+ param-test="string:required:Value or expression to test"
86
+ param-eq="string:optional:Compare equal to value"
87
+ param-ne="string:optional:Compare not equal to value"
88
+ param-lt="string:optional:Compare less than (numeric)"
89
+ param-gt="string:optional:Compare greater than (numeric)"
90
+ param-le="string:optional:Compare less than or equal (numeric)"
91
+ param-ge="string:optional:Compare greater than or equal (numeric)">
92
+ <!-- Supports ==, !=, <, >, <=, >= in test expression -->
93
+ </subroutine>
94
+
95
+ <subroutine name="loop"
96
+ description="Iterate fixed number of times"
97
+ param-count="string:required:Number of iterations (supports variable substitution)"
98
+ param-var="string:optional:Loop counter variable name (default: i)">
99
+ <!-- Use with <break /> for early exit -->
100
+ <!-- For while-loop behavior, use large count with <test-if> + <break> -->
101
+ </subroutine>
102
+
103
+ <subroutine name="foreach"
104
+ description="Iterate over XML elements"
105
+ param-from="string:required:XML content or variable (starts with $ or &lt;)"
106
+ param-as="string:optional:Iterator variable name (default: item)"
107
+ param-xpath="string:optional:XPath filter for elements">
108
+ </subroutine>
109
+
110
+ <subroutine name="break"
111
+ description="Exit current loop or foreach iteration">
112
+ <!-- Use with conditionals for while-loop behavior -->
113
+ </subroutine>
114
+
115
+ <!-- ============================================================
116
+ EXPRESSIONS & EVALUATION
117
+ ============================================================ -->
118
+
119
+ <subroutine name="expr"
120
+ description="Arithmetic and logical operations"
121
+ param-eval="string:required:Operation to perform"
122
+ param-op="string:optional:Alias for eval attribute">
123
+ <!-- Arguments provided as <arg> child elements -->
124
+ <!-- Results output as text (1 for true, 0 for false in comparisons) -->
125
+ </subroutine>
126
+
127
+ <subroutine name="eval"
128
+ description="Evaluate JavaScript expression with full context"
129
+ param-name="string:optional:Variable name to store result"
130
+ param-expr="string:optional:JavaScript code (or use text content)">
131
+ <!-- Context includes: all DIRAC variables, fs, path, session -->
132
+ <!-- Supports top-level await -->
133
+ <!-- Use getParams() to access current subroutine parameters -->
134
+ </subroutine>
135
+
136
+ <!-- ============================================================
137
+ SUBROUTINES & CALLS
138
+ ============================================================ -->
139
+
140
+ <subroutine name="subroutine"
141
+ description="Define reusable code block"
142
+ param-name="string:required:Subroutine name"
143
+ param-description="string:optional:Human-readable description"
144
+ param-visible="string:optional:Visibility setting|subroutine|variable|both"
145
+ param-extend="string:optional:Parent subroutine to extend"
146
+ param-extends="string:optional:Alias for extend">
147
+ <!-- <subroutine name="greet" param-name="string:required:Person to greet"> -->
148
+ <!-- <output>Hello <parameters select="@name" />!</output> -->
149
+ <!-- </subroutine> -->
150
+ <!-- Use param-* attributes to document parameters -->
151
+ <!-- Format: param-NAME="type:required|optional:description:example" -->
152
+ <!-- Invoke with <call name="greet" /> or <greet /> directly -->
153
+ </subroutine>
154
+
155
+ <subroutine name="call"
156
+ description="Invoke defined subroutine"
157
+ param-name="string:required:Subroutine name to call"
158
+ param-subroutine="string:optional:Alias for name attribute">
159
+ <!-- Pass parameters as attributes or child elements -->
160
+ <!-- Positional params: p1, p2, p3, etc. -->
161
+ </subroutine>
162
+
163
+ <subroutine name="parameters"
164
+ description="Access parameters passed to subroutine"
165
+ param-select="string:required:Parameter selector">
166
+ <!-- select="*" : All child elements (returns output) -->
167
+ <!-- select="@*" : All attributes as string -->
168
+ <!-- select="@name" : Specific attribute (creates variable) -->
169
+ </subroutine>
170
+
171
+ <subroutine name="available-subroutines"
172
+ description="List all registered subroutines as XML">
173
+ <!-- Useful with <foreach> to iterate over subroutines -->
174
+ </subroutine>
175
+
176
+ <subroutine name="list-subroutines"
177
+ description="List subroutines in specified format"
178
+ param-format="string:optional:Output format (default: text)|text|json|xml"
179
+ param-output="string:optional:Variable name to store result">
180
+ <!-- xml: Same as <available-subroutines /> -->
181
+ </subroutine>
182
+
183
+ <subroutine name="save-subroutine"
184
+ description="Save subroutine definition to disk"
185
+ param-name="string:required:Subroutine name to save"
186
+ param-file="string:optional:Explicit file path"
187
+ param-path="string:optional:Directory name under ~/.dirac/lib/"
188
+ param-format="string:optional:Output format (default: xml)|xml|braket">
189
+ <!-- Saves subroutine to canonical location: ~/.dirac/lib/user/NAME.di -->
190
+ <!-- Override with file="..." for custom path or path="..." for subdirectory -->
191
+ <!-- Automatically indexes saved subroutine for search functionality -->
192
+ <!-- Shell command: :save <name> [file|path] -->
193
+ <!-- Examples: -->
194
+ <!-- :save greet -> ~/.dirac/lib/user/greet.di -->
195
+ <!-- :save greet utils -> ~/.dirac/lib/utils/greet.di -->
196
+ <!-- :save greet ./custom.di -> ./custom.di -->
197
+ </subroutine>
198
+
199
+ <subroutine name="edit-subroutine"
200
+ description="Edit subroutine definition in external editor"
201
+ param-name="string:required:Subroutine name to edit"
202
+ param-editor="string:optional:Editor command (default: $EDITOR or vi)">
203
+ <!-- Opens subroutine in temp file with editor (blocking) -->
204
+ <!-- After save/exit, automatically re-imports into session -->
205
+ <!-- Changes take effect immediately but are NOT saved to disk -->
206
+ <!-- Use save-subroutine to persist changes -->
207
+ </subroutine>
208
+
209
+ <subroutine name="subroutine-index"
210
+ description="Search and manage subroutine knowledge base"
211
+ param-path="string:optional:Directory to index or search"
212
+ param-query="string:optional:Natural language search query"
213
+ param-limit="string:optional:Maximum results to return"
214
+ param-output="string:optional:Variable name to store results"
215
+ param-format="string:optional:Output format|text|json">
216
+ <!-- Requires embedding service for semantic search -->
217
+ </subroutine>
218
+
219
+ <subroutine name="index-subroutines"
220
+ description="Index subroutines from files or directories for later search"
221
+ param-path="string:required:File or directory path to index">
222
+ <!-- Recursively scans .di files and extracts subroutine definitions -->
223
+ <!-- Indexed subroutines can be searched with search-subroutines tag -->
224
+ <!-- Shell auto-indexes ~/.dirac/lib/user on startup -->
225
+ </subroutine>
226
+
227
+ <subroutine name="search-subroutines"
228
+ description="Search indexed subroutines by name or description"
229
+ param-query="string:required:Search query (name or description keywords)"
230
+ param-limit="string:optional:Maximum results to return (default: 10)"
231
+ param-output="string:optional:Variable name to store results"
232
+ param-format="string:optional:Output format (default: text)|text|json|xml">
233
+ <!-- Searches subroutines indexed via index-subroutines -->
234
+ <!-- Shell command: :search <query> -->
235
+ <!-- Example: <search-subroutines query="greeting" limit="5" format="text" /> -->
236
+ </subroutine>
237
+
238
+ <!-- ============================================================
239
+ CODE EXECUTION
240
+ ============================================================ -->
241
+
242
+ <subroutine name="execute"
243
+ description="Execute dynamically generated DIRAC code"
244
+ param-source="string:optional:Variable containing DIRAC code">
245
+ <!-- Strips markdown code blocks if present -->
246
+ <!-- Useful for executing LLM-generated DIRAC code -->
247
+ </subroutine>
248
+
249
+ <subroutine name="system"
250
+ description="Execute shell commands"
251
+ param-background="string:optional:Run in background without waiting|true|false">
252
+ <!-- Command built from text content or children -->
253
+ <!-- Background mode returns immediately without waiting -->
254
+ </subroutine>
255
+
256
+ <!-- ============================================================
257
+ FILE & MODULE MANAGEMENT
258
+ ============================================================ -->
259
+
260
+ <subroutine name="import"
261
+ description="Import subroutines from other DIRAC files"
262
+ param-src="string:required:File path or package name">
263
+ <!-- Supports ./ ../ / for paths, otherwise searches node_modules -->
264
+ <!-- Automatically adds .di extension -->
265
+ <!-- Package.json "main" field specifies entry point -->
266
+ </subroutine>
267
+
268
+ <subroutine name="require_module"
269
+ description="Load Node.js module into variable"
270
+ param-name="string:required:Module name to import"
271
+ param-var="string:optional:Variable name to store module (defaults to name)">
272
+ <!-- Import npm packages or built-in Node modules -->
273
+ <!-- Module stored as variable for use in <eval> -->
274
+ </subroutine>
275
+
276
+ <!-- ============================================================
277
+ LLM & AI
278
+ ============================================================ -->
279
+
280
+ <subroutine name="llm"
281
+ description="Invoke Large Language Model with validation"
282
+ param-provider="string:optional:LLM provider for this call|anthropic|openai|ollama|custom"
283
+ param-model="string:optional:Model name or use DEFAULT_MODEL env var"
284
+ param-output="string:optional:Variable to store result"
285
+ param-context="string:optional:Context variable for RAG"
286
+ param-save-dialog="string:optional:Enable dialog persistence|true|false"
287
+ param-execute="string:optional:Execute generated code immediately|true|false"
288
+ param-temperature="string:optional:Sampling temperature (default: 1.0)"
289
+ param-maxTokens="string:optional:Maximum tokens to generate (default: 4096)"
290
+ param-noextra="string:optional:Skip extra context injection|true|false"
291
+ param-validate="string:optional:Validate generated DIRAC tags|true|false"
292
+ param-autocorrect="string:optional:Auto-fix validation errors|true|false"
293
+ param-max-retries="string:optional:Validation retry attempts (default: 0)"
294
+ param-feedback="string:optional:Enable validation feedback loop|true|false"
295
+ param-max-iterations="string:optional:Max feedback iterations (default: 3)"
296
+ param-on-iteration="string:optional:Callback subroutine invoked after each iteration"
297
+ param-replace-tick="string:optional:Replace backticks in code|true|false">
298
+ <!-- Generate DIRAC code via LLM -->
299
+ <!-- Supports Anthropic, OpenAI, Ollama, Custom providers -->
300
+ <!-- provider attribute allows per-call provider switching -->
301
+ <!-- save-dialog=true enables conversation persistence with 85% token savings -->
302
+ <!-- execute=true runs generated code immediately -->
303
+ <!-- validate/autocorrect for syntax checking and repair -->
304
+ <!-- Generated subroutines auto-dumped to ~/.dirac/lib/TIMESTAMP/ -->
305
+ <!-- on-iteration: callback for monitoring LLM feedback loops -->
306
+ <!-- Callback has access to __llm_iteration__, __llm_max_iterations__, __llm_dialog__ -->
307
+ <!-- Set __llm_stop_requested__="true" in callback to stop iteration early -->
308
+ </subroutine>
309
+
310
+ <subroutine name="load-context"
311
+ description="Load subroutine definitions as LLM context"
312
+ param-limit="string:optional:Maximum subroutines to include"
313
+ param-import="string:optional:Also import subroutines (default: true)|true|false"
314
+ param-output="string:optional:Variable to store context text">
315
+ <!-- Prepare RAG context for LLM -->
316
+ <!-- Fetches subroutine definitions with metadata -->
317
+ <!-- Use with context="ctx" in <llm> tag -->
318
+ <!-- Enables knowledge-base enhanced prompts -->
319
+ </subroutine>
320
+
321
+ <!-- ============================================================
322
+ EXCEPTION HANDLING
323
+ ============================================================ -->
324
+
325
+ <subroutine name="try"
326
+ description="Establish exception boundary">
327
+ <!-- <try> -->
328
+ <!-- <defvar name="x" value="${undefined}" /> -->
329
+ <!-- </try> -->
330
+ <!-- <catch name="exception"><output>Error caught</output></catch> -->
331
+ <!-- Use with <catch> to handle errors -->
332
+ </subroutine>
333
+
334
+ <subroutine name="catch"
335
+ description="Catch exceptions by name"
336
+ param-name="string:optional:Exception name to catch (default: exception)">
337
+ <!-- Catches exceptions between current position and last <try> boundary -->
338
+ </subroutine>
339
+
340
+ <subroutine name="throw"
341
+ description="Throw named exception"
342
+ param-name="string:optional:Exception name (default: exception)">
343
+ <!-- Children become exception payload -->
344
+ <!-- Caught by matching <catch> in enclosing <try> -->
345
+ </subroutine>
346
+
347
+ <subroutine name="exception"
348
+ description="Access caught exception content"
349
+ param-name="string:optional:Exception variable name">
350
+ </subroutine>
351
+
352
+ <!-- ============================================================
353
+ XML & DATA MANIPULATION
354
+ ============================================================ -->
355
+
356
+ <subroutine name="attr"
357
+ description="Extract attribute from XML element"
358
+ param-name="string:required:Attribute name to extract"
359
+ param-from="string:required:Variable containing XML element">
360
+ <!-- Used with <foreach> to access iteration item properties -->
361
+ <!-- Element stored as variable from foreach as="varname" -->
362
+ </subroutine>
363
+
364
+ <!-- ============================================================
365
+ SCHEDULING & BACKGROUND TASKS
366
+ ============================================================ -->
367
+
368
+ <subroutine name="schedule"
369
+ description="Run tasks on interval without blocking"
370
+ param-interval="string:required:Seconds between executions"
371
+ param-name="string:optional:Task identifier for logging">
372
+ <!-- Task runs every N seconds -->
373
+ <!-- Continues until shell/program exit -->
374
+ <!-- Replaces existing task with same name -->
375
+ </subroutine>
376
+
377
+ <subroutine name="cron"
378
+ description="Run tasks on cron schedule without blocking"
379
+ param-time="string:required:Cron expression (minute hour day month weekday)"
380
+ param-name="string:optional:Job identifier for logging">
381
+ <!-- Cron expression examples: -->
382
+ <!-- "* * * * *" - Every minute -->
383
+ <!-- "0 9 * * *" - Every day at 9 AM -->
384
+ <!-- "*/5 * * * *" - Every 5 minutes -->
385
+ <!-- "0 0 * * 1" - Every Monday at midnight -->
386
+ <!-- "0 8-17 * * 1-5" - Every hour 8AM-5PM, Monday-Friday -->
387
+ <!-- Task continues until shell/program exit -->
388
+ <!-- Replaces existing job with same name -->
389
+ </subroutine>
390
+
391
+ <subroutine name="run-at"
392
+ description="Run task once at future time without blocking"
393
+ param-time="string:required:When to execute"
394
+ param-name="string:optional:Run identifier for logging">
395
+ <!-- Executes task once at specified future time, then removes itself -->
396
+ <!-- Time formats (all relative to current moment): -->
397
+ <!-- "+30" = 30 seconds from now -->
398
+ <!-- "+5m" = 5 minutes from now (300 seconds) -->
399
+ <!-- "+2h" = 2 hours from now (7200 seconds) -->
400
+ <!-- "+7d" = 7 days from now (604800 seconds) -->
401
+ <!-- "2026-04-07T15:30:00" = Absolute ISO timestamp -->
402
+ <!-- "1712502600000" = Unix timestamp in milliseconds -->
403
+ <!-- Non-blocking: returns immediately after scheduling -->
404
+ <!-- Error if time is in the past -->
405
+ <!-- Replaces existing run with same name -->
406
+ </subroutine>
407
+
408
+ <!-- ============================================================
409
+ MONGODB (if dirac-mongodb package installed)
410
+ ============================================================ -->
411
+
412
+ <subroutine name="mongodb"
413
+ description="MongoDB database operations"
414
+ param-connection="string:required:MongoDB connection string"
415
+ param-database="string:required:Database name"
416
+ param-collection="string:required:Collection name"
417
+ param-operation="string:required:Operation to perform|insert|find|update|delete"
418
+ param-query="string:optional:Query document (JSON)"
419
+ param-document="string:optional:Document to insert/update (JSON)"
420
+ param-output="string:optional:Variable to store results">
421
+ <!-- Query and document parameters use JSON format -->
422
+ </subroutine>
423
+
424
+ <!-- ============================================================
425
+ DEBUGGING & TESTING
426
+ ============================================================ -->
427
+
428
+ <subroutine name="tag-check"
429
+ description="Validate tag name availability">
430
+ <!-- Used during subroutine validation -->
431
+ </subroutine>
432
+
433
+ <!-- ============================================================
434
+ USAGE NOTES
435
+ ============================================================
436
+
437
+ VARIABLE SUBSTITUTION:
438
+ - In attributes: Use $varname or ${varname}
439
+ - In text: Use ${varname}
440
+ - Example: <output>Hello $name, result is ${result}</output>
441
+
442
+ PARAMETER DOCUMENTATION:
443
+ - Use param-* attributes to document subroutine parameters
444
+ - Format: param-NAME="type:required|optional:description:example"
445
+ - Types: string, number, boolean, flag, any
446
+ - Enum: param-NAME="type:required:desc:example:opt1|opt2|opt3"
447
+
448
+ NATIVE VS. SUBROUTINE EXECUTION:
449
+ - Interpreter checks native tags FIRST (switch statement)
450
+ - Then checks user-defined subroutines (getSubroutine)
451
+ - These interface definitions never execute - documentation only
452
+
453
+ LOADING THIS FILE:
454
+ - Import in shell init: <import src="~/.dirac/lib/native-tags.di" />
455
+ - Or load on demand: <import src="path/to/native-tags.di" />
456
+ - Native tags will appear in :subs list with documentation
457
+
458
+ EXTENDING:
459
+ - Add new native tags to src/tags/ directory
460
+ - Update this file with stub definition
461
+ - Follow param-* convention for parameter docs
462
+
463
+ ============================================================ -->
@@ -0,0 +1,20 @@
1
+ # Dirac Shell Init Script
2
+ # This script runs automatically when the shell starts
3
+
4
+ # Auto-index user's saved subroutines for search functionality
5
+ <index-subroutines path="~/.dirac/lib/user" />
6
+
7
+ # Uncomment to load native tags for tab completion:
8
+ |import src="dirac/lib/native-tags.di" >
9
+
10
+ |import src="dirac/lib/ai.di" >
11
+
12
+ # Define some useful helper subroutines
13
+ #<hello |
14
+ # |output>Hello from init script!
15
+
16
+ #<greet name=String |
17
+ # |output>Hello, |variable name=name>!
18
+
19
+ # Uncomment to see available subroutines on startup
20
+ #|list-subroutines format=braket>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,8 @@
13
13
  ".": "./dist/index.js"
14
14
  },
15
15
  "files": [
16
- "dist/"
16
+ "dist/",
17
+ "lib/"
17
18
  ],
18
19
  "scripts": {
19
20
  "dev": "tsx src/cli.ts",