fix(cursor): the hooks find the installed runtime and sessionStart restores the project memory

Merged
FM
2d ago
+447-128

What

egc install --target cursor copies the runtime under .cursor/scripts of the project, while the hooks in .cursor/hooks looked for it two levels up, where only the EGC repository has it. In an installed project the session start, the push at the end of a response, the GateGuard and the dev server block did nothing and said nothing.

  • adapter.js has resolveRuntimePath: the installed copy (.cursor/scripts/...) when it exists, the repository layout (scripts/...) otherwise; getPluginRoot is .cursor; runExistingHook runs the hook through it and can hand its stdout back.
  • session-start.js runs scripts/hooks/cursor-session-start.js (the shared session-start adapter, host cursor: Team Brain pull when the team asks for it, state restored, telemetry) and answers Cursor with additional_context holding the project memory, nothing else: the payload is no longer echoed back as the answer.
  • stop.js adds the Team Brain push of scripts/hooks/cursor-stop.js after the turn, when a state file changed since the last run, the way Claude's Stop hook pushes.
  • before-tool-use.js loads the GateGuard and before-shell-execution.js the shell splitter through resolveRuntimePath.
  • The two memory hooks no hook configuration ever called (egc-memory-load.js and egc-memory-save.js, which wrote a field Cursor does not read) leave the tree.
  • VISION, TEAM-BRAIN and integration-tiers no longer say that the Cursor hook cannot inject context.

Phase 1 of the Team Brain plan. The hook files of .cursor/hooks were placed by the maintainer, as the Guardian asks for a hook surface.

Test plan

  • tests/hooks/cursor-installed-layout.test.js (new): an installed project built from .cursor/hooks plus scripts/hooks and scripts/lib under .cursor/scripts; the adapter resolves the installed runtime and the repository runtime; sessionStart answers JSON with the memory as additional_context, runs the Team Brain pull when team.json asks for it, answers {} with no memory; stop runs the push after a turn that changed the state; preToolUse denies the first Write through the GateGuard; beforeShellExecution blocks a dev server outside tmux (7 passed).
  • tests/hooks/cursor-gateguard.test.js, cursor-guardian-adapter.test.js, cursor-crusher-adapter.test.js still pass (19, 12 and 10).
  • eslint clean, local gate clean (repository eslint, Sonar rules, duplication).

Summary by cubic

Fixes the Cursor hooks that egc install --target cursor sets up: they looked for the EGC runtime scripts two levels up, where only the repository has them, so in an installed project the session start, the Team Brain push, the GateGuard, and the dev server block silently did nothing.

  • Each runtime script now resolves to the installed layout (.cursor/scripts/...) first and the repository layout (scripts/...) second, so an installed copy wins over a project file of the same name.
  • sessionStart runs the shared session adapter, pulls the Team Brain when the team asks for it, and answers Cursor with the project memory as additional_context; the input payload is no longer echoed back as the answer.
  • The stop hook runs exactly one Team Brain push per turn through cursor-stop.js behind the stop:team-brain gate, with session-end.js deferring to it for Cursor payloads.
  • The never-configured egc-memory-load.js and egc-memory-save.js hooks are removed, and the docs no longer claim Cursor cannot inject context.