Make pscale agent-friendly: JSON auth, sql command, AGENTS.md#1280
Open
no-itsbackpack wants to merge 5 commits into
Open
Make pscale agent-friendly: JSON auth, sql command, AGENTS.md#1280no-itsbackpack wants to merge 5 commits into
no-itsbackpack wants to merge 5 commits into
Conversation
Extract ResolveAccessRole and PostgresInheritedRoles for shell and sql, add agent next_steps command builders, JSONReportedError, and TryOpenBrowser. Co-authored-by: Cursor <cursoragent@cursor.com>
auth check and login emit structured status, issues, and next_steps for non-interactive device flow onboarding. Co-authored-by: Cursor <cursoragent@cursor.com>
Run read/write SQL with JSON output, reader default role, and destructive query gating that requires explicit user approval via --force. Co-authored-by: Cursor <cursoragent@cursor.com>
Document flag placement, auth workflow, sql conventions, and destructive query approval for any agent or script using the CLI. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f945d7d. Configure here.
auth check exits non-zero for action_required (including NO_ORG), login writes pending JSON to stderr and always emits a final stdout envelope after credentials are saved, and org setup failures report ORG_SETUP_FAILED. Co-authored-by: Cursor <cursoragent@cursor.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.

Summary
Automated agents and scripts can use
pscalewithout a TTY by followingAGENTS.mdand passing--format json. This PR adds structured onboarding, a non-interactive SQL command, and guardrails against accidental destructive queries.AGENTS.md— agent guide: flag placement (--orgon subcommands, positionals before flags), auth workflow,pscale sqlusage, destructive SQL approval flow. Uses placeholders only (<org>,<database>,<branch>).pscale auth check --format json— reportsstatus,authenticated,issues, andnext_stepsso agents know whether to log in, pick an org, or proceed.pscale auth login --format json— device flow with pending JSON (verification_url,user_code,browser_opened); polls until approved without requiring an interactive shell.pscale sql— run a single query withoutpscale shell. Default role is reader (unlike shell’s admin default). JSON response includesstatus,columns,rows, andnext_stepson error.DELETE,DROP, orTRUNCATE(word match) returnstatus: action_requireduntil the user approves and the agent re-runs with--force.ResolveAccessRole,PostgresInheritedRoles, andagent_stepsnext-step strings (correct flag order), shared by auth, sql, and shell.Agent workflow
Test plan
go test ./internal/cmdutil/... ./internal/cmd/auth/... ./internal/cmd/sql/... ./internal/sqlquery/...staticcheck/golangci-linton changed packagespscale auth check --format jsonon authenticated machinepscale sql <database> <branch> --org <org> --format json --query "SELECT 1"action_requiredJSON;--forcerequired after user approvalFollow-ups
status/issues/next_stepsresponses across other commands. Auth and sql use typed JSON envelopes today; most commands still emit a plain{"error": "..."}on stderr. A shared JSON error/onboarding helper would reduce per-command one-offs.