#!/usr/bin/env node
"use strict";
var import_commander = require("commander");
var import_banner = require("./banner");
var import_help = require("./commands/help");
var import_init = require("./commands/init");
var import_uninit = require("./commands/uninit");
var import_commands = require("./commands/index");
var import_sync = require("./commands/sync");
var import_status = require("./commands/status");
var import_query = require("./commands/query");
var import_files = require("./commands/files");
var import_context = require("./commands/context");
var import_affected = require("./commands/affected");
var import_mark_dirty = require("./commands/mark-dirty");
var import_sync_if_dirty = require("./commands/sync-if-dirty");
var import_unlock = require("./commands/unlock");
var import_install = require("./commands/install");
var import_serve = require("./commands/serve");
var import_dashboard = require("./commands/dashboard");
var import_architecture = require("./commands/architecture");
var import_coupling = require("./commands/coupling");
var import_package = require("./commands/package");
var import_caveman = require("./commands/caveman");
var import_dead_code = require("./commands/dead-code");
var import_hotspots = require("./commands/hotspots");
var import_surprising = require("./commands/surprising");
var import_snapshot = require("./commands/snapshot");
var import_path = require("./commands/path");
var import_export = require("./commands/export");
var import_gain = require("./commands/gain");
var import_compression = require("./commands/compression");
var import_exec = require("./commands/exec");
var import_memory = require("./commands/memory");
var import_docs = require("./commands/docs");
process.on("uncaughtException", (err) => {
  const msg = err?.message ?? String(err);
  const isWasmAbort = msg.includes("Aborted(") || msg.includes("RuntimeError") || err?.constructor?.name === "RuntimeError";
  if (isWasmAbort) {
    process.stderr.write([
      "",
      "  \u2716 KiroGraph crashed: SQLite WASM runtime aborted.",
      "",
      "  Most likely cause: another process (e.g. the Kiro MCP server) is",
      "  holding the database open while indexing is running.",
      "",
      "  How to fix:",
      "    1. Close Kiro IDE (or disable the kirograph MCP server) before indexing",
      "    2. Run: kirograph unlock",
      "    3. Then retry: kirograph index",
      "",
      "  If the problem persists, delete the lock manually:",
      "    del .kirograph\\kirograph.db.lock  (Windows)",
      "    rm -rf .kirograph/kirograph.db.lock  (macOS/Linux)",
      ""
    ].join("\n"));
    process.exit(1);
  }
  process.stderr.write(`Uncaught error: ${msg}
`);
  process.exit(1);
});
const program = new import_commander.Command();
program.name("kirograph").description("Semantic code knowledge graph for Kiro").version("0.16.0").addHelpCommand(true).hook("preAction", (thisCommand) => {
  const name = thisCommand.name();
  if (name === "init") (0, import_banner.printBanner)();
});
(0, import_install.register)(program);
(0, import_init.register)(program);
(0, import_uninit.register)(program);
(0, import_commands.register)(program);
(0, import_sync.register)(program);
(0, import_sync_if_dirty.register)(program);
(0, import_mark_dirty.register)(program);
(0, import_status.register)(program);
(0, import_query.register)(program);
(0, import_context.register)(program);
(0, import_files.register)(program);
(0, import_affected.register)(program);
(0, import_unlock.register)(program);
(0, import_serve.register)(program);
(0, import_dashboard.register)(program);
(0, import_architecture.register)(program);
(0, import_coupling.register)(program);
(0, import_package.register)(program);
(0, import_caveman.register)(program);
(0, import_dead_code.register)(program);
(0, import_hotspots.register)(program);
(0, import_surprising.register)(program);
(0, import_snapshot.register)(program);
(0, import_path.register)(program);
(0, import_export.register)(program);
(0, import_gain.register)(program);
(0, import_compression.register)(program);
(0, import_exec.register)(program);
(0, import_memory.register)(program);
(0, import_docs.register)(program);
if (process.argv.length === 2) {
  (0, import_banner.printBanner)();
  (0, import_help.printColoredHelp)();
  process.exit(0);
}
(0, import_help.register)(program);
program.parse(process.argv);
//# sourceMappingURL=kirograph.js.map
