/**
 * Workspace v2 type definitions and migration logic.
 * Unified container model: ordered/unordered containers hold docs, tags are cross-cutting.
 */
import { randomUUID } from 'crypto';
// ============================================================================
// MIGRATION
// ============================================================================
export function isV1(data) {
    return !data.version || data.version < 2;
}
export function migrateV1toV2(legacy) {
    const root = [];
    for (const item of legacy.items || []) {
        root.push({ type: 'doc', file: item.file, title: item.file.replace(/\.md$/, '') });
    }
    return {
        version: 2,
        title: legacy.title,
        voiceProfileId: legacy.voiceProfileId ?? null,
        root,
        context: legacy.context,
    };
}
// ============================================================================
// HELPERS
// ============================================================================
export function generateContainerId() {
    return randomUUID().slice(0, 8);
}
