Skip to content

feat(setup): add Pi extension integration via engram setup pi #127

@yvolchkov

Description

@yvolchkov

📋 Pre-flight Checks

  • I have searched existing issues and this is not a duplicate
  • I understand this issue needs status:approved before a PR can be opened

🔍 Problem Description

Pi (pi-coding-agent (https://github.com/mariozechner/pi-coding-agent)) is a growing coding agent that supports native Type Script extensions. Currently there's no way to integrate Engram with Pi — users would need to manually set up MCP, which adds friction and doesn't leverage Pi's extension system (lifecycle hooks, prompt injection, native tools).

💡 Proposed Solution

Add first-class Pi support via engram setup pi, following the same pattern as the existing OpenCode integration (native TypeScript extension, no MCP required).

  engram setup pi

This installs ~/.pi/agent/extensions/engram.ts, which provides:

  • Native Engram tools — engram_search, engram_save, engram_context, engram_session_summary, engram_timeline, engram_get, engram_update, engram_delete, engram_stats
  • Memory Protocol injection into the system prompt (same protocol as other agents)
  • Session lifecycle hooks — session start/end tracking via /sessions
  • Compaction recovery — deferred summary persistence + context reinjection after session_compact
  • Auto-start of engram serve when needed
  • Privacy stripping — tags removed before any data leaves the extension

📦 Affected Area

CLI (commands, flags)

🔄 Alternatives Considered

  • MCP-only integration: Pi supports MCP, but using a native extension avoids MCP setup friction and enables prompt injection + lifecycle hooks that MCP can't provide. This mirrors the rationale behind the OpenCode plugin.
  • Separate repository: Could ship the extension standalone, but embedding it in the engram binary (like OpenCode) keeps the install to a single command.

📎 Additional Context

The implementation follows the established OpenCode plugin pattern exactly:

  • Source of truth in plugin/pi/engram.ts
  • Embedded copy generated via go generate ./internal/setup/
  • Installed to user home (~/.pi/agent/extensions/) by engram setup pi
  • All non-fatal error handling, privacy stripping, and session management patterns match the existing plugins

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions