Source: Source pull request number: 929 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: fix: scope git worktrees to shared project id
Author: wbugitlab1
State: closed
Draft: no
Merged: no
Head: wbugitlab1/agentmemory:fix/worktree-project-scope @ c234cbd
Base: main @ f6f9e3c
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-06-14T02:51:35Z
Updated: 2026-06-14T15:27:17Z
Closed: 2026-06-14T15:27:17Z
Merged at: (not merged)
Original PR body:
Summary
- resolve project scope through a canonical git project id instead of raw cwd path
- make linked worktrees for the same repository share the same
git:<hash> project scope
- preserve explicit
AGENTMEMORY_PROJECT_ID / AGENTMEMORY_PROJECT_NAME overrides and non-git basename fallback
- expose optional project arguments through MCP/REST memory operations
Verification
npm run build passed
npm run skills:check passed
npx vitest run test/worktree-project-scope.test.ts test/hook-project.test.ts test/api-memories-project.test.ts test/mcp-project-scope.test.ts test/pre-tool-use-project.test.ts test/remember-project-scope.test.ts test/mcp-standalone.test.ts test/mcp-standalone-proxy.test.ts passed: 8 files, 72 tests
gitleaks protect --staged --redact passed
gitleaks detect --source . --log-opts 'origin/main..HEAD' --redact passed
git diff --name-only origin/main..HEAD | xargs semgrep scan --config p/default --error --metrics=off passed: 30 files, 0 findings
git diff --check origin/main..HEAD passed
Notes
- Full
npm test currently has unrelated local failures in test/fs-watcher.test.ts; this file is not touched by this PR. Other first-run timeout failures passed when rerun in isolation.
- Full repo
semgrep scan --config p/default --error --metrics=off . reports existing findings outside this PR diff.
- Full history
gitleaks detect --source . --redact reports one historical finding; the PR commit itself is clean.
Manual smoke
A local build of this change was tested with two linked worktrees for the same repo. Hook-generated sessions from both worktrees resolved to the same project id:
/Users/A1538552/_projects/_tools/agentmemory -> git:c578c496c2ba2535ab6a51797c014666
/Users/A1538552/.codex/worktrees/aba6/agentmemory -> git:c578c496c2ba2535ab6a51797c014666
Summary by CodeRabbit
Release Notes
-
New Features
- Memories can be scoped to projects via
AGENTMEMORY_PROJECT_ID (preferred) or AGENTMEMORY_PROJECT_NAME.
- Added optional
project parameter to memory_recall and smart search tools.
- The memories API now supports
project filtering with includeUnscoped.
-
Improvements
- Project scoping is now more consistent across Git worktrees;
cwd is normalized in event payloads.
- Project info is no longer exposed in “Memory saved” logging.
-
Documentation
- Updated environment and tool references to include
AGENTMEMORY_PROJECT_ID and the new project parameter.
-
Tests
- Added/expanded coverage for project scoping, filtering, and worktree behavior.
Local branch:
Fork PR:
Fork decision:
Verification:
Notes:
Source: Source pull request number: 929 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: fix: scope git worktrees to shared project id
Author: wbugitlab1
State: closed
Draft: no
Merged: no
Head: wbugitlab1/agentmemory:fix/worktree-project-scope @ c234cbd
Base: main @ f6f9e3c
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-06-14T02:51:35Z
Updated: 2026-06-14T15:27:17Z
Closed: 2026-06-14T15:27:17Z
Merged at: (not merged)
Original PR body:
Summary
git:<hash>project scopeAGENTMEMORY_PROJECT_ID/AGENTMEMORY_PROJECT_NAMEoverrides and non-git basename fallbackVerification
npm run buildpassednpm run skills:checkpassednpx vitest run test/worktree-project-scope.test.ts test/hook-project.test.ts test/api-memories-project.test.ts test/mcp-project-scope.test.ts test/pre-tool-use-project.test.ts test/remember-project-scope.test.ts test/mcp-standalone.test.ts test/mcp-standalone-proxy.test.tspassed: 8 files, 72 testsgitleaks protect --staged --redactpassedgitleaks detect --source . --log-opts 'origin/main..HEAD' --redactpassedgit diff --name-only origin/main..HEAD | xargs semgrep scan --config p/default --error --metrics=offpassed: 30 files, 0 findingsgit diff --check origin/main..HEADpassedNotes
npm testcurrently has unrelated local failures intest/fs-watcher.test.ts; this file is not touched by this PR. Other first-run timeout failures passed when rerun in isolation.semgrep scan --config p/default --error --metrics=off .reports existing findings outside this PR diff.gitleaks detect --source . --redactreports one historical finding; the PR commit itself is clean.Manual smoke
A local build of this change was tested with two linked worktrees for the same repo. Hook-generated sessions from both worktrees resolved to the same project id:
Summary by CodeRabbit
Release Notes
New Features
AGENTMEMORY_PROJECT_ID(preferred) orAGENTMEMORY_PROJECT_NAME.projectparameter tomemory_recalland smart search tools.projectfiltering withincludeUnscoped.Improvements
cwdis normalized in event payloads.Documentation
AGENTMEMORY_PROJECT_IDand the newprojectparameter.Tests
Local branch:
Fork PR:
Fork decision:
Verification:
Notes: