dirac-lang 0.1.24 → 0.1.26

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/{examples/lib → lib}/math.di +3 -3
  4. package/package.json +13 -1
  5. package/.env.example +0 -8
  6. package/COMMUNITY.md +0 -465
  7. package/CONDITIONAL-TAGS.md +0 -172
  8. package/EXCEPTION-HANDLING.md +0 -156
  9. package/LIBRARIES.md +0 -172
  10. package/LLM-VALIDATION.md +0 -128
  11. package/NAMESPACES.md +0 -366
  12. package/PROMOTION.md +0 -257
  13. package/QUICKSTART-LIBRARY.md +0 -93
  14. package/TEST-COVERAGE.md +0 -113
  15. package/TESTING.md +0 -162
  16. package/config.test.yml +0 -5
  17. package/dirac-http/examples/demo.di +0 -9
  18. package/dirac-http/lib/index.di +0 -12
  19. package/examples/add-demo.di +0 -74
  20. package/examples/add.bk +0 -11
  21. package/examples/advanced-math-demo.di +0 -53
  22. package/examples/calculator.di +0 -32
  23. package/examples/compact-test.di +0 -6
  24. package/examples/comprehensive.bk +0 -29
  25. package/examples/defvar-variable-demo.di +0 -18
  26. package/examples/direct-call.di +0 -17
  27. package/examples/disk-analysis.di +0 -16
  28. package/examples/exception-demo.di +0 -82
  29. package/examples/executable-hello.di +0 -7
  30. package/examples/execute-demo.di +0 -38
  31. package/examples/file-manager.di +0 -77
  32. package/examples/file-stats.di +0 -18
  33. package/examples/hello.bk +0 -1
  34. package/examples/hello.di +0 -5
  35. package/examples/if-comparison.di +0 -91
  36. package/examples/if-cstyle-test.di +0 -149
  37. package/examples/if-vs-testif.di +0 -56
  38. package/examples/import-demo.di +0 -31
  39. package/examples/inline-test.bk +0 -7
  40. package/examples/llm-agent.di +0 -32
  41. package/examples/llm-basic.di +0 -12
  42. package/examples/llm-command-more.di +0 -6
  43. package/examples/llm-command-no-exec.di +0 -13
  44. package/examples/llm-command.di +0 -6
  45. package/examples/llm-complex.di +0 -141
  46. package/examples/llm-feedback-debug.di +0 -30
  47. package/examples/llm-feedback-demo.di +0 -19
  48. package/examples/llm-feedback-math.di +0 -22
  49. package/examples/llm-feedback-simple.di +0 -16
  50. package/examples/llm-feedback-sub.di +0 -22
  51. package/examples/llm-no-feedback.di +0 -10
  52. package/examples/llm-recursive.di +0 -31
  53. package/examples/llm-reflection-test.di +0 -19
  54. package/examples/llm-simple-test.di +0 -12
  55. package/examples/llm-subs.di +0 -132
  56. package/examples/llm-use-subs.di +0 -6
  57. package/examples/llm-validate-test.di +0 -18
  58. package/examples/loop.di +0 -12
  59. package/examples/math-test.di +0 -22
  60. package/examples/minimal-test.di +0 -13
  61. package/examples/mongodb-context-test.di +0 -27
  62. package/examples/mongodb-count-events.di +0 -8
  63. package/examples/mongodb-import-demo.di +0 -25
  64. package/examples/mongodb-simple-test.di +0 -18
  65. package/examples/nl-agent.di +0 -47
  66. package/examples/parameters-demo.di +0 -68
  67. package/examples/params-meta-test.di +0 -17
  68. package/examples/params-test.di +0 -10
  69. package/examples/recipe-chain.di +0 -38
  70. package/examples/recursive-llm.di +0 -44
  71. package/examples/sample-library/README.md +0 -152
  72. package/examples/sample-library/examples/demo.di +0 -34
  73. package/examples/sample-library/lib/index.di +0 -65
  74. package/examples/sample-library/package.json +0 -31
  75. package/examples/scope-test-nested.di +0 -60
  76. package/examples/scope-test.di +0 -55
  77. package/examples/seamless.di +0 -45
  78. package/examples/shell-test.bk +0 -10
  79. package/examples/simple-import.di +0 -13
  80. package/examples/simple-recursive.di +0 -26
  81. package/examples/story-builder.di +0 -45
  82. package/examples/subroutine.di +0 -23
  83. package/examples/system-llm.di +0 -21
  84. package/examples/system-simple.di +0 -3
  85. package/examples/system-test.di +0 -8
  86. package/examples/tag-check-test.di +0 -139
  87. package/examples/task-assistant.di +0 -27
  88. package/examples/test-if-demo.di +0 -110
  89. package/examples/test-parameters.di +0 -50
  90. package/examples/try-catch-test.di +0 -118
  91. package/examples/two-styles.di +0 -28
  92. package/examples/var-debug.di +0 -6
  93. package/examples/var-inline.di +0 -4
  94. package/examples/var-test2.di +0 -6
  95. package/examples/variable-replace.di +0 -25
  96. package/examples/variable-simple.di +0 -16
  97. package/examples/variable-test.di +0 -22
  98. package/examples/whitespace-test.di +0 -24
  99. package/filePath +0 -1
  100. package/greeting.txt +0 -1
  101. package/src/cli.ts +0 -140
  102. package/src/index.ts +0 -33
  103. package/src/llm/ollama.ts +0 -58
  104. package/src/runtime/braket-parser.ts +0 -234
  105. package/src/runtime/interpreter.ts +0 -203
  106. package/src/runtime/parser.ts +0 -155
  107. package/src/runtime/session.ts +0 -325
  108. package/src/tags/assign.ts +0 -37
  109. package/src/tags/attr.ts +0 -64
  110. package/src/tags/available-subroutines.ts +0 -70
  111. package/src/tags/call.ts +0 -259
  112. package/src/tags/catch.ts +0 -24
  113. package/src/tags/defvar.ts +0 -115
  114. package/src/tags/environment.ts +0 -21
  115. package/src/tags/eval.ts +0 -71
  116. package/src/tags/exception.ts +0 -20
  117. package/src/tags/execute.ts +0 -52
  118. package/src/tags/expr.ts +0 -128
  119. package/src/tags/foreach.ts +0 -170
  120. package/src/tags/if.ts +0 -191
  121. package/src/tags/import.ts +0 -135
  122. package/src/tags/index.ts +0 -41
  123. package/src/tags/input.ts +0 -182
  124. package/src/tags/llm.ts +0 -415
  125. package/src/tags/loop.ts +0 -43
  126. package/src/tags/mongodb.ts +0 -70
  127. package/src/tags/output.ts +0 -53
  128. package/src/tags/parameters.ts +0 -81
  129. package/src/tags/require_module.ts +0 -19
  130. package/src/tags/subroutine.ts +0 -75
  131. package/src/tags/system.ts +0 -93
  132. package/src/tags/tag-check.ts +0 -176
  133. package/src/tags/test-if.ts +0 -112
  134. package/src/tags/throw.ts +0 -26
  135. package/src/tags/try.ts +0 -19
  136. package/src/tags/variable.ts +0 -25
  137. package/src/test-runner.ts +0 -300
  138. package/src/types/index.ts +0 -128
  139. package/src/utils/llm-adapter.ts +0 -113
  140. package/src/utils/tag-validator.ts +0 -231
  141. package/test-available-extends.di +0 -28
  142. package/test-available-simple.di +0 -12
  143. package/test-available-subroutines.di +0 -16
  144. package/test-call.di +0 -9
  145. package/test-extend-basic.di +0 -17
  146. package/test-extend-chain.di +0 -26
  147. package/test-extend-debug.di +0 -17
  148. package/test-extend-debug2.di +0 -15
  149. package/test-extend-person.di +0 -17
  150. package/test-extend-simple.di +0 -11
  151. package/test-extend-zhi.di +0 -23
  152. package/test-extend.di +0 -19
  153. package/test-extend2.di +0 -26
  154. package/test-extend3-fixed.di +0 -23
  155. package/test-extend3-trouble.di +0 -23
  156. package/test-extend3.di +0 -21
  157. package/test-factorial.di +0 -19
  158. package/test-input-debug.di +0 -19
  159. package/test-nested-debug.di +0 -7
  160. package/test-nested-debug2.di +0 -8
  161. package/test-no-extend.di +0 -16
  162. package/test-simple-call.di +0 -7
  163. package/test-simple.di +0 -6
  164. package/tests/README.md +0 -69
  165. package/tests/assign-basic.test.di +0 -7
  166. package/tests/assign-from-eval.test.di +0 -7
  167. package/tests/available-subroutines-foreach.test.di +0 -32
  168. package/tests/basic-output.test.di +0 -5
  169. package/tests/call-basic.test.di +0 -11
  170. package/tests/call-with-output.test.di +0 -10
  171. package/tests/comments-before-content.test.di +0 -6
  172. package/tests/defvar-multiple.test.di +0 -8
  173. package/tests/environment-basic.test.di +0 -22
  174. package/tests/environment-nonexistent.test.di +0 -5
  175. package/tests/environment-with-defvar.test.di +0 -15
  176. package/tests/eval-basic.test.di +0 -6
  177. package/tests/eval-with-variables.test.di +0 -8
  178. package/tests/exception-basic.test.di +0 -10
  179. package/tests/expr-basic.test.di +0 -11
  180. package/tests/extend-basic.test.di +0 -19
  181. package/tests/extend-inheritance-chain.test.di +0 -26
  182. package/tests/extend-multiple-nested.test.di +0 -24
  183. package/tests/extend-self.test.di +0 -19
  184. package/tests/extend-with-parameters.test.di +0 -14
  185. package/tests/generate-dirac.test.di +0 -22
  186. package/tests/if-conditional.test.di +0 -17
  187. package/tests/if-else.test.di +0 -11
  188. package/tests/if-with-variables.test.di +0 -8
  189. package/tests/import-basic.test.di +0 -6
  190. package/tests/input-file-all.test.di +0 -5
  191. package/tests/input-file-line.test.di +0 -15
  192. package/tests/input-file-loop.test.di +0 -12
  193. package/tests/input-stdin-all.test.di +0 -8
  194. package/tests/input-stdin-all.txt +0 -1
  195. package/tests/llm-validate.test.di +0 -17
  196. package/tests/loop-basic.test.di +0 -9
  197. package/tests/loop-nested.test.di +0 -10
  198. package/tests/loop-with-eval.test.di +0 -8
  199. package/tests/no-root-element.test.di +0 -6
  200. package/tests/output-file.test.di +0 -19
  201. package/tests/output-multiple.test.di +0 -9
  202. package/tests/parameters-basic.test.di +0 -6
  203. package/tests/require-module-basic.test.di +0 -7
  204. package/tests/subroutine-basic.test.di +0 -9
  205. package/tests/subroutine-multiple-params.test.di +0 -10
  206. package/tests/subroutine-nested-calls.test.di +0 -32
  207. package/tests/subroutine-sequential-calls.test.di +0 -36
  208. package/tests/system-background.test.di +0 -39
  209. package/tests/system-basic.test.di +0 -5
  210. package/tests/tag-check.test.di +0 -27
  211. package/tests/test-if-basic.test.di +0 -8
  212. package/tests/test-input.txt +0 -3
  213. package/tests/try-catch-basic.test.di +0 -10
  214. package/tests/try-catch-eval-error.test.di +0 -10
  215. package/tests/variable-basic.test.di +0 -6
  216. package/tests/variable-interpolation.test.di +0 -7
  217. package/tools/create-library.sh +0 -175
  218. package/tsconfig.json +0 -19
  219. /package/{examples/lib → lib}/advanced-math.di +0 -0
  220. /package/{examples/lib → lib}/fileops.di +0 -0
  221. /package/{examples/lib → lib}/mongodb.di +0 -0
