@rcrsr/rill 0.1.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 (295) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +187 -0
  3. package/dist/cli.d.ts +11 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +69 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/demo.d.ts +6 -0
  8. package/dist/demo.d.ts.map +1 -0
  9. package/dist/demo.js +121 -0
  10. package/dist/demo.js.map +1 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +9 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/lexer/errors.d.ts +9 -0
  16. package/dist/lexer/errors.d.ts.map +1 -0
  17. package/dist/lexer/errors.js +12 -0
  18. package/dist/lexer/errors.js.map +1 -0
  19. package/dist/lexer/helpers.d.ts +14 -0
  20. package/dist/lexer/helpers.d.ts.map +1 -0
  21. package/dist/lexer/helpers.js +30 -0
  22. package/dist/lexer/helpers.js.map +1 -0
  23. package/dist/lexer/index.d.ts +8 -0
  24. package/dist/lexer/index.d.ts.map +1 -0
  25. package/dist/lexer/index.js +8 -0
  26. package/dist/lexer/index.js.map +1 -0
  27. package/dist/lexer/operators.d.ts +11 -0
  28. package/dist/lexer/operators.d.ts.map +1 -0
  29. package/dist/lexer/operators.js +58 -0
  30. package/dist/lexer/operators.js.map +1 -0
  31. package/dist/lexer/readers.d.ts +12 -0
  32. package/dist/lexer/readers.d.ts.map +1 -0
  33. package/dist/lexer/readers.js +144 -0
  34. package/dist/lexer/readers.js.map +1 -0
  35. package/dist/lexer/state.d.ts +18 -0
  36. package/dist/lexer/state.d.ts.map +1 -0
  37. package/dist/lexer/state.js +37 -0
  38. package/dist/lexer/state.js.map +1 -0
  39. package/dist/lexer/tokenizer.d.ts +9 -0
  40. package/dist/lexer/tokenizer.d.ts.map +1 -0
  41. package/dist/lexer/tokenizer.js +100 -0
  42. package/dist/lexer/tokenizer.js.map +1 -0
  43. package/dist/lexer.d.ts +19 -0
  44. package/dist/lexer.d.ts.map +1 -0
  45. package/dist/lexer.js +344 -0
  46. package/dist/lexer.js.map +1 -0
  47. package/dist/parser/arithmetic.d.ts +16 -0
  48. package/dist/parser/arithmetic.d.ts.map +1 -0
  49. package/dist/parser/arithmetic.js +128 -0
  50. package/dist/parser/arithmetic.js.map +1 -0
  51. package/dist/parser/boolean.d.ts +15 -0
  52. package/dist/parser/boolean.d.ts.map +1 -0
  53. package/dist/parser/boolean.js +20 -0
  54. package/dist/parser/boolean.js.map +1 -0
  55. package/dist/parser/control-flow.d.ts +56 -0
  56. package/dist/parser/control-flow.d.ts.map +1 -0
  57. package/dist/parser/control-flow.js +167 -0
  58. package/dist/parser/control-flow.js.map +1 -0
  59. package/dist/parser/expressions.d.ts +23 -0
  60. package/dist/parser/expressions.d.ts.map +1 -0
  61. package/dist/parser/expressions.js +950 -0
  62. package/dist/parser/expressions.js.map +1 -0
  63. package/dist/parser/extraction.d.ts +48 -0
  64. package/dist/parser/extraction.d.ts.map +1 -0
  65. package/dist/parser/extraction.js +279 -0
  66. package/dist/parser/extraction.js.map +1 -0
  67. package/dist/parser/functions.d.ts +20 -0
  68. package/dist/parser/functions.d.ts.map +1 -0
  69. package/dist/parser/functions.js +96 -0
  70. package/dist/parser/functions.js.map +1 -0
  71. package/dist/parser/helpers.d.ts +94 -0
  72. package/dist/parser/helpers.d.ts.map +1 -0
  73. package/dist/parser/helpers.js +225 -0
  74. package/dist/parser/helpers.js.map +1 -0
  75. package/dist/parser/index.d.ts +49 -0
  76. package/dist/parser/index.d.ts.map +1 -0
  77. package/dist/parser/index.js +73 -0
  78. package/dist/parser/index.js.map +1 -0
  79. package/dist/parser/literals.d.ts +37 -0
  80. package/dist/parser/literals.d.ts.map +1 -0
  81. package/dist/parser/literals.js +373 -0
  82. package/dist/parser/literals.js.map +1 -0
  83. package/dist/parser/parser-collect.d.ts +16 -0
  84. package/dist/parser/parser-collect.d.ts.map +1 -0
  85. package/dist/parser/parser-collect.js +125 -0
  86. package/dist/parser/parser-collect.js.map +1 -0
  87. package/dist/parser/parser-control.d.ts +20 -0
  88. package/dist/parser/parser-control.d.ts.map +1 -0
  89. package/dist/parser/parser-control.js +120 -0
  90. package/dist/parser/parser-control.js.map +1 -0
  91. package/dist/parser/parser-expr.d.ts +37 -0
  92. package/dist/parser/parser-expr.d.ts.map +1 -0
  93. package/dist/parser/parser-expr.js +639 -0
  94. package/dist/parser/parser-expr.js.map +1 -0
  95. package/dist/parser/parser-extract.d.ts +17 -0
  96. package/dist/parser/parser-extract.d.ts.map +1 -0
  97. package/dist/parser/parser-extract.js +222 -0
  98. package/dist/parser/parser-extract.js.map +1 -0
  99. package/dist/parser/parser-functions.d.ts +21 -0
  100. package/dist/parser/parser-functions.d.ts.map +1 -0
  101. package/dist/parser/parser-functions.js +155 -0
  102. package/dist/parser/parser-functions.js.map +1 -0
  103. package/dist/parser/parser-literals.d.ts +22 -0
  104. package/dist/parser/parser-literals.d.ts.map +1 -0
  105. package/dist/parser/parser-literals.js +288 -0
  106. package/dist/parser/parser-literals.js.map +1 -0
  107. package/dist/parser/parser-script.d.ts +21 -0
  108. package/dist/parser/parser-script.d.ts.map +1 -0
  109. package/dist/parser/parser-script.js +174 -0
  110. package/dist/parser/parser-script.js.map +1 -0
  111. package/dist/parser/parser-variables.d.ts +20 -0
  112. package/dist/parser/parser-variables.d.ts.map +1 -0
  113. package/dist/parser/parser-variables.js +146 -0
  114. package/dist/parser/parser-variables.js.map +1 -0
  115. package/dist/parser/parser.d.ts +49 -0
  116. package/dist/parser/parser.d.ts.map +1 -0
  117. package/dist/parser/parser.js +54 -0
  118. package/dist/parser/parser.js.map +1 -0
  119. package/dist/parser/script.d.ts +14 -0
  120. package/dist/parser/script.d.ts.map +1 -0
  121. package/dist/parser/script.js +196 -0
  122. package/dist/parser/script.js.map +1 -0
  123. package/dist/parser/state.d.ts +40 -0
  124. package/dist/parser/state.d.ts.map +1 -0
  125. package/dist/parser/state.js +129 -0
  126. package/dist/parser/state.js.map +1 -0
  127. package/dist/parser/variables.d.ts +10 -0
  128. package/dist/parser/variables.d.ts.map +1 -0
  129. package/dist/parser/variables.js +215 -0
  130. package/dist/parser/variables.js.map +1 -0
  131. package/dist/runtime/ast-equals.d.ts +13 -0
  132. package/dist/runtime/ast-equals.d.ts.map +1 -0
  133. package/dist/runtime/ast-equals.js +447 -0
  134. package/dist/runtime/ast-equals.js.map +1 -0
  135. package/dist/runtime/builtins.d.ts +13 -0
  136. package/dist/runtime/builtins.d.ts.map +1 -0
  137. package/dist/runtime/builtins.js +180 -0
  138. package/dist/runtime/builtins.js.map +1 -0
  139. package/dist/runtime/callable.d.ts +88 -0
  140. package/dist/runtime/callable.d.ts.map +1 -0
  141. package/dist/runtime/callable.js +98 -0
  142. package/dist/runtime/callable.js.map +1 -0
  143. package/dist/runtime/context.d.ts +13 -0
  144. package/dist/runtime/context.d.ts.map +1 -0
  145. package/dist/runtime/context.js +73 -0
  146. package/dist/runtime/context.js.map +1 -0
  147. package/dist/runtime/core/callable.d.ts +171 -0
  148. package/dist/runtime/core/callable.d.ts.map +1 -0
  149. package/dist/runtime/core/callable.js +246 -0
  150. package/dist/runtime/core/callable.js.map +1 -0
  151. package/dist/runtime/core/context.d.ts +29 -0
  152. package/dist/runtime/core/context.d.ts.map +1 -0
  153. package/dist/runtime/core/context.js +154 -0
  154. package/dist/runtime/core/context.js.map +1 -0
  155. package/dist/runtime/core/equals.d.ts +9 -0
  156. package/dist/runtime/core/equals.d.ts.map +1 -0
  157. package/dist/runtime/core/equals.js +381 -0
  158. package/dist/runtime/core/equals.js.map +1 -0
  159. package/dist/runtime/core/eval/base.d.ts +65 -0
  160. package/dist/runtime/core/eval/base.d.ts.map +1 -0
  161. package/dist/runtime/core/eval/base.js +112 -0
  162. package/dist/runtime/core/eval/base.js.map +1 -0
  163. package/dist/runtime/core/eval/evaluator.d.ts +47 -0
  164. package/dist/runtime/core/eval/evaluator.d.ts.map +1 -0
  165. package/dist/runtime/core/eval/evaluator.js +73 -0
  166. package/dist/runtime/core/eval/evaluator.js.map +1 -0
  167. package/dist/runtime/core/eval/index.d.ts +57 -0
  168. package/dist/runtime/core/eval/index.d.ts.map +1 -0
  169. package/dist/runtime/core/eval/index.js +95 -0
  170. package/dist/runtime/core/eval/index.js.map +1 -0
  171. package/dist/runtime/core/eval/mixins/annotations.d.ts +19 -0
  172. package/dist/runtime/core/eval/mixins/annotations.d.ts.map +1 -0
  173. package/dist/runtime/core/eval/mixins/annotations.js +146 -0
  174. package/dist/runtime/core/eval/mixins/annotations.js.map +1 -0
  175. package/dist/runtime/core/eval/mixins/closures.d.ts +49 -0
  176. package/dist/runtime/core/eval/mixins/closures.d.ts.map +1 -0
  177. package/dist/runtime/core/eval/mixins/closures.js +479 -0
  178. package/dist/runtime/core/eval/mixins/closures.js.map +1 -0
  179. package/dist/runtime/core/eval/mixins/collections.d.ts +24 -0
  180. package/dist/runtime/core/eval/mixins/collections.d.ts.map +1 -0
  181. package/dist/runtime/core/eval/mixins/collections.js +466 -0
  182. package/dist/runtime/core/eval/mixins/collections.js.map +1 -0
  183. package/dist/runtime/core/eval/mixins/control-flow.d.ts +27 -0
  184. package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +1 -0
  185. package/dist/runtime/core/eval/mixins/control-flow.js +369 -0
  186. package/dist/runtime/core/eval/mixins/control-flow.js.map +1 -0
  187. package/dist/runtime/core/eval/mixins/core.d.ts +24 -0
  188. package/dist/runtime/core/eval/mixins/core.d.ts.map +1 -0
  189. package/dist/runtime/core/eval/mixins/core.js +335 -0
  190. package/dist/runtime/core/eval/mixins/core.js.map +1 -0
  191. package/dist/runtime/core/eval/mixins/expressions.d.ts +19 -0
  192. package/dist/runtime/core/eval/mixins/expressions.d.ts.map +1 -0
  193. package/dist/runtime/core/eval/mixins/expressions.js +202 -0
  194. package/dist/runtime/core/eval/mixins/expressions.js.map +1 -0
  195. package/dist/runtime/core/eval/mixins/extraction.d.ts +10 -0
  196. package/dist/runtime/core/eval/mixins/extraction.d.ts.map +1 -0
  197. package/dist/runtime/core/eval/mixins/extraction.js +250 -0
  198. package/dist/runtime/core/eval/mixins/extraction.js.map +1 -0
  199. package/dist/runtime/core/eval/mixins/literals.d.ts +23 -0
  200. package/dist/runtime/core/eval/mixins/literals.d.ts.map +1 -0
  201. package/dist/runtime/core/eval/mixins/literals.js +180 -0
  202. package/dist/runtime/core/eval/mixins/literals.js.map +1 -0
  203. package/dist/runtime/core/eval/mixins/types.d.ts +20 -0
  204. package/dist/runtime/core/eval/mixins/types.d.ts.map +1 -0
  205. package/dist/runtime/core/eval/mixins/types.js +109 -0
  206. package/dist/runtime/core/eval/mixins/types.js.map +1 -0
  207. package/dist/runtime/core/eval/mixins/variables.d.ts +34 -0
  208. package/dist/runtime/core/eval/mixins/variables.d.ts.map +1 -0
  209. package/dist/runtime/core/eval/mixins/variables.js +247 -0
  210. package/dist/runtime/core/eval/mixins/variables.js.map +1 -0
  211. package/dist/runtime/core/eval/types.d.ts +41 -0
  212. package/dist/runtime/core/eval/types.d.ts.map +1 -0
  213. package/dist/runtime/core/eval/types.js +10 -0
  214. package/dist/runtime/core/eval/types.js.map +1 -0
  215. package/dist/runtime/core/evaluate.d.ts +42 -0
  216. package/dist/runtime/core/evaluate.d.ts.map +1 -0
  217. package/dist/runtime/core/evaluate.debug.js +1251 -0
  218. package/dist/runtime/core/evaluate.js +1913 -0
  219. package/dist/runtime/core/evaluate.js.map +1 -0
  220. package/dist/runtime/core/execute.d.ts +26 -0
  221. package/dist/runtime/core/execute.d.ts.map +1 -0
  222. package/dist/runtime/core/execute.js +177 -0
  223. package/dist/runtime/core/execute.js.map +1 -0
  224. package/dist/runtime/core/signals.d.ts +19 -0
  225. package/dist/runtime/core/signals.d.ts.map +1 -0
  226. package/dist/runtime/core/signals.js +26 -0
  227. package/dist/runtime/core/signals.js.map +1 -0
  228. package/dist/runtime/core/types.d.ts +177 -0
  229. package/dist/runtime/core/types.d.ts.map +1 -0
  230. package/dist/runtime/core/types.js +50 -0
  231. package/dist/runtime/core/types.js.map +1 -0
  232. package/dist/runtime/core/values.d.ts +66 -0
  233. package/dist/runtime/core/values.d.ts.map +1 -0
  234. package/dist/runtime/core/values.js +240 -0
  235. package/dist/runtime/core/values.js.map +1 -0
  236. package/dist/runtime/evaluate.d.ts +32 -0
  237. package/dist/runtime/evaluate.d.ts.map +1 -0
  238. package/dist/runtime/evaluate.js +1111 -0
  239. package/dist/runtime/evaluate.js.map +1 -0
  240. package/dist/runtime/execute.d.ts +26 -0
  241. package/dist/runtime/execute.d.ts.map +1 -0
  242. package/dist/runtime/execute.js +121 -0
  243. package/dist/runtime/execute.js.map +1 -0
  244. package/dist/runtime/ext/builtins.d.ts +16 -0
  245. package/dist/runtime/ext/builtins.d.ts.map +1 -0
  246. package/dist/runtime/ext/builtins.js +528 -0
  247. package/dist/runtime/ext/builtins.js.map +1 -0
  248. package/dist/runtime/ext/content-parser.d.ts +83 -0
  249. package/dist/runtime/ext/content-parser.d.ts.map +1 -0
  250. package/dist/runtime/ext/content-parser.js +536 -0
  251. package/dist/runtime/ext/content-parser.js.map +1 -0
  252. package/dist/runtime/index.d.ts +28 -0
  253. package/dist/runtime/index.d.ts.map +1 -0
  254. package/dist/runtime/index.js +34 -0
  255. package/dist/runtime/index.js.map +1 -0
  256. package/dist/runtime/signals.d.ts +19 -0
  257. package/dist/runtime/signals.d.ts.map +1 -0
  258. package/dist/runtime/signals.js +26 -0
  259. package/dist/runtime/signals.js.map +1 -0
  260. package/dist/runtime/types.d.ts +169 -0
  261. package/dist/runtime/types.d.ts.map +1 -0
  262. package/dist/runtime/types.js +50 -0
  263. package/dist/runtime/types.js.map +1 -0
  264. package/dist/runtime/values.d.ts +50 -0
  265. package/dist/runtime/values.d.ts.map +1 -0
  266. package/dist/runtime/values.js +209 -0
  267. package/dist/runtime/values.js.map +1 -0
  268. package/dist/runtime.d.ts +254 -0
  269. package/dist/runtime.d.ts.map +1 -0
  270. package/dist/runtime.js +2014 -0
  271. package/dist/runtime.js.map +1 -0
  272. package/dist/types.d.ts +752 -0
  273. package/dist/types.d.ts.map +1 -0
  274. package/dist/types.js +189 -0
  275. package/dist/types.js.map +1 -0
  276. package/docs/00_INDEX.md +65 -0
  277. package/docs/01_guide.md +390 -0
  278. package/docs/02_types.md +399 -0
  279. package/docs/03_variables.md +314 -0
  280. package/docs/04_operators.md +551 -0
  281. package/docs/05_control-flow.md +350 -0
  282. package/docs/06_closures.md +353 -0
  283. package/docs/07_collections.md +686 -0
  284. package/docs/08_iterators.md +330 -0
  285. package/docs/09_strings.md +205 -0
  286. package/docs/10_parsing.md +366 -0
  287. package/docs/11_reference.md +350 -0
  288. package/docs/12_examples.md +771 -0
  289. package/docs/13_modules.md +519 -0
  290. package/docs/14_host-integration.md +826 -0
  291. package/docs/15_grammar.ebnf +693 -0
  292. package/docs/16_conventions.md +696 -0
  293. package/docs/99_llm-reference.txt +300 -0
  294. package/docs/assets/logo.png +0 -0
  295. package/package.json +70 -0
