aethershell 0.3.1

The world's first multi-agent shell with typed functional pipelines and multi-modal AI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# ============================================
# COMPREHENSIVE SYNTAX COVERAGE TEST
# Tests ALL AST constructs from src/ast.rs
# ============================================

print("=== COMPREHENSIVE SYNTAX COVERAGE ===\n")

# ============================================
# SECTION 1: LITERALS (Expr variants)
# ============================================
print("SECTION 1: LITERALS\n")

# 1.1 LitInt - Integer literals
print("1.1 Integer Literals...")
int_pos = 42
int_zero = 0
int_neg = -17
int_large = 9999999
match type_of(int_pos) == "Int" && type_of(int_neg) == "Int" {
    true => print("  ✓ Integer literals work"),
    false => print("  ✗ FAILED: Integer literals")
}

# 1.2 LitFloat - Float literals
print("1.2 Float Literals...")
float_simple = 3.14
float_small = 0.001
float_neg = -2.5
match type_of(float_simple) == "Float" {
    true => print("  ✓ Float literals work"),
    false => print("  ✗ FAILED: Float literals")
}

# 1.3 LitStr - String literals
print("1.3 String Literals...")
str_simple = "hello"
str_empty = ""
str_spaces = "hello world"
str_special = "tab\there"
match type_of(str_simple) == "String" && len(str_empty) == 0 {
    true => print("  ✓ String literals work"),
    false => print("  ✗ FAILED: String literals")
}

# 1.4 String interpolation
print("1.4 String Interpolation...")
name = "world"
interpolated = "hello ${name}!"
match contains(interpolated, "world") {
    true => print("  ✓ String interpolation works"),
    false => print("  ✗ FAILED: String interpolation")
}

# 1.5 LitBool - Boolean literals
print("1.5 Boolean Literals...")
bool_true = true
bool_false = false
match type_of(bool_true) == "Bool" && bool_true == true && bool_false == false {
    true => print("  ✓ Boolean literals work"),
    false => print("  ✗ FAILED: Boolean literals")
}

# 1.6 Null literal
print("1.6 Null Literal...")
null_val = null
match type_of(null_val) == "Null" {
    true => print("  ✓ Null literal works"),
    false => print("  ✗ FAILED: Null literal")
}

# ============================================
# SECTION 2: COLLECTIONS
# ============================================
print("\nSECTION 2: COLLECTIONS\n")

# 2.1 Array - Array literals
print("2.1 Array Literals...")
arr_nums = [1, 2, 3, 4, 5]
arr_mixed = [1, "two", true, null]
arr_empty = []
arr_nested = [[1, 2], [3, 4]]
match type_of(arr_nums) == "Array" && len(arr_nums) == 5 && len(arr_empty) == 0 {
    true => print("  ✓ Array literals work"),
    false => print("  ✗ FAILED: Array literals")
}

# 2.2 Record - Record literals
print("2.2 Record Literals...")
rec_simple = {name: "Alice", age: 30}
rec_nested = {user: {name: "Bob"}, active: true}
rec_empty = {}
match type_of(rec_simple) == "Record" && len(keys(rec_simple)) == 2 {
    true => print("  ✓ Record literals work"),
    false => print("  ✗ FAILED: Record literals")
}

# 2.3 Record field access (MemberAccess)
print("2.3 Member Access...")
person = {name: "Alice", age: 30}
name_val = person.name
age_val = person.age
match name_val == "Alice" && age_val == 30 {
    true => print("  ✓ Member access works"),
    false => print("  ✗ FAILED: Member access")
}

# ============================================
# SECTION 3: VARIABLES
# ============================================
print("\nSECTION 3: VARIABLES\n")

# 3.1 Let binding (immutable)
print("3.1 Let Bindings...")
let x = 42
match x == 42 {
    true => print("  ✓ Let binding works"),
    false => print("  ✗ FAILED: Let binding")
}

# 3.2 Let mut binding (mutable)
print("3.2 Mutable Bindings...")
let mut counter = 0
counter = counter + 1
counter = counter + 1
match counter == 2 {
    true => print("  ✓ Mutable binding works"),
    false => print("  ✗ FAILED: Mutable binding")
}

# 3.3 Ident - Variable reference
print("3.3 Variable Reference...")
val1 = 10
val2 = val1
val3 = val1 + val2
match val3 == 20 {
    true => print("  ✓ Variable reference works"),
    false => print("  ✗ FAILED: Variable reference")
}

# ============================================
# SECTION 4: OPERATORS (BinOp)
# ============================================
print("\nSECTION 4: OPERATORS\n")

# 4.1 Arithmetic operators
print("4.1 Arithmetic Operators...")
add = 10 + 5
sub = 10 - 5
mul = 10 * 5
div = 10 / 5
match add == 15 && sub == 5 && mul == 50 && div == 2 {
    true => print("  ✓ Basic arithmetic works (+, -, *, /)"),
    false => print("  ✗ FAILED: Basic arithmetic")
}

# 4.2 Modulo and Power
print("4.2 Modulo and Power...")
rem = 17 % 5
pow_result = pow(2, 3)
match rem == 2 && pow_result == 8 {
    true => print("  ✓ Modulo and power work (%, **)"),
    false => print("  ✗ FAILED: Modulo/power")
}

# 4.3 Comparison operators
print("4.3 Comparison Operators...")
eq = 5 == 5
ne = 5 != 3
lt = 3 < 5
lte = 5 <= 5
gt = 10 > 5
gte = 5 >= 5
match eq && ne && lt && lte && gt && gte {
    true => print("  ✓ Comparison operators work (==, !=, <, <=, >, >=)"),
    false => print("  ✗ FAILED: Comparison operators")
}

# 4.4 Logical operators
print("4.4 Logical Operators...")
and_result = true && true
or_result = false || true
not_result = !false
match and_result && or_result && not_result {
    true => print("  ✓ Logical operators work (&&, ||, !)"),
    false => print("  ✗ FAILED: Logical operators")
}

# 4.5 String concatenation
print("4.5 String Concatenation...")
concat = "hello" + " " + "world"
match concat == "hello world" {
    true => print("  ✓ String concatenation works"),
    false => print("  ✗ FAILED: String concatenation")
}

# ============================================
# SECTION 5: UNARY OPERATORS (UnOp)
# ============================================
print("\nSECTION 5: UNARY OPERATORS\n")

# 5.1 Negation
print("5.1 Numeric Negation...")
neg = -42
double_neg = --42
match neg == -42 && double_neg == 42 {
    true => print("  ✓ Numeric negation works"),
    false => print("  ✗ FAILED: Numeric negation")
}

# 5.2 Logical NOT
print("5.2 Logical NOT...")
not1 = !true
not2 = !false
not3 = !!true
match not1 == false && not2 == true && not3 == true {
    true => print("  ✓ Logical NOT works"),
    false => print("  ✗ FAILED: Logical NOT")
}

# ============================================
# SECTION 6: LAMBDAS
# ============================================
print("\nSECTION 6: LAMBDAS\n")

# 6.1 Single parameter lambda
print("6.1 Single Parameter Lambda...")
double = fn(x) => x * 2
match double(21) == 42 {
    true => print("  ✓ Single parameter lambda works"),
    false => print("  ✗ FAILED: Single parameter lambda")
}

# 6.2 Multi-parameter lambda
print("6.2 Multi-Parameter Lambda...")
add_fn = fn(a, b) => a + b
match add_fn(10, 20) == 30 {
    true => print("  ✓ Multi-parameter lambda works"),
    false => print("  ✗ FAILED: Multi-parameter lambda")
}

# 6.3 Zero parameter lambda (AetherShell requires at least one param)
print("6.3 Thunk-style Lambda...")
constant = fn(_) => 42
match constant(null) == 42 {
    true => print("  ✓ Thunk-style lambda works"),
    false => print("  ✗ FAILED: Thunk-style lambda")
}

# 6.4 Lambda as value
print("6.4 Lambda as Value...")
identity = fn(x) => x
match type_of(identity) == "Lambda" {
    true => print("  ✓ Lambda as value works"),
    false => print("  ✗ FAILED: Lambda as value")
}

# 6.5 Higher-order functions
print("6.5 Higher-Order Functions...")
apply_twice = fn(f, x) => f(f(x))
result = apply_twice(fn(x) => x + 1, 0)
match result == 2 {
    true => print("  ✓ Higher-order functions work"),
    false => print("  ✗ FAILED: Higher-order functions")
}

# ============================================
# SECTION 7: FUNCTION CALLS
# ============================================
print("\nSECTION 7: FUNCTION CALLS\n")

# 7.1 Builtin calls
print("7.1 Builtin Calls...")
len_result = len([1, 2, 3])
match len_result == 3 {
    true => print("  ✓ Builtin calls work"),
    false => print("  ✗ FAILED: Builtin calls")
}

# 7.2 Positional arguments
print("7.2 Positional Arguments...")
# take(arr, count) style
take_result = take([1, 2, 3, 4, 5], 2)
match len(take_result) == 2 {
    true => print("  ✓ Positional arguments work"),
    false => print("  ✗ FAILED: Positional arguments")
}

# 7.3 Chained calls
print("7.3 Chained Calls...")
chained = len(take([1, 2, 3], 2))
match chained == 2 {
    true => print("  ✓ Chained calls work"),
    false => print("  ✗ FAILED: Chained calls")
}

# ============================================
# SECTION 8: PIPELINES
# ============================================
print("\nSECTION 8: PIPELINES\n")

# 8.1 Simple pipeline
print("8.1 Simple Pipeline...")
pipe1 = [1, 2, 3] | len
match pipe1 == 3 {
    true => print("  ✓ Simple pipeline works"),
    false => print("  ✗ FAILED: Simple pipeline")
}

# 8.2 Pipeline with function call
print("8.2 Pipeline with Call...")
pipe2 = [1, 2, 3] | map(fn(x) => x * 2)
match len(pipe2) == 3 {
    true => print("  ✓ Pipeline with call works"),
    false => print("  ✗ FAILED: Pipeline with call")
}

# 8.3 Chained pipeline
print("8.3 Chained Pipeline...")
pipe3 = [1, 2, 3, 4, 5] | where(fn(x) => x > 2) | map(fn(x) => x * 10)
match len(pipe3) == 3 {
    true => print("  ✓ Chained pipeline works"),
    false => print("  ✗ FAILED: Chained pipeline")
}

# 8.4 Pipeline to reduce
print("8.4 Pipeline to Reduce...")
pipe4 = [1, 2, 3, 4] | reduce(fn(a, b) => a + b, 0)
match pipe4 == 10 {
    true => print("  ✓ Pipeline to reduce works"),
    false => print("  ✗ FAILED: Pipeline to reduce")
}

# 8.5 Pipeline with lambda shorthand
print("8.5 Pipeline Lambda Shorthand...")
pipe5 = [1, 2, 3] | fn(x) => x * 3
match first(pipe5) == 3 {
    true => print("  ✓ Pipeline lambda shorthand works"),
    false => print("  ✗ FAILED: Pipeline lambda shorthand")
}

# ============================================
# SECTION 9: MATCH EXPRESSIONS
# ============================================
print("\nSECTION 9: MATCH EXPRESSIONS\n")

# 9.1 Literal patterns
print("9.1 Literal Patterns...")
match_lit = match 2 {
    1 => "one",
    2 => "two",
    3 => "three",
    _ => "other"
}
match match_lit == "two" {
    true => print("  ✓ Literal patterns work"),
    false => print("  ✗ FAILED: Literal patterns")
}

# 9.2 Wildcard pattern
print("9.2 Wildcard Pattern...")
match_wild = match 999 {
    1 => "one",
    _ => "wildcard"
}
match match_wild == "wildcard" {
    true => print("  ✓ Wildcard pattern works"),
    false => print("  ✗ FAILED: Wildcard pattern")
}

# 9.3 Variable binding pattern
print("9.3 Variable Binding Pattern...")
match_var = match 42 {
    x => x * 2
}
match match_var == 84 {
    true => print("  ✓ Variable binding pattern works"),
    false => print("  ✗ FAILED: Variable binding pattern")
}

# 9.4 Guard conditions
print("9.4 Guard Conditions...")
match_guard = match 15 {
    x if x < 10 => "small",
    x if x < 20 => "medium",
    _ => "large"
}
match match_guard == "medium" {
    true => print("  ✓ Guard conditions work"),
    false => print("  ✗ FAILED: Guard conditions")
}

# 9.5 Boolean match (ternary-like)
print("9.5 Boolean Match...")
condition = true
ternary = match condition {
    true => "yes",
    false => "no"
}
match ternary == "yes" {
    true => print("  ✓ Boolean match works"),
    false => print("  ✗ FAILED: Boolean match")
}

# 9.6 String patterns
print("9.6 String Patterns...")
match_str = match "hello" {
    "hi" => 1,
    "hello" => 2,
    _ => 0
}
match match_str == 2 {
    true => print("  ✓ String patterns work"),
    false => print("  ✗ FAILED: String patterns")
}

# ============================================
# SECTION 10: COMPLEX EXPRESSIONS
# ============================================
print("\nSECTION 10: COMPLEX EXPRESSIONS\n")

# 10.1 Nested expressions
print("10.1 Nested Expressions...")
nested = (1 + 2) * (3 + 4)
match nested == 21 {
    true => print("  ✓ Nested expressions work"),
    false => print("  ✗ FAILED: Nested expressions")
}

# 10.2 Complex pipeline
print("10.2 Complex Pipeline...")
complex = range(1, 10) 
    | where(fn(x) => x % 2 == 0) 
    | map(fn(x) => x * x)
    | reduce(fn(a, b) => a + b, 0)
# 2^2 + 4^2 + 6^2 + 8^2 = 4 + 16 + 36 + 64 = 120
match complex == 120 {
    true => print("  ✓ Complex pipeline works"),
    false => print("  ✗ FAILED: Complex pipeline: ${complex}")
}

# 10.3 Record in array
print("10.3 Record in Array...")
users = [{name: "Alice"}, {name: "Bob"}]
first_name = first(users).name
match first_name == "Alice" {
    true => print("  ✓ Record in array works"),
    false => print("  ✗ FAILED: Record in array")
}

# 10.4 Lambda returning record
print("10.4 Lambda Returning Record...")
make_pair = fn(a, b) => {first: a, second: b}
pair = make_pair(1, 2)
match pair.first == 1 && pair.second == 2 {
    true => print("  ✓ Lambda returning record works"),
    false => print("  ✗ FAILED: Lambda returning record")
}

print("\n=== SYNTAX COVERAGE COMPLETE ===")
print("All major AST constructs have been tested!")