Skip to content

feat(memories): store memories in markdown#232

Merged
remarkablemark merged 7 commits into
masterfrom
feat/memories
Jul 11, 2026
Merged

feat(memories): store memories in markdown#232
remarkablemark merged 7 commits into
masterfrom
feat/memories

Conversation

@remarkablemark

@remarkablemark remarkablemark commented Jul 11, 2026

Copy link
Copy Markdown
Member

What is the motivation for this pull request?

Feature addition: a local, inspectable memory system that persists context across sessions using Markdown files under ~/.code-ollama/memories/.

plan.md

What is the current behavior?

No persistent memory — context is lost between sessions.

What is the new behavior?

  • Memories are stored as Markdown files:
    ~/.code-ollama/memories/
      global/
        MEMORY.md
      projects/
        <project-slug>-<hash>/
          MEMORY.md
          metadata.json
    
  • Project memory ID is derived from the normalized git remote URL (falls back to git root path), using a readable slug plus a 12-character hash.
  • Global and project MEMORY.md are loaded into the system prompt (capped at 200 lines / 25 KB each).
  • A /memory command group is added to the TUI:
    • /memory show — display loaded global and project memory contents
    • /memory add <text> — append a bullet to the project MEMORY.md
    • /memory add --global <text> — append a bullet to global MEMORY.md
    • /memory path — show the active memory directory and files
  • Memory files are created lazily on first write.

Checklist:

Add a local, inspectable memory system for `code-ollama` using Markdown files under `~/.code-ollama/memories/`. Start with manual memory only; no automatic saving, no database, and no semantic retrieval in v1.

---

Changes

- Add memory storage under:

  ```text
  ~/.code-ollama/memories/
    global/
      MEMORY.md
    projects/
      <project-slug>-<hash>/
        MEMORY.md
        metadata.json
  ```

- Derive project memory ID from the normalized git remote URL when available; fall back to the git root absolute path. Use a readable slug plus a 12-character hash.
- Load bounded memory into the system prompt:
  - global `MEMORY.md`
  - current project `MEMORY.md`
  - cap each at first 200 lines or 25KB, whichever comes first.
- Treat `MEMORY.md` as a concise startup summary plus table of contents to relative topic files.
- Do not automatically load topic files like `debugging.md` or `conventions.md`; the agent may read them with normal file tools when relevant.

---

CLI/TUI Behavior

- Add a `/memory` command group:
  - `/memory show` displays loaded global and project memory.
  - `/memory add <text>` appends a bullet to the project `MEMORY.md`.
  - `/memory add --global <text>` appends a bullet to global `MEMORY.md`.
  - `/memory edit` opens or prints the project memory path, depending on existing editor behavior in the app.
  - `/memory path` shows the active memory directory and files.
- If memory files do not exist, create them lazily on first write.
- Do not save secrets, transient branch facts, command transcripts, or speculative conclusions unless the user explicitly adds them.

---

Implementation Notes

- Add a `src/utils/memory.ts` module for:
  - project ID derivation
  - memory path resolution
  - bounded Markdown reads
  - append operations
  - metadata creation
- Update system prompt construction in `src/utils/agents.ts` to include loaded memory after `AGENTS.md` and before skills.
- Add memory command handling alongside existing slash-command/menu handling, following current TUI command patterns.
- Keep the config shape minimal; no config required for v1 unless memory needs a disable flag already matching existing config style.
Now command suggestions behave like this:

- `Tab` completes the highlighted suggestion into the input.
  - `/mo` + Tab -> `/models`
  - `/mem` + Tab -> `/memory`
  - `/memory a` + Tab -> `/memory add`
- `Enter` submits/runs the highlighted command when it is executable.
- File/model suggestions keep their old behavior because the new Tab completion path is opt-in for
  command suggestions.
- If command suggestions are visible, raw text submission backs off.
- The selected suggestion submits instead.
- `handleSubmitCommand` now accepts memory subcommands like `/memory path`,
  not just top-level commands.
Now command-specific validity lives next to command suggestions in `CommandMenu.tsx`:

- `getMatchingCommands(input)`
- `isSubmittableCommand(value)`
- `MEMORY_COMMANDS`

`ChatInput` only asks those helpers whether suggestions exist or whether the command is
submittable. It no longer knows memory subcommand grammar directly.
`/memory show` should show contents only; `/memory path` is for locations.
@remarkablemark remarkablemark self-assigned this Jul 11, 2026
@remarkablemark remarkablemark added the enhancement New feature or request label Jul 11, 2026
Comment thread src/utils/memory.ts Dismissed
Comment thread src/utils/memory.ts Dismissed
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/components/Chat/Chat.tsx 100.00% <100.00%> (ø)
src/components/Chat/ChatInput.tsx 100.00% <100.00%> (ø)
src/components/Chat/CommandMenu.tsx 100.00% <100.00%> (ø)
src/components/Messages/Message.tsx 100.00% <100.00%> (ø)
src/components/Messages/Messages.tsx 100.00% <100.00%> (ø)
src/components/Suggestions/Suggestions.tsx 100.00% <100.00%> (ø)
src/components/TextInput/TextInput.tsx 100.00% <ø> (ø)
src/constants/command.ts 100.00% <ø> (ø)
src/utils/agents.ts 100.00% <100.00%> (ø)
src/utils/memory.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remarkablemark remarkablemark merged commit d0683ae into master Jul 11, 2026
16 checks passed
@remarkablemark remarkablemark deleted the feat/memories branch July 11, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants