- Role: (start, messages) → (ctx: ThreadContext) - AgentFn prompt callbacks: (start) → (ctx) - ModeratorContext → ThreadContext - 13 files updated across knowledge-extraction and solve-issue workflows 小橘 <xiaoju@shazhou.work>
22 lines
683 B
TypeScript
22 lines
683 B
TypeScript
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();
|
|
}
|