pub fn discover_agents(dir: &Path) -> Vec<(String, PathBuf)>Expand description
Discover all agent configs in the given directory.
Why: tcode needs to know which agents are available before the PM loop
starts so it can validate delegate_to_agent calls pre-flight. As of
#2897 Slice D, .toml is no longer a loadable format — a project that
has not migrated yet must be told LOUDLY, not silently ignored, or its
agents would appear to vanish with no diagnostic.
What: Scans dir/*.md and returns (name, path) pairs sorted by
file-stem name. Any dir/*.toml file found in the SAME scan is never
parsed and never appears in the returned list; instead every orphaned
.toml path found in this call is named in ONE aggregated
tracing::warn! pointing at the migration script — one call per
discover_agents invocation (not one per file) so a directory with
several un-migrated files does not spam the log, and no process-global
latch is used (the crate convention is no global/Once-gated state for
plain helpers — see repo CLAUDE.md), so the warning fires again on
every subsequent scan for as long as the orphaned file remains.
Test: discover_agents_finds_md, discover_agents_ignores_toml,
discover_agents_warns_on_orphaned_toml,
discover_agents_missing_dir_is_empty.