const { runStatus } = require("../lib/doctor");

module.exports = async function status(_args, flags) {
  const rootDir = process.cwd();
  const data = runStatus(rootDir);

  if (flags.json) {
    console.log(JSON.stringify(data, null, 2));
    return;
  }

  console.log("\n## CapInt Status (read-only)\n");
  console.log(`Package: @bcelep/capint v${data.capint_package}`);
  console.log(`Matrix: ${data.matrix_version || "—"} (${data.matrix_updated || "—"})`);
  console.log(`Skills on disk: ${data.skills_on_disk} (core registry: ${data.core_skills})`);
  console.log(`Doctor: ${data.doctor_pass ? "pass" : "fail"} (issues: ${data.issues_count}, warnings: ${data.warnings_count})`);
  console.log(`Providers default: memory=${data.provider_defaults.memory}, graph=${data.provider_defaults.graph}`);
  if (data.context) {
    console.log(`Context preset: ${data.context.preset || "—"}`);
  }
  console.log("");
};
