Repository navigation
feat(integrations): Pi memory plugin using native lifecycle and Basic Memory CLI #1488
Description
Activity
Claude finished @phernandez's task in 27s —— View job
Triage
Type: Feature request (enhancement) — new integration package (
integrations/pi/), no existing code affected.Component:
integrations(Pi plugin, CLI + MCP transport modes). Not a Cloud-specific issue — routing/auth reuse existing Basic Memory mechanisms, so nocloudlabel applied.Priority: Medium. High strategic value (extends the OpenClaw/Hermes integration pattern to a new host), but it's net-new, additive scope with no user-facing regression or broken functionality today.
Complexity: Complex. This is a multi-phase effort (investigation of an unverified third-party MCP adapter, a new package with CLI/MCP dual-mode support, lifecycle/compaction-aware capture, cross-mode comparison benchmarking, and distribution/docs) spanning a dedicated worktree and branch already scoped in the issue.
Duplicate check: No existing open or closed issues found referencing Pi integration,
pi-mcp-adapter, or this plugin work.Notes for follow-up: Phase 1 explicitly calls out an unverified dependency (
pi-mcp-adaptercompatibility/licensing not yet confirmed) — worth confirming that spike happens before committing to the MCP-mode design, since Phase 2+ scope depends on its outcome.v0.24.0 delivery audit: needs maintainer decision on MCP lifecycle contract
Inspected the complete issue and discussion, merged #1492 and #1509, preserved
feat/pi-memory/../basic-memory-pi, and started fresh branchcodex/1488-pi-completionin the requested reusable../basic-memory-pr1540worktree from currentorigin/main(756f183617a8aae0ce7c503b88e9fb5c8180b1de). No product changes, new PR, or merge in this audit.Existing work is reusable, but does not close this issue
#1492 already landed the package, CLI installer/wheel resources, shared skill references, CLI hook integration, and cross-transport manual evidence. #1509 corrected effective automation status. The old prototype's Pi implementation is already represented on main; it should not be reimplemented.
Current
integrations/pi/extensions/index.tsroutesbuildRecall,captureSession, andrunHookthroughrunBmregardless oftransport. MCP mode registers a model-facing server only.refreshConfigexplicitly rejects MCPprojectId.docs/PI_MEMORY_E2E_RESULTS.mdalready acknowledges the CLI-backed command limitation. These are incomplete acceptance coverage, not evidence that equivalent CLI/MCP lifecycle modes have shipped.Released external API gap
Verified installed Pi 0.85.1, installed
bm0.23.2, and downloaded the actual npm tarball for pi-mcp-adapter 2.33.0 (npm SHA-1bb623263f34de7f6fc5927952118ba7caf4330e8). The adapter is MIT licensed and supports stdio/remote servers, discovery, cancellation and owned connection cleanup internally. Those capabilities do not imply a public call API for another extension.- Released adapter entrypoint:
McpServerRegistrationexposes onlydispose(): Promise<void>. Public runtime events register a server or read its snapshot; there is no public cross-extension tool invocation operation. - Released adapter README, “Runtime registration from other extensions”: registered servers expose tools through the model proxy. Registration is not a callable client. The standalone CLI is setup/configuration, not a tool-call bridge.
- Released Pi API:
ExtensionAPI.getAllTools()returnsToolInfometadata, not executable tool handles. There is noexecuteTool/callToolmethod.sendUserMessagestarts/queues a model turn; it is not a bounded tool-result API that a pre-compaction callback can await. - Alternative inspected: @nklisch/pi-mcp-adapter 2.21.0-nklisch.4 public contract.
McpProgrammaticRuntimesupports capabilities, validation, replace/remove/inspect source operations; its public interface excludes the internal runtime'scallToolmethod. - Alternative inspected: pi-mcp-extension 1.5.0. It bridges tools to the model but documents no cooperating-extension invocation API; its peer contracts also still use the older
@mariozechnerhost package names. Importing its internal manager would not satisfy the issue's supported-API constraint.
Decision needed before completing scope
The missing API blocks awaitable MCP-backed recall/capture in lifecycle callbacks using the supported installed-adapter contract. It does not block ordinary model-initiated MCP calls. I am not claiming all Pi integration is blocked or that the existing CLI work is unusable.
Choose one explicit delivery contract:
- Accept the existing hybrid boundary for v0.24: CLI owns lifecycle recall/checkpoint operations in both modes, while MCP is model-driven access. Update the issue's same-mode lifecycle comparison/acceptance wording accordingly. The issue anticipated documenting this limitation before choosing automation; this choice must be explicit, not concealed behind
transport: "mcp". - Retain full transport parity and obtain a released public adapter invocation API (server/tool/arguments, cancellation, bounded completion, result/error, cleanup ownership, no blind retry of ambiguous writes) before completing the MCP lifecycle slice.
Queuing model instructions for a later turn changes checkpoint timing and persistence guarantees. Deep-importing private managers or implementing a new MCP host conflicts with the confirmed scope. I have not chosen either workaround implicitly.
Other remaining work, not separate external blockers
After the transport decision, reuse the current package and finish synthesized capture versus raw-turn opt-in semantics (current Pi checkpoints copy user/assistant turn text), lifecycle/branch/deduplication host tests, explicit project isolation in both modes, equivalent fresh-process comparisons, and the remaining distribution/docs work. These remain implementation tasks; the API gap does not excuse marking them complete.
just package-check-pipassed on the audited head: TypeScript, 15 tests, four canonical reference drift checks, npm pack dry run. The current tests cover config, capture construction, fencing and status; they do not prove the full lifecycle acceptance matrix. No model-backed quality benchmark or cloud fixture run is claimed.Per the requested stop condition, marking this issue
needs reviewand stopping delivery work here. #1488 remains open. Existing #1492 and #1509 remain merged; no new PR is awaiting CI/Codex/merge. Main and all worktree registrations were left untouched; only the requested reusable worktree was switched to the fresh branch.Additional real CLI probe (isolated
BASIC_MEMORY_HOMEandBASIC_MEMORY_CONFIG_DIR, forced local, throwawaypi-contractproject): stdin write returned JSONaction: createdwithpi-contract/pi/sessions/pi-contract; repeating without overwrite exited 1 withNOTE_ALREADY_EXISTS;--overwritereturnedaction: updated; a separate search process returned that real reference and the decision/rationale/next-step text. This proves local CLI transport behavior only, not MCP lifecycle parity or cloud UUID isolation. Evidence is retained locally in/tmp/bm-pi-1488-contract/cli-results.json.- Released adapter entrypoint:
- addedneeds reviewA human maintainer needs to look at this issueA human maintainer needs to look at this issue
on Sep 14, 2026 Milestone status (2026-09-14): the Pi package is shipped; full MCP lifecycle parity remains decision-blocked.
Merged #1492 and #1509 provide the integration package, installer/wheel resources, shared skills, CLI lifecycle flow, MCP registration, and truthful automation status.
just package-check-pipreviously passed. The released contracts are still Pi 0.85.1 andpi-mcp-adapter2.33.0; neither exposes a supported awaitable cross-extension MCP tool-call API for pre-compaction recall/capture.Next step requires one maintainer decision:
- accept the current hybrid contract for v0.24—CLI owns automatic lifecycle work while MCP remains model-facing; or
- retain full transport parity and wait for a released adapter API that supports bounded invocation, cancellation, results/errors, and lifecycle ownership.
After that decision, remaining work is synthesized-vs-raw capture semantics, lifecycle/deduplication and project-isolation tests, fresh-process mode comparison, and final distribution docs. No PR is pending.
- removedneeds reviewA human maintainer needs to look at this issueA human maintainer needs to look at this issue
on Sep 14, 2026 Maintainer decision for v0.24: accept the CLI-owned lifecycle contract.
Pi is intentionally CLI-first for automatic memory behavior. The Basic Memory CLI owns lifecycle recall, capture/checkpoint persistence, project routing, and bounded completion. MCP registration remains available for model-initiated tools, but
transport: "mcp"does not promise that Pi lifecycle callbacks invoke MCP tools or provide transport parity.This resolves the decision blocker identified above. Do not wait for or build a cross-extension MCP invocation API, deep-import adapter internals, queue a model turn to simulate lifecycle persistence, or add another MCP host.
Remaining delivery work for this issue:
- make configuration/status/docs describe the hybrid boundary plainly;
- finish synthesized durable capture versus explicit raw-turn opt-in semantics;
- add lifecycle, branch/deduplication, failure-surfacing, and explicit project-isolation tests;
- verify the CLI flow from a fresh Pi process;
- finish distribution documentation and package checks.
Removing
needs review; the issue remains in v0.24.0 and is ready for this bounded CLI-flow completion.Correction to the decision above: “CLI-first” describes the transport, not lifecycle ownership.
Pi owns the integration shape:
- Pi's native session, branch, compaction, and extension lifecycle events decide when recall and capture happen.
- The Basic Memory extension translates those native events into the smallest appropriate Basic Memory operations.
- The
bmCLI provides structured, bounded storage/search/read/write primitives and explicit project routing. - Basic Memory must adapt to Pi's event payloads and timing; Pi should not be made to emulate Basic Memory's hook protocol or lifecycle model.
So the target is Basic Memory working naturally inside Pi, not a generic
bm hook --harness piflow that makes Pi behave like another harness. Reuse shared logic where it genuinely fits, but do not make shared lifecycle uniformity an acceptance criterion.Implementation implication: evaluate the current
runHookpath as replaceable scaffolding. Prefer direct adapter code driven by Pi-native events and backed by structured CLI commands. Preserve Pi's compaction/history behavior, make capture synthesis fit the information Pi actually exposes, and surface failures through Pi's normal extension UX.MCP remains model-facing and optional. No cross-extension MCP invocation parity is required for automatic lifecycle behavior.
Updated remaining work:
- map Pi-native lifecycle events and guarantees;
- implement recall/capture at those native boundaries using structured CLI operations;
- test branching, compaction, deduplication, project isolation, and failure behavior in Pi terms;
- document the behavior as a Pi integration, with Basic Memory configuration limited to storage/routing concerns.
- changed the title
[-]feat(integrations): Pi memory plugin with CLI and MCP modes — never start over[/-][+]feat(integrations): Pi memory plugin using native lifecycle and Basic Memory CLI[/+]on Sep 14, 2026 Final maintainer clarification: Pi integration is CLI-only. There is no MCP mode.
The architectural contract for #1488 is:
- Pi owns session, branching, compaction, lifecycle timing, and extension UX.
- The Basic Memory Pi extension adapts to Pi's native events.
- The extension invokes structured
bmCLI operations for project routing, recall, reads, searches, and durable writes. - Basic Memory does not ask Pi to emulate a shared Basic Memory harness lifecycle.
- Basic Memory does not register or invoke an MCP server for this integration.
- There is no CLI/MCP parity matrix, transport switch, MCP adapter dependency, or model-facing MCP fallback in scope.
Existing MCP-oriented implementation and acceptance text in this issue is superseded by this decision. Reuse useful CLI/package work from #1492 and #1509, but remove or simplify MCP-specific configuration and code where it exists.
The remaining acceptance target is a host-native Pi integration, backed by the Basic Memory CLI, with tests expressed in Pi's own lifecycle terms.
Milestone decision: removing this from v0.24.0. The issue remains open under the clarified architecture: Pi-native lifecycle with structured Basic Memory CLI operations and no MCP mode. This integration can proceed independently without blocking the v0.24 release.
Pi memory integration: you are never starting over
Goal
A fresh Pi session recovers the relevant decisions, working state, blockers, and next
steps without the user repeating the previous conversation. Knowledge belongs to the
user and remains usable across agents, projects, and local/cloud deployments.
Ship one Pi package with two user-selectable access modes: Basic Memory CLI and an
existing Pi MCP adapter. Share memory behavior and skills, not two independent memory
implementations. Switching transport must not require migrating notes.
Confirmed direction
integrations/pi/in the Basic Memory monorepo.Phase 1 — investigate and prove transport contracts
pi-mcp-adapterand alternatives: current Pi compatibility, tool naming,discovery, cancellation, shutdown/reload, stdio and remote support, licensing.
If not, document the limitation before choosing how automated recall/capture runs;
do not depend on private adapter internals.
bmCLI flags, structured output, write error/overwrite semantics,stdin support, project UUID routing, and local/cloud behavior against real calls.
bm hookrecall/checkpoint implementation for reusable core logic.Its documented harnesses are Claude and Codex, not Pi.
Phase 2 — smallest end-to-end continuity slice
and hermetic test setup.
Verify their tool/CLI instructions work in both modes without duplicate discovery.
current state, blockers, next steps, and source/session provenance.
Phase 3 — lifecycle continuity
and source provenance; avoid repeatedly injecting the same context.
Settle checkpoint timing using Pi lifecycle tests, not assumptions about reentrant turns.
contradictory branches or duplicating captures.
capture is a separate opt-in decision, not an implied prerequisite for continuity.
trust and never route private session traces into shared projects implicitly.
Never blindly retry non-idempotent writes after an ambiguous transport failure.
Phase 4 — compare CLI and MCP
Run both modes with the same Basic Memory version, seeded notes, model, task prompts,
retrieval budgets, and capture policy. Use independent sessions and equivalent isolated
projects so one trial cannot benefit from another trial's captures.
Measure separately:
Test local routing first. Cloud tests are opt-in against a dedicated test project;
never mutate existing personal/team projects as fixtures. Report model-backed quality
results separately from deterministic transport assertions. Recommend a default from
observed results while keeping both modes supported.
Acceptance scenarios
the topic and recovers the decision, rationale, and next step with a real note reference.
or attributing another branch's state to the current branch.
visible; Pi remains usable and never falsely confirms persistence.
settings or destination routing.
Phase 5 — distribution and documentation
just package-check-pitarget and integration into consolidated package checks.privacy defaults, failure recovery, and supported version matrix.
docs.basicmemory.comin a separate docs change.Development workflow
Worktree:
../basic-memory-pi; branch:feat/pi-memory(created from localorigin/main).Use separate Pi print/JSON/RPC processes for end-to-end verification and isolated Basic
Memory config/data. Model-backed tests require available provider access and incur usage.
Use
/reloadfor interactive development once the extension is configured; a full restartis not normally required. Do not install extensions into the user's live config implicitly.
References
Live website index: https://docs.basicmemory.com/llms.txt
Live Markdown read during planning:
Additional documentation reviewed from the sibling website source checkout:
Implementation references:
integrations/openclaw/,integrations/hermes/,skills/.MCP candidate: https://github.com/nicobailon/pi-mcp-adapter (not yet compatibility-verified).
Pi: installed README, extension/package/skill/compaction documentation and examples.