Built-in functions and standard library reference
print(args ...any)
Prints values to stdout, separated by spaces, followed by a newline.
len(value any) int
Returns the length of a string (in Unicode codepoints) or array.
split(s string, sep string) [string]
Splits a string by a separator and returns an array of substrings.
join(arr any, sep string) string
Joins array elements into a string with the given separator.
trim(s string) string
Removes leading and trailing whitespace from a string.
replace(s string, old string, new string) string
Replaces all occurrences of old with new in a string.
contains(haystack any, needle any) bool
Returns true if a string contains a substring, or an array contains a value.
starts_with(s string, prefix string) bool
Returns true if the string starts with the given prefix.
ends_with(s string, suffix string) bool
Returns true if the string ends with the given suffix.
to_int(s string) string! int
Parses a string as an integer. Returns an error if the string is not a valid number.
map(arr [T], block) [U]
Transforms each element of an array using a block, returning a new array.
resolve(promise T?) T
Waits for an async promise to complete and returns its value.
assert(condition bool, msg: string?) string! void
Asserts that a condition is true. Raises an error with the given message on failure.
assert_eq(a any, b any, msg: string?) string! void
Asserts that two values are equal. Raises an error with the given message on failure.
pwd() string
Returns the current working directory.
Basic AWS CLI wrappers for common operations.
Requires the aws CLI to be installed and configured.
whoami() string! string
Returns the current AWS caller identity.
s3_list() string! string
Lists S3 buckets.
s3_copy(src string, dst string) string!
Copies a file to/from S3.
s3_sync(src string, dst string) string!
Syncs a local directory to/from S3.
ssm_get(name string) string! string
Gets an SSM parameter value.
ssm_set(name string, value string) string!
Sets an SSM parameter value.
ec2_list() string! string
Lists EC2 instances.
region() string! string
Gets the current region.
Basic Azure CLI wrappers for common operations.
Requires the az CLI to be installed and configured.
account() string! string
Returns the current account info.
subscription() string! string
Returns the current subscription ID.
resource_groups() string! string
Lists resource groups.
storage_accounts() string! string
Lists storage accounts.
vms() string! string
Lists VMs.
blob_upload(account string, container string, file string) string!
Uploads a blob to storage.
blob_download(account string, container string, name string, dest string) string!
Downloads a blob from storage.
encode(data [byte]) string
decode(s string) string! [byte]
test_encode_decode_roundtrip() string!
test_encode_known_value() string!
test_decode_known_value() string!
test_encode_empty() string!
test_decode_empty() string!
test_decode_invalid() string!
random_bytes(n int) string! [byte]
uuidv4() string! string
aes_keygen() string! [byte]
aes_encrypt(plaintext [byte], key [byte]) string! [byte]
aes_decrypt(ciphertext [byte], key [byte]) string! [byte]
rsa_keygen() string! RsaKeyPair
rsa_encrypt(plaintext [byte], public_key [byte]) string! [byte]
rsa_decrypt(ciphertext [byte], private_key [byte]) string! [byte]
test_random_bytes_length() string!
test_random_bytes_different() string!
test_uuidv4_format() string!
test_uuidv4_unique() string!
test_aes_roundtrip() string!
test_aes_different_ciphertexts() string!
test_rsa_roundtrip() string!
Environment variable management.
get(name string) string?
Returns the value of an environment variable, or nil if not set.
set(name string, value string) string!
Sets an environment variable.
unset(name string) string!
Unsets an environment variable.
list() [EnvVar]
Returns all environment variables as an array of {name, value} structs.
test_set_and_get() string!
test_get_nonexistent() string!
test_unset() string!
test_list() string!
list(path string) [FileInfo]
read(path string) string! string
write(path string, content string) string!
stat(path string) string! FileInfo
exists(path string) bool
is_dir(path string) bool
copy(src string, dst string) string!
move(src string, dst string) string!
chmod(path string, mode int) string!
chown(path string, uid int, gid int) string!
mkdir(path string) string!
Creates a directory and all parent directories.
symlink(target string, link string) string!
Creates a symbolic link pointing to target.
chown_name(path string, owner string, group string, recursive: bool?) string!
Changes ownership by user/group name. Optionally recursive.
append(path string, content string) string!
Appends content to a file.
copy_r(src string, dst string) string!
Recursively copies a file or directory.
remove_r(path string) string!
Recursively removes a file or directory.
test_write_and_read() string!
test_stat() string!
test_exists() string!
test_is_dir() string!
test_copy() string!
test_move() string!
test_read_nonexistent() string!
Basic Google Cloud CLI wrappers for common operations.
Requires the gcloud CLI to be installed and configured.
project() string! string
Returns the current project ID.
account() string! string
Returns the current authenticated account.
gcs_list() string! string
Lists GCS buckets.
gcs_copy(src string, dst string) string!
Copies a file to/from GCS.
gcs_sync(src string, dst string) string!
Syncs a local directory to/from GCS.
instances() string! string
Lists compute instances.
region() string! string
Gets the current region.
Basic git CLI wrappers for common operations.
Requires git to be installed. Directory handled by caller via cd blocks.
clone(url string, branch: string?) string!
Clones a repository. Optionally specify a branch.
fetch() string!
Fetches from all remotes.
pull() string!
Pulls the current branch.
checkout(ref string) string!
Checks out a branch, tag, or commit.
rev() string!
Returns the current commit hash.
branch() string!
Returns the current branch name.
encode(data [byte]) string
decode(s string) string! [byte]
test_encode_decode_roundtrip() string!
test_encode_known_value() string!
test_decode_known_value() string!
test_encode_empty() string!
test_decode_empty() string!
test_decode_invalid() string!
JSON parsing and emitting.
parse(s string) string! any
Parses a JSON string into a pitcrew value. Objects become structs, arrays become arrays, strings/numbers/bools map directly, null becomes nil.
emit(val any, indent: bool?) string! string
Converts a pitcrew value to a JSON string. Supports structs, arrays, strings, numbers, bools, and nil. Set indent: true for pretty-printed output.
keys(val any) string! [string]
Returns the keys of a JSON object (struct) as an array of strings.
typeof(val any) string
Returns the type of a value as a string: "string", "number", "bool", "array", "object", "null", or "unknown".
test_parse_object() string!
test_parse_array() string!
test_parse_nested() string!
test_parse_null() string!
test_parse_bool() string!
test_emit_string() string!
test_emit_number() string!
test_emit_array() string!
test_round_trip() string!
test_keys() string!
test_typeof() string!
test_emit_indent() string!
test_parse_invalid() string!
HTTP requests, DNS lookups, and port checks.
get(url string) string! HttpResponse
Performs an HTTP GET request. Returns {status: int, body: string}.
post(url string, body string, content_type: string?) string! HttpResponse
Performs an HTTP POST request. Returns {status: int, body: string}.
dns_lookup(host string) string! [string]
Resolves a hostname to a list of IP addresses.
port_open(host string, port int) bool
Returns true if a TCP connection can be made to host:port.
test_dns_lookup() string!
test_port_open_closed() string!
test_dns_lookup_bad_host() string!
npm package management.
ls() string!
Lists installed packages (depth=0).
outdated() string!
Shows packages needing updates.
version() string!
Returns the npm version string.
install(production: bool?) string!
Installs dependencies. Optionally production-only.
ci(production: bool?) string!
Clean installs dependencies from lockfile. Optionally production-only.
run(script string) string!
Runs a named npm script.
test() string!
Runs npm test.
build() string!
Runs npm run build.
Unified package management across apt, yum/dnf, and brew. Detects the system's package manager automatically.
manager() string
Returns the detected package manager: "apt", "dnf", "yum", "brew", or "unknown".
install(name string, version: string?) string!
Installs a package. Optionally specify a version.
remove(name string) string!
Removes a package.
installed(name string) string! bool
Returns true if the given package is installed.
update() string!
Updates the package list/index.
upgrade(name: string?) string!
Upgrades a specific package, or all packages if no name given.
test_manager_returns_string() string!
start(cmd string) string! int
stop(pid int) string!
signal(pid int, sig string) string!
status(pid int) string! ProcessInfo
pidfile(path string) string! int
alive(pid int) bool
test_alive_nonexistent() string!
test_status_init() string!
test_status_nonexistent() string!
test_pidfile() string!
test_pidfile_notfound() string!
test_start_and_stop() string!
test_signal() string!
Regular expression matching and manipulation.
match(pattern regex, text string) bool
Returns true if the regex pattern matches the text.
find(pattern regex, text string) string?
Returns the first match of the pattern in the text, or nil if no match.
find_all(pattern regex, text string) [string]
Returns all matches of the pattern in the text as an array of strings.
replace(pattern regex, text string, replacement string) string
Replaces all matches of the pattern in the text with the replacement string.
test_match_true() string!
test_match_false() string!
test_match_digits() string!
test_find_first() string!
test_find_no_match() string!
test_find_all() string!
test_find_all_no_match() string!
test_replace() string!
test_replace_no_match() string!
test_word_boundary() string!
test_regex_with_groups() string!
Service management for systemd and launchd.
start(name string) string!
Starts a service.
stop(name string) string!
Stops a service.
restart(name string) string!
Restarts a service.
enable(name string) string!
Enables a service to start on boot.
disable(name string) string!
Disables a service from starting on boot.
running(name string) string! bool
Returns true if a service is currently running.
daemon_reload() string!
Reloads the systemd daemon configuration.
manager() string
Returns the detected service manager: "systemd", "launchd", or "unknown".
test_manager_returns_string() string!
limiter(n int) limit
sleep(seconds int)
Pauses execution for the given number of seconds.
Simple string templating for config file generation. Uses {{key}} placeholders replaced by values from a struct.
render(template string, vars any) string
Renders a template string, replacing {{key}} placeholders with values from vars. Example: render("Hello {{name}}!", {name: "world"}) => "Hello world!"
test_simple_render() string!
test_multiple_vars() string!
test_no_vars() string!
test_repeated_placeholder() string!
User and group management.
create(name string, home: string?, shell: string?) string!
Creates a new user. Optionally specify a home directory and shell.
delete(name string, remove_home: bool?) string!
Deletes a user. Set remove_home to true to also delete their home directory.
exists(name string) bool
Returns true if a user exists on the system.
add_to_group(user string, group string) string!
Adds a user to a group.
create_group(name string) string!
Creates a group.
delete_group(name string) string!
Deletes a group.
group_exists(name string) bool
Returns true if a group exists.