feat(cli): add github command group for workspace GitHub connections - #113
feat(cli): add github command group for workspace GitHub connections#113AmanVarshney01 wants to merge 3 commits into
Conversation
Adds prisma-cli github list/connect/install so agents and headless sessions can drive the GitHub connection flow the Console gained in pdp-control-plane#4406: list connected and connectable accounts, connect an already-installed account to the active workspace without a GitHub round trip, and mint the install URL for brand-new accounts. Connect resolution is non-interactive by design: missing or unknown accounts fail with structured errors carrying the connectable options in meta and as runnable next steps. Real mode calls the Management API endpoints from pdp-control-plane#4408; the connectable/connect paths are called through a single typed seam until the published SDK carries them. Fixture mode is fully covered by tests.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Replaces the separate github command group with three subcommands under the existing git group, so all GitHub functionality lives in one place: git accounts (list connected + connectable), git connect-account (connect an already-installed account from another workspace), git install (install link). git connect/disconnect keep owning the repo-to-project link. Reuses the existing source-repository API seam and install-intent helper; error codes are GIT_ACCOUNT_REQUIRED / GIT_ACCOUNT_NOT_FOUND / GIT_CONNECT_FAILED.
Reworks the GitHub account commands into a git account sub-group: git account list # connected + connectable accounts git account connect [account] # connect one, or install a new one git account connect is the single add-an-account command. With an explicit account it connects directly (agent path). In a terminal with no account it shows a picker of connectable accounts plus a '+ Install a new GitHub account' option; choosing install opens the browser and polls until the account appears, reusing the same open-and-wait mechanism as git connect, so it never dead-ends. In a non-interactive context it returns the connectable options (and install URL when nothing is connectable) as structured data instead of prompting. Replaces the flatter git accounts / connect-account / install trio.
|
Closing as stale: every file this touches — the commander |
Why
Agent-friendly counterpart to the Console work in pdp-control-plane#4396/#4402/#4406/#4407: agents and headless sessions need to drive the GitHub connection flow without a browser. The critical piece is connecting an org that already has the Prisma GitHub App installed — the only path GitHub itself cannot round-trip (no callback fires when nothing changes), now exposed by pdp-control-plane#4408.
Commands
connectwithout an account fails withGITHUB_ACCOUNT_REQUIRED, carrying the connectable options inerror.meta.connectableand as runnable next steps — an agent picks and reruns, no prompt-blocking. Unknown accounts fail the same way withGITHUB_ACCOUNT_NOT_FOUND.GITHUB_CONNECT_FAILEDafter the platform self-heals its stale rows.Draft status: one dependency
Real mode calls the two new Management API endpoints from pdp-control-plane#4408 (open). The published
@prisma/management-api-sdkdoes not carry those paths yet, so they go through a single documented, fully-typed seam inlib/github/provider.ts— delete-marked for when the SDK regen lands after #4408 merges. Everything else (/v1/scm-installations,install-intents) uses the typed SDK client directly.Undraft once #4408 is merged and the SDK is bumped (seam removal is a follow-up commit here).
Testing
6 fixture-mode CLI tests (
tests/github.test.ts): list with per-account dedupe (newest installation wins), connect by login and by numeric id, structuredGITHUB_ACCOUNT_REQUIREDwith machine-readable options,GITHUB_ACCOUNT_NOT_FOUNDwith the same, install URL. Full suite 615 green; typecheck clean. Real mode needs a live check against #4408 once deployed.