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
| "author": record["_json_author"], | ||
| "priority": record["priority"], | ||
| "enabled": record["enabled"], | ||
| "source": {"kind": record["_json_source_kind"]}, |
There was a problem hiding this comment.
Addressed in 1e4f38c2: structured catalog sources are now preserved, with safe fallback for legacy or malformed records. Added regression coverage; 17 focused and 1138 related tests pass locally.
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
| "author": record["_json_author"], | ||
| "priority": record["priority"], | ||
| "enabled": record["enabled"], | ||
| "source": _normalized_source(record["_json_source"]), |
|
Please address Copilot feedback |
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