Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Import Styles

Source: crates/core/crush-lang/walkers/tree-sitter-crush/test_imports.crush

Crush has several import forms. Standard modules use import; external resources and capabilities use use @.

// Standard module import
import io;
import fs as files;                    // aliased
import net { http_get, http_post };    // selective

// MCP server — wire a remote API as typed capabilities
use @mcp "https://api.github.com" { "issues.list", "repos.get" } as github;

// Capability import — grant specific cap handles under an alias
use @cap "fs.read" { "fs.read", "fs.list" } as reader;

// Polyglot import — pull a symbol from a language module
use @lang python "sys" { "version", "path" } as pysys;

// External resources
import @git "https://github.com/nixpt/exosphere.git" as exo;
import @http "https://example.com/data.json" as data;

fn main() {
    io.print("Imports working!");
}

Form Reference

FormPurpose
import moduleCrush stdlib module (io, fs, net, sys, math, time, …)
import module as aliasModule with alias
import module { a, b }Selective import — only named symbols
use @mcp "url" { tools } as aliasWire an MCP server as capabilities
use @cap "cap.path" { names } as aliasImport specific capability handles
use @lang python "module" { symbols }Import a polyglot language module
import @git "url" as aliasBind a git repository as a resource
import @http "url" as aliasBind an HTTP resource

All use @... forms are enforced by the capability system: the runtime only grants the declared access; anything undeclared is denied at execution time.