// src/slash-commands/types.ts
var VALID_PLATFORMS = ["claude-code", "gemini-cli", "codex", "cursor"];
var GENERATED_HEADER_CLAUDE = "<!-- Generated by harness generate-slash-commands. Do not edit. -->";
var GENERATED_HEADER_GEMINI = "# Generated by harness generate-slash-commands. Do not edit.";
var GENERATED_HEADER_CURSOR = "<!-- Generated by harness generate-slash-commands. Do not edit. -->";
var GENERATED_HEADER_CODEX = "<!-- Generated by harness generate-slash-commands. Do not edit. -->";

// src/slash-commands/sync.ts
import fs from "fs";
import path from "path";

// src/agent-definitions/constants.ts
var GENERATED_HEADER_AGENT = "<!-- Generated by harness generate-agent-definitions. Do not edit. -->";

// src/slash-commands/sync.ts
function computeSyncPlan(outputDir, rendered) {
  const added = [];
  const updated = [];
  const removed = [];
  const unchanged = [];
  for (const [filename, content] of rendered) {
    const filePath = path.join(outputDir, filename);
    if (!fs.existsSync(filePath)) {
      added.push(filename);
    } else {
      const existing = fs.readFileSync(filePath, "utf-8");
      if (existing === content) {
        unchanged.push(filename);
      } else {
        updated.push(filename);
      }
    }
  }
  if (fs.existsSync(outputDir)) {
    const existing = fs.readdirSync(outputDir).filter((f) => {
      const stat = fs.statSync(path.join(outputDir, f));
      return stat.isFile();
    });
    for (const filename of existing) {
      if (rendered.has(filename)) continue;
      const content = fs.readFileSync(path.join(outputDir, filename), "utf-8");
      if (content.includes(GENERATED_HEADER_CLAUDE) || content.includes(GENERATED_HEADER_GEMINI) || content.includes(GENERATED_HEADER_AGENT)) {
        removed.push(filename);
      }
    }
  }
  return { added, updated, removed, unchanged };
}
function applySyncPlan(outputDir, rendered, plan, deleteOrphans) {
  fs.mkdirSync(outputDir, { recursive: true });
  for (const filename of [...plan.added, ...plan.updated]) {
    const content = rendered.get(filename);
    if (content !== void 0) {
      fs.writeFileSync(path.join(outputDir, filename), content);
    }
  }
  if (deleteOrphans) {
    for (const filename of plan.removed) {
      const filePath = path.join(outputDir, filename);
      if (fs.existsSync(filePath)) {
        fs.unlinkSync(filePath);
      }
    }
  }
}

export {
  GENERATED_HEADER_AGENT,
  VALID_PLATFORMS,
  GENERATED_HEADER_CLAUDE,
  GENERATED_HEADER_GEMINI,
  GENERATED_HEADER_CURSOR,
  GENERATED_HEADER_CODEX,
  computeSyncPlan,
  applySyncPlan
};
