import type { StartStep } from "@uncaged/nerve-core"; type StartMetaWithWorkdir = StartStep["meta"] & { workdir?: string | null }; /** * Resolve the target repo working directory. * Priority: start.meta.workdir → prompt second line (if absolute path) → cwd. */ export function resolveWorkdir(start: StartStep): string { const m = start.meta as StartMetaWithWorkdir; if (m.workdir) return m.workdir; // Allow prompt to carry workdir on the second line: "seed\n/abs/path" const lines = start.content.split(/\r?\n/); if (lines.length >= 2) { const candidate = lines[1]!.trim(); if (candidate.startsWith("/")) return candidate; } return process.cwd(); }