import { loadContinuityState } from "../continuity/index.js";
export function continuityStateToMemoryEvents(cwd, state) {
    const events = [];
    if (state.goal || state.currentTask || state.nextAction) {
        events.push({
            type: "handoff",
            summary: state.currentTask ?? state.goal ?? state.nextAction ?? "Continuity handoff",
            content: [state.goal, state.currentTask, state.nextAction].filter(Boolean).join("\n"),
            priority: 4,
            tags: ["continuity", "import", "handoff"],
            metadata: { cwd, status: state.status },
        });
    }
    for (const file of state.modifiedFiles.slice(-25)) {
        events.push({
            type: "file_modified",
            summary: `Continuity modified file: ${file}`,
            priority: 3,
            filePaths: [file],
            tags: ["continuity", "import", "file"],
        });
    }
    for (const question of state.openQuestions.slice(-10)) {
        events.push({
            type: "open_question",
            summary: question,
            priority: 4,
            tags: ["continuity", "import", "question"],
        });
    }
    for (const blocker of state.blockedOn.slice(-10)) {
        events.push({
            type: "blocker",
            summary: blocker,
            priority: 5,
            tags: ["continuity", "import", "blocker"],
        });
    }
    for (const checkpoint of state.checkpoints.slice(-10)) {
        events.push({
            type: "handoff",
            summary: `Imported continuity checkpoint: ${checkpoint.reason}`,
            content: JSON.stringify(checkpoint),
            priority: checkpoint.reason === "loop_end" ? 4 : 3,
            filePaths: checkpoint.modifiedFiles,
            tags: ["continuity", "import", "checkpoint"],
            createdAt: new Date(checkpoint.timestamp).toISOString(),
        });
    }
    return events;
}
export async function importContinuityIntoMemory(cwd, memoryService) {
    const state = await loadContinuityState(cwd);
    const events = continuityStateToMemoryEvents(cwd, state);
    let imported = 0;
    for (const event of events) {
        const recorded = await memoryService.recordEvent(event);
        if (recorded)
            imported++;
    }
    return imported;
}
//# sourceMappingURL=continuity-import.js.map