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/.env.example ADDED
@@ -0,0 +1,8 @@
1
+ # OpenAI API Key (recommended)
2
+ OPENAI_API_KEY=sk-your-key-here
3
+
4
+ # Or Anthropic API Key
5
+ # ANTHROPIC_API_KEY=sk-ant-your-key-here
6
+
7
+ # Default model (optional)
8
+ # DEFAULT_MODEL=gpt-4-turbo-preview
package/COMMUNITY.md ADDED
@@ -0,0 +1,465 @@
1
+ # Dirac Community Library Ecosystem
2
+
3
+ ## Publishing a Library
4
+
5
+ ### Step 1: Create Your Library
6
+
7
+ Create a repository structure:
8
+ ```
9
+ my-dirac-library/
10
+ ├── package.json # npm metadata
11
+ ├── README.md # Documentation
12
+ ├── lib/
13
+ │ ├── main.di # Your subroutines
14
+ │ └── utils.di # Helper functions
15
+ ├── examples/
16
+ │ └── demo.di # Usage examples
17
+ └── tests/
18
+ └── test.di # Tests
19
+ ```
20
+
21
+ ### Step 2: Follow Naming Convention
22
+
23
+ **CRITICAL: Prevent conflicts with prefixes**
24
+
25
+ All library tags MUST use a prefix:
26
+ - Package: `dirac-http` → Prefix: `HTTP_`
27
+ - Package: `dirac-crypto` → Prefix: `CRYPTO_`
28
+ - Example: `<HTTP_GET/>`, `<CRYPTO_SHA256/>`
29
+
30
+ ### Step 3: Add package.json
31
+
32
+ ```json
33
+ {
34
+ "name": "dirac-crypto",
35
+ "version": "1.0.0",
36
+ "description": "Cryptography library for Dirac",
37
+ "main": "lib/main.di",
38
+ "keywords": ["dirac", "crypto", "hash"],
39
+ "author": "Your Name",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/username/dirac-crypto"
44
+ },
45
+ "dirac": {
46
+ "version": ">=0.1.0",
47
+ "exports": {
48
+ "main": "lib/main.di",
49
+ "utils": "lib/utils.di"
50
+ },
51
+ "dependencies": {}
52
+ }
53
+ }
54
+ ```
55
+
56
+ ### Step 3: Publish
57
+
58
+ #### Option A: npm (Recommended)
59
+ ```bash
60
+ npm login
61
+ npm publish
62
+ ```
63
+
64
+ Users install:
65
+ ```bash
66
+ npm install dirac-crypto
67
+ ```
68
+
69
+ Use:
70
+ ```xml
71
+ <import src="./node_modules/dirac-crypto/lib/main.di"/>
72
+ <SHA256 text="hello world"/>
73
+ ```
74
+
75
+ #### Option B: GitHub
76
+ ```bash
77
+ git tag v1.0.0
78
+ git push --tags
79
+ ```
80
+
81
+ Users install:
82
+ ```bash
83
+ npm install github:username/dirac-crypto
84
+ ```
85
+
86
+ #### Option C: Dirac Registry (Future)
87
+ ```bash
88
+ dirac publish
89
+ ```
90
+
91
+ Users install:
92
+ ```bash
93
+ dirac install crypto
94
+ ```
95
+
96
+ Use:
97
+ ```xml
98
+ <import src="@dirac/crypto/main"/>
99
+ ```
100
+
101
+ ## Discovery Mechanisms
102
+
103
+ ### 1. npm with "dirac-" prefix
104
+
105
+ Convention: All Dirac libraries use `dirac-` prefix:
106
+ - `dirac-http` - HTTP client
107
+ - `dirac-db` - Database operations
108
+ - `dirac-ml` - Machine learning
109
+ - `dirac-crypto` - Cryptography
110
+
111
+ Search on npm:
112
+ ```bash
113
+ npm search dirac-
114
+ ```
115
+
116
+ ### 2. GitHub Topics
117
+
118
+ Tag repos with:
119
+ - `dirac`
120
+ - `dirac-library`
121
+ - `mask-language`
122
+
123
+ Browse: https://github.com/topics/dirac-library
124
+
125
+ ### 3. Central Registry Website
126
+
127
+ Create `diraclibs.org`:
128
+ - **Browse** libraries by category
129
+ - **Search** by functionality
130
+ - **Ratings** and downloads
131
+ - **Documentation** for each library
132
+ - **Examples** and tutorials
133
+
134
+ ### 4. CLI Discovery
135
+
136
+ ```bash
137
+ dirac search "http client"
138
+ dirac info dirac-http
139
+ dirac install dirac-http
140
+ ```
141
+
142
+ ## Quality Standards
143
+
144
+ ### Verified Libraries
145
+
146
+ Libraries can be "verified" by passing:
147
+
148
+ 1. **Tests** - Automated test suite
149
+ 2. **Documentation** - README with examples
150
+ 3. **Compatibility** - Works with current Dirac version
151
+ 4. **Security** - No malicious code (automated scan)
152
+ 5. **Community** - Downloads, stars, issues resolved
153
+
154
+ Badge in README:
155
+ ```markdown
156
+ ![Dirac Verified](https://img.shields.io/badge/dirac-verified-green)
157
+ ```
158
+
159
+ ### Library Template
160
+
161
+ Provide starter template:
162
+ ```bash
163
+ dirac create-lib my-library
164
+ ```
165
+
166
+ Generates:
167
+ ```
168
+ my-library/
169
+ ├── package.json
170
+ ├── README.md
171
+ ├── lib/
172
+ │ └── index.di
173
+ ├── examples/
174
+ │ └── example.di
175
+ ├── tests/
176
+ │ └── test.di
177
+ └── .github/
178
+ └── workflows/
179
+ └── test.yml # Auto-test on push
180
+ ```
181
+
182
+ ## Version Management
183
+
184
+ ### Semantic Versioning
185
+
186
+ Follow semver for library versions:
187
+ - `1.0.0` - Initial release
188
+ - `1.1.0` - New subroutines (backward compatible)
189
+ - `2.0.0` - Breaking changes
190
+
191
+ ### Dependency Resolution
192
+
193
+ In `package.json`:
194
+ ```json
195
+ {
196
+ "dirac": {
197
+ "dependencies": {
198
+ "dirac-utils": "^1.0.0",
199
+ "dirac-http": "^2.1.0"
200
+ }
201
+ }
202
+ }
203
+ ```
204
+
205
+ Install with:
206
+ ```bash
207
+ npm install
208
+ ```
209
+
210
+ ### Import from Dependencies
211
+
212
+ ```xml
213
+ <!-- Import from node_modules -->
214
+ <import src="./node_modules/dirac-http/lib/main.di"/>
215
+
216
+ <!-- Or use a helper tag (future) -->
217
+ <import package="dirac-http"/>
218
+ ```
219
+
220
+ ## Community Governance
221
+
222
+ ### 1. Core Standard Library
223
+
224
+ Official libraries maintained by Dirac team:
225
+ - `@dirac/stdlib` - Standard library
226
+ - `@dirac/test` - Testing framework
227
+ - `@dirac/docs` - Documentation generator
228
+
229
+ Published under `@dirac` scope on npm.
230
+
231
+ ### 2. Community Libraries
232
+
233
+ Anyone can publish `dirac-*` packages:
234
+ - Use npm's existing infrastructure
235
+ - No approval needed
236
+ - Free innovation
237
+
238
+ ### 3. Awesome List
239
+
240
+ Maintain `awesome-dirac` repo:
241
+ ```markdown
242
+ # Awesome Dirac
243
+
244
+ ## HTTP & Networking
245
+ - [dirac-http](https://github.com/user/dirac-http) - HTTP client
246
+ - [dirac-websocket](https://github.com/user/dirac-ws) - WebSocket
247
+
248
+ ## Data Processing
249
+ - [dirac-json](https://github.com/user/dirac-json) - JSON parser
250
+ - [dirac-csv](https://github.com/user/dirac-csv) - CSV operations
251
+
252
+ ## Machine Learning
253
+ - [dirac-ml](https://github.com/user/dirac-ml) - ML toolkit
254
+ ```
255
+
256
+ ### 4. Discord/Forum
257
+
258
+ Community channels:
259
+ - **#library-showcase** - Share new libraries
260
+ - **#help** - Get support
261
+ - **#development** - Discuss features
262
+ - **#security** - Report issues
263
+
264
+ ## Example: Publishing dirac-http
265
+
266
+ ### 1. Create Library
267
+
268
+ `lib/main.di`:
269
+ ```xml
270
+ <dirac>
271
+
272
+ <subroutine name="HTTP_GET">
273
+ <eval>
274
+ const caller = getParams();
275
+ const url = caller.attributes.url;
276
+ const response = await fetch(url);
277
+ const text = await response.text();
278
+ console.log(text);
279
+ </eval>
280
+ </subroutine>
281
+
282
+ <subroutine name="HTTP_POST">
283
+ <eval>
284
+ const caller = getParams();
285
+ const url = caller.attributes.url;
286
+ const body = caller.attributes.body || '';
287
+ const response = await fetch(url, {
288
+ method: 'POST',
289
+ body: body
290
+ });
291
+ const text = await response.text();
292
+ console.log(text);
293
+ </eval>
294
+ </subroutine>
295
+
296
+ </dirac>
297
+ ```
298
+
299
+ ### 2. Create package.json
300
+
301
+ ```json
302
+ {
303
+ "name": "dirac-http",
304
+ "version": "1.0.0",
305
+ "description": "HTTP client for Dirac",
306
+ "main": "lib/main.di",
307
+ "keywords": ["dirac", "http", "fetch", "rest"],
308
+ "author": "Community Member",
309
+ "license": "MIT",
310
+ "repository": "github:username/dirac-http",
311
+ "dirac": {
312
+ "version": ">=0.1.0"
313
+ }
314
+ }
315
+ ```
316
+
317
+ ### 3. Create README.md
318
+
319
+ ```markdown
320
+ # dirac-http
321
+
322
+ HTTP client library for Dirac.
323
+
324
+ ## Installation
325
+
326
+ \`\`\`bash
327
+ npm install dirac-http
328
+ \`\`\`
329
+
330
+ ## Usage
331
+
332
+ \`\`\`xml
333
+ <import src="./node_modules/dirac-http/lib/main.di"/>
334
+
335
+ <HTTP_GET url="https://api.github.com/users/octocat"/>
336
+
337
+ <HTTP_POST
338
+ url="https://httpbin.org/post"
339
+ body='{"key":"value"}'/>
340
+ \`\`\`
341
+
342
+ ## API
343
+
344
+ ### HTTP_GET
345
+ Get a URL.
346
+
347
+ **Attributes:**
348
+ - `url` - URL to fetch (required)
349
+
350
+ ### HTTP_POST
351
+ Post to a URL.
352
+
353
+ **Attributes:**
354
+ - `url` - URL to post to (required)
355
+ - `body` - Request body (optional)
356
+ ```
357
+
358
+ ### 4. Publish
359
+
360
+ ```bash
361
+ npm login
362
+ npm publish
363
+ ```
364
+
365
+ ### 5. Users Install & Use
366
+
367
+ ```bash
368
+ npm install dirac-http
369
+ ```
370
+
371
+ ```xml
372
+ <import src="./node_modules/dirac-http/lib/main.di"/>
373
+ <HTTP_GET url="https://example.com"/>
374
+ ```
375
+
376
+ ## Future Enhancements
377
+
378
+ ### 1. Dirac Package Manager
379
+
380
+ ```bash
381
+ dirac init # Initialize project
382
+ dirac add http # Add library
383
+ dirac remove http # Remove library
384
+ dirac list # List installed
385
+ dirac search "machine learning" # Search registry
386
+ dirac publish # Publish library
387
+ ```
388
+
389
+ ### 2. Smart Imports
390
+
391
+ ```xml
392
+ <!-- Current -->
393
+ <import src="./node_modules/dirac-http/lib/main.di"/>
394
+
395
+ <!-- Future -->
396
+ <import package="http"/> <!-- From installed packages -->
397
+ <import from="http" names="GET"/> <!-- Named imports -->
398
+ <import src="https://cdn.dirac.org/http/1.0.0/main.di"/> <!-- CDN -->
399
+ ```
400
+
401
+ ### 3. Type System (Optional)
402
+
403
+ ```xml
404
+ <subroutine name="ADD" params="(x: number, y: number) -> number">
405
+ <expr eval="plus">
406
+ <arg><parameters select="@x"/></arg>
407
+ <arg><parameters select="@y"/></arg>
408
+ </expr>
409
+ </subroutine>
410
+ ```
411
+
412
+ ### 4. Testing Framework
413
+
414
+ ```xml
415
+ <import src="@dirac/test"/>
416
+
417
+ <test name="ADD works correctly">
418
+ <assert>
419
+ <expr eval="eq">
420
+ <arg><ADD x="1" y="2"/></arg>
421
+ <arg>3</arg>
422
+ </expr>
423
+ </assert>
424
+ </test>
425
+ ```
426
+
427
+ ## Community Growth Phases
428
+
429
+ ### Phase 1: Bootstrap (Month 1-3)
430
+ - ✅ Core interpreter working
431
+ - ✅ Basic examples
432
+ - Create 5-10 core libraries
433
+ - Set up GitHub org
434
+ - Launch Discord
435
+
436
+ ### Phase 2: Early Adopters (Month 4-6)
437
+ - npm publishing convention
438
+ - awesome-dirac list
439
+ - Tutorial videos
440
+ - First community libraries
441
+
442
+ ### Phase 3: Growth (Month 7-12)
443
+ - 50+ libraries on npm
444
+ - diraclibs.org registry
445
+ - Conference talks
446
+ - Plugin for VS Code
447
+
448
+ ### Phase 4: Maturity (Year 2+)
449
+ - 200+ libraries
450
+ - Dirac package manager
451
+ - Corporate adoption
452
+ - Certification program
453
+
454
+ ## Getting Started Contributing
455
+
456
+ 1. **Pick a domain**: crypto, http, db, ml, etc.
457
+ 2. **Check existing**: Search npm for `dirac-*`
458
+ 3. **Create library**: Use template
459
+ 4. **Test thoroughly**: Write examples
460
+ 5. **Document well**: README + examples
461
+ 6. **Publish**: npm publish
462
+ 7. **Announce**: Discord + GitHub discussions
463
+ 8. **Maintain**: Respond to issues
464
+
465
+ The ecosystem grows organically as developers scratch their own itches!
package/LIBRARIES.md ADDED
@@ -0,0 +1,172 @@
1
+ # Dirac Library Ecosystem
2
+
3
+ ## Philosophy
4
+
5
+ Dirac follows the UNIX philosophy: **composition over complexity**. Complex operations should be implemented as reusable libraries that users can import and use with clean, declarative syntax.
6
+
7
+ ## Library Architecture
8
+
9
+ ### Pattern: JavaScript → Dirac Tags
10
+
11
+ 1. **Implement complexity in `<eval>`** - Use JavaScript's full power for complex algorithms
12
+ 2. **Wrap in `<subroutine>`** - Expose as a clean Dirac tag
13
+ 3. **Distribute as `.di` files** - Share via `<import>`
14
+ 4. **Use like built-in tags** - `<SQRT n="16"/>` not `eval(...)`
15
+
16
+ ### Example: Square Root
17
+
18
+ **Implementation** (in library):
19
+ ```xml
20
+ <subroutine name="SQRT">
21
+ <eval>
22
+ const caller = getParams();
23
+ const n = parseFloat(caller.attributes.n || 0);
24
+ let x = n, prev;
25
+ do {
26
+ prev = x;
27
+ x = (x + n / x) / 2;
28
+ } while (Math.abs(x - prev) &lt; 1e-10);
29
+ console.log(x);
30
+ </eval>
31
+ </subroutine>
32
+ ```
33
+
34
+ **Usage** (by end user):
35
+ ```xml
36
+ <import src="./lib/advanced-math.di"/>
37
+ <SQRT n="16"/> <!-- Clean, declarative -->
38
+ ```
39
+
40
+ ## Current Libraries
41
+
42
+ ### `lib/math.di` - Basic Math
43
+ - `SQUARE` - Square a number
44
+ - `ADD` - Add two numbers
45
+ - `FACTORIAL` - Calculate factorial
46
+
47
+ ### `lib/fileops.di` - File Operations
48
+ - `LIST_FILES` - List directory contents
49
+ - `COUNT_FILES` - Count files in directory
50
+
51
+ ### `lib/advanced-math.di` - Advanced Math
52
+ - `SQRT` - Square root (Newton's method)
53
+ - `FACTORIAL` - Factorial (recursive)
54
+ - `GCD` - Greatest common divisor
55
+ - `PRIME` - Primality test
56
+ - `STATS` - Statistical analysis
57
+ - `RANDOM` - Random number generation
58
+
59
+ ## Publishing Libraries
60
+
61
+ ### Option 1: GitHub
62
+ ```bash
63
+ # Create a dirac-libs repository
64
+ mkdir dirac-libs
65
+ cd dirac-libs
66
+ git init
67
+ # Add your .di library files
68
+ git add lib/
69
+ git commit -m "Add math libraries"
70
+ git push
71
+ ```
72
+
73
+ Users import via URL or local clone.
74
+
75
+ ### Option 2: npm Package
76
+ ```json
77
+ {
78
+ "name": "dirac-stdlib",
79
+ "version": "1.0.0",
80
+ "description": "Standard library for Dirac",
81
+ "main": "index.js",
82
+ "files": ["lib/**/*.di"],
83
+ "keywords": ["dirac", "mask", "xml", "dsl"]
84
+ }
85
+ ```
86
+
87
+ Users:
88
+ ```bash
89
+ npm install dirac-stdlib
90
+ ```
91
+
92
+ ```xml
93
+ <import src="./node_modules/dirac-stdlib/lib/math.di"/>
94
+ ```
95
+
96
+ ### Option 3: Central Registry
97
+ Future: Create a Dirac package registry like PyPI/npm specifically for `.di` libraries.
98
+
99
+ ## Best Practices
100
+
101
+ ### 1. Use XML Entities for Operators
102
+ ```xml
103
+ <eval>
104
+ if (x &lt; 5) ... <!-- Use &lt; not < -->
105
+ if (x &gt; 10) ... <!-- Use &gt; not > -->
106
+ if (x &lt;= 5) ... <!-- Use &lt;= -->
107
+ </eval>
108
+ ```
109
+
110
+ ### 2. Use getParams() for Attributes
111
+ ```xml
112
+ <subroutine name="FOO">
113
+ <eval>
114
+ const caller = getParams();
115
+ const x = caller.attributes.x;
116
+ const children = caller.children;
117
+ </eval>
118
+ </subroutine>
119
+ ```
120
+
121
+ ### 3. Handle Edge Cases
122
+ ```javascript
123
+ const n = parseFloat(caller.attributes.n || 0);
124
+ if (n < 0) { console.log('NaN'); return; }
125
+ ```
126
+
127
+ ### 4. Document Your Library
128
+ ```xml
129
+ <!--
130
+ SQRT - Square Root Calculator
131
+
132
+ Usage: <SQRT n="16"/>
133
+ Returns: Square root using Newton's method
134
+ Attributes:
135
+ - n: Number to find square root of (required)
136
+ -->
137
+ <subroutine name="SQRT">
138
+ ...
139
+ </subroutine>
140
+ ```
141
+
142
+ ## Future Libraries
143
+
144
+ Ideas for community-contributed libraries:
145
+
146
+ - **dirac-crypto** - Hashing, encryption (`<SHA256>`, `<AES>`)
147
+ - **dirac-http** - HTTP client (`<GET>`, `<POST>`)
148
+ - **dirac-db** - Database operations (`<SQL>`, `<QUERY>`)
149
+ - **dirac-ml** - Machine learning (`<PREDICT>`, `<TRAIN>`)
150
+ - **dirac-dsp** - Signal processing (`<FFT>`, `<FILTER>`)
151
+ - **dirac-viz** - Data visualization (`<CHART>`, `<PLOT>`)
152
+ - **dirac-nlp** - Natural language (`<TOKENIZE>`, `<SENTIMENT>`)
153
+
154
+ ## Contributing
155
+
156
+ To contribute a library:
157
+
158
+ 1. Create `.di` file with subroutines
159
+ 2. Test thoroughly
160
+ 3. Document all tags
161
+ 4. Submit PR or publish to npm
162
+ 5. Add to Dirac wiki/registry
163
+
164
+ ## Philosophy: Why This Works
165
+
166
+ This approach follows McCarthy's insight about homoiconicity:
167
+ - **Code as data**: Subroutines are XML, same as the code using them
168
+ - **Composition**: Complex tags built from simple ones
169
+ - **Distribution**: Libraries are just more Dirac files
170
+ - **No special cases**: `<SQRT>` works exactly like `<output>`
171
+
172
+ The entire ecosystem grows organically through composition, not by modifying the interpreter.