From e8bc4e4da73fa3a8ef31c571ceff6db799e23c0a Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Sun, 26 Apr 2026 08:58:58 -0400 Subject: [PATCH] fix(pi): guard prompt replacement to anthropic-only and preserve pi-coding-agent --- .../config/extensions/replace-pi-with-claude-code.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/home/programs/terminal/pi/config/extensions/replace-pi-with-claude-code.ts b/modules/home/programs/terminal/pi/config/extensions/replace-pi-with-claude-code.ts index b2206a0..82787c5 100644 --- a/modules/home/programs/terminal/pi/config/extensions/replace-pi-with-claude-code.ts +++ b/modules/home/programs/terminal/pi/config/extensions/replace-pi-with-claude-code.ts @@ -1,10 +1,17 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; export default function replacePiWithClaudeCodeExtension(pi: ExtensionAPI) { - pi.on("before_agent_start", async (event) => { + pi.on("before_agent_start", async (event, ctx) => { + // Anthropic-Only Guard - Other providers (e.g. OpenAI, Google) should + // see the unmodified pi system prompt. + if (ctx.model?.provider !== "anthropic") { + return undefined; + } + // Replace "pi" With "claude code" - Exclude Literal ".pi" (e.g. Paths) + // And "pi-coding-agent" (Package Name) const transformedSystemPrompt = event.systemPrompt.replace( - /(?