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
@@ -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>