import { existsSync, mkdirSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
import { execSync } from "node:child_process";
import { mergeMcpJson, removeMcpJson } from "./utils.js";
const MCP_KEY_PATH = ["mcpServers", "wigolo"];
function antigravityDir() {
  return join(homedir(), ".antigravity");
}
function detect() {
  if (existsSync(antigravityDir())) return true;
  try {
    execSync("which antigravity", { stdio: ["pipe", "pipe", "pipe"] });
    return true;
  } catch {
    return false;
  }
}
async function installMcp(cmd) {
  const dir = antigravityDir();
  mkdirSync(dir, { recursive: true });
  const configPath = join(dir, "mcp.json");
  mergeMcpJson(configPath, { command: cmd.command, args: cmd.args }, MCP_KEY_PATH);
}
async function uninstall() {
  const removed = [];
  const configPath = join(antigravityDir(), "mcp.json");
  if (existsSync(configPath)) {
    removeMcpJson(configPath, MCP_KEY_PATH);
    removed.push("~/.antigravity/mcp.json (wigolo entry)");
  }
  return { removed };
}
const antigravityHandler = {
  id: "antigravity",
  displayName: "Antigravity",
  supportsSkills: false,
  supportsCommands: false,
  detect,
  installMcp,
  // No instructions layer for antigravity (config format unclear, MCP only)
  installInstructions: async () => {
  },
  uninstall
};
export {
  antigravityHandler
};
//# sourceMappingURL=antigravity.js.map