@rcrsr/rill 0.5.0 → 0.6.0

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 (240) hide show
  1. package/dist/generated/introspection-data.d.ts +1 -1
  2. package/dist/generated/introspection-data.d.ts.map +1 -1
  3. package/dist/generated/introspection-data.js +107 -186
  4. package/dist/generated/introspection-data.js.map +1 -1
  5. package/dist/generated/version-data.d.ts +1 -1
  6. package/dist/generated/version-data.js +3 -3
  7. package/dist/generated/version-data.js.map +1 -1
  8. package/dist/highlight-map.d.ts +4 -0
  9. package/dist/highlight-map.d.ts.map +1 -0
  10. package/dist/highlight-map.js +71 -0
  11. package/dist/highlight-map.js.map +1 -0
  12. package/dist/index.d.ts +2 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +5 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/lexer/errors.d.ts.map +1 -1
  17. package/dist/lexer/errors.js +9 -3
  18. package/dist/lexer/errors.js.map +1 -1
  19. package/dist/lexer/operators.js +1 -1
  20. package/dist/lexer/tokenizer.d.ts.map +1 -1
  21. package/dist/lexer/tokenizer.js +0 -14
  22. package/dist/lexer/tokenizer.js.map +1 -1
  23. package/dist/parser/helpers.d.ts +8 -0
  24. package/dist/parser/helpers.d.ts.map +1 -1
  25. package/dist/parser/helpers.js +4 -4
  26. package/dist/parser/helpers.js.map +1 -1
  27. package/dist/parser/index.d.ts.map +1 -1
  28. package/dist/parser/index.js +1 -1
  29. package/dist/parser/index.js.map +1 -1
  30. package/dist/parser/parser-collect.js +1 -1
  31. package/dist/parser/parser-collect.js.map +1 -1
  32. package/dist/parser/parser-control.js +4 -4
  33. package/dist/parser/parser-control.js.map +1 -1
  34. package/dist/parser/parser-expr.js +32 -10
  35. package/dist/parser/parser-expr.js.map +1 -1
  36. package/dist/parser/parser-extract.js +7 -3
  37. package/dist/parser/parser-extract.js.map +1 -1
  38. package/dist/parser/parser-functions.d.ts.map +1 -1
  39. package/dist/parser/parser-functions.js +7 -18
  40. package/dist/parser/parser-functions.js.map +1 -1
  41. package/dist/parser/parser-literals.js +15 -15
  42. package/dist/parser/parser-literals.js.map +1 -1
  43. package/dist/parser/parser-script.js +3 -3
  44. package/dist/parser/parser-script.js.map +1 -1
  45. package/dist/parser/parser-variables.js +4 -4
  46. package/dist/parser/parser-variables.js.map +1 -1
  47. package/dist/parser/state.d.ts +1 -1
  48. package/dist/parser/state.d.ts.map +1 -1
  49. package/dist/parser/state.js +2 -2
  50. package/dist/parser/state.js.map +1 -1
  51. package/dist/runtime/core/callable.d.ts +20 -0
  52. package/dist/runtime/core/callable.d.ts.map +1 -1
  53. package/dist/runtime/core/callable.js +30 -7
  54. package/dist/runtime/core/callable.js.map +1 -1
  55. package/dist/runtime/core/context.d.ts +21 -0
  56. package/dist/runtime/core/context.d.ts.map +1 -1
  57. package/dist/runtime/core/context.js +75 -4
  58. package/dist/runtime/core/context.js.map +1 -1
  59. package/dist/runtime/core/eval/base.d.ts.map +1 -1
  60. package/dist/runtime/core/eval/base.js +3 -3
  61. package/dist/runtime/core/eval/base.js.map +1 -1
  62. package/dist/runtime/core/eval/index.d.ts.map +1 -1
  63. package/dist/runtime/core/eval/index.js +2 -0
  64. package/dist/runtime/core/eval/index.js.map +1 -1
  65. package/dist/runtime/core/eval/mixins/annotations.js +3 -3
  66. package/dist/runtime/core/eval/mixins/annotations.js.map +1 -1
  67. package/dist/runtime/core/eval/mixins/closures.d.ts.map +1 -1
  68. package/dist/runtime/core/eval/mixins/closures.js +69 -40
  69. package/dist/runtime/core/eval/mixins/closures.js.map +1 -1
  70. package/dist/runtime/core/eval/mixins/collections.js +15 -15
  71. package/dist/runtime/core/eval/mixins/collections.js.map +1 -1
  72. package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +1 -1
  73. package/dist/runtime/core/eval/mixins/control-flow.js +12 -12
  74. package/dist/runtime/core/eval/mixins/control-flow.js.map +1 -1
  75. package/dist/runtime/core/eval/mixins/core.d.ts.map +1 -1
  76. package/dist/runtime/core/eval/mixins/core.js +12 -13
  77. package/dist/runtime/core/eval/mixins/core.js.map +1 -1
  78. package/dist/runtime/core/eval/mixins/expressions.js +9 -9
  79. package/dist/runtime/core/eval/mixins/expressions.js.map +1 -1
  80. package/dist/runtime/core/eval/mixins/extraction.d.ts.map +1 -1
  81. package/dist/runtime/core/eval/mixins/extraction.js +15 -15
  82. package/dist/runtime/core/eval/mixins/extraction.js.map +1 -1
  83. package/dist/runtime/core/eval/mixins/literals.js +22 -22
  84. package/dist/runtime/core/eval/mixins/literals.js.map +1 -1
  85. package/dist/runtime/core/eval/mixins/types.js +4 -4
  86. package/dist/runtime/core/eval/mixins/types.js.map +1 -1
  87. package/dist/runtime/core/eval/mixins/variables.js +34 -34
  88. package/dist/runtime/core/eval/mixins/variables.js.map +1 -1
  89. package/dist/runtime/core/execute.js +3 -3
  90. package/dist/runtime/core/execute.js.map +1 -1
  91. package/dist/runtime/core/introspection.d.ts +30 -1
  92. package/dist/runtime/core/introspection.d.ts.map +1 -1
  93. package/dist/runtime/core/introspection.js +47 -1
  94. package/dist/runtime/core/introspection.js.map +1 -1
  95. package/dist/runtime/core/types.d.ts +11 -0
  96. package/dist/runtime/core/types.d.ts.map +1 -1
  97. package/dist/runtime/core/types.js.map +1 -1
  98. package/dist/runtime/ext/builtins.js +22 -22
  99. package/dist/runtime/ext/builtins.js.map +1 -1
  100. package/dist/runtime/ext/extensions.d.ts +1 -1
  101. package/dist/runtime/ext/extensions.d.ts.map +1 -1
  102. package/dist/runtime/ext/extensions.js +4 -5
  103. package/dist/runtime/ext/extensions.js.map +1 -1
  104. package/dist/runtime/index.d.ts +6 -4
  105. package/dist/runtime/index.d.ts.map +1 -1
  106. package/dist/runtime/index.js +3 -2
  107. package/dist/runtime/index.js.map +1 -1
  108. package/dist/types.d.ts +36 -37
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/types.js +440 -120
  111. package/dist/types.js.map +1 -1
  112. package/package.json +7 -66
  113. package/README.md +0 -223
  114. package/dist/check/config.d.ts +0 -20
  115. package/dist/check/config.d.ts.map +0 -1
  116. package/dist/check/config.js +0 -151
  117. package/dist/check/config.js.map +0 -1
  118. package/dist/check/fixer.d.ts +0 -39
  119. package/dist/check/fixer.d.ts.map +0 -1
  120. package/dist/check/fixer.js +0 -119
  121. package/dist/check/fixer.js.map +0 -1
  122. package/dist/check/index.d.ts +0 -10
  123. package/dist/check/index.d.ts.map +0 -1
  124. package/dist/check/index.js +0 -21
  125. package/dist/check/index.js.map +0 -1
  126. package/dist/check/rules/anti-patterns.d.ts +0 -65
  127. package/dist/check/rules/anti-patterns.d.ts.map +0 -1
  128. package/dist/check/rules/anti-patterns.js +0 -481
  129. package/dist/check/rules/anti-patterns.js.map +0 -1
  130. package/dist/check/rules/closures.d.ts +0 -66
  131. package/dist/check/rules/closures.d.ts.map +0 -1
  132. package/dist/check/rules/closures.js +0 -370
  133. package/dist/check/rules/closures.js.map +0 -1
  134. package/dist/check/rules/collections.d.ts +0 -90
  135. package/dist/check/rules/collections.d.ts.map +0 -1
  136. package/dist/check/rules/collections.js +0 -373
  137. package/dist/check/rules/collections.js.map +0 -1
  138. package/dist/check/rules/conditionals.d.ts +0 -41
  139. package/dist/check/rules/conditionals.d.ts.map +0 -1
  140. package/dist/check/rules/conditionals.js +0 -134
  141. package/dist/check/rules/conditionals.js.map +0 -1
  142. package/dist/check/rules/flow.d.ts +0 -46
  143. package/dist/check/rules/flow.d.ts.map +0 -1
  144. package/dist/check/rules/flow.js +0 -206
  145. package/dist/check/rules/flow.js.map +0 -1
  146. package/dist/check/rules/formatting.d.ts +0 -133
  147. package/dist/check/rules/formatting.d.ts.map +0 -1
  148. package/dist/check/rules/formatting.js +0 -648
  149. package/dist/check/rules/formatting.js.map +0 -1
  150. package/dist/check/rules/helpers.d.ts +0 -26
  151. package/dist/check/rules/helpers.d.ts.map +0 -1
  152. package/dist/check/rules/helpers.js +0 -66
  153. package/dist/check/rules/helpers.js.map +0 -1
  154. package/dist/check/rules/index.d.ts +0 -21
  155. package/dist/check/rules/index.d.ts.map +0 -1
  156. package/dist/check/rules/index.js +0 -78
  157. package/dist/check/rules/index.js.map +0 -1
  158. package/dist/check/rules/loops.d.ts +0 -77
  159. package/dist/check/rules/loops.d.ts.map +0 -1
  160. package/dist/check/rules/loops.js +0 -310
  161. package/dist/check/rules/loops.js.map +0 -1
  162. package/dist/check/rules/naming.d.ts +0 -21
  163. package/dist/check/rules/naming.d.ts.map +0 -1
  164. package/dist/check/rules/naming.js +0 -174
  165. package/dist/check/rules/naming.js.map +0 -1
  166. package/dist/check/rules/strings.d.ts +0 -28
  167. package/dist/check/rules/strings.d.ts.map +0 -1
  168. package/dist/check/rules/strings.js +0 -79
  169. package/dist/check/rules/strings.js.map +0 -1
  170. package/dist/check/rules/types.d.ts +0 -41
  171. package/dist/check/rules/types.d.ts.map +0 -1
  172. package/dist/check/rules/types.js +0 -167
  173. package/dist/check/rules/types.js.map +0 -1
  174. package/dist/check/types.d.ts +0 -112
  175. package/dist/check/types.d.ts.map +0 -1
  176. package/dist/check/types.js +0 -6
  177. package/dist/check/types.js.map +0 -1
  178. package/dist/check/validator.d.ts +0 -18
  179. package/dist/check/validator.d.ts.map +0 -1
  180. package/dist/check/validator.js +0 -110
  181. package/dist/check/validator.js.map +0 -1
  182. package/dist/check/visitor.d.ts +0 -33
  183. package/dist/check/visitor.d.ts.map +0 -1
  184. package/dist/check/visitor.js +0 -259
  185. package/dist/check/visitor.js.map +0 -1
  186. package/dist/cli-check.d.ts +0 -43
  187. package/dist/cli-check.d.ts.map +0 -1
  188. package/dist/cli-check.js +0 -368
  189. package/dist/cli-check.js.map +0 -1
  190. package/dist/cli-eval.d.ts +0 -15
  191. package/dist/cli-eval.d.ts.map +0 -1
  192. package/dist/cli-eval.js +0 -116
  193. package/dist/cli-eval.js.map +0 -1
  194. package/dist/cli-exec.d.ts +0 -49
  195. package/dist/cli-exec.d.ts.map +0 -1
  196. package/dist/cli-exec.js +0 -183
  197. package/dist/cli-exec.js.map +0 -1
  198. package/dist/cli-module-loader.d.ts +0 -19
  199. package/dist/cli-module-loader.d.ts.map +0 -1
  200. package/dist/cli-module-loader.js +0 -83
  201. package/dist/cli-module-loader.js.map +0 -1
  202. package/dist/cli-shared.d.ts +0 -44
  203. package/dist/cli-shared.d.ts.map +0 -1
  204. package/dist/cli-shared.js +0 -108
  205. package/dist/cli-shared.js.map +0 -1
  206. package/dist/cli.d.ts +0 -13
  207. package/dist/cli.d.ts.map +0 -1
  208. package/dist/cli.js +0 -62
  209. package/dist/cli.js.map +0 -1
  210. package/dist/runtime/core/introspection-data.d.ts +0 -2
  211. package/dist/runtime/core/introspection-data.d.ts.map +0 -1
  212. package/dist/runtime/core/introspection-data.js +0 -618
  213. package/dist/runtime/core/introspection-data.js.map +0 -1
  214. package/dist/runtime/core/version-data.d.ts +0 -18
  215. package/dist/runtime/core/version-data.d.ts.map +0 -1
  216. package/dist/runtime/core/version-data.js +0 -16
  217. package/dist/runtime/core/version-data.js.map +0 -1
  218. package/docs/00_INDEX.md +0 -67
  219. package/docs/01_guide.md +0 -390
  220. package/docs/02_types.md +0 -504
  221. package/docs/03_variables.md +0 -324
  222. package/docs/04_operators.md +0 -629
  223. package/docs/05_control-flow.md +0 -692
  224. package/docs/06_closures.md +0 -787
  225. package/docs/07_collections.md +0 -688
  226. package/docs/08_iterators.md +0 -330
  227. package/docs/09_strings.md +0 -205
  228. package/docs/10_parsing.md +0 -366
  229. package/docs/11_reference.md +0 -600
  230. package/docs/12_examples.md +0 -748
  231. package/docs/13_modules.md +0 -519
  232. package/docs/14_host-integration.md +0 -985
  233. package/docs/15_grammar.ebnf +0 -773
  234. package/docs/16_conventions.md +0 -695
  235. package/docs/17_cli-tools.md +0 -184
  236. package/docs/18_design-principles.md +0 -247
  237. package/docs/19_cookbook.md +0 -628
  238. package/docs/88_errors.md +0 -902
  239. package/docs/99_llm-reference.txt +0 -614
  240. package/docs/assets/logo.png +0 -0
@@ -1,618 +0,0 @@
1
- // AUTO-GENERATED - DO NOT EDIT
2
- // Generated by scripts/generate-docs-bundle.ts from docs/99_llm-reference.txt
3
- export const LANGUAGE_REFERENCE = `RILL LANGUAGE REFERENCE
4
- =======================
5
-
6
- Rill is designed to be generated by LLMs and understood by humans. The focus is on auditable LLM output, not ergonomic human authoring. It combines the flexibility of imperative languages with the strictness of declaritive specifications.
7
-
8
- STRENGTHS AND USE CASES
9
- -----------------------
10
- Strengths:
11
- - Unambiguous syntax: \$ prefix, explicit operators, no implicit coercion
12
- - Single-pass parseable: LLMs generate correct code without symbol tables
13
- - Readable by humans: pipe chains show data flow left-to-right
14
- - Safe defaults: immutable values, type locking, no null/undefined
15
-
16
- Use cases:
17
- - Workflow orchestration: chain LLM calls, API requests, transformations
18
- - State machines: (cond) @ { } loops with \$ as state dict handle multi-state logic
19
- - Data pipelines: each/map/filter/fold process collections declaratively
20
- - Prompt engineering: parse LLM output with parse_json, parse_xml, parse_fence
21
-
22
- State machine pattern (\$ carries state through iterations):
23
- [state: "init", data: \$input]
24
- -> (\$.state != "done") @ {
25
- \$.state -> [
26
- init: { [state: "process", data: transform(\$.data)] },
27
- process: { [state: "done", data: finalize(\$.data)] }
28
- ]
29
- }
30
-
31
- NAMING CONVENTION: snake_case
32
- -----------------------------
33
- Use snake_case for all identifiers:
34
- \$user_name, \$item_list, \$is_valid # variables
35
- \$double_value, \$cleanup_text # closures
36
- [first_name: "x", last_name: "y"] # dict keys
37
-
38
- WHY VARIABLES USE \$ PREFIX
39
- --------------------------
40
- The \$ prefix enables single-pass parsing without a symbol table:
41
-
42
- name() -> host function call
43
- \$name() -> closure invocation
44
- \$name -> variable reference
45
- name -> dict key literal
46
-
47
- Without \$, "process(data)" is ambiguous: is process a host function or stored
48
- closure? Is data a variable or key? This would require tracking all declarations.
49
-
50
- Additional disambiguation:
51
- - Capture: :> \$x requires \$ for lookahead (avoids conflict with slice /<1:>)
52
- - Destructure: *<\$a, \$b> marks variables vs skip patterns
53
- - Dynamic access: \$data.\$key distinguishes variable-key from literal field
54
- - Visual clarity: \$total is always a variable, no context needed
55
-
56
- This follows rill's "no magic" principle: syntax communicates intent explicitly.
57
-
58
- SPACING RULES
59
- -------------
60
- Operators: space both sides 5 + 3, \$x -> .upper, "a" :> \$b
61
- Parentheses: no inner space (\$x + 1), (\$ > 3) ? "yes"
62
- Braces: space inside { \$x + 1 }, each { \$ * 2 }
63
- Brackets: no inner space \$list[0], \$dict.items[1]
64
- Literals: space after , and : [1, 2, 3], [name: "x", age: 30]
65
- Closures: space after params |x| (\$x * 2), |a, b| { \$a + \$b }
66
- Methods: no space before . or ( \$str.upper(), \$list.join(", ")
67
- Pipes: space both sides "x" -> .upper -> .len
68
- Continuations: indent 2 spaces \$data
69
- -> .filter { \$.active }
70
- -> map { \$.name }
71
-
72
- IMPLICIT \$ SHORTHAND (always prefer)
73
- ------------------------------------
74
- \$.method() -> .method "x" -> .upper (not \$.upper())
75
- func(\$) -> func "x" -> log (not log(\$))
76
- \$fn(\$) -> \$fn 5 -> \$double (not \$double(\$))
77
-
78
- NO THROWAWAY CAPTURES
79
- ---------------------
80
- Don't capture just to continue - use line continuation instead:
81
- # avoid # good
82
- "x" :> \$a "x"
83
- \$a -> .upper :> \$b -> .upper
84
- \$b -> .len -> .len
85
-
86
- Only capture when the variable is reused later in the code.
87
-
88
- CRITICAL DIFFERENCES FROM MAINSTREAM LANGUAGES
89
- ----------------------------------------------
90
-
91
- 1. NO ASSIGNMENT OPERATOR
92
- Wrong: x = 5
93
- Right: 5 :> \$x
94
-
95
- Pipe (->): passes value to next operation
96
- Capture (:>): stores value AND continues chain
97
- Example: "hello" :> \$x -> .upper :> \$y # \$x="hello", \$y="HELLO"
98
-
99
- 2. NO NULL/UNDEFINED
100
- Empty values ("", [], [:]) exist. "No value" cannot be represented.
101
- Use ?? for defaults: \$dict.field ?? "default"
102
- Use .empty to check: \$str -> .empty ? "was empty"
103
-
104
- 3. NO TRUTHINESS
105
- Conditions MUST be boolean. No implicit coercion.
106
- Wrong: "" ? "yes" ! "no"
107
- Right: "" -> .empty ? "yes" ! "no"
108
- Wrong: 0 ? "yes" ! "no"
109
- Right: (0 == 0) ? "yes" ! "no"
110
-
111
- Negation (!) also requires boolean:
112
- Right: !true # false
113
- Right: "hello" -> .empty -> (!\$) # true (negates boolean from .empty)
114
- Wrong: !"hello" # ERROR: Negation requires boolean, got string
115
- Wrong: !0 # ERROR: Negation requires boolean, got number
116
-
117
- 4. VARIABLES LOCK TO FIRST TYPE
118
- "hello" :> \$x
119
- 42 :> \$x # ERROR: cannot assign number to string variable
120
-
121
- 5. NO VARIABLE SHADOWING (CRITICAL FOR LOOPS)
122
- Child scopes can READ parent variables but cannot WRITE or redeclare them.
123
- Variables created inside blocks/loops do NOT leak out.
124
-
125
- WRONG - this pattern NEVER works:
126
- 0 :> \$count
127
- [1, 2, 3] -> each { \$count + 1 :> \$count } # creates LOCAL \$count
128
- \$count # still 0!
129
-
130
- RIGHT - use \$ or \$@ as state carrier (see LOOP STATE PATTERNS below)
131
-
132
- 6. NO EXCEPTIONS
133
- Errors halt execution. No try/catch. Use conditionals for error handling.
134
- Built-in: assert (validate condition), error (halt with message).
135
-
136
- 7. VALUE SEMANTICS (no references)
137
- All copies are deep. All comparisons are by value. No object identity.
138
- [1, 2, 3] == [1, 2, 3] # true (content equality)
139
- [1, 2] :> \$a
140
- \$a :> \$b # \$b is an independent deep copy
141
- Mainstream habit to avoid: expecting two variables to share the same object.
142
-
143
- SYNTAX QUICK REFERENCE
144
- ----------------------
145
-
146
- Variables: \$name (always prefixed with \$)
147
- Strings: "hello {\$var}" # interpolation with {}
148
- """...""" # multiline (also interpolates)
149
- Numbers: 42, 3.14, -7
150
- Booleans: true, false
151
- Lists: [1, 2, 3]
152
- [...\$list, 4] # spread: inline list elements
153
- Dicts: [name: "alice", age: 30] # identifier keys
154
- [1: "one", 2: "two"] # number keys (incl. negative: [-1: "neg"])
155
- [true: "yes", false: "no"] # boolean keys
156
- [["a", "b"]: 1] # multi-key: [a: 1, b: 1]
157
- [\$keyVar: value] # variable key (must eval to string)
158
- [(\$expr): value] # computed key (must eval to string)
159
- Tuples: *[1, 2, 3] # for argument unpacking
160
- Closures: |x|(\$x + 1) # like lambda/arrow functions
161
- Type annot: "hi" :> \$x:string # lock type on capture
162
- Comments: # single line only
163
-
164
- PIPES AND \$ BINDING
165
- -------------------
166
-
167
- \$ is the current piped value. Its meaning depends on context:
168
-
169
- | Context | \$ contains |
170
- |----------------------------|-------------------------|
171
- | -> { body } | piped value |
172
- | -> each { } | current item |
173
- | (cond) @ { } | accumulated value |
174
- | @ { } ? cond | accumulated value |
175
- | cond ? { } ! { } | tested value |
176
- | -> ? { } ! { } | piped value |
177
- | ||{ \$.field } in dict | the containing dict |
178
- | |x|{ } stored closure | N/A - use parameters |
179
-
180
- Implied \$: bare .method() means \$ -> .method()
181
- Example: "hello" -> .upper # same as "hello" -> \$.upper()
182
-
183
- CONTROL FLOW
184
- ------------
185
-
186
- Conditional (if-else):
187
- cond ? then_expr ! else_expr
188
- cond ? then_expr # else returns ""
189
-
190
- Piped conditional (\$ becomes condition):
191
- value -> ? then_expr ! else_expr
192
-
193
- Condition loop (NO "while" keyword - use @ operator):
194
- init_value -> (\$ < 10) @ { \$ + 1 } # \$ is accumulator
195
-
196
- Do-condition loop (body runs at least once):
197
- init_value -> @ { \$ + 1 } ? (\$ < 10)
198
-
199
- Break (exits loop, returns collected results before break):
200
- [1,2,3,4,5] -> each { (\$ == 3) ? break; \$ } # returns [1, 2]
201
-
202
- Return (exits block or script with value):
203
- { 5 :> \$x; (\$x > 3) ? ("big" -> return); "small" } # returns "big"
204
- "done" -> return # exits script with "done"
205
-
206
- Assert (validate condition, halt if false, pass through if true):
207
- 5 -> assert (\$ > 0) # returns 5
208
- -1 -> assert (\$ > 0) # ERROR: Assertion failed
209
- "" -> assert !.empty "Input required" # ERROR: Input required
210
- \$val -> assert \$:?list "Expected list" # type validation
211
-
212
- Error (halt execution immediately with message):
213
- error "Something went wrong" # halt with message
214
- "Operation failed" -> error # piped form (must be string)
215
- error "Status: {\$code}" # interpolation works
216
-
217
- Pass (returns \$ unchanged, explicit no-op):
218
- cond ? pass ! "fallback" # preserve \$ when condition true
219
- cond ? "value" ! pass # preserve \$ when condition false
220
- "data" -> { [status: pass] } # include \$ in dict: [status: "data"]
221
- [1, -2, 3] -> map { (\$ > 0) ? pass ! 0 } # [1, 0, 3]
222
- Note: pass requires pipe context. Using pass without \$ throws error.
223
-
224
- LOOP STATE PATTERNS (CRITICAL)
225
- ------------------------------
226
- Rill loops CANNOT modify outer variables. All state must flow through \$ or \$@.
227
-
228
- WRONG - outer variable modification (NEVER works):
229
- 0 :> \$sum
230
- [1, 2, 3] -> each { \$sum + \$ :> \$sum } # \$sum unchanged!
231
-
232
- WRONG - "while" keyword does not exist:
233
- while (\$i < 10) { \$i + 1 :> \$i } # SYNTAX ERROR
234
-
235
- RIGHT - use fold for reduction:
236
- [1, 2, 3] -> fold(0) { \$@ + \$ } # 6 (\$@ is accumulator)
237
-
238
- RIGHT - use each(init) when you need both results AND accumulator:
239
- [1, 2, 3] -> each(0) { \$@ + \$ } # [1, 3, 6] (running totals)
240
-
241
- RIGHT - use (cond) @ { } with \$ as state dict for multiple values:
242
- [iter: 0, max: 3, text: \$input, done: false]
243
- -> (!\$.done && \$.iter < \$.max) @ {
244
- \$.iter + 1 :> \$i
245
- process(\$.text) :> \$result
246
- \$result.finished ? [iter: \$i, max: \$.max, text: \$.text, done: true]
247
- ! [iter: \$i, max: \$.max, text: \$result.text, done: false]
248
- }
249
- # Access final state: \$.text, \$.iter
250
-
251
- Pattern summary:
252
- - Single value accumulation -> fold(init) { \$@ + \$ }
253
- - Per-item results + running -> each(init) { ... \$@ ... }
254
- - Multiple state values / while -> (cond) @ { } with \$ as state dict
255
- - "while" and "for" keywords -> DO NOT EXIST
256
-
257
- COLLECTION OPERATORS
258
- --------------------
259
-
260
- | Operator | Execution | Returns | Break? |
261
- |--------------------|------------|----------------------|--------|
262
- | -> each { } | sequential | all body results | yes |
263
- | -> each(i) { \$@+\$} | sequential | all with accumulator | yes |
264
- | -> map { } | parallel | all body results | NO |
265
- | -> filter { } | parallel | matching elements | NO |
266
- | -> fold(i) { \$@+\$} | sequential | final result only | yes |
267
-
268
- \$@ is the accumulator in each(init) and fold(init).
269
-
270
- Method shorthand in collection operators:
271
- ["a", "b"] -> map .upper # ["A", "B"]
272
- ["", "x"] -> filter (!.empty) # ["x"]
273
- ["a", "b"] -> map .pad_start(3, "0") # ["00a", "00b"] (with args)
274
- [" HI "] -> map .trim.lower # ["hi"] (chained methods)
275
-
276
- Body forms (all operators accept these):
277
- -> each { \$ * 2 } # block (\$ is current element)
278
- -> each (\$ + 10) # grouped expression
279
- -> each |x| (\$x * 2) # inline closure
280
- -> each \$double # variable closure
281
- -> each .upper # method shorthand
282
-
283
- Dict iteration (\$ contains key and value fields):
284
- [a: 1, b: 2] -> each { "{\$.key}={\$.value}" } # ["a=1", "b=2"]
285
- [a: 1, b: 5] -> filter { \$.value > 2 } # entries where value > 2
286
-
287
- String iteration (iterates over characters):
288
- "abc" -> each { "{\$}!" } # ["a!", "b!", "c!"]
289
- "hello" -> filter { \$ != "l" } # ["h", "e", "o"]
290
-
291
- CLOSURES
292
- --------
293
-
294
- BLOCK-CLOSURES vs EXPLICIT CLOSURES:
295
-
296
- Two ways to create closures:
297
-
298
- 1. Block-closures: { body } in expression position
299
- { \$ + 1 } :> \$inc # implicit \$ parameter
300
- \$inc(5) # 6
301
- 5 -> \$inc # 6 (pipe invocation)
302
- [x: { \$ * 2 }] # dict value is closure
303
- type({ "hi" }) # "closure"
304
-
305
- 2. Explicit closures: |params| body
306
- |x|(\$x + 1) :> \$inc # named parameter
307
- |a, b|(\$a + \$b) :> \$add # multiple params
308
- |x = 0|(\$x + 1) :> \$inc_or_one # default value
309
- |x: number|(\$x + 1) :> \$typed # type annotation
310
-
311
- CRITICAL: { } vs ( ) distinction
312
-
313
- | Syntax | Semantics | Example |
314
- |--------------|------------------------|----------------------------|
315
- | { body } | Deferred (closure) | { \$ + 1 } :> \$fn # closure |
316
- | ( expr ) | Eager (immediate eval) | ( 5 + 1 ) :> \$x # 6 |
317
-
318
- When to use:
319
- { body } :> \$fn # store closure for later use
320
- ( expr ) :> \$x # store result value immediately
321
-
322
- PIPE TARGET: { } creates closure then immediately invokes it:
323
- 5 -> { \$ + 1 } # 6 (create closure, invoke with 5)
324
- 5 -> (\$ + 1) # 6 (evaluate expression with \$=5)
325
- Same observable result, different mechanism. Error messages differ.
326
-
327
- Block-closure invocation:
328
- { \$ + 1 } :> \$inc
329
- \$inc(5) # direct call: 6
330
- 5 -> \$inc # pipe call: 6
331
- [1,2,3] -> map \$inc # in collection op
332
-
333
- LATE BINDING: closures capture scope, not values. Variables resolve at call time.
334
-
335
- \$ vs named params:
336
- Use \$ in inline pipes and loops: "hello" -> { .upper }
337
- Use named params in stored closures: |x| (\$x * 2) :> \$double
338
- \$ is undefined when a stored closure is called later — always use params.
339
-
340
- Zero-param dict closures (methods):
341
- [count: 3, double: ||{ \$.count * 2 }] :> \$obj
342
- \$obj.double # 6 (\$ is bound to dict)
343
-
344
- PROPERTY ACCESS
345
- ---------------
346
-
347
- \$data.field # dict field
348
- \$data[0], \$data[-1] # list index (negative from end)
349
- \$data.\$key # variable as key
350
- \$data.(\$i + 1) # computed key
351
- \$data.(a || b) # try keys left-to-right
352
- \$data.field ?? "default" # default if missing
353
- \$data.?field # existence check (boolean)
354
- \$data.?\$keyVar # variable existence check
355
- \$data.?(\$expr) # computed existence check
356
- \$data.?field&string # existence AND type check
357
- \$data.?\$key&number # variable existence + type check
358
- \$data.?(\$a -> "{\$}_b")&list # computed existence + type check
359
-
360
- DISPATCH OPERATORS
361
- ------------------
362
-
363
- DICT DISPATCH (single key):
364
- Pipe a value to a dict to match keys and return associated values:
365
- \$val -> [apple: "fruit", carrot: "veg"] # returns "fruit" if \$val is "apple"
366
- \$val -> [apple: "fruit"] ?? "not found" # default if no match
367
- \$method -> [["GET", "HEAD"]: "safe", ["POST", "PUT"]: "unsafe"] # multi-key dispatch
368
-
369
- Multi-key dispatch uses the same syntax as multi-key dict literals:
370
- [["GET", "HEAD"]: "safe"] # dict with keys "GET" and "HEAD" both = "safe"
371
- "GET" -> [["GET", "HEAD"]: "safe"] # "safe" (matches "GET" key)
372
-
373
- Type-aware matching (keys matched by value AND type):
374
- 1 -> [1: "number", "1": "string"] # "number" (number key matches)
375
- "1" -> [1: "number", "1": "string"] # "string" (string key matches)
376
- true -> [true: "bool", "true": "str"] # "bool" (boolean key matches)
377
-
378
- LIST DISPATCH (index):
379
- Pipe a number to a list to get element at index:
380
- 0 -> ["first", "second"] # "first"
381
- -1 -> ["first", "second"] # "second" (last)
382
- 5 -> ["a", "b"] ?? "not found" # default if out of bounds
383
-
384
- HIERARCHICAL DISPATCH (path navigation):
385
- Pipe a list of keys/indexes to navigate nested structures:
386
- ["name", "first"] -> [name: [first: "Alice"]] # "Alice" (dict path)
387
- [0, 1] -> [[1, 2, 3], [4, 5, 6]] # 2 (list path)
388
- ["users", 0, "name"] -> [users: [[name: "Alice"]]] # "Alice" (mixed)
389
- [] -> [a: 1] # [a: 1] (empty path = unchanged)
390
- ["a", "missing"] -> [a: [x: 1]] ?? "default" # "default" (missing key)
391
-
392
- Path elements: strings for dict keys, numbers for list indexes (negative supported).
393
- Terminal closures receive \$ bound to final path key:
394
- ["req", "draft"] -> [req: [draft: { "key={\$}" }]] # "key=draft"
395
-
396
- TYPE OPERATIONS
397
- ---------------
398
-
399
- :type - assert type (error if wrong): 42:number passes; "x":number errors
400
- :?type - check type (boolean): 42:?number is true; "x":?number is false
401
-
402
- Types: string, number, boolean, list, dict, tuple, closure
403
-
404
- COMPARISON METHODS
405
- ------------------
406
-
407
- Methods for readable comparisons in conditionals:
408
- .eq(val) == \$v -> .eq("A") ? "match"
409
- .ne(val) != \$v -> .ne("") ? "has value"
410
- .lt(val) < \$v -> .lt(10) ? "small"
411
- .gt(val) > 5 -> .gt(3) ? "big"
412
- .le(val) <= 10 -> .le(10) ? "ok"
413
- .ge(val) >= \$age -> .ge(18) ? "adult"
414
-
415
- OPERATOR PRECEDENCE (highest to lowest)
416
- ---------------------------------------
417
-
418
- 1. Member access: .field, [index]
419
- 2. Type operators: :type, :?type
420
- 3. Unary: -, !
421
- 4. Multiplicative: *, /, %
422
- 5. Additive: +, -
423
- 6. Comparison: ==, !=, <, >, <=, >=
424
- 7. Logical AND: &&
425
- 8. Logical OR: ||
426
- 9. Default: ??
427
- 10. Pipe: ->
428
- 11. Capture: :>
429
-
430
- Use parentheses to override: (2 + 3) * 4
431
-
432
- EXTRACTION OPERATORS
433
- --------------------
434
-
435
- Destructure (*<>):
436
- [1, 2, 3] -> *<\$a, \$b, \$c> # \$a=1, \$b=2, \$c=3
437
- [x: 1, y: 2] -> *<x: \$a, y: \$b> # \$a=1, \$b=2
438
- [1, 2, 3] -> *<\$first, _, \$third> # _ skips element
439
-
440
- Slice (/<start:stop:step>):
441
- [0,1,2,3,4] -> /<1:3> # [1, 2]
442
- [0,1,2,3,4] -> /<-2:> # [3, 4]
443
- [0,1,2,3,4] -> /<::-1> # [4,3,2,1,0] (reverse)
444
- "hello" -> /<1:4> # "ell"
445
-
446
- LIST SPREAD IN LITERALS
447
- -----------------------
448
-
449
- Inline list elements into a new list using ... (spread operator):
450
- [1, 2] :> \$a
451
- [...\$a, 3] # [1, 2, 3]
452
- [...\$a, ...\$b] # concatenate lists
453
- [...[], 1] # [1] (empty spread contributes nothing)
454
- [...(\$nums -> map {\$ * 2})] # spread expression result
455
- [...\$nested[0]] # spread from nested access
456
-
457
- Error: spreading non-list throws RUNTIME_TYPE_ERROR
458
- "hello" :> \$s
459
- [...\$s] # ERROR: Spread requires list, got string
460
-
461
- MULTI-KEY DICT LITERALS
462
- -----------------------
463
-
464
- Map multiple keys to the same value using list syntax:
465
- [["a", "b"]: 1] # [a: 1, b: 1]
466
- [[1, "1"]: "x"] # [1: "x", "1": "x"] (mixed types)
467
- [a: 0, ["b", "c"]: 1] # [a: 0, b: 1, c: 1] (mixed entries)
468
- [a: 0, ["a", "b"]: 1] # [a: 1, b: 1] (last-write-wins)
469
-
470
- Error cases:
471
- [[]: 1] # ERROR: empty key list
472
- [[[1, 2], "a"]: 1] # ERROR: non-primitive key element
473
-
474
- TUPLES FOR ARGUMENT UNPACKING
475
- -----------------------------
476
-
477
- *[1, 2, 3] -> \$fn() # positional: \$fn(1, 2, 3)
478
- *[b: 2, a: 1] -> \$fn() # named: \$fn(a=1, b=2)
479
- *[...\$list, 3] -> \$fn() # spread in tuple: combines elements
480
-
481
- SPREAD OPERATOR (@)
482
- -------------------
483
-
484
- Chains closures sequentially:
485
- 5 -> @[\$inc, \$double, \$add10] # (5+1)*2+10 = 22
486
-
487
- STRING METHODS
488
- --------------
489
-
490
- .len length
491
- .empty is empty string
492
- .trim remove whitespace
493
- .upper uppercase
494
- .lower lowercase
495
- .split(sep) split into list
496
- .lines split on newlines
497
- .join(sep) join list with separator (on list)
498
- .contains(s) substring check
499
- .starts_with(s) prefix check
500
- .ends_with(s) suffix check
501
- .replace(p,r) replace first match
502
- .replace_all(p,r) replace all matches
503
- .match(regex) first match info (dict with matched, index, groups)
504
- .is_match(regex) boolean regex check
505
- .head first character
506
- .tail last character
507
- .at(i) character at index
508
- .index_of(s) position of first match (-1 if none)
509
- .repeat(n) repeat string n times: "ab" -> .repeat(3) # "ababab"
510
- .pad_start(n,f) pad start to length: "42" -> .pad_start(5, "0") # "00042"
511
- .pad_end(n,f) pad end to length: "42" -> .pad_end(5, "0") # "42000"
512
- .str convert any value to string: 42 -> .str # "42"
513
- .num parse string to number: "42" -> .num # 42
514
-
515
- LIST/DICT METHODS
516
- -----------------
517
-
518
- .len length
519
- .empty is empty
520
- .head first element
521
- .tail last element
522
- .at(i) element at index
523
- .has(val) check if list contains value (deep equality)
524
- .has_any(list) check if list contains any value from candidates
525
- .has_all(list) check if list contains all values from candidates
526
- .keys dict keys as list
527
- .values dict values as list
528
- .entries dict as list of [key: k, value: v]
529
-
530
- PARSING FUNCTIONS (for LLM output)
531
- ----------------------------------
532
-
533
- parse_auto(str) auto-detect format
534
- parse_json(str) parse JSON (repairs common errors)
535
- parse_xml(str, tag?) extract XML tag content
536
- parse_fence(str, lang?) extract fenced code block
537
- parse_fences(str) all fenced blocks as list
538
- parse_frontmatter(str) parse --- delimited YAML + body
539
- parse_checklist(str) parse markdown task lists
540
-
541
- GLOBAL FUNCTIONS
542
- ----------------
543
-
544
- type(val) returns type name
545
- log(val) print and pass through
546
- json(val) convert to JSON string
547
- identity(val) returns input unchanged
548
- range(start, end, step?) number sequence
549
- repeat(val, count) repeat value n times
550
- enumerate(coll) add index to elements
551
-
552
- ITERATORS
553
- ---------
554
-
555
- Lazy sequence generation. Collection operators auto-expand iterators.
556
-
557
- Built-in iterators:
558
- range(0, 5) -> each { \$ * 2 } # [0, 2, 4, 6, 8]
559
- repeat("x", 3) -> each { \$ } # ["x", "x", "x"]
560
-
561
- .first() method (returns iterator for any collection):
562
- [1, 2, 3] -> .first() # iterator at 1
563
- "abc" -> .first() # iterator at "a"
564
- [] -> .first() # [done: true, ...]
565
-
566
- Iterator protocol (dict with value, done, next):
567
- \$it.done # bool: is exhausted?
568
- \$it.value # current element
569
- \$it.next() # returns new iterator at next position
570
-
571
- ITERATION LIMITS
572
- ----------------
573
-
574
- Default: 10,000 iterations max for loops.
575
- Override: ^(limit: N) statement
576
-
577
- Example:
578
- ^(limit: 100) 0 -> (\$ < 50) @ { \$ + 1 }
579
-
580
- Concurrency limit for map (controls parallel concurrency):
581
- ^(limit: 3) \$items -> map { slow_process(\$) }
582
-
583
- COMMON MISTAKES
584
- ---------------
585
-
586
- 1. Using = for assignment -> use :> instead
587
- 2. Using || for defaults -> use ?? instead
588
- 3. Assuming truthiness -> explicit boolean checks required
589
- 4. Breaking from map/filter -> only works in each/fold
590
- 5. Modifying outer vars in loops -> use fold/\$@ or \$ as state dict (see LOOP STATE PATTERNS)
591
- 6. Expecting variables to leak -> block scope is strict
592
- 7. Forgetting () on methods -> .upper() not .upper (unless property)
593
- 8. Reassigning different type -> variables lock to first type
594
- 9. Using while/for keywords -> use (cond) @ { } or -> each { } instead
595
-
596
- SCRIPT RETURN VALUES
597
- --------------------
598
-
599
- true / non-empty string -> exit code 0
600
- false / empty string -> exit code 1
601
- [0, "message"] -> exit code 0 with message
602
- [1, "message"] -> exit code 1 with message
603
-
604
- MAINSTREAM TO RILL TRANSLATION
605
- ------------------------------
606
-
607
- | Mainstream | Rill |
608
- |--------------------------|----------------------------------------- |
609
- | x = value | value :> \$x |
610
- | null / undefined | ?? default, .? existence check |
611
- | if "" (truthiness) | .empty, == 0, :?type |
612
- | try { } catch { } | assert, conditionals, error |
613
- | for (i = 0; ...) | each, map, filter, fold |
614
- | count += 1 in loop | fold(0) { \$@ + 1 } or \$ accumulator |
615
- | a === b (reference) | == always compares by value |
616
- | a = b (shared ref) | :> always deep-copies |
617
- `;
618
- //# sourceMappingURL=introspection-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"introspection-data.js","sourceRoot":"","sources":["../../../src/runtime/core/introspection-data.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsmBjC,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Version information structure
3
- */
4
- export interface VersionInfo {
5
- readonly major: number;
6
- readonly minor: number;
7
- readonly patch: number;
8
- readonly prerelease: string | undefined;
9
- }
10
- /**
11
- * Version string from package.json
12
- */
13
- export declare const VERSION = "0.5.0";
14
- /**
15
- * Parsed version components
16
- */
17
- export declare const VERSION_INFO: VersionInfo;
18
- //# sourceMappingURL=version-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version-data.d.ts","sourceRoot":"","sources":["../../../src/runtime/core/version-data.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,WAK1B,CAAC"}
@@ -1,16 +0,0 @@
1
- // AUTO-GENERATED - DO NOT EDIT
2
- // Generated by scripts/generate-version.ts from package.json
3
- /**
4
- * Version string from package.json
5
- */
6
- export const VERSION = '0.5.0';
7
- /**
8
- * Parsed version components
9
- */
10
- export const VERSION_INFO = {
11
- major: 0,
12
- minor: 5,
13
- patch: 0,
14
- prerelease: undefined,
15
- };
16
- //# sourceMappingURL=version-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version-data.js","sourceRoot":"","sources":["../../../src/runtime/core/version-data.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,6DAA6D;AAY7D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,SAAS;CACtB,CAAC"}