-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add global (cross-project) memories support #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add global (cross-project) memories support #1007
Conversation
Extend Serena's memory system to support global memories stored in
~/.serena/memories/, in addition to existing project-scoped memories.
Key changes:
- Add scope parameter ("project"|"global") to all 5 memory tools
(write, read, list, delete, edit), defaulting to "project"
- ListMemoriesTool also supports scope="all" to show both scopes
- Add GlobalMemoriesManager to SerenaAgent (MemoriesManager pointed
at SerenaPaths().serena_user_home_dir)
- Add _get_memories_manager_for_scope() helper to Component
- Mark memory tools with ToolMarkerDoesNotRequireActiveProject so
global memories work without an active project
- Add edit_memory() method to MemoriesManager, decoupling memory
editing from ReplaceContentTool/CodeEditor/project
- Make save_memory() use atomic writes (write to .tmp then os.replace)
- Include global memories in system prompt and dashboard config overview
- Update dashboard memory endpoints to support scope parameter
Fully backward-compatible: all defaults remain scope="project".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace hand-rolled .md.tmp sibling file with tempfile.mkstemp(dir=...) for proper temp file handling. Uses the same directory to keep os.replace() atomic (same filesystem), with cleanup on failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MemoriesManager.__init__ passes project_root through get_serena_managed_in_project_dir() which appends .serena. When the global manager was given SerenaPaths().serena_user_home_dir (~/.serena) as its root, the memory dir became ~/.serena/.serena/memories/. Add optional memory_dir kwarg to MemoriesManager to allow passing the directory directly, bypassing the project-root path construction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The memories section now displays project and global memories in separate sub-sections with scope labels. All CRUD operations (create, read, edit, delete) pass the scope parameter to the API. Scope badges in modals indicate which scope is being operated on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
failing tests are also failing on main, no new failures introduced by this PR. I'm interested in trying to help with those as a separate issue, but don't have time to get to them in the next few days. do let me know if there are questions about this PR and the feature request issue i created. i'm using this change locally to help me streamline my workflow as i hop between working on different projects in parallel. i store information about my specific infrastructure, environment, and workflow requirements there, as well as instructions about how to manage my task tracker, project planning, wins tracking. saves me a lot of time, keeps me organized. highly recommend a similar approach to others. |
|
Thank you @butterflysky. Global memories are a good idea, let's bring this to Serena! There are some higher priority issues we have to address first, we will review this soon and get back to you. |
|
Thanks @MischaPanch - just want to say I'm finding Serena very helpful, so thank you for it! |
Summary
Closes #1006
~/.serena/memories/, shared across all projectsscopeparameter ("project"|"global", default"project")list_memoriesalso supportsscope="all"→{"project": [...], "global": [...]}ToolMarkerDoesNotRequireActiveProject)edit_memory()method toMemoriesManager, decoupling fromReplaceContentTool/CodeEditorsave_memory()use atomic writes (write-to-tmp+os.replace())scopeparameter to the API.scope="project"Test plan
list_memories()returns project memories only (backward compatible)list_memories(scope="all")returns{"project": [...], "global": [...]}write_memory("test", "hello", scope="global")creates file in~/.serena/memories/read_memory("test", scope="global")reads from global storeedit_memory("test", "hello", "world", mode="literal", scope="global")worksdelete_memory("test", scope="global")removes global memoryscope="project"preserves existing behavior🤖 Generated with Claude Code