pi-purge README

README проекта с github.com/ZiChuanLan/pi-purge. Одним файлом markdown: 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)

Ищем в базе…

Что это такое?Расширение для pi, которое позволяет команде /purge заменить встроенную персону ассистента и системный промпт pi на ваш собственный файл с промптом, чтобы проводить эксперименты по промпт-инжинирингу с одним и тем же запросом под разными системными промптами.
Это отдельное приложение или оно встраивается в что-то другое?Это лёгкое расширение для pi coding agent (@earendil-works/pi-coding-agent). Оно добавляет одну команду /purge и два хука в уже установленный pi и не работает как самостоятельная программа.
Как его включить в сессии?После установки расширения в pi запустите /purge on внутри сессии. В комплекте идёт пример промпта персоны, поэтому для новой установки не нужны дополнительные файлы. Или можно указать свой файл командой /purge source .
Нужно ли, чтобы pi уже был установлен?Да, это работает только внутри уже установленного pi coding agent. Расширение переписывает системный промпт внутри локального процесса и само по себе ничего не запускает.
Сохраняется ли режим между сессиями?Нет, при каждом старте сессии (startup, new, resume, reload) purge начинает в выключенном состоянии, и ничего не записывается на диск. Поэтому включать его придётся заново каждый раз.
Отправляет ли это какие-нибудь данные куда-либо?Нет, оно только переписывает системный промпт внутри процесса и не делает никаких исходящих соединений.
Какие есть три режима сборки промпта?append ставит ваш промпт перед полным промптом pi как основу. replace убирает строку идентичности pi и раздел документации, но оставляет инструменты и рекомендации. strict (по умолчанию) отправляет только ваш промпт и рабочую директорию, изолируя ваши инструкции как единственную переменную.
Что происходит, если обновление pi меняет формулировки, которые расширение пытается убрать?Режим replace ищет строку идентичности и раздел документации pi по точному совпадению текста. Если обновление их переформулирует, он не трогает промпт и переходит к поведению append, сообщая, что строка идентичности не найдена. Режим strict от этого не зависит, так как вообще не сопоставляет текст.
Зачем это создали?Чтобы исследователи могли сравнивать поведение агента, когда персона обвязки присутствует, урезана или отсутствует. Это нужно для регрессионного тестирования пользовательских инструкций и для изучения того, насколько хорошо модель следует инструкциям и устойчива к атакам с внедрением инструкций, в контролируемых условиях.
Откуда взят этот механизм?Он портирован из проекта YuJunZhiXue/dsh-purge и повторяет его идеи: удаление строки идентичности обвязки, три режима сборки промпта и пример промпта из комплекта.
Автор
ZiChuanLan
Размер
0.1 MB
Звёзды
803
Обновлён
КоммитNov 12
Возраст
1 мес
Коммиты · 90 дней