Skip to content

Conversation

@butterflysky-ai
Copy link

@butterflysky-ai butterflysky-ai commented Feb 9, 2026

Summary

Closes #1006

  • Add global memories stored in ~/.serena/memories/, shared across all projects
  • Extend all 5 memory tools with optional scope parameter ("project" | "global", default "project")
  • list_memories also supports scope="all"{"project": [...], "global": [...]}
  • Global memories work without an active project (tools marked with ToolMarkerDoesNotRequireActiveProject)
  • Add edit_memory() method to MemoriesManager, decoupling from ReplaceContentTool/CodeEditor
  • Make save_memory() use atomic writes (write-to-tmp + os.replace())
  • Include global memories in system prompt and dashboard config overview
  • Dashboard: Show both project and global memories in separate sub-sections with scope labels, scope badges in edit/delete modals, and per-scope "Add Memory" buttons. All dashboard CRUD operations pass the scope parameter to the API.
  • Fully backward-compatible: all defaults remain scope="project"

Test plan

  • Verify list_memories() returns project memories only (backward compatible)
  • Verify list_memories(scope="all") returns {"project": [...], "global": [...]}
  • Verify write_memory("test", "hello", scope="global") creates file in ~/.serena/memories/
  • Verify read_memory("test", scope="global") reads from global store
  • Verify edit_memory("test", "hello", "world", mode="literal", scope="global") works
  • Verify delete_memory("test", scope="global") removes global memory
  • Verify global memory operations work without an active project
  • Verify default scope="project" preserves existing behavior
  • Verify system prompt lists global memories when they exist
  • Verify dashboard shows both project and global memory sections
  • Verify dashboard edit/delete/create operations pass correct scope
  • Run existing test suite — no regressions (all pre-existing test results identical)

🤖 Generated with Claude Code

butterflysky-ai and others added 4 commits February 9, 2026 00:51
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>
@butterflysky
Copy link

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.

@MischaPanch
Copy link
Contributor

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.

@butterflysky
Copy link

Thanks @MischaPanch - just want to say I'm finding Serena very helpful, so thank you for it!

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.

Add global (cross-project) memories

3 participants