import type { ExtensionAPI } from "@jaeswift/jae-coding-agent";

const TEACH_PROMPT = `
# Teach Mode Active

You are in TEACH MODE. For every action you take:
1. Explain WHY you are making this decision (not just what)
2. Describe alternative approaches you considered and why you rejected them
3. Point out patterns, best practices, and potential pitfalls
4. When writing code, add educational comments explaining non-obvious logic
5. After completing a task, provide a brief summary of what was learned
6. Use analogies and examples to clarify complex concepts
7. Highlight any trade-offs being made (performance vs readability, etc.)
`;

export default function (pi: ExtensionAPI) {
  let teachModeOn = false;

  pi.on("before_agent_start", async (_event, _ctx) => {
    if (teachModeOn) {
      return { systemPrompt: TEACH_PROMPT };
    }
  });

  pi.registerCommand("teach", {
    description: "Toggle teach mode - JAE explains every decision in detail",
    handler: async (_args, ctx) => {
      teachModeOn = !teachModeOn;
      ctx.ui.setStatus("teach-mode", teachModeOn ? "\u{1F393} Teach Mode" : undefined);
      ctx.ui.notify(
        teachModeOn
          ? "\u{1F393} Teach Mode ON - JAE will explain every decision in detail."
          : "\u{1F393} Teach Mode OFF - Back to normal operation.",
        "info",
      );
    },
  });
}
