"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var query_exports = {};
__export(query_exports, {
  register: () => register
});
module.exports = __toCommonJS(query_exports);
var import_ui = require("../ui");
function register(program) {
  program.command("query <search>").description("Search for symbols").option("--kind <kind>", "Filter by kind").option("--limit <n>", "Max results", "10").action(async (search, opts) => {
    const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
    const { trackCliToolSaving } = await Promise.resolve().then(() => require("./utils.js"));
    const cwd = process.cwd();
    const cg = await KiroGraph.open(cwd);
    const results = cg.searchNodes(search, opts.kind, parseInt(opts.limit));
    if (results.length === 0) {
      console.log(`  ${import_ui.dim}No results for${import_ui.reset} ${import_ui.violet}${import_ui.bold}${search}${import_ui.reset}`);
    } else {
      console.log();
      for (const r of results) {
        console.log(`  ${import_ui.violet}${import_ui.bold}${r.node.name}${import_ui.reset}  ${import_ui.dim}${r.node.kind}${import_ui.reset}  ${import_ui.dim}${r.node.filePath}:${r.node.startLine}${import_ui.reset}`);
      }
      console.log(`
  ${import_ui.dim}${results.length} result(s)${import_ui.reset}`);
    }
    const output = results.map((r) => `${r.node.name} ${r.node.kind} ${r.node.filePath}:${r.node.startLine}`).join("\n");
    trackCliToolSaving(cwd, "kirograph_search", output, { limit: parseInt(opts.limit) });
    cg.close();
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  register
});
//# sourceMappingURL=query.js.map
