// tools/register-memory-tools.ts — Registers expert memory tools (SPEC-040)
// Tools: log_decision, reality_check
import { z } from 'zod';
import { handleLogDecision } from './log-decision.js';
import { handleRealityCheck } from './reality-check.js';
import { safeLicensed } from './safe-handler.js';
export function registerMemoryTools(server) {
    // log_decision
    server.registerTool('log_decision', {
        description: 'Register, list, search, or supersede architectural and process decisions for a project. ' +
            'Prevents re-debating settled choices across sessions. ' +
            'Warns when a proposed change conflicts with an existing active decision.',
        annotations: { readOnlyHint: false },
        inputSchema: {
            projectId: z
                .string()
                .max(500)
                .describe('Project ID (hash of project path from init_project)'),
            operation: z
                .enum(['register', 'list', 'supersede', 'search'])
                .describe('register: save a new decision | ' +
                'list: show all decisions (filter by specId via query) | ' +
                'supersede: mark a decision as replaced | ' +
                'search: full-text search in decision history'),
            decision: z
                .object({
                what: z.string().max(10_000).describe('What was decided (short declarative statement)'),
                why: z.string().max(10_000).describe('Rationale — why this option was chosen'),
                alternatives: z
                    .array(z.string().max(10_000))
                    .max(100)
                    .optional()
                    .describe('Alternatives that were considered but rejected'),
                decidedBy: z
                    .enum(['human', 'ai', 'both'])
                    .optional()
                    .describe('Who made the decision (default: both)'),
                category: z
                    .enum(['architecture', 'stack', 'ux', 'business', 'process'])
                    .optional()
                    .describe('Decision category — auto-inferred from content if omitted'),
                specId: z
                    .string()
                    .max(500)
                    .optional()
                    .describe('Associate decision with a specific spec (e.g. "SPEC-001")'),
            })
                .optional()
                .describe('Decision payload — required for operation "register"'),
            decisionId: z
                .string()
                .max(500)
                .optional()
                .describe('Decision ID to supersede — required for operation "supersede"'),
            query: z
                .string()
                .max(500)
                .optional()
                .describe('Search query for operation "search"; ' +
                'specId filter for operation "list" (optional)'),
        },
    }, safeLicensed('log_decision', async (args) => handleLogDecision(args)));
    // reality_check
    server.registerTool('reality_check', {
        description: 'Evaluate whether a set of requirements is feasible given the project context. ' +
            'Detects impossible timelines, contradictory requirements (offline + real-time sync), ' +
            'performance paradoxes (fast + secure + cheap simultaneously), and scope creep. ' +
            'Returns a FeasibilityReport with a score 0-100, issues with alternatives, and viability flag. ' +
            'Score < 50 triggers a prominent warning.',
        annotations: { readOnlyHint: true },
        inputSchema: {
            projectId: z
                .string()
                .max(500)
                .describe('Project ID (hash of project path from init_project)'),
            requirements: z
                .array(z.string().max(10_000))
                .min(1)
                .max(1000)
                .describe('List of requirements or user stories to evaluate. ' +
                'Each item should describe one requirement or expectation.'),
        },
    }, safeLicensed('reality_check', async (args) => handleRealityCheck(args)));
}
//# sourceMappingURL=register-memory-tools.js.map