Skip to content

feat: add Pi coding agent source#3

Merged
winjer merged 10 commits into
mainfrom
worktree-pi-agent-support
May 11, 2026
Merged

feat: add Pi coding agent source#3
winjer merged 10 commits into
mainfrom
worktree-pi-agent-support

Conversation

@winjer

@winjer winjer commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds Pi coding agent (@earendil-works/pi-coding-agent) as a third trace source alongside Claude Code and OpenCode
  • Implements a TypeScript extension at plugin/pi-agent/code-trace.ts that hooks Pi's agent_end event and pushes new session entries to the code-trace binary via stdin (push model, symmetric with the existing OpenCode plugin)
  • Adds src/pi_agent.rs normalizer that converts Pi's session entry format (flat role-based entries with toolCall/toolResult types) into the Claude-format Value shape that turns::build_turns already understands
  • Updates install.sh with --pi/-p flag and auto-detect for ~/.pi/agent

Test Plan

  • 41 unit tests + 4 integration tests all pass (cargo test)
  • Clippy clean (cargo clippy --all-targets -- -D warnings)
  • New end_to_end_pi_agent_transcript integration test covers user → assistant with tool_use → toolResult pipeline
  • Manual smoke test: install pi, copy extension, set TRACE_TO_LANGFUSE=true, run a session, verify trace appears in Langfuse under "Pi Agent - Turn N"

🤖 Generated with Claude Code

winjer and others added 10 commits May 11, 2026 09:53
Adds OpenCode as a second trace source alongside Claude Code.
Introduces Source enum, multi-source Input dispatch, opencode message
normalizer, pi-ready state keys, and an OpenCode TypeScript plugin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update gather_env_tags to accept source and agent_version parameters.
Add version probing for all three sources (ClaudeCode, Opencode, PiAgent):
- ProbeCommand will run only when agent_version is not provided
- Push version tag in format "{source.version_tag_prefix()}:{version}"
- Include new tests for each source variant

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement normalize_pi_agent_messages converting Pi agent session entries
(user, assistant, toolResult roles) into the Claude-format shape expected
by turns::build_turns, with thinking-block suppression and tool-result
correlation following the opencode.rs pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds comprehensive integration test for Pi Agent message flow covering
user messages, assistant messages with tool calls, and tool results.
Test verifies proper normalization, turn building, and event emission
for the pi-agent source.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add support for installing Pi Agent extension alongside the existing
OpenCode plugin support. Includes --pi/-p flag, pi detection, and
automatic or prompted installation to ~/.pi/agent/extensions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add Pi Agent as a third input source in the architecture section.
Document the pi_agent normalizer and pi extension in key files.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@winjer winjer merged commit 5636092 into main May 11, 2026
1 check passed
@winjer winjer deleted the worktree-pi-agent-support branch May 11, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant