Skip to content

feat: add cursor auth and dashboard sync#17

Merged
Miss-you merged 3 commits into
mainfrom
you-10-cursor-dashboard-auth-sync
Mar 16, 2026
Merged

feat: add cursor auth and dashboard sync#17
Miss-you merged 3 commits into
mainfrom
you-10-cursor-dashboard-auth-sync

Conversation

@Miss-you

Copy link
Copy Markdown
Owner

Summary

  • add explicit codetok cursor login, status, sync, and logout subcommands
  • validate WorkosCursorSessionToken against Cursor before saving it locally and store credentials with atomic owner-only writes
  • fetch Cursor dashboard CSV into ~/.codetok/cursor/synced/usage.csv with failure-safe cache preservation and test coverage
  • lock parser compatibility so synced CSVs remain discoverable by the existing local Cursor provider

Validation

  • make fmt
  • make vet
  • make test
  • make build
  • manual smoke: ./bin/codetok cursor --help
  • manual smoke: HOME=$(mktemp -d) ./bin/codetok cursor status
  • manual smoke: ./bin/codetok daily --all --cursor-dir "$(pwd)/e2e/testdata/cursor" --kimi-dir "$EMPTY_DIR" --claude-dir "$EMPTY_DIR" --codex-dir "$EMPTY_DIR"
  • make lint (golangci-lint not installed in this environment, target skipped)

Notes

  • normal daily / session flows remain local-only and do not call Cursor APIs
  • synced CSVs are written atomically so a failed sync keeps the previous local cache intact
  • implementation scope is limited to YOU-10 tasks 2.1 through 2.5

Copilot AI review requested due to automatic review settings March 16, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit Cursor auth/sync workflow to codetok, including local credential storage and an on-demand dashboard CSV sync, while ensuring the existing local Cursor provider can discover the synced cache.

Changes:

  • Introduces codetok cursor login|status|sync|logout via a new Cobra command wired into the root CLI.
  • Adds a new cursor domain package: credential storage (atomic + owner-only), Cursor API client (validate + export CSV), and sync orchestration.
  • Extends Cursor provider tests to confirm synced CSVs in a nested synced/ directory remain discoverable.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
provider/cursor/parser_test.go Adds coverage ensuring nested synced/usage.csv is discovered by the existing provider.
docs/plans/2026-03-16-cursor-dashboard-sync-implementation.md Documents the implementation plan for Cursor auth + dashboard sync.
cursor/auth.go Implements Service for login/status/logout backed by storage + API client abstraction.
cursor/client.go Adds Cursor HTTP client for session validation and CSV export.
cursor/storage.go Adds credential + synced CSV storage with atomic writes and restricted perms.
cursor/sync.go Implements sync orchestration: load creds → fetch CSV → atomically write cache.
cmd/cursor.go Adds codetok cursor command group and subcommands.
*_test.go files Adds unit tests across cmd/ and cursor/ plus provider coverage for synced CSV discovery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cursor/storage.go Outdated
Comment on lines +189 to +191
if err := os.Rename(tmpPath, path); err != nil {
return err
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Atomic writes now use a replace helper that retries via remove-and-rename when destination replacement is required, and coverage now exercises overwriting an existing cache file.

Comment thread cursor/storage.go Outdated
Comment on lines +44 to +52
func (s Store) CredentialsPath() string {
path, _ := s.credentialsPath()
return path
}

// SyncedCSVPath returns the path to the tool-owned synced CSV cache file.
func (s Store) SyncedCSVPath() string {
path, _ := s.syncedCSVPath()
return path

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. CredentialsPath now returns (string, error) so home-dir resolution failures surface directly, with regression coverage for the default-root failure path.

Comment thread cursor/storage.go Outdated
Comment on lines +44 to +52
func (s Store) CredentialsPath() string {
path, _ := s.credentialsPath()
return path
}

// SyncedCSVPath returns the path to the tool-owned synced CSV cache file.
func (s Store) SyncedCSVPath() string {
path, _ := s.syncedCSVPath()
return path

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. SyncedCSVPath now returns (string, error) instead of swallowing root-resolution failures, and the tests cover that error path.

Comment thread cursor/client.go Outdated
if err != nil {
return nil, fmt.Errorf("read usage CSV: %w", err)
}
if !bytes.HasPrefix(bytes.TrimSpace(data), []byte("Date,")) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. FetchUsageCSV now tolerates an optional UTF-8 BOM before the Date, header, and there is regression coverage for BOM-prefixed CSV exports.

@Miss-you
Miss-you merged commit b183284 into main Mar 16, 2026
7 checks passed
@Miss-you
Miss-you deleted the you-10-cursor-dashboard-auth-sync branch March 16, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants