Skip to content

feat(memory): path-scoped rules + project memory write-path (#-remember)#134

Merged
oratis merged 1 commit into
mainfrom
feat/memory-rules-and-remember
May 31, 2026
Merged

feat(memory): path-scoped rules + project memory write-path (#-remember)#134
oratis merged 1 commit into
mainfrom
feat/memory-rules-and-remember

Conversation

@oratis
Copy link
Copy Markdown
Owner

@oratis oratis commented May 31, 2026

Summary

Closes two §3.6a memory gaps from the audit.

Path-scoped rules.deepcode/rules/*.md were loaded flat with no scope info. Now each rule's frontmatter globs (or applyTo/paths) is surfaced in its injected header — # rule: ts.md (applies to: src/**/*.ts, test/**) — so the model applies it only when editing matching files, and the frontmatter fence is stripped from the body.

Agent/user memory write-path — there was a read path but nothing ever wrote project memory (the "# to remember" in /help was aspirational):

  • projectMemoryKey(cwd) / projectMemoryPath(home,cwd)~/.deepcode/projects/<slug>/memory/MEMORY.md (mirrors the harness layout).
  • rememberFact(cwd, fact) appends a bullet (writes a header on first write).
  • loadMemory now reads that project-memory file too (step 1b, after user memory).
  • REPL: a #<text> line remembers the fact (no agent turn) — the documented shortcut, now real.

Tests

+2 (loader.test.ts): rule glob annotation + frontmatter strip; rememberFactloadMemory round-trip (both facts present, header written once). Core suite 608 green.

Note

Path-scoping is annotation-based (the scope is declared + visible to the model) rather than hard filtering — a CLI agent doesn't know the "active file" at memory-load time, and globbing the whole tree per launch would be costly. This matches how an LLM-driven agent self-applies scoped rules.

🤖 Generated with Claude Code

Two §3.6a gaps from the audit:

Path-scoped rules: `.deepcode/rules/*.md` were dumped flat. Now each rule's
frontmatter `globs` (or `applyTo`/`paths`) is surfaced in its injected header
("rule: ts.md (applies to: src/**/*.ts)") so the model applies it only when
editing matching files, and the frontmatter fence is stripped from the body.

Agent/user memory write-path: there was a read path but nothing wrote it (the
"# to remember" help was aspirational).
- projectMemoryKey(cwd) / projectMemoryPath(home,cwd) →
  ~/.deepcode/projects/<slug>/memory/MEMORY.md (mirrors the harness layout).
- rememberFact(cwd, fact) appends a bullet (writes a header on first use).
- loadMemory now READS that project-memory file too (step 1b).
- REPL: a `#<text>` line remembers the fact (no agent turn) — the documented
  shortcut, now real.

Tests: +2 (rule glob annotation + frontmatter strip; rememberFact → loadMemory
round-trip with single header). Core 608 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit 906cd8b into main May 31, 2026
3 checks passed
@oratis oratis deleted the feat/memory-rules-and-remember branch May 31, 2026 15:28
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.

1 participant