import { z } from 'zod';
import { t } from '../../i18n/index.js';
import { safeTracked, safeLicensed } from '../safe-handler.js';
import { AgentPlatformEnum, SubAgentFrameworkEnum, ChallengeSpecFocusEnum, } from '../schemas/index.js';
import { handleGenerateADR } from '../generate-adr.js';
import { handleDesignSchema } from '../design-schema.js';
import { handleDefineUIContract } from '../define-ui-contract.js';
import { handleChallengeSpec } from '../challenge-spec.js';
import { handleGenerateExecutionPlan } from '../generate-execution-plan.js';
import { handleSuggestStack } from '../suggest-stack.js';
import { handleCheckVersions } from '../check-versions.js';
import { handleGenerateSkill } from '../generate-skill.js';
import { handleDetectAgent } from '../detect-agent.js';
import { handleGenerateSubAgent } from '../generate-sub-agent.js';
import { handleGenerateRules } from '../generate-rules.js';
import { handleGenerateOrchestrationScript } from '../generate-orchestration-script.js';
/**
 * Registers design, challenge, stack, and agent tools (tools 20–30) on the MCP server.
 */
export function registerDesignStackTools(server) {
    // 20. generate_adr
    server.registerTool('generate_adr', {
        description: t('tools.generate_adr.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID'),
            projectId: z.string().describe('Project ID'),
            decisions: z.array(z.string()).optional().describe('Specific decisions to document'),
        },
    }, safeLicensed('generate_adr', async (args) => handleGenerateADR(args)));
    // 21. design_schema
    server.registerTool('design_schema', {
        description: t('tools.design_schema.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID'),
            projectId: z.string().describe('Project ID'),
            description: z.string().optional().describe('Additional schema context or requirements'),
        },
    }, safeLicensed('design_schema', async (args) => handleDesignSchema(args)));
    // 22. define_ui_contract
    server.registerTool('define_ui_contract', {
        description: t('tools.define_ui_contract.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID'),
            projectId: z.string().describe('Project ID'),
            screens: z
                .array(z.string())
                .optional()
                .describe('Specific screens to define contracts for'),
        },
    }, safeLicensed('define_ui_contract', async (args) => handleDefineUIContract(args)));
    // 23. challenge_spec
    server.registerTool('challenge_spec', {
        description: t('tools.challenge_spec.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID to challenge'),
            projectId: z.string().describe('Project ID'),
            focus: z.array(ChallengeSpecFocusEnum).optional().describe('Focus areas for the challenge'),
        },
    }, safeLicensed('challenge_spec', async (args) => handleChallengeSpec(args)));
    // 24. generate_execution_plan
    server.registerTool('generate_execution_plan', {
        description: t('tools.generate_execution_plan.description'),
        inputSchema: {
            specId: z.string().describe('Spec ID'),
            projectId: z.string().describe('Project ID'),
        },
    }, safeTracked('generate_execution_plan', async (args) => handleGenerateExecutionPlan(args)));
    // 25. suggest_stack
    server.registerTool('suggest_stack', {
        description: t('tools.suggest_stack.description'),
        inputSchema: {
            projectType: z
                .enum(['web', 'mobile', 'backend', 'fullstack', 'cli', 'library'])
                .describe('Project type: web | mobile | backend | fullstack | cli | library'),
            requirements: z.array(z.string()).describe('Project requirements'),
            constraints: z
                .array(z.string())
                .optional()
                .describe('Constraints (budget, team size, timeline, etc.)'),
            projectId: z.string().optional().describe('Project ID for context'),
        },
    }, safeTracked('suggest_stack', async (args) => handleSuggestStack(args)));
    // 26. check_versions
    server.registerTool('check_versions', {
        description: t('tools.check_versions.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            includeDevDeps: z
                .boolean()
                .optional()
                .describe('Include dev dependencies (default: false)'),
        },
    }, safeTracked('check_versions', async (args) => handleCheckVersions(args)));
    // 27. generate_skill
    server.registerTool('generate_skill', {
        description: t('tools.generate_skill.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            platform: AgentPlatformEnum.describe('Target agent platform'),
            skillType: z
                .enum(['project-rules', 'domain-skill', 'workflow', 'convention'])
                .describe('Skill type: project-rules | domain-skill | workflow | convention'),
            name: z.string().describe('Skill name'),
            description: z.string().describe('Skill description'),
            specId: z.string().optional().describe('Spec ID for context'),
        },
    }, safeLicensed('generate_skill', async (args) => handleGenerateSkill(args)));
    // 28. detect_agent
    server.registerTool('detect_agent', {
        description: t('tools.detect_agent.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
        },
    }, safeLicensed('detect_agent', async (args) => handleDetectAgent(args)));
    // 29. generate_sub_agent
    server.registerTool('generate_sub_agent', {
        description: t('tools.generate_sub_agent.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            framework: SubAgentFrameworkEnum.describe('Sub-agent framework'),
            agentName: z.string().describe('Name for the sub-agent'),
            role: z.string().describe('Role description for the sub-agent'),
            capabilities: z.array(z.string()).describe('List of capabilities'),
            tools: z.array(z.string()).optional().describe('Tools the sub-agent can use'),
            systemPrompt: z.string().optional().describe('Custom system prompt'),
        },
    }, safeLicensed('generate_sub_agent', async (args) => handleGenerateSubAgent(args)));
    // 30. generate_rules
    server.registerTool('generate_rules', {
        description: t('tools.generate_rules.description'),
        inputSchema: {
            projectId: z.string().describe('Project ID'),
            platform: AgentPlatformEnum.describe('Target agent platform'),
            includeArchitecture: z
                .boolean()
                .optional()
                .describe('Include architecture rules (default: true)'),
            includeConventions: z
                .boolean()
                .optional()
                .describe('Include convention rules (default: true)'),
            includeQuality: z.boolean().optional().describe('Include quality rules (default: true)'),
            includeWorkflow: z.boolean().optional().describe('Include workflow rules (default: true)'),
            customRules: z.array(z.string()).optional().describe('Additional custom rules'),
        },
    }, safeLicensed('generate_rules', async (args) => handleGenerateRules(args)));
    // 31. generate_orchestration_script
    server.registerTool('generate_orchestration_script', {
        description: t('tools.generate_orchestration_script.description'),
        inputSchema: {
            specIds: z
                .array(z.string())
                .min(1)
                .describe('List of spec IDs to run in parallel (e.g. ["SPEC-013", "SPEC-014a"])'),
            projectPath: z.string().describe('Absolute path to the project root'),
            mainBranch: z.string().optional().describe('Main branch name (default: main)'),
            baseBranch: z.string().optional().describe('Base branch for worktrees (default: develop)'),
        },
    }, safeLicensed('generate_orchestration_script', (args) => Promise.resolve(handleGenerateOrchestrationScript(args))));
}
//# sourceMappingURL=design-stack-tools.js.map