import { z } from 'zod';
import { t } from '../../i18n/index.js';
import { safe, safeLicensed } from '../safe-handler.js';
import { ChecklistFocusEnum, AuditCategoryEnum } from '../schemas/index.js';
import { handleDetectDrift } from '../detect-drift.js';
import { handleSummarizeSpec } from '../summarize-spec.js';
import { handleGenerateChecklist } from '../generate-checklist.js';
import { handleReconcileSpec } from '../reconcile-spec.js';
import { handleLearn } from '../learn.js';
import { handleAudit } from '../audit.js';
import { handleConsultDocs } from '../consult-docs.js';
import { handleDiscoverMcps } from '../discover-mcps.js';
import { handleSuggestMcps } from '../suggest-mcps.js';
/**
 * Registers drift detection, analysis, and discovery tools (tools 11–19) on the MCP server.
 */
export function registerAnalysisTools(server) {
    // 11. detect_drift
    server.registerTool('detect_drift', {
        description: t('tools.detect_drift.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID to check'),
            projectId: z.string().describe('Project ID'),
            mode: z
                .enum(['full', 'quick'])
                .optional()
                .describe('Analysis mode: full | quick (default: quick)'),
            outputFormat: z
                .enum(['report', 'ci-json', 'github-annotations'])
                .optional()
                .describe('Output format: report | ci-json | github-annotations'),
            threshold: z.number().optional().describe('Drift tolerance threshold 0-100 (default: 10)'),
        },
    }, safe(async (args) => handleDetectDrift(args)));
    // 12. summarize_spec
    server.registerTool('summarize_spec', {
        description: t('tools.summarize_spec.description'),
        annotations: { readOnlyHint: true },
        inputSchema: {
            specId: z.string().describe('Spec ID to summarize'),
            projectId: z.string().describe('Project ID'),
            format: z
                .enum(['executive', 'technical', 'oneliner'])
                .optional()
                .describe('Summary format: executive | technical | oneliner (default: technical)'),
        },
    }, async (args) => handleSummarizeSpec(args));
    // 13. generate_checklist
    server.registerTool('generate_checklist', {
        description: t('tools.generate_checklist.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID'),
            projectId: z.string().describe('Project ID'),
            focus: z.array(ChecklistFocusEnum).optional().describe('Focus areas for the checklist'),
        },
    }, safeLicensed('generate_checklist', async (args) => handleGenerateChecklist(args)));
    // 14. reconcile_spec
    server.registerTool('reconcile_spec', {
        description: t('tools.reconcile_spec.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID to reconcile'),
            projectId: z.string().describe('Project ID'),
            autoDetect: z
                .boolean()
                .optional()
                .describe('Auto-detect changes from implementation (default: true)'),
            changes: z
                .array(z.object({
                section: z.string(),
                originalValue: z.string(),
                newValue: z.string(),
                reason: z.string(),
                approved: z.boolean(),
            }))
                .optional()
                .describe('Manual changes to apply'),
        },
    }, safeLicensed('reconcile_spec', async (args) => handleReconcileSpec(args)));
    // 15. learn_pattern
    server.registerTool('learn_pattern', {
        description: t('tools.learn_pattern.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            type: z
                .enum(['architecture', 'convention', 'estimation', 'stack', 'quality'])
                .describe('Pattern type: architecture | convention | estimation | stack | quality'),
            pattern: z.string().describe('Pattern description'),
            source: z.string().optional().describe('Where this pattern was observed'),
        },
    }, safe(async (args) => handleLearn(args)));
    // 16. audit
    server.registerTool('audit', {
        description: t('tools.audit.description'),
        inputSchema: {
            path: z.string().describe('Path to file or directory to audit'),
            projectId: z.string().describe('Project ID'),
            categories: z.array(AuditCategoryEnum).optional().describe('Audit categories to check'),
            specId: z.string().optional().describe('Spec ID to audit against'),
        },
    }, safeLicensed('audit', async (args) => handleAudit(args)));
    // 17. consult_docs
    server.registerTool('consult_docs', {
        description: t('tools.consult_docs.description'),
        inputSchema: {
            topic: z.string().describe('Topic to search for'),
            projectId: z.string().describe('Project ID'),
            framework: z
                .string()
                .optional()
                .describe('Framework to consult docs for (auto-detected if omitted)'),
        },
    }, safe(async (args) => handleConsultDocs(args)));
    // 18. discover_mcps
    server.registerTool('discover_mcps', {
        description: t('tools.discover_mcps.description'),
        inputSchema: {
            configPath: z
                .string()
                .optional()
                .describe('Path to MCP config file (auto-detected if omitted)'),
            projectId: z.string().optional().describe('Project ID'),
        },
    }, safeLicensed('discover_mcps', async (args) => handleDiscoverMcps(args)));
    // 19. suggest_mcps
    server.registerTool('suggest_mcps', {
        description: t('tools.suggest_mcps.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            specId: z.string().optional().describe('Spec ID for context-specific suggestions'),
        },
    }, safeLicensed('suggest_mcps', async (args) => handleSuggestMcps(args)));
}
//# sourceMappingURL=analysis-tools.js.map