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.
- package/dist/cli.js +13 -1
- package/lib/index.di +9 -0
- package/{examples/lib → lib}/math.di +3 -3
- package/package.json +13 -1
- package/.env.example +0 -8
- package/COMMUNITY.md +0 -465
- package/CONDITIONAL-TAGS.md +0 -172
- package/EXCEPTION-HANDLING.md +0 -156
- package/LIBRARIES.md +0 -172
- package/LLM-VALIDATION.md +0 -128
- package/NAMESPACES.md +0 -366
- package/PROMOTION.md +0 -257
- package/QUICKSTART-LIBRARY.md +0 -93
- package/TEST-COVERAGE.md +0 -113
- package/TESTING.md +0 -162
- package/config.test.yml +0 -5
- package/dirac-http/examples/demo.di +0 -9
- package/dirac-http/lib/index.di +0 -12
- package/examples/add-demo.di +0 -74
- package/examples/add.bk +0 -11
- package/examples/advanced-math-demo.di +0 -53
- package/examples/calculator.di +0 -32
- package/examples/compact-test.di +0 -6
- package/examples/comprehensive.bk +0 -29
- package/examples/defvar-variable-demo.di +0 -18
- package/examples/direct-call.di +0 -17
- package/examples/disk-analysis.di +0 -16
- package/examples/exception-demo.di +0 -82
- package/examples/executable-hello.di +0 -7
- package/examples/execute-demo.di +0 -38
- package/examples/file-manager.di +0 -77
- package/examples/file-stats.di +0 -18
- package/examples/hello.bk +0 -1
- package/examples/hello.di +0 -5
- package/examples/if-comparison.di +0 -91
- package/examples/if-cstyle-test.di +0 -149
- package/examples/if-vs-testif.di +0 -56
- package/examples/import-demo.di +0 -31
- package/examples/inline-test.bk +0 -7
- package/examples/llm-agent.di +0 -32
- package/examples/llm-basic.di +0 -12
- package/examples/llm-command-more.di +0 -6
- package/examples/llm-command-no-exec.di +0 -13
- package/examples/llm-command.di +0 -6
- package/examples/llm-complex.di +0 -141
- package/examples/llm-feedback-debug.di +0 -30
- package/examples/llm-feedback-demo.di +0 -19
- package/examples/llm-feedback-math.di +0 -22
- package/examples/llm-feedback-simple.di +0 -16
- package/examples/llm-feedback-sub.di +0 -22
- package/examples/llm-no-feedback.di +0 -10
- package/examples/llm-recursive.di +0 -31
- package/examples/llm-reflection-test.di +0 -19
- package/examples/llm-simple-test.di +0 -12
- package/examples/llm-subs.di +0 -132
- package/examples/llm-use-subs.di +0 -6
- package/examples/llm-validate-test.di +0 -18
- package/examples/loop.di +0 -12
- package/examples/math-test.di +0 -22
- package/examples/minimal-test.di +0 -13
- package/examples/mongodb-context-test.di +0 -27
- package/examples/mongodb-count-events.di +0 -8
- package/examples/mongodb-import-demo.di +0 -25
- package/examples/mongodb-simple-test.di +0 -18
- package/examples/nl-agent.di +0 -47
- package/examples/parameters-demo.di +0 -68
- package/examples/params-meta-test.di +0 -17
- package/examples/params-test.di +0 -10
- package/examples/recipe-chain.di +0 -38
- package/examples/recursive-llm.di +0 -44
- package/examples/sample-library/README.md +0 -152
- package/examples/sample-library/examples/demo.di +0 -34
- package/examples/sample-library/lib/index.di +0 -65
- package/examples/sample-library/package.json +0 -31
- package/examples/scope-test-nested.di +0 -60
- package/examples/scope-test.di +0 -55
- package/examples/seamless.di +0 -45
- package/examples/shell-test.bk +0 -10
- package/examples/simple-import.di +0 -13
- package/examples/simple-recursive.di +0 -26
- package/examples/story-builder.di +0 -45
- package/examples/subroutine.di +0 -23
- package/examples/system-llm.di +0 -21
- package/examples/system-simple.di +0 -3
- package/examples/system-test.di +0 -8
- package/examples/tag-check-test.di +0 -139
- package/examples/task-assistant.di +0 -27
- package/examples/test-if-demo.di +0 -110
- package/examples/test-parameters.di +0 -50
- package/examples/try-catch-test.di +0 -118
- package/examples/two-styles.di +0 -28
- package/examples/var-debug.di +0 -6
- package/examples/var-inline.di +0 -4
- package/examples/var-test2.di +0 -6
- package/examples/variable-replace.di +0 -25
- package/examples/variable-simple.di +0 -16
- package/examples/variable-test.di +0 -22
- package/examples/whitespace-test.di +0 -24
- package/filePath +0 -1
- package/greeting.txt +0 -1
- package/src/cli.ts +0 -140
- package/src/index.ts +0 -33
- package/src/llm/ollama.ts +0 -58
- package/src/runtime/braket-parser.ts +0 -234
- package/src/runtime/interpreter.ts +0 -203
- package/src/runtime/parser.ts +0 -155
- package/src/runtime/session.ts +0 -325
- package/src/tags/assign.ts +0 -37
- package/src/tags/attr.ts +0 -64
- package/src/tags/available-subroutines.ts +0 -70
- package/src/tags/call.ts +0 -259
- package/src/tags/catch.ts +0 -24
- package/src/tags/defvar.ts +0 -115
- package/src/tags/environment.ts +0 -21
- package/src/tags/eval.ts +0 -71
- package/src/tags/exception.ts +0 -20
- package/src/tags/execute.ts +0 -52
- package/src/tags/expr.ts +0 -128
- package/src/tags/foreach.ts +0 -170
- package/src/tags/if.ts +0 -191
- package/src/tags/import.ts +0 -135
- package/src/tags/index.ts +0 -41
- package/src/tags/input.ts +0 -182
- package/src/tags/llm.ts +0 -415
- package/src/tags/loop.ts +0 -43
- package/src/tags/mongodb.ts +0 -70
- package/src/tags/output.ts +0 -53
- package/src/tags/parameters.ts +0 -81
- package/src/tags/require_module.ts +0 -19
- package/src/tags/subroutine.ts +0 -75
- package/src/tags/system.ts +0 -93
- package/src/tags/tag-check.ts +0 -176
- package/src/tags/test-if.ts +0 -112
- package/src/tags/throw.ts +0 -26
- package/src/tags/try.ts +0 -19
- package/src/tags/variable.ts +0 -25
- package/src/test-runner.ts +0 -300
- package/src/types/index.ts +0 -128
- package/src/utils/llm-adapter.ts +0 -113
- package/src/utils/tag-validator.ts +0 -231
- package/test-available-extends.di +0 -28
- package/test-available-simple.di +0 -12
- package/test-available-subroutines.di +0 -16
- package/test-call.di +0 -9
- package/test-extend-basic.di +0 -17
- package/test-extend-chain.di +0 -26
- package/test-extend-debug.di +0 -17
- package/test-extend-debug2.di +0 -15
- package/test-extend-person.di +0 -17
- package/test-extend-simple.di +0 -11
- package/test-extend-zhi.di +0 -23
- package/test-extend.di +0 -19
- package/test-extend2.di +0 -26
- package/test-extend3-fixed.di +0 -23
- package/test-extend3-trouble.di +0 -23
- package/test-extend3.di +0 -21
- package/test-factorial.di +0 -19
- package/test-input-debug.di +0 -19
- package/test-nested-debug.di +0 -7
- package/test-nested-debug2.di +0 -8
- package/test-no-extend.di +0 -16
- package/test-simple-call.di +0 -7
- package/test-simple.di +0 -6
- package/tests/README.md +0 -69
- package/tests/assign-basic.test.di +0 -7
- package/tests/assign-from-eval.test.di +0 -7
- package/tests/available-subroutines-foreach.test.di +0 -32
- package/tests/basic-output.test.di +0 -5
- package/tests/call-basic.test.di +0 -11
- package/tests/call-with-output.test.di +0 -10
- package/tests/comments-before-content.test.di +0 -6
- package/tests/defvar-multiple.test.di +0 -8
- package/tests/environment-basic.test.di +0 -22
- package/tests/environment-nonexistent.test.di +0 -5
- package/tests/environment-with-defvar.test.di +0 -15
- package/tests/eval-basic.test.di +0 -6
- package/tests/eval-with-variables.test.di +0 -8
- package/tests/exception-basic.test.di +0 -10
- package/tests/expr-basic.test.di +0 -11
- package/tests/extend-basic.test.di +0 -19
- package/tests/extend-inheritance-chain.test.di +0 -26
- package/tests/extend-multiple-nested.test.di +0 -24
- package/tests/extend-self.test.di +0 -19
- package/tests/extend-with-parameters.test.di +0 -14
- package/tests/generate-dirac.test.di +0 -22
- package/tests/if-conditional.test.di +0 -17
- package/tests/if-else.test.di +0 -11
- package/tests/if-with-variables.test.di +0 -8
- package/tests/import-basic.test.di +0 -6
- package/tests/input-file-all.test.di +0 -5
- package/tests/input-file-line.test.di +0 -15
- package/tests/input-file-loop.test.di +0 -12
- package/tests/input-stdin-all.test.di +0 -8
- package/tests/input-stdin-all.txt +0 -1
- package/tests/llm-validate.test.di +0 -17
- package/tests/loop-basic.test.di +0 -9
- package/tests/loop-nested.test.di +0 -10
- package/tests/loop-with-eval.test.di +0 -8
- package/tests/no-root-element.test.di +0 -6
- package/tests/output-file.test.di +0 -19
- package/tests/output-multiple.test.di +0 -9
- package/tests/parameters-basic.test.di +0 -6
- package/tests/require-module-basic.test.di +0 -7
- package/tests/subroutine-basic.test.di +0 -9
- package/tests/subroutine-multiple-params.test.di +0 -10
- package/tests/subroutine-nested-calls.test.di +0 -32
- package/tests/subroutine-sequential-calls.test.di +0 -36
- package/tests/system-background.test.di +0 -39
- package/tests/system-basic.test.di +0 -5
- package/tests/tag-check.test.di +0 -27
- package/tests/test-if-basic.test.di +0 -8
- package/tests/test-input.txt +0 -3
- package/tests/try-catch-basic.test.di +0 -10
- package/tests/try-catch-eval-error.test.di +0 -10
- package/tests/variable-basic.test.di +0 -6
- package/tests/variable-interpolation.test.di +0 -7
- package/tools/create-library.sh +0 -175
- package/tsconfig.json +0 -19
- /package/{examples/lib → lib}/advanced-math.di +0 -0
- /package/{examples/lib → lib}/fileops.di +0 -0
- /package/{examples/lib → lib}/mongodb.di +0 -0
package/examples/shell-test.bk
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Simple import test -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<import src="./lib/math.di" />
|
|
5
|
-
|
|
6
|
-
<defvar name="x" value="7" />
|
|
7
|
-
<output>Testing SQUARE with x=${x} </output>
|
|
8
|
-
|
|
9
|
-
<eval name="result">return 7 * 7;</eval>
|
|
10
|
-
<output>Direct calc: ${result} </output>
|
|
11
|
-
|
|
12
|
-
<call name="SQUARE" />
|
|
13
|
-
</dirac>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!-- Simple Recursive Demo - LISP Style -->
|
|
2
|
-
<dirac>
|
|
3
|
-
<output>Simple Recursion Demo </output>
|
|
4
|
-
|
|
5
|
-
<!-- Subroutine that calculates something -->
|
|
6
|
-
<subroutine name="CALC">
|
|
7
|
-
<eval name="result">return 5 * 5;</eval>
|
|
8
|
-
<output>Calculated: ${result} </output>
|
|
9
|
-
</subroutine>
|
|
10
|
-
|
|
11
|
-
<!-- Subroutine with nested LLM call -->
|
|
12
|
-
<subroutine name="NESTED">
|
|
13
|
-
<output>Entering nested call... </output>
|
|
14
|
-
<LLM execute="true" maxTokens="50">
|
|
15
|
-
<dirac><output>From nested LLM! </output></dirac>
|
|
16
|
-
</LLM>
|
|
17
|
-
</subroutine>
|
|
18
|
-
|
|
19
|
-
<!-- Start with direct LLM execution -->
|
|
20
|
-
<output>Starting... </output>
|
|
21
|
-
<LLM execute="true" maxTokens="50">
|
|
22
|
-
Copy this EXACTLY: <dirac><CALC /><NESTED /></dirac>
|
|
23
|
-
</LLM>
|
|
24
|
-
|
|
25
|
-
<output>Done! </output>
|
|
26
|
-
</dirac>
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<!-- Story Builder - Loop with LLM -->
|
|
2
|
-
<dirac>
|
|
3
|
-
<defvar name="character" value="a curious robot" />
|
|
4
|
-
<defvar name="setting" value="abandoned space station" />
|
|
5
|
-
|
|
6
|
-
<output>Creating a story about ${character} in ${setting}... </output>
|
|
7
|
-
|
|
8
|
-
<!-- Generate the opening -->
|
|
9
|
-
<LLM output="opening" maxTokens="150">
|
|
10
|
-
Write the opening paragraph of a story about ${character} in ${setting}.
|
|
11
|
-
End with a cliffhanger.
|
|
12
|
-
</LLM>
|
|
13
|
-
<output>${opening} </output>
|
|
14
|
-
|
|
15
|
-
<!-- Generate 3 story beats -->
|
|
16
|
-
<defvar name="context" value="${opening}" />
|
|
17
|
-
|
|
18
|
-
<loop var="i" from="1" to="3">
|
|
19
|
-
<output>--- Part ${i} --- </output>
|
|
20
|
-
|
|
21
|
-
<LLM output="nextPart" maxTokens="150">
|
|
22
|
-
Continue this story with the next paragraph:
|
|
23
|
-
|
|
24
|
-
${context}
|
|
25
|
-
|
|
26
|
-
Make it exciting and end with a cliffhanger.
|
|
27
|
-
</LLM>
|
|
28
|
-
|
|
29
|
-
<output>${nextPart} </output>
|
|
30
|
-
|
|
31
|
-
<!-- Update context for next iteration -->
|
|
32
|
-
<assign name="context" value="${context} ${nextPart}" />
|
|
33
|
-
</loop>
|
|
34
|
-
|
|
35
|
-
<!-- Generate conclusion -->
|
|
36
|
-
<output>--- Conclusion --- </output>
|
|
37
|
-
<LLM output="ending" maxTokens="150">
|
|
38
|
-
Write a satisfying conclusion to this story:
|
|
39
|
-
|
|
40
|
-
${context}
|
|
41
|
-
|
|
42
|
-
Wrap up the plot in 2-3 sentences.
|
|
43
|
-
</LLM>
|
|
44
|
-
<output>${ending} </output>
|
|
45
|
-
</dirac>
|
package/examples/subroutine.di
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<!-- Subroutine and parameters test -->
|
|
2
|
-
<dirac>
|
|
3
|
-
<subroutine name="greet">
|
|
4
|
-
<parameters>
|
|
5
|
-
<variable name="name" passby="value" />
|
|
6
|
-
</parameters>
|
|
7
|
-
<output>Hello, ${name}!</output>
|
|
8
|
-
</subroutine>
|
|
9
|
-
|
|
10
|
-
<call name="greet">
|
|
11
|
-
<parameters>
|
|
12
|
-
<variable value="Alice" />
|
|
13
|
-
</parameters>
|
|
14
|
-
</call>
|
|
15
|
-
|
|
16
|
-
<output> </output>
|
|
17
|
-
|
|
18
|
-
<call name="greet">
|
|
19
|
-
<parameters>
|
|
20
|
-
<variable value="Bob" />
|
|
21
|
-
</parameters>
|
|
22
|
-
</call>
|
|
23
|
-
</dirac>
|
package/examples/system-llm.di
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<!-- Get file listing -->
|
|
3
|
-
<defvar name="dir">examples</defvar>
|
|
4
|
-
<output>Getting file listing from ${dir}...</output>
|
|
5
|
-
<output> </output>
|
|
6
|
-
|
|
7
|
-
<llm noextra="true" output="fileList">
|
|
8
|
-
<system>ls -lh ${dir} | head -10</system>
|
|
9
|
-
|
|
10
|
-
Above is a directory listing. Please analyze it and tell me:
|
|
11
|
-
1. How many files are shown?
|
|
12
|
-
2. What is the total size of the largest file?
|
|
13
|
-
3. What file types do you see (by extension)?
|
|
14
|
-
|
|
15
|
-
Please be concise.
|
|
16
|
-
</llm>
|
|
17
|
-
|
|
18
|
-
<output> LLM Analysis:</output>
|
|
19
|
-
<output> </output>
|
|
20
|
-
<output><variable name="fileList"/></output>
|
|
21
|
-
</dirac>
|
package/examples/system-test.di
DELETED
|
@@ -1,139 +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
|
-
<output>Start checking tag for a wrong tag:</output>
|
|
134
|
-
<tag-check execute="true" autocorrect="true" >
|
|
135
|
-
<background-set color="red" />
|
|
136
|
-
</tag-check>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
</dirac>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!-- Task Assistant - LLM breaks down and executes tasks -->
|
|
2
|
-
<dirac>
|
|
3
|
-
<defvar name="task" value="organize a birthday party" />
|
|
4
|
-
|
|
5
|
-
<output>Task: ${task} </output>
|
|
6
|
-
|
|
7
|
-
<!-- Ask LLM to break down the task -->
|
|
8
|
-
<output>Breaking down the task... </output>
|
|
9
|
-
<LLM output="steps" maxTokens="300">
|
|
10
|
-
Break down "${task}" into 3-5 concrete action steps.
|
|
11
|
-
Return ONLY a numbered list, one step per line.
|
|
12
|
-
Keep each step brief and actionable.
|
|
13
|
-
</LLM>
|
|
14
|
-
|
|
15
|
-
<output> Steps to complete: ${steps} </output>
|
|
16
|
-
|
|
17
|
-
<!-- Now get LLM to provide tips for the first step -->
|
|
18
|
-
<output>Getting tips for step 1... </output>
|
|
19
|
-
<LLM output="tips" maxTokens="200">
|
|
20
|
-
For the first step in this list:
|
|
21
|
-
${steps}
|
|
22
|
-
|
|
23
|
-
Provide 2-3 quick practical tips. Be concise.
|
|
24
|
-
</LLM>
|
|
25
|
-
|
|
26
|
-
<output> Tips: ${tips} </output>
|
|
27
|
-
</dirac>
|
package/examples/test-if-demo.di
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<output>===== Attribute-based TEST-IF Tests =====</output>
|
|
3
|
-
<output>
|
|
4
|
-
</output>
|
|
5
|
-
|
|
6
|
-
<!-- Test 1: Simple true condition -->
|
|
7
|
-
<output>Test 1: Simple true test</output>
|
|
8
|
-
<defvar name="x" value="5"/>
|
|
9
|
-
|
|
10
|
-
<test-if test="x">
|
|
11
|
-
<output>x is truthy (correct!)</output>
|
|
12
|
-
</test-if>
|
|
13
|
-
<output>
|
|
14
|
-
</output>
|
|
15
|
-
|
|
16
|
-
<!-- Test 2: Equality check -->
|
|
17
|
-
<output>Test 2: Equality test</output>
|
|
18
|
-
<defvar name="status" value="active"/>
|
|
19
|
-
|
|
20
|
-
<test-if test="$status" eq="active">
|
|
21
|
-
<output>Status is active (correct!)</output>
|
|
22
|
-
</test-if>
|
|
23
|
-
<output>
|
|
24
|
-
</output>
|
|
25
|
-
|
|
26
|
-
<!-- Test 3: Not equal -->
|
|
27
|
-
<output>Test 3: Not equal test</output>
|
|
28
|
-
<defvar name="count" value="10"/>
|
|
29
|
-
|
|
30
|
-
<test-if test="$count" ne="0">
|
|
31
|
-
<output>Count is not zero (correct!)</output>
|
|
32
|
-
</test-if>
|
|
33
|
-
<output>
|
|
34
|
-
</output>
|
|
35
|
-
|
|
36
|
-
<!-- Test 4: Greater than -->
|
|
37
|
-
<output>Test 4: Greater than test</output>
|
|
38
|
-
<defvar name="age" value="25"/>
|
|
39
|
-
|
|
40
|
-
<test-if test="$age" gt="18">
|
|
41
|
-
<output>Age is greater than 18 (correct!)</output>
|
|
42
|
-
</test-if>
|
|
43
|
-
<output>
|
|
44
|
-
</output>
|
|
45
|
-
|
|
46
|
-
<!-- Test 5: Less than -->
|
|
47
|
-
<output>Test 5: Less than test</output>
|
|
48
|
-
<defvar name="temp" value="15"/>
|
|
49
|
-
|
|
50
|
-
<test-if test="$temp" lt="20">
|
|
51
|
-
<output>Temperature is less than 20 (correct!)</output>
|
|
52
|
-
</test-if>
|
|
53
|
-
<output>
|
|
54
|
-
</output>
|
|
55
|
-
|
|
56
|
-
<!-- Test 6: Greater than or equal -->
|
|
57
|
-
<output>Test 6: Greater than or equal test</output>
|
|
58
|
-
<defvar name="score" value="100"/>
|
|
59
|
-
|
|
60
|
-
<test-if test="$score" ge="100">
|
|
61
|
-
<output>Score is 100 or higher (correct!)</output>
|
|
62
|
-
</test-if>
|
|
63
|
-
<output>
|
|
64
|
-
</output>
|
|
65
|
-
|
|
66
|
-
<!-- Test 7: Less than or equal -->
|
|
67
|
-
<output>Test 7: Less than or equal test</output>
|
|
68
|
-
<defvar name="price" value="50"/>
|
|
69
|
-
|
|
70
|
-
<test-if test="$price" le="50">
|
|
71
|
-
<output>Price is 50 or less (correct!)</output>
|
|
72
|
-
</test-if>
|
|
73
|
-
<output>
|
|
74
|
-
</output>
|
|
75
|
-
|
|
76
|
-
<!-- Test 8: False condition (should not output) -->
|
|
77
|
-
<output>Test 8: False condition</output>
|
|
78
|
-
<defvar name="flag" value="false"/>
|
|
79
|
-
|
|
80
|
-
<test-if test="$flag" eq="true">
|
|
81
|
-
<output>This should NOT appear</output>
|
|
82
|
-
</test-if>
|
|
83
|
-
<output>Test completed (no output expected above)</output>
|
|
84
|
-
<output>
|
|
85
|
-
</output>
|
|
86
|
-
|
|
87
|
-
<!-- Test 9: Variable existence check -->
|
|
88
|
-
<output>Test 9: Variable exists</output>
|
|
89
|
-
<defvar name="name" value="Alice"/>
|
|
90
|
-
|
|
91
|
-
<test-if test="$name">
|
|
92
|
-
<output>Name variable exists: <variable name="name"/></output>
|
|
93
|
-
</test-if>
|
|
94
|
-
<output>
|
|
95
|
-
</output>
|
|
96
|
-
|
|
97
|
-
<!-- Test 10: Complex nested content -->
|
|
98
|
-
<output>Test 10: Nested content in test-if</output>
|
|
99
|
-
<defvar name="user_type" value="admin"/>
|
|
100
|
-
|
|
101
|
-
<test-if test="$user_type" eq="admin">
|
|
102
|
-
<output>Access granted for admin</output>
|
|
103
|
-
<defvar name="permissions" value="full"/>
|
|
104
|
-
<output>Permissions set to: <variable name="permissions"/></output>
|
|
105
|
-
</test-if>
|
|
106
|
-
<output>
|
|
107
|
-
</output>
|
|
108
|
-
|
|
109
|
-
<output>===== All TEST-IF tests complete =====</output>
|
|
110
|
-
</dirac>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<dirac>
|
|
3
|
-
<!-- Test 1: parameters select="*" - access child elements -->
|
|
4
|
-
<subroutine name="GREET">
|
|
5
|
-
<output>Hello, </output>
|
|
6
|
-
<parameters select="*"/>
|
|
7
|
-
<output>!</output>
|
|
8
|
-
</subroutine>
|
|
9
|
-
|
|
10
|
-
<output>Test 1 - Child elements:</output>
|
|
11
|
-
<GREET>
|
|
12
|
-
<output>Alice</output>
|
|
13
|
-
</GREET>
|
|
14
|
-
<output> </output>
|
|
15
|
-
|
|
16
|
-
<!-- Test 2: parameters select="@attr" - access specific attribute -->
|
|
17
|
-
<subroutine name="SQUARE">
|
|
18
|
-
<output>x=</output>
|
|
19
|
-
<parameters select="@x"/>
|
|
20
|
-
<output> squared = ?</output>
|
|
21
|
-
</subroutine>
|
|
22
|
-
|
|
23
|
-
<output>Test 2 - Attribute access: </output>
|
|
24
|
-
<SQUARE x="5"/>
|
|
25
|
-
<output> </output>
|
|
26
|
-
|
|
27
|
-
<!-- Test 3: parameters select="@*" - access all attributes -->
|
|
28
|
-
<subroutine name="SHOW_ATTRS">
|
|
29
|
-
<output>Attributes: </output>
|
|
30
|
-
<parameters select="@*"/>
|
|
31
|
-
<output> </output>
|
|
32
|
-
</subroutine>
|
|
33
|
-
|
|
34
|
-
<output>Test 3 - All attributes:</output>
|
|
35
|
-
<SHOW_ATTRS name="test" value="123" color="red"/>
|
|
36
|
-
|
|
37
|
-
<!-- Test 4: Multiple child elements -->
|
|
38
|
-
<subroutine name="LIST">
|
|
39
|
-
<output>Items: </output>
|
|
40
|
-
<parameters select="*"/>
|
|
41
|
-
<output> </output>
|
|
42
|
-
</subroutine>
|
|
43
|
-
|
|
44
|
-
<output>Test 4 - Multiple children: </output>
|
|
45
|
-
<LIST>
|
|
46
|
-
<output>Apple, </output>
|
|
47
|
-
<output>Banana, </output>
|
|
48
|
-
<output>Orange</output>
|
|
49
|
-
</LIST>
|
|
50
|
-
</dirac>
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<!-- Test 1: Basic throw and catch -->
|
|
3
|
-
<output>Test 1: Basic throw and catch</output>
|
|
4
|
-
<output>
|
|
5
|
-
</output>
|
|
6
|
-
|
|
7
|
-
<try>
|
|
8
|
-
<output>Inside try block</output>
|
|
9
|
-
<throw name="myerror">
|
|
10
|
-
<output>Error occurred: Something went wrong!</output>
|
|
11
|
-
</throw>
|
|
12
|
-
<output>This should not appear</output>
|
|
13
|
-
</try>
|
|
14
|
-
|
|
15
|
-
<catch name="myerror">
|
|
16
|
-
<output>Caught exception: </output>
|
|
17
|
-
<exception/>
|
|
18
|
-
</catch>
|
|
19
|
-
|
|
20
|
-
<output>
|
|
21
|
-
</output>
|
|
22
|
-
<output>---</output>
|
|
23
|
-
<output>
|
|
24
|
-
</output>
|
|
25
|
-
|
|
26
|
-
<!-- Test 2: No matching catch -->
|
|
27
|
-
<output>Test 2: Throw without matching catch</output>
|
|
28
|
-
<output>
|
|
29
|
-
</output>
|
|
30
|
-
|
|
31
|
-
<try>
|
|
32
|
-
<output>Throwing specific error</output>
|
|
33
|
-
<throw name="specificerror">
|
|
34
|
-
<output>Specific error message</output>
|
|
35
|
-
</throw>
|
|
36
|
-
</try>
|
|
37
|
-
|
|
38
|
-
<catch name="differenterror">
|
|
39
|
-
<output>This should not appear</output>
|
|
40
|
-
</catch>
|
|
41
|
-
|
|
42
|
-
<output>
|
|
43
|
-
</output>
|
|
44
|
-
<output>---</output>
|
|
45
|
-
<output>
|
|
46
|
-
</output>
|
|
47
|
-
|
|
48
|
-
<!-- Test 3: Multiple exceptions -->
|
|
49
|
-
<output>Test 3: Multiple exceptions</output>
|
|
50
|
-
<output>
|
|
51
|
-
</output>
|
|
52
|
-
|
|
53
|
-
<try>
|
|
54
|
-
<throw name="error1">
|
|
55
|
-
<output>First error</output>
|
|
56
|
-
</throw>
|
|
57
|
-
<throw name="error2">
|
|
58
|
-
<output>Second error</output>
|
|
59
|
-
</throw>
|
|
60
|
-
<throw name="error1">
|
|
61
|
-
<output>Third error (error1 again)</output>
|
|
62
|
-
</throw>
|
|
63
|
-
</try>
|
|
64
|
-
|
|
65
|
-
<catch name="error1">
|
|
66
|
-
<output>Caught error1 exceptions: </output>
|
|
67
|
-
<exception/>
|
|
68
|
-
</catch>
|
|
69
|
-
|
|
70
|
-
<output>
|
|
71
|
-
</output>
|
|
72
|
-
<output>---</output>
|
|
73
|
-
<output>
|
|
74
|
-
</output>
|
|
75
|
-
|
|
76
|
-
<!-- Test 4: Nested try/catch -->
|
|
77
|
-
<output>Test 4: Nested try/catch blocks</output>
|
|
78
|
-
<output>
|
|
79
|
-
</output>
|
|
80
|
-
|
|
81
|
-
<try>
|
|
82
|
-
<output>Outer try</output>
|
|
83
|
-
<try>
|
|
84
|
-
<output>Inner try</output>
|
|
85
|
-
<throw name="innerexception">
|
|
86
|
-
<output>Inner exception message</output>
|
|
87
|
-
</throw>
|
|
88
|
-
</try>
|
|
89
|
-
<catch name="innerexception">
|
|
90
|
-
<output>Caught in inner catch: </output>
|
|
91
|
-
<exception/>
|
|
92
|
-
</catch>
|
|
93
|
-
<output>After inner catch</output>
|
|
94
|
-
</try>
|
|
95
|
-
|
|
96
|
-
<output>
|
|
97
|
-
</output>
|
|
98
|
-
<output>---</output>
|
|
99
|
-
<output>
|
|
100
|
-
</output>
|
|
101
|
-
|
|
102
|
-
<!-- Test 5: Default exception name -->
|
|
103
|
-
<output>Test 5: Default exception name</output>
|
|
104
|
-
<output>
|
|
105
|
-
</output>
|
|
106
|
-
|
|
107
|
-
<try>
|
|
108
|
-
<throw>
|
|
109
|
-
<output>Default exception (no name attribute)</output>
|
|
110
|
-
</throw>
|
|
111
|
-
</try>
|
|
112
|
-
|
|
113
|
-
<catch>
|
|
114
|
-
<output>Caught default exception: </output>
|
|
115
|
-
<exception/>
|
|
116
|
-
</catch>
|
|
117
|
-
|
|
118
|
-
</dirac>
|
package/examples/two-styles.di
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<!-- Comparing Two Styles of LLM-Code Execution -->
|
|
2
|
-
<dirac>
|
|
3
|
-
<output>=== Style Comparison Demo === </output>
|
|
4
|
-
|
|
5
|
-
<!-- STYLE 1: EXPLICIT (Clear, Debuggable) -->
|
|
6
|
-
<output>--- Explicit Style (Clarity) --- </output>
|
|
7
|
-
<LLM output="generatedCode" maxTokens="100">
|
|
8
|
-
Return ONLY this XML, nothing else:
|
|
9
|
-
<dirac><eval name="result">return 10 + 20;</eval><output>Sum: ${result}</output></dirac>
|
|
10
|
-
</LLM>
|
|
11
|
-
|
|
12
|
-
<output>Generated code: ${generatedCode} </output>
|
|
13
|
-
<output>Executing... </output>
|
|
14
|
-
<execute source="generatedCode" />
|
|
15
|
-
<output> </output>
|
|
16
|
-
|
|
17
|
-
<!-- STYLE 2: LISP (Seamless, Direct) -->
|
|
18
|
-
<output>--- LISP Style (Seamless) --- </output>
|
|
19
|
-
<LLM execute="true" maxTokens="100">
|
|
20
|
-
Return ONLY this XML, nothing else:
|
|
21
|
-
<dirac><eval name="result">return 30 + 40;</eval><output>Sum: ${result}</output></dirac>
|
|
22
|
-
</LLM>
|
|
23
|
-
<output> </output>
|
|
24
|
-
|
|
25
|
-
<output>--- When to Use Each --- </output>
|
|
26
|
-
<output>Explicit: Debugging, inspection, conditional execution </output>
|
|
27
|
-
<output>LISP: Real-time interaction, streaming, recursive calls </output>
|
|
28
|
-
</dirac>
|
package/examples/var-debug.di
DELETED
package/examples/var-inline.di
DELETED