Skip to content

feat(version): print complete version information as JSON - #4821

Merged
mnriem merged 4 commits into
github:mainfrom
mnriem:mnriem-version-json-contract
Oct 2, 2026
Merged

mnriem merged 4 commits into
github:mainfrom
mnriem:mnriem-version-json-contract

Conversation

@mnriem

@mnriem mnriem commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Make specify version --json print complete version information directly as JSON, with top-level cli_version, runtime, system, and features fields. The existing human version display and focused --features view remain unchanged. Combining --features and --json produces the same complete JSON output.

The existing command rejects --json alone and writes its human error to stdout; combining the options emits a provisional features-only object. This change makes --json usable directly and intentionally replaces that provisional shape with the complete version data.

Success writes one JSON object to stdout with empty stderr. Unavailable OpenSSL information is represented by runtime.openssl: null. Unexpected information-collection failures exit nonzero, leave stdout empty, and emit one sanitized JSON error object to stderr without exposing exception text or tracebacks.

Scope is limited to the version command, its mirrored tests, and concise command-reference documentation. No sibling commands or shared JSON infrastructure are changed.

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

The test checkbox above is left unchecked because validation used the documented worktree-local interpreter instead of uv run pytest. A sample project is not applicable to this project-independent command.

Validation after merging upstream main:

  • uv sync --extra test — passed.
  • .venv/bin/python -m pytest tests/specify_cli/test_command_version.py -q — 9 passed.
  • .venv/bin/python -m pytest tests/specify_cli/test_*version*.py -q — 140 passed, 1 skipped.
  • .venv/bin/python -m pytest tests -q — 9,511 passed, 19 skipped; 9,530 tests collected. The command suite increases from 7 tests upstream to 9; no collection is removed.
  • uvx ruff@0.15.0 check src tests — passed.
  • npx --yes markdownlint-cli2 docs/reference/core.md — passed.
  • git diff --check upstream/main...HEAD — passed.
  • uv run specify --help — passed.
  • .venv/bin/specify version --json and .venv/bin/specify version --features --json — passed; output was checked for the exact four top-level fields, byte-identical payloads, and empty stderr.
  • .venv/bin/specify version and .venv/bin/specify version --features — passed with empty stderr.

Tests assert deterministic output and stream purity, equivalence of the combined options, unavailable OpenSSL handling, and sanitized unexpected failures. Before the implementation, the canonical invocation exited 1 with a human error on stdout; after it, the regression tests pass with complete JSON output.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: GitHub Copilot, using GPT-5.6 Sol and subsequently GPT-6.1 Sol, implemented the code, tests, and documentation on behalf of @mnriem. The agents ran in autonomous mode with the session-provided reasoning configuration and applied the contributor's requested output and documentation adjustments. Copilot ran the reported automated validation, authored the commits and PR text, and merged upstream updates without rewriting published history. No personal human execution of the tests or line-by-line human review is claimed.

mnriem and others added 4 commits October 2, 2026 13:07
Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 18:44

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.

Copilot review overview

🟢 Approval recommended

The focused implementation matches the documented contract and has appropriate positive and negative test coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds complete, script-friendly JSON output to specify version while preserving existing human-readable views.

Changes:

  • Adds runtime, system, CLI version, and feature fields to JSON output.
  • Provides sanitized JSON errors and stable OpenSSL-unavailable handling.
  • Adds comprehensive tests and command-reference documentation.
File Description
src/​specify_cli/​command_version.py Implements complete JSON output and error handling.
tests/​specify_cli/​test_command_version.py Covers success, failure, compatibility, and OpenSSL cases.
docs/​reference/​core.md Documents the new JSON contract.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mnriem
mnriem merged commit 8dfb15d into github:main Oct 2, 2026
15 checks passed
@mnriem
mnriem deleted the mnriem-version-json-contract branch October 2, 2026 18:59
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.

2 participants