package com.correx.core.tasks

import com.correx.core.events.types.TaskTargetKind

/**
 * Infers what a work-graph link points at from its target id, for callers that don't say
 * explicitly. ADR ids (`adr-12`, `ADR_0007`) and `.md` paths are documents; everything else is
 * assumed to be another task. Shared by the agent tool and the REST surface so the heuristic
 * stays in one place. Always prefer an explicit [TaskTargetKind] when the caller provides one.
 */
object TaskTargetKinds {
    private val ADR_ID = Regex("(?i)^adr[-_ ]?\\d+$")

    fun infer(targetId: String): TaskTargetKind =
        if (ADR_ID.matches(targetId) || targetId.endsWith(".md")) TaskTargetKind.DOC else TaskTargetKind.TASK
}
