feat: add Pi session support (v2 subagent dirs + v3 native format)#155
Open
adamjramirez wants to merge 2 commits intoobsessiondb:mainfrom
Open
feat: add Pi session support (v2 subagent dirs + v3 native format)#155adamjramirez wants to merge 2 commits intoobsessiondb:mainfrom
adamjramirez wants to merge 2 commits intoobsessiondb:mainfrom
Conversation
Support pi (https://github.com/mariozechner/pi-coding-agent) sessions that were previously invisible to Rudel. Handles two pi storage formats: Pi v2 (~282 sessions): subagent-only UUID dirs under ~/.claude/projects/ Pi v3 (~846 sessions): native format under ~/.pi/agent/sessions/ Approach: - New PiAdapter in packages/agent-adapters/src/adapters/pi/ - Registered via registerScanOnlyAdapter() to share source 'claude_code' without colliding in the adapter registry - v3 content transformed to Claude Code JSONL format so the ClickHouse materialized view can extract analytics (timestamps, tokens, model, etc.) - Session resolver updated to find pi sessions by UUID or path - Upload command routes to Pi adapter via isPiSession() detection - Enable command gracefully handles Pi's no-op hooks Closes obsessiondb#153
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for pi sessions that were previously invisible to Rudel. Closes #153.
Before: 60 sessions visible (Claude Code only)
After: 1,188 sessions visible (Claude Code + Pi v2 + Pi v3)
Two Pi storage formats
~/.claude/projects/<project>/<uuid>/subagents/agent-*.jsonl~/.pi/agent/sessions/--<encoded-cwd>--/<timestamp>_<uuid>.jsonlApproach
New
PiAdapterfollowing the existing adapter pattern (like Codex):registerScanOnlyAdapter()— sharessource: "claude_code"without colliding in the adapter registry. NoSourceSchemachanges needed.contentfield, populatessubagentsmapv3 content transformation
The MV parses
contentline-by-line expecting Claude Code format (type: "user"/"assistant"at line level,message.usage.input_tokens, etc.). Pi v3 uses different structures, so the adapter transforms on upload:{type: "message", message: {role: "user"}}→{type: "user", ...}input→input_tokens,output→output_tokens,cacheRead→cache_read_input_tokens,cacheWrite→cache_creation_input_tokensuuidandsessionIdso the web UI conversation parser worksapi,provider,stopReason,cost,totalTokens) to reduce content sizesession,compaction,thinking_level_change,toolResult)Changes
packages/agent-adapters/src/adapters/pi/index.tspackages/agent-adapters/src/registry.tsregisterScanOnlyAdapter()for shared-source adapterspackages/agent-adapters/src/index.tsapps/cli/src/lib/session-resolver.tsapps/cli/src/commands/upload.tsapps/cli/src/commands/dev/list-sessions.ts[Pi]label for pi sessionsapps/cli/src/commands/enable.tsapps/cli/src/__tests__/agents.test.tsZero API/schema/migration changes.
Tested
bun run check-types✅bun run lint✅bun test— 24 pass, 0 fail ✅Follow-up suggestion
Currently pi sessions show as
source: "claude_code"since we reuse the existing source to avoid schema changes. A natural follow-up would be adding"pi"toSourceSchemaso the UI can distinguish which harness produced a session.