import { z } from 'zod';
import { t } from '../../i18n/index.js';
import { safeTracked, safeLicensed } from '../safe-handler.js';
import { DocumentationTypeEnum, GitActionEnum, DevLifecycleCategoryEnum, PMPlatformEnum, PMActionEnum, OrchestrateActionEnum, ManageContextActionEnum, ContextBudgetActionEnum, } from '../schemas/index.js';
import { handleSuggestTooling } from '../suggest-tooling.js';
import { handleGenerateTests } from '../generate-tests.js';
import { handleGenerateDocs } from '../generate-docs.js';
import { handleIntegratePM } from '../integrate-pm.js';
import { handleManageContext } from '../manage-context.js';
import { handleManageGit } from '../manage-git.js';
import { handleOrchestrate } from '../orchestrate.js';
import { handleParadigmReport } from '../paradigm-report.js';
import { handleContextBudget } from '../context-budget.js';
/**
 * Registers dev lifecycle, infrastructure, and semantic tools (tools 31–38) on the MCP server.
 */
export function registerLifecycleInfraTools(server) {
    // 31. suggest_tooling
    server.registerTool('suggest_tooling', {
        description: t('tools.suggest_tooling.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            specId: z.string().optional().describe('Spec ID for context'),
            categories: z
                .array(DevLifecycleCategoryEnum)
                .optional()
                .describe('Specific categories to assess'),
        },
    }, safeLicensed('suggest_tooling', async (args) => handleSuggestTooling(args)));
    // 32. generate_tests
    server.registerTool('generate_tests', {
        description: t('tools.generate_tests.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID'),
            projectId: z.string().describe('Project ID'),
            autoGenerate: z.boolean().optional().describe('Auto-generate test files (default: false)'),
        },
    }, safeTracked('generate_tests', async (args) => handleGenerateTests(args)));
    // 33. generate_docs
    server.registerTool('generate_docs', {
        description: t('tools.generate_docs.description'),
        annotations: { readOnlyHint: true },
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            types: z.array(DocumentationTypeEnum).describe('Types of documentation to generate'),
            docType: DocumentationTypeEnum.optional().describe('Single documentation type for routing — shorthand for types: [docType]'),
            specId: z.string().optional().describe('Spec ID for context'),
            audience: z
                .enum(['end-user', 'developer', 'stakeholder', 'ops'])
                .optional()
                .describe('Target audience: end-user | developer | stakeholder | ops'),
            format: z
                .enum(['markdown', 'html', 'pdf-ready'])
                .optional()
                .describe('Output format: markdown | html | pdf-ready (default: markdown)'),
            language: z.string().optional().describe('Language for the documentation'),
        },
    }, safeTracked('generate_docs', async (args) => handleGenerateDocs(args)));
    // 34. manage_context
    server.registerTool('manage_context', {
        description: t('tools.manage_context.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            action: ManageContextActionEnum.describe('Context action'),
            key: z.string().optional().describe('Context key (required for save, load, delete)'),
            content: z.string().optional().describe('Content to save (required for save action)'),
            ttlDays: z.number().optional().describe('Time-to-live in days (optional for save)'),
        },
    }, safeLicensed('manage_context', async (args) => handleManageContext(args)));
    // 35. manage_git
    server.registerTool('manage_git', {
        description: t('tools.manage_git.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            action: GitActionEnum.describe('Git action to perform'),
            specId: z.string().optional().describe('Spec ID for context'),
            config: z
                .object({
                branchPrefix: z.record(z.string(), z.string()).optional(),
                commitFormat: z
                    .enum(['conventional', 'spec-id', 'custom'])
                    .optional()
                    .describe('Commit format: conventional | spec-id | custom'),
                customCommitTemplate: z.string().optional(),
                autoCreateBranch: z.boolean().optional(),
                requireSpecInCommit: z.boolean().optional(),
                protectedBranches: z.array(z.string()).optional(),
            })
                .optional()
                .describe('Git configuration overrides'),
        },
    }, safeTracked('manage_git', async (args) => handleManageGit(args)));
    // 36. orchestrate
    server.registerTool('orchestrate', {
        description: t('tools.orchestrate.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            action: OrchestrateActionEnum.describe('Orchestration action'),
            sessionId: z.string().optional().describe('Agent session ID'),
            specId: z.string().optional().describe('Spec ID for context'),
            resourcePath: z.string().optional().describe('Resource path to lock/unlock'),
            specIds: z.array(z.string()).optional().describe('List of spec IDs for pre-check'),
            agentCount: z
                .number()
                .int()
                .min(1)
                .optional()
                .describe('Number of subtasks for decompose (default: 2)'),
            limit: z
                .number()
                .int()
                .min(1)
                .optional()
                .describe('Max journal sessions to list (default: 10)'),
            experienceLevel: z
                .enum(['beginner', 'expert'])
                .optional()
                .describe('Output verbosity: beginner | expert'),
            lockTtlMinutes: z
                .number()
                .int()
                .min(1)
                .optional()
                .describe('Lock TTL in minutes (default: 30)'),
            fileOwnership: z
                .array(z.string())
                .optional()
                .describe('Files exclusively owned by this agent'),
            journalAction: z
                .enum(['emit', 'list'])
                .optional()
                .describe('Journal sub-action: emit | list (default: list)'),
            eventType: z.string().optional().describe('Journal event type for emit action'),
            commitHash: z.string().optional().describe('Commit hash to record in journal'),
        },
    }, safeLicensed('orchestrate', async (args) => handleOrchestrate(args)));
    // 37. integrate_pm
    server.registerTool('integrate_pm', {
        description: t('tools.integrate_pm.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            platform: PMPlatformEnum.describe('PM platform'),
            action: PMActionEnum.describe('Integration action'),
            specId: z.string().optional().describe('Spec ID'),
            config: z
                .record(z.string(), z.string())
                .optional()
                .describe('Platform-specific configuration'),
        },
    }, safeLicensed('integrate_pm', async (args) => handleIntegratePM(args)));
    // 38. paradigm_report
    server.registerTool('paradigm_report', {
        description: t('tools.paradigm_report.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID to analyse for paradigms'),
        },
        annotations: { readOnlyHint: true },
    }, safeLicensed('paradigm_report', async (args) => handleParadigmReport(args)));
    // 39. context_budget
    server.registerTool('context_budget', {
        description: t('tools.context_budget.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            action: ContextBudgetActionEnum.describe('Context budget action'),
            contextWindowSize: z
                .number()
                .int()
                .min(1000)
                .optional()
                .describe('Context window size in tokens (default: 200000)'),
            warningThreshold: z
                .number()
                .min(0)
                .max(1)
                .optional()
                .describe('Warning threshold 0-1 (default: 0.75)'),
            criticalThreshold: z
                .number()
                .min(0)
                .max(1)
                .optional()
                .describe('Critical threshold 0-1 (default: 0.90)'),
            checkpointId: z.string().optional().describe('Checkpoint ID for restore'),
            limit: z.number().int().min(1).optional().describe('Max checkpoints to list (default: 10)'),
            summary: z.string().optional().describe('Session summary for checkpoint'),
            decisions: z.array(z.string()).optional().describe('Key decisions made during session'),
            filesModified: z.array(z.string()).optional().describe('Files modified in session'),
            filesRead: z.array(z.string()).optional().describe('Files read in session'),
            specsInProgress: z.array(z.string()).optional().describe('Specs currently in progress'),
            pendingWork: z.array(z.string()).optional().describe('Pending work items'),
        },
    }, safeLicensed('context_budget', async (args) => handleContextBudget(args)));
}
//# sourceMappingURL=lifecycle-infra-tools.js.map