Expand description
harn-hostlib: opt-in host builtins for code intelligence (tree-sitter,
repo scanning, deterministic indexing) and tool execution (search, file
I/O, git, process lifecycle, file watcher).
This crate is the Rust home of two classes of optional host capabilities:
- Code intelligence —
ast/,code_index/,scanner/,fs_watch/. - Deterministic tools —
tools/(search, fs, git, process).
These don’t belong inside harn-vm — pulling tree-sitter grammars,
ripgrep, and notify into the VM would balloon the footprint of every
pipeline that doesn’t index host code. Instead, this crate exposes a
single HostlibCapability trait. Embedders such as harn-cli’s ACP
server) compose the modules they need via HostlibRegistry and wire
the resulting builtins into the VM through harn_vm::Vm::register_builtin
/ harn_vm::Vm::register_async_builtin.
§Status
The AST, scanner, code-index, and deterministic-tool surfaces are
implemented. fs_watch/ still registers its public contract with
HostlibError::Unimplemented handlers. Module names, method names,
and JSON schemas under schemas/ are the source of truth for hostlib
request/response compatibility, so they must stay stable while module
bodies evolve.
Re-exports§
pub use error::HostlibError;
Modules§
- ast
- AST host capability.
- code_
index - Code index host capability.
- error
- Error type for hostlib host calls.
- fs_
watch - File-system watch host capability.
- process
- Process abstraction used by the deterministic process tools.
- scanner
- Repo scanner host capability.
- schemas
- Embedded JSON Schemas for every hostlib host method.
- tools
- Deterministic tools capability.
Structs§
- Builtin
Registry - Mutable collector each capability writes into during
register. - Hostlib
Registry - Composes capabilities and emits VM registrations.
- Registered
Builtin - One registered builtin. The name is what Harn scripts call (e.g.
hostlib_ast_parse_file);moduleandmethodare the canonical schema-directory coordinates (schemas/<module>/<method>.request.json).
Traits§
- Hostlib
Capability - One module’s worth of builtins. Kept tiny on purpose: capabilities exist purely so tests can reason about the surface without booting a VM, and so embedders can opt into individual modules.
Functions§
- install_
default - Convenience: build a
HostlibRegistrypopulated with every capability the crate ships, register them on the supplied VM, and return the registry so callers can introspect (e.g. for schema-drift tests).