import { entity, warning } from '../output/style.js';
import { analyzeApplicationVersionLogs } from '../srv/analyze-application-version-logs.js';
import { createApplicationVersionCommand } from './common/application-version-command-factory.js';

const command = createApplicationVersionCommand({
    name: 'ai-analyze',
    desc: 'Analyze application version logs with AI (BETA)',
    usage: 'afctl ai-analyze APPLICATION [VERSION]',
    serviceCall: analyzeApplicationVersionLogs,
    formatOutput: (result) => [
        warning(
            'Please note that this is a Beta feature that should not be used in productive environment.\n' +
            'The following recommendations are AI-generated suggestions and may be incomplete or inaccurate. ' +
            'Please carefully review them before implementing in your code or setup.\n\n'
        ),
        entity('Analyze result:\n'),
        result?.analysis || ''
    ]
});

export const getMetadata = command.getMetadata;
export const getCompletion = command.getCompletion;
export const run = command.run;
