index.ts: the entire pi extension (single-file, TypeScript loaded directly bypi)test/e2e.ts: end-to-end tests that invokepias a subprocessREADME.md: user-facing install/usage docspackage.json: metadata + peer dependencies (provided by the pi runtime)
Runtime data lives outside the repo under ~/.pi/agent/memory/ (MEMORY.md, SCRATCHPAD.md, daily/YYYY-MM-DD.md).
- Track all work sessions by writing a short entry to the pi-memory daily log using
memory_write(target:daily). - Summaries should include what changed, files touched, and any notable decisions.
- Use the scratchpad tool for follow-ups or TODOs discovered during work.
pi -p -e ./index.ts "remember: I prefer dark mode": manual local run (print mode)pi install .(or from the parent folder:pi install ./pi-memory): install the extension into pinpm test: run the fast unit suite (bun test test/unit.test.ts; no API key, no qmd)npm run test:e2e(ornpx tsx test/e2e.ts): run E2E tests (requirespion PATH + a configured API key)npm run test:eval: run the recall-effectiveness eval (requirespi+ API key + qmd)npm run build: typecheck withtsc(--noEmit)npm run lint: lint with Biome- Optional (for
memory_search, requires Bun):command -v qmd >/dev/null 2>&1 || bun install -g https://github.com/tobi/qmd - Optional search setup:
qmd collection add ~/.pi/agent/memory --name pi-memory && qmd embed
- Keep
index.tsself-contained; avoid adding a build step unless absolutely necessary. - Match existing formatting: tabs for indentation, semicolons, and double quotes.
- Naming:
camelCasefor functions,PascalCasefor types,SCREAMING_SNAKE_CASEfor constants; tool names remainsnake_case(e.g.memory_write).
- Enforce TDD for every behavior change: follow
red -> green -> refactor. - Start by establishing a verifiable baseline: run the relevant existing tests before edits, and record the exact command + outcome in the PR/commit notes.
- Add or update a failing test first that reproduces the bug or captures the new requirement; implement code only after the test fails for the expected reason.
- Keep tests green after implementation and after any refactor; do not merge with skipped failing tests.
- Every bug fix must include a regression test that fails before the fix and passes after it.
- Tests touch
~/.pi/agent/memory/; ensure backups/restores remain intact and new tests don’t leak user data. - Prefer behavior-focused assertions (tool availability, file contents, cross-session recall). Keep timeouts generous for model latency.
- Use Conventional Commits (
feat:,fix:,docs:,chore:) and keep messages imperative. - PRs: include a short summary, exact test command(s) run, and call out any changes to on-disk memory formats or
qmdbehavior.
- Never commit real memory files or secrets. Tests assume
piis configured via environment (e.g.OPENAI_API_KEY).