Add file-backed durable memory tools

This commit is contained in:
Adolfo Reyna
2026-05-15 15:07:40 -04:00
parent b02ef0b455
commit d791b2495f
4 changed files with 202 additions and 0 deletions

View File

@@ -7,10 +7,12 @@ keep the core small, make the seams obvious, and add capability through tools.
- `src/agent.ts` — the agent loop
- `src/model/openai.ts` — the OpenAI Responses API adapter
- `src/memory.ts` — file-backed durable memory
- `src/events.ts` — typed lifecycle events
- `src/commands.ts` — slash-command registry
- `src/tools/registry.ts` — tool registration and lookup
- `src/tools/builtins.ts` — two read-only built-in tools
- `src/tools/memory.ts` — memory tools backed by markdown files
- `src/extensions.ts` — project-local extension loader
- `src/logger.ts` — ordered lifecycle logging
- `extensions/example.ts` — an example extension that registers `echo`
@@ -108,6 +110,7 @@ The core provides:
- `/reset` — clear the current conversation history
- `/save` — persist the current conversation immediately
- `/logs [on|off]` — toggle lifecycle traces
- `/memory` — inspect durable memory files
- `/exit` — leave the interactive session
Extensions can register their own commands.
@@ -123,6 +126,32 @@ You are a helpful agent. Use tools when they are useful, and answer clearly.
Override it with the `SYSTEM_PROMPT` environment variable. Extensions can also
append fragments to the final system prompt with `addSystemPrompt(...)`.
## Durable memory
The harness keeps long-lived memory in simple markdown files:
```text
.harness/memory/
MEMORY.md
USER.md
daily/
YYYY-MM-DD.md
```
The model can choose to use:
- `memory_read` — read `MEMORY.md` or `USER.md`
- `memory_write` — append durable facts or user preferences
- `memory_log` — append chronological notes to today's daily file
The split is intentional:
- `MEMORY.md` — durable project or world facts
- `USER.md` — user preferences and profile
- `daily/` — episodic notes that are useful as chronology rather than permanent truth
These files are plain markdown so they remain inspectable and easy to edit by hand.
That gives us a clean path to later add:
- more providers