dirac-lang 0.1.23 → 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 (226) hide show
  1. package/dist/{chunk-APWJJXNI.js → chunk-7OUYWIZV.js} +55 -14
  2. package/dist/{chunk-RGS2XK6T.js → chunk-OUMUIBK3.js} +1 -1
  3. package/dist/cli.js +15 -3
  4. package/dist/index.js +2 -2
  5. package/dist/{interpreter-UZDVASAW.js → interpreter-MTIIHIIQ.js} +1 -1
  6. package/dist/test-runner.js +1 -1
  7. package/lib/index.di +9 -0
  8. package/package.json +13 -1
  9. package/.env.example +0 -8
  10. package/COMMUNITY.md +0 -465
  11. package/CONDITIONAL-TAGS.md +0 -172
  12. package/EXCEPTION-HANDLING.md +0 -156
  13. package/LIBRARIES.md +0 -172
  14. package/LLM-VALIDATION.md +0 -128
  15. package/NAMESPACES.md +0 -366
  16. package/PROMOTION.md +0 -257
  17. package/QUICKSTART-LIBRARY.md +0 -93
  18. package/TEST-COVERAGE.md +0 -113
  19. package/TESTING.md +0 -162
  20. package/config.test.yml +0 -5
  21. package/dirac-http/examples/demo.di +0 -9
  22. package/dirac-http/lib/index.di +0 -12
  23. package/examples/add-demo.di +0 -74
  24. package/examples/add.bk +0 -11
  25. package/examples/advanced-math-demo.di +0 -53
  26. package/examples/calculator.di +0 -32
  27. package/examples/compact-test.di +0 -6
  28. package/examples/comprehensive.bk +0 -29
  29. package/examples/defvar-variable-demo.di +0 -18
  30. package/examples/direct-call.di +0 -17
  31. package/examples/disk-analysis.di +0 -16
  32. package/examples/exception-demo.di +0 -82
  33. package/examples/executable-hello.di +0 -7
  34. package/examples/execute-demo.di +0 -38
  35. package/examples/file-manager.di +0 -77
  36. package/examples/file-stats.di +0 -18
  37. package/examples/hello.bk +0 -1
  38. package/examples/hello.di +0 -5
  39. package/examples/if-comparison.di +0 -91
  40. package/examples/if-cstyle-test.di +0 -149
  41. package/examples/if-vs-testif.di +0 -56
  42. package/examples/import-demo.di +0 -31
  43. package/examples/inline-test.bk +0 -7
  44. package/examples/llm-agent.di +0 -32
  45. package/examples/llm-basic.di +0 -12
  46. package/examples/llm-command-more.di +0 -6
  47. package/examples/llm-command-no-exec.di +0 -13
  48. package/examples/llm-command.di +0 -6
  49. package/examples/llm-complex.di +0 -141
  50. package/examples/llm-feedback-debug.di +0 -30
  51. package/examples/llm-feedback-demo.di +0 -19
  52. package/examples/llm-feedback-math.di +0 -22
  53. package/examples/llm-feedback-simple.di +0 -16
  54. package/examples/llm-feedback-sub.di +0 -22
  55. package/examples/llm-no-feedback.di +0 -10
  56. package/examples/llm-recursive.di +0 -31
  57. package/examples/llm-reflection-test.di +0 -19
  58. package/examples/llm-simple-test.di +0 -12
  59. package/examples/llm-subs.di +0 -132
  60. package/examples/llm-use-subs.di +0 -6
  61. package/examples/llm-validate-test.di +0 -18
  62. package/examples/loop.di +0 -12
  63. package/examples/math-test.di +0 -22
  64. package/examples/minimal-test.di +0 -13
  65. package/examples/mongodb-context-test.di +0 -27
  66. package/examples/mongodb-count-events.di +0 -8
  67. package/examples/mongodb-import-demo.di +0 -25
  68. package/examples/mongodb-simple-test.di +0 -18
  69. package/examples/nl-agent.di +0 -47
  70. package/examples/parameters-demo.di +0 -68
  71. package/examples/params-meta-test.di +0 -17
  72. package/examples/params-test.di +0 -10
  73. package/examples/recipe-chain.di +0 -38
  74. package/examples/recursive-llm.di +0 -44
  75. package/examples/sample-library/README.md +0 -152
  76. package/examples/sample-library/examples/demo.di +0 -34
  77. package/examples/sample-library/lib/index.di +0 -65
  78. package/examples/sample-library/package.json +0 -31
  79. package/examples/scope-test-nested.di +0 -60
  80. package/examples/scope-test.di +0 -55
  81. package/examples/seamless.di +0 -45
  82. package/examples/shell-test.bk +0 -10
  83. package/examples/simple-import.di +0 -13
  84. package/examples/simple-recursive.di +0 -26
  85. package/examples/story-builder.di +0 -45
  86. package/examples/subroutine.di +0 -23
  87. package/examples/system-llm.di +0 -21
  88. package/examples/system-simple.di +0 -3
  89. package/examples/system-test.di +0 -8
  90. package/examples/tag-check-test.di +0 -139
  91. package/examples/task-assistant.di +0 -27
  92. package/examples/test-if-demo.di +0 -110
  93. package/examples/test-parameters.di +0 -50
  94. package/examples/try-catch-test.di +0 -118
  95. package/examples/two-styles.di +0 -28
  96. package/examples/var-debug.di +0 -6
  97. package/examples/var-inline.di +0 -4
  98. package/examples/var-test2.di +0 -6
  99. package/examples/variable-replace.di +0 -25
  100. package/examples/variable-simple.di +0 -16
  101. package/examples/variable-test.di +0 -22
  102. package/examples/whitespace-test.di +0 -24
  103. package/filePath +0 -1
  104. package/greeting.txt +0 -1
  105. package/src/cli.ts +0 -140
  106. package/src/index.ts +0 -33
  107. package/src/llm/ollama.ts +0 -58
  108. package/src/runtime/braket-parser.ts +0 -234
  109. package/src/runtime/interpreter.ts +0 -203
  110. package/src/runtime/parser.ts +0 -155
  111. package/src/runtime/session.ts +0 -325
  112. package/src/tags/assign.ts +0 -37
  113. package/src/tags/attr.ts +0 -64
  114. package/src/tags/available-subroutines.ts +0 -70
  115. package/src/tags/call.ts +0 -259
  116. package/src/tags/catch.ts +0 -24
  117. package/src/tags/defvar.ts +0 -115
  118. package/src/tags/environment.ts +0 -21
  119. package/src/tags/eval.ts +0 -71
  120. package/src/tags/exception.ts +0 -20
  121. package/src/tags/execute.ts +0 -52
  122. package/src/tags/expr.ts +0 -128
  123. package/src/tags/foreach.ts +0 -170
  124. package/src/tags/if.ts +0 -191
  125. package/src/tags/import.ts +0 -66
  126. package/src/tags/index.ts +0 -41
  127. package/src/tags/input.ts +0 -182
  128. package/src/tags/llm.ts +0 -415
  129. package/src/tags/loop.ts +0 -43
  130. package/src/tags/mongodb.ts +0 -70
  131. package/src/tags/output.ts +0 -53
  132. package/src/tags/parameters.ts +0 -81
  133. package/src/tags/require_module.ts +0 -19
  134. package/src/tags/subroutine.ts +0 -75
  135. package/src/tags/system.ts +0 -93
  136. package/src/tags/tag-check.ts +0 -176
  137. package/src/tags/test-if.ts +0 -112
  138. package/src/tags/throw.ts +0 -26
  139. package/src/tags/try.ts +0 -19
  140. package/src/tags/variable.ts +0 -25
  141. package/src/test-runner.ts +0 -300
  142. package/src/types/index.ts +0 -128
  143. package/src/utils/llm-adapter.ts +0 -113
  144. package/src/utils/tag-validator.ts +0 -231
  145. package/test-available-extends.di +0 -28
  146. package/test-available-simple.di +0 -12
  147. package/test-available-subroutines.di +0 -16
  148. package/test-call.di +0 -9
  149. package/test-extend-basic.di +0 -17
  150. package/test-extend-chain.di +0 -26
  151. package/test-extend-debug.di +0 -17
  152. package/test-extend-debug2.di +0 -15
  153. package/test-extend-person.di +0 -17
  154. package/test-extend-simple.di +0 -11
  155. package/test-extend-zhi.di +0 -23
  156. package/test-extend.di +0 -19
  157. package/test-extend2.di +0 -26
  158. package/test-extend3-fixed.di +0 -23
  159. package/test-extend3-trouble.di +0 -23
  160. package/test-extend3.di +0 -21
  161. package/test-factorial.di +0 -19
  162. package/test-input-debug.di +0 -19
  163. package/test-nested-debug.di +0 -7
  164. package/test-nested-debug2.di +0 -8
  165. package/test-no-extend.di +0 -16
  166. package/test-simple-call.di +0 -7
  167. package/test-simple.di +0 -6
  168. package/tests/README.md +0 -69
  169. package/tests/assign-basic.test.di +0 -7
  170. package/tests/assign-from-eval.test.di +0 -7
  171. package/tests/available-subroutines-foreach.test.di +0 -32
  172. package/tests/basic-output.test.di +0 -5
  173. package/tests/call-basic.test.di +0 -11
  174. package/tests/call-with-output.test.di +0 -10
  175. package/tests/comments-before-content.test.di +0 -6
  176. package/tests/defvar-multiple.test.di +0 -8
  177. package/tests/environment-basic.test.di +0 -22
  178. package/tests/environment-nonexistent.test.di +0 -5
  179. package/tests/environment-with-defvar.test.di +0 -15
  180. package/tests/eval-basic.test.di +0 -6
  181. package/tests/eval-with-variables.test.di +0 -8
  182. package/tests/exception-basic.test.di +0 -10
  183. package/tests/expr-basic.test.di +0 -11
  184. package/tests/extend-basic.test.di +0 -19
  185. package/tests/extend-inheritance-chain.test.di +0 -26
  186. package/tests/extend-multiple-nested.test.di +0 -24
  187. package/tests/extend-self.test.di +0 -19
  188. package/tests/extend-with-parameters.test.di +0 -14
  189. package/tests/generate-dirac.test.di +0 -22
  190. package/tests/if-conditional.test.di +0 -17
  191. package/tests/if-else.test.di +0 -11
  192. package/tests/if-with-variables.test.di +0 -8
  193. package/tests/import-basic.test.di +0 -6
  194. package/tests/input-file-all.test.di +0 -5
  195. package/tests/input-file-line.test.di +0 -15
  196. package/tests/input-file-loop.test.di +0 -12
  197. package/tests/input-stdin-all.test.di +0 -8
  198. package/tests/input-stdin-all.txt +0 -1
  199. package/tests/llm-validate.test.di +0 -17
  200. package/tests/loop-basic.test.di +0 -9
  201. package/tests/loop-nested.test.di +0 -10
  202. package/tests/loop-with-eval.test.di +0 -8
  203. package/tests/no-root-element.test.di +0 -6
  204. package/tests/output-file.test.di +0 -19
  205. package/tests/output-multiple.test.di +0 -9
  206. package/tests/parameters-basic.test.di +0 -6
  207. package/tests/require-module-basic.test.di +0 -7
  208. package/tests/subroutine-basic.test.di +0 -9
  209. package/tests/subroutine-multiple-params.test.di +0 -10
  210. package/tests/subroutine-nested-calls.test.di +0 -32
  211. package/tests/subroutine-sequential-calls.test.di +0 -36
  212. package/tests/system-background.test.di +0 -39
  213. package/tests/system-basic.test.di +0 -5
  214. package/tests/tag-check.test.di +0 -27
  215. package/tests/test-if-basic.test.di +0 -8
  216. package/tests/test-input.txt +0 -3
  217. package/tests/try-catch-basic.test.di +0 -10
  218. package/tests/try-catch-eval-error.test.di +0 -10
  219. package/tests/variable-basic.test.di +0 -6
  220. package/tests/variable-interpolation.test.di +0 -7
  221. package/tools/create-library.sh +0 -175
  222. package/tsconfig.json +0 -19
  223. /package/{examples/lib → lib}/advanced-math.di +0 -0
  224. /package/{examples/lib → lib}/fileops.di +0 -0
  225. /package/{examples/lib → lib}/math.di +0 -0
  226. /package/{examples/lib → lib}/mongodb.di +0 -0
