continual-learning: write to user-scoped memory file by default#74
Open
yuranich wants to merge 2 commits into
Open
continual-learning: write to user-scoped memory file by default#74yuranich wants to merge 2 commits into
yuranich wants to merge 2 commits into
Conversation
The plugin previously wrote learnings into the workspace `AGENTS.md` and kept its cadence + incremental-index state under `.cursor/hooks/state/`. On a team repository both of those paths are shared with every contributor: personal preferences end up committed into the team's instructions, and the state files permanently sit in `git status` as untracked noise. Default the memory file to `~/.cursor/projects/<workspace-slug>/AGENTS.local.md` and the state directory to a sibling `continual-learning/` folder (mirroring the existing `agent-transcripts/` layout). Cursor already loads stacked AGENTS.md context, so the user file is still picked up automatically. Add an opt-in `CONTINUAL_LEARNING_WORKSPACE_FILE` env var for users who want a shared workspace-scoped memory file inside their repo, and gate it behind a `git check-ignore` safety check (bypassable via `CONTINUAL_LEARNING_ALLOW_SHARED=1`) so the plugin refuses to write team- shareable bullets to a path that would be committed by accident. The hook now embeds the already-resolved target paths and any block reason directly into the `followup_message`, so the `agents-memory-updater` subagent gets concrete absolute paths instead of having to recompute them. Section routing is made explicit: `## Learned User Preferences` always goes to the user file, `## Learned Workspace Facts` only to the workspace file when it is configured and not blocked, and a `## Learned Workspace Facts (local)` fallback heading is used in the user file otherwise. First-run migration copies any pre-existing legacy state out of the workspace into the user-scoped location (with a backup under the user state dir) and removes the originals so they stop appearing in `git status`. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 8039a82. Configure here.
Bugbot (PR cursor#74) flagged the blocked branch of the followup message as contradicting the routing instructions in the same message and in `agents-memory-updater.md`. The routing rule is to fall back to the user memory file under `## Learned Workspace Facts (local)` whenever the workspace target is missing or blocked, so the blocked-branch line is updated to match. The no-workspace-file branch is reworded for the same reason. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Make the
continual-learningplugin safe to enable inside team repositories.Today the plugin defaults to writing learned bullets into the workspace
AGENTS.mdand keeping its cadence + incremental-index state under.cursor/hooks/state/. On a shared repo both of those paths are owned byevery contributor, so:
git statusas untrackednoise (or get committed by accident).
This PR moves the defaults to user-scoped locations under
~/.cursor/projects/<workspace-slug>/— the same directory layout Cursoralready uses for
agent-transcripts/— and keeps any write inside the repostrictly opt-in.
What changes
~/.cursor/projects/<slug>/AGENTS.local.md(personal,never committed). Cursor's stacked
AGENTS.mdloading picks it upautomatically.
~/.cursor/projects/<slug>/continual-learning/withcadence.json(hook state) andindex.json(incremental index).CONTINUAL_LEARNING_WORKSPACE_FILE. If set,the hook runs
git check-ignoreagainst it and refuses to write when thefile is inside a git repo and not gitignored. The check can be bypassed
with
CONTINUAL_LEARNING_ALLOW_SHARED=1.## Learned User Preferences→ user file only.## Learned Workspace Facts→ workspace file when configured and notblocked.
## Learned Workspace Facts (local)→ user file fallback headingwhen no workspace file is configured or the workspace file is blocked.
followup_messageso theagents-memory-updatersubagent gets concrete absolute paths and theblock reason (if any) instead of having to recompute them.
.cursor/hooks/state/continual-learning{,-index}.jsoninto the newuser-scoped location, keeps a backup under the user state dir, and
removes the originals so they stop appearing in
git status.CONTINUAL_LEARNING_USER_FILE,CONTINUAL_LEARNING_WORKSPACE_FILE,CONTINUAL_LEARNING_STATE_DIR,CONTINUAL_LEARNING_ALLOW_SHARED. Existing cadence vars and legacyCONTINUOUS_LEARNING_*aliases are unchanged.Files
continual-learning/hooks/continual-learning-stop.ts— use resolvedtargets for state paths; build a structured followup message; migrate
legacy state once on startup.
continual-learning/hooks/lib/memory-targets.ts(new) — slugcomputation, env-driven path resolution,
git check-ignoresafety check,legacy-state migration. ~180 lines, no new dependencies (
node:fs,node:os,node:path,node:child_processonly).continual-learning/agents/agents-memory-updater.md— describe thedual-target write model, the section-routing rules, the safety check, and
the local-fallback heading. Prefers the embedded paths from the hook when
present.
continual-learning/skills/continual-learning/SKILL.md— header wordingupdated; orchestration unchanged.
continual-learning/README.md— new "Safe defaults for team repos" andexpanded configuration sections.
continual-learning/CHANGELOG.md(new) —Unreleasedentry followingthe format used by sibling plugins.
Backwards compatibility
AGENTS.mdto~/.cursor/projects/<slug>/AGENTS.local.md. Existing users who relied onthe old behavior can restore it by setting
CONTINUAL_LEARNING_WORKSPACE_FILE=<absolute path to AGENTS.md>andCONTINUAL_LEARNING_ALLOW_SHARED=1.CONTINUAL_LEARNING_MIN_TURNS, trial mode flags,the
CONTINUOUS_LEARNING_*legacy aliases) keep their current meaning..cursor/hooks/state/are migratedautomatically on the next hook run.
Test plan
node scripts/validate-plugins.mjs— passes (no manifest changes).bun build continual-learning/hooks/continual-learning-stop.ts—bundles cleanly.
{}and does nottrigger the followup.
contains the resolved user file path and routes workspace facts to
the user file under
## Learned Workspace Facts (local).CONTINUAL_LEARNING_WORKSPACE_FILEpointing at atracked file — followup message marks the workspace target as
BLOCKEDwith the git-leak reason and routes workspace facts to theuser file under
## Learned Workspace Facts (local).CONTINUAL_LEARNING_ALLOW_SHARED=1— followupmessage labels the workspace target as
shared, may be committedandallows the write.
.cursor/hooks/state/files — files are moved to the user-scopedlocation, a backup is left there, and the originals are removed from
git status.Made with Cursor