Problem
When working in repo A (e.g., greenroom) but editing files in repo B (e.g., opencode-mem), memories get tagged with the cwd project (A) instead of the actual project being worked on (B).
Proposed Solution: File Path Heuristics
Track which repo's files are touched during a session and use that to determine the actual project:
- Extract all file paths from
tool.execute.after events (read/write/edit tools)
- Group by git repo root (find nearest
.git parent)
- If dominant repo ≠ cwd, update session's project to dominant repo
Why this approach?
- Reliable signal - File operations are concrete actions, not ambiguous text
- Already available - We capture
tool.execute.after events with file paths
- Low complexity - Count paths and pick the dominant repo
- Works across languages/topics - Doesn't depend on naming conventions
Alternative considered: Keyword analysis
- Scan prompts for project-specific keywords
- Rejected: too ambiguous, needs keyword list maintenance, false positives when discussing other projects
Implementation Location
Likely in plugin_ingest.py or during session finalization.
Context
This came up when fixing the message extraction bug while cwd was greenroom but all file edits were in opencode-mem. Had to manually SQL update 16 sessions to fix the project tag.
Problem
When working in repo A (e.g., greenroom) but editing files in repo B (e.g., opencode-mem), memories get tagged with the cwd project (A) instead of the actual project being worked on (B).
Proposed Solution: File Path Heuristics
Track which repo's files are touched during a session and use that to determine the actual project:
tool.execute.afterevents (read/write/edit tools).gitparent)Why this approach?
tool.execute.afterevents with file pathsAlternative considered: Keyword analysis
Implementation Location
Likely in
plugin_ingest.pyor during session finalization.Context
This came up when fixing the message extraction bug while cwd was greenroom but all file edits were in opencode-mem. Had to manually SQL update 16 sessions to fix the project tag.