Skip to main content

Module ast

Module ast 

Source
Expand description

AST host capability.

Wraps tree-sitter parsing, symbol extraction, and outline generation. The implementation is fully wired so AST builtins share one canonical wire format.

§Wire format

  • Row/column coordinates are 0-based across all three builtins, matching tree-sitter’s native Point representation. parse_file, symbols, and outline share one convention.
  • parse_file emits a flat node list with parent_id rather than nested children — keeps the wire JSON-serializable without inflating it with object copies.
  • symbols and outline carry a signature string (e.g. "fn foo(bar: i32)") on every entry.

§Languages

language::Language covers the general-purpose languages (Harn, TypeScript/TSX, JavaScript/JSX, Python, Go, Rust, Java, C, C++, C#, Ruby, Kotlin, PHP, Scala, Bash, Swift, Zig, Elixir, Lua, Haskell, R) plus data/markup/config grammars (JSON, YAML, TOML, CSS, HTML, SQL, Markdown). The latter support the query-driven edit primitives but carry no symbol-graph projection — see language::Language::edit_capabilities for the per-language matrix. Adding/dropping languages requires coordinated schema, fixture, and host-bridge updates.

Modules§

api
Programmatic entry point to the AST builtins. Embedders typically go through the registered builtins, but tests and tools that want strongly-typed access can use these helpers directly.

Structs§

AstCapability
AST capability handle. Stateless; tree-sitter parsers are constructed per-call (cheap relative to grammar lookup) so the capability itself has nothing to own.
AstCapabilityWithCodeIndex
AST capability registered with access to the shared code-index state.
EditCapabilities
Which AST-precise edit primitives are available for a language.
OutlineItem
One node in a hierarchical outline. The children list nests in document order; see [crate::ast::outline] for the fold algorithm.
ParseError
One ERROR / MISSING node from a tree-sitter parse. All row/column coordinates are 0-based, matching tree-sitter’s native Point.
ParsedNode
One tree-sitter node, flattened for parse_file’s wire format. Matches schemas/ast/parse_file.response.json#/$defs/Node.
Symbol
A flat symbol record. All row/col coordinates are 0-based, matching tree-sitter native positions.
UndefinedName
Reference to an identifier that wasn’t defined within the current file. Coordinates are 0-based. kind is "identifier" for value-side references and "type" for type-only references (TypeScript only).

Enums§

Language
Languages with tree-sitter grammar support.
SymbolKind
Symbol kind. The wire form is the lowercase string returned by SymbolKind::as_str.

Constants§

TEXT_PATCH_FALLBACK
The text-level fallback the agent loop should reach for when an AST-precise edit is unavailable for a file. Surfaced verbatim as the fallback_suggestion field on every unsupported_* edit response so the loop can degrade gracefully without per-call branching.