Skip to content

Importing Modules

Vibe can import from TypeScript files, Vibe modules, and system utilities.

import { formatDate, parseConfig } from "./helpers.ts"
import { sendEmail } from "./services/email.ts"
let formatted = formatDate("2025-01-15")

Vibe extracts function signatures from TypeScript files and validates calls at compile time:

helpers.ts
export function add(a: number, b: number): number {
return a + b;
}
import { add } from "./helpers.ts"
// Valid - correct types
let result = add(1, 2)
// Error at compile time - expected number, got text
let x: text = "hello"
add(x, 2) // Error: Argument 1 of 'add': expected number, got text
// Error - wrong number of arguments
add(1) // Error: Function 'add' requires 2 arguments, got 1

Return types are also inferred:

import { add } from "./helpers.ts"
let result = add(1, 2) // Inferred as number
let bad: text = add(1, 2) // Error: cannot assign number to text

Vibe provides built-in utilities organized into modules:

print and env are always available:

// No import needed
let apiKey = env("ANTHROPIC_API_KEY")
let port = env("PORT", "3000") // With default
print("API key loaded")
FunctionDescription
env(name, default?)Get environment variable
print(message)Print to console

Import from "system/utils":

import { uuid, now, random, jsonParse, jsonStringify } from "system/utils"
FunctionDescription
uuid()Generate UUID v4
now()Current timestamp (ms)
random()Random number 0-1
random(min, max)Random integer in range
jsonParse(text)Parse JSON string
jsonStringify(value, pretty?)Convert to JSON string

For AI tool use:

import { readFile, writeFile, bash, glob, grep } from "system/tools"
model agent = {
name: "claude-sonnet-4-20250514",
provider: "anthropic",
apiKey: env("ANTHROPIC_API_KEY"),
tools: [readFile, writeFile, bash]
}

See Tools for the full list.

import { helperFunction } from "./utils.vibe"
import { sharedModel } from "./config.vibe"
let result = helperFunction("input")
let response = do "Hello" sharedModel

Vibe uses named imports:

// Named import (supported)
import { functionName } from "./module.ts"
// Default import (not supported)
// import module from "./module.ts"