import path from "node:path";
import { evalInit, validateInitName } from "../init/init.js";
export async function runInitCli(input) {
    try {
        validateInitName(input.name);
        const sourceDir = path.resolve(input.sourceDir ?? process.cwd());
        const result = await evalInit({
            sourceDir,
            name: input.name,
            kind: input.kind ?? "plan",
            targetRepo: input.targetRepo,
            targetRef: input.targetRef
        });
        process.stdout.write(`${path.relative(sourceDir, result.evalDir)}\n`);
        process.stdout.write(`next: poe-code eval check ${input.name}\n`);
        return 0;
    }
    catch (error) {
        process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
        return 1;
    }
}
