// =============================================================================
// finalize_prd tool registration. Logic + store live in ./prd-api.ts.
// We re-export `prdStore` so existing imports (atlas.ts) continue to work.
// =============================================================================

import { registerTool } from './registry';
import * as api from './prd-api';

export { prdStore } from './prd-api';

registerTool({
    name: 'finalize_prd',
    description: 'Call this when you have finished writing the complete PRD document. Pass the full PRD markdown as content. This saves the document and signals to the user that discovery is complete.',
    parameters: {
        type: 'object',
        properties: {
            content: {
                type: 'string',
                description: 'The complete PRD document in markdown format'
            }
        },
        required: ['content']
    },
    async handler(args, ctx) {
        // Store against workspaceRoot as a unique key (each project has its own workspace)
        return api.finalizePrd(ctx.workspaceRoot, String(args.content));
    }
});
