Important flows
This section describes the logic of each cargo agents command.
Crate-sourced skill resolution
When a skill group uses source = "crate", the sync flow takes an additional path:
predicate::union_matched_crates()resolves plugin-level and group-level predicates against the workspace to produce a set of concrete crate name/version pairs.- For each crate in the set,
RustCrateFetchfetches the source — checking path overrides (for local path deps), then the cargo registry cache, then crates.io. crate_metadata::parse_crate_metadata()reads[package.metadata.symposium]from the crate’sCargo.toml:- No metadata — fall back to the default
skills/subdirectory. skills = []— no skills from this crate.path = "..."entries — scan that subdirectory for skills.crate = { name, version? }entries — redirect: fetch the target crate and follow its metadata recursively (with cycle detection and a depth limit of 10).
- No metadata — fall back to the default
discover_skills()scans each resolved directory forSKILL.mdfiles.
The key code paths are in skills.rs (load_crate_skills, fetch_and_resolve_skills), crate_metadata.rs (parse_crate_metadata), predicate.rs (matched_crates, union_matched_crates), and crate_sources/mod.rs (RustCrateFetch, WorkspaceCrate).
Help rendering
cargo agents --help (and -h, the bare help keyword, or no subcommand) is rendered by help_render, not by clap’s default help.
- The binary and the test harness parse argv with
Cli::try_parse_from, then callhelp_render::help_text(parse, args, sym, cwd). Because the decision happens after parsing, argument order (--help --quiet) does not matter and there is no second argv parser to keep in sync. - For no subcommand,
--help/-h, or the barehelpkeyword,help_textreturns the top-level grouped help:renderslices clap’s own rendered help (header + options block) and hand-renders “Commands for humans” / “Commands for agents” between them, mixing built-ins (cli::builtin_audience) with workspace-filtered plugin subcommands (subcommand_dispatch::applicable_subcommands). - For
<built-in> --help,help_textre-renders clap’s per-command help by walking clap’s command tree to the named subcommand — so required-arg commands (crate-info), required-subcommand groups (plugin), and nested commands (plugin list) all work even though clap’s auto help flag is disabled. - A plugin-vended
<name> --helpis left alone:help_textreturnsNone, and dispatch forwards--helpto the child binary, which owns its own help.
clap’s auto help flag and help subcommand are disabled in cli::Cli; --help/-h is a manual global bool. The key code paths are in help_render.rs (help_text, render, subcommand_help), cli.rs (builtin_audience, the Cli flags), and bin/cargo-agents.rs plus symposium-testlib (the parse-then-help_text wiring).
Subcommand dispatch
When the user runs cargo agents <name> for a name not built into the binary, clap’s allow_external_subcommands routes it to Commands::External(argv).
- The binary (or library
cli::run) callssubcommand_dispatch::dispatch_external(sym, cwd, argv). find_subcommandwalks the plugin registry. For each plugin it applies the plugin-levelcratespredicate against the workspace, then looks upargv[0]inplugin.subcommands. If the entry has its owncratespredicate, that must also match. Two or more matches → error.- The matched subcommand’s
commandfield names anInstallationon the same plugin.installation::resolve_runnableacquires the source if any, runsinstall_commands, and picks theRunnable(Execfor binaries,Scriptfor shell scripts). - The child is spawned with stdio inherited. Its exit code is collapsed to a
u8— the binary wraps it inExitCode::from; the library treats non-zero as an error so the test harness can assert on success/failure.
The key code paths are in subcommand_dispatch.rs, cli.rs (the External arm), and bin/cargo-agents.rs (binary-side wrapping that surfaces the numeric exit code to the OS).