Improved Pi integration - #128
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
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 pito 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/listand to run indexing/publish automation on pi lifecycle events. - Made the Codex integration respect relocated
CODEX_HOME(viacodex 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 tofunes-push.shon shutdown so the boundary publish indexes thepiharness 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.shso the script can runfunes index --harness pibefore 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.
`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>
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.
This adds indexing hooks to Pi, and updates the tool registration to automatically register new MCP verbs.