package com.correx.infrastructure.workflow

import java.nio.file.Path
import kotlin.io.path.exists
import kotlin.io.path.readText

class FileSystemPromptLoader(
    private val configDir: Path = Path.of(System.getProperty("user.home"), ".config", "correx", "prompts"),
) : PromptLoader {
    override fun load(path: String): String {
        val local = Path.of(path)
        if (local.exists()) return local.readText()

        val fromConfig = configDir.resolve(path)
        if (fromConfig.exists()) return fromConfig.readText()

        throw PromptNotFoundException("Prompt not found: $path (searched: $local, $fromConfig)")
    }
}