@@ -0,0 +1,300 @@
1
+ RILL LANGUAGE REFERENCE FOR LLM AGENTS
2
+ =======================================
3
+
4
+ Rill is a pipe-based scripting language. Data flows through pipes (->), not assignment (=).
5
+
6
+ NAMING CONVENTION: snake_case
7
+ -----------------------------
8
+ Use snake_case for all identifiers:
9
+ $user_name, $item_list, $is_valid # variables
10
+ $double_value, $cleanup_text # closures
11
+ [first_name: "x", last_name: "y"] # dict keys
12
+
13
+ SPACING RULES
14
+ -------------
15
+ Operators: space both sides 5 + 3, $x -> .upper, "a" :> $b
16
+ Parentheses: no inner space ($x + 1), ($ > 3) ? "yes"
17
+ Braces: space inside { $x + 1 }, each { $ * 2 }
18
+ Brackets: no inner space $list[0], $dict.items[1]
19
+ Literals: space after , and : [1, 2, 3], [name: "x", age: 30]
20
+ Closures: space after params |x| ($x * 2), |a, b| { $a + $b }
21
+ Methods: no space before . or ( $str.upper(), $list.join(", ")
22
+ Pipes: space both sides "x" -> .upper -> .len
23
+ Continuations: indent 2 spaces $data
24
+ -> .filter { $.active }
25
+ -> map { $.name }
26
+
27
+ IMPLICIT $ SHORTHAND (always prefer)
28
+ ------------------------------------
29
+ $.method() -> .method "x" -> .upper (not $.upper())
30
+ func($) -> func "x" -> log (not log($))
31
+ $fn($) -> $fn 5 -> $double (not $double($))
32
+
33
+ NO THROWAWAY CAPTURES
34
+ ---------------------
35
+ Don't capture just to continue - use line continuation instead:
36
+ # avoid # good
37
+ "x" :> $a "x"
38
+ $a -> .upper :> $b -> .upper
39
+ $b -> .len -> .len
40
+
41
+ Only capture when the variable is reused later in the code.
42
+
43
+ CRITICAL DIFFERENCES FROM MAINSTREAM LANGUAGES
44
+ ----------------------------------------------
45
+
46
+ 1. NO ASSIGNMENT OPERATOR
47
+ Wrong: x = 5
48
+ Right: 5 :> $x
49
+
50
+ Pipe (->): passes value to next operation
51
+ Capture (:>): stores value AND continues chain
52
+ Example: "hello" :> $x -> .upper :> $y # $x="hello", $y="HELLO"
53
+
54
+ 2. NO NULL/UNDEFINED
55
+ Empty values ("", [], [:]) exist. "No value" cannot be represented.
56
+ Use ?? for defaults: $dict.field ?? "default"
57
+ Use .empty to check: $str -> .empty ? "was empty"
58
+
59
+ 3. NO TRUTHINESS
60
+ Conditions MUST be boolean. No implicit coercion.
61
+ Wrong: "" ? "yes" ! "no"
62
+ Right: "" -> .empty ? "yes" ! "no"
63
+ Wrong: 0 ? "yes" ! "no"
64
+ Right: (0 == 0) ? "yes" ! "no"
65
+
66
+ 4. VARIABLES LOCK TO FIRST TYPE
67
+ "hello" :> $x
68
+ 42 :> $x # ERROR: cannot assign number to string variable
69
+
70
+ 5. NO VARIABLE SHADOWING
71
+ Child scopes can READ parent variables but cannot WRITE or redeclare them.
72
+ Variables created inside blocks/loops do NOT leak out.
73
+
74
+ 6. NO EXCEPTIONS
75
+ Errors halt execution. No try/catch. Use conditionals for error handling.
76
+ Script-level exit functions (error, stop) must be host-provided.
77
+
78
+ SYNTAX QUICK REFERENCE
79
+ ----------------------
80
+
81
+ Variables: $name (always prefixed with $)
82
+ Strings: "hello {$var}" # interpolation with {}
83
+ <<EOF ... EOF # heredoc (also interpolates)
84
+ Numbers: 42, 3.14, -7
85
+ Booleans: true, false
86
+ Lists: [1, 2, 3]
87
+ Dicts: [name: "alice", age: 30]
88
+ Tuples: *[1, 2, 3] # for argument unpacking
89
+ Closures: |x|($x + 1) # like lambda/arrow functions
90
+ Comments: # single line only
91
+
92
+ PIPES AND $ BINDING
93
+ -------------------
94
+
95
+ $ is the current piped value. Its meaning depends on context:
96
+
97
+ | Context | $ contains |
98
+ |----------------------------|-------------------------|
99
+ | -> { body } | piped value |
100
+ | -> each { } | current item |
101
+ | (cond) @ { } | accumulated value |
102
+ | @ { } ? cond | accumulated value |
103
+ | cond ? { } ! { } | tested value |
104
+ | -> ? { } ! { } | piped value |
105
+ | ||{ $.field } in dict | the containing dict |
106
+ | |x|{ } stored closure | N/A - use parameters |
107
+
108
+ Implied $: bare .method() means $ -> .method()
109
+ Example: "hello" -> .upper # same as "hello" -> $.upper()
110
+
111
+ CONTROL FLOW
112
+ ------------
113
+
114
+ Conditional (if-else):
115
+ cond ? then_expr ! else_expr
116
+ cond ? then_expr # else returns ""
117
+
118
+ Piped conditional ($ becomes condition):
119
+ value -> ? then_expr ! else_expr
120
+
121
+ While loop:
122
+ init_value -> ($ < 10) @ { $ + 1 } # $ is accumulator
123
+
124
+ Do-while loop (body runs at least once):
125
+ init_value -> @ { $ + 1 } ? ($ < 10)
126
+
127
+ Break (exits loop, returns collected results before break):
128
+ [1,2,3,4,5] -> each { ($ == 3) ? break; $ } # returns [1, 2]
129
+
130
+ Return (exits block or script with value):
131
+ { 5 :> $x; ($x > 3) ? ("big" -> return); "small" } # returns "big"
132
+ "done" -> return # exits script with "done"
133
+
134
+ COLLECTION OPERATORS
135
+ --------------------
136
+
137
+ | Operator | Execution | Returns | Break? |
138
+ |--------------------|------------|----------------------|--------|
139
+ | -> each { } | sequential | all body results | yes |
140
+ | -> each(i) { $@+$} | sequential | all with accumulator | yes |
141
+ | -> map { } | parallel | all body results | NO |
142
+ | -> filter { } | parallel | matching elements | NO |
143
+ | -> fold(i) { $@+$} | sequential | final result only | yes |
144
+
145
+ $@ is the accumulator in each(init) and fold(init).
146
+
147
+ Method shorthand in collection operators:
148
+ ["a", "b"] -> map .upper # ["A", "B"]
149
+ ["", "x"] -> filter (!.empty) # ["x"]
150
+
151
+ CLOSURES
152
+ --------
153
+
154
+ Definition:
155
+ |x|($x + 1) :> $inc # single param
156
+ |a, b|($a + $b) :> $add # multiple params
157
+ |x = 0|($x + 1) :> $inc_or_one # default value
158
+ |x: number|($x + 1) :> $typed # type annotation
159
+
160
+ Invocation:
161
+ $inc(5) # direct call: 6
162
+ 5 -> $inc() # piped call: 6
163
+ [1,2,3] -> map $inc # in collection op
164
+
165
+ LATE BINDING: closures capture scope, not values. Variables resolve at call time.
166
+
167
+ Dict closures (methods):
168
+ [count: 3, double: ||{ $.count * 2 }] :> $obj
169
+ $obj.double # 6 ($ is bound to dict)
170
+
171
+ PROPERTY ACCESS
172
+ ---------------
173
+
174
+ $data.field # dict field
175
+ $data[0], $data[-1] # list index (negative from end)
176
+ $data.$key # variable as key
177
+ $data.($i + 1) # computed key
178
+ $data.(a || b) # try keys left-to-right
179
+ $data.field ?? "default" # default if missing
180
+ $data.?field # existence check (boolean)
181
+ $data.?field&string # existence AND type check
182
+
183
+ TYPE OPERATIONS
184
+ ---------------
185
+
186
+ :type - assert type (error if wrong): 42:number passes; "x":number errors
187
+ :?type - check type (boolean): 42:?number is true; "x":?number is false
188
+
189
+ Types: string, number, boolean, list, dict, tuple, closure
190
+
191
+ EXTRACTION OPERATORS
192
+ --------------------
193
+
194
+ Destructure (*<>):
195
+ [1, 2, 3] -> *<$a, $b, $c> # $a=1, $b=2, $c=3
196
+ [x: 1, y: 2] -> *<x: $a, y: $b> # $a=1, $b=2
197
+ [1, 2, 3] -> *<$first, _, $third> # _ skips element
198
+
199
+ Slice (/<start:stop:step>):
200
+ [0,1,2,3,4] -> /<1:3> # [1, 2]
201
+ [0,1,2,3,4] -> /<-2:> # [3, 4]
202
+ [0,1,2,3,4] -> /<::-1> # [4,3,2,1,0] (reverse)
203
+ "hello" -> /<1:4> # "ell"
204
+
205
+ TUPLES FOR ARGUMENT UNPACKING
206
+ -----------------------------
207
+
208
+ *[1, 2, 3] -> $fn() # positional: $fn(1, 2, 3)
209
+ *[b: 2, a: 1] -> $fn() # named: $fn(a=1, b=2)
210
+
211
+ SPREAD OPERATOR (@)
212
+ -------------------
213
+
214
+ Chains closures sequentially:
215
+ 5 -> @[$inc, $double, $add10] # (5+1)*2+10 = 22
216
+
217
+ STRING METHODS
218
+ --------------
219
+
220
+ .len length
221
+ .empty is empty string
222
+ .trim remove whitespace
223
+ .upper uppercase
224
+ .lower lowercase
225
+ .split(sep) split into list
226
+ .lines split on newlines
227
+ .join(sep) join list with separator (on list)
228
+ .contains(s) substring check
229
+ .starts_with(s) prefix check
230
+ .ends_with(s) suffix check
231
+ .replace(p,r) replace first match
232
+ .replace_all(p,r) replace all matches
233
+ .match(regex) first match info (dict with matched, index, groups)
234
+ .is_match(regex) boolean regex check
235
+ .head first character
236
+ .tail last character
237
+ .at(i) character at index
238
+
239
+ LIST/DICT METHODS
240
+ -----------------
241
+
242
+ .len length
243
+ .empty is empty
244
+ .head first element
245
+ .tail last element
246
+ .at(i) element at index
247
+ .keys dict keys as list
248
+ .values dict values as list
249
+ .entries dict as list of [key: k, value: v]
250
+
251
+ PARSING FUNCTIONS (for LLM output)
252
+ ----------------------------------
253
+
254
+ parse_auto(str) auto-detect format
255
+ parse_json(str) parse JSON (repairs common errors)
256
+ parse_xml(str, tag?) extract XML tag content
257
+ parse_fence(str, lang?) extract fenced code block
258
+ parse_fences(str) all fenced blocks as list
259
+ parse_frontmatter(str) parse --- delimited YAML + body
260
+ parse_checklist(str) parse markdown task lists
261
+
262
+ GLOBAL FUNCTIONS
263
+ ----------------
264
+
265
+ type(val) returns type name
266
+ log(val) print and pass through
267
+ json(val) convert to JSON string
268
+ identity(val) returns input unchanged
269
+ range(start, end, step?) number sequence
270
+ repeat(val, count) repeat value n times
271
+ enumerate(coll) add index to elements
272
+
273
+ ITERATION LIMITS
274
+ ----------------
275
+
276
+ Default: 10,000 iterations max for loops.
277
+ Override: ^(limit: N) statement
278
+
279
+ Example:
280
+ ^(limit: 100) 0 -> ($ < 50) @ { $ + 1 }
281
+
282
+ COMMON MISTAKES
283
+ ---------------
284
+
285
+ 1. Using = for assignment -> use :> instead
286
+ 2. Using || for defaults -> use ?? instead
287
+ 3. Assuming truthiness -> explicit boolean checks required
288
+ 4. Breaking from map/filter -> only works in each/fold
289
+ 5. Expecting variable shadowing -> not allowed
290
+ 6. Expecting variables to leak -> block scope is strict
291
+ 7. Forgetting () on methods -> .upper() not .upper (unless property)
292
+ 8. Reassigning different type -> variables lock to first type
293
+
294
+ SCRIPT RETURN VALUES
295
+ --------------------
296
+
297
+ true / non-empty string -> exit code 0
298
+ false / empty string -> exit code 1
299
+ [0, "message"] -> exit code 0 with message
300
+ [1, "message"] -> exit code 1 with message
Binary file
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@rcrsr/rill",
3
+ "version": "0.1.0",
4
+ "description": "Rill - An embeddable scripting language for orchestrating LLM workflows",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "docs"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/rcrsr/rill.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/rcrsr/rill/issues"
24
+ },
25
+ "homepage": "https://github.com/rcrsr/rill#readme",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc",
31
+ "build:watch": "tsc --watch",
32
+ "typecheck": "tsc --noEmit",
33
+ "test": "vitest run",
34
+ "test:watch": "vitest",
35
+ "test:coverage": "vitest run --coverage",
36
+ "lint": "eslint src/",
37
+ "lint:fix": "eslint src/ --fix",
38
+ "format": "prettier --write src/",
39
+ "format:check": "prettier --check src/",
40
+ "clean": "rm -rf dist",
41
+ "rill": "npx tsx src/cli.ts",
42
+ "test:examples": "npx tsx scripts/test-examples.ts docs/",
43
+ "check": "npm run test:examples && npm run format:check && npm run lint && npm run typecheck && npm run test"
44
+ },
45
+ "keywords": [
46
+ "rill",
47
+ "scripting",
48
+ "dsl",
49
+ "pipe",
50
+ "workflow",
51
+ "parser",
52
+ "interpreter"
53
+ ],
54
+ "author": "Andre Bremer",
55
+ "license": "MIT",
56
+ "engines": {
57
+ "node": ">=18.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "@eslint/js": "^9.39.2",
61
+ "@types/node": "^25.0.10",
62
+ "@typescript-eslint/eslint-plugin": "^8.53.1",
63
+ "@typescript-eslint/parser": "^8.53.1",
64
+ "eslint": "^9.39.2",
65
+ "globals": "^17.0.0",
66
+ "prettier": "^3.8.1",
67
+ "typescript": "^5.9.3",
68
+ "vitest": "^4.0.17"
69
+ }
70
+ }