fix(pi): guard prompt replacement to anthropic-only and preserve pi-coding-agent

This commit is contained in:
2026-04-26 08:58:58 -04:00
parent 8e11fe06de
commit e8bc4e4da7

View File

@@ -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(
/(?<!\.)pi/gi,
/(?<!\.)pi(?!-coding-agent)/gi,
"claude code",
);