@rcrsr/rill 0.6.0 → 0.6.1

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/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # @rcrsr/rill
2
+
3
+ Embeddable runtime for the [rill](https://github.com/rcrsr/rill) workflow language. Zero dependencies. Browser and Node.js compatible.
4
+
5
+ > **Experimental.** Breaking changes will occur until v1.0.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @rcrsr/rill
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { parse, execute, createRuntimeContext } from '@rcrsr/rill';
17
+
18
+ const script = `
19
+ prompt("Analyze this code for issues")
20
+ -> .contains("ERROR") ? error($) ! "Analysis complete"
21
+ `;
22
+
23
+ const ctx = createRuntimeContext({
24
+ functions: {
25
+ prompt: {
26
+ params: [{ name: 'message', type: 'string' }],
27
+ fn: async (args) => await callYourLLM(args[0]),
28
+ },
29
+ },
30
+ });
31
+
32
+ const result = await execute(parse(script), ctx);
33
+ console.log(result.value);
34
+ ```
35
+
36
+ ## API
37
+
38
+ ### Core Pipeline
39
+
40
+ ```
41
+ Source Text → parse() → AST → execute() → Result
42
+ ```
43
+
44
+ | Export | Purpose |
45
+ |--------|---------|
46
+ | `parse(source)` | Parse rill source into an AST |
47
+ | `execute(ast, ctx)` | Execute an AST with a runtime context |
48
+ | `createRuntimeContext(opts)` | Create a configured runtime context |
49
+ | `callable(fn, isProperty?)` | Wrap a function as a rill-callable value |
50
+ | `prefixFunctions(prefix, fns)` | Namespace host functions (e.g., `app::`) |
51
+
52
+ ### Runtime Options
53
+
54
+ ```typescript
55
+ const ctx = createRuntimeContext({
56
+ // Host functions available to scripts
57
+ functions: {
58
+ prompt: {
59
+ params: [{ name: 'text', type: 'string' }],
60
+ fn: async (args, ctx, location) => { /* ... */ },
61
+ },
62
+ },
63
+
64
+ // Variables injected into script scope
65
+ variables: {
66
+ config: { greeting: 'hello' },
67
+ },
68
+
69
+ // Callbacks
70
+ callbacks: {
71
+ onLog: (value) => console.log(value),
72
+ },
73
+
74
+ // Observability hooks
75
+ observability: {
76
+ onStepStart: (e) => { /* ... */ },
77
+ onStepEnd: (e) => { /* ... */ },
78
+ },
79
+
80
+ // Execution limits
81
+ timeout: 30000,
82
+ signal: abortController.signal,
83
+ });
84
+ ```
85
+
86
+ ### Stepper API
87
+
88
+ Step through execution one statement at a time:
89
+
90
+ ```typescript
91
+ import { parse, createRuntimeContext, createStepper } from '@rcrsr/rill';
92
+
93
+ const stepper = createStepper(parse(script), createRuntimeContext());
94
+
95
+ let step;
96
+ while (!(step = await stepper.next()).done) {
97
+ console.log(step.value);
98
+ }
99
+ ```
100
+
101
+ ### Additional Exports
102
+
103
+ | Export | Purpose |
104
+ |--------|---------|
105
+ | `parseWithRecovery(source)` | Parse with error recovery (for editors) |
106
+ | `tokenize(source)` | Tokenize source into a token stream |
107
+ | `TOKEN_HIGHLIGHT_MAP` | Syntax highlighting category map |
108
+ | `getLanguageReference()` | LLM-optimized language reference text |
109
+ | `getDocumentationCoverage()` | Coverage stats for doc examples |
110
+ | `getFunctions()` | List of built-in function metadata |
111
+ | `VERSION` / `VERSION_INFO` | Runtime version string and metadata |
112
+
113
+ ### Error Handling
114
+
115
+ ```typescript
116
+ import { parse, execute, createRuntimeContext, AbortError } from '@rcrsr/rill';
117
+
118
+ try {
119
+ const result = await execute(parse(script), ctx);
120
+ } catch (err) {
121
+ if (err instanceof AbortError) {
122
+ // Execution was cancelled via signal
123
+ }
124
+ // Runtime errors include source location and error code
125
+ }
126
+ ```
127
+
128
+ ### Type Guards
129
+
130
+ | Export | Purpose |
131
+ |--------|---------|
132
+ | `isDict(value)` | Check if value is a rill dict |
133
+ | `isTuple(value)` | Check if value is a rill tuple |
134
+ | `isCallable(value)` | Check if value is any callable |
135
+ | `isScriptCallable(value)` | Check if value is a script-defined closure |
136
+ | `isApplicationCallable(value)` | Check if value is a host-provided callable |
137
+
138
+ ## Documentation
139
+
140
+ | Document | Description |
141
+ |----------|-------------|
142
+ | [Host Integration](https://github.com/rcrsr/rill/blob/main/docs/integration-host.md) | Embedding guide |
143
+ | [Host API Reference](https://github.com/rcrsr/rill/blob/main/docs/ref-host-api.md) | Complete TypeScript API |
144
+ | [Language Reference](https://github.com/rcrsr/rill/blob/main/docs/ref-language.md) | Language specification |
145
+ | [Extensions](https://github.com/rcrsr/rill/blob/main/docs/integration-extensions.md) | Reusable host function packages |
146
+
147
+ ## License
148
+
149
+ MIT
@@ -10,7 +10,7 @@ export interface VersionInfo {
10
10
  /**
11
11
  * Version string from package.json
12
12
  */
13
- export declare const VERSION = "0.6.0";
13
+ export declare const VERSION = "0.6.1";
14
14
  /**
15
15
  * Parsed version components
16
16
  */
@@ -3,14 +3,14 @@
3
3
  /**
4
4
  * Version string from package.json
5
5
  */
6
- export const VERSION = '0.6.0';
6
+ export const VERSION = '0.6.1';
7
7
  /**
8
8
  * Parsed version components
9
9
  */
10
10
  export const VERSION_INFO = {
11
11
  major: 0,
12
12
  minor: 6,
13
- patch: 0,
13
+ patch: 1,
14
14
  prerelease: undefined,
15
15
  };
16
16
  //# sourceMappingURL=version-data.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcrsr/rill",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "access": "public"
13
13
  },
14
14
  "scripts": {
15
- "build": "tsc --build",
15
+ "build": "tsx scripts/generate-version.ts && tsc --build",
16
16
  "test": "vitest run",
17
17
  "test:examples": "tsx ../../scripts/test-examples.ts ../../docs/",
18
18
  "typecheck": "tsc --noEmit",