feat(cli): envelope-first plan-gate upgrade hints#5943
Draft
pamelachia wants to merge 4 commits into
Draft
Conversation
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.
Paid-feature denials now read the management API's
entitlement_requirederror envelope straight off the failed response and print the upgrade hint with zero extra API calls. Previously the suggest path made 2 extra round-trips (project lookup + entitlements) per gated failure, and only 9 commands were wired at all.Changed:
plan_gate.go, TSlegacy-upgrade-suggest.ts) parse{ error: { code: "entitlement_required", feature, upgrade_url } }first; the entitlements round-trip stays as the fallback for gates that do not emit the envelope yet (v1 SSO carries no server-side gate at all).domains create/get/activate/reverifyandvanity-subdomains getnewly show the hint: envelope-only, no fallback, because thecustom_domainentitlement key is plan-level while the gate is a per-project add-on, so the old round-trip would tell Free orgs to upgrade on unrelated 404s.cli_upgrade_suggestedreports the server-authoritative feature:feature_keycomes from the envelope (fixes abranching_persistentdenial being logged asbranching_limit);org_slugis parsed fromupgrade_url.AGENTS.mdtelemetry table and the affectedSIDE_EFFECTS.mdfiles updated to match.Note: the envelope's
upgrade_urlis server-built and printed without a host check. This trusts the management API host the same way every authenticated call already does; a host allowlist would silently suppress valid hints on profiles whose dashboard URL differs from the CLI default.To test
Requires a Free-org project ref (to hit the gates).
Tested locally against prod (
bun src/legacy/main.ts, Free org):domains get --project-ref <free-ref> --agent noprints "Upgrade your plan: .../org//billing" on stderr;--debugshows exactly one HTTP request, no project/entitlements lookupsvanity-subdomains getshows the same hint via the decorated server gateLinear