@marclefrancois/pi-jev-guard0.3.0
Fail-closed Jev danger confirmation guard for Pi tool calls
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
@marclefrancois/pi-jev-guard
A fail-closed danger-confirmation guard for Pi tool calls.
Every tool call (and every user shell command) is assessed by the
typesafe/jev-latest classifier before it runs. Calls scoring above the
0.60 danger threshold require explicit confirmation. Calls at or below the
threshold run normally, with a small widget showing the score.
How it works
- The extension hooks
tool_callanduser_bash. - Each call is serialized (tool name + input, capped at 12 000 characters) and
sent to the classifier as a
boolquestion ("could executing this tool call cause significant harm...?"). The classifier prompt treats file or directory deletion (rm,rm -rf) as destructive even inside a worktree. - Danger score ≤ 0.60 → allowed. A TUI widget shows the score; Ctrl+G / Ctrl+Shift+G toggles the expanded view.
- Danger score > 0.60 → a confirmation prompt is shown. If the user declines, dismisses, or no UI is available, the call is blocked.
- Fail-closed: prompt setup or read failure, classifier unavailable, assessment error, invalid response, or a shut-down session all result in a block.
- Classifier usage is recorded in the session (
guard/Tools/ "Command classifier") but never affects the decision.
Install
pi install npm:@marclefrancois/pi-jev-guard
Customizing classifier prompts
The guard stores prompts in <agent-dir>/jev-guard/, under Pi's configured
agent directory (including PI_CODING_AGENT_DIR):
dangerous-instructions.mddangerous-true.mddangerous-false.md
At session start, missing files are copied from the bundled defaults. Existing files are never overwritten during setup. The guard reads all three files for each assessment, so edits apply to the next classification without restarting. If the prompts cannot be set up or read, the guard blocks the call.
Run /jev-guard-config in an interactive session to select a prompt and edit
its current contents. After saving, cancelling the editor, or rejecting a blank
edit, the selector opens again; cancel the selector to exit. You can also edit
the files directly.
Development
npm install
make check # tsc + vitest
make test-one TEST=test/index.test.ts
License
MIT — see LICENSE.