import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { isToolCallEventType } from "@earendil-works/pi-coding-agent";

export default function (pi: ExtensionAPI) {
  pi.on("tool_call", async (event, ctx) => {
    if (!isToolCallEventType("bash", event)) return;

    const cmd = event.input.command || "";
    const isYxCommand = cmd.includes("yx ");

    // Allow yaks in interactive mode, block in print mode (sub-agents)
    if (isYxCommand && ctx.mode === "print") {
      return {
        block: true,
        reason: "yx commands are disabled in print mode. Sub-agents must focus on domain work only.",
      };
    }
  });
}
