pi-purge README

The project's README from github.com/ZiChuanLan/pi-purge. As one markdown file: README.md.

pi-purge

English | 中文 | 日本語

A pi extension for system-prompt experiments: /purge switches which system prompt a session runs with — pi's stock prompt, a trimmed variant, or only a persona prompt.

It is meant for prompt engineering work: comparing how the same request behaves when the harness prompt is present, trimmed, or absent; regression-testing your own instructions; and studying instruction-following and prompt-injection robustness under controlled conditions.

With it off, nothing changes — no prompt rewrite, no disk reads. pi behaves exactly as if the extension were not installed.

Not Only PI?

https://github.com/ZiChuanLan/agent-purge

Install

pi install git:github.com/ZiChuanLan/pi-purge@ffafeb9
pi install npm:pi-purge

Then, inside a session:

/purge

That is all. A short example prompt ships inside the package, so a fresh install works with no extra files. To run your own instructions instead:

/purge source C:/prompts/my-instructions.md
/purge mode replace
/purge on

/purge source embedded switches back to the bundled persona.

Commands

Command Effect
/purge Toggle on/off for this session
/purge on / off Enable or disable the rewrite
/purge status Mode, prompt source, loaded size, and what the previous turn actually changed
/purge mode append|replace|strict Switch composition mode (default strict)
/purge source <path|embedded> Change the prompt file, or go back to the bundled example; a failed switch rolls back
/purge reload Re-read an external prompt file after editing it

Modes

Mode System prompt sent to the model Use it when
append Your prompt prepended to pi's prompt, unchanged. You want a control run: baseline behavior plus your instructions on top.
replace Your prompt, then pi's prompt with its built-in assistant identity line and bundled documentation section removed. Tool list, guidelines, and project context stay. You want to measure the effect of the harness framing without losing tool context.
fallback Behaves like replace only when the prompt came from an external file; with the bundled example the host prompt is left untouched for the whole turn. You want "installed but unobtrusive": stock behavior by default, takeover only once /purge source points at your own file. Mirrors upstream dsh-purge's default policy.
strict Your prompt plus Current working directory: … only. You want to isolate your instructions as a single variable. This is the default.

replace / fallback locate both sections by anchors: the documentation block is cut as a whole <docs>…</docs> span, and the identity line has entries for both pi ≤1.4 and ≥1.5.2 wording, with a single-line template as a last resort. If no anchor matches it leaves the prompt intact rather than cutting the wrong text — /purge status then reports 身份段 未匹配 (identity line not found) and behavior falls back to append. strict does no matching at all, so it behaves the same across pi versions. On omp, which supplies a prompt block array without these pi-specific anchors, replace also leaves the host prompt intact; use strict when the harness framing must be gone.

{{cwd}} inside your prompt is replaced with the session's real working directory (POSIX form); under strict the same path is still appended as Current working directory: ….

Tool schemas are passed through the API tools parameter rather than the system prompt, so tools keep working in every mode, including strict.

Session scope and defaults

Upgrading from 0.1.x

0.2 no longer writes or reads pi-purge.json, and it no longer auto-detects a prompt file — the persona is bundled and the mode defaults to strict.

Notes for experiments

Development

npm test   # two suites; both run against temporary agent dirs and assert nothing is written

The extension registers one before_agent_start hook, one session_start hook, and a /purge command. No other hooks, no background work, no file writes.

Credits

The mechanism here is ported from YuJunZhiXue/dsh-purge: the idea of removing the harness identity line rather than drowning it out, the three composition modes, and the bundled prompt all come from that project. Credited and linked here as its author requires.

Non-profit, study and research only. Users bear full responsibility for how they use this software. It must not be used for any unlawful purpose.

Zero tolerance. The authors do not support, encourage, or assist unauthorized network attacks, exploitation, data theft, intrusion into information systems, or the generation of illegal content. Any such use is unrelated to the authors, and the person doing it bears the full legal responsibility alone.

No illegal content. The code, docs, and bundled prompt are not malware, backdoors, unauthorized penetration tooling, ransomware, credential-stuffing scripts, or attack payloads aimed at public or third-party systems.

Local use on your own pi only. Prompt substitution happens entirely inside the official pi installation on the user's own machine (@earendil-works/pi-coding-agent, the local agent directory and profile). The target is your own local software, not someone else's website, server, account, or information system.

No outbound networking. This extension only rewrites the system prompt inside the local process. It opens no network connections, and it does not scan, probe, intrude on, or send attack traffic to any public host or unauthorized system. Do not use it as a stepping stone against external networks.

