Skip to content

manusajith/pi-amnesia

Repository files navigation

pi-amnesia

Your agents forget everything. Amnesia remembers.

A pi extension that syncs, indexes, and analyzes session data from Claude Code, Pi, and Codex — with semantic search powered by Turso native vectors.

Features

  • /sync — Incrementally ingests new session files into Turso.
  • /analyze [focus] — Asks the active model to analyze patterns in your session history.
  • /summarize [filter] — Summarizes recent sessions grouped by project.
  • query_agent_data — A tool for structured queries, text search, semantic search, and read-only SQL.

Install

pi install git:github.com/manusajith/pi-amnesia

Setup

1. Create a Turso database

turso db create amnesia
turso db show amnesia --url
turso db tokens create amnesia

2. Set environment variables

export TURSO_URL="libsql://amnesia-<your-org>.turso.io"
export TURSO_AUTH_TOKEN="<your-token>"

3. Restart pi and sync

/sync

Embeddings

Amnesia uses OpenAI embeddings for semantic search.

By default it uses text-embedding-3-small. You can override that with:

export AMNESIA_EMBEDDING_MODEL="text-embedding-3-large"

The API key is resolved from Pi's model registry automatically, so you do not need a separate OPENAI_API_KEY when Pi already has an OpenAI provider configured.

If no OpenAI key is available, Amnesia still works — semantic search is disabled and text search remains available.

Usage

Sync sessions

/sync

Scans:

  • ~/.claude/projects/
  • ~/.pi/agent/sessions/
  • ~/.codex/archived_sessions/

Analyze patterns

/analyze
/analyze errors
/analyze tools
/analyze project my-app
/analyze last-week
/analyze agent claude last-month

Summarize sessions

/summarize
/summarize today
/summarize project my-app
/summarize last-week

Natural-language exploration

Ask things like:

  • "What tools do I use most across projects?"
  • "Find sessions where I dealt with authentication issues"
  • "Show me errors that keep recurring"
  • "What did I work on this week?"

Semantic search

When embeddings are available:

  • "Find conversations about database migrations"
  • "When did I last work on deployment pipelines?"

Data sources

Agent Location Format
Claude Code ~/.claude/projects/**/*.jsonl Messages with tool calls and sidechains
Pi ~/.pi/agent/sessions/**/*.jsonl Typed event streams
Codex ~/.codex/archived_sessions/*.jsonl Session metadata and response items

Schema

  • projects — unique project paths and extracted repo names
  • sessions — per-conversation metadata
  • messages — user/assistant/system messages with optional embeddings
  • tool_calls — tool invocations and results
  • sync_state — per-source sync watermark
  • insights — derived analysis data

Development

npm install
npm run check
npm run format

Tooling:

  • oxlint for linting
  • oxfmt for formatting
  • tsc for type-checking
  • node:test for tests

Adding adapters

To support another agent, implement SessionAdapter in extensions/amnesia/lib/adapters/ and register it in extensions/amnesia/lib/sync.ts.

import type { SessionAdapter } from "./types.ts";

export const myAdapter: SessionAdapter = {
  name: "my-agent",
  async discoverFiles(sinceMs?) {
    return [];
  },
  async parse(filePath) {
    return null;
  },
};

License

MIT

About

Cross-agent session analytics for Pi, Claude Code, and Codex with semantic search powered by Turso vectors.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors