Skip to content

Fix target TTY detection, add shorthand --json | -j flag#83

Open
austin-denoble wants to merge 7 commits intomainfrom
adenoble/fix-target-and-json-flag
Open

Fix target TTY detection, add shorthand --json | -j flag#83
austin-denoble wants to merge 7 commits intomainfrom
adenoble/fix-target-and-json-flag

Conversation

@austin-denoble
Copy link
Copy Markdown
Collaborator

@austin-denoble austin-denoble commented Apr 2, 2026

Problem

Describe the purpose of this change. What problem is being solved and why?

Solution

make sure target cmd detects non-TTY and sets JSON mode automatically, same as login, when pc target needs to authenticate the URL is output to stdout properly, add shorthand --json flag for needed commands

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

Describe specific steps for validating this change.


Note

Medium Risk
Adds a global authentication pre-check for most commands and changes login/target behavior in non-TTY JSON mode, which could affect automation and command execution paths if the skip list or auth detection is incorrect.

Overview
Adds a root-level auth gate for most commands. pc now runs login.EnsureAuthenticated() in PersistentPreRun, with a curated skip list for commands that manage credentials/local state, and auto-detects JSON mode (non-TTY stdout or --json/-j) to format auth errors appropriately.

Improves non-interactive/agentic UX. login and auth login gain -j shorthand and updated help/examples; target now auto-enables JSON mode in non-TTY contexts, supports pc target --json as an auth-free “show current context” path, and centralizes JSON context printing.

Refactors and extends post-auth setup. Login utilities split context initialization into applyAuthContext(), ensure target project state is cleared when no projects exist, keep stdout clean during wait-mode by printing auth URLs to stderr, and introduce EnsureAuthenticated() to lazily complete pending daemon sessions and auto-initialize org/project context after successful browser auth.

Reviewed by Cursor Bugbot for commit ddb7ecd. Bugbot is set up for automated code reviews on this repo. Configure here.

…, same as login, when pc target needs to authenticate the URL is output to stdout properly, add shorthand --json flag for needed commands
…show/--clear are now not blocked by auth state
…e sure auth local-keys is not blocked by auth logic, remove duplicated output
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

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.

1 participant