Repository navigation
Description
Summary
All memories live in one global store (~/.config/opencode/memory), and nothing records which repo a memory came from. Every read path that feeds the model scores or lists all active memories, so knowledge from one project is injected into sessions in unrelated projects.
This is probably just an oversight rather than a design choice, and sharing is often convenient: preferences and general tooling habits should follow you between projects. It becomes a problem when projects are meant to stay separate, for example different clients, work vs. personal, or a fork next to its upstream. Then one repo's commands, decisions and open threads surface as "durable memory" somewhere they don't belong.
Reproduction
- In repo A, have the agent store:
memory_remember type=pattern scope=billing-service content="Staging deploys require the VPN and make deploy-staging" - Open opencode in an unrelated repo B and ask: "how do I deploy to staging?"
- The system prompt for repo B now contains:
## Relevant durable memory - [2026-10-21] pattern/billing-service: Staging deploys require the VPN and make deploy-staging
The agent in repo B now has repo A's deploy steps as "durable memory" and may follow them.
Where
At commit 2674b54, every one of these reads from loadAll() with no repo filter:
relevantKnowledge()– per-epoch injectioncontextualPull()– memories appended to grep/glob/read resultssystemDigest()– memory count, plus the open-thread "frontier", which surfaces open threads from other projectscompactionAnchor()– the summarizer is told to preserve the newest memories "verbatim", whichever repo they came frommemory_recallwith no filters returns the most recent memories from all repos
/repo-init scopes its memories by basename(root), so two checkouts with the same folder name (e.g. api, or a fork next to its upstream) share init stamps and script memories too.
Expected
Memories written in a repo are visible only in that repo by default, with an explicit way to mark a memory as cross-project (user preferences, global tooling habits).
Suggested approach
- Record a
repo=field on every row at write time: the git toplevel path, or a hash of the origin remote URL so it survives re-clones. - Filter injection, pull, digest, compaction anchor and default recall to
repo == current || repo == global. - Let
memory_remembertakeglobal: true(or a reservedglobalscope) for cross-project memories;preferencemight default to global. - Treat existing rows without
repo=as global, so upgrading is non-breaking, and add a one-time helper in the viewer to assign them to a repo. - Use the same repo key for
/repo-initinstead ofbasename(root).
Happy to send a PR if this direction works for you.
Activity
chore: drop the security review doc from this branch
Merge pull request #29 from abogartz/feat/repo-scoping
chore(release): 0.4.0 [skip ci]
feat(scope): repo-stamp every memory; model-facing reads are repo-local