// tools/register-context-tools.ts — Registers context ingestion tools (SPEC-036)
// Tools: request_context, contribute_context
import { z } from 'zod';
import { handleRequestContext, handleContributeContext } from './contribute-context.js';
import { safeLicensed } from './safe-handler.js';
export function registerContextTools(server) {
    // request_context
    server.registerTool('request_context', {
        description: 'Generate a prompt that asks the user for reference documentation (README, PRD, ' +
            'architecture diagrams, wireframes, ADRs, etc.) so the agent can learn the project. ' +
            'Sets a flag to avoid re-asking on subsequent calls. Use force=true to re-generate.',
        inputSchema: {
            projectId: z.string().describe('Project ID (hash of project path from init_project)'),
            force: z
                .boolean()
                .optional()
                .describe('Force re-generation even if already requested (default: false)'),
        },
    }, safeLicensed('request_context', async (args) => handleRequestContext(args)));
    // contribute_context
    server.registerTool('contribute_context', {
        description: 'Persist structured knowledge that the agent extracted from user-provided documents. ' +
            'Merges intelligently with auto-detected knowledge; reports conflicts for agent resolution. ' +
            'Multiple calls accumulate — they do not overwrite each other.',
        inputSchema: {
            projectId: z.string().describe('Project ID (hash of project path from init_project)'),
            context: z
                .object({
                entities: z
                    .array(z.object({
                    name: z.string().describe('Entity / model name'),
                    fields: z.array(z.string()).describe('Field names'),
                    relations: z.array(z.string()).optional().describe('Related entity names'),
                }))
                    .optional()
                    .describe('Data entities / models extracted from the docs'),
                apiContracts: z
                    .array(z.object({
                    type: z
                        .enum(['rest', 'graphql', 'trpc', 'grpc', 'websocket'])
                        .describe('Contract type'),
                    endpoint: z.string().optional().describe('Base endpoint or path'),
                    description: z.string().describe('What this API does'),
                }))
                    .optional()
                    .describe('API contract descriptions'),
                architectureNotes: z
                    .string()
                    .optional()
                    .describe('Architecture decisions and patterns from the docs'),
                techDecisions: z
                    .array(z.string())
                    .optional()
                    .describe('Key technical decisions recorded in ADRs or equivalent'),
                userFlows: z
                    .array(z.string())
                    .optional()
                    .describe('User journey descriptions from wireframes or PRD'),
                nonFunctionalRequirements: z
                    .array(z.string())
                    .optional()
                    .describe('Performance, security, and scalability requirements'),
                additionalContext: z
                    .string()
                    .max(10_000)
                    .optional()
                    .describe('Free-text additional context (max 10 000 chars)'),
            })
                .describe('Structured knowledge extracted from the user documents'),
            source: z
                .object({
                documentName: z
                    .string()
                    .describe('Name or description of the source document (e.g. "README.md", "PRD v2")'),
                contributedAt: z
                    .string()
                    .describe('ISO 8601 timestamp of when this contribution was made'),
                contributedBy: z.string().describe('Agent identifier (e.g. "claude-code", "cursor")'),
            })
                .describe('Trace metadata for this contribution'),
        },
    }, safeLicensed('contribute_context', async (args) => handleContributeContext(args)));
}
//# sourceMappingURL=register-context-tools.js.map