@@ -1,141 +0,0 @@
1
- <dirac>
2
- <!-- UI Control Services -->
3
- <!-- These subroutines are exposed as natural language endpoints -->
4
-
5
- <subroutine name="background"
6
- description="Change the background color, do not generate other tags like <changeBackground /> use precise tag"
7
- param-color="string:required:Background color:red|blue|green|yellow|orange|purple|pink|white|black">
8
- <parameters select="@color"/>
9
-
10
- <eval>
11
- console.log('Changing background color to: ' + color);
12
- </eval>
13
- </subroutine>
14
-
15
- <subroutine name="set-text-size"
16
- description="Adjust the text size"
17
- param-size="string:required:Font size:12px|14px|16px|18px|20px|24px">
18
- <parameters select="@size" />
19
- <eval>
20
- console.log("change text size to "+size );
21
- document.body.style.fontSize = '${size}';
22
- </eval>
23
- </subroutine>
24
-
25
- <subroutine name="reset-styles"
26
- description="Reset all styles to default">
27
- <eval>
28
- console.log("reset all styles back");
29
- document.body.style.backgroundColor = 'white';
30
- document.body.style.fontSize = '16px';
31
- </eval>
32
- </subroutine>
33
-
34
- <subroutine name="text-color"
35
- description="Change the text color"
36
- param-color="string:required:Text color:black|white|red|blue|green">
37
- <parameters select="@color" />
38
- <eval>
39
- console.log("change color of text to "+color);
40
- document.body.style.color = '${color}';
41
- </eval>
42
- </subroutine>
43
-
44
- <!-- Event Generation Examples -->
45
-
46
- <subroutine name="click-button"
47
- description="Simulate clicking a button"
48
- param-selector="string:optional:CSS selector (default: #submit-button)">
49
- <eval>
50
- const selector = '${selector}' || '#submit-button';
51
- const element = document.querySelector(selector);
52
- if (element) {
53
- const clickEvent = new MouseEvent('click', {
54
- bubbles: true,
55
- cancelable: true,
56
- view: window
57
- });
58
- element.dispatchEvent(clickEvent);
59
- } else {
60
- throw new Error('Element not found: ' + selector);
61
- }
62
- </eval>
63
- </subroutine>
64
-
65
- <subroutine name="type-text"
66
- description="Type text into an input field"
67
- param-text="string:required:Text to type"
68
- param-field="string:optional:Which field:name|email">
69
- <parameters select="@text" />
70
- <parameters select="@field" />
71
- <eval>
72
- const _field = typeof field !== 'undefined' && field ? field : 'name';
73
- const selector = _field === 'email' ? '#email-input' : '#name-input';
74
- const input = document.querySelector(selector);
75
- if (input) {
76
- input.value = text;
77
- input.dispatchEvent(new Event('input', { bubbles: true }));
78
- input.dispatchEvent(new Event('change', { bubbles: true }));
79
- } else {
80
- throw new Error('Input not found: ' + selector);
81
- }
82
- </eval>
83
- </subroutine>
84
-
85
- <subroutine name="check-terms"
86
- description="Check or uncheck the terms checkbox"
87
- param-checked="string:optional:Check state:true|false">
88
- <eval>
89
- const shouldCheck = '${checked}' !== 'false';
90
- const checkbox = document.querySelector('#terms-checkbox');
91
- if (checkbox) {
92
- checkbox.checked = shouldCheck;
93
- checkbox.dispatchEvent(new Event('change', { bubbles: true }));
94
- } else {
95
- throw new Error('Checkbox not found');
96
- }
97
- </eval>
98
- </subroutine>
99
-
100
- <subroutine name="clear-input"
101
- description="Clear an input field"
102
- param-field="string:optional:Which field:name|email">
103
- <eval>
104
- const field = '${field}' || 'name';
105
- const selector = field === 'email' ? '#email-input' : '#name-input';
106
- const input = document.querySelector(selector);
107
- if (input) {
108
- input.value = '';
109
- input.dispatchEvent(new Event('input', { bubbles: true }));
110
- input.dispatchEvent(new Event('change', { bubbles: true }));
111
- } else {
112
- throw new Error('Input not found: ' + selector);
113
- }
114
- </eval>
115
- </subroutine>
116
-
117
- <!--
118
- <subroutine name="modify-file"
119
- description="modify a file based on pattern and replacement field "
120
- param-filename="string|required"
121
- param-pattern="string|required"
122
- param-replace="string|required"
123
- >
124
- <parameters select="@filename" />
125
- <parameters select="@pattern" />
126
- <parameters select="@replace" />
127
- <system>
128
- sed -e 's/${pattern}/${replace}/g' ${filename}
129
- </system>
130
- </subroutine>
131
- -->
132
-
133
- <llm noextra="true" execute="false">
134
- <system>
135
- ls -tl
136
- </system>
137
- find me the file with name hello.di and modify the pattern of World with Zhi
138
- use the command <modify-file I listed to do this.
139
- </llm>
140
-
141
- </dirac>
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Test: Feedback with math calculation - DEBUG VERSION -->
3
-
4
- <dirac>
5
- <subroutine name="add" description="addition of two numbers" param-a="number:required:first argument::2" param-b="number:required:second argument::3">
6
- <output>DEBUG: a=<variable name="a" />, b=<variable name="b" />
7
- </output>
8
- <expr eval="plus">
9
- <arg><variable name="a" /></arg>
10
- <arg><variable name="b" /></arg>
11
- </expr>
12
- </subroutine>
13
-
14
- <llm
15
- execute="true"
16
- feedback="true"
17
- autocorrect="true"
18
- max-iterations="3"
19
- replace-tick="true"
20
- output-var="generated_code">
21
- Calculate 5 + 3 using the add subroutine and display the result.
22
- </llm>
23
-
24
- <output>
25
-
26
- Generated code was:
27
- <variable name="generated_code" />
28
- </output>
29
-
30
- </dirac>
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Test: LLM feedback mode
3
- Description: Test the feedback loop where LLM generates code, sees output, and can iterate
4
- Expected: Should output "Hello from feedback loop!" and eventually say "DONE"
5
- -->
6
-
7
- <dirac>
8
- <llm
9
- execute="true"
10
- feedback="true"
11
- max-iterations="2"
12
- validate="true"
13
- autocorrect="true"
14
- max-retries="2"
15
- replace-tick="true"
16
- no-extra="true">
17
- Use the output tag to print "Hello from feedback loop!"
18
- </llm>
19
- </dirac>
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Test: Feedback with math calculation -->
3
-
4
- <dirac>
5
- <subroutine name="add" description="addition of two numbers " param-a="number:required:first argument::1st arg" param-b="number:required:second argument::2nd arg">
6
- <expr eval="plus">
7
- <arg><variable name="a" /></arg>
8
- <arg><variable name="b" /></arg>
9
- </expr>
10
- </subroutine>
11
-
12
- <llm
13
- execute="true"
14
- feedback="true"
15
- validate="true"
16
- autocorrect="true"
17
- max-iterations="3"
18
- replace-tick="true">
19
- Calculate 5 + 3 using the add subroutine and display the result.
20
- </llm>
21
-
22
- </dirac>
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Test: Simple feedback mode without validation -->
3
-
4
- <dirac>
5
- <subroutine name="greet" param-name="string">
6
- <output>Hello, <variable name="name" />!</output>
7
- </subroutine>
8
-
9
- <llm
10
- execute="true"
11
- feedback="true"
12
- max-iterations="2"
13
- replace-tick="true">
14
- Call greet with name="Feedback Test"
15
- </llm>
16
- </dirac>
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Test: LLM feedback mode with subroutine
3
- Description: Test feedback loop with a simple subroutine
4
- Expected: Should call print-message and see the feedback loop work
5
- -->
6
-
7
- <dirac>
8
- <subroutine name="print-message" param-text="string">
9
- <output><variable name="text" /></output>
10
- </subroutine>
11
-
12
- <llm
13
- execute="true"
14
- feedback="true"
15
- max-iterations="2"
16
- validate="true"
17
- autocorrect="true"
18
- max-retries="2"
19
- replace-tick="true">
20
- Call print-message with text="Hello from feedback loop!"
21
- </llm>
22
- </dirac>
@@ -1,10 +0,0 @@
1
-
2
- <dirac>
3
- <subroutine name="greet" param-name="string">
4
- <output>Hello, <variable name="name" />!</output>
5
- </subroutine>
6
-
7
- <llm execute="true" >
8
- Hi, my name is Zhi, greet me
9
- </llm>
10
- </dirac>
@@ -1,31 +0,0 @@
1
- <!-- Recursive LLM - LLM calling Dirac calling LLM -->
2
- <dirac>
3
- <!-- Define a subroutine that gets stock info -->
4
- <subroutine name="getStockPrice">
5
- <parameters>
6
- <variable name="symbol" passby="value" />
7
- </parameters>
8
-
9
- <LLM output="price" maxTokens="50">
10
- What is the current approximate stock price of ${symbol}?
11
- Respond with just a number (e.g., "150.23").
12
- </LLM>
13
-
14
- <output>${symbol}: $${price}</output>
15
- </subroutine>
16
-
17
- <!-- LLM decides which stocks to check -->
18
- <LLM output="response">
19
- List 3 major tech stocks to check, one per line.
20
- Format: SYMBOL only (e.g., "AAPL")
21
- </LLM>
22
-
23
- <output>Checking stocks from LLM: ${response}&#10;&#10;</output>
24
-
25
- <!-- In the future, this could parse ${response} and call getStockPrice for each -->
26
- <call name="getStockPrice">
27
- <parameters>
28
- <variable value="AAPL" />
29
- </parameters>
30
- </call>
31
- </dirac>
@@ -1,19 +0,0 @@
1
- <dirac>
2
- <subroutine name="inventory" description="Show you the inventory" >
3
- you have reachded the inventory
4
- </subroutine>
5
-
6
- <subroutine name="order" description="Places an order for an item." param-item="string:required:Item name" param-quantity="number:required:Quantity">
7
- <parameters select="@item"/>
8
- <parameters select="@quantity"/>
9
- <output>
10
- this is my item: <variable name="item" />
11
- and <variable name="quantity" />
12
- </output>
13
- </subroutine>
14
-
15
- <llm execute="true">Show me my inventory</llm>
16
- <llm execute="true">Order 2 apples</llm>
17
-
18
-
19
- </dirac>
@@ -1,12 +0,0 @@
1
- <dirac>
2
- <defvar name="topic" value="test" />
3
- <output>Topic is: <variable name="topic" /></output>
4
- <output>&#10;</output>
5
-
6
- <LLM output="response" maxTokens="50" noextra="true">
7
- Say hello
8
- </LLM>
9
-
10
- <output>Response: <variable name="response" /></output>
11
- <output>&#10;</output>
12
- </dirac>
@@ -1,132 +0,0 @@
1
- <dirac>
2
- <!-- UI Control Services -->
3
- <!-- These subroutines are exposed as natural language endpoints -->
4
-
5
- <subroutine name="background"
6
- description="Change the background color, do not generate other tags like <changeBackground /> use precise tag"
7
- param-color="string:required:Background color:red|blue|green|yellow|orange|purple|pink|white|black">
8
- <parameters select="@color"/>
9
-
10
- <eval>
11
- console.log('Changing background color to: ' + color);
12
- </eval>
13
- </subroutine>
14
-
15
- <subroutine name="set-text-size"
16
- description="Adjust the text size"
17
- param-size="string:required:Font size:12px|14px|16px|18px|20px|24px">
18
- <parameters select="@size" />
19
- <eval>
20
- console.log("change text size to "+size );
21
- document.body.style.fontSize = '${size}';
22
- </eval>
23
- </subroutine>
24
-
25
- <subroutine name="reset-styles"
26
- description="Reset all styles to default">
27
- <eval>
28
- console.log("reset all styles back");
29
- document.body.style.backgroundColor = 'white';
30
- document.body.style.fontSize = '16px';
31
- </eval>
32
- </subroutine>
33
-
34
- <subroutine name="text-color"
35
- description="Change the text color"
36
- param-color="string:required:Text color:black|white|red|blue|green">
37
- <parameters select="@color" />
38
- <eval>
39
- console.log("change color of text to "+color);
40
- document.body.style.color = '${color}';
41
- </eval>
42
- </subroutine>
43
-
44
- <!-- Event Generation Examples -->
45
-
46
- <subroutine name="click-button"
47
- description="Simulate clicking a button"
48
- param-selector="string:optional:CSS selector (default: #submit-button)">
49
- <eval>
50
- const selector = '${selector}' || '#submit-button';
51
- const element = document.querySelector(selector);
52
- if (element) {
53
- const clickEvent = new MouseEvent('click', {
54
- bubbles: true,
55
- cancelable: true,
56
- view: window
57
- });
58
- element.dispatchEvent(clickEvent);
59
- } else {
60
- throw new Error('Element not found: ' + selector);
61
- }
62
- </eval>
63
- </subroutine>
64
-
65
- <subroutine name="type-text"
66
- description="Type text into an input field"
67
- param-text="string:required:Text to type"
68
- param-field="string:optional:Which field:name|email">
69
- <parameters select="@text" />
70
- <parameters select="@field" />
71
- <eval>
72
- const _field = typeof field !== 'undefined' && field ? field : 'name';
73
- const selector = _field === 'email' ? '#email-input' : '#name-input';
74
- const input = document.querySelector(selector);
75
- if (input) {
76
- input.value = text;
77
- input.dispatchEvent(new Event('input', { bubbles: true }));
78
- input.dispatchEvent(new Event('change', { bubbles: true }));
79
- } else {
80
- throw new Error('Input not found: ' + selector);
81
- }
82
- </eval>
83
- </subroutine>
84
-
85
- <subroutine name="check-terms"
86
- description="Check or uncheck the terms checkbox"
87
- param-checked="string:optional:Check state:true|false">
88
- <eval>
89
- const shouldCheck = '${checked}' !== 'false';
90
- const checkbox = document.querySelector('#terms-checkbox');
91
- if (checkbox) {
92
- checkbox.checked = shouldCheck;
93
- checkbox.dispatchEvent(new Event('change', { bubbles: true }));
94
- } else {
95
- throw new Error('Checkbox not found');
96
- }
97
- </eval>
98
- </subroutine>
99
-
100
- <subroutine name="clear-input"
101
- description="Clear an input field"
102
- param-field="string:optional:Which field:name|email">
103
- <eval>
104
- const field = '${field}' || 'name';
105
- const selector = field === 'email' ? '#email-input' : '#name-input';
106
- const input = document.querySelector(selector);
107
- if (input) {
108
- input.value = '';
109
- input.dispatchEvent(new Event('input', { bubbles: true }));
110
- input.dispatchEvent(new Event('change', { bubbles: true }));
111
- } else {
112
- throw new Error('Input not found: ' + selector);
113
- }
114
- </eval>
115
- </subroutine>
116
-
117
- <!--
118
- <subroutine name="modify-file"
119
- description="modify a file based on pattern and replacement field "
120
- param-filename="string|required"
121
- param-pattern="string|required"
122
- param-replace="string|required"
123
- >
124
- <parameters select="@filename" />
125
- <parameters select="@pattern" />
126
- <parameters select="@replace" />
127
- <system>
128
- sed -e 's/${pattern}/${replace}/g' ${filename}
129
- </system>
130
- </subroutine>
131
- -->
132
- </dirac>
@@ -1,6 +0,0 @@
1
- <dirac>
2
- <import src="llm-subs.di" />
3
- <llm execute="true">set the background color to red</llm>
4
-
5
-
6
- </dirac>
@@ -1,18 +0,0 @@
1
- <dirac>
2
- <subroutine name="greet" description="Greet someone by name" param-name="string:required:The person's name">
3
- <output>Hello, <variable name="name" />!</output>
4
- </subroutine>
5
-
6
- <subroutine name="calculate" description="Calculate a simple math expression" param-expression="string:required:Math expression to calculate">
7
- <output>Result: <variable name="expression" /></output>
8
- </subroutine>
9
-
10
- <output>Testing LLM with tag validation...</output>
11
- <output>&#10;</output>
12
-
13
- <llm execute="true" validate="true" autocorrect="true" max-retries="2" maxTokens="200">
14
- Greet the user named Alice
15
- </llm>
16
-
17
- <output>&#10;</output>
18
- </dirac>
package/examples/loop.di DELETED
@@ -1,12 +0,0 @@
1
- <!-- Loop and conditional test -->
2
- <dirac>
3
- <defvar name="result" value="" />
4
-
5
- <loop count="5" var="i">
6
- <eval name="isEven" expr="i % 2 === 0" />
7
-
8
- <if test="${isEven} == true">
9
- <output>${i} is even&#10;</output>
10
- </if>
11
- </loop>
12
- </dirac>
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <dirac>
3
- <import src="./lib/math.di" />
4
-
5
- <output>Math Library Test&#10;&#10;</output>
6
-
7
- <defvar name="x" value="8" />
8
- <output>Square of ${x}: </output>
9
- <call name="SQUARE" />
10
- <output>&#10;</output>
11
-
12
- <defvar name="a" value="15" />
13
- <defvar name="b" value="25" />
14
- <output>${a} + ${b} = </output>
15
- <call name="ADD" />
16
- <output>&#10;</output>
17
-
18
- <defvar name="num" value="6" />
19
- <output>Factorial of ${num}: </output>
20
- <call name="FACTORIAL" />
21
- <output>&#10;</output>
22
- </dirac>
@@ -1,13 +0,0 @@
1
- <dirac>
2
- <output>Test</output>
3
- <defvar name="x" value="5"/>
4
- <if>
5
- <cond eval="eq">
6
- <arg><variable name="x"/></arg>
7
- <arg>5</arg>
8
- </cond>
9
- <then>
10
- <output>Match</output>
11
- </then>
12
- </if>
13
- </dirac>
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Simple llm context test -->
3
- <dirac>
4
-
5
-
6
- <!-- Import the MongoDB extension library -->
7
- <import src="./lib/mongodb.di" />
8
-
9
- <defvar name="myllmcontext" />
10
-
11
- <defvar name="mongo_output" >
12
- <MONGODB database="betting" collection="events" action="count" >{"type.name":"Pass" }</MONGODB>
13
- </defvar>
14
-
15
- <output>I have : <variable name="mongo_output" />: records</output>
16
-
17
- <llm execute="true" context="myllmcontext"> I have a mongodb, the database name is betting,\n and the collection name is events,
18
- in the collection there is a field called type.name, can you select the records with type.name as Pass, and limit result to 5. give me the command to retrieve them </llm>
19
-
20
- The context was used: <variable name="myllmcontext" />
21
-
22
- <eval name="contextString">
23
- return JSON.stringify(myllmcontext, null, 2);
24
- </eval>
25
- <output>${contextString}</output>
26
-
27
- </dirac>
@@ -1,8 +0,0 @@
1
-
2
-
3
- <dirc >
4
- <mongodb database="betting" collection="events" action="find">
5
- { }
6
- </mongodb>
7
-
8
- </dirac>
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Demo: Using MongoDB extension library -->
3
- <dirac>
4
-
5
-
6
- <subroutine name="MONGODB">
7
- <parameters select="@database" />
8
- <parameters select="@collection" />
9
- <defvar name="body"><parameters select="*"/></defvar>
10
- <!-- <defvar name="body">some body</defvar> -->
11
-
12
- <output>database is: <variable name="database" />&#10;</output>
13
- <output>collection is: <variable name="collection" />&#10;</output>
14
- <output>query is: <variable name="body" />&#10;</output>
15
- <output>from dirac&#10;</output>
16
-
17
-
18
- </subroutine>
19
-
20
-
21
- <MONGODB database="betting" collection="events" action="find">
22
- hi, this is a test
23
- </MONGODB>
24
-
25
- </dirac>
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Simple MongoDB extension test -->
3
- <dirac>
4
-
5
-
6
- <!-- Import the MongoDB extension library -->
7
- <import src="./lib/mongodb.di" />
8
-
9
- <!--
10
- <MONGODB database="betting" collection="events" action="find">{ "type.name": "Pass" }</MONGODB>
11
- -->
12
-
13
- <output>Testing MongoDB count:&#10;</output>
14
-
15
- <MONGODB database="betting" collection="events" action="count">{ "type.name": "Pass" }</MONGODB>
16
-
17
-
18
- </dirac>