Skip to content

continual-learning: write to user-scoped memory file by default#74

Open
yuranich wants to merge 2 commits into
cursor:mainfrom
yuranich:feat/continual-learning-user-scoped-memory
Open

continual-learning: write to user-scoped memory file by default#74
yuranich wants to merge 2 commits into
cursor:mainfrom
yuranich:feat/continual-learning-user-scoped-memory

Conversation

@yuranich
Copy link
Copy Markdown

@yuranich yuranich commented May 23, 2026

Summary

Make the continual-learning plugin safe to enable inside team repositories.

Today the plugin defaults to writing learned bullets into the workspace
AGENTS.md and keeping its cadence + incremental-index state under
.cursor/hooks/state/. On a shared repo both of those paths are owned by
every contributor, so:

  • personal preferences end up committed into the team's instructions, and
  • the two state JSON files permanently show up in git status as untracked
    noise (or get committed by accident).

This PR moves the defaults to user-scoped locations under
~/.cursor/projects/<workspace-slug>/ — the same directory layout Cursor
already uses for agent-transcripts/ — and keeps any write inside the repo
strictly opt-in.

What changes

  • New defaults
    • Memory file: ~/.cursor/projects/<slug>/AGENTS.local.md (personal,
      never committed). Cursor's stacked AGENTS.md loading picks it up
      automatically.
    • State dir: ~/.cursor/projects/<slug>/continual-learning/ with
      cadence.json (hook state) and index.json (incremental index).
  • Opt-in shared file via CONTINUAL_LEARNING_WORKSPACE_FILE. If set,
    the hook runs git check-ignore against it and refuses to write when the
    file is inside a git repo and not gitignored. The check can be bypassed
    with CONTINUAL_LEARNING_ALLOW_SHARED=1.
  • Explicit section routing
    • ## Learned User Preferences → user file only.
    • ## Learned Workspace Facts → workspace file when configured and not
      blocked.
    • ## Learned Workspace Facts (local) → user file fallback heading
      when no workspace file is configured or the workspace file is blocked.
  • Hook embeds resolved paths in followup_message so the
    agents-memory-updater subagent gets concrete absolute paths and the
    block reason (if any) instead of having to recompute them.
  • First-run migration copies any pre-existing
    .cursor/hooks/state/continual-learning{,-index}.json into the new
    user-scoped location, keeps a backup under the user state dir, and
    removes the originals so they stop appearing in git status.
  • New env vars (all optional): CONTINUAL_LEARNING_USER_FILE,
    CONTINUAL_LEARNING_WORKSPACE_FILE, CONTINUAL_LEARNING_STATE_DIR,
    CONTINUAL_LEARNING_ALLOW_SHARED. Existing cadence vars and legacy
    CONTINUOUS_LEARNING_* aliases are unchanged.

Files

  • continual-learning/hooks/continual-learning-stop.ts — use resolved
    targets for state paths; build a structured followup message; migrate
    legacy state once on startup.
  • continual-learning/hooks/lib/memory-targets.ts (new) — slug
    computation, env-driven path resolution, git check-ignore safety check,
    legacy-state migration. ~180 lines, no new dependencies (node:fs,
    node:os, node:path, node:child_process only).
  • continual-learning/agents/agents-memory-updater.md — describe the
    dual-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 wording
    updated; orchestration unchanged.
  • continual-learning/README.md — new "Safe defaults for team repos" and
    expanded configuration sections.
  • continual-learning/CHANGELOG.md (new)Unreleased entry following
    the format used by sibling plugins.

Backwards compatibility

  • Default memory file path changes from workspace AGENTS.md to
    ~/.cursor/projects/<slug>/AGENTS.local.md. Existing users who relied on
    the old behavior can restore it by setting
    CONTINUAL_LEARNING_WORKSPACE_FILE=<absolute path to AGENTS.md> and
    CONTINUAL_LEARNING_ALLOW_SHARED=1.
  • All existing env vars (CONTINUAL_LEARNING_MIN_TURNS, trial mode flags,
    the CONTINUOUS_LEARNING_* legacy aliases) keep their current meaning.
  • Existing cadence/index files in .cursor/hooks/state/ are migrated
    automatically 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.
  • Cold run (no transcript advance) — hook outputs {} and does not
    trigger the followup.
  • Forced trigger with no workspace file configured — followup message
    contains the resolved user file path and routes workspace facts to
    the user file under ## Learned Workspace Facts (local).
  • Forced trigger with CONTINUAL_LEARNING_WORKSPACE_FILE pointing at a
    tracked file — followup message marks the workspace target as
    BLOCKED with the git-leak reason and routes workspace facts to the
    user file under ## Learned Workspace Facts (local).
  • Same scenario with CONTINUAL_LEARNING_ALLOW_SHARED=1 — followup
    message labels the workspace target as shared, may be committed and
    allows the write.
  • First-run migration on a workspace that has the old
    .cursor/hooks/state/ files — files are moved to the user-scoped
    location, a backup is left there, and the originals are removed from
    git status.

Made with Cursor

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>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 8039a82. Configure here.

Comment thread continual-learning/hooks/continual-learning-stop.ts
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>
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