repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/terse/index.ts
RawFile outline
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
const TERSE_TITLE = "## Response Protocol — terse";
const SDK_DATE_FOOTER = "\nCurrent date:"; // Pi SDK appends date/cwd footer last.
const TERSE_RULES = [
"- Output only. No preamble, no recap, no hedging.",
"- Drop articles/conjunctions/filler. Fragments OK.",
"- Abbrev: DB/auth/config/req/res/fn/impl/ref/ctx.",
"- Causality: X → Y → Z. Lists: •. Alternatives: A | B.",
"- Repeated concept >2x → α/β/γ if clear.",
"- Prefer symbols: ∀/∃/∧/∨/¬/≈/≠/≤/≥ when useful.",
"- Code, tool args, file contents, quoted errors: exact, uncompressed.",
"- Security/user confusion/destructive ops: clarity > compression.",
];
export const TERSE_BLOCK = [TERSE_TITLE, ...TERSE_RULES].join("\n");
// Insert before SDK date/cwd footer: late enough to dominate style, not after metadata.
export function injectTerseBlock(prompt: string): string {
if (prompt.includes(TERSE_TITLE)) return prompt;
const footer = prompt.lastIndexOf(SDK_DATE_FOOTER);
return footer >= 0
? `${prompt.slice(0, footer)}\n\n${TERSE_BLOCK}${prompt.slice(footer)}`
: `${prompt}\n\n${TERSE_BLOCK}`;
}
export default function (pi: ExtensionAPI) {
pi.on("before_agent_start", (event) => ({
systemPrompt: injectTerseBlock(event.systemPrompt),
}));
}