// tools/register-scope-tools.ts — Registers Scope Guardian tools (SPEC-038)
import { z } from 'zod';
import { handleManageScope } from './manage-scope.js';
import { handleDetectContradictions } from './detect-contradictions.js';
import { safeLicensed } from './safe-handler.js';
/**
 * Registers the `manage_scope` and `detect_contradictions` tools (SPEC-038).
 */
export function registerScopeTools(server) {
    // manage_scope — view/update scope and backlog
    server.registerTool('manage_scope', {
        description: 'Manage the project scope definition and backlog. ' +
            'View current scope, list backlog items, add deferred requirements to backlog, ' +
            'or propose a formal scope change (requires explicit approval and reason).',
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID'),
            operation: z
                .enum(['view', 'add_to_backlog', 'propose_change', 'list_backlog'])
                .describe('view: show current scope; list_backlog: list deferred items; ' +
                'add_to_backlog: defer a requirement; propose_change: formally change scope'),
            itemDescription: z
                .string()
                .max(10_000)
                .optional()
                .describe('Description of the item to defer (required for add_to_backlog)'),
            exclusionReason: z
                .string()
                .max(10_000)
                .optional()
                .describe('Why this item is not in the current scope (required for add_to_backlog)'),
            specId: z
                .string()
                .max(500)
                .optional()
                .describe('Associated spec ID (optional for add_to_backlog)'),
            newScope: z
                .object({
                platforms: z
                    .array(z.string().max(500))
                    .max(100)
                    .optional()
                    .describe('Target platforms'),
                targetUsers: z
                    .array(z.string().max(500))
                    .max(100)
                    .optional()
                    .describe('Target user types'),
                primaryProblem: z
                    .string()
                    .max(10_000)
                    .optional()
                    .describe('The core problem being solved'),
            })
                .optional()
                .describe('New scope definition (required for propose_change)'),
            changeReason: z
                .string()
                .max(10_000)
                .optional()
                .describe('Business reason for scope change (required for propose_change)'),
            approvedBy: z
                .string()
                .max(500)
                .optional()
                .describe('Name of the person approving the change (required for propose_change)'),
        },
        annotations: {
            readOnlyHint: false,
        },
    }, safeLicensed('manage_scope', async (args) => handleManageScope(args)));
    // detect_contradictions — analyze all specs for semantic conflicts
    server.registerTool('detect_contradictions', {
        description: 'Analyze all specs in a project for semantic contradictions. ' +
            'Detects patterns like offline vs real-time, sync vs async, simple vs complex, ' +
            'performance vs security, local vs cloud. ' +
            'Returns a report with severity (blocker/warning) and recommendations.',
        inputSchema: {
            projectId: z.string().max(500).describe('Project ID to analyze'),
        },
        annotations: {
            readOnlyHint: true,
        },
    }, safeLicensed('detect_contradictions', async (args) => handleDetectContradictions(args)));
}
//# sourceMappingURL=register-scope-tools.js.map