feat(cursor): add project-local tokensave integration - #5
Conversation
Generate Cursor project rules, permissions, and supported hooks from the local installer so Cursor can prefer tokensave safely within a repo.
Add installer-generated Cursor project hooks for the local install: - sessionStart: steer the Agent toward tokensave MCP tools and report index freshness (fire-and-forget). - afterShellExecution: on Agent-run git checkout/switch/worktree add, bootstrap /maintain branch tracking via the shared library branch-add path (idempotent, no subprocess); other state-changing git commands run a coalesced incremental sync. - workspaceOpen: ensure the current branch DB exists (branch add if missing) and run a catch-up incremental sync. Performance: afterFileEdit now does a TARGETED single-file sync of only the edited path(s) via sync_if_stale_silent (matcher "Write"), never a full-tree scan, since scan cost scales with repo size not edit size and the Agent can edit many files per turn. All Cursor hooks are fail-open and only act when .tokensave/ exists. The installer now reconciles its own hook entries on reinstall so refinements like the afterFileEdit matcher reach pre-existing configs. Caveat (documented): Cursor hooks only observe the Cursor Agent's own actions and IDE lifecycle. Manual/external-terminal git checkout and in-place branch switches are not seen (workspaceOpen does not fire for in-place checkout); the git post-commit hook and on-demand MCP staleness check cover those.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4d5ea33dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Avoid treating single-file checkout restores as branch switches so Cursor hooks run normal sync instead of creating bogus branch tracking.
Merge the Windows path expectation fix while preserving Cursor local install test exclusions.
Flake ScriptedAlchemy#5: the codex app-server / model backend tests (the success-path `codex_app_server_*` / `fake_codex_app_server_*` cases) flaked under parallel execution. `fake_codex_response_timeout()` was 5s on non-Windows — the budget for the fake codex child (a real python interpreter) to spawn and complete its scripted turn. Under process-per-test parallelism that spawn can be scheduled slowly enough to exceed 5s, yielding a spurious "timed out waiting for codex app-server response". Fix (test only): use a uniform generous 30s success-path budget (matching the prior Windows value). Tests that deliberately exercise the timeout path pass their own tight `Duration` (e.g. 300ms) and are unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
install --local --agent cursor.Test plan