|
| 1 | +# Pi memory integration: you are never starting over |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +A fresh Pi session recovers the relevant decisions, working state, blockers, and next |
| 6 | +steps without the user repeating the previous conversation. Knowledge belongs to the |
| 7 | +user and remains usable across agents, projects, and local/cloud deployments. |
| 8 | + |
| 9 | +Ship one Pi package with two user-selectable access modes: Basic Memory CLI and an |
| 10 | +existing Pi MCP adapter. Share memory behavior and skills, not two independent memory |
| 11 | +implementations. Switching transport must not require migrating notes. |
| 12 | + |
| 13 | +## Confirmed direction |
| 14 | + |
| 15 | +- Implement under `integrations/pi/` in the Basic Memory monorepo. |
| 16 | +- Reuse canonical top-level memory skills and Basic Memory routing/authentication. |
| 17 | +- Support CLI access and MCP through an existing extension; do not build a generic MCP host. |
| 18 | +- Preserve Pi's native session history and compaction. |
| 19 | +- Distinguish lifecycle metadata, raw transcripts, and synthesized durable knowledge. |
| 20 | +- Keep project selection explicit; never change the user's global default implicitly. |
| 21 | +- Surface capture/recall failures without blocking ordinary work or claiming a save succeeded. |
| 22 | + |
| 23 | +## Phase 1 — investigate and prove transport contracts |
| 24 | + |
| 25 | +- [x] Inspect `pi-mcp-adapter` and alternatives: current Pi compatibility, tool naming, |
| 26 | + discovery, cancellation, shutdown/reload, stdio and remote support, licensing. |
| 27 | +- [x] Determine whether lifecycle hooks can invoke the adapter through a supported API. |
| 28 | + If not, document the limitation before choosing how automated recall/capture runs; |
| 29 | + do not depend on private adapter internals. |
| 30 | +- [x] Verify installed `bm` CLI flags, structured output, write error/overwrite semantics, |
| 31 | + stdin support, project UUID routing, and local/cloud behavior against real calls. |
| 32 | +- [x] Inspect existing `bm hook` recall/checkpoint implementation for reusable core logic. |
| 33 | + Its documented harnesses are Claude and Codex, not Pi. |
| 34 | +- [x] Record a short architecture decision with version requirements and initial defaults. |
| 35 | + See `docs/PI_MEMORY_TRANSPORT_DECISION.md`. |
| 36 | + |
| 37 | +## Phase 2 — smallest end-to-end continuity slice |
| 38 | + |
| 39 | +- [x] Add Pi package metadata, TypeScript extension entrypoint, config validation, |
| 40 | + and hermetic test setup. |
| 41 | +- [x] Support explicit CLI/MCP mode and project selection with visible status. |
| 42 | +- [x] Bundle a focused set of shared skills: notes, capture, continue, and tasks. |
| 43 | +- [ ] Verify bundled skill tool/CLI instructions work in both modes without duplicate discovery. |
| 44 | +- [x] Capture one coherent working-thread note with goal, decisions and rationale, |
| 45 | + current state, blockers, next steps, and source/session provenance. |
| 46 | +- [x] Start a separate fresh Pi process and recover that thread through Basic Memory. |
| 47 | +- [x] Repeat the identical scenario through the other access mode. |
| 48 | + See `docs/PI_MEMORY_E2E_RESULTS.md`. |
| 49 | + |
| 50 | +## Phase 3 — lifecycle continuity |
| 51 | + |
| 52 | +- [ ] Bounded recall at session entry / first relevant prompt, including note identifiers |
| 53 | + and source provenance; avoid repeatedly injecting the same context. |
| 54 | +- [ ] Capture important decisions during work; support explicit remember/recall commands. |
| 55 | +- [ ] Add compaction-aware durable checkpoints without replacing native compaction. |
| 56 | + Settle checkpoint timing using Pi lifecycle tests, not assumptions about reentrant turns. |
| 57 | +- [ ] Restore state on reload/resume and track forks/tree navigation without merging |
| 58 | + contradictory branches or duplicating captures. |
| 59 | +- [ ] Choose and document automatic capture defaults and destinations. Raw transcript |
| 60 | + capture is a separate opt-in decision, not an implied prerequisite for continuity. |
| 61 | +- [ ] Treat recalled notes as source material, not privileged instructions. Respect project |
| 62 | + trust and never route private session traces into shared projects implicitly. |
| 63 | +- [ ] Bound subprocess/request duration, propagate cancellation, and clean up owned resources. |
| 64 | + Never blindly retry non-idempotent writes after an ambiguous transport failure. |
| 65 | + |
| 66 | +## Phase 4 — compare CLI and MCP |
| 67 | + |
| 68 | +Run both modes with the same Basic Memory version, seeded notes, model, task prompts, |
| 69 | +retrieval budgets, and capture policy. Use independent sessions and equivalent isolated |
| 70 | +projects so one trial cannot benefit from another trial's captures. |
| 71 | + |
| 72 | +Measure separately: |
| 73 | + |
| 74 | +- cold startup, first operation, warm read/search/write latency; |
| 75 | +- tool discovery and prompt overhead, tokens and provider usage; |
| 76 | +- successful writes and recovery of their actual identifiers; |
| 77 | +- recall correctness: decision, rationale, blocker, next action, source citation; |
| 78 | +- duplication, routing isolation, and behavior after errors/reload/compaction. |
| 79 | + |
| 80 | +Test local routing first. Cloud tests are opt-in against a dedicated test project; |
| 81 | +never mutate existing personal/team projects as fixtures. Report model-backed quality |
| 82 | +results separately from deterministic transport assertions. Recommend a default from |
| 83 | +observed results while keeping both modes supported. |
| 84 | + |
| 85 | +## Acceptance scenarios |
| 86 | + |
| 87 | +1. Session A records a decision and unfinished next step. Fresh session B receives only |
| 88 | + the topic and recovers the decision, rationale, and next step with a real note reference. |
| 89 | +2. CLI captures are recalled over MCP and vice versa without migration. |
| 90 | +3. Reload, resume, compaction, and forks preserve usable context without duplicate writes |
| 91 | + or attributing another branch's state to the current branch. |
| 92 | +4. Two projects with conflicting decisions remain isolated, including ambiguous names. |
| 93 | +5. Missing CLI, unavailable MCP server, auth failure, cancellation, and failed writes are |
| 94 | + visible; Pi remains usable and never falsely confirms persistence. |
| 95 | +6. Opted-out capture writes nothing; retrieved note instructions cannot change capture |
| 96 | + settings or destination routing. |
| 97 | + |
| 98 | +## Phase 5 — distribution and documentation |
| 99 | + |
| 100 | +- [x] Root `just package-check-pi` target and integration into consolidated package checks. |
| 101 | +- [x] Package install/pack validation and isolated Pi subprocess smoke tests. |
| 102 | + See `docs/PI_MEMORY_E2E_RESULTS.md`. |
| 103 | +- [x] README with CLI and MCP installation, explicit mode switching, project routing, |
| 104 | + privacy defaults, failure recovery, and supported version matrix. |
| 105 | +- [ ] Add the Pi integration page to `docs.basicmemory.com` in a separate docs change. |
| 106 | +- [ ] Wire release metadata/publishing consistently with existing integration packages. |
| 107 | + Version bump wiring is in place; npm publishing workflow is still open. |
| 108 | + See `docs/PI_MEMORY_SHIPPING.md`. |
| 109 | + |
| 110 | +## Development workflow |
| 111 | + |
| 112 | +Worktree: `../basic-memory-pi`; branch: `feat/pi-memory` (created from local `origin/main`). |
| 113 | +Use separate Pi print/JSON/RPC processes for end-to-end verification and isolated Basic |
| 114 | +Memory config/data. Model-backed tests require available provider access and incur usage. |
| 115 | +Use `/reload` for interactive development once the extension is configured; a full restart |
| 116 | +is not normally required. Do not install extensions into the user's live config implicitly. |
| 117 | + |
| 118 | +## References |
| 119 | + |
| 120 | +Live website index: https://docs.basicmemory.com/llms.txt |
| 121 | + |
| 122 | +Live Markdown read during planning: |
| 123 | +- https://docs.basicmemory.com/raw/reference/ai-assistant-guide.md |
| 124 | +- https://docs.basicmemory.com/raw/integrations/harness-capture.md |
| 125 | + |
| 126 | +Additional documentation reviewed from the sibling website source checkout: |
| 127 | +- https://docs.basicmemory.com/raw/reference/cli-reference.md |
| 128 | +- https://docs.basicmemory.com/raw/cloud/cloud-cli.md |
| 129 | +- https://docs.basicmemory.com/raw/cloud/routing.md |
| 130 | +- https://docs.basicmemory.com/raw/integrations/hermes.md |
| 131 | +- https://docs.basicmemory.com/raw/integrations/openclaw.md |
| 132 | + |
| 133 | +Implementation references: `integrations/openclaw/`, `integrations/hermes/`, `skills/`. |
| 134 | +MCP adapter: https://github.com/nicobailon/pi-mcp-adapter (`2.32.1` compatibility verified for the initial runtime-registration scenario). |
| 135 | +Pi: installed README, extension/package/skill/compaction documentation and examples. |
0 commit comments