"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var antigravity_exports = {};
__export(antigravity_exports, {
  installAntigravityEarly: () => installAntigravityEarly,
  installAntigravityLate: () => installAntigravityLate,
  printAntigravityNextSteps: () => printAntigravityNextSteps,
  uninitAntigravity: () => uninitAntigravity
});
module.exports = __toCommonJS(antigravity_exports);
var fs = __toESM(require("fs"));
var path = __toESM(require("path"));
var import_common = require("../common");
var import_instructions = require("../instructions");
const ANTIGRAVITY_BLOCK_ID = "antigravity";
function buildAntigravityHooks() {
  return {
    "kirograph-sync": {
      Stop: [
        {
          hooks: [
            {
              type: "command",
              command: "kirograph sync --quiet 2>/dev/null || true",
              timeout: 30
            }
          ]
        }
      ]
    }
  };
}
function installAntigravityEarly(_projectRoot) {
}
function installAntigravityLate(projectRoot, cavemanMode, shellCompressionLevel, enableMemory) {
  const opts = (0, import_common.buildInstructionOpts)(cavemanMode, shellCompressionLevel, enableMemory, true);
  const instructionsPath = path.join(projectRoot, ".kirograph", "antigravity.md");
  (0, import_common.ensureDir)(path.dirname(instructionsPath));
  fs.writeFileSync(instructionsPath, (0, import_instructions.buildAgentInstructions)(opts));
  console.log(`  \u2713 Antigravity instructions written to ${instructionsPath}`);
  const geminiPath = path.join(projectRoot, "GEMINI.md");
  const changed = (0, import_common.upsertGeneratedBlock)(geminiPath, ANTIGRAVITY_BLOCK_ID, "## KiroGraph", (0, import_instructions.buildAgentInstructions)(opts));
  console.log(changed ? `  \u2713 GEMINI.md updated with KiroGraph instructions` : `  \u2713 GEMINI.md already up to date`);
  const hooksPath = path.join(projectRoot, ".agents", "hooks.json");
  (0, import_common.ensureDir)(path.dirname(hooksPath));
  const existing = (0, import_common.readJson)(hooksPath);
  const kgHooks = buildAntigravityHooks();
  for (const [name, config] of Object.entries(kgHooks)) {
    if (!existing[name]) {
      existing[name] = config;
    }
  }
  (0, import_common.writeJson)(hooksPath, existing);
  console.log(`  \u2713 Antigravity hooks written to ${hooksPath}`);
}
function uninitAntigravity(projectRoot) {
  const geminiPath = path.join(projectRoot, "GEMINI.md");
  if ((0, import_common.removeGeneratedBlock)(geminiPath, ANTIGRAVITY_BLOCK_ID)) {
    console.log(`  \u2713 Removed KiroGraph block from GEMINI.md`);
  }
  const hooksPath = path.join(projectRoot, ".agents", "hooks.json");
  if (fs.existsSync(hooksPath)) {
    const config = (0, import_common.readJson)(hooksPath);
    if (config["kirograph-sync"]) {
      delete config["kirograph-sync"];
      (0, import_common.writeJson)(hooksPath, config);
      console.log(`  \u2713 Removed kirograph-sync from .agents/hooks.json`);
    }
  }
}
function printAntigravityNextSteps(projectRoot) {
  console.log("\n  Done! KiroGraph instructions are in GEMINI.md.");
  console.log("  Auto-sync hook installed in .agents/hooks.json");
  (0, import_common.printMcpSetup)("~/.gemini/antigravity/mcp_config.json", projectRoot);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  installAntigravityEarly,
  installAntigravityLate,
  printAntigravityNextSteps,
  uninitAntigravity
});
//# sourceMappingURL=antigravity.js.map
