@mrclrchtr/supi-pi-patches19.0.0
Prompt rules for the Pi coding agent that correct recurring model mistakes with Pi's built-in tools
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
@mrclrchtr/supi-pi-patches
SuPi Pi Patches is a Pi extension with small corrections for Pi's built-in tools: facts in the prompt that the model cannot know, a hint to the Jev classifier in Pi's codemode tool, and a limit for very long lines in bash results. Each patch is measured, and it is removed once Pi covers it or a measurement no longer shows its benefit.
The package is part of the Recommended installer preset.
Install
pi install npm:@mrclrchtr/supi-pi-patches
If Pi is open, run /reload after installation.
For local development:
pi install ./packages/supi-pi-patches
What it adds
The extension registers no tool, command, or setting. It changes the system prompt in before_agent_start hooks and bash results in a tool_result hook:
| Patch | Active when | Effect |
|---|---|---|
sed flavor |
bash is active and sed --version identifies GNU or BSD sed |
Adds a <shell> section that names the sed flavor; for BSD sed it also gives the sed -i syntax. The probe runs once per process through the bash tool's shellPath and shellCommandPrefix. |
| Bash habits | bash is active |
Appends three rules to the bash rules: a call starts in the working directory, so no leading cd; pick fields of single-line JSON with jq instead of head or tail; and rg skips hidden files and directories unless called with --hidden. |
| Jev guidance | codemode is active and openrouter/~typesafe/jev-latest has credentials, checked at session start |
Appends two sentences to the description of codemode in the tools section: asking which of many texts are of a kind is a classification, to run with Jev on each full text in the script that fetches them; it is fast and costs almost nothing. Adds a short <jev_classification> section with the models.classify call shape and answer types. |
| Long line limit | The model calls bash directly |
Cuts every line of the result at 2000 characters, marks it with the number of characters left out, and appends a note that says how to print a part of such a line. Pi's bash limits lines and bytes of an output but not the length of a line, so one line of minified code can fill the result. Calls from a codemode script keep their full lines. The transcript shows the cut result. |
The added text is static for a session, so the prompt prefix stays cacheable. Pi's own rules stay in place.
Why these patches
The aim is fewer wasted calls, tokens, and time at equal results. The tool fallback benchmark measured each patch with Sonnet 5.5, the bash habits also with Haiku 5.5, on single tasks:
| Patch | Measured |
|---|---|
sed flavor |
Not measured: Pi's prompt does not name the platform, so the model cannot know which sed -i form works. |
No leading cd |
A leading cd drops from 20 of 36 commands to none for Sonnet and from 34 of 38 to 8 of 44 for Haiku. |
jq for single-line JSON |
Haiku reads the JSON with jq in every command instead of every second one; Sonnet does so without the rule. |
rg --hidden |
Without the rule 3 of 96 runs searched without --hidden and named only the visible file; with it none of 96 did. |
| Jev guidance | On 150 real issues 31 of 32 runs classify the full texts with Jev and find more of the wanted issues (F1 0.80 against 0.68) for about 3 ¢ more per run; without it runs judge the titles themselves. On 43 short texts no run calls Jev. On 300 review comments the runs call Jev without a better answer, 13 to 17 seconds slower. |
| Long line limit | A search in bundled code filled the result with 44 kB lines in 40 of 40 runs; with the limit in none, at about a quarter of the cost and with every task solved. |
The benchmark also decided what the package does not add:
- Rules that kept file work out of
bashcost more calls and tokens without solving more tasks. - Rules that replaced or extended Pi's
codemoderule made scripts return more and cost more. - A rule that names the tools scripts cannot call, such as
agent_run, showed no benefit: without it a quarter of the runs that start agents from a script fail once and then call the tool directly; with it 0 of 12 did, within the spread of runs without it. - Notes on
rg's exit code,-h, and-Ishowed no benefit and cost Haiku extra calls.
The prompt patches state facts or recommend with a reason, and leave the choice of tool to the model.
Limits
Pi renders the rules of a tool only in its native prompt; a custom system prompt (--system-prompt, SYSTEM.md) gets the <shell> and <jev_classification> sections but neither the tool rules nor the tools section, so the Jev reference is present without the sentence that says when to use it. The same holds while codemode is deferred.
A handler that runs earlier and forces the complete system prompt (returns systemPrompt) hides these rules. The package then records a warning Debug event with source supi-pi-patches; read it with @mrclrchtr/supi-debug.
The Jev guidance only changes the prompt of Pi's own codemode; the package never registers or activates codemode.
Agent Runs and Reviewer Sessions
Child sessions of @mrclrchtr/supi-agent and @mrclrchtr/supi-review get the same patches without this package installed, and the Jev guidance when they run with codemode.
API
import { registerPiPatches } from "@mrclrchtr/supi-pi-patches/api";
registerPiPatches(pi) registers every patch. Use it as an extension factory for a session that does not load this package's extension. Repeated registrations in one session are harmless.