Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Important flows

This section describes the logic of each cargo agents command.

Crate-sourced skill resolution

A plugin loads a crate as a plugin by naming that crate in a [[plugins]] chained reference (source.cargo = "..."); the user can also load one directly by enabling the dependency it lives in (see enablement below). When the owning plugin is active and the edge’s predicates hold, the crate is resolved into the active plugin set — the shared list every facet (skills, MCP servers, hooks, subcommands) resolves over, so a crate-sourced plugin’s extensions dispatch exactly like a registry plugin’s. A single path handles every crate — a crate is always a first-class plugin, whether it describes itself with a Symposium.toml, with [package.metadata.symposium], with both, or with neither:

  1. skills::active_plugins seeds a worklist from the trust-root plugins the registry loaded: each active plugin’s plugin.chained edges whose predicates hold (evaluated against the owning plugin’s provenance) contribute a source.cargo crate id.
  2. For each id the fixed-point calls pms.load_plugin(id, update) on the package-manager set active_plugins was handed (built once per invocation by Symposium::workspace). The id’s pm routes it to the cargo transport, which:
    • CargoPm::fetch resolves the source via RustCrateFetch. A workspace dependency is served from the source cargo metadata already extracted (path overrides for local path deps). Any other crate is read under UpdateLevel::None from cargo’s extracted crates.io sources ($CARGO_HOME/registry/src/index.crates.io-*, the registry the probe asks, so another registry’s same-named crate is never substituted), with no process and no network, and goes through the crates.io probe under Check or Fetch. The per-invocation paths (--help, subcommand dispatch, hook dispatch) pass None, so they never spawn cargo; sync passes Check, so it downloads a crate cargo has not cached yet. The fetched id carries the exact resolved version.
    • CargoPm::plugin_from_fetched returns the crate as an unvalidated plugin, with a manifest the cargo PM’s manifest::merge builds by layering two sources (merge order: [package.metadata.symposium] from Cargo.toml → Symposium.toml file). Both use the ordinary plugin-manifest schema and are parsed leniently (a malformed layer is logged and dropped).
    • A crate with neither source but a plugin.json at its root is an Agent Plugins package instead. The cargo PM only flags it (UnvalidatedPlugin::agent_plugin): the translator lives in Symposium, and its warnings belong in the user’s report, which a package manager running as its own process cannot reach.
    • The cargo instance validates it (plugins::validate_plugin with PluginKind::Package). A flagged package is first translated by plugins::agent_plugin_manifest into one skill group per immediate child of skills/ and its mcp.json into MCP servers, with the default skills/ group turned off. The translation is strict, so an invalid plugin.json makes the crate yield no plugin at all (reported as a warning) rather than falling back to its skills/ folder. For any other package, a plugin.json beside its manifest sources only fills the name, version and description they leave out; a malformed one is logged.
    • Validation then runs under ManifestOrigin::Crate (name defaults to the crate, depends-on is waived, [defaults] accepted, default skills/ group appended unless [defaults] skills = false). The result is a Plugin whose canonical id is the resolved crate. A crate with no manifest sources and no plugin.json still yields one whose only content is that default skills/ group.
  3. record_active honors the crate plugin’s own plugin-level predicates (applies, which stamps its provenance: never a workspace member), appends it to the active set, and enqueues its own [[plugins]] edges. This is how a [package.metadata.symposium] redirect (now a [[plugins]] source.cargo chained reference to the target crate) is followed. A visited set keyed on the package identity (PmRegistry::identity), global across the whole active_plugins call, collapses diamonds (a crate reached through two plugins loads once, so its hooks don’t double-fire and its subcommands don’t read as a false conflict) and breaks cycles; the finite crate universe bounds termination.
  4. Facet extraction then walks the active set. collect_skills runs each plugin’s skill groups through the ordinary load_skills_for_group pipeline — honoring named groups, group predicates, and source.path/source.git, with each discovered skill’s origin hashed from its on-disk SKILL.md path (this is where git skill sources are fetched, hence the update level). MCP-server filtering (sync), hook dispatch (hook::dispatch_plugin_hooks), and subcommand lookup (subcommand_dispatch) each iterate the same set. A crate plugin’s custom predicate definitions are the one facet still not wired in — they resolve only from configured registries, and warn_undispatched_crate_features notes when a crate declares one.

A skill’s install identity is the hash of its on-disk SKILL.md path, so a crate reached two ways dedupes to one install. The edge’s version requirement is recorded but not yet enforced — the crate resolves against the workspace (pin / path override).

