Skip to main content

Module skill_loader

Module skill_loader 

Source
Expand description

CLI-side glue that assembles harn-vm’s layered skill discovery from the inputs harn run / harn test / harn check see at startup: repeatable --skill-dir, $HARN_SKILLS_PATH, the nearest harn.toml, and the user’s home / system directories.

The output is a pre-populated skills VM global — a registry dict in the shape the existing skill_* builtins already understand, so scripts can call skill_count(skills) / skill_find(skills, name) without any new language surface.

Structs§

LoadedSkills
Bundle of everything the run path needs: the registry VmValue to set as a global, plus the raw discovery report (for harn doctor and post-run diagnostics). The loader_warnings vec carries per-skill messages — unknown frontmatter fields, unreadable SKILL.md files — that the caller prints to stderr before the VM starts.
SkillLoaderInputs
Inputs threaded in from the CLI layer. Anything we can compute from the environment or from the source path we compute internally; this struct captures only the stuff the user passed via flags.

Functions§

canonicalize_cli_dirs
Convenience: canonicalize CLI-provided --skill-dir paths against the provided cwd (or the process cwd when None). Non-existent paths are kept as-is so harn doctor can flag the typo.
emit_loader_warnings
Print loader warnings to stderr. Non-fatal — a malformed SKILL.md simply doesn’t participate in the registry.
install_skills_global
Set the resolved skill registry as the VM global skills. Safe to call even when no skills were discovered — the value is an empty skill_registry so skill_count(skills) still returns 0.
load_skills
Build a LoadedSkills from CLI inputs. Does no I/O unless one of the input layers has a directory to walk.