@@ -1,38 +0,0 @@
1
- <!-- Simple Execute Demo - LLM generates and executes code -->
2
- <dirac>
3
- <output>Demo: LLM-Generated Executable Code&#10;&#10;</output>
4
-
5
- <!-- Simple calculation task -->
6
- <output>Task: Calculate 15 * 23 + 7&#10;</output>
7
- <LLM output="mathCode" maxTokens="150">
8
- Generate Dirac XML to calculate: 15 * 23 + 7
9
-
10
- Format:
11
- &lt;dirac&gt;
12
- &lt;eval name="result"&gt;return 15 * 23 + 7;&lt;/eval&gt;
13
- &lt;output&gt;Result: ${result}&lt;/output&gt;
14
- &lt;/dirac&gt;
15
-
16
- Return only XML, no markdown.
17
- </LLM>
18
-
19
- <execute source="mathCode" />
20
- <output>&#10;</output>
21
-
22
- <!-- File listing task -->
23
- <output>Task: Count files in current directory&#10;</output>
24
- <LLM output="fileCode" maxTokens="150">
25
- Generate Dirac XML to count files in current directory.
26
-
27
- Format:
28
- &lt;dirac&gt;
29
- &lt;eval name="count"&gt;return fs.readdirSync('.').length;&lt;/eval&gt;
30
- &lt;output&gt;Files: ${count}&lt;/output&gt;
31
- &lt;/dirac&gt;
32
-
33
- Return only XML, no markdown.
34
- </LLM>
35
-
36
- <execute source="fileCode" />
37
- <output>&#10;Done!&#10;</output>
38
- </dirac>
@@ -1,77 +0,0 @@
1
- <!-- File Manager Agent - Operational Example -->
2
- <dirac>
3
- <defvar name="targetDir" value="examples" />
4
-
5
- <output>Analyzing directory: ${targetDir}&#10;&#10;</output>
6
-
7
- <!-- Step 1: List files in directory -->
8
- <output>Listing files...&#10;</output>
9
- <eval name="fileList">
10
- const files = fs.readdirSync(targetDir);
11
- return files.join(', ');
12
- </eval>
13
- <output>Found: ${fileList}&#10;&#10;</output>
14
-
15
- <!-- Step 2: Ask LLM to analyze what's missing -->
16
- <output>Asking LLM to analyze...&#10;</output>
17
- <LLM output="analysis" maxTokens="200">
18
- I have a directory with these files: ${fileList}
19
-
20
- These appear to be example files for a programming language.
21
- Suggest ONE simple example file that would be useful to add.
22
-
23
- Respond with ONLY:
24
- 1. Filename (must end in .di)
25
- 2. Brief description (one line)
26
-
27
- Format:
28
- FILENAME: name.di
29
- DESCRIPTION: what it does
30
- </LLM>
31
- <output>${analysis}&#10;&#10;</output>
32
-
33
- <!-- Step 3: Extract filename from LLM response -->
34
- <eval name="newFilename">
35
- const text = analysis;
36
- const match = text.match(/FILENAME:\s*(\S+\.di)/i);
37
- return match ? match[1] : 'new-example.di';
38
- </eval>
39
-
40
- <output>Creating file: ${newFilename}&#10;</output>
41
-
42
- <!-- Step 4: Ask LLM to generate the file content -->
43
- <LLM output="fileContent" maxTokens="300">
44
- Create the content for ${newFilename} based on this description:
45
- ${analysis}
46
-
47
- The file should use Dirac XML syntax with these tags:
48
- - &lt;dirac&gt; (root)
49
- - &lt;defvar name="x" value="y" /&gt;
50
- - &lt;output&gt;text&lt;/output&gt;
51
- - &lt;LLM output="var"&gt;prompt&lt;/LLM&gt;
52
-
53
- Make it simple and functional. Include XML declaration and comment.
54
- </LLM>
55
-
56
- <!-- Step 5: Write the file -->
57
- <eval name="writeResult">
58
- const filePath = path.join(targetDir, newFilename);
59
- const content = fileContent;
60
- fs.writeFileSync(filePath, content, 'utf-8');
61
- return 'File written successfully to ' + filePath;
62
- </eval>
63
-
64
- <output>&#10;Result: ${writeResult}&#10;</output>
65
-
66
- <!-- Step 6: Verify the file was created -->
67
- <eval name="verification">
68
- const filePath = path.join(targetDir, newFilename);
69
- if (fs.existsSync(filePath)) {
70
- const stats = fs.statSync(filePath);
71
- return 'Verified! File size: ' + stats.size + ' bytes';
72
- }
73
- return 'Error: File not found';
74
- </eval>
75
-
76
- <output>Verification: ${verification}&#10;</output>
77
- </dirac>
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Executable Dirac Script: Quick File Analysis -->
3
- <dirac>
4
- <eval name="fileCount">
5
- return fs.readdirSync('.').length;
6
- </eval>
7
-
8
- <eval name="diracFiles">
9
- return fs.readdirSync('.')
10
- .filter(f => f.endsWith('.di'))
11
- .length;
12
- </eval>
13
-
14
- <output>Current Directory Analysis&#10;</output>
15
- <output>========================&#10;</output>
16
- <output>Total files: ${fileCount}&#10;</output>
17
- <output>Dirac scripts: ${diracFiles}&#10;</output>
18
- </dirac>
package/examples/hello.bk DELETED
@@ -1 +0,0 @@
1
- |output>Hello from bra-ket notation!
package/examples/hello.di DELETED
@@ -1,5 +0,0 @@
1
- <!-- Basic variable and output test -->
2
- <dirac>
3
- <defvar name="greeting" value="Hello, World!" />
4
- <output><variable name="greeting" /></output>
5
- </dirac>
@@ -1,91 +0,0 @@
1
- <dirac>
2
- <output>====== Comparing IF and TEST-IF ======</output>
3
- <output>
4
- </output>
5
-
6
- <defvar name="score" value="85"/>
7
-
8
- <output>--- Using C-style IF ---</output>
9
- <if>
10
- <cond eval="ge">
11
- <arg><variable name="score"/></arg>
12
- <arg>80</arg>
13
- </cond>
14
- <then>
15
- <output>Grade: B or better (score >= 80)</output>
16
- </then>
17
- <else>
18
- <output>Grade: Below B (score < 80)</output>
19
- </else>
20
- </if>
21
- <output>
22
- </output>
23
-
24
- <output>--- Using TEST-IF (equivalent, no else) ---</output>
25
- <test-if test="$score" ge="80">
26
- <output>Grade: B or better (score >= 80)</output>
27
- </test-if>
28
- <output>
29
- </output>
30
-
31
- <output>--- Nested conditionals with IF ---</output>
32
- <defvar name="temp_score" value="85"/>
33
- <if>
34
- <cond eval="ge">
35
- <arg><variable name="temp_score"/></arg>
36
- <arg>80</arg>
37
- </cond>
38
- <then>
39
- <output>Good job! (B grade or better)</output>
40
- </then>
41
- <else>
42
- <output>Keep working! (below B)</output>
43
- </else>
44
- </if>
45
- <output>
46
- </output>
47
-
48
- <output>--- Multiple TEST-IF conditions ---</output>
49
- <test-if test="$score" ge="90">
50
- <output>Excellent! (A grade)</output>
51
- </test-if>
52
- <test-if test="$score" lt="90">
53
- <test-if test="$score" ge="80">
54
- <output>Good job! (B grade)</output>
55
- </test-if>
56
- </test-if>
57
- <test-if test="$score" lt="80">
58
- <output>Keep working! (C or below)</output>
59
- </test-if>
60
- <output>
61
- </output>
62
-
63
- <output>--- String comparison with IF ---</output>
64
- <defvar name="status" value="active"/>
65
- <if>
66
- <cond eval="eq">
67
- <arg><variable name="status"/></arg>
68
- <arg>active</arg>
69
- </cond>
70
- <then>
71
- <output>System is active</output>
72
- </then>
73
- <else>
74
- <output>System is not active</output>
75
- </else>
76
- </if>
77
- <output>
78
- </output>
79
-
80
- <output>--- String comparison with TEST-IF ---</output>
81
- <test-if test="$status" eq="active">
82
- <output>System is active</output>
83
- </test-if>
84
- <test-if test="$status" ne="active">
85
- <output>System is not active</output>
86
- </test-if>
87
- <output>
88
- </output>
89
-
90
- <output>====== Comparison Complete ======</output>
91
- </dirac>
@@ -1,149 +0,0 @@
1
- <dirac>
2
- <output>===== C-Style IF with cond/then/else =====</output>
3
- <output>
4
- </output>
5
-
6
- <!-- Test 1: Simple condition with cond eval -->
7
- <output>Test 1: Simple equality test</output>
8
- <defvar name="x" value="5"/>
9
-
10
- <if>
11
- <cond eval="eq">
12
- <arg><variable name="x"/></arg>
13
- <arg>5</arg>
14
- </cond>
15
- <then>
16
- <output>x equals 5 (correct!)</output>
17
- </then>
18
- <else>
19
- <output>x does not equal 5 (wrong!)</output>
20
- </else>
21
- </if>
22
- <output>
23
- </output>
24
-
25
- <!-- Test 2: Less than comparison -->
26
- <output>Test 2: Less than comparison</output>
27
- <defvar name="a" value="3"/>
28
-
29
- <if>
30
- <cond eval="lt">
31
- <arg><variable name="a"/></arg>
32
- <arg>10</arg>
33
- </cond>
34
- <then>
35
- <output>a is less than 10 (correct!)</output>
36
- </then>
37
- <else>
38
- <output>a is not less than 10 (wrong!)</output>
39
- </else>
40
- </if>
41
- <output>
42
- </output>
43
-
44
- <!-- Test 3: Not equal -->
45
- <output>Test 3: Not equal test</output>
46
- <defvar name="status" value="active"/>
47
-
48
- <if>
49
- <cond eval="ne">
50
- <arg><variable name="status"/></arg>
51
- <arg>inactive</arg>
52
- </cond>
53
- <then>
54
- <output>Status is not inactive (correct!)</output>
55
- </then>
56
- <else>
57
- <output>Status is inactive (wrong!)</output>
58
- </else>
59
- </if>
60
- <output>
61
- </output>
62
-
63
- <!-- Test 4: Greater than or equal -->
64
- <output>Test 4: Greater than or equal</output>
65
- <defvar name="age" value="18"/>
66
-
67
- <if>
68
- <cond eval="ge">
69
- <arg><variable name="age"/></arg>
70
- <arg>18</arg>
71
- </cond>
72
- <then>
73
- <output>Age is 18 or older (correct!)</output>
74
- </then>
75
- <else>
76
- <output>Age is under 18 (wrong!)</output>
77
- </else>
78
- </if>
79
- <output>
80
- </output>
81
-
82
- <!-- Test 5: Condition without eval (predicate style) -->
83
- <output>Test 5: Simple predicate (non-empty is true)</output>
84
- <defvar name="name" value="Alice"/>
85
-
86
- <if>
87
- <variable name="name"/>
88
- <then>
89
- <output>Name exists: <variable name="name"/></output>
90
- </then>
91
- <else>
92
- <output>Name is empty</output>
93
- </else>
94
- </if>
95
- <output>
96
- </output>
97
-
98
- <!-- Test 6: False condition -->
99
- <output>Test 6: False condition (should go to else)</output>
100
- <defvar name="count" value="0"/>
101
-
102
- <if>
103
- <cond eval="eq">
104
- <arg><variable name="count"/></arg>
105
- <arg>10</arg>
106
- </cond>
107
- <then>
108
- <output>Count is 10 (wrong!)</output>
109
- </then>
110
- <else>
111
- <output>Count is not 10 (correct!)</output>
112
- </else>
113
- </if>
114
- <output>
115
- </output>
116
-
117
- <!-- Test 7: Only then block (no else) -->
118
- <output>Test 7: If without else block</output>
119
- <defvar name="enabled" value="true"/>
120
-
121
- <if>
122
- <output>true</output>
123
- <then>
124
- <output>Feature is enabled</output>
125
- </then>
126
- </if>
127
- <output>
128
- </output>
129
-
130
- <!-- Test 8: Using <do> instead of <then> -->
131
- <output>Test 8: Using do instead of then</output>
132
-
133
- <if>
134
- <cond eval="same">
135
- <arg>hello</arg>
136
- <arg>hello</arg>
137
- </cond>
138
- <do>
139
- <output>Strings match (correct!)</output>
140
- </do>
141
- <else>
142
- <output>Strings don't match (wrong!)</output>
143
- </else>
144
- </if>
145
- <output>
146
- </output>
147
-
148
- <output>===== All C-style IF tests complete =====</output>
149
- </dirac>
@@ -1,56 +0,0 @@
1
- <dirac>
2
- <output>====== Comparing IF and TEST-IF ======</output>
3
- <output>
4
- </output>
5
-
6
- <defvar name="score" value="85"/>
7
-
8
- <output>--- Using C-style IF ---</output>
9
- <if>
10
- <cond eval="ge">
11
- <arg><variable name="score"/></arg>
12
- <arg>80</arg>
13
- </cond>
14
- <then>
15
- <output>Grade: B or better (score >= 80)</output>
16
- </then>
17
- <else>
18
- <output>Grade: Below B (score less than 80)</output>
19
- </else>
20
- </if>
21
- <output>
22
- </output>
23
-
24
- <output>--- Using TEST-IF (no else clause) ---</output>
25
- <test-if test="$score" ge="80">
26
- <output>Grade: B or better (score >= 80)</output>
27
- </test-if>
28
- <output>
29
- </output>
30
-
31
- <output>--- String comparison with IF ---</output>
32
- <defvar name="status" value="active"/>
33
- <if>
34
- <cond eval="eq">
35
- <arg><variable name="status"/></arg>
36
- <arg>active</arg>
37
- </cond>
38
- <then>
39
- <output>System is active</output>
40
- </then>
41
- <else>
42
- <output>System is not active</output>
43
- </else>
44
- </if>
45
- <output>
46
- </output>
47
-
48
- <output>--- String comparison with TEST-IF ---</output>
49
- <test-if test="$status" eq="active">
50
- <output>System is active</output>
51
- </test-if>
52
- <output>
53
- </output>
54
-
55
- <output>====== Comparison Complete ======</output>
56
- </dirac>
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Demo: Using imported libraries -->
3
- <dirac>
4
- <output>Import Demo&#10;&#10;</output>
5
-
6
- <!-- Import libraries -->
7
- <import src="./lib/math.di" />
8
- <import src="./lib/fileops.di" />
9
-
10
- <output>Testing math library:&#10;</output>
11
- <defvar name="x" value="5" />
12
- <output>Square of ${x}: </output>
13
- <call name="SQUARE" />
14
-
15
- <defvar name="a" value="10" />
16
- <defvar name="b" value="20" />
17
- <output>Add ${a} + ${b}: </output>
18
- <call name="ADD" />
19
-
20
- <defvar name="num" value="5" />
21
- <output>Factorial of ${num}: </output>
22
- <call name="FACTORIAL" />
23
-
24
- <output>&#10;Testing file ops library:&#10;</output>
25
- <defvar name="dir" value="." />
26
- <call name="LIST_FILES" />
27
- <call name="COUNT_FILES" />
28
-
29
- <defvar name="filepath" value="./package.json" />
30
- <call name="FILE_EXISTS" />
31
- </dirac>
@@ -1,7 +0,0 @@
1
- <greet|
2
- |parameters select=@name>
3
- |output>Hello, |variable name=name>!
4
-
5
- |greet name=Alice>
6
- |output>
7
- |greet name=Bob>
@@ -1,32 +0,0 @@
1
- <!-- Agent with LLM-generated operations -->
2
- <dirac>
3
- <defvar name="task" value="create a hello world file named greeting.txt" />
4
-
5
- <output>Task: ${task}&#10;&#10;</output>
6
-
7
- <!-- Ask LLM to generate Dirac code to accomplish the task -->
8
- <output>Asking LLM to generate executable code...&#10;</output>
9
- <LLM output="generatedCode" maxTokens="400">
10
- You are a Dirac code generator. Generate valid Dirac XML to accomplish this task:
11
- "${task}"
12
-
13
- Available tags:
14
- - &lt;dirac&gt; (root element)
15
- - &lt;defvar name="x" value="y" /&gt; (define variable)
16
- - &lt;output&gt;text&lt;/output&gt; (print output)
17
- - &lt;eval name="result"&gt;JavaScript code&lt;/eval&gt; (run JS, has fs and path modules)
18
-
19
- The eval tag can use fs.writeFileSync(filename, content) to write files.
20
- Variables are accessed as plain JavaScript variables (not with ${}).
21
-
22
- Return ONLY valid Dirac XML starting with &lt;dirac&gt; tag. No explanations.
23
- </LLM>
24
-
25
- <output>&#10;Generated code:&#10;${generatedCode}&#10;&#10;</output>
26
-
27
- <!-- Execute the LLM-generated code -->
28
- <output>Executing generated code...&#10;</output>
29
- <execute source="generatedCode" />
30
-
31
- <output>&#10;Task completed!&#10;</output>
32
- </dirac>
@@ -1,12 +0,0 @@
1
- <!-- LLM integration example - THE INNOVATION -->
2
- <dirac>
3
- <defvar name="topic" value="quantum computing" />
4
-
5
- <output>Asking LLM about <variable name="topic" />...&#10;&#10;</output>
6
-
7
- <LLM output="response" maxTokens="200">
8
- Explain <variable name="topic" /> in one sentence.
9
- </LLM>
10
-
11
- <output>Response: <variable name="response" />&#10;</output>
12
- </dirac>
@@ -1,6 +0,0 @@
1
- <dirac>
2
- <subroutine name="background" description="set the background color." param-color="string:required:color name" >
3
- this is my color: <variable name="color" />
4
- </subroutine>
5
- <llm execute="true">what is the color of red mix with yellow and set the background color to that color</llm>
6
- </dirac>
@@ -1,13 +0,0 @@
1
- <dirac>
2
-
3
- <subroutine name="background" description="set the background color." param-color="string:required:color name" >
4
- <parameters select="@color"/>
5
- <output>
6
- this is my color: <variable name="color" />
7
- </output>
8
- </subroutine>
9
-
10
- <llm >set the background color to red</llm>
11
-
12
-
13
- </dirac>
@@ -1,6 +0,0 @@
1
- <dirac>
2
- <subroutine name="background" description="set the background color." param-color="string:required:color name" >
3
- this is my color: <variable name="color" />
4
- </subroutine>
5
- <llm execute="true" validate="true">set the background color to red</llm>
6
- </dirac>