fix(pi): guard prompt replacement to anthropic-only and preserve pi-coding-agent
This commit is contained in:
@@ -1,10 +1,17 @@
|
|||||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||||
|
|
||||||
export default function replacePiWithClaudeCodeExtension(pi: ExtensionAPI) {
|
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)
|
// Replace "pi" With "claude code" - Exclude Literal ".pi" (e.g. Paths)
|
||||||
|
// And "pi-coding-agent" (Package Name)
|
||||||
const transformedSystemPrompt = event.systemPrompt.replace(
|
const transformedSystemPrompt = event.systemPrompt.replace(
|
||||||
/(?<!\.)pi/gi,
|
/(?<!\.)pi(?!-coding-agent)/gi,
|
||||||
"claude code",
|
"claude code",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user