@bettermemory/plugin-pi0.0.1
bettermemory for Pi: memory files, memory tools and session search as a Pi extension.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
@bettermemory/plugin-pi
bettermemory for Pi: an extension that runs inside Pi's own process and gives the agent memory that lasts between sessions.
With no config it uses the OpenClaw preset: at the start of each session Pi's system prompt gets SOUL.md, IDENTITY.md, USER.md, MEMORY.md and the recent daily notes, and the agent gets tools to write them (update_memory, update_user, memory_append, ...), search them (memory_search, memory_get) and search past Pi sessions (sessions_search). Memory lives in ~/.bettermemory/, shared by every project on the machine.
Install
Not on npm yet: until the first release, use the steps for a clone below.
pi install npm:@bettermemory/plugin-pi
That adds the package to ~/.pi/agent/settings.json, so every Pi session loads it. To add it to one project only, run it with -l (Pi writes .pi/settings.json and loads it once you trust the project). To try it for one run without installing:
pi -e npm:@bettermemory/plugin-pi
From a clone of this repo, build it and install the folder:
pnpm build
pi install ./packages/plugin-pi
Start Pi and tell it something worth remembering. In the next session it is in the system prompt, inside a <bettermemory> section.
Configure
Put a bettermemory.config.ts in the project folder. It takes the same options as betterMemory(), plus userId, and anything you leave out keeps its default:
import type { PiMemoryConfig } from "@bettermemory/plugin-pi";
import { userProfile, notes } from "@bettermemory/core";
export default {
plugins: [userProfile(), notes()],
storage: "./.bettermemory",
} satisfies PiMemoryConfig;
| Option | Default |
|---|---|
plugins |
[openclaw()] |
storage |
~/.bettermemory |
transcripts |
{ source: "harness" } (Pi's own sessions) |
budget |
10_000 characters of session-start context |
userId |
your operating-system user name |
The extension loads the file with jiti at each session_start, and loads it again when it has changed since. It reads the file only in a project you trust, since loading it runs its code; in an untrusted project it shows a warning and uses the defaults.
How it maps onto Pi
| bettermemory | Pi |
|---|---|
memory.session() |
session_start, with Pi's session id |
sessionStart() |
before_agent_start, as the bettermemory system prompt section |
turnStart() |
before_agent_start, with the prompt, as bettermemory-turn |
tools + callTool() |
pi.registerTool(), with each JSON Schema wrapped in Type.Unsafe |
turnEnd() |
turn_end, with the prompt, the assistant message and tool results |
With transcripts: { source: "harness" }, session search reads Pi's session files for the current project (~/.pi/agent/sessions/--<path>--/*.jsonl) and copies nothing.