pi
An extension for the pi coding agent that recalls memory before each run and captures sessions afterwards.
The pi extension gives pi the same memory loop as the Claude Code hooks, by calling the m3m0s binary.
- Recall (
before_agent_start): runsm3m0s hook claude-code --injectwith the prompt and appends the relevant memories as a hidden custom message. The block is fenced in<memory-context>with a note that it is recalled memory and not new user input. - Capture (
agent_end,session_shutdown): runsm3m0s hook claude-codeagainst pi’s session file. Memories are stored withsource: "pi".
Nothing is injected on compaction. Recall happens per prompt.
Install
- Install the binary and store the credentials: CLI and credentials. The extension looks for
m3m0sat~/go/bin/m3m0sfirst and then onPATH. - Install the package from npm:
pi install npm:@rafaelvieiras/m3m0s-pi
- Restart pi. Set
M3M0S_BINif the binary lives somewhere else.
Manual install
Copy the extension into pi’s extensions folder instead:
mkdir -p ~/.pi/agent/extensions
curl -fsSL https://raw.githubusercontent.com/rafaelvieiras/m3m0s/main/integrations/pi/m3m0s-memory.ts \
-o ~/.pi/agent/extensions/m3m0s-memory.ts
Then restart pi.
Optional: read-only MCP
Register the server in ~/.pi/agent/mcp.json:
{
"m3m0s": {
"command": "sh",
"args": ["-c", "set -a; . \"$HOME/.m3m0s/hook.env\"; exec m3m0s mcp --read-only"]
}
}
Troubleshooting
Failures are silent and never block pi. Read ~/.m3m0s/hooks/claude-code.log and run m3m0s doctor. If a memory from another project shows up, see Recall and tuning.