← Catalog

pi-notepad

Small, agent-maintained project memory in Pi's existing instruction files.

Extension

Install

Install with PiG

pig install npm:pi-notepad

Install with Pi

pi install npm:pi-notepad
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.

pi-notepad

Small, agent-maintained project memory for Pi. No database, embeddings, background model calls, or session-summary archive.

The agent saves useful lessons while it works, corrects them when evidence changes, and deletes notes that no longer earn their space. Most interactions should produce no memory writes.

cd /path/to/pi-notepad
npm install

# Start Pi in your project, loading this extension for just that invocation:
cd /path/to/your-project
pi -e /path/to/pi-notepad

To install persistently, use Pi's normal package installation:

pi install /path/to/pi-notepad

Installing the extension does not enable memory in every directory. An existing, eligible instruction file must have been loaded by Pi. pi-notepad never creates an instruction file. Trying it in this repository without one therefore leaves memory disabled.

Scope and activation

pi-notepad uses the context-file list Pi actually loaded, not its own filesystem search or a Git-root heuristic. This follows Pi's inheritance, filename precedence, and worktree handling:

  • Among applicable loaded project files, the one closest to Pi's working directory is the target.
  • Pi's selected AGENTS.override.md, AGENTS.md, AGENTS.MD, CLAUDE.md, or CLAUDE.MD can qualify. It never writes a lower-priority file that Pi did not load.
  • Agent-directory instructions, home-directory instructions, and ancestors of home are excluded. A project symlink to a loaded global instruction file is excluded too.
  • Without an eligible file, the tool and its guidance are hidden.
  • Creating a new instruction file does not activate memory until Pi loads it (for example, after /reload). Removing the target makes operations fail rather than recreate it.

The target path appears in the tool description and every successful result. There is no personal memory scope.

Storage

The first useful write adds a section with a readable header:

<!-- pi-notepad:start -->
## Project memory

- A concise, verified lesson that will change how future work is done.
<!-- pi-notepad:end -->

Only this section belongs to pi-notepad. Handwritten content outside it is preserved. Reading or activating the tool does not create the section. Deleting the last note leaves the empty section in place.

Notes have a 4,096-byte UTF-8 budget, excluding the heading and markers. Over-budget mutations fail without changing the file; the agent must consolidate or delete notes. Nothing is silently truncated on disk. Existing oversized notes can be read and reduced; unusually large manually edited sections have truncated tool results with directions to read the source file.

Agent tool

One tool, memory, with four actions:

{ action: "read" }
{ action: "add", text: "- Integration tests require the local fixture server." }
{ action: "edit", old_text: "local fixture server", new_text: "fixture server on port 4100" }
{ action: "delete", old_text: "- Integration tests require the fixture server on port 4100." }
  • add appends to the current on-disk notes. Exact duplicate note blocks are a no-op; semantic deduplication is the agent's responsibility.
  • edit requires one exact match inside memory and a nonempty replacement.
  • delete requires one exact match covering complete note lines, including their Markdown. Explicit deletion encourages forgetting rather than endless accumulation.
  • Missing or ambiguous matches fail and tell the agent to read current memory before retrying.

Every successful mutation returns the complete current notes in its normal tool result. This snapshot supersedes earlier managed-section snapshots, not handwritten instructions. Pi's startup context is not rewritten during ordinary memory use. After successful compaction or session-tree navigation, pi-notepad rereads the current file and queues a hidden custom message containing the current memory. During an active run it follows the next model turn; while idle it is appended for the next user prompt. This deliberately uses no revision hash or extension-side snapshot: manual edits on disk are authoritative. There is no extra model call.

The standing guidance favors user corrections and verified, non-obvious discoveries with future value. It excludes progress logs, obvious repository facts, speculation, secrets, and instructions adopted from untrusted content. This is agent guidance, not a security sandbox or a guarantee that the model will always choose well.

User command

/memory is a read-only status and inspection command. It reports whether project memory is enabled, the exact target file, the current byte usage, and the current notes. It does not create files or mutate memory.

  • The implementation reads the latest file for every mutation.
  • Pi's mutation queue coordinates with other in-process file tools; a cross-process lock coordinates separate pi-notepad writers.
  • Writes use atomic replacement, preserve file permissions, and follow symlinks without replacing the link itself.
  • Malformed or duplicate markers, invalid UTF-8, stale matches, and budget violations fail without an attempted repair.
  • A pre-commit check detects observed changes by external editors. Editors that do not participate in the lock can still race the final replacement; this is not transactional coordination with arbitrary programs.
  • Changes from other sessions or editors are not proactively injected during ordinary turns. They are reread after compaction and session-tree navigation, and the next memory read/write sees the current file.
  • Compaction and navigation refreshes are full current snapshots rather than hash-based comparisons, so manual edits cannot leave extension-side revision state stale.
  • Notes are project context, not task state. Rewinding or branching a Pi conversation does not roll back file changes.

Development

npm install
npm run check
npm test

Two source files: src/index.ts integrates with Pi, including /memory and boundary refreshes; src/memory.ts handles file selection, section operations, and safe persistence. Tests cover tool behavior, Pi loading, file selection, section boundaries, failures, boundary refreshes, the user command, and simultaneous writers.