Skip to main content

lib_roots

Function lib_roots 

Source
pub fn lib_roots(project_root: &Path) -> Vec<PathBuf>
Expand description

Filesystem roots that require searches for libraries, highest priority first. Only existing directories are returned.

  1. project_root/lib/ — the project’s own modules
  2. $AGENT_BLOCK_HOME/lib/ (default ~/.agent-block/lib/) — the user’s modules, shared by every project on the machine

The embedded sources come after these, and the script’s own directory before them; both are wired in [build_isle_init].

lib/ and blocks/ are two directories on purpose. blocks/ holds entry points — scripts the CLI --block flag and agent-block mcp run by name — and is never on the require path, so a helper dropped beside a block does not become a callable block, and a block cannot be required as if it were a module. A module that starts as a helper inside a project’s lib/ moves to the user’s lib/ and then upstream (into [EMBEDDED_LIBS]) without renaming: each tier resolves the same name, and the first one that has it wins.

AGENT_BLOCK_HOME being unresolvable (no HOME) only drops the user tier; it is not an error here because the kv / sql / ts bridges report that condition already, on the paths they actually need.