kumi 0.0.26 → 0.0.28
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/CLAUDE.md +4 -0
- data/README.md +36 -12
- data/data/functions/core/arithmetic.yaml +28 -8
- data/data/functions/core/boolean.yaml +8 -3
- data/data/functions/core/comparison.yaml +12 -4
- data/data/functions/core/conversion.yaml +32 -0
- data/data/kernels/javascript/core/arithmetic.yaml +6 -2
- data/data/kernels/javascript/core/coercion.yaml +20 -0
- data/data/kernels/ruby/core/arithmetic.yaml +7 -2
- data/data/kernels/ruby/core/coercion.yaml +20 -0
- data/docs/ARCHITECTURE.md +277 -0
- data/docs/DEVELOPMENT.md +62 -0
- data/docs/FUNCTIONS.md +955 -0
- data/docs/SYNTAX.md +8 -0
- data/docs/VSCODE_EXTENSION.md +114 -0
- data/docs/functions-reference.json +1821 -0
- data/golden/array_element/expected/schema_ruby.rb +1 -1
- data/golden/array_index/expected/lir_00_unoptimized.txt +2 -2
- data/golden/array_index/expected/lir_01_hoist_scalar_references.txt +2 -2
- data/golden/array_index/expected/lir_02_inlined.txt +2 -2
- data/golden/array_index/expected/lir_03_cse.txt +2 -2
- data/golden/array_index/expected/lir_04_1_loop_fusion.txt +2 -2
- data/golden/array_index/expected/lir_04_loop_invcm.txt +2 -2
- data/golden/array_index/expected/lir_06_const_prop.txt +2 -2
- data/golden/array_index/expected/schema_ruby.rb +1 -1
- data/golden/array_index/expected/snast.txt +2 -2
- data/golden/array_operations/expected/lir_00_unoptimized.txt +2 -2
- data/golden/array_operations/expected/lir_01_hoist_scalar_references.txt +2 -2
- data/golden/array_operations/expected/lir_02_inlined.txt +2 -2
- data/golden/array_operations/expected/lir_03_cse.txt +2 -2
- data/golden/array_operations/expected/lir_04_1_loop_fusion.txt +2 -2
- data/golden/array_operations/expected/lir_04_loop_invcm.txt +2 -2
- data/golden/array_operations/expected/lir_06_const_prop.txt +2 -2
- data/golden/array_operations/expected/schema_ruby.rb +1 -1
- data/golden/array_operations/expected/snast.txt +2 -2
- data/golden/cascade_logic/expected/schema_ruby.rb +1 -1
- data/golden/chained_fusion/expected/schema_ruby.rb +1 -1
- data/golden/decimal_explicit/expected/ast.txt +38 -0
- data/golden/decimal_explicit/expected/input_plan.txt +3 -0
- data/golden/decimal_explicit/expected/lir_00_unoptimized.txt +30 -0
- data/golden/decimal_explicit/expected/lir_01_hoist_scalar_references.txt +30 -0
- data/golden/decimal_explicit/expected/lir_02_inlined.txt +44 -0
- data/golden/decimal_explicit/expected/lir_03_cse.txt +40 -0
- data/golden/decimal_explicit/expected/lir_04_1_loop_fusion.txt +40 -0
- data/golden/decimal_explicit/expected/lir_04_loop_invcm.txt +40 -0
- data/golden/decimal_explicit/expected/lir_06_const_prop.txt +40 -0
- data/golden/decimal_explicit/expected/nast.txt +30 -0
- data/golden/decimal_explicit/expected/schema_javascript.mjs +31 -0
- data/golden/decimal_explicit/expected/schema_ruby.rb +57 -0
- data/golden/decimal_explicit/expected/snast.txt +30 -0
- data/golden/decimal_explicit/expected.json +1 -0
- data/golden/decimal_explicit/input.json +5 -0
- data/golden/decimal_explicit/schema.kumi +14 -0
- data/golden/element_arrays/expected/schema_ruby.rb +1 -1
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +1 -1
- data/golden/function_overload/expected/schema_ruby.rb +1 -1
- data/golden/game_of_life/expected/schema_ruby.rb +1 -1
- data/golden/hash_keys/expected/schema_ruby.rb +1 -1
- data/golden/hash_value/expected/schema_ruby.rb +1 -1
- data/golden/hierarchical_complex/expected/lir_00_unoptimized.txt +3 -3
- data/golden/hierarchical_complex/expected/lir_01_hoist_scalar_references.txt +3 -3
- data/golden/hierarchical_complex/expected/lir_02_inlined.txt +3 -3
- data/golden/hierarchical_complex/expected/lir_03_cse.txt +3 -3
- data/golden/hierarchical_complex/expected/lir_04_1_loop_fusion.txt +3 -3
- data/golden/hierarchical_complex/expected/lir_04_loop_invcm.txt +3 -3
- data/golden/hierarchical_complex/expected/lir_06_const_prop.txt +3 -3
- data/golden/hierarchical_complex/expected/schema_ruby.rb +1 -1
- data/golden/hierarchical_complex/expected/snast.txt +3 -3
- data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +1 -1
- data/golden/input_reference/expected/schema_ruby.rb +1 -1
- data/golden/interleaved_fusion/expected/lir_00_unoptimized.txt +1 -1
- data/golden/interleaved_fusion/expected/lir_01_hoist_scalar_references.txt +1 -1
- data/golden/interleaved_fusion/expected/lir_02_inlined.txt +2 -2
- data/golden/interleaved_fusion/expected/lir_03_cse.txt +2 -2
- data/golden/interleaved_fusion/expected/lir_04_1_loop_fusion.txt +2 -2
- data/golden/interleaved_fusion/expected/lir_04_loop_invcm.txt +2 -2
- data/golden/interleaved_fusion/expected/lir_06_const_prop.txt +2 -2
- data/golden/interleaved_fusion/expected/schema_ruby.rb +1 -1
- data/golden/interleaved_fusion/expected/snast.txt +1 -1
- data/golden/let_inline/expected/lir_00_unoptimized.txt +2 -2
- data/golden/let_inline/expected/lir_01_hoist_scalar_references.txt +2 -2
- data/golden/let_inline/expected/lir_02_inlined.txt +6 -6
- data/golden/let_inline/expected/lir_03_cse.txt +6 -6
- data/golden/let_inline/expected/lir_04_1_loop_fusion.txt +6 -6
- data/golden/let_inline/expected/lir_04_loop_invcm.txt +6 -6
- data/golden/let_inline/expected/lir_06_const_prop.txt +6 -6
- data/golden/let_inline/expected/schema_ruby.rb +1 -1
- data/golden/let_inline/expected/snast.txt +2 -2
- data/golden/loop_fusion/expected/schema_ruby.rb +1 -1
- data/golden/min_reduce_scope/expected/schema_ruby.rb +1 -1
- data/golden/mixed_dimensions/expected/schema_ruby.rb +1 -1
- data/golden/multirank_hoisting/expected/lir_00_unoptimized.txt +2 -2
- data/golden/multirank_hoisting/expected/lir_01_hoist_scalar_references.txt +2 -2
- data/golden/multirank_hoisting/expected/lir_02_inlined.txt +7 -7
- data/golden/multirank_hoisting/expected/lir_03_cse.txt +7 -7
- data/golden/multirank_hoisting/expected/lir_04_1_loop_fusion.txt +7 -7
- data/golden/multirank_hoisting/expected/lir_04_loop_invcm.txt +7 -7
- data/golden/multirank_hoisting/expected/lir_06_const_prop.txt +7 -7
- data/golden/multirank_hoisting/expected/schema_ruby.rb +1 -1
- data/golden/multirank_hoisting/expected/snast.txt +2 -2
- data/golden/nested_hash/expected/lir_00_unoptimized.txt +1 -1
- data/golden/nested_hash/expected/lir_01_hoist_scalar_references.txt +1 -1
- data/golden/nested_hash/expected/lir_02_inlined.txt +1 -1
- data/golden/nested_hash/expected/lir_03_cse.txt +1 -1
- data/golden/nested_hash/expected/lir_04_1_loop_fusion.txt +1 -1
- data/golden/nested_hash/expected/lir_04_loop_invcm.txt +1 -1
- data/golden/nested_hash/expected/lir_06_const_prop.txt +1 -1
- data/golden/nested_hash/expected/schema_ruby.rb +1 -1
- data/golden/nested_hash/expected/snast.txt +1 -1
- data/golden/reduction_broadcast/expected/schema_ruby.rb +1 -1
- data/golden/roll/expected/schema_ruby.rb +1 -1
- data/golden/shift/expected/schema_ruby.rb +1 -1
- data/golden/shift_2d/expected/schema_ruby.rb +1 -1
- data/golden/simple_math/expected/lir_00_unoptimized.txt +2 -2
- data/golden/simple_math/expected/lir_01_hoist_scalar_references.txt +2 -2
- data/golden/simple_math/expected/lir_02_inlined.txt +2 -2
- data/golden/simple_math/expected/lir_03_cse.txt +2 -2
- data/golden/simple_math/expected/lir_04_1_loop_fusion.txt +2 -2
- data/golden/simple_math/expected/lir_04_loop_invcm.txt +2 -2
- data/golden/simple_math/expected/lir_06_const_prop.txt +2 -2
- data/golden/simple_math/expected/schema_ruby.rb +1 -1
- data/golden/simple_math/expected/snast.txt +2 -2
- data/golden/streaming_basics/expected/lir_00_unoptimized.txt +3 -3
- data/golden/streaming_basics/expected/lir_01_hoist_scalar_references.txt +3 -3
- data/golden/streaming_basics/expected/lir_02_inlined.txt +9 -9
- data/golden/streaming_basics/expected/lir_03_cse.txt +7 -7
- data/golden/streaming_basics/expected/lir_04_1_loop_fusion.txt +7 -7
- data/golden/streaming_basics/expected/lir_04_loop_invcm.txt +7 -7
- data/golden/streaming_basics/expected/lir_06_const_prop.txt +7 -7
- data/golden/streaming_basics/expected/schema_ruby.rb +1 -1
- data/golden/streaming_basics/expected/snast.txt +3 -3
- data/golden/tuples/expected/schema_ruby.rb +1 -1
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +1 -1
- data/golden/us_tax_2024/expected/lir_00_unoptimized.txt +6 -6
- data/golden/us_tax_2024/expected/lir_01_hoist_scalar_references.txt +6 -6
- data/golden/us_tax_2024/expected/lir_02_inlined.txt +71 -71
- data/golden/us_tax_2024/expected/lir_03_cse.txt +43 -43
- data/golden/us_tax_2024/expected/lir_04_1_loop_fusion.txt +48 -48
- data/golden/us_tax_2024/expected/lir_04_loop_invcm.txt +43 -43
- data/golden/us_tax_2024/expected/lir_06_const_prop.txt +43 -43
- data/golden/us_tax_2024/expected/schema_ruby.rb +1 -1
- data/golden/us_tax_2024/expected/snast.txt +6 -6
- data/golden/with_constants/expected/schema_ruby.rb +1 -1
- data/lib/kumi/configuration.rb +6 -0
- data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +1 -1
- data/lib/kumi/core/error_reporter.rb +1 -1
- data/lib/kumi/core/errors.rb +1 -1
- data/lib/kumi/core/functions/overload_resolver.rb +57 -11
- data/lib/kumi/core/functions/type_categories.rb +44 -0
- data/lib/kumi/core/input/type_matcher.rb +8 -1
- data/lib/kumi/core/ruby_parser/input_builder.rb +2 -2
- data/lib/kumi/core/types/normalizer.rb +1 -0
- data/lib/kumi/core/types/validator.rb +2 -2
- data/lib/kumi/core/types.rb +2 -2
- data/lib/kumi/dev/golden/reporter.rb +9 -0
- data/lib/kumi/dev/golden/result.rb +3 -1
- data/lib/kumi/dev/golden/runtime_test.rb +25 -0
- data/lib/kumi/dev/golden/suite.rb +4 -4
- data/lib/kumi/dev/golden/value_normalizer.rb +80 -0
- data/lib/kumi/dev/golden.rb +21 -12
- data/lib/kumi/doc_generator/formatters/json.rb +39 -0
- data/lib/kumi/doc_generator/formatters/markdown.rb +175 -0
- data/lib/kumi/doc_generator/loader.rb +37 -0
- data/lib/kumi/doc_generator/merger.rb +54 -0
- data/lib/kumi/doc_generator.rb +4 -0
- data/lib/kumi/frontends/text.rb +33 -5
- data/lib/kumi/syntax/location.rb +5 -1
- data/lib/kumi/version.rb +1 -1
- data/vscode-extension/.gitignore +4 -0
- data/vscode-extension/README.md +59 -0
- data/vscode-extension/TESTING.md +151 -0
- data/vscode-extension/package.json +51 -0
- data/vscode-extension/src/extension.ts +295 -0
- data/vscode-extension/tsconfig.json +15 -0
- metadata +38 -1
data/docs/SYNTAX.md
CHANGED
@@ -17,6 +17,7 @@ end
|
|
17
17
|
```kumi
|
18
18
|
integer # Integer numbers
|
19
19
|
float # Floating point numbers
|
20
|
+
decimal # Precise decimal numbers (money, bignum calculations)
|
20
21
|
string # Text strings
|
21
22
|
array # Sequential collections
|
22
23
|
hash # Structured objects
|
@@ -58,6 +59,12 @@ trait :name, expr # Boolean mask
|
|
58
59
|
- `fn(:abs, x)` — Absolute value
|
59
60
|
- `fn(:clamp, x, lo, hi)` — Clamp to range
|
60
61
|
|
62
|
+
**Type Conversion:**
|
63
|
+
- `fn(:to_decimal, x)` — Convert to decimal
|
64
|
+
- `fn(:to_integer, x)` — Convert to integer
|
65
|
+
- `fn(:to_float, x)` — Convert to float
|
66
|
+
- `fn(:to_string, x)` — Convert to string
|
67
|
+
|
61
68
|
**String:**
|
62
69
|
- `fn(:concat, s1, s2)` — Concatenate strings
|
63
70
|
- `fn(:upcase, str)` — Convert to uppercase
|
@@ -140,6 +147,7 @@ Scalar inputs represent single values:
|
|
140
147
|
input do
|
141
148
|
integer :x
|
142
149
|
float :rate
|
150
|
+
decimal :price # Precise decimal for money calculations
|
143
151
|
string :name
|
144
152
|
end
|
145
153
|
```
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# VSCode Extension for Kumi
|
2
|
+
|
3
|
+
The `vscode-extension/` directory contains a VSCode extension that provides IDE support for Kumi functions using the auto-generated function reference.
|
4
|
+
|
5
|
+
## What It Does
|
6
|
+
|
7
|
+
- **Autocomplete** - Suggest function names when typing `fn(:`
|
8
|
+
- **Hover Documentation** - Show function signatures, parameters, and types
|
9
|
+
- **Type Information** - Display type inference rules for each function
|
10
|
+
- **Arity Display** - Show parameter counts at a glance
|
11
|
+
|
12
|
+
## Setup
|
13
|
+
|
14
|
+
### 1. Build the Extension
|
15
|
+
|
16
|
+
```bash
|
17
|
+
cd vscode-extension
|
18
|
+
npm install
|
19
|
+
npm run compile
|
20
|
+
```
|
21
|
+
|
22
|
+
This generates JavaScript in `out/extension.js` from the TypeScript sources.
|
23
|
+
|
24
|
+
### 2. Install in VSCode
|
25
|
+
|
26
|
+
**Option A: Load as Development Extension**
|
27
|
+
|
28
|
+
- Open the `vscode-extension` folder in VSCode
|
29
|
+
- Press `F5` to launch a debugging session
|
30
|
+
- The extension will activate automatically
|
31
|
+
|
32
|
+
**Option B: Package as VSIX**
|
33
|
+
|
34
|
+
```bash
|
35
|
+
npm install -g vsce
|
36
|
+
vsce package
|
37
|
+
```
|
38
|
+
|
39
|
+
Then install the generated `.vsix` file in VSCode via "Extensions: Install from VSIX"
|
40
|
+
|
41
|
+
### 3. Generate Function Data
|
42
|
+
|
43
|
+
Before using the extension, ensure the function reference JSON is up-to-date:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
bin/kumi-doc-gen
|
47
|
+
```
|
48
|
+
|
49
|
+
This creates `docs/functions-reference.json` which the extension reads.
|
50
|
+
|
51
|
+
## Usage in VSCode
|
52
|
+
|
53
|
+
When editing Ruby files in a Kumi project:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# Start typing fn(: to get suggestions
|
57
|
+
fn(:add, x, y) # ← Autocomplete shows available functions
|
58
|
+
↑
|
59
|
+
# Hover to see: core.add (arity: 2, type: promoted from left_operand, right_operand)
|
60
|
+
|
61
|
+
# Completions include:
|
62
|
+
# - add, sub, mul, div, pow (arithmetic)
|
63
|
+
# - sum, count, min, max, mean (aggregations)
|
64
|
+
# - ... and all other functions
|
65
|
+
```
|
66
|
+
|
67
|
+
The extension provides:
|
68
|
+
- Full function name with backticks for easy identification
|
69
|
+
- Arity (parameter count)
|
70
|
+
- Type inference rules
|
71
|
+
- Parameter names
|
72
|
+
- Available kernel implementations
|
73
|
+
|
74
|
+
## Data Flow
|
75
|
+
|
76
|
+
```
|
77
|
+
data/functions/ (YAML)
|
78
|
+
↓
|
79
|
+
bin/kumi-doc-gen
|
80
|
+
↓
|
81
|
+
docs/functions-reference.json
|
82
|
+
↓
|
83
|
+
vscode-extension/src/extension.ts
|
84
|
+
↓
|
85
|
+
VSCode IDE features (autocomplete, hover, etc.)
|
86
|
+
```
|
87
|
+
|
88
|
+
## Development
|
89
|
+
|
90
|
+
To modify the extension:
|
91
|
+
|
92
|
+
1. Edit `vscode-extension/src/extension.ts`
|
93
|
+
2. Run `npm run watch` to auto-compile TypeScript
|
94
|
+
3. Press `F5` in VSCode to reload the debugging session
|
95
|
+
4. Test new features against the live extension
|
96
|
+
|
97
|
+
## Limitations
|
98
|
+
|
99
|
+
Currently the extension:
|
100
|
+
- Only provides autocomplete after `fn(:`
|
101
|
+
- Only works with Ruby files
|
102
|
+
- Doesn't validate argument types at compile time
|
103
|
+
- Doesn't provide inline hints during parameter entry
|
104
|
+
|
105
|
+
These could be added as future enhancements!
|
106
|
+
|
107
|
+
## Future Enhancements
|
108
|
+
|
109
|
+
- Parameter validation (type checking)
|
110
|
+
- Signature help (inline parameter hints)
|
111
|
+
- Go-to-definition for function implementations
|
112
|
+
- Diagnostics for arity mismatches
|
113
|
+
- Snippet expansion for common patterns
|
114
|
+
- LSP server for language-agnostic support
|