#!/usr/bin/env node
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
import {
  loadEnv
} from "./chunk-25DJSF2K.js";
import "./chunk-SAKJMNSR.js";
import "./chunk-MWW62YZP.js";
import {
  resolveVaultDir
} from "./chunk-N33KUCFP.js";
import "./chunk-RNWALAFP.js";
import "./chunk-WBLTISAK.js";
import "./chunk-PZUWP5VK.js";

// src/cli.ts
import fs from "fs";
import path from "path";
loadEnv();
var USAGE = `Usage: myco <command> [args]

Commands:
  init [options]           Initialize a new vault
  config <get|set> [args]  Get or set vault config values
  curate [options]         Scan vault and supersede stale spores (--dry-run)
  detect-providers         Detect available LLM/embedding providers (JSON)
  verify                   Test LLM and embedding connectivity
  stats                    Vault health, index counts, vector count
  search <query>           Combined FTS + vector search with scores
  vectors <query>          Raw vector search with similarity scores
  session [id|latest]      Show a session note
  logs [options]           View daemon logs
  setup-llm [options]      Configure LLM and embedding providers
  setup-digest [options]   Configure digest and capture settings
  digest [options]         Run a digest cycle (--tier N, --full)
  restart                  Restart the daemon
  rebuild                  Reindex the entire vault
  reprocess [options]      Re-extract observations, regenerate summaries, re-index
  version                  Show plugin version
`;
async function main() {
  const [cmd, ...args] = process.argv.slice(2);
  if (!cmd || cmd === "--help" || cmd === "-h") {
    process.stdout.write(USAGE);
    return;
  }
  if (cmd === "init") return (await import("./init-7N7F6W6U.js")).run(args);
  if (cmd === "detect-providers") return (await import("./detect-providers-I2QQFDJW.js")).run(args);
  if (cmd === "version" || cmd === "--version" || cmd === "-v") {
    const { getPluginVersion } = await import("./version-NKOECSVH.js");
    console.log(getPluginVersion());
    return;
  }
  const vaultDir = resolveVaultDir();
  if (!fs.existsSync(path.join(vaultDir, "myco.yaml"))) {
    console.error(`No myco.yaml found in ${vaultDir}. Run 'myco init' first.`);
    process.exit(1);
  }
  switch (cmd) {
    case "config":
      return (await import("./config-HDUFDOQN.js")).run(args, vaultDir);
    case "curate":
      return (await import("./curate-DYE4VCBJ.js")).run(args, vaultDir);
    case "verify":
      return (await import("./verify-MG5O7SBU.js")).run(args, vaultDir);
    case "stats":
      return (await import("./stats-2OUQSEZO.js")).run(args, vaultDir);
    case "search":
      return (await import("./search-SWMJ4MZ3.js")).run(args, vaultDir);
    case "vectors":
      return (await import("./search-SWMJ4MZ3.js")).runVectors(args, vaultDir);
    case "session":
      return (await import("./session-F326AWCH.js")).run(args, vaultDir);
    case "setup-llm":
      return (await import("./setup-llm-PCZ64ALK.js")).run(args, vaultDir);
    case "setup-digest":
      return (await import("./setup-digest-BOYOSM4B.js")).run(args, vaultDir);
    case "digest":
      return (await import("./digest-PNHFM7JJ.js")).run(args, vaultDir);
    case "restart":
      return (await import("./restart-WSJRHRHI.js")).run(args, vaultDir);
    case "rebuild":
      return (await import("./rebuild-WXKQ5HZO.js")).run(args, vaultDir);
    case "reprocess":
      return (await import("./reprocess-PKRDV67L.js")).run(args, vaultDir);
    case "logs":
      return (await import("./logs-IENORIYR.js")).run(args, vaultDir);
    default:
      console.error(`Unknown command: ${cmd}`);
      process.stdout.write(USAGE);
      process.exit(1);
  }
}
main().catch((err) => {
  console.error(`myco: ${err.message}`);
  process.exit(1);
});
//# sourceMappingURL=cli-LMBBPV2D.js.map