Skip to content

[FEATURE] add a dedicated pi coding agent adapter #674

Description

@wutongyuonce

Feature request

Add a dedicated memu-pi host adapter for
@earendil-works/pi-coding-agent,
following the existing host-adapter pattern used by Claude Code, Codex, Hermes,
OpenClaw, and the other supported agents.

Why a dedicated adapter is needed

pi stores v3 JSONL sessions under:

~/.pi/agent/sessions/<encoded-cwd>/*.jsonl

The generic adapter can partially sniff this typed-message format, but it does
not model pi's records precisely. In particular, an assistant entry whose
content contains only toolCall blocks is currently classified as a normal
conversation message. That feeds tool arguments into the conversation track
instead of the tool track. A read-only scan of 10 recent real pi sessions found
385 such pure tool-call entries.

pi also has stable host-specific integration points that the generic adapter
cannot safely infer:

  • global instructions: ~/.pi/agent/AGENTS.md;
  • skills: ~/.pi/agent/skills;
  • headless scheduled execution: pi -p <prompt>;
  • scheduled-run identity: PI_SESSION_ID and PI_SESSION_FILE;
  • custom locations: PI_CODING_AGENT_DIR and
    PI_CODING_AGENT_SESSION_DIR.

Proposed support

Add a small memu.hosts.pi package containing one TranscriptSource and one
HostSpec, plus the memu-pi console entry point.

The transcript source would:

  • discover sessions recursively below pi's session root;
  • retain user and assistant text as MESSAGE;
  • classify toolResult, bashExecution, and pure assistant toolCall entries
    as TOOL;
  • retain narrated assistant tool calls as conversation messages when a text
    block is present;
  • ignore session headers, compaction records, thinking-only entries, malformed
    JSON, and unknown records.

The host specification would reuse memU's existing bridging, instruction,
skills, scheduling, and lifecycle-reporting machinery rather than adding new
framework code.

Platform coverage

  • macOS: install instructions and an OS-scheduled bridge using pi -p.
  • Linux: the same cron-compatible bridge as macOS.
  • Windows: Task Scheduler support through memU's existing schedule
    commands, including headless-auth verification.

All platforms would support pi's default paths. The adapter would also honor
PI_CODING_AGENT_DIR and PI_CODING_AGENT_SESSION_DIR for custom layouts.

This proposal does not claim end-to-end platform certification until each OS
has been exercised; it only provides the same platform-specific installation
and scheduling surfaces as the existing adapters.

Documentation changes

  • add pi to the README adapter and CLI tables;
  • route ~/.pi detection from memu-agent to memu-pi;
  • add install, bridging-task, and uninstall guides;
  • document the npm install and pi authentication prerequisites.

Acceptance criteria

  • memu-pi prepare reads default and configured pi v3 session directories;
  • pure tool-call rows never enter the conversation track;
  • memu-pi install-instruction manages only memU's block in pi's global
    AGENTS.md and installs the existing retrieval skill;
  • macOS/Linux and Windows scheduling commands render valid host-specific
    wrappers and prompts;
  • memu-agent detect ~/.pi redirects to the dedicated adapter;
  • focused classifier and scheduling tests pass, along with the repository's
    full make check and make test suites.

Compatibility and scope

The change adds no dependency and no new abstraction. It reuses HostSpec, the
bridging pipeline, OS scheduling helpers, and the existing instruction/skill
installers. Unknown future pi record types degrade to OTHER rather than being
included as conversation data.

Implementation

The focused implementation and tests are available in #675.

Current validation:

  • make check passes;
  • make test passes (604 passed, 8 skipped);
  • 385/385 pure tool-call rows in the sampled real pi sessions are classified
    as TOOL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions