Skip to content

Add Pi (pi.dev) agent harness support + shared derive layer#17

Merged
eliot-emp merged 2 commits intomainfrom
eliot/recursing-tharp
Apr 17, 2026
Merged

Add Pi (pi.dev) agent harness support + shared derive layer#17
eliot-emp merged 2 commits intomainfrom
eliot/recursing-tharp

Conversation

@eliothedeman
Copy link
Copy Markdown
Collaborator

Summary

Adds support for deriving Toolpath provenance documents from Pi coding-agent session logs, and introduces a new shared derivation layer that future conversation providers will build on.

  • toolpath-derive (new, 0.1.0) — shared derivation: toolpath_convo::ConversationViewtoolpath::v1::Path. Centralizes the turn→step mapping so every provider produces consistent output. toolpath-claude is not migrated in this PR; that's a follow-up so we can validate the shared layer on Pi first.
  • toolpath-pi (new, 0.1.0) — read Pi JSONL session files from ~/.pi/agent/sessions/, implement ConversationProvider, and derive Toolpath Path documents. Preserves Pi's in-file conversation tree (id/parentId) as a DAG in the output Path, and follows parentSession links across session files.
  • CLI: path derive pi and path list pi, matching the shape of the existing claude/git/github subcommands.

What the new crates do

toolpath-pi layout:

  • types.rs — Pi v3 session schema as typed serde enums with forward-compat extra maps on every struct
  • paths.rsPathResolver for ~/.pi/agent/sessions/--<encoded-cwd>--/
  • reader.rs — JSONL parser, tree reconstruction via id/parentId, bounded parentSession chain-following
  • io.rs — filesystem enumeration (list_projects, list_sessions)
  • provider.rsConversationProvider impl, tool classification, bash-execution synthesis, tool-result correlation via toolCallId
  • derive.rs — thin PiSession → ConversationView → toolpath_derive::derive_path wrapper
  • lib.rsPiConvo manager (default ~/.pi/agent/sessions/, configurable via with_resolver)

toolpath-derive:

  • derive_path(view, config) with DeriveConfig { base_uri, path_id, title, include_thinking, include_tool_uses }
  • File-path extraction for FileWrite tools uses a fixed field-name preference list: file_path, path, filename, file
  • Actors, files_changed, token usage, delegations flow through to PathMeta/step extras

Usage

path derive pi --project /Users/alex/myproj --pretty
path derive pi --project /Users/alex/myproj --session 2026-04-16_abc123
path derive pi --project /Users/alex/myproj --all --pretty
path list pi
path list pi --project /Users/alex/myproj

--base DIR overrides the default ~/.pi/agent/sessions/ on both commands.

Design decisions worth flagging

  • No watcher in this PR. Static reading only. A watcher feature parallel to toolpath-claude's can be added later.
  • Static classification, no trait hook. Pi tools are classified in toolpath-pi's provider; the shared derive consumes pre-classified ToolCategory only. Keeps the shared layer agnostic of provider tool names/casing.
  • Tree preserved as DAG. Pi's in-file branching (id/parentId) maps 1:1 onto Toolpath's dead-end semantics. Dead branches become dead ends in the output Path, exactly as the format intends.
  • parentSession cross-file IDs namespaced. Turn IDs from a parent file are rewritten as <session-id>:<entry-id> when merged so they can't collide with child-session IDs.
  • toolpath-claude unchanged. Migration onto toolpath-derive is a separate PR.

Test plan

All green:

  • cargo test --workspace — 220 existing + 185 new tests, 0 failures
    • toolpath-derive: 30 unit + 1 doc
    • toolpath-pi: 123 unit + 9 integration + 3 doc
    • toolpath-cli: +11 Pi tests (137 total, up from 126)
  • cargo clippy -p toolpath-derive -p toolpath-pi --all-targets -- -D warnings — clean
  • cargo clippy -p toolpath-cli --bin path -- -D warnings — clean
  • path derive pi --help / path list pi --help render correctly
  • Manual: run path derive pi against a real ~/.pi/agent/sessions/ directory (reviewer can try)

Release-checklist updates

Per CLAUDE.md's rules for adding new crates, this PR updates:

  • Cargo.toml (workspace members + [workspace.dependencies])
  • CLAUDE.md (repository layout, dependency graph, CLI examples, testing section, "Things to know")
  • README.md (workspace listing)
  • site/_data/crates.json + site/pages/crates.md
  • scripts/release.sh (tier-2 publish order: toolpath-derive before toolpath-pi)
  • CHANGELOG.md

Follow-ups (not in this PR)

  1. Migrate toolpath-claude onto toolpath-derive (separate PR; must preserve or justify snapshot deltas).
  2. Pi filesystem watcher (feature-gated watcher module mirroring toolpath-claude).

Two new crates:

- toolpath-derive (0.1.0): shared derivation layer that converts a
  provider-agnostic toolpath-convo::ConversationView into a
  toolpath::v1::Path. Centralizes the turn→step mapping so future
  providers produce consistent output; toolpath-claude will migrate
  onto it in a follow-up.

- toolpath-pi (0.1.0): read Pi (pi.dev) coding-agent session JSONL
  logs from ~/.pi/agent/sessions/, implement ConversationProvider,
  and derive Toolpath Path documents. Preserves Pi's in-file
  conversation tree (id/parentId) as a DAG in the output Path and
  follows parentSession links across session files.

CLI: `path derive pi` and `path list pi` subcommands, matching the
shape of the existing claude/git/github commands.

Tests: 30 + 132 + 3 new tests in the new crates + CLI, all passing.
Workspace-wide totals unchanged-everything-else; clippy clean on new
and modified code.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

🔍 Preview deployed: https://50054a6c.toolpath.pages.dev

@eliothedeman
Copy link
Copy Markdown
Collaborator Author

Basic "rm" of a file in a directory
test

@eliothedeman eliothedeman requested a review from akesling April 16, 2026 21:14
@eliothedeman eliothedeman assigned akesling and unassigned akesling Apr 16, 2026
Collapses the separate toolpath-derive crate into toolpath-convo so the
provider-agnostic ConversationView → toolpath::v1::Path mapping lives
alongside the types it consumes. Callers now use
toolpath_convo::derive_path and toolpath_convo::DeriveConfig directly.

- toolpath-convo 0.5.0 → 0.6.0; gains a toolpath workspace dep and a
  new derive module with all 30 existing derive tests.
- toolpath-pi drops its toolpath-derive dependency; re-exports
  DeriveConfig from toolpath-convo.
- toolpath-derive crate removed from the workspace.
- release.sh: toolpath-convo moves from tier 1 to tier 2 (now has a
  workspace dep on toolpath). toolpath is the sole tier-1 crate.
- CLAUDE.md, README.md, CHANGELOG.md, site data, and release script
  updated accordingly.

791 tests passing, no clippy warnings on new/modified code.
Copy link
Copy Markdown
Contributor

@akesling akesling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eliot-emp eliot-emp merged commit 93ed517 into main Apr 17, 2026
2 checks passed
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.

3 participants