dirac-lang 0.1.2

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.
Files changed (110) hide show
  1. package/.env.example +8 -0
  2. package/COMMUNITY.md +465 -0
  3. package/LIBRARIES.md +172 -0
  4. package/NAMESPACES.md +366 -0
  5. package/PROMOTION.md +257 -0
  6. package/QUICKSTART-LIBRARY.md +93 -0
  7. package/README.md +257 -0
  8. package/config.yml +6 -0
  9. package/config.yml.openai +4 -0
  10. package/dirac-http/examples/demo.di +9 -0
  11. package/dirac-http/lib/index.di +12 -0
  12. package/dist/chunk-NDIRTD3D.js +217 -0
  13. package/dist/chunk-S625X7ME.js +1071 -0
  14. package/dist/cli.d.ts +1 -0
  15. package/dist/cli.js +261 -0
  16. package/dist/index.d.ts +144 -0
  17. package/dist/index.js +22 -0
  18. package/dist/session-4QG7OERD.js +42 -0
  19. package/examples/add-demo.di +74 -0
  20. package/examples/add.bk +11 -0
  21. package/examples/advanced-math-demo.di +53 -0
  22. package/examples/calculator.di +32 -0
  23. package/examples/comprehensive.bk +29 -0
  24. package/examples/defvar-variable-demo.di +18 -0
  25. package/examples/direct-call.di +17 -0
  26. package/examples/disk-analysis.di +16 -0
  27. package/examples/executable-hello.di +7 -0
  28. package/examples/execute-demo.di +38 -0
  29. package/examples/file-manager.di +77 -0
  30. package/examples/file-stats.di +18 -0
  31. package/examples/hello.bk +1 -0
  32. package/examples/hello.di +5 -0
  33. package/examples/import-demo.di +31 -0
  34. package/examples/inline-test.bk +7 -0
  35. package/examples/lib/advanced-math.di +81 -0
  36. package/examples/lib/fileops.di +26 -0
  37. package/examples/lib/math.di +25 -0
  38. package/examples/lib/mongodb.di +96 -0
  39. package/examples/llm-agent.di +32 -0
  40. package/examples/llm-basic.di +12 -0
  41. package/examples/llm-command-no-exec.di +13 -0
  42. package/examples/llm-command.di +13 -0
  43. package/examples/llm-complex.di +141 -0
  44. package/examples/llm-recursive.di +31 -0
  45. package/examples/llm-reflection-test.di +19 -0
  46. package/examples/llm-subs.di +132 -0
  47. package/examples/llm-use-subs.di +6 -0
  48. package/examples/loop.di +12 -0
  49. package/examples/math-test.di +22 -0
  50. package/examples/mongodb-count-events.di +8 -0
  51. package/examples/mongodb-import-demo.di +25 -0
  52. package/examples/mongodb-simple-test.di +18 -0
  53. package/examples/nl-agent.di +47 -0
  54. package/examples/parameters-demo.di +68 -0
  55. package/examples/params-test.di +10 -0
  56. package/examples/recipe-chain.di +38 -0
  57. package/examples/recursive-llm.di +44 -0
  58. package/examples/sample-library/README.md +152 -0
  59. package/examples/sample-library/examples/demo.di +34 -0
  60. package/examples/sample-library/lib/index.di +65 -0
  61. package/examples/sample-library/package.json +31 -0
  62. package/examples/seamless.di +45 -0
  63. package/examples/shell-test.bk +10 -0
  64. package/examples/simple-import.di +13 -0
  65. package/examples/simple-recursive.di +26 -0
  66. package/examples/story-builder.di +45 -0
  67. package/examples/subroutine.di +23 -0
  68. package/examples/system-llm.di +21 -0
  69. package/examples/system-simple.di +3 -0
  70. package/examples/system-test.di +13 -0
  71. package/examples/task-assistant.di +27 -0
  72. package/examples/test-parameters.di +50 -0
  73. package/examples/two-styles.di +28 -0
  74. package/examples/var-debug.di +6 -0
  75. package/examples/var-inline.di +4 -0
  76. package/examples/var-test2.di +6 -0
  77. package/examples/variable-simple.di +16 -0
  78. package/examples/variable-test.di +22 -0
  79. package/filePath +1 -0
  80. package/greeting.txt +1 -0
  81. package/package.json +41 -0
  82. package/src/cli.ts +118 -0
  83. package/src/index.ts +33 -0
  84. package/src/llm/ollama.ts +58 -0
  85. package/src/runtime/braket-parser.ts +234 -0
  86. package/src/runtime/interpreter.ts +135 -0
  87. package/src/runtime/parser.ts +151 -0
  88. package/src/runtime/session.ts +228 -0
  89. package/src/tags/assign.ts +37 -0
  90. package/src/tags/call.ts +156 -0
  91. package/src/tags/defvar.ts +56 -0
  92. package/src/tags/eval.ts +68 -0
  93. package/src/tags/execute.ts +52 -0
  94. package/src/tags/expr.ts +128 -0
  95. package/src/tags/if.ts +58 -0
  96. package/src/tags/import.ts +66 -0
  97. package/src/tags/index.ts +37 -0
  98. package/src/tags/llm.ts +207 -0
  99. package/src/tags/loop.ts +43 -0
  100. package/src/tags/mongodb.ts +70 -0
  101. package/src/tags/output.ts +23 -0
  102. package/src/tags/parameters.ts +79 -0
  103. package/src/tags/require_module.ts +19 -0
  104. package/src/tags/subroutine.ts +52 -0
  105. package/src/tags/system.ts +70 -0
  106. package/src/tags/variable.ts +25 -0
  107. package/src/types/index.ts +101 -0
  108. package/src/utils/llm-adapter.ts +113 -0
  109. package/tools/create-library.sh +175 -0
  110. package/tsconfig.json +19 -0
