Skip to content

feat(cli): default output to JSON for coding agents#5532

Merged
jgoux merged 8 commits into
developfrom
pamela/growth-913-cli-auto-switch-default-output-to-json-for-agents-on
Jun 10, 2026
Merged

feat(cli): default output to JSON for coding agents#5532
jgoux merged 8 commits into
developfrom
pamela/growth-913-cli-auto-switch-default-output-to-json-for-agents-on

Conversation

@pamelachia

@pamelachia pamelachia commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Coding agents that run the CLI now get JSON output by default, so they can parse structured results instead of scraping human-formatted tables. I resolve the effective output format once at the TypeScript entrypoint (both the legacy and next roots): an explicit --output / --output-format always wins, otherwise a detected coding agent gets json and everyone else keeps text. For Go-proxied commands this flows down as --output json to the Go subprocess, which renders JSON for the data-returning commands and ignores the flag elsewhere, so no Go changes were needed.

Changes

  • Resolve output format from coding-agent detection in both CLI roots, defaulting agents to json when no format is set explicitly.
  • Add a shared resolveAgentOutputFormat helper (explicit ?? (agent ? json : text)) reused by both roots, with unit tests.
  • Make the --output-format global flag optional so an explicitly-passed format is distinguishable from the default.
  • Suppress the agent JSON default whenever the Go-compat -o/--output flag is passed explicitly: -o json|yaml|toml|env already short-circuits inside handlers, and -o pretty now keeps rendering the human table on natively ported commands instead of being overridden to JSON.

Behavior notes

  • Humans and CI keep their current output: production telemetry shows ~99.6% of CI invocations carry no coding-agent env signal, so they don't flip.
  • Error rendering follows the resolved format. In text mode errors stay as red text on stderr, unchanged. In agent-default JSON mode handler errors emit the existing structured envelope ({"_tag":"Error","error":{code,message}}) on stdout with a non-zero exit code, the same behavior --output-format json already had, so agents get parseable failures instead of prose.
  • Interactive prompts already refuse to block in JSON mode (NonInteractiveError), so a detected agent cannot hang on a confirm prompt.
  • --help and --version render before the output layer engages and stay text in both roots.
  • --agent yes|no overrides detection in both directions for the default-format decision.

Linear

  • fixes GROWTH-913

@pamelachia pamelachia requested a review from a team as a code owner June 10, 2026 10:24
@pamelachia pamelachia self-assigned this Jun 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 333917938d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/cli/src/legacy/cli/root.ts Outdated
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase@5532

Preview package for commit e940eac.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c907b6cdf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/next/cli/root.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2f5e4c66b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/shared/cli/run.ts
Comment thread apps/cli/src/shared/legacy/global-flags.ts
@jgoux jgoux added this pull request to the merge queue Jun 10, 2026
Merged via the queue into develop with commit 3b517e7 Jun 10, 2026
26 checks passed
@jgoux jgoux deleted the pamela/growth-913-cli-auto-switch-default-output-to-json-for-agents-on branch June 10, 2026 14: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