Skip to content

trail show: add --json - #1885

Closed
peyton-alt wants to merge 5 commits into
mainfrom
trail-show-json
Closed

trail show: add --json#1885
peyton-alt wants to merge 5 commits into
mainfrom
trail-show-json

Conversation

@peyton-alt

@peyton-alt peyton-alt commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/962

Every read command in the trail group (list, watch, finding and its subcommands) offers --json except show — the natural "give me the trail as data" call for agents. This closes that gap: trail show --json emits the resolved TrailResource, with the body carrying the detail-endpoint description text and the URL carrying the browser link the human output already surfaces. The description fetch stays best-effort with its warning on stderr.

Independent of (not stacked on) the trail resume non-interactive contract PR (#1884); both branch off main.

Note: TestRunExplainAuto_GeneratePersistsHexOnBranchUnderRefsPrimary fails on this main snapshot with the change stashed too — pre-existing, unrelated.

🤖 Generated with Claude Code


Note

Low Risk
Adds an optional CLI output mode with no changes to auth, persistence, or API contracts beyond reusing existing trail resolution and description loading.

Overview
entire trail show now accepts --json, matching other trail read commands (list, watch, finding).

With the flag set, the command prints a single indented TrailResource JSON object instead of the human-readable view. The payload uses the same resolved description text and browser URL that normal output already derives (detail fetch still best-effort; failures keep the list body and warn on stderr).

A small encodeTrailShowJSON helper performs the serialization; tests cover the JSON shape and that the --json flag is registered on the show subcommand.

Reviewed by Cursor Bugbot for commit e102596. Configure here.

Every read command in the trail group (list, watch, finding and its
subcommands) offers --json except show — the natural "give me the trail
as data" call for agents. Emit the resolved TrailResource with the body
carrying the detail-endpoint description text and the URL carrying the
browser link the human output already surfaces. The description fetch
stays best-effort with its warning on stderr.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Entire-Checkpoint: 01KYWQ6EWXG0G9GRP1NK0PMTCQ
Copilot AI review requested due to automatic review settings July 31, 2026 18:34
@peyton-alt
peyton-alt requested a review from a team as a code owner July 31, 2026 18:34

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

This PR adds a JSON output mode to entire trail show so agent/script callers can consume a single trail as structured data, aligning show with the other read-only trail commands that already support --json.

Changes:

  • Add --json to entire trail show and plumb the flag through runTrailShow.
  • Introduce encodeTrailShowJSON to emit the resolved api.TrailResource with the resolved description in body and the browser link in url.
  • Add unit tests to pin the JSON payload shape and ensure the --json flag is registered.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/trail_cmd.go Adds --json to trail show and implements JSON encoding for the resolved trail resource.
cmd/entire/cli/trail_show_json_test.go Adds tests for the JSON output shape and for --json flag registration on trail show.

Comment thread cmd/entire/cli/trail_cmd.go Outdated
peyton-alt and others added 4 commits July 31, 2026 15:42
Review finding (Copilot): the description is user-authored text; default
Go encoding turns < > & into \u escapes, diverging from the jsonutil
convention the other JSON helpers follow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Trail-review finding: the JSON payload serialized a failed description
fetch and a genuinely empty description identically as body "". The
text path draws that distinction via descriptionLoaded; the JSON
payload now carries it as description_loaded, so agents don't mistake
an unavailable description for an empty one.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review pass findings:
- show --json emitted api.TrailResource while list --json emits
  trail.Metadata — an agent reading both saw two shapes for the same
  object (id vs trail_id, null vs [] slices, merged_at absent vs
  null). show now encodes ToMetadata() like the text path already
  renders, keeping description_loaded.
- The encoder hand-rolled what jsonutil.MarshalIndentWithNewline
  provides; it now uses the helper, making the test's cited convention
  real.
- New command-level test drives `trail show 42 --json` against a fake
  control plane: detail body supersedes the list body on stdout as pure
  JSON, and a failed detail fetch keeps stdout parseable with
  description_loaded=false and the warning on stderr.
- Flag help matches the sibling convention; url key absence (omitempty)
  and slice normalization pinned in the encoder tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@peyton-alt peyton-alt closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants