import { loadIdeas, updateIdea } from '../storage/ideas-store.js';
/** Handle discard_idea tool call. Idempotent if already discarded. */
export async function handleDiscardIdea(input) {
    const { projectPath, ideaId, reason } = input;
    const ideas = await loadIdeas(projectPath);
    const idea = ideas.find((i) => i.id === ideaId);
    if (!idea) {
        return {
            content: [{ type: 'text', text: `Idea not found: ${ideaId}` }],
            isError: true,
        };
    }
    // Idempotent: already discarded
    if (idea.status === 'discarded') {
        return {
            content: [{ type: 'text', text: `Idea "${idea.title}" was already discarded.` }],
        };
    }
    await updateIdea(projectPath, ideaId, {
        status: 'discarded',
        discardedReason: reason,
    });
    return {
        content: [{ type: 'text', text: `Idea "${idea.title}" discarded. Reason: ${reason}` }],
    };
}
//# sourceMappingURL=discard-idea-handler.js.map