Skip to main content

Crate harn_hostlib

Crate harn_hostlib 

Source
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:

  1. Code intelligenceast/, code_index/, scanner/, fs_watch/.
  2. Deterministic toolstools/ (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.
secret_store
Per-OS secret-store host primitive.
tools
Deterministic tools capability.

Structs§

BuiltinRegistry
Mutable collector each capability writes into during register.
HostlibRegistry
Composes capabilities and emits VM registrations.
RegisteredBuiltin
One registered builtin. The name is what Harn scripts call (e.g. hostlib_ast_parse_file); module and method are the canonical schema-directory coordinates (schemas/<module>/<method>.request.json).

Traits§

HostlibCapability
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 HostlibRegistry populated 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).