trail show: add --json - #1885
Closed
peyton-alt wants to merge 5 commits into
Closed
Conversation
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
Contributor
There was a problem hiding this comment.
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
--jsontoentire trail showand plumb the flag throughrunTrailShow. - Introduce
encodeTrailShowJSONto emit the resolvedapi.TrailResourcewith the resolved description inbodyand the browser link inurl. - Add unit tests to pin the JSON payload shape and ensure the
--jsonflag 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. |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://entire.io/gh/entireio/cli/trails/962
Every read command in the trail group (
list,watch,findingand its subcommands) offers--jsonexceptshow— the natural "give me the trail as data" call for agents. This closes that gap:trail show --jsonemits the resolvedTrailResource, 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_GeneratePersistsHexOnBranchUnderRefsPrimaryfails 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 shownow accepts--json, matching other trail read commands (list,watch,finding).With the flag set, the command prints a single indented
TrailResourceJSON 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
encodeTrailShowJSONhelper performs the serialization; tests cover the JSON shape and that the--jsonflag is registered on the show subcommand.Reviewed by Cursor Bugbot for commit e102596. Configure here.