import { loadIdeas, saveIdea } from '../storage/ideas-store.js';
const EXPIRY_DAYS = 90;
/** Generate a unique idea ID based on date and sequence number. */
async function generateIdeaId(projectPath) {
    const ideas = await loadIdeas(projectPath);
    const today = new Date();
    const dateStr = today.toISOString().slice(0, 10).replace(/-/g, '');
    const todayPrefix = `idea-${dateStr}-`;
    const todayCount = ideas.filter((i) => i.id.startsWith(todayPrefix)).length;
    const seq = String(todayCount + 1).padStart(3, '0');
    return `${todayPrefix}${seq}`;
}
/** Calculate expiry date 90 days from now. */
function calculateExpiry() {
    const expiry = new Date();
    expiry.setDate(expiry.getDate() + EXPIRY_DAYS);
    return expiry.toISOString();
}
/** Handle capture_idea tool call. */
export async function handleCaptureIdea(input) {
    const { projectPath, title, description, tags = [] } = input;
    const id = await generateIdeaId(projectPath);
    const now = new Date().toISOString();
    const idea = {
        id,
        title,
        description,
        tags,
        capturedAt: now,
        capturedFrom: 'tool',
        status: 'new',
        expiresAt: calculateExpiry(),
    };
    await saveIdea(projectPath, idea);
    return {
        content: [{ type: 'text', text: `Idea guardada: [${id}] ${title}` }],
    };
}
//# sourceMappingURL=capture-idea-handler.js.map