Puts the effect= work from 4.0 to use: a new usage mcp server lets agents read command effects locally over stdio, the CLI declares effects for its own commands, and specs gain a repository field so consumers away from the checkout can find the source.
Added
-
usage mcp— serve a spec to an agent over stdio (#746 by @jdx). A local Model Context Protocol server that speaks JSON-RPC 2.0 over newline-delimited stdio, so an agent can ask what a command does before running it. Load a spec with-for-s(stdin is the transport, so--file -is rejected):usage mcp -f mycli.usage.kdlTwo tools:
list_commands— the command tree, each entry tagged with its effectdescribe_command— one command's help, flags, arguments, and the effect of each
Effect is reported as an attribute alongside
helpandaliases; an unset effect staysnullrather than defaulting to something reassuring, and the serverinstructionstell the client that a missing effect means ask. Hidden commands are excluded from listings by default, withinclude_hiddento opt back in. This is the first consumer of theeffect=metadata now declared across roughly 385 commands in mise, hk, pitchfork, aube, and communique. -
repositoryfield on the spec (#747 by @jdx). A plain top-level URL, mirroring whatCargo.toml,package.json, orpyproject.tomlcarry — declared as arepository "..."node at the top of a spec. Distinct fromsource_code_link_template(which is a per-command deep link with a{{path}}placeholder). Anything reading a spec away from its checkout — usage.sh, a registry, an agent handed a.usage.kdl— previously had no way back to the project it described. Round-trips through parse, merge, serialize, and template rendering. -
usageCLI declares its own effects (#751 by @jdx). Every command is now classified: mostgeneratesubcommands areread, with--out-file/--out-dirraising them towrite;generate sdkiswriteat the command level (its output flag is required). Script runners (bash,fish,zsh,powershell,exec) are deliberately unclassified — their effect is whatever the user's script does — and a test asserts every unclassified command has an entry inUNCLASSIFIEDwith a reason. Also emitsmin_usage_version "4.0"so an olderusagedoesn't silently drop the annotation. -
clap_usage::spec()(#743 by @jdx). Returns theSpecderived from aclap::Command(withbinalready set), so callers can annotate it before rendering:let mut spec = clap_usage::spec(&mut cmd, "mycli"); spec.cmd.subcommands.get_mut("rm").unwrap().effect = Some(SpecCommandEffect::Destructive); println!("{spec}");
generate()now delegates tospec()plus twowriteln!s; a test asserts its output is byte-identical. -
usage::available_flagsis public (#746 by @jdx), so consumers can enumerate flags the same way the parser does — respecting global merge and re-declaration rules.
Fixed
-
Re-declared globals keep their aliases on one flag (#752 by @jdx). A global like
flag "-y --yes" global=#truere-declared non-globally by a subcommand (optionally adding a third alias, e.g.-y --yes --assume-yes) could leave-yand--yespointing at two differentArc<SpecFlag>objects, with the-yview missing the new alias. The collision guard now compares flag origins rather thanArcidentity, and rebinds every existing alias for the global to the merged flag on first merge. -
Completions for repeated variadic args (#753 by @Jai-JAP).
complete-wordcounted parsed positional entries to pick which arg to complete next, but variadic values all collapse into one entry — so after the first value, completion fell through to files. It now checks the parsed value per positional and keeps using the variadic arg's completer untilvar_maxis reached.
Changed
clap_usagerepublished as 4.0.0 (#743 by @jdx). crates.io still shippedclap_usage2.0.3, pinned tousage-lib ^2.0.3, because its source hadn't changed since — blocking downstream crates from adoptingeffect=. It now tracksusage-lib's major, and thespec()addition means dependents no longer have to inlinegenerate()and depend onusage-libdirectly.
New Contributors
Full Changelog: v4.0.0...v4.1.0
💚 Sponsor usage
usage is maintained by @jdx, an open source developer for entire.io, the title sponsor of the jdx.dev open source tools including mise, aube, hk, and more. Work on usage is funded by sponsorships.
If usage powers CLI specs, docs, or completions for a tool you maintain or use, please consider sponsoring at jdx.dev. Every sponsorship helps the project stay independent and moving.