Skip to content

Improved Pi integration - #128

Merged
dacorvo merged 5 commits into
mainfrom
pi_integration
Sep 1, 2026
Merged

Improved Pi integration#128
dacorvo merged 5 commits into
mainfrom
pi_integration

Conversation

@dacorvo

@dacorvo dacorvo commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

This adds indexing hooks to Pi, and updates the tool registration to automatically register new MCP verbs.

dacorvo and others added 4 commits August 31, 2026 14:25
The extension hand-wrote `recall` and `get`, so pi saw neither the four
verbs added since nor `get`'s current arguments — it was still passing
`turn_uuid`/`window`. It now registers whatever `tools/list` returns and
passes each MCP schema through as pi's `parameters`, which pi validates
directly, so there is no second copy of the surface to drift.

Those schemas make optional arguments nullable unions, which pi only
validates correctly from 0.84.0 on; below that every call omitting one
would be rejected, so `funes add pi` refuses to register there rather
than leave tools that look installed and fail.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
pi has no hook system, which is why it was the one agent funes left to
manual `funes index` runs. It does expose its lifecycle to extensions,
so the automation rides in the extension that already carries the tools:
`turn_end` indexes, and — with a memory bound — `session_shutdown`
publishes, as does `session_start` on a fresh process, which is the one
start with no shutdown of ours behind it.

It drives the same two scripts every other agent does, extracted beside
the extension, and `funes add pi` now bootstraps like the others: the
first index and the first push, which the push hook cannot do itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`~/.agents/skills` is read by every harness implementing the skills
standard — pi loads it globally, unprompted — so a skill installed there
for Codex became pi's too, and `funes remove codex` silently took it out
of pi's sessions while pi's own integration stayed installed.

Codex reads `~/.codex/skills` as well, verified against codex-cli
0.151.0, so the skill goes in that private root and add/remove touch
nothing another agent reads. Both install and uninstall clear the
shared-tree copy an earlier install left behind.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
funes derived Codex's config, hooks, and skill paths from `$HOME/.codex`,
which Codex itself never consults: it honors `CODEX_HOME` and resolves
the user's home on its own. A relocated home meant funes wrote hooks and
a skill to a directory Codex would never read, with nothing to show for
it.

`codex doctor --json` reports the home it actually uses, so the paths
hang off that. The report is read whatever the exit status says — that
status is the health verdict, not whether it answered — and `CODEX_HOME`
then `$HOME/.codex` remain as fallbacks when Codex cannot be asked.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves agent integrations—especially pi—by shifting tool registration to dynamic discovery via MCP (tools/list) and by adding lifecycle-driven automation so sessions are indexed (and optionally published) without manual steps.

Changes:

  • Updated funes add pi to bootstrap the same local pipeline as other agents (initial index + first publish when a remote memory is bound).
  • Enhanced the embedded pi extension to register tools from tools/list and to run indexing/publish automation on pi lifecycle events.
  • Made the Codex integration respect relocated CODEX_HOME (via codex doctor --json) and adjusted documentation to match the new automation behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main.rs Routes add pi through bootstrap_add and enforces scanner availability when binding a remote memory.
src/agents/pi.rs Raises minimum supported pi version, extracts shared automation scripts for pi, and tightens install gating.
src/agents/codex.rs Determines Codex home via codex doctor --json / CODEX_HOME fallback and installs skills/hooks under that home.
integrations/pi/README.md Updates pi integration docs for dynamic tool registration + automation.
integrations/pi/package.json Updates extension description to include per-turn indexing.
integrations/pi/index.ts Dynamically registers MCP tools and adds per-turn indexing + session-boundary publish via pi events.
docs/index.md Updates indexing guidance to reflect broader automation coverage.
docs/automation.md Documents pi automation via extension lifecycle events and updates shared automation descriptions.
docs/add.md Updates agent capability table and removes now-outdated “pi has no hooks” guidance.
AGENTS.md Records the “integration never restates tool surface” decision (pi registers tools/list).
Suppressed comments (2)

integrations/pi/index.ts:244

  • Same as session_start: pass the harness name to funes-push.sh on shutdown so the boundary publish indexes the pi harness first.
  pi.on("session_shutdown", async (event: any) => {
    if (memory && event?.reason !== "reload") runScript(PUSH_SH, memory);
  });

integrations/pi/index.ts:236

  • The push hook should pass the harness name as the second argument to funes-push.sh so the script can run funes index --harness pi before publishing (matching how other agents invoke it).
    // A fresh process is the one start with no shutdown behind it, so it catches up whatever a
    // process that never shut down cleanly left unpublished.
    if (memory && event?.reason === "startup") runScript(PUSH_SH, memory);
  });

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread integrations/pi/index.ts Outdated
`funes-push.sh` takes the harness as its second argument and indexes it
before publishing, so a session boundary carries the turns the detached
per-turn worker has not stored yet. The pi extension called it with the
memory alone, leaving that index unrun and the last turns for the next
session to catch up.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dacorvo
dacorvo merged commit 2f5d249 into main Sep 1, 2026
8 checks passed
@dacorvo
dacorvo deleted the pi_integration branch September 1, 2026 09:41
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