import { init_paths_state, resolveStateDir } from "../../../config/paths-state.js";
import { formatExamples, register } from "../../registry.js";
import { runDoctor } from "./flow.js";
import { Command } from "commander";
//#region src/cli/commands/doctor/index.ts
init_paths_state();
function createDoctorCommand(ctx) {
	return new Command("doctor").description("Check xopc installation health and diagnose common issues").option("--fix", "Automatically apply safe fixes", false).option("--json", "Output results as JSON", false).option("--deep", "Run deeper / slower checks (e.g. session scan)", false).option("--security", "Run gateway security audit only (structured findings)", false).addHelpText("after", formatExamples([
		"xopc doctor",
		"xopc doctor --json",
		"xopc doctor --deep",
		"xopc doctor --security",
		"xopc doctor --fix"
	])).action(async (opts) => {
		const configPath = ctx.configPath;
		if ((await runDoctor({
			configPath,
			stateDir: resolveStateDir(),
			options: {
				fix: Boolean(opts.fix),
				json: Boolean(opts.json),
				deep: Boolean(opts.deep),
				security: Boolean(opts.security)
			}
		})).some((r) => r.status === "fail")) process.exitCode = 1;
	});
}
register({
	id: "doctor",
	name: "doctor",
	description: "Check xopc installation health and diagnose common issues",
	factory: createDoctorCommand,
	metadata: {
		category: "maintenance",
		examples: [
			"xopc doctor",
			"xopc doctor --json",
			"xopc doctor --deep",
			"xopc doctor --security",
			"xopc doctor --fix"
		]
	}
});
//#endregion
export {};

//# sourceMappingURL=index.js.map