The key code paths are in symposium-pm-cargo (CargoPm::load_plugin, plugin_from_fetched, manifest::merge), pm/mod.rs (PmInstance, PluginKind), plugins/agent_plugin.rs (agent_plugin_manifest, fill_from_agent_plugin), plugins.rs (validate_plugin, ManifestOrigin::Crate, Plugin::canonical), skills.rs (active_plugins, record_active, plugin_key, collect_skills, hash_origin_key), and, in symposium-pm-cargo, metadata.rs (symposium_metadata), workspace.rs (WorkspaceDeps, WorkspaceCrate), and sources.rs (RustCrateFetch).

Dependency enablement

A dependency’s own plugin content (a Symposium.toml, [package.metadata.symposium], an Agent Plugins plugin.json, or a skills/ directory) is reachable without any manifest pointing at it, but only with the user’s consent: dependencies are not a trust root.

  1. discovery::discover asks the untrusted cargo transport for its active_plugins(dep_ids): the plugins embedded in the workspace’s dependencies. CargoPm::active_plugins inspects each dependency in the source cargo metadata already extracted (WorkspaceCrate::source_dir), with no probe or network, so registry-dep embedded plugins are discoverable too. The trusted registries (including the recommendations repo) are skipped, because their plugins are trust roots and never need consent. Each candidate is classified against [plugins] on its crate name — enabled by use, auto-enabled, declined, or an undecided candidate. Nothing is prompted or written.
  2. At sync time, plugins::active_plugins asks discovery::enabled_dependencies which packages [plugins] auto-enable or an applicable use entry covers (workspace deps, plus the packages use entries name that aren’t deps at all) and seeds each id on the same worklist a chained reference feeds, so pms.load_plugin honors the crate’s manifest sources, skill groups, and its own [[plugins]] edges. Each use name is resolved by the package managers (PmRegistry::identify) at the level crate loading uses: a name a configured registry provides is left to that registry plugin, so it isn’t double-loaded, and a name no package manager has is skipped. sync resolves at Check, reading the cargo cache first and searching crates.io only for a crate that is not cached; the per-invocation paths resolve at None, which reads only workspace dependencies and the cargo cache. This reads config rather than the offer list, so cargo agents use <crate> loads a crate from crates.io whether or not the workspace depends on it, and even before its source has been fetched.
  3. Independently, a registry plugin with no dependency gate anywhere loads dormant (PluginManifest::requires_use) and activates only when a use entry names it. The gate rides the PredicateContext (with_used / is_used, holding the canonical ids discovery::used_plugins finds by matching each plugin’s name under its own package manager’s rule), so skill resolution, hook dispatch, subcommand lookup, help, and MCP filtering all agree.

Decisions are recorded by the consent prompt in an interactive cargo agents sync (discovery::prompt_for_consent, which writes auto-enable and disable) and by cargo agents use (use entries); cargo agents status reports what [plugins] currently decides. A hook never prompts: SessionStart names the pending candidates as context instead.

The key code paths are in discovery.rs, config.rs (PluginsConfig, UseEntry), symposium-pm-cargo (CargoPm::active_plugins, CargoPm::load_plugin), plugins.rs (PluginManifest::requires_use), predicate.rs (PredicateContext::is_used), and skills.rs (active_plugins, record_active).

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.

  1. The binary and the test harness parse argv with Cli::try_parse_from, then call help_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.
  2. For no subcommand, --help/-h, or the bare help keyword, help_text returns the top-level grouped help: render slices 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).
  3. For <built-in> --help, help_text re-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.
  4. A plugin-vended <name> --help is left alone: help_text returns None, and dispatch forwards --help to 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).

  1. The binary (or library cli::run) calls subcommand_dispatch::dispatch_external(sym, cwd, argv), which first resolves the active plugin set (skills::active_plugins — registry plugins plus crate-sourced ones) so a crate’s subcommands are dispatchable too.
  2. find_subcommand walks that set. For each plugin it applies the plugin-level depends-on predicate against the workspace, then looks up argv[0] in plugin.subcommands. If the entry has its own depends-on predicate, that must also match. Two or more matches → error.
  3. The matched subcommand’s command field names an Installation on the same plugin. installation::resolve_runnable acquires the source if any, runs install_commands, and picks the Runnable (Exec for binaries, Script for shell scripts).
  4. The child is spawned with stdio inherited. Its exit code is collapsed to a u8 — the binary wraps it in ExitCode::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).