feat(spec): add a top-level repository field#747
Conversation
A spec has no way to say where its CLI's source lives. The nearest thing
is `source_code_link_template`, but that is a per-command deep link with
a `{{path}}` placeholder, built for rendering "view source" links in
markdown docs. Recovering a repository URL from it means pattern-matching
`https://github.com/(owner)/(repo)/blob/...`, which is one forge and one
URL layout, and it is absent from most specs because clap emits nothing
for it.
repository "https://github.com/jdx/mise"
Plain URL, the same value a Cargo.toml, package.json or pyproject.toml
carries. Parsed, merged and re-emitted like the other optional top-level
strings, and exposed to documentation templates.
This matters for anything that reads a spec away from its checkout — a
docs site, a registry, an agent handed a `.usage.kdl` file. Those have a
spec and no way back to the project it describes.
clap has no equivalent, so `clap_usage` cannot generate it. Declare it in
an extra spec merged over the generated one, which is where
`source_code_link_template` already lives; usage's own spec does that
here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryAdds optional repository provenance throughout the usage specification pipeline.
Confidence Score: 5/5The PR appears safe to merge, with the new optional field propagated consistently through its intended parsing, composition, serialization, and documentation paths. The repository value is preserved by parsing, merge-over-generated composition, KDL re-emission, documentation-model conversion, and raw JSON serialization, with targeted tests covering the principal silent-drop paths. Important Files Changed
Reviews (1): Last reviewed commit: "feat(spec): add a top-level `repository`..." | Re-trigger Greptile |
A usage spec has no way to say where the CLI's source lives.
The nearest thing today is
source_code_link_template, but that's a per-command deep link with a{{path}}placeholder, built for rendering "view source" links in generated markdown. Getting a repository URL out of it means pattern-matchinghttps://github.com/(owner)/(repo)/blob/…— one forge, one URL layout — and it's absent from most specs anyway, since clap emits nothing for it and it only exists where someone hand-wrote it into an extra spec.A plain URL, the same value a
Cargo.toml,package.jsonorpyproject.tomlcarries. Parsed, merged and re-emitted like the other optional top-level strings, and passed through to documentation templates asrepository.Why
Anything that reads a spec away from its checkout has a spec and no way back to the project it describes: usage.sh, a registry, an agent handed a
.usage.kdlfile. The repo is the one piece of provenance that isn't derivable from the spec's own contents.It's deliberately separate from
source_code_link_template, and neither implies the other. Set both if you want both.Notes
clap_usagecan't generate this — clap has no equivalent concept. It goes in an extra spec merged over the generated one, exactly wheresource_code_link_templatealready lives. usage's owncli/assets/usage-extra.usage.kdldoes that here, so the regeneratedcli/usage.usage.kdlanddocs/cli/reference/commands.jsoncarry it.Specis#[non_exhaustive], so the field is additive.cargo semver-checksreports no break; the docs model it also touches ispub(crate).This PR was generated by an AI coding assistant.
Note
Low Risk
Additive optional metadata on a non-exhaustive
Spec; no behavior changes unless callers set the field.Overview
Adds an optional top-level
repositorystring to usage specs so readers (docs generators, JSON export, registries) get a plain project URL without inferring it fromsource_code_link_template.The field is wired through
Speclike other optional metadata: KDL parse/emit,mergefor extra specs layered on clap-generated output, serde serialization, and the docsSpecmodel for template context. Spec reference docs explain how it differs from per-command source links and that clap cannot emit it.The usage CLI sets
repositoryinusage-extra.usage.kdl, which flows into regeneratedusage.usage.kdlandcommands.json. Tests cover parse → re-emit and merge-over-generated behavior.Reviewed by Cursor Bugbot for commit b12fca6. Bugbot is set up for automated code reviews on this repo. Configure here.