package/NAMESPACES.md ADDED
@@ -0,0 +1,366 @@
1
+ # Tag Namespace Conflict Resolution
2
+
3
+ ## The Problem
4
+
5
+ ```xml
6
+ <!-- Both dirac-http and dirac-rest define GET -->
7
+ <import src="./node_modules/dirac-http/lib/index.di"/>
8
+ <import src="./node_modules/dirac-rest/lib/index.di"/>
9
+
10
+ <GET url="..."/> <!-- Which GET? Conflict! -->
11
+ ```
12
+
13
+ ## Solution Options
14
+
15
+ ### Option 1: Library Prefixes (Convention)
16
+
17
+ Libraries use consistent prefixes:
18
+
19
+ ```xml
20
+ <!-- dirac-http uses HTTP_ prefix -->
21
+ <subroutine name="HTTP_GET">...</subroutine>
22
+ <subroutine name="HTTP_POST">...</subroutine>
23
+
24
+ <!-- dirac-db uses DB_ prefix -->
25
+ <subroutine name="DB_QUERY">...</subroutine>
26
+ <subroutine name="DB_INSERT">...</subroutine>
27
+ ```
28
+
29
+ **Pros:**
30
+ - Simple, works today
31
+ - No interpreter changes needed
32
+ - Clear ownership: `HTTP_GET`, `DB_QUERY`
33
+ - Searchable: "HTTP_*" shows all HTTP functions
34
+
35
+ **Cons:**
36
+ - Verbose: `<HTTP_GET/>` vs `<GET/>`
37
+ - Convention-based (not enforced)
38
+
39
+ **Recommendation: Use this NOW** ✅
40
+
41
+ ### Option 2: Import Aliases (Future Feature)
42
+
43
+ ```xml
44
+ <!-- Import with alias -->
45
+ <import src="./node_modules/dirac-http/lib/index.di" as="http"/>
46
+ <import src="./node_modules/dirac-rest/lib/index.di" as="rest"/>
47
+
48
+ <!-- Use with alias -->
49
+ <http:GET url="..."/>
50
+ <rest:GET endpoint="..."/>
51
+ ```
52
+
53
+ **Pros:**
54
+ - Clean syntax
55
+ - Explicit disambiguation
56
+ - User controls naming
57
+
58
+ **Cons:**
59
+ - Requires interpreter changes
60
+ - XML namespace complexity
61
+
62
+ ### Option 3: Scoped Imports (Future Feature)
63
+
64
+ ```xml
65
+ <!-- Import specific tags -->
66
+ <import src="dirac-http" names="GET as HTTP_GET, POST as HTTP_POST"/>
67
+ <import src="dirac-rest" names="GET as REST_GET"/>
68
+
69
+ <HTTP_GET url="..."/>
70
+ <REST_GET endpoint="..."/>
71
+ ```
72
+
73
+ **Pros:**
74
+ - Explicit control
75
+ - No unused tags loaded
76
+ - User-defined aliases
77
+
78
+ **Cons:**
79
+ - Verbose import statements
80
+ - Requires interpreter support
81
+
82
+ ### Option 4: Implicit Namespacing (Future Feature)
83
+
84
+ ```xml
85
+ <import src="dirac-http" scope="http"/>
86
+
87
+ <!-- Tags automatically prefixed in scope -->
88
+ <http>
89
+ <GET url="..."/> <!-- Resolves to http:GET -->
90
+ <POST url="..."/> <!-- Resolves to http:POST -->
91
+ </http>
92
+ ```
93
+
94
+ **Pros:**
95
+ - Clean usage
96
+ - Scoped context
97
+
98
+ **Cons:**
99
+ - Complex to implement
100
+ - Unusual XML pattern
101
+
102
+ ### Option 5: Last Import Wins (Simple)
103
+
104
+ ```xml
105
+ <import src="dirac-http/lib/index.di"/>
106
+ <import src="dirac-rest/lib/index.di"/>
107
+
108
+ <GET url="..."/> <!-- Uses dirac-rest's GET (last imported) -->
109
+ ```
110
+
111
+ **Pros:**
112
+ - No changes needed
113
+ - Works today
114
+
115
+ **Cons:**
116
+ - Unpredictable behavior
117
+ - Hidden conflicts
118
+ - Debugging nightmare
119
+
120
+ ❌ **Not recommended**
121
+
122
+ ## Recommended Approach
123
+
124
+ ### Phase 1: Convention (Now)
125
+
126
+ **Establish naming conventions:**
127
+
128
+ ```
129
+ Library Prefix Convention:
130
+ - dirac-http → HTTP_* (HTTP_GET, HTTP_POST)
131
+ - dirac-db → DB_* (DB_QUERY, DB_CONNECT)
132
+ - dirac-crypto → CRYPTO_* (CRYPTO_SHA256, CRYPTO_AES)
133
+ - dirac-string → STR_* (STR_UPPER, STR_LOWER)
134
+ - dirac-math → MATH_* (MATH_SQRT, MATH_SIN)
135
+ - dirac-json → JSON_* (JSON_PARSE, JSON_STRINGIFY)
136
+ - dirac-xml → XML_* (XML_PARSE, XML_QUERY)
137
+ ```
138
+
139
+ **Document in COMMUNITY.md:**
140
+ ```markdown
141
+ ## Naming Convention
142
+
143
+ All library tags MUST use a prefix based on the library name:
144
+
145
+ - Package name: `dirac-[domain]`
146
+ - Tag prefix: `[DOMAIN]_`
147
+ - Example: `dirac-http` → `HTTP_GET`, `HTTP_POST`
148
+
149
+ This prevents naming conflicts between libraries.
150
+ ```
151
+
152
+ **Enforce in template:**
153
+ ```xml
154
+ <!-- lib/index.di -->
155
+ <dirac>
156
+
157
+ <!-- Replace MYLIB with your library name (uppercase) -->
158
+ <subroutine name="MYLIB_FUNCTION1">
159
+ ...
160
+ </subroutine>
161
+
162
+ <subroutine name="MYLIB_FUNCTION2">
163
+ ...
164
+ </subroutine>
165
+
166
+ </dirac>
167
+ ```
168
+
169
+ ### Phase 2: Import Aliases (Future)
170
+
171
+ Add `as` attribute to `<import>`:
172
+
173
+ ```xml
174
+ <import src="./node_modules/dirac-http/lib/index.di" as="http"/>
175
+
176
+ <!-- Interpreter translates http:GET to HTTP_GET internally -->
177
+ <http:GET url="..."/>
178
+ ```
179
+
180
+ **Implementation:**
181
+ 1. Parse `as` attribute in import tag
182
+ 2. Store alias → library mapping in session
183
+ 3. When resolving tags, check if tag contains `:`
184
+ 4. If yes, look up alias and resolve to prefixed name
185
+ 5. Fall back to direct name if no alias
186
+
187
+ ### Phase 3: Module System (Later)
188
+
189
+ Full module system with explicit imports:
190
+
191
+ ```xml
192
+ <module>
193
+ <import from="dirac-http">
194
+ <use name="GET" as="fetch"/>
195
+ <use name="POST"/>
196
+ </import>
197
+
198
+ <import from="dirac-db">
199
+ <use name="QUERY"/>
200
+ </import>
201
+ </module>
202
+
203
+ <fetch url="..."/> <!-- dirac-http's GET -->
204
+ <POST url="..."/> <!-- dirac-http's POST -->
205
+ <QUERY sql="..."/> <!-- dirac-db's QUERY -->
206
+ ```
207
+
208
+ ## Conflict Detection Tool
209
+
210
+ Create a tool to check for conflicts:
211
+
212
+ ```bash
213
+ dirac check-conflicts
214
+
215
+ # Output:
216
+ # Warning: Tag 'GET' defined in multiple libraries:
217
+ # - dirac-http (HTTP_GET)
218
+ # - dirac-rest (REST_GET)
219
+ # Recommendation: Use prefixed names
220
+ ```
221
+
222
+ ## Real-World Examples
223
+
224
+ ### Example 1: HTTP + Database
225
+
226
+ ```xml
227
+ <import src="dirac-http"/>
228
+ <import src="dirac-db"/>
229
+
230
+ <!-- Clear ownership with prefixes -->
231
+ <HTTP_GET url="https://api.example.com/users"/>
232
+ <DB_INSERT table="users" data="..."/>
233
+ ```
234
+
235
+ ### Example 2: Multiple String Libraries
236
+
237
+ ```xml
238
+ <import src="dirac-string"/>
239
+ <import src="dirac-regex"/>
240
+
241
+ <!-- No conflict -->
242
+ <STR_UPPER text="hello"/>
243
+ <REGEX_MATCH pattern="[0-9]+" text="abc123"/>
244
+ ```
245
+
246
+ ### Example 3: Conflict Scenario (BAD)
247
+
248
+ ```xml
249
+ <!-- Both define PARSE -->
250
+ <import src="dirac-json"/>
251
+ <import src="dirac-xml"/>
252
+
253
+ <PARSE data="..."/> <!-- Which one? -->
254
+ ```
255
+
256
+ **Solution:**
257
+ ```xml
258
+ <import src="dirac-json"/>
259
+ <import src="dirac-xml"/>
260
+
261
+ <JSON_PARSE data='{"key":"value"}'/>
262
+ <XML_PARSE data="<root>...</root>"/>
263
+ ```
264
+
265
+ ## Standard Library Naming
266
+
267
+ Core Dirac tags (built-in) have no prefix:
268
+ - `<output>` - Built-in
269
+ - `<eval>` - Built-in
270
+ - `<if>` - Built-in
271
+ - `<loop>` - Built-in
272
+
273
+ All library tags MUST have prefixes:
274
+ - `<HTTP_GET>` - From dirac-http
275
+ - `<DB_QUERY>` - From dirac-db
276
+
277
+ This makes it clear what's built-in vs library.
278
+
279
+ ## Migration Path
280
+
281
+ For libraries already published without prefixes:
282
+
283
+ 1. **Deprecation warning:**
284
+ ```xml
285
+ <subroutine name="GET">
286
+ <output>⚠️ Warning: GET is deprecated. Use HTTP_GET instead.</output>
287
+ <!-- ... actual implementation ... -->
288
+ </subroutine>
289
+ ```
290
+
291
+ 2. **Alias old names:**
292
+ ```xml
293
+ <!-- New prefixed name -->
294
+ <subroutine name="HTTP_GET">
295
+ ...
296
+ </subroutine>
297
+
298
+ <!-- Old name calls new name -->
299
+ <subroutine name="GET">
300
+ <HTTP_GET>
301
+ <parameters select="*"/>
302
+ </HTTP_GET>
303
+ </subroutine>
304
+ ```
305
+
306
+ 3. **Semver major version:**
307
+ - v1.x.x: `GET` (old, no prefix)
308
+ - v2.0.0: `HTTP_GET` (new, with prefix)
309
+ - v2.0.0: `GET` marked deprecated but still works
310
+
311
+ ## Validation Tool
312
+
313
+ Add to `create-library.sh`:
314
+
315
+ ```bash
316
+ # Check that all subroutines use proper prefix
317
+ LIBNAME_UPPER=$(echo "$LIBNAME" | tr '[:lower:]' '[:upper:]')
318
+ echo "Remember: All tags should be prefixed with ${LIBNAME_UPPER}_"
319
+ echo "Example: ${LIBNAME_UPPER}_FUNCTION"
320
+ ```
321
+
322
+ Add lint command:
323
+ ```bash
324
+ dirac lint lib/index.di
325
+
326
+ # Checks:
327
+ # ✓ All subroutine names use library prefix
328
+ # ✗ Found unprefixed subroutine: GET
329
+ # Should be: HTTP_GET
330
+ ```
331
+
332
+ ## Documentation
333
+
334
+ Update all docs to show prefixed names:
335
+
336
+ **Good:**
337
+ ```xml
338
+ <import src="dirac-http"/>
339
+ <HTTP_GET url="https://example.com"/>
340
+ ```
341
+
342
+ **Bad:**
343
+ ```xml
344
+ <import src="dirac-http"/>
345
+ <GET url="https://example.com"/> <!-- Don't do this! -->
346
+ ```
347
+
348
+ ## Summary
349
+
350
+ **Now (Phase 1):**
351
+ - ✅ Use prefix convention: `LIBNAME_FUNCTION`
352
+ - ✅ Document in community guidelines
353
+ - ✅ Update library template
354
+ - ✅ Update all examples
355
+
356
+ **Later (Phase 2):**
357
+ - Add `as` attribute to imports
358
+ - Support `prefix:TAG` syntax
359
+ - Backward compatible
360
+
361
+ **Future (Phase 3):**
362
+ - Full module system
363
+ - Explicit named imports
364
+ - Conflict detection tools
365
+
366
+ This gives us a working solution today while leaving room for syntactic sugar later.
package/PROMOTION.md ADDED
@@ -0,0 +1,257 @@
1
+ # Dirac: The Agentic Recursive Language for LLM-Augmented Computing
2
+
3
+ ## What is Dirac?
4
+
5
+ Dirac is a **declarative execution language** specifically designed for the AI era, where large language models (LLMs) are not just tools, but active participants in code execution. It's named after physicist Paul Dirac and his bra-ket notation, reflecting its dual nature: bridging human-readable declarations with machine execution.
6
+
7
+ ## The Recursive LLM Paradigm
8
+
9
+ Traditional programming languages separate code from AI. You write code, then separately call an LLM API. Dirac **eliminates this boundary**:
10
+
11
+ ```xml
12
+ <llm execute="true">
13
+ Create a Dirac program that lists all .txt files,
14
+ reads the first one, and summarizes it.
15
+ </llm>
16
+ ```
17
+
18
+ The LLM doesn't just respond—it **generates Dirac code that immediately executes**. The generated code can itself call LLMs, creating a **recursive chain** where AI and execution seamlessly interweave.
19
+
20
+ ## Agentic by Design
21
+
22
+ Dirac treats LLMs as **autonomous agents** that can:
23
+
24
+ - **Generate executable code** on-the-fly
25
+ - **Make decisions** based on runtime data
26
+ - **Invoke system commands** and process their output
27
+ - **Call themselves recursively** to break down complex tasks
28
+ - **Import and compose libraries** for modular problem-solving
29
+
30
+ Example of an agentic workflow:
31
+
32
+ ```xml
33
+ <llm output="fileList">
34
+ <system>ls -la</system>
35
+ Analyze these files and create Dirac code to process them.
36
+ </llm>
37
+
38
+ <execute source="fileList"/> <!-- LLM-generated code runs here -->
39
+ ```
40
+
41
+
42
+ ## Neural-Symbolic AI: Bridging Symbolic Reasoning and Neural Networks
43
+
44
+ Dirac is not just agentic—it’s also a natural fit for **neural-symbolic AI**. Its bra/ket-inspired knowledge representation allows you to express and connect symbolic logic and neural computation in a unified language.
45
+
46
+ **Example: Aristotle’s Syllogism**
47
+
48
+ - All humans are mortal.
49
+ - Socrates is a human.
50
+ - Therefore, Socrates is mortal.
51
+
52
+ In Dirac’s bra/ket notation, this can be represented as:
53
+ - `|mortal⟩⟨human|` (all humans are mortal)
54
+ - `|human⟩⟨Socrates|` (Socrates is a human)
55
+
56
+ When you ask `|Socrates⟩`, chaining these together yields `|mortal⟩`.
57
+
58
+ From a **neural network** perspective, these bra/ket pairs are like matrices (or tensors), and the input `|Socrates⟩` is a vector. The network applies transformations—possibly nonlinear—to produce an output.
59
+
60
+ From a **symbolic AI** perspective, these are like Dirac subroutines:
61
+ ```xml
62
+ <subroutine name="human">
63
+ <mortal/>
64
+ </subroutine>
65
+ ```
66
+ Or, in Dirac’s shorthand:
67
+ ```
68
+ <human|
69
+ |mortal>
70
+ ```
71
+
72
+ **Dirac bridges these worlds:**
73
+ - As a symbolic language, it lets you define and chain logical relationships explicitly.
74
+ - As a bridge to neural networks, it enables LLMs and other neural models to participate in these chains, providing generative, nonlinear reasoning when needed.
75
+
76
+ Dirac is the missing link for building systems where **symbolic structure and neural intelligence work together**—making it ideal for the next generation of explainable, powerful AI.
77
+
78
+ The LLM sees real system state, generates appropriate code, and that code executes—all in one flow.
79
+
80
+ ## Key Features
81
+
82
+ ### 1. **Seamless LLM Integration**
83
+ LLMs are first-class citizens, not afterthoughts:
84
+ ```xml
85
+ <llm>What is 2+2?</llm> <!-- Direct output -->
86
+ <llm output="result">Calculate 2+2</llm> <!-- Store in variable -->
87
+ <llm execute="true">Write a loop</llm> <!-- Generate and execute code -->
88
+ ```
89
+
90
+ ### 2. **Declarative Simplicity**
91
+ Express **what** you want, not **how** to do it:
92
+ ```xml
93
+ <system>df -h</system> <!-- Run shell command -->
94
+ <llm>Summarize the disk usage above</llm>
95
+ ```
96
+
97
+ ### 3. **Recursive Composition**
98
+ Programs can generate programs:
99
+ ```xml
100
+ <subroutine name="analyze">
101
+ <llm execute="true">
102
+ Generate code to analyze <variable name="data"/>
103
+ </llm>
104
+ </subroutine>
105
+ ```
106
+
107
+ ### 4. **Bra-Ket Notation** (Optional Compact Syntax)
108
+ Inspired by quantum mechanics, our `.bk` format reduces verbosity:
109
+
110
+ **XML (.di):**
111
+ ```xml
112
+ <subroutine name="greet">
113
+ <parameters select="@name"/>
114
+ <output>Hello, <variable name="name"/>!</output>
115
+ </subroutine>
116
+ <greet name="World"/>
117
+ ```
118
+
119
+ **Bra-Ket (.bk):**
120
+ ```
121
+ <greet|
122
+ |parameters select=@name>
123
+ |output>Hello, |variable name=name>!
124
+
125
+ |greet name=World>
126
+ ```
127
+
128
+ ### 5. **Library Ecosystem**
129
+ Import and compose functionality with namespace-safe prefixes:
130
+ ```xml
131
+ <import src="dirac-http"/>
132
+ <HTTP_GET url="https://api.example.com"/>
133
+
134
+ <import src="dirac-database"/>
135
+ <DB_QUERY>SELECT * FROM users</DB_QUERY>
136
+ ```
137
+
138
+ ## Real-World Use Cases
139
+
140
+ ### System Administration
141
+ ```xml
142
+ <llm execute="true">
143
+ <system>docker ps</system>
144
+ Analyze these containers and create Dirac code to
145
+ restart any that are unhealthy.
146
+ </llm>
147
+ ```
148
+
149
+ ### Data Analysis
150
+ ```xml
151
+ <llm output="analysis">
152
+ <system>cat data.csv | head -20</system>
153
+ What patterns do you see? Generate Dirac code to process the full file.
154
+ </llm>
155
+ <execute source="analysis"/>
156
+ ```
157
+
158
+ ### Task Automation
159
+ ```xml
160
+ <llm execute="true">
161
+ I need to backup all .js files modified today to ~/backup.
162
+ Write Dirac code to do this.
163
+ </llm>
164
+ ```
165
+
166
+ ### Multi-Agent Workflows
167
+ ```xml
168
+ <llm output="step1" execute="true">
169
+ Task: Analyze logs in /var/log. Generate code for this step.
170
+ </llm>
171
+
172
+ <llm execute="true">
173
+ Previous step output: <variable name="step1"/>
174
+ Now generate code to summarize findings and email the report.
175
+ </llm>
176
+ ```
177
+
178
+ ## Why "Recursive" Matters
179
+
180
+ In traditional programming, recursion means a function calling itself. In Dirac, **the entire execution model is recursive**:
181
+
182
+ 1. **Code generates code**: LLMs output Dirac programs
183
+ 2. **Programs invoke LLMs**: Those programs can ask LLMs for more code
184
+ 3. **Infinite depth**: This can continue to arbitrary depths (with safety limits)
185
+ 4. **Context flows**: Each layer has access to results from previous layers
186
+
187
+ This creates a **self-extending** execution environment where the boundary between "prompt" and "program" dissolves.
188
+
189
+ ## Installation
190
+
191
+ ```bash
192
+ npm install -g dirac-lang
193
+ ```
194
+
195
+ ## Quick Start
196
+
197
+ **hello.di:**
198
+ ```xml
199
+ <dirac>
200
+ <output>Hello, World!</output>
201
+ </dirac>
202
+ ```
203
+
204
+ **Run it:**
205
+ ```bash
206
+ dirac hello.di
207
+ ```
208
+
209
+ **With LLM (requires API key):**
210
+ ```bash
211
+ export ANTHROPIC_API_KEY=your-key
212
+ echo '<dirac><llm>Write a haiku about code</llm></dirac>' | dirac -
213
+ ```
214
+
215
+ ## Philosophy
216
+
217
+ Dirac embraces three principles:
218
+
219
+ 1. **LLMs are co-pilots, not tools**: They execute alongside your code, not as external services
220
+ 2. **Declarative over imperative**: Say what you want, let AI figure out how
221
+ 3. **Composable intelligence**: Small, reusable pieces combine into powerful workflows
222
+
223
+ ## Future Vision
224
+
225
+ We're building toward a world where:
226
+ - **Natural language prompts** compile to executable Dirac
227
+ - **AI-generated libraries** extend functionality on-demand
228
+ - **Self-improving programs** refactor themselves based on execution patterns
229
+ - **Multi-model orchestration** lets different LLMs collaborate on subtasks
230
+
231
+ ## Community
232
+
233
+ - **GitHub**: [wangzhi63/dirac](https://github.com/wangzhi63/dirac)
234
+ - **npm**: [dirac-lang](https://www.npmjs.com/package/dirac-lang)
235
+ - **License**: MIT
236
+ - **Status**: Active development (v0.1.0)
237
+
238
+ ## Join the Movement
239
+
240
+ Dirac is more than a language—it's a **paradigm shift** in how we think about code and AI. If you believe that:
241
+
242
+ - Programming should be more **declarative**
243
+ - LLMs should be **execution partners**, not API endpoints
244
+ - Code should **generate code** dynamically
245
+ - The future is **agentic** and **recursive**
246
+
247
+ ...then Dirac is for you.
248
+
249
+ **Start building the future today.**
250
+
251
+ ```bash
252
+ npm install -g dirac-lang
253
+ ```
254
+
255
+ ---
256
+
257
+ *"In the quantum realm, a bra meets a ket to produce reality. In Dirac, a declaration meets an LLM to produce execution."*
@@ -0,0 +1,93 @@
1
+ # Quick Start: Publishing Your First Dirac Library
2
+
3
+ ## 5-Minute Guide
4
+
5
+ ### 1. Create Your Library (2 min)
6
+
7
+ ```bash
8
+ mkdir dirac-mylibrary
9
+ cd dirac-mylibrary
10
+ ```
11
+
12
+ Create `lib/index.di`:
13
+ ```xml
14
+ <dirac>
15
+ <subroutine name="HELLO">
16
+ <eval>
17
+ const caller = getParams();
18
+ const name = caller.attributes.name || 'World';
19
+ console.log(`Hello, ${name}!`);
20
+ </eval>
21
+ </subroutine>
22
+ </dirac>
23
+ ```
24
+
25
+ ### 2. Add package.json (1 min)
26
+
27
+ ```bash
28
+ npm init -y
29
+ ```
30
+
31
+ Edit to add:
32
+ ```json
33
+ {
34
+ "name": "dirac-mylibrary",
35
+ "main": "lib/index.di",
36
+ "keywords": ["dirac", "hello"]
37
+ }
38
+ ```
39
+
40
+ ### 3. Test It (1 min)
41
+
42
+ Create `test.di`:
43
+ ```xml
44
+ <dirac>
45
+ <import src="./lib/index.di"/>
46
+ <HELLO name="Alice"/>
47
+ </dirac>
48
+ ```
49
+
50
+ Run:
51
+ ```bash
52
+ dirac test.di
53
+ ```
54
+
55
+ ### 4. Publish (1 min)
56
+
57
+ ```bash
58
+ npm login
59
+ npm publish
60
+ ```
61
+
62
+ Done! Others can now use:
63
+ ```bash
64
+ npm install dirac-mylibrary
65
+ ```
66
+
67
+ ```xml
68
+ <import src="./node_modules/dirac-mylibrary/lib/index.di"/>
69
+ <HELLO name="World"/>
70
+ ```
71
+
72
+ ## Naming Convention
73
+
74
+ - **dirac-[domain]** - Core functionality (e.g., `dirac-http`, `dirac-crypto`)
75
+ - **@yourorg/dirac-[name]** - Organization packages
76
+ - **dirac-contrib-[name]** - Community contributions
77
+
78
+ ## Where to Announce
79
+
80
+ 1. **npm** - Automatically indexed
81
+ 2. **GitHub** - Tag with `dirac-library` topic
82
+ 3. **Discord/Forum** - #library-showcase channel (coming soon)
83
+ 4. **awesome-dirac** - Submit PR to add your library
84
+ 5. **Twitter/X** - Use #DiracLang hashtag
85
+
86
+ ## Next Steps
87
+
88
+ See [COMMUNITY.md](COMMUNITY.md) for full details on:
89
+ - Quality standards
90
+ - Best practices
91
+ - Testing
92
+ - Documentation
93
+ - Community governance