Authorized, controlled scope only. This is an aid for prompt-engineering and robustness evaluation on an official pi installation you are entitled to administer. Do not run it against targets you lack written authorization for, against public online systems, or in production. All testing must stay within your own authorized local pi, offline synthetic fixtures, authorized exercise ranges, and compliant lab environments.

Mainland China, Hong Kong, and Macao are off limits. Do not access, scan, probe, or otherwise operate against networks in mainland China, Hong Kong, or Macao, nor against servers, sites, or addresses that resolve into those ranges. Naming a cloud provider is not an exception. The only exception is the single exact IP or the single fully qualified hostname the user has registered beforehand as their own server. Keys, passwords, CIDR blocks, wildcards, and verbal statements in a conversation add no exception. Unregistered means prohibited, without exception.

Prohibited uses. Users must not use this project, directly or indirectly, to violate any of the following, and must comply with each without exception:

Also prohibited: unauthorized penetration or attack against public or private information systems, extortion, damage, credential stuffing, or malware distribution; producing or spreading content that endangers national security, promotes terrorism or graphic violence, is obscene or gambling-related, fraudulent, or infringes privacy or intellectual property; and violating the terms of service or abuse policies of any model provider.

User assumes all liability. This project is provided "as is" under the MIT License, without warranty of any kind, express or implied, as to completeness, security, or fitness for purpose. Users bear sole and complete civil, administrative, and criminal liability for their own download, deployment, execution, modification, and distribution of this software, and for all inputs and outputs that result. The authors and contributors accept no direct, indirect, or consequential liability arising from misuse.

License terminates on breach. Any person or entity that uses this project for illegal attacks, malicious activity, or other violations has its open-source license terminated automatically and irrevocably from the date of the violation. That party must stop using the project immediately, permanently destroy all copies of its code, scripts, and derived data, and face the applicable legal consequences.

Third-party independence. This is a fully independent open-source security research project. It has no affiliation, commercial partnership, authorization, or official endorsement from pi or any related entity. The word "official" refers only to the fact that the evaluation target is the official pi package installed on the user's machine; it does not mean pi develops, endorses, or vouches for this extension.

Attribution required. Anyone reusing this project's name, approach, code, or prompt must credit the author and link this repository. Failure to attribute will be pursued legally.

License


提示词仓库 https://github.com/ZiChuanLan/some-magic


MIT


感谢 LINUX DO 社区

pi-purge (ZiChuanLan/pi-purge)

Searching Database…

What is this?A pi extension that lets the /purge command swap out pi's built-in assistant persona and system prompt for your own prompt file, so you can run prompt-engineering experiments on the exact same request under different system prompts.
Is this a standalone app, or does it plug into something else?It is a lightweight extension for the pi coding agent (@earendil-works/pi-coding-agent) — it adds one /purge command and two hooks inside an existing pi installation rather than running as its own program.
How do I turn it on in a session?After installing the extension into pi, run /purge on inside a session; it ships with a bundled example persona prompt so a fresh install needs no extra files, or you can point it at your own file with /purge source .
Do I need pi already installed?Yes, this only works inside an existing pi coding agent installation — it rewrites the system prompt inside that local process and has nothing to run on its own.
Does it stay enabled across sessions?No, every session start (startup, new, resume, reload) begins with purge disabled and nothing is ever written to disk, so you have to re-enable it each time.
Does it send any data anywhere?No, it only rewrites the in-process system prompt and makes no outbound connections at all.
What are the three prompt composition modes?append prepends your prompt to pi's full prompt as a baseline; replace strips pi's identity line and docs section but keeps tools and guidelines; strict (the default) sends only your prompt plus the working directory, isolating your instructions as a single variable.
What happens if a pi update changes the wording it tries to strip?replace mode matches pi's identity line and docs section by exact wording, so if an update rewords them it leaves the prompt untouched and falls back to append behavior, reporting that the identity line was not found. strict mode isn't affected since it does no text matching at all.
Why was this built?It exists to let researchers compare an agent's behavior with its harness persona present, trimmed, or absent, for regression-testing custom instructions and studying instruction-following and prompt-injection robustness under controlled conditions.
Where does the mechanism come from?It's ported from YuJunZhiXue/dsh-purge, reusing that project's idea of removing the harness identity line, its three composition modes, and the bundled example prompt.
Creator
ZiChuanLan
Size
0.1 MB
Stars
811
Updated
CommitNov 12
Age
1mo
Commits · 90 Days