Skip to content

Add pi.dev agent integration#15

Merged
MadhuAppachi merged 2 commits intoAppachiTech:devfrom
mblarsen:feat/pi-support
Apr 3, 2026
Merged

Add pi.dev agent integration#15
MadhuAppachi merged 2 commits intoAppachiTech:devfrom
mblarsen:feat/pi-support

Conversation

@mblarsen
Copy link
Copy Markdown
Contributor

@mblarsen mblarsen commented Apr 3, 2026

Summary

Adds support for tracking commands executed by the pi.dev coding agent. Implements #14

Changes

  • Add suv init pi command to install pi.dev extension
  • Extension captures bash commands via tool_result event
  • Extension captures user prompts via before_agent_start event
  • Records commands with executor=pi and correct exit codes
  • Prompts cached to ~/.local/share/suvadu/prompts/pi-{session}.prompt

Usage

suv init pi

Creates ~/.pi/agent/extensions/suvadu.ts which auto-loads when pi.dev starts.

How It Works

Event Purpose
before_agent_start Captures user prompts before LLM processing
tool_call Tracks bash command start (command, cwd, session)
tool_result Records completed commands via suv add

Exit Code Handling

  • Successful commands (isError: false) → exit code 0
  • Failed commands (isError: true) → tries to extract exit code from details, defaults to 1

Testing

Tested manually with pi.dev:

  • Commands are recorded with correct executor
  • Exit codes are captured correctly
  • Prompts are cached and associated with commands

Follows the same patterns as the OpenCode integration.

- Add  command to install pi.dev extension
- Extension captures bash commands via  event
- Extension captures prompts via  event
- Records commands with executor=pi and correct exit codes
- Prompts cached to ~/.local/share/suvadu/prompts/pi-{session}.prompt
- Follows same patterns as OpenCode integration
Copy link
Copy Markdown
Contributor

@MadhuAppachi MadhuAppachi left a comment

Choose a reason for hiding this comment

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

Thanks for the quick PR! This follows the existing integration patterns nicely.

A few things I'd like to clarify before merging:

  1. Pi.dev API stability — How stable is the ExtensionAPI from @mariozechner/pi-coding-agent? Since Pi is relatively new, any breaking changes there would break this extension.
  2. Session IDbase.slice(0, 12) could collide if session filenames share a common prefix. Would using the full basename be safer?
  3. _ctx.cwd — Does this always reflect the working directory where the bash command runs, or is it the initial launch directory?

Also, could you retarget this PR to the dev branch? We're planning the 0.3.1 release within the next 48 hours, and this will be part of it.

Happy to iterate on these — nice work getting this in so quickly!

@mblarsen
Copy link
Copy Markdown
Contributor Author

mblarsen commented Apr 3, 2026

I'll look into 1. and 3. tomorrow. Do you have a recommendation for 2.?

@mblarsen
Copy link
Copy Markdown
Contributor Author

mblarsen commented Apr 3, 2026

I suggest we close the PR for now and then reassess a bit down the road. Seems like changes could be coming.

image

- Use ctx.sessionManager.getSessionId() for proper session UUID
- Fallback extracts UUID from filename pattern (timestamp_uuid.jsonl)
- No longer truncates to 12 chars which was just cutting up a date
@mblarsen
Copy link
Copy Markdown
Contributor Author

mblarsen commented Apr 3, 2026

Found a way to get a UUID from the session so they look like this now:

image

Was not able to assess if cmd is the initial dir or where bash is run from. I cannot seem to set up a case where they are different. So I'm guessing the initial dir. Seems that each bash tool invocation is relative to the initial dir. I'm guessing that is common?

@mblarsen mblarsen changed the base branch from main to dev April 3, 2026 13:57
@mblarsen
Copy link
Copy Markdown
Contributor Author

mblarsen commented Apr 3, 2026

The parts used from ctx seems fairly stable:

  • ctx.sessionManager.getSessionId
  • ctx.cmd

Your call :D

@MadhuAppachi
Copy link
Copy Markdown
Contributor

Thanks for digging into all of this! The API surface is small enough (sessionManager.getSessionId, ctx.cmd) that I'm comfortable merging. If Pi.dev breaks things down the road, we'll adapt. Merging to dev — will ship with 0.3.1.

@MadhuAppachi MadhuAppachi merged commit cd36dd4 into AppachiTech:dev Apr 3, 2026
@mblarsen mblarsen deleted the feat/pi-support branch April 3, 2026 15:46
@mblarsen
Copy link
Copy Markdown
Contributor Author

mblarsen commented Apr 3, 2026

Cool, looking forward to it, and what else you come up with :)

@MadhuAppachi MadhuAppachi mentioned this pull request Apr 5, 2026
@mblarsen
Copy link
Copy Markdown
Contributor Author

mblarsen commented Apr 15, 2026

Hi @MadhuAppachi pi has added PI_CODING_AGENT=true so all sub-shells will have that var now. Would that make the integration obsolete or simpler?

See CHANGELOG

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.

2 participants