// engine/spec-dependency-graph/supersedes-parser.ts — SPEC-746
// Reads `supersedes` and `depends_on` frontmatter fields from spec objects.
// Access non-standard YAML frontmatter fields that are not in the Spec type.
// These are serialised as string keys in the raw frontmatter so we cast to
// Record<string, unknown> first to avoid the dot-notation lint rule.
function getRaw(spec, key) {
    return spec[key];
}
function toStringArray(raw) {
    if (!raw) {
        return [];
    }
    if (typeof raw === 'string') {
        return raw.trim() ? [raw.trim()] : [];
    }
    if (Array.isArray(raw)) {
        return raw.map(String).filter(Boolean);
    }
    return [];
}
/**
 * Extract the list of spec IDs that this spec supersedes.
 * Accepts both string and array shapes.
 */
export function parseSupersedes(spec) {
    return toStringArray(getRaw(spec, 'supersedes'));
}
/**
 * Extract the list of spec IDs this spec depends on (alias for `dependencies`).
 * `depends_on` is the canonical name; `dependencies` is the legacy name.
 * Both are accepted and merged (deduplicated).
 */
export function parseDependsOn(spec) {
    const fromField = toStringArray(getRaw(spec, 'depends_on'));
    const legacy = spec.dependencies;
    // Merge and deduplicate
    const combined = [...legacy, ...fromField];
    return [...new Set(combined)];
}
//# sourceMappingURL=supersedes-parser.js.map