import { z } from 'zod';
import { safeLicensed } from './safe-handler.js';
import { handleValidateAnnotations } from './validate-annotations.js';
import { handleGenerateAnnotations } from './generate-annotations.js';
import { handleSnapshotSpecHashes } from './snapshot-spec-hashes.js';
import { handleAutoReconcile } from './auto-reconcile.js';
/**
 * Registers living spec tools on the MCP server.
 */
export function registerLivingSpecTools(server) {
    // validate_annotations
    server.registerTool('validate_annotations', {
        description: 'Validate @spec annotations in source code. Checks that all annotated spec IDs exist and criteria numbers are valid. Use after adding annotations to verify correctness.',
        annotations: { readOnlyHint: true },
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            projectPath: z
                .string()
                .max(4096)
                .describe('Path to the project root directory'),
            specId: z
                .string()
                .max(500)
                .optional()
                .describe('Optional spec ID to filter annotations for a specific spec'),
        },
    }, safeLicensed('validate_annotations', async (args) => handleValidateAnnotations(args)));
    // generate_annotations
    server.registerTool('generate_annotations', {
        description: 'Suggest @spec annotations for unannotated source files. Uses living-spec-analyzer heuristics to match files to spec criteria and generates annotation comments to add.',
        annotations: { readOnlyHint: true },
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            projectPath: z
                .string()
                .max(4096)
                .describe('Path to the project root directory'),
            specId: z.string().max(500).describe('Spec ID to generate annotations for'),
        },
    }, safeLicensed('generate_annotations', async (args) => handleGenerateAnnotations(args)));
    // snapshot_spec_hashes
    server.registerTool('snapshot_spec_hashes', {
        description: 'Create or update a SHA-256 hash snapshot for a spec. Tracks file hashes and exported function signatures of all files referenced in the spec technical.md File Plan section. Used for drift detection.',
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            specId: z.string().max(500).describe('Spec ID to snapshot'),
        },
    }, safeLicensed('snapshot_spec_hashes', async (args) => handleSnapshotSpecHashes(args)));
    // auto_reconcile
    server.registerTool('auto_reconcile', {
        description: 'Auto-reconcile specs after code changes. Applies safe changes automatically (completion %, status flip, hash update, timestamp). Unsafe changes (status downgrade, criterion removal) are skipped and require manual approval. Rate-limited: max 1 per spec per 5 minutes.',
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            specId: z
                .string()
                .max(500)
                .optional()
                .describe('Specific spec ID to reconcile (if omitted, finds affected specs from changedFiles)'),
            changedFiles: z
                .array(z.string().max(4096))
                .max(1000)
                .optional()
                .describe('List of changed file paths to find affected specs'),
        },
    }, safeLicensed('auto_reconcile', async (args) => handleAutoReconcile(args)));
}
//# sourceMappingURL=register-living-spec-tools.js.map