Cursor adapter: dashboard usage pools + Grok weekly window (v0.2.0) - #9
Merged
Merged
Conversation
Verified against a live capture. Two cookie-authed POST endpoints back the cursor.com dashboard: get-current-period-usage for the included usage pools (Cursor Models auto bucket + Other Models API usage, reset at billingCycleEnd) and get-sand-usage-status for the Grok Bot weekly window. Team accounts require a teamId in the request body, so the adapter tries the bare request first, discovers the team id via /api/dashboard/teams on refusal, and caches whichever strategy worked. Plans without the Grok feature simply omit that lane (4xx on the sand endpoint is absence, not an error); everything else keeps the contract — never throws, never coerces an unknown shape to a number, no Authorization header, no cookie access. Third provider proves the single-file contribution story: adapter file, registry line, manifest origin, fixtures, tests. Version 0.2.0.
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.
Provider #3, verified against a live capture — and the proof of the single-file contribution story from CONTRIBUTING.md: one adapter file, one registry line, one manifest origin, fixtures, tests.
How it reads Cursor
Two cookie-authed POST endpoints back cursor.com's own dashboard:
/api/dashboard/get-current-period-usage→ the "Included usage" pools: Cursor Models (auto bucket,autoPercentUsed) and Other Models (named/API models,apiPercentUsed), both resetting atbillingCycleEnd(epoch-ms string, normalized)./api/dashboard/get-sand-usage-status→ the Grok Bot weekly window (usagePercent,nextResetTimestampUtc). Plans without the feature return 4xx there — treated as "no lane", not an error.Team-id discovery: team accounts require
{"teamId": N}in the body, but the extension can't read theteam_idcookie (nocookiespermission, by design). The adapter tries the bare{}request first (individual accounts), and on refusal discovers the id via/api/dashboard/teams, caching whichever strategy worked so steady-state refreshes stay minimal.Contract invariants hold and are tested: never throws, unknown shapes are
endpoint_not_verified/schema_mismatcherrors (never a number), noAuthorizationheader, cookie values never touched.Verification
npm run cigreen: typecheck + 66 tests + build. Cursor tests cover: live-fixture happy path (headrooms 100/90/97 matching the capturing account's dashboard: 1%/10%/3% used), team-discovery flow with caching, absent-Grok plans, unauthenticated/rate-limited mapping, HTML-body handling, never-throws, and the no-Authorization assertion.Version bumped to 0.2.0 (this is the next store upload once the v0.1.1 review completes). README provider table and CONTRIBUTING references updated.
Generated by Claude Code