// cli/commands/health.ts — planu health (SPEC-609)
import { handleWorkspaceHealth } from '../../tools/workspace-dashboard-handler.js';
import { formatToolResult } from '../formatter.js';
import { bold, green, red } from '../colors.js';
export const healthCommand = {
    name: 'health',
    description: 'Check workspace health across all registered projects',
    usage: 'planu health [--threshold 80]',
    async run(args, flags) {
        const { parseArgs } = await import('node:util');
        const { values } = parseArgs({
            args,
            options: {
                threshold: { type: 'string', short: 't' },
            },
            strict: false,
            allowPositionals: true,
        });
        const healthThreshold = values.threshold ? Number(values.threshold) : undefined;
        if (!flags?.quiet && !flags?.json) {
            process.stdout.write(`${bold('Checking workspace health...')}\n\n`);
        }
        const result = await handleWorkspaceHealth({ healthThreshold });
        if (result.isError) {
            process.stderr.write(`${red(formatToolResult(result, flags))}\n`);
            process.exitCode = 1;
            return;
        }
        const output = formatToolResult(result, flags);
        if (output) {
            process.stdout.write(output + '\n');
        }
        else if (!flags?.quiet && !flags?.json) {
            process.stdout.write(`${green('Workspace health check complete.')}\n`);
        }
    },
};
//# sourceMappingURL=health.js.map