Skip to content

feat: add --json output to every command - #223

Merged
riglar merged 4 commits into
devfrom
feat/json-everywhere
Oct 16, 2026
Merged

riglar merged 4 commits into
devfrom
feat/json-everywhere

Conversation

@riglar

@riglar riglar commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Every command and every live subcommand now takes --json. With it, stdout carries exactly one JSON object, on success and on failure, so scripts and agents can pipe it straight into a parser.

Before this, only cloud, upload, list, status and live hierarchy had JSON output. And errors thrown from most commands printed plain text even with --json set.

Changes

  • JSON errors everywhere. src/index.ts checks for --json in argv. If it's there, any thrown error prints as { "status": "FAILED", "error": "..." } (colour codes removed), and usage errors skip the help screen.
  • New --json support:
    • whoami, logout, switch-org, upgrade (UPGRADED / UP_TO_DATE / NO_RELEASE).
    • login and switch-org: prompts and the login URL go to stderr, so a person can still answer them. stdout gets only the result.
    • artifacts: ReportDownloadService now returns a result per download instead of only warning, so the command can list what happened. Exits 1 if every download failed.
    • live start, install, exec, run, screenshot, stop, status, and the bare live menu. live status leaves out the large screenshot and hierarchy data. A failed live run prints its result and exits 2, as before.
    • live hierarchy --json --output <file> now prints { status, path } instead of a plain-text line.
  • Shared helpers: jsonFlag (output.flags.ts), logger.json, logger.fail (exit non-zero without printing a second object), and wantsJson. Existing JSON call sites now use logger.json; their output is unchanged.
  • STYLE_GUIDE.md rule 7 and CLAUDE.md describe the new rule.

Testing

  • pnpm typecheck, pnpm lint (0 errors) and pnpm test:unit (325 passing). New specs are in test/unit/json-output.test.ts and report-download.service.test.ts.
  • Ran the built CLI by hand for whoami, logout, upgrade, artifacts (an error and a failed download), live, switch-org, live status and an unknown command. Each printed one object that jq could read, with the right exit code.
  • Not tested: a full login, switch-org with its picker, and live start / install / exec / run / screenshot against the real API. These need a real session or device.

🤖 Generated with Claude Code

Every command and live subcommand now takes --json. With it, stdout
carries exactly one JSON object on success and on failure.

- index.ts prints thrown errors as { status: 'FAILED', error } when
  --json is in argv, and skips the help screen on usage errors.
- New --json on whoami, logout, switch-org, login, upgrade, artifacts
  and all live subcommands. login and switch-org draw prompts and the
  login URL on stderr.
- ReportDownloadService returns a result per download so artifacts
  --json can report failures; it exits 1 if every download failed.
- live hierarchy --json --output prints { status, path } instead of a
  plain-text line.
- Adds jsonFlag, logger.json, logger.fail and wantsJson; existing JSON
  call sites use logger.json with unchanged output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
finalerock44
finalerock44 previously approved these changes Oct 16, 2026
@riglar riglar closed this Oct 16, 2026
@riglar riglar reopened this Oct 16, 2026
Comment thread src/commands/live.ts Outdated
Under --json the 'Live session started' block is dropped, so a waitForReady
timeout or polling error left a billed session with no name to stop it by.
Catch the error and print { status: 'FAILED', error, session_name, platform,
ready: false, consoleUrl } before exiting with the original exit code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
riglar added a commit that referenced this pull request Oct 16, 2026
…ing is posted (#224)

Port of dcd's fixes. Headless runs ended the turn early (backgrounded
reviewers, denied tools), so no comment was posted and the job still went
green. PR #223's review stopped after 10 turns with 3 permission denials.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@riglar
riglar merged commit 1f74aec into dev Oct 16, 2026
9 checks passed
@riglar
riglar deleted the feat/json-everywhere branch October 16, 2026 16:51
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