feat: add JSON output to preset and extension lists - #4218
Conversation
There was a problem hiding this comment.
Pull request overview
Adds machine-readable JSON output for installed preset and extension listings.
Changes:
- Adds
--jsonCLI output and structured error responses. - Adds contribution counts, authors, sources, and precedence ordering.
- Adds documentation and contract tests.
Structured catalog provenance is currently lost because only source.kind is emitted.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/_installed_list_json.py |
Defines the shared JSON schema and emitters. |
src/specify_cli/_project.py |
Adds non-rendering project resolution. |
src/specify_cli/presets/_commands.py |
Adds preset JSON listing. |
src/specify_cli/presets/__init__.py |
Computes preset JSON metadata. |
src/specify_cli/extensions/_commands.py |
Adds extension JSON listing. |
src/specify_cli/extensions/__init__.py |
Computes extension JSON metadata. |
tests/test_installed_list_json.py |
Tests JSON contracts and failures. |
docs/reference/presets.md |
Documents preset JSON output. |
docs/reference/extensions.md |
Documents extension JSON output. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Balanced
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback
Preserve valid catalog provenance in installed preset and extension JSON output while retaining the local fallback for missing, legacy, unknown, and malformed records. Carry raw registry source metadata through healthy and corrupt manager records, whitelist the public kind/catalog shape in the shared adapter, and document and test the contract without changing provenance producers.
There was a problem hiding this comment.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/specify_cli/presets/_commands.py:64
- The new machine-readable ordering contract is not exercised: the only JSON preset test installs one item, while the existing multi-preset precedence tests invoke only the text branch. Add a JSON test with reversed installation/priority order and an equal-priority ID tie so consumers can rely on the promised
(priority, id)array order.
installed = sorted(
installed,
key=lambda pack: (pack.get("priority", 10), str(pack.get("id", ""))),
)
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Balanced
|
Please address Copilot feedback |
Propagate normalized catalog names through preset and extension install, init, bundler refresh, archive, and update paths while preserving local fallbacks and deterministic JSON ordering.
|
Addressed the latest Copilot feedback in |
There was a problem hiding this comment.
🟢 Approval recommended
The implementation satisfies the documented schema, provenance, ordering, error, and compatibility requirements with focused coverage.
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 0 new
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Parse-time failures still emit human-formatted output despite the linked issue’s JSON error contract.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 2
- Review effort level: Balanced
| runtime failures after option parsing, `--json` writes `{"error":"..."}` to | ||
| stderr and exits nonzero. |
| extensions. For runtime failures after option parsing, `--json` writes | ||
| `{"error":"..."}` to stderr and exits nonzero. |
|
Please address Copilot feedback and resolve conflicts |
Preserve catalog provenance while retaining current main's bundler configuration scaffolding and bundled-extension update/rollback behavior.
Handle parse-time Click usage errors for preset and extension list when the raw --json flag is present, preserving stderr-only output and exit 2 in either flag order. Document and test the contract.
Description
Add
--jsonoutput tospecify preset listandspecify extension list.The new output provides a consistent installed-item schema with per-kind
contribution counts, normalized local/catalog source kinds, and nullable
authors. Existing text output and preset precedence ordering remain unchanged.
In JSON mode,
extension list --availableand--allcontinue to returninstalled extensions only.
Closes #4211
Testing
.venv/bin/python -m pytest -p no:cacheprovider tests/test_installed_list_json.py tests/test_init_dir_cli.py -q— 25 passed.venv/bin/specify preset list --help.venv/bin/specify extension list --helpgit diff --check