Skip to content

fix(cursor): native adapter hardening - #101

Merged
fusengine merged 3 commits into
mainfrom
fix/cursor-adapter-hardening
Sep 2, 2026
Merged

fix(cursor): native adapter hardening#101
fusengine merged 3 commits into
mainfrom
fix/cursor-adapter-hardening

Conversation

@fusengine

Copy link
Copy Markdown
Owner

Summary

  • Cursor plugin-root discovery with explicit precedence (CURSOR_PLUGIN_ROOT -> CLAUDE_PLUGIN_ROOT -> cwd marker) and a stderr diagnostic on miss; project cwd precedence now honors CURSOR_PROJECT_DIR/CLAUDE_PROJECT_DIR.
  • Canonical payload projection for scope dispatchers (tool_name, cwd, tool_input string->object) and MCP:<tool> canonicalization via a closed server table.
  • Doc-cache gate reachable on beforeMCPExecution (cursor-only guard); per-event native response schemas + exhaustive renderer; additional_context 10,000-char cap with a session-level budget ledger (keyed session|event|generation|tool_use_id, fail-open, idempotent truncation).

Changes

  • src/adapters/cursor/{context,normalize,respond,native-response}.ts (modified), new src/adapters/cursor/{plugin-root,native-schemas,context-limit,context-budget}.ts + interfaces/context-budget.ts.
  • src/runtime/handle.ts, src/runtime/lifecycle/rules-root.ts, src/runtime/lifecycle/aipilot/dispatch-aipilot.ts, src/runtime/lifecycle/failure-lesson.ts — branches guarded by id === "cursor".
  • 15 cursor-* test files (modified/new) + test/fixtures/cursor/** (23 fixtures + README).
  • CHANGELOG.md + package.json bumped to 0.1.92 (separate commit).

Test plan

  • 1311 tests green x3 on a frozen tree
  • tsc clean
  • source/dist/tarball parity 40/40
  • sniper + challenger PASS

Breaking changes

None

- Plugin-root discovery with explicit precedence (CURSOR_PLUGIN_ROOT ->
  CLAUDE_PLUGIN_ROOT -> cwd marker) and stderr diagnostic on miss.
- Project cwd precedence incl. CURSOR_PROJECT_DIR/CLAUDE_PROJECT_DIR.
- Canonical payload projection for scope dispatchers (tool_name, cwd,
  tool_input string->object).
- `MCP:<tool>` canonicalization via a closed server table.
- Doc-cache gate reachable on beforeMCPExecution (cursor-only guard).
- Per-event native response schemas + exhaustive renderer.
- additional_context 10,000-char cap + session-level budget ledger keyed
  session|event|generation|tool_use_id, fail-open, idempotent truncation.
- 23 provenance-labelled fixtures + byte-level stdout tests.
- Test hygiene: tmp cwd/HOME, env restore, hex-free nonce for a
  pre-existing flake.
Reproduced the CI failure: with HOME=tmp (dedicated per harness id) and no
planted root doc as a positive witness, a bare CI $HOME has neither doc, so
an empty additional_context was legitimate and JSON.parse("") threw
"Unexpected EOF" on cursor-context-budget.test.ts:156. The test now asserts
status===0 and stdout empty-or-valid-JSON instead of assuming non-empty
JSON, and checks the registry in the isolated HOME.
@fusengine
fusengine merged commit c1d93f5 into main Sep 2, 2026
1 check passed
@fusengine
fusengine deleted the fix/cursor-adapter-hardening branch September 2, 2026 18:07
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.

1 participant