Skip to content

Cursor plugin: project_id resolves to the plugin cache folder hash (all workspaces share one app_id) #7614

Open

Description

@marcvertalier-stack

Where: mem0 Cursor plugin (cursor-public/mem0), hooks in hooks/cursor-hooks.json.

What happens: In Cursor, hook commands run with the plugin cache folder as working directory, and the hook input JSON has no cwd field (Cursor sends workspace_roots). As a result:

  • _project.sh resolves the project from $PWD, i.e. the plugin cache folder, so project_id becomes its name (e.g. 965140eb190bf390979d41bb6ffff12c0b02e70b);
  • scripts that read .cwd // "." from the input (on_file_read*.sh, on_session_start.sh) get ..

Every Cursor workspace therefore reads and writes memories under the same app_id, and ~/.mem0/project_map.json ends up with a "." key mapped to that hash. ~/.mem0/hooks.log shows e.g. Auto-import started: cwd=. git_root=(none) project=965140eb….

Expected: project_id is the opened workspace (git remote slug or project_map entry), as in Claude Code.

Suggested fix: in the Cursor wrappers, resolve the workspace as .cwd // .workspace_roots[0] from the hook input, cd into it and set .cwd before calling the shared scripts. A local wrapper doing exactly this fixes it for me:

INPUT=$(cat)
ROOT=$(printf "%s" "$INPUT" | jq -r ".cwd // .workspace_roots[0] // empty")
if [ -n "$ROOT" ] && [ -d "$ROOT" ]; then
  cd "$ROOT"
  INPUT=$(printf "%s" "$INPUT" | jq -c --arg r "$ROOT" ".cwd = \$r")
fi
printf "%s" "$INPUT" | "$@"

Related (minor): the preToolUse Read hook searches memories with the file path as the query; with few memories it injects the same unrelated results on every file read (scores 0.5–0.6 above the 0.3 threshold). An option to disable it in ~/.mem0/settings.json would help.

Environment: macOS (arm64), Cursor with the mem0 plugin from the Cursor marketplace (cache folder 965140e…).

Activity

  1. added
    integrationsAgent and editor integrations
    pluginEditor and agent plugins (Claude Code, Cursor, Codex, OpenClaw, Pi Agent)
    on Oct 12, 2026
  2. manish-9245 commented on Oct 13, 2026

    @manish-9245

    I'd like to work on this — resolving the project from workspace_roots in the hook input instead of $PWD (plugin cache folder) in the Cursor hooks. I'll dig in and open a PR.

  3. marcvertalier-stack commented on Oct 15, 2026

    @marcvertalier-stack
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    integrationsAgent and editor integrationspluginEditor and agent plugins (Claude Code, Cursor, Codex, OpenClaw, Pi Agent)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions