import { z } from 'zod';
import { handleGenerateCI } from './ci-generator.js';
import { handleGeneratePlanuCI } from './ci-planu-handler.js';
import { safeLicensed } from './safe-handler.js';
export function registerCITools(server) {
    server.registerTool('generate_ci', {
        description: 'Generate a GitHub Actions CI workflow YAML for a project. Auto-detects ecosystem (Node.js, Python, Go, Rust, Java/Kotlin, Ruby, PHP, Dart, .NET) and configures lint, test, build, and deploy jobs with proper caching and dependency installation.',
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            projectPath: z.string().max(4096).describe('Absolute path to the project root'),
            jobs: z
                .array(z
                .enum(['lint', 'test', 'build', 'deploy'])
                .describe('Job type: lint | test | build | deploy'))
                .max(100)
                .optional()
                .describe('CI jobs to include. Defaults to [lint, test, build]. Valid values: lint | test | build | deploy'),
            triggers: z
                .array(z
                .enum(['push', 'pull_request', 'workflow_dispatch', 'schedule'])
                .describe('Trigger: push | pull_request | workflow_dispatch | schedule'))
                .max(100)
                .optional()
                .describe('GitHub Actions triggers. Defaults to [push, pull_request]. Valid values: push | pull_request | workflow_dispatch | schedule'),
            nodeVersion: z
                .string()
                .max(500)
                .optional()
                .describe('Node.js version to use (e.g. "20", "22"). Auto-detected from .nvmrc or package.json if omitted'),
            pythonVersion: z
                .string()
                .max(500)
                .optional()
                .describe('Python version to use (e.g. "3.11", "3.12"). Auto-detected from .python-version or pyproject.toml if omitted'),
            goVersion: z
                .string()
                .max(500)
                .optional()
                .describe('Go version to use (e.g. "1.22", "1.23"). Auto-detected from go.mod if omitted'),
            rustChannel: z
                .enum(['stable', 'beta', 'nightly'])
                .optional()
                .describe('Rust toolchain channel: stable | beta | nightly. Auto-detected from rust-toolchain.toml if omitted'),
            javaVersion: z
                .string()
                .max(500)
                .optional()
                .describe('Java version to use (e.g. "21", "17"). Auto-detected from pom.xml or build.gradle if omitted'),
            workflowName: z
                .string()
                .max(500)
                .optional()
                .describe('Name for the GitHub Actions workflow (default: "CI"). Used as the workflow name and filename'),
        },
        annotations: { readOnlyHint: true },
    }, safeLicensed('generate_ci', async (args) => handleGenerateCI(args)));
    server.registerTool('generate_planu_ci', {
        description: 'Generate a Planu-specific GitHub Actions CI workflow that validates specs, detects drift between code and specs, posts results as PR comments, generates badges, and supports .planu.yml configuration. Produces ready-to-use workflow YAML + config file.',
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            specsDir: z
                .string()
                .max(4096)
                .optional()
                .describe('Directory containing specs (default: "docs/sdd/specs")'),
            detectDrift: z
                .boolean()
                .optional()
                .describe('Enable drift detection between code changes and specs (default: true)'),
            failOnDrift: z
                .boolean()
                .optional()
                .describe('Exit with code 1 when drift/issues detected above threshold (default: true)'),
            severityThreshold: z
                .enum(['critical', 'warning', 'info'])
                .optional()
                .describe('Severity threshold for CI failure: critical | warning | info (default: "warning"). critical = only mandatory broken specs; warning = any drift or incomplete criteria; info = always passes'),
            postComment: z
                .boolean()
                .optional()
                .describe('Post/update a markdown results comment on PRs (default: true)'),
            badge: z
                .boolean()
                .optional()
                .describe('Generate a shields.io badge endpoint for README (default: true)'),
            workingDirectory: z
                .string()
                .max(4096)
                .optional()
                .describe('Working directory for monorepo projects (default: ".")'),
        },
        annotations: { readOnlyHint: true },
    }, safeLicensed('generate_planu_ci', (args) => Promise.resolve(handleGeneratePlanuCI(args))));
}
//# sourceMappingURL=register-ci-tools.js.map