pi-supermemory
v0.1.0
Published
Persistent memory extension for Pi coding agent - remember context across sessions using SuperMemory
Maintainers
Readme
🧠 Pi SuperMemory Extension
Persistent memory for Pi - the AI coding agent that remembers context across sessions using SuperMemory.
Note: This extension is compatible with SuperMemory SDK v2. API parameters have changed from earlier versions (containerTag instead of containerTags, limit instead of topK, q instead of context, forget instead of delete).
Overview
This extension gives Pi long-term memory capabilities, allowing it to:
- Remember user preferences across all projects (coding style, favorite tools, etc.)
- Maintain project context between sessions (architecture decisions, pending tasks)
- Learn from conversations and recall relevant information when needed
- Build a user profile that accumulates facts about you over time
Features
🔄 Automatic Context Injection
- Relevant memories are automatically injected into prompts based on semantic similarity
- No manual searching required - memories surface when they're needed
🎯 Two Memory Scopes
- User scope: Cross-project knowledge that follows you everywhere
- Project scope: Project-specific knowledge tied to the current directory
🤖 LLM Tool Access
The supermemory tool gives the AI direct access to:
add- Store new memories with type classificationsearch- Find relevant memories by queryprofile- View accumulated user profilelist- Browse recent memoriesforget- Delete specific memories
⌨️ Slash Commands
/remember <text>- Quick-save something to memory/recall <query>- Search your memories/memory-profile- View your user profile
💾 Automatic Conversation Capture
Conversations are automatically stored (when substantial) for future reference.
Installation
Prerequisites
Get a SuperMemory API key:
- Sign up at supermemory.ai
- Generate an API key from your dashboard
Set environment variables:
export SUPERMEMORY_API_KEY="your-api-key-here" # Optional: customize container prefix (default: "pi") export SUPERMEMORY_CONTAINER="myorg"
Install the Extension
# In your Pi extensions directory (usually ~/.pi/agent/extensions/)
cd ~/.pi/agent/extensions/
# Clone or copy this extension
git clone https://github.com/dan/pi-supermemory.git supermemory
# Install dependencies
cd supermemory
npm installVerify Installation
Start Pi and look for the 🧠 indicator in the status bar, or check that no "SUPERMEMORY_API_KEY not set" warning appears.
Usage
Let the AI Remember Things
Simply tell Pi to remember something:
"Remember that I prefer 2-space indentation in TypeScript" "Save this for later - the database connection string is..." "Remember this project uses a monorepo structure"
The AI will use the supermemory tool to store this information with the appropriate scope and type.
Manual Commands
# Quick save
/remember I always use pnpm instead of npm
# Search memories
/recall database schema
# View your profile
/memory-profileMemory Types
When storing memories, they can be classified as:
| Type | Description |
|------|-------------|
| preference | Personal preferences (coding style, tools, etc.) |
| project-config | Project configuration details |
| architecture | System design and architecture decisions |
| error-solution | Solutions to problems you've encountered |
| learned-pattern | General patterns and insights |
| conversation | Automatically captured conversations |
Memory Scopes
user: Available across all projects (good for personal preferences)project: Only available in the current project directory (default)
Configuration
Environment Variables
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| SUPERMEMORY_API_KEY | Yes | - | Your SuperMemory API key |
| SUPERMEMORY_CONTAINER | No | pi | Prefix for container tags |
How Container Tags Work
The extension uses container tags to organize memories:
- User memories:
{SUPERMEMORY_CONTAINER}_user_{username} - Project memories:
{SUPERMEMORY_CONTAINER}_project_{project_name}
This keeps different users' and projects' memories separate.
API Reference
Tool: supermemory
The LLM can call this tool with the following parameters:
{
mode: "add" | "search" | "profile" | "list" | "forget" | "help",
content?: string, // For "add" mode
query?: string, // For "search" or "profile" modes
type?: MemoryType, // For "add" mode
scope?: "user" | "project", // For "add", "search", "list" modes
memoryId?: string, // For "forget" mode
limit?: number // For "search" and "list" modes
}Note: The SuperMemory SDK v2 API uses containerTag (singular), limit (instead of topK), and q (instead of context). This extension has been updated to match the latest SDK.
Example Tool Calls
// Store a preference
{ mode: "add", content: "Prefers dark mode themes", type: "preference", scope: "user" }
// Search for relevant memories
{ mode: "search", query: "database connection", scope: "project", limit: 5 }
// View user profile
{ mode: "profile", query: "coding preferences" }
// List recent memories
{ mode: "list", scope: "project", limit: 10 }
// Forget a memory
{ mode: "forget", memoryId: "mem_abc123", scope: "project" }Architecture
The extension works by:
Before each agent turn: Searches SuperMemory for context relevant to the user's prompt, injects matching memories into the system prompt
After each agent turn: Captures the conversation text and stores it in project scope for future reference
During tool execution: Provides the LLM with tools to actively manage memory (add, search, delete)
On session start: Shows a 🧠 status indicator when memory is active
Development
# Clone the repo
git clone https://github.com/dan/pi-supermemory.git
cd pi-supermemory
# Install dependencies
npm install
# Link for local development
npm link
# In Pi extensions directory
npm link pi-supermemoryTroubleshooting
"SUPERMEMORY_API_KEY not set - extension disabled"
- Make sure you've set the
SUPERMEMORY_API_KEYenvironment variable - Restart Pi after setting environment variables
Memories not appearing
- Check that the SuperMemory API key is valid
- Verify network connectivity to supermemory.ai
- Check Pi's console for error messages
Wrong project scope
- The project scope is derived from the current working directory name
- Make sure you're in the correct project directory
Related
- Pi Coding Agent - The AI coding agent this extension is for
- SuperMemory - The memory service powering this extension
License
MIT
Contributing
Contributions welcome! Please open an issue or PR on GitHub.
