dirac-lang 0.1.24 → 0.1.25

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 (221) hide show
  1. package/dist/cli.js +13 -1
  2. package/lib/index.di +9 -0
  3. package/package.json +13 -1
  4. package/.env.example +0 -8
  5. package/COMMUNITY.md +0 -465
  6. package/CONDITIONAL-TAGS.md +0 -172
  7. package/EXCEPTION-HANDLING.md +0 -156
  8. package/LIBRARIES.md +0 -172
  9. package/LLM-VALIDATION.md +0 -128
  10. package/NAMESPACES.md +0 -366
  11. package/PROMOTION.md +0 -257
  12. package/QUICKSTART-LIBRARY.md +0 -93
  13. package/TEST-COVERAGE.md +0 -113
  14. package/TESTING.md +0 -162
  15. package/config.test.yml +0 -5
  16. package/dirac-http/examples/demo.di +0 -9
  17. package/dirac-http/lib/index.di +0 -12
  18. package/examples/add-demo.di +0 -74
  19. package/examples/add.bk +0 -11
  20. package/examples/advanced-math-demo.di +0 -53
  21. package/examples/calculator.di +0 -32
  22. package/examples/compact-test.di +0 -6
  23. package/examples/comprehensive.bk +0 -29
  24. package/examples/defvar-variable-demo.di +0 -18
  25. package/examples/direct-call.di +0 -17
  26. package/examples/disk-analysis.di +0 -16
  27. package/examples/exception-demo.di +0 -82
  28. package/examples/executable-hello.di +0 -7
  29. package/examples/execute-demo.di +0 -38
  30. package/examples/file-manager.di +0 -77
  31. package/examples/file-stats.di +0 -18
  32. package/examples/hello.bk +0 -1
  33. package/examples/hello.di +0 -5
  34. package/examples/if-comparison.di +0 -91
  35. package/examples/if-cstyle-test.di +0 -149
  36. package/examples/if-vs-testif.di +0 -56
  37. package/examples/import-demo.di +0 -31
  38. package/examples/inline-test.bk +0 -7
  39. package/examples/llm-agent.di +0 -32
  40. package/examples/llm-basic.di +0 -12
  41. package/examples/llm-command-more.di +0 -6
  42. package/examples/llm-command-no-exec.di +0 -13
  43. package/examples/llm-command.di +0 -6
  44. package/examples/llm-complex.di +0 -141
  45. package/examples/llm-feedback-debug.di +0 -30
  46. package/examples/llm-feedback-demo.di +0 -19
  47. package/examples/llm-feedback-math.di +0 -22
  48. package/examples/llm-feedback-simple.di +0 -16
  49. package/examples/llm-feedback-sub.di +0 -22
  50. package/examples/llm-no-feedback.di +0 -10
  51. package/examples/llm-recursive.di +0 -31
  52. package/examples/llm-reflection-test.di +0 -19
  53. package/examples/llm-simple-test.di +0 -12
  54. package/examples/llm-subs.di +0 -132
  55. package/examples/llm-use-subs.di +0 -6
  56. package/examples/llm-validate-test.di +0 -18
  57. package/examples/loop.di +0 -12
  58. package/examples/math-test.di +0 -22
  59. package/examples/minimal-test.di +0 -13
  60. package/examples/mongodb-context-test.di +0 -27
  61. package/examples/mongodb-count-events.di +0 -8
  62. package/examples/mongodb-import-demo.di +0 -25
  63. package/examples/mongodb-simple-test.di +0 -18
  64. package/examples/nl-agent.di +0 -47
  65. package/examples/parameters-demo.di +0 -68
  66. package/examples/params-meta-test.di +0 -17
  67. package/examples/params-test.di +0 -10
  68. package/examples/recipe-chain.di +0 -38
  69. package/examples/recursive-llm.di +0 -44
  70. package/examples/sample-library/README.md +0 -152
  71. package/examples/sample-library/examples/demo.di +0 -34
  72. package/examples/sample-library/lib/index.di +0 -65
  73. package/examples/sample-library/package.json +0 -31
  74. package/examples/scope-test-nested.di +0 -60
  75. package/examples/scope-test.di +0 -55
  76. package/examples/seamless.di +0 -45
  77. package/examples/shell-test.bk +0 -10
  78. package/examples/simple-import.di +0 -13
  79. package/examples/simple-recursive.di +0 -26
  80. package/examples/story-builder.di +0 -45
  81. package/examples/subroutine.di +0 -23
  82. package/examples/system-llm.di +0 -21
  83. package/examples/system-simple.di +0 -3
  84. package/examples/system-test.di +0 -8
  85. package/examples/tag-check-test.di +0 -139
  86. package/examples/task-assistant.di +0 -27
  87. package/examples/test-if-demo.di +0 -110
  88. package/examples/test-parameters.di +0 -50
  89. package/examples/try-catch-test.di +0 -118
  90. package/examples/two-styles.di +0 -28
  91. package/examples/var-debug.di +0 -6
  92. package/examples/var-inline.di +0 -4
  93. package/examples/var-test2.di +0 -6
  94. package/examples/variable-replace.di +0 -25
  95. package/examples/variable-simple.di +0 -16
  96. package/examples/variable-test.di +0 -22
  97. package/examples/whitespace-test.di +0 -24
  98. package/filePath +0 -1
  99. package/greeting.txt +0 -1
  100. package/src/cli.ts +0 -140
  101. package/src/index.ts +0 -33
  102. package/src/llm/ollama.ts +0 -58
  103. package/src/runtime/braket-parser.ts +0 -234
  104. package/src/runtime/interpreter.ts +0 -203
  105. package/src/runtime/parser.ts +0 -155
  106. package/src/runtime/session.ts +0 -325
  107. package/src/tags/assign.ts +0 -37
  108. package/src/tags/attr.ts +0 -64
  109. package/src/tags/available-subroutines.ts +0 -70
  110. package/src/tags/call.ts +0 -259
  111. package/src/tags/catch.ts +0 -24
  112. package/src/tags/defvar.ts +0 -115
  113. package/src/tags/environment.ts +0 -21
  114. package/src/tags/eval.ts +0 -71
  115. package/src/tags/exception.ts +0 -20
  116. package/src/tags/execute.ts +0 -52
  117. package/src/tags/expr.ts +0 -128
  118. package/src/tags/foreach.ts +0 -170
  119. package/src/tags/if.ts +0 -191
  120. package/src/tags/import.ts +0 -135
  121. package/src/tags/index.ts +0 -41
  122. package/src/tags/input.ts +0 -182
  123. package/src/tags/llm.ts +0 -415
  124. package/src/tags/loop.ts +0 -43
  125. package/src/tags/mongodb.ts +0 -70
  126. package/src/tags/output.ts +0 -53
  127. package/src/tags/parameters.ts +0 -81
  128. package/src/tags/require_module.ts +0 -19
  129. package/src/tags/subroutine.ts +0 -75
  130. package/src/tags/system.ts +0 -93
  131. package/src/tags/tag-check.ts +0 -176
  132. package/src/tags/test-if.ts +0 -112
  133. package/src/tags/throw.ts +0 -26
  134. package/src/tags/try.ts +0 -19
  135. package/src/tags/variable.ts +0 -25
  136. package/src/test-runner.ts +0 -300
  137. package/src/types/index.ts +0 -128
  138. package/src/utils/llm-adapter.ts +0 -113
  139. package/src/utils/tag-validator.ts +0 -231
  140. package/test-available-extends.di +0 -28
  141. package/test-available-simple.di +0 -12
  142. package/test-available-subroutines.di +0 -16
  143. package/test-call.di +0 -9
  144. package/test-extend-basic.di +0 -17
  145. package/test-extend-chain.di +0 -26
  146. package/test-extend-debug.di +0 -17
  147. package/test-extend-debug2.di +0 -15
  148. package/test-extend-person.di +0 -17
  149. package/test-extend-simple.di +0 -11
  150. package/test-extend-zhi.di +0 -23
  151. package/test-extend.di +0 -19
  152. package/test-extend2.di +0 -26
  153. package/test-extend3-fixed.di +0 -23
  154. package/test-extend3-trouble.di +0 -23
  155. package/test-extend3.di +0 -21
  156. package/test-factorial.di +0 -19
  157. package/test-input-debug.di +0 -19
  158. package/test-nested-debug.di +0 -7
  159. package/test-nested-debug2.di +0 -8
  160. package/test-no-extend.di +0 -16
  161. package/test-simple-call.di +0 -7
  162. package/test-simple.di +0 -6
  163. package/tests/README.md +0 -69
  164. package/tests/assign-basic.test.di +0 -7
  165. package/tests/assign-from-eval.test.di +0 -7
  166. package/tests/available-subroutines-foreach.test.di +0 -32
  167. package/tests/basic-output.test.di +0 -5
  168. package/tests/call-basic.test.di +0 -11
  169. package/tests/call-with-output.test.di +0 -10
  170. package/tests/comments-before-content.test.di +0 -6
  171. package/tests/defvar-multiple.test.di +0 -8
  172. package/tests/environment-basic.test.di +0 -22
  173. package/tests/environment-nonexistent.test.di +0 -5
  174. package/tests/environment-with-defvar.test.di +0 -15
  175. package/tests/eval-basic.test.di +0 -6
  176. package/tests/eval-with-variables.test.di +0 -8
  177. package/tests/exception-basic.test.di +0 -10
  178. package/tests/expr-basic.test.di +0 -11
  179. package/tests/extend-basic.test.di +0 -19
  180. package/tests/extend-inheritance-chain.test.di +0 -26
  181. package/tests/extend-multiple-nested.test.di +0 -24
  182. package/tests/extend-self.test.di +0 -19
  183. package/tests/extend-with-parameters.test.di +0 -14
  184. package/tests/generate-dirac.test.di +0 -22
  185. package/tests/if-conditional.test.di +0 -17
  186. package/tests/if-else.test.di +0 -11
  187. package/tests/if-with-variables.test.di +0 -8
  188. package/tests/import-basic.test.di +0 -6
  189. package/tests/input-file-all.test.di +0 -5
  190. package/tests/input-file-line.test.di +0 -15
  191. package/tests/input-file-loop.test.di +0 -12
  192. package/tests/input-stdin-all.test.di +0 -8
  193. package/tests/input-stdin-all.txt +0 -1
  194. package/tests/llm-validate.test.di +0 -17
  195. package/tests/loop-basic.test.di +0 -9
  196. package/tests/loop-nested.test.di +0 -10
  197. package/tests/loop-with-eval.test.di +0 -8
  198. package/tests/no-root-element.test.di +0 -6
  199. package/tests/output-file.test.di +0 -19
  200. package/tests/output-multiple.test.di +0 -9
  201. package/tests/parameters-basic.test.di +0 -6
  202. package/tests/require-module-basic.test.di +0 -7
  203. package/tests/subroutine-basic.test.di +0 -9
  204. package/tests/subroutine-multiple-params.test.di +0 -10
  205. package/tests/subroutine-nested-calls.test.di +0 -32
  206. package/tests/subroutine-sequential-calls.test.di +0 -36
  207. package/tests/system-background.test.di +0 -39
  208. package/tests/system-basic.test.di +0 -5
  209. package/tests/tag-check.test.di +0 -27
  210. package/tests/test-if-basic.test.di +0 -8
  211. package/tests/test-input.txt +0 -3
  212. package/tests/try-catch-basic.test.di +0 -10
  213. package/tests/try-catch-eval-error.test.di +0 -10
  214. package/tests/variable-basic.test.di +0 -6
  215. package/tests/variable-interpolation.test.di +0 -7
  216. package/tools/create-library.sh +0 -175
  217. package/tsconfig.json +0 -19
  218. /package/{examples/lib → lib}/advanced-math.di +0 -0
  219. /package/{examples/lib → lib}/fileops.di +0 -0
  220. /package/{examples/lib → lib}/math.di +0 -0
  221. /package/{examples/lib → lib}/mongodb.di +0 -0
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import "dotenv/config";
13
13
  // package.json
14
14
  var package_default = {
15
15
  name: "dirac-lang",
16
- version: "0.1.23",
16
+ version: "0.1.25",
17
17
  description: "LLM-Augmented Declarative Execution",
18
18
  type: "module",
19
19
  main: "dist/index.js",
@@ -21,6 +21,18 @@ var package_default = {
21
21
  bin: {
22
22
  dirac: "dist/cli.js"
23
23
  },
24
+ exports: {
25
+ ".": "./dist/index.js",
26
+ "./lib": "./lib/index.di",
27
+ "./lib/math": "./lib/math.di",
28
+ "./lib/advanced-math": "./lib/advanced-math.di",
29
+ "./lib/fileops": "./lib/fileops.di",
30
+ "./lib/mongodb": "./lib/mongodb.di"
31
+ },
32
+ files: [
33
+ "dist/",
34
+ "lib/"
35
+ ],
24
36
  scripts: {
25
37
  dev: "tsx src/cli.ts",
26
38
  build: "tsup src/index.ts src/cli.ts src/test-runner.ts --format esm --dts --clean",
package/lib/index.di ADDED
@@ -0,0 +1,9 @@
1
+ <dirac>
2
+ <!-- DIRAC Standard Library -->
3
+ <!-- Import all standard library modules -->
4
+
5
+ <import src="./math.di"/>
6
+ <import src="./advanced-math.di"/>
7
+ <import src="./fileops.di"/>
8
+ <import src="./mongodb.di"/>
9
+ </dirac>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,6 +8,18 @@
8
8
  "bin": {
9
9
  "dirac": "dist/cli.js"
10
10
  },
11
+ "exports": {
12
+ ".": "./dist/index.js",
13
+ "./lib": "./lib/index.di",
14
+ "./lib/math": "./lib/math.di",
15
+ "./lib/advanced-math": "./lib/advanced-math.di",
16
+ "./lib/fileops": "./lib/fileops.di",
17
+ "./lib/mongodb": "./lib/mongodb.di"
18
+ },
19
+ "files": [
20
+ "dist/",
21
+ "lib/"
22
+ ],
11
23
  "scripts": {
12
24
  "dev": "tsx src/cli.ts",
13
25
  "build": "tsup src/index.ts src/cli.ts src/test-runner.ts --format esm --dts --clean",
package/.env.example DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,465 +0,0 @@
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!
@@ -1,172 +0,0 @@
1
- # Conditional Tags in Dirac
2
-
3
- Dirac supports two styles of conditional execution:
4
-
5
- ## 1. C-Style `<if>` Tag (Based on C MASK)
6
-
7
- The `<if>` tag uses child elements for structure, following the C MASK pattern.
8
-
9
- ### Syntax
10
-
11
- ```xml
12
- <if>
13
- <cond eval="eq|ne|lt|gt|le|ge">
14
- <arg>value1</arg>
15
- <arg>value2</arg>
16
- </cond>
17
- <then>
18
- <!-- executed if condition is true -->
19
- </then>
20
- <else>
21
- <!-- executed if condition is false (optional) -->
22
- </else>
23
- </if>
24
- ```
25
-
26
- ### Supported Comparison Types
27
-
28
- - `eq`, `equal`, `same` - Equality comparison
29
- - `ne`, `notequal`, `different` - Not equal
30
- - `lt`, `less` - Less than (numeric)
31
- - `le`, `lessequal` - Less than or equal (numeric)
32
- - `gt`, `greater` - Greater than (numeric)
33
- - `ge`, `greaterequal` - Greater than or equal (numeric)
34
-
35
- ### Alternative Syntax
36
-
37
- You can use `<do>` instead of `<then>`.
38
-
39
- You can omit the `<cond>` wrapper and use any element as the predicate:
40
-
41
- ```xml
42
- <if>
43
- <variable name="x"/>
44
- <then>
45
- <output>x exists and is truthy</output>
46
- </then>
47
- </if>
48
- ```
49
-
50
- ### Examples
51
-
52
- ```xml
53
- <!-- Simple equality -->
54
- <defvar name="x" value="5"/>
55
- <if>
56
- <cond eval="eq">
57
- <arg><variable name="x"/></arg>
58
- <arg>5</arg>
59
- </cond>
60
- <then>
61
- <output>x equals 5</output>
62
- </then>
63
- <else>
64
- <output>x does not equal 5</output>
65
- </else>
66
- </if>
67
-
68
- <!-- Greater than -->
69
- <defvar name="age" value="25"/>
70
- <if>
71
- <cond eval="gt">
72
- <arg><variable name="age"/></arg>
73
- <arg>18</arg>
74
- </cond>
75
- <then>
76
- <output>Adult</output>
77
- </then>
78
- <else>
79
- <output>Minor</output>
80
- </else>
81
- </if>
82
-
83
- <!-- Simple predicate -->
84
- <defvar name="name" value="Alice"/>
85
- <if>
86
- <variable name="name"/>
87
- <then>
88
- <output>Name is: <variable name="name"/></output>
89
- </then>
90
- </if>
91
- ```
92
-
93
- ## 2. Attribute-Based `<test-if>` Tag (Original Dirac Style)
94
-
95
- The `<test-if>` tag uses attributes for conditions, providing a more compact syntax.
96
-
97
- ### Syntax
98
-
99
- ```xml
100
- <test-if test="$variable" [eq|ne|lt|gt|le|ge]="value">
101
- <!-- executed if condition is true -->
102
- </test-if>
103
- ```
104
-
105
- ### Supported Attributes
106
-
107
- - `test` (required) - The value or variable to test (use `$` prefix for variables)
108
- - `eq` - Equals comparison
109
- - `ne` - Not equals comparison
110
- - `lt` - Less than (numeric)
111
- - `gt` - Greater than (numeric)
112
- - `le` - Less than or equal (numeric)
113
- - `ge` - Greater than or equal (numeric)
114
-
115
- If no comparison attribute is provided, the test value is evaluated as a boolean (non-empty = true).
116
-
117
- ### Examples
118
-
119
- ```xml
120
- <!-- Simple boolean test -->
121
- <defvar name="x" value="5"/>
122
- <test-if test="$x">
123
- <output>x is truthy</output>
124
- </test-if>
125
-
126
- <!-- Equality test -->
127
- <defvar name="status" value="active"/>
128
- <test-if test="$status" eq="active">
129
- <output>Status is active</output>
130
- </test-if>
131
-
132
- <!-- Greater than test -->
133
- <defvar name="age" value="25"/>
134
- <test-if test="$age" gt="18">
135
- <output>Age is greater than 18</output>
136
- </test-if>
137
-
138
- <!-- Less than or equal -->
139
- <defvar name="price" value="50"/>
140
- <test-if test="$price" le="50">
141
- <output>Price is affordable</output>
142
- </test-if>
143
- ```
144
-
145
- ## Choosing Between `<if>` and `<test-if>`
146
-
147
- - Use **`<if>`** when:
148
- - You need an else clause
149
- - You're porting code from C MASK
150
- - You prefer explicit structure
151
- - You need complex predicates
152
-
153
- - Use **`<test-if>`** when:
154
- - You only need a then clause (no else)
155
- - You want compact, attribute-based syntax
156
- - You're doing simple comparisons
157
- - You prefer the original Dirac style
158
-
159
- ## Truthiness Evaluation
160
-
161
- Both tags evaluate values as follows:
162
-
163
- - **False**: Empty string, "0", "false"
164
- - **True**: "1", "true", any non-empty string
165
- - For numeric comparisons, values are parsed as floats
166
-
167
- ## Notes
168
-
169
- - Condition evaluation does not produce output (intermediate values are captured and removed)
170
- - Arguments in `<cond>` are evaluated and their outputs captured
171
- - Variable substitution in `<test-if>` uses `$varname` or `${varname}` syntax
172
- - Both tags support nested content including `<defvar>`, `<output>`, and other tags