Function Categories

General Functions

help()

Index: 0

Description: Display help for all built-in functions

help()  // Shows all functions and descriptions

call(function, ...args)

Index: 1

Description: Call a function with arguments

f = fn(x) => x * 2
call(f, 5)  // 10

// Pipeline mode
5 | call(fn(x) => x * 2)  // 10

clear()

Index: 2

Description: Clear the terminal screen

clear()  // Clears screen

echo(...values)

Index: 3

Description: Print values separated by spaces

echo("Hello", "World")  // "Hello World"
echo(1, 2, 3)           // "1 2 3"

print(value)

Index: 4 Pipeline

Description: Print a value and return it (for pipeline chaining)

print([1, 2, 3])  // Prints [1, 2, 3]

// Pipeline mode
[1,2,3] | map(fn(x) => x * 2) | print  // Prints [2, 4, 6]

http_get(url)

Index: 5 Pipeline

Description: Make HTTP GET request

response = http_get("https://api.example.com/data")
print(response)

// Pipeline mode
"https://api.example.com/data" | http_get | json_parse

File System Functions

ls(path) / list(path)

Index: 8 Pipeline

Description: List directory contents as table of records

files = ls(".")
files = ls("/home/user/docs")

// Pipeline mode
"." | ls | where(fn(f) => f.size > 1000)

Returns: Array of records with {name, type, size, modified}

pwd()

Index: 9

Description: Print working directory

current = pwd()
print(current)  // "/home/user/project"

cat(path)

Index: 10 Pipeline

Description: Read entire file contents

content = cat("README.md")
print(content)

// Pipeline mode
"README.md" | cat | split("\n") | len

read_text(path)

Index: 11 Pipeline

Description: Alias for cat

text = read_text("file.txt")

head(path, n)

Index: 12 Pipeline

Description: Read first N lines of file

preview = head("large-file.txt", 10)

// Pipeline mode (array)
[1,2,3,4,5] | head(3)  // [1, 2, 3]

tail(path, n)

Index: 13 Pipeline

Description: Read last N lines of file

last_lines = tail("log.txt", 20)

// Pipeline mode (array)
[1,2,3,4,5] | tail(2)  // [4, 5]

find(path, pattern)

Index: 14 Pipeline

Description: Find files matching glob pattern

rust_files = find(".", "*.rs")
all_docs = find("docs", "*.md")

// Pipeline mode
"src" | find("*.rs")

sort(array)

Index: 15 Pipeline

Description: Sort array in ascending order

sorted = sort([3, 1, 4, 1, 5])  // [1, 1, 3, 4, 5]

// Pipeline mode
[3, 1, 4] | sort  // [1, 3, 4]

uniq(array)

Index: 16 Pipeline

Description: Remove consecutive duplicates

unique = uniq([1, 1, 2, 2, 3])  // [1, 2, 3]

// Pipeline mode
[1, 1, 2, 3, 3] | uniq  // [1, 2, 3]

wc(path)

Index: 17 Pipeline

Description: Count lines, words, characters in file

stats = wc("README.md")  // {lines: 50, words: 300, chars: 2000}

// Pipeline mode
"file.txt" | wc

grep(path, pattern)

Index: 18 Pipeline

Description: Search file for lines matching pattern

matches = grep("README.md", "AetherShell")

// Pipeline mode
"log.txt" | grep("ERROR")

Pipeline Functions

map(array, fn)

Index: 19 Pipeline

Description: Transform each element in array

doubled = map([1, 2, 3], fn(x) => x * 2)  // [2, 4, 6]

// Pipeline mode
[1, 2, 3] | map(fn(x) => x * 2)  // [2, 4, 6]

where(array, fn)

Index: 20 Pipeline

Description: Filter elements that satisfy predicate

evens = where([1,2,3,4,5,6], fn(x) => x % 2 == 0)  // [2,4,6]

// Pipeline mode
[1,2,3,4,5] | where(fn(x) => x > 2)  // [3,4,5]

reduce(array, fn, init)

Index: 21 Pipeline

Description: Fold array to single value

sum = reduce([1,2,3,4], fn(a,b) => a+b, 0)  // 10

// Pipeline mode
[1,2,3,4] | reduce(fn(a,b) => a+b, 0)  // 10

take(array, n)

Index: 22 Pipeline

Description: Take first N elements

first_three = take([1,2,3,4,5], 3)  // [1,2,3]

// Pipeline mode
[1,2,3,4,5] | take(2)  // [1,2]

keys(record)

Index: 23 Pipeline

Description: Get all keys from record

k = keys({name: "Alice", age: 30})  // ["name", "age"]

// Pipeline mode
{x: 1, y: 2} | keys  // ["x", "y"]

len(value) / length(value)

Index: 24 Pipeline

Description: Get length of array, string, or record

len([1,2,3])     // 3
len("hello")     // 5
len({x: 1, y: 2}) // 2

// Pipeline mode
[1,2,3,4] | len  // 4

type_of(value) / typeof(value)

Index: 25 Pipeline

Description: Get type name of value

type_of(42)       // "Int"
type_of(3.14)     // "Float"
type_of("hello")  // "Str"
type_of([1,2,3])  // "Array"

// Pipeline mode
42 | type_of  // "Int"

first(array)

Index: 26 Pipeline

Description: Get first element of array

first([10, 20, 30])  // 10

// Pipeline mode
[10, 20, 30] | first  // 10

last(array)

Index: 27 Pipeline

Description: Get last element of array

last([10, 20, 30])  // 30

// Pipeline mode
[10, 20, 30] | last  // 30

any(array, fn)

Index: 28 Pipeline

Description: Check if any element satisfies predicate

has_even = any([1,3,5,6], fn(x) => x % 2 == 0)  // true

// Pipeline mode
[1,3,5] | any(fn(x) => x > 4)  // true

all(array, fn)

Index: 29 Pipeline

Description: Check if all elements satisfy predicate

all_positive = all([1,2,3,4], fn(x) => x > 0)  // true

// Pipeline mode
[2,4,6] | all(fn(x) => x % 2 == 0)  // true

String Functions

split(str, delimiter)

Index: 34 Pipeline

Description: Split string by delimiter

words = split("a,b,c", ",")  // ["a", "b", "c"]

// Pipeline mode
"hello world" | split(" ")  // ["hello", "world"]

join(array, separator)

Index: 35 Pipeline

Description: Join array elements with separator

joined = join(["a", "b", "c"], ",")  // "a,b,c"

// Pipeline mode
["hello", "world"] | join(" ")  // "hello world"

trim(str)

Index: 36 Pipeline

Description: Remove leading/trailing whitespace

trimmed = trim("  hello  ")  // "hello"

// Pipeline mode
"  spaces  " | trim  // "spaces"

upper(str)

Index: 37 Pipeline

Description: Convert to uppercase

upper("hello")  // "HELLO"

// Pipeline mode
"hello" | upper  // "HELLO"

lower(str)

Index: 38 Pipeline

Description: Convert to lowercase

lower("HELLO")  // "hello"

// Pipeline mode
"HELLO" | lower  // "hello"

replace(str, from, to)

Index: 39 Pipeline

Description: Replace all occurrences

replaced = replace("hello world", "world", "AetherShell")

// Pipeline mode
"foo bar foo" | replace("foo", "baz")  // "baz bar baz"

contains(str, substr)

Index: 40 Pipeline

Description: Check if string contains substring

contains("hello world", "world")  // true

// Pipeline mode
"hello" | contains("lo")  // true

starts_with(str, prefix)

Index: 41 Pipeline

Description: Check if string starts with prefix

starts_with("hello", "he")  // true

// Pipeline mode
"hello" | starts_with("he")  // true

ends_with(str, suffix)

Index: 42 Pipeline

Description: Check if string ends with suffix

ends_with("hello", "lo")  // true

// Pipeline mode
"hello.txt" | ends_with(".txt")  // true

Array Functions

Some(value)

Index: 6

Description: Create Option with value

opt = Some(42)  // Option containing 42

None()

Index: 7

Description: Create empty Option

empty = None()  // Empty option

flatten(array)

Index: 43 Pipeline

Description: Flatten nested arrays by one level

flat = flatten([[1,2], [3,4]])  // [1, 2, 3, 4]

// Pipeline mode
[[1,2], [3,4]] | flatten  // [1, 2, 3, 4]

reverse(array)

Index: 44 Pipeline

Description: Reverse array elements

reversed = reverse([1,2,3,4])  // [4, 3, 2, 1]

// Pipeline mode
[1,2,3] | reverse  // [3, 2, 1]

slice(array, start, end)

Index: 45 Pipeline

Description: Extract subarray from start to end (exclusive)

sub = slice([1,2,3,4,5], 1, 4)  // [2, 3, 4]

// Pipeline mode
[1,2,3,4,5] | slice(1, 3)  // [2, 3]

range(start, end)

Index: 46 Pipeline

Description: Create array of numbers from start to end (exclusive)

nums = range(1, 6)  // [1, 2, 3, 4, 5]
range(0, 10)        // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

// Pipeline mode
5 | range(10)  // [5, 6, 7, 8, 9]

zip(array1, array2)

Index: 47 Pipeline

Description: Zip two arrays into array of pairs

pairs = zip([1,2,3], ["a","b","c"])  // [[1,"a"], [2,"b"], [3,"c"]]

// Pipeline mode
[1,2,3] | zip(["a","b","c"])  // [[1,"a"], [2,"b"], [3,"c"]]

push(array, value)

Index: 48 Pipeline

Description: Add element to end of array

new_arr = push([1,2,3], 4)  // [1, 2, 3, 4]

// Pipeline mode
[1,2,3] | push(4)  // [1, 2, 3, 4]

concat(array1, array2)

Index: 49 Pipeline

Description: Concatenate two arrays

combined = concat([1,2], [3,4])  // [1, 2, 3, 4]

// Pipeline mode
[1,2] | concat([3,4])  // [1, 2, 3, 4]

Math Functions

abs(num)

Index: 50 Pipeline

Description: Absolute value

abs(-42)   // 42
abs(3.14)  // 3.14

// Pipeline mode
-10 | abs  // 10

min(a, b)

Index: 51 Pipeline

Description: Minimum of two numbers

min(10, 20)  // 10

// Pipeline mode
10 | min(20)  // 10

max(a, b)

Index: 52 Pipeline

Description: Maximum of two numbers

max(10, 20)  // 20

// Pipeline mode
10 | max(20)  // 20

floor(num)

Index: 53 Pipeline

Description: Round down to nearest integer

floor(3.9)   // 3
floor(-2.1)  // -3

// Pipeline mode
3.9 | floor  // 3

ceil(num)

Index: 54 Pipeline

Description: Round up to nearest integer

ceil(3.1)   // 4
ceil(-2.9)  // -2

// Pipeline mode
3.1 | ceil  // 4

round(num)

Index: 55 Pipeline

Description: Round to nearest integer

round(3.5)  // 4
round(3.4)  // 3

// Pipeline mode
3.7 | round  // 4

sqrt(num)

Index: 56 Pipeline

Description: Square root

sqrt(16)  // 4
sqrt(2)   // 1.414...

// Pipeline mode
16 | sqrt  // 4

pow(base, exponent)

Index: 57 Pipeline

Description: Power/exponentiation

pow(2, 8)   // 256
pow(10, 3)  // 1000

// Pipeline mode
2 | pow(8)  // 256

Utility Functions

exit(code)

Index: 58 Pipeline

Description: Exit shell with code

exit(0)   // Exit successfully
exit(1)   // Exit with error

// Pipeline mode
1 | exit  // Exit with code 1

env(var)

Index: 59 Pipeline

Description: Get environment variable

home = env("HOME")
path = env("PATH")

// Pipeline mode
"HOME" | env  // "/home/user"

set_env(var, value)

Index: 60 Pipeline

Description: Set environment variable

set_env("MY_VAR", "value")

// Pipeline mode
"value" | set_env("MY_VAR")

sleep(seconds)

Index: 61 Pipeline

Description: Sleep for N seconds

sleep(2)  // Sleep 2 seconds

// Pipeline mode
2 | sleep

time(fn)

Index: 62 Pipeline

Description: Time function execution

duration = time(fn() => {
    range(1, 1000) | reduce(fn(a,b) => a+b, 0)
})

json_parse(str)

Index: 63 Pipeline

Description: Parse JSON string to value

obj = json_parse('{"name":"Alice","age":30}')

// Pipeline mode
'{"x":1}' | json_parse  // {x: 1}

json_stringify(value)

Index: 64 Pipeline

Description: Convert value to JSON string

json = json_stringify({name: "Alice", age: 30})

// Pipeline mode
{x: 1, y: 2} | json_stringify  // '{"x":1,"y":2}'

MCP (Model Context Protocol) Functions

mcp_servers() / mcp-servers()

Index: 30 Pipeline

Description: List available MCP servers

servers = mcp_servers()
print(servers)

mcp_detect(path) / mcp-detect(path)

Index: 31 Pipeline

Description: Detect MCP servers in path

found = mcp_detect(".")

// Pipeline mode
"./servers" | mcp_detect

mcp_cache_clear() / mcp-cache-clear()

Index: 32

Description: Clear MCP cache

mcp_cache_clear()

mcp_cache_status() / mcp-cache-status()

Index: 33

Description: Get MCP cache status

status = mcp_cache_status()
print(status)

Syntax Knowledge Base Functions

syntax_get(id)

Index: 65 Pipeline

Description: Retrieve syntax entry by ID

ab_spec = syntax_get("ab")
print(ab_spec.name)         // "AgenticBinary Protocol"
print(ab_spec.category)     // "protocol"

// Pipeline mode
"ab" | syntax_get

syntax_list([category])

Index: 66 Pipeline

Description: List syntax IDs, optionally filtered by category

all = syntax_list()             // All IDs
protocols = syntax_list("protocol")  // ["ab", "jsonrpc", "http"]

// Pipeline mode
"protocol" | syntax_list

syntax_search(query)

Index: 67 Pipeline

Description: Search syntax by keyword

results = syntax_search("binary")  // ["ab"]
all_proto = syntax_search("protocol")

// Pipeline mode
"agent" | syntax_search

syntax_add(record)

Index: 68 Pipeline

Description: Add custom syntax entry

new_syntax = {
    id: "myproto",
    name: "My Protocol",
    category: "protocol",
    specification: "Custom protocol spec...",
    examples: ["example1", "example2"]
}
syntax_add(new_syntax)

// Pipeline mode
{id: "test", name: "Test"} | syntax_add

syntax_categories()

Index: 69

Description: List all available categories

cats = syntax_categories()
// ["protocol", "grammar", "format", "encoding", "schema"]
print(cats)

ab_encode(msg_type, opcode, payload)

Index: 70 Pipeline

Description: Encode AgenticBinary message

Message Types: "command", "query", "response", "event"

Opcodes: "ping", "ack", "query", "exec", "data", "error", "sync", "auth", "delegate", "collaborate", "learn", "reason", "plan", "observe", "reflect", "extend"

// Encode a PING command
ping = ab_encode("command", "ping", "hello")
// [0, 5, 104, 101, 108, 108, 111]

// Encode ACK response
ack = ab_encode("response", "ack", "received")

// Pipeline mode
"task_data" | ab_encode("command", "exec")

ab_decode(bytes)

Index: 71 Pipeline

Description: Decode AgenticBinary message

bytes = [0, 5, 104, 101, 108, 108, 111]
decoded = ab_decode(bytes)
print(decoded.msg_type)  // "Command"
print(decoded.opcode)    // "PING"
print(decoded.payload)   // "hello"

// Pipeline mode
[0, 5, 104, 101, 108, 108, 111] | ab_decode

Pipeline Support Summary

Functions marked with Pipeline support both direct calls and pipeline operations:

// Direct call
map([1,2,3], fn(x) => x * 2)

// Pipeline call (piped value becomes first argument)
[1,2,3] | map(fn(x) => x * 2)

// Both produce the same result!

Total functions with pipeline support: 65 of 72

Next: Learn about the Type System or explore Code Examples.