import * as fsPromises from "node:fs/promises";
import { discoverPlans } from "@poe-code/agent-harness-tools";
function createDefaultFs() {
    return {
        readFile: fsPromises.readFile,
        readdir: fsPromises.readdir,
        lstat: async (filePath) => {
            const stat = await fsPromises.lstat(filePath);
            return { isSymbolicLink: () => stat.isSymbolicLink() };
        },
        stat: async (filePath) => {
            const stat = await fsPromises.stat(filePath);
            return {
                isFile: () => stat.isFile(),
                isDirectory: () => stat.isDirectory(),
                mtimeMs: stat.mtimeMs
            };
        }
    };
}
export async function discoverDocs(options) {
    const fs = options.fs ?? createDefaultFs();
    const plans = await discoverPlans({
        cwd: options.cwd,
        homeDir: options.homeDir,
        planDirectory: options.planDirectory?.trim() || ".poe-code/ralph/plans",
        kinds: ["ralph"],
        fs: fs
    });
    return plans.map((plan) => ({
        path: plan.displayPath,
        displayPath: plan.displayPath
    }));
}
