Fix target TTY detection, add shorthand --json | -j flag#83
Open
austin-denoble wants to merge 7 commits intomainfrom
Open
Fix target TTY detection, add shorthand --json | -j flag#83austin-denoble wants to merge 7 commits intomainfrom
target TTY detection, add shorthand --json | -j flag#83austin-denoble wants to merge 7 commits intomainfrom
Conversation
…, 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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
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.

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
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.
pcnow runslogin.EnsureAuthenticated()inPersistentPreRun, 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.
loginandauth logingain-jshorthand and updated help/examples;targetnow auto-enables JSON mode in non-TTY contexts, supportspc target --jsonas 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 introduceEnsureAuthenticated()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.