docs/cursor.md
On macOS, Cursor can reuse Cursor.app's local session or a cursor.com browser session. Automatic mode prefers a usable Cursor.app session and falls back to cookies when the app token is missing, expired, invalid, or rejected.
Cursor.app local auth (preferred in Automatic mode)
ItemTable key cursorAuth/accessToken.~/Library/Application Support/Cursor/User/globalStorage/state.vscdbstate.vscdb-wal and state.vscdb-shm~/Library/Application Support/CodexBar/cursor-session.json through the standard credential-file writer.Cached cookie header
com.steipete.codexbar.cache (account cookie.cursor).Browser cookie import
cursor.com, cursor.sh.WorkosCursorSessionToken__Secure-next-auth.session-tokennext-auth.session-tokenStored session cookies (fallback)
~/Library/Application Support/CodexBar/cursor-session.json.On macOS, explicit --source web skips Cursor.app local auth and uses only the cookie ladder. A configured Manual cookie
header remains an explicit override. codexbar usage --provider cursor --source auto --verbose prints the selected
automatic path and is the quickest live-read check after Cursor login.
Manual option:
Cookie: header from a cursor.com request.https://authenticator.cursor.sh/ in a supported browser.GET https://cursor.com/api/usage-summary
GET https://cursor.com/api/auth/me
GET https://cursor.com/api/usage?user=ID
POST https://cursor.com/api/dashboard/get-sand-usage-status
usagePercent, nextResetTimestampUtc). Same session cookie;
requires Origin: https://cursor.com. Best-effort: a failure leaves Cursor's monthly bars intact.~/Library/Cookies/Cookies.binarycookies~/Library/Application Support/Google/Chrome/*/Cookies~/Library/Application Support/Firefox/Profiles/*/cookies.sqlite~/.config/codexbar/config.json (or legacy ~/.codexbar/config.json) work on Linux.When Settings → Advanced → Track provider local storage is enabled on macOS, CodexBar measures:
~/Library/Application Support/Cursor~/Library/Application Support/Caches/cursor-updater~/.cursor~/Library/Caches/Cursor~/Library/Caches/com.todesktop.230313mzl4w4u92~/Library/Caches/com.todesktop.230313mzl4w4u92.ShipIt~/Library/Caches/cursor-compile-cache~/Library/HTTPStorages/com.todesktop.230313mzl4w4u92The storage detail lists measured paths and their sizes. CodexBar does not delete Cursor data.
The cost summary's Cursor section is opt-in: it only fetches when Show cost summary is enabled and the Cursor provider is on. Unlike Claude and Codex cost (scanned from local session logs on this machine), Cursor cost is remote, account-wide data from the cursor.com dashboard, so it covers usage from every machine on the account.
Auth reuses the exact status-probe session resolution and cookie-source policy:
codexbar cost --provider cursor fails explicitly and /cost returns a provider error row.Fetch behavior:
POST https://cursor.com/api/dashboard/get-filtered-usage-events (cookie-authenticated; requires a matching Origin for CSRF).{}; empty terminal pages omit the event array but retain totalUsageEventsCount. Both shapes were verified against populated pages from the same live session. The decoder accepts only these exact omitted-array shapes, preserves the query count, and rejects malformed arrays or ambiguous envelopes; a terminal {} contradicting an earlier positive count still fails.Two totals are reported from the same events:
tokenUsage.totalCents, with an API-list-price fallback only when the field is missing or null. Fallbacks use the existing cached models.dev catalog or bundled rates at the event date, preserve Cursor's disjoint input/cache counters, and do not read native Codex custom pricing or refresh prices over the network. Reported zero remains zero; malformed, negative, nonfinite, or otherwise invalid costs stay unpriced and fail the same-model sum closed. Unknown models remain unpriced. Reported, estimated, and unpriced request counts remain visible even when a rejected cost invalidates a model total.meteredCostUSD): what Cursor's plan actually deducts over the window, shown as its own "Cursor-metered:" line.API-list-price estimates are not estimates of actual Cursor charges: they do not apply plan-specific Cursor Token Rates, regional adjustments, or legacy billing rules. chargedCents and Cursor-metered totals remain separate and unchanged. In Overview, history coverage describes the included sources' established history; a selected subscription without spend still makes amounts partial and remains disclosed in the subscription count, without erasing another source's known history days.
Caching: the app holds the snapshot for an in-memory hourly TTL, keyed by the history window plus the cookie source and resolved account (manual-cookie hash or auto-mode account fingerprint), so switching accounts or pasting a new cookie invalidates it immediately.
get-sand-usage-status when the account has a non-zero Bot allowance.nextResetTimestampUtc (weekly).Sources/CodexBarCore/Providers/Cursor/CursorAppAuth.swiftSources/CodexBarCore/Providers/Cursor/CursorStatusProbe.swiftSources/CodexBarCore/Providers/Cursor/CursorSandUsage.swift (Grok Bot weekly included usage)Sources/CodexBar/CursorLoginRunner.swift (login flow)Sources/CodexBar/Providers/Cursor/CursorLoginFlow.swift (menu integration)Sources/CodexBar/CursorLoginBrowserRouter.swift (browser routing and selection)