Skip to content

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

Merged
Fmarzochi merged 9 commits into
mainfrom
fix/cursor-installed-layout
Dec 5, 2026
Merged

Fmarzochi merged 9 commits into
mainfrom
fix/cursor-installed-layout

Conversation

@Fmarzochi

@Fmarzochi Fmarzochi commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

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.

Written for commit 601cf0d. Summary will update on new commits.

View guided diff Turn on auto-fix

…es the project memory

The install copies the runtime under .cursor/scripts while the Cursor hooks looked for it two levels up, so in an installed project the session start, the push after a response, the GateGuard and the dev server block did nothing. The new scripts/hooks/cursor-session-start.js runs the shared session adapter with the workspace root, pulls the Team Brain when the team asks for it and answers the memory as additional_context. The shared adapter takes a payload a host wrapper already read.

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>

# Conflicts:
#	docs/VISION.md
#	scripts/lib/session-start-adapter.js
# Conflicts:
#	CHANGELOG.md
#	docs/VISION.md

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
…stores the project memory

egc install --target cursor copies the runtime under .cursor/scripts, while the hooks in .cursor/hooks looked for it two levels up, where only the EGC repository has it, so in an installed project the session start, the push at the end of a response, the GateGuard and the dev server block did nothing. The adapter resolves each script in the installed layout first and in the repository layout second, sessionStart runs the shared session adapter and answers the project memory as additional_context, and stop pushes the Team Brain after a turn that changed the state.

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 14 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/hooks/cursor-stop.js Resolved
Comment thread .cursor/hooks/session-start.js Resolved
Comment thread .cursor/hooks/adapter.js Resolved
Comment thread scripts/hooks/cursor-stop.js Resolved
Comment thread docs/spec/integration-tiers.md Resolved
Comment thread docs/VISION.md Resolved
…layout

# Conflicts:
#	CHANGELOG.md

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
@Fmarzochi
Fmarzochi marked this pull request as draft December 5, 2026 00:54
@Fmarzochi
Fmarzochi marked this pull request as ready for review December 5, 2026 00:55

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 14 files

View guided diff | Turn on auto-fix | Re-trigger cubic

…ull and the push went through, and the docs state the push gate

The stop hook ran the push twice, once through session-end.js and once through cursor-stop.js, so the second file now answers nothing and says why. The two sync cases run against a bare remote of their own through egc team init, assert the ok outcome in the autosync log, check the memory is still answered with the team on, prove a turn that changed nothing pushes nothing, and clean team.json in a finally. VISION and integration-tiers say the push happens on the first run and then only when a state document changed.

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/hooks/cursor-stop.js Resolved
@codecov

codecov Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.cursor/hooks/adapter.js 74.07% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

…he layout test resolves the real temporary path

cursor-stop.js is the push again, through the shared team-sync-stop.js, behind the stop:team-brain gate of the Cursor stop hook, and session-end.js leaves the push to it when the payload comes from the Cursor adapter, so disabling one gate never disables the other hook. The layout test resolves the real path of the temporary folder, which on macOS is a link, and the unchanged-turn check counts every push attempt, not only the ones that went through.

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
…layout

# Conflicts:
#	CHANGELOG.md

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
…ile of the project with the same name and that each stop gate controls its own push

The installed project now carries a scripts/hooks/session-start.js of its own, which the repository layout would reach two levels up from the hooks, so an inverted precedence fails the case; the repository layout is proved on an isolated copy under the temporary folder instead of this checkout. The stop case rewrites the state document the way a turn would, making it writable first (the server keeps a synced document read-only), runs the hook with the Team Brain gate off and asserts no push is attempted, then with the session record gate off and asserts the push happens by itself; the hooks outside the case stay off so the cost tracker writes nothing under the checkout.

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

…hy the write bit is restored

update_state writes a fresh file and renames it over the old one, with no chmod; the test restores the write bit because writeFileSync needs it on a document the server publishes read-only.

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 5, 2026

Copy link
Copy Markdown

@Fmarzochi
Fmarzochi merged commit 29f716c into main Dec 5, 2026
36 checks passed
@Fmarzochi
Fmarzochi deleted the fix/cursor-installed-layout branch December 5, 2026 03:21
@Fmarzochi Fmarzochi moved this to Done in EGC Roadmap Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant