Importing Modules
Vibe can import from TypeScript files, Vibe modules, and system utilities.
Importing from TypeScript Files
Section titled “Importing from TypeScript Files”import { formatDate, parseConfig } from "./helpers.ts"import { sendEmail } from "./services/email.ts"
let formatted = formatDate("2025-01-15")Type Checking
Section titled “Type Checking”Vibe extracts function signatures from TypeScript files and validates calls at compile time:
export function add(a: number, b: number): number { return a + b;}import { add } from "./helpers.ts"
// Valid - correct typeslet result = add(1, 2)
// Error at compile time - expected number, got textlet x: text = "hello"add(x, 2) // Error: Argument 1 of 'add': expected number, got text
// Error - wrong number of argumentsadd(1) // Error: Function 'add' requires 2 arguments, got 1Return types are also inferred:
import { add } from "./helpers.ts"
let result = add(1, 2) // Inferred as numberlet bad: text = add(1, 2) // Error: cannot assign number to textSystem Imports
Section titled “System Imports”Vibe provides built-in utilities organized into modules:
Core Functions (No Import Needed)
Section titled “Core Functions (No Import Needed)”print and env are always available:
// No import neededlet apiKey = env("ANTHROPIC_API_KEY")let port = env("PORT", "3000") // With defaultprint("API key loaded")| Function | Description |
|---|---|
env(name, default?) | Get environment variable |
print(message) | Print to console |
Utility Functions
Section titled “Utility Functions”Import from "system/utils":
import { uuid, now, random, jsonParse, jsonStringify } from "system/utils"| Function | Description |
|---|---|
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 |
System Tools
Section titled “System Tools”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.
Importing Vibe Files
Section titled “Importing Vibe Files”import { helperFunction } from "./utils.vibe"import { sharedModel } from "./config.vibe"
let result = helperFunction("input")let response = do "Hello" sharedModelNamed vs Default Imports
Section titled “Named vs Default Imports”Vibe uses named imports:
// Named import (supported)import { functionName } from "./module.ts"
// Default import (not supported)// import module from "./module.ts"