pub fn load_all_agents(dir: &Path) -> Vec<AgentConfig>Expand description
Load all agent configs from the given directory, skipping parse errors.
Why: Startup needs a map of all available agents; individual parse errors
should not crash the whole harness. A project that has not yet created
.claude/agents/, has created it but left it empty, or has populated it
with only unparseable (or, post-#2897, only orphaned-.toml) configs must
not start with zero agents — see the embedded-fallback note below.
What: Calls discover_agents (which already excludes .toml paths — see
its doc), then dispatches every discovered .md path to
md_loader::load_md_agent, collecting only the successfully parsed
configs (failures are logged at WARN level and skipped). The fallback
threshold is the parsed result being empty, not merely discover_agents
finding no paths — a directory full of configs that all fail to parse (or
that holds nothing but orphaned .toml files) must fall back exactly like
an empty or missing directory does. Any single successfully-parsed disk
config is treated as the project’s own catalog and used as-is, never
merged with the embedded set. Falls back to load_embedded_default_agents
when parsing yields nothing. Disk agents always win when present.
Test: load_all_agents_skips_invalid,
load_all_agents_falls_back_to_embedded_when_disk_empty,
load_all_agents_falls_back_to_embedded_when_disk_all_invalid,
load_all_agents_falls_back_when_disk_has_only_orphaned_toml,
load_all_agents_disk_wins_when_present.