Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
767 B · 30 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031/** * Protected Paths Extension * * Blocks edit operations to protected paths. * Useful for preventing accidental modifications to sensitive files. */
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) { const protectedPaths = [".env", ".git/", "node_modules/"];
pi.on("tool_call", async (event, ctx) => { if (event.toolName !== "edit") { return undefined; }
const path = event.input.path as string; const isProtected = protectedPaths.some((p) => path.includes(p));
if (isProtected) { if (ctx.hasUI) { ctx.ui.notify(`Blocked edit to protected path: ${path}`, "warning"); } return { block: true, reason: `Path "${path}" is protected` }; }
return undefined; });}