Repository navigation
feat(pi): add a native Pi guard extension (companion of Graphify-Labs/graphify#4378) - #14
Closed
andrebrait wants to merge 2 commits into
Closed
andrebrait wants to merge 2 commits into
andrebrait wants to merge 2 commits into
Conversation
|
Thanks for the pull request, @andrebrait. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
Member
Author
|
@codex review |
Member
Author
|
@coderabbitai review |
Pi has no PreToolUse hook, so the installed hook-guard policy never ran there. graphify/pi/ ships a Pi package (Node built-ins only, no node_modules) that runs `graphify hook-guard read|search` before Pi's read, grep, find and search-style bash calls: strict-mode denials become tool_call blocks, and guidance arrives as a graphify system reminder. Only local targets inside the project are checked, the hook uses the first `graphify` on PATH outside the project, and every call is bounded and fails open. `graphify pi guard install|uninstall` delegates registration to Pi's own `pi install|remove <dir>`; `graphify pi guard path` prints the package directory. Oh My Pi reads the same `pi` manifest key, so `omp plugin install "$(graphify pi guard path)"` loads it there too, where guidance uses OMP's passive tool-call context channel.
andrebrait
force-pushed
the
feat/pi-guard
branch
from
October 13, 2026 06:05
000b6df to
a628136
Compare
Member
Author
|
@codex review |
Member
Author
|
@coderabbitai full review |
…; document Pi 0.58.4+
Member
Author
|
@codex review |
Member
Author
|
@coderabbitai review |
Member
Author
|
Upstream shipped this in Graphify v0.9.89 as an authorship-preserving cherry-pick (Graphify-Labs#4378). Closing the review copy. |
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.
Companion PR (review-only)
Companion of Graphify-Labs#4378 (same head, same upstream base
v8=7536dc0, identical diff), opened on our fork so our review bots can access it.Summary
Graphify already installs a Pi skill (
graphify pi install), but Pi has noPreToolUsehook, so the hook-guard policy that Claude Code, Codex and others get never runs there. This adds a native Pi extension that runs the installedgraphify hook-guardbefore Pi's tool calls.graphify/pi/is a Pi package (package.jsonwith api.extensionsentry, plusindex.ts) shipped inside the wheel and sdist. It imports only Node built-ins, so it loads straight from site-packages with nonode_modules.tool_callforread,grep,findand search-stylebash, it callsgraphify hook-guard read|searchwith a Claude-shaped payload. A strict-mode (GRAPHIFY_HOOK_STRICT=1) denial becomes a{block, reason}result. Guidance is sent as one<system-reminder source="graphify">steering message. All graph decisions stay in the existing Python policy.graphify pi guard install|uninstalldelegates to Pi's ownpi install|remove <package dir>.graphify pi guard pathprints the directory.graphifyon an absolutePATHentry outside the project, so there is no project-local fallback.SIGKILLbudget.Oh My Pi
Oh My Pi reads the same
pimanifest key, so the same package loads there withomp plugin install "$(graphify pi guard path)". On OMP, guidance uses its passive tool-call context channel instead of a steering message. OMP'sgloband;-separated targets are handled too. This supersedes Graphify-Labs#3506, which shipped an OMP-only package.Testing
tests/pi.test.ts(bun, 19 tests) drives the real extension against the real installedgraphifyCLI. It covers nudges, the strict denial, out-of-project and remote targets,~/@paths,PATHshadowing and symlinked executables, timeouts, output and input caps, cancellation on navigation, unmapped tools, and Pi vs OMP delivery. The newpi-guardCI job runs it.tests/test_pi_guard_install.pycoverspi guard path, delegation topi install/pi removewith exit-code propagation, and a missingpi.graphify pi guard installregistered the package. A Pi SDK session loaded it from that registration and got nudges forgrep/find/bash/readand the one-time strict denial.omp plugin install "$(graphify pi guard path)"gave the same results.