# AgentScript (ASL) > Generated from asl/grammar/llmsEntry.md and asl/grammar/tools.asn by scripts/install.sh --render-rules; scripts/install.sh --check-rules fails when this file differs from that render. AgentScript is two things. - ASL, the language: source files (.asl) and data files (.asn) are S-expressions with balanced parentheses. `asl check ` checks delimiter balance, `asl test ` runs a test suite, and `asl help` lists the shell commands; the language section below says which engine enforces what. - asl, the toolbelt: `asl '
...'` runs file operations on the git repository that holds the working directory; the forms of one call run as one batch. ## The language An ASL file is a module header, then items starting in column 0: (module ws/name :x [exported names] :i [(other/module :a alias)]). Imports name the module a file declares, not its path. Docs are not in source: each lives as a (:doc :symbol "path#name" :text "...") row in the package doc.asn, and the reader rejects :d docstrings and prose ; comments. A function is a bare line, fn name a: Int64 b: String -> Bool, with its body indented below; that line is not a form, so the body closes only its own parentheses. Each bracket kind pairs exactly: ( ) forms, [ ] lists, { } records. enum Shape (circle r: Int64) (square side: Int64) makes positional constructors, taken apart by (mt s ((circle r) ...) ((square a) ...)); patterns nest one level. A record field reads as x.f, chains as a.b.c, and on an expression as (expr).f; (with x :k v) is a copy of record x with field k set to v. (let [(a 1) (b (+ a 1))] body) binds in sequence; (fn [x] body) is a value; cond ends with (else v). Conditions, and, or, not and assert take only true or false. Int and Float never mix; overflow and division by zero trap. There is no nil, exception or try: listHead, listTail, listGet, listSlice, stringSlice and mapGet return (some v) or (none), failures are (err e), unwrapped by mt, optionOr or resultOr. Builtins are camelCase like user names, predicates end in ?: listLength, stringContains?, some?; len and head do not exist; + is not a value. A test exports runTests, returning true after at least one (assert cond "msg") or refute. The stage-0 host asl/host/out/asl-host enforces all this before running, and (:test), (:check), asl test and asl check of an .asl file and asl eval run on it (asl eval prints a keyword-headed form back as ASN data); a bare asl test or asl check sweeps every discovered suite or tracked file on it, and the lenient asl-core runner is retired. After an ASL edit run asl/host/out/asl-host check FILE, then test FILE: exit 0 and the executed assert count are the evidence; a test is (module ws/t :x [runTests]) with fn runTests -> Bool ending true after (assert c); asl run FILE runs a program; asl '(:help :builtin stringTo)' lists builtins by name, else by doc, with types. ## Concepts - Form: one parenthesised operation, such as `(:read :file "src/app.py" :symbol "greet")`. - Staging: (:edit) and (:write) stage changes in a buffer on disk outside the working tree, under .asl/vfs, or ~/.cache/asl/vfs/ for a workspace without .asl; each ASL_SESSION has its own buffer. Staged changes persist across calls until (:flush) writes them or (:discard) drops them, and (:diff), (:check) and (:test) see staged content. - Transaction: (:txn :owns ( ...) ...) stages, gates and flushes in one call, and restores every touched file when a nested step fails. - Receipt: every form answers with an ASN S-expression; asl exits 0 on success, 1 on rejected forms and 2 on syntax or balance errors. - Names: user and builtin names are camelCase whole words and predicates end in ?, such as stringLower and listEmpty?. ## Registry and help - `asl '(:tools)'` prints the live operation registry. - `asl '(:help :op read)'` shows an op's form, parameters, defaults, errors and related ops. - `asl '(:help :topic staging)'` explains a topic; topics: staging, txn, batch, receipts, errors, language. ## Operations - `(:tools)` Print the operation registry. - `(:help)` Show help for an op, a topic, or the ASL builtins whose name contains a text. - `(:eval)` Evaluate ASL code in an isolated, time-bounded native-first subprocess. - `(:mem)` List, get, query, and stage row-keyed memory ledger changes. - `(:doc)` Look up a D150 doc ledger row by symbol, or list a file's rows. - `(:read)` Return a symbol or bounded slice of a file. - `(:query)` Search code for definitions and uses of a name; :in text searches comments, docs, memories and data instead, each labelled. - `(:edit)` Stage a string replacement in the session buffer. - `(:write)` Stage whole-file content in the session buffer. - `(:diff)` Show staged changes against disk. - `(:flush)` Write all staged changes to disk atomically. - `(:discard)` Drop all staged changes. - `(:check)` Check a file: delimiter balance, then for an .asl file the stage-0 host check on staged content. - `(:test)` Run an ASL test file on the stage-0 host against staged content. - `(:fix)` Propose or stage minimal delimiter repair. - `(:txn)` Run nested edits and gates atomically inside owns.