Skip to content

feat: add JSON output to preset and extension lists - #4218

Open
WOLIKIMCHENG wants to merge 6 commits into
github:mainfrom
WOLIKIMCHENG:feat/4211-json-list-output
Open

feat: add JSON output to preset and extension lists#4218
WOLIKIMCHENG wants to merge 6 commits into
github:mainfrom
WOLIKIMCHENG:feat/4211-json-list-output

Conversation

@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor

Description

Add --json output to specify preset list and specify 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 --available and --all continue to return
installed 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 --help
  • git diff --check

@WOLIKIMCHENG
WOLIKIMCHENG requested a review from mnriem as a code owner August 20, 2026 09:22
@mnriem
mnriem requested a balanced review from Copilot August 20, 2026 12:54
@mnriem mnriem self-assigned this Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds machine-readable JSON output for installed preset and extension listings.

Changes:

  • Adds --json CLI 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

Comment thread src/specify_cli/_installed_list_json.py Outdated

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback

@mnriem mnriem removed their assignment Aug 20, 2026
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/specify_cli/_installed_list_json.py
@mnriem

mnriem commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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.
@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor Author

Addressed the latest Copilot feedback in dd8b34e3. Happy to adjust further if needed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread docs/reference/presets.md Outdated
Comment on lines +57 to +58
runtime failures after option parsing, `--json` writes `{"error":"..."}` to
stderr and exits nonzero.
Comment thread docs/reference/extensions.md Outdated
Comment on lines +71 to +72
extensions. For runtime failures after option parsing, `--json` writes
`{"error":"..."}` to stderr and exits nonzero.
@mnriem

mnriem commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and resolve conflicts

WOLIKIMCHENG added 2 commits September 2, 2026 11:13
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add --json output to preset list and extension list

3 participants