chore(workflow): auto-generated commit
This commit is contained in:
parent
d6e95f5c65
commit
d786827ac8
@ -1,11 +0,0 @@
|
||||
import type { SpawnError } from "@uncaged/nerve-workflow-utils";
|
||||
|
||||
export function formatSpawnFailure(error: SpawnError): string {
|
||||
if (error.kind === "spawn_failed") {
|
||||
return `spawn_failed: ${error.message}`;
|
||||
}
|
||||
if (error.kind === "timeout") {
|
||||
return `timeout: stdout=${error.stdout.slice(0, 200)} stderr=${error.stderr.slice(0, 200)}`;
|
||||
}
|
||||
return `non_zero_exit(${error.exitCode}): stderr=${error.stderr.slice(0, 400)}`;
|
||||
}
|
||||
@ -1,10 +1,9 @@
|
||||
import type { Role, RoleResult, StartStep, WorkflowMessage } from "@uncaged/nerve-core";
|
||||
import { cursorAgent, isDryRun, llmExtract } from "@uncaged/nerve-workflow-utils";
|
||||
import type { LlmProvider } from "@uncaged/nerve-workflow-utils";
|
||||
import { createCursorRole } from "@uncaged/nerve-workflow-utils";
|
||||
import { z } from "zod";
|
||||
import { resolveRepoCwd } from "../../lib/repo-context.js";
|
||||
import { threadIdFromStart } from "../../lib/start-meta.js";
|
||||
import { formatSpawnFailure } from "../../lib/spawn-utils.js";
|
||||
import { buildPlanPrompt } from "./prompt.js";
|
||||
|
||||
export const planMetaSchema = z.object({
|
||||
@ -27,38 +26,24 @@ export function buildPlanRole({ provider, nerveRoot }: BuildPlanDeps): Role<Plan
|
||||
};
|
||||
}
|
||||
|
||||
const dry = isDryRun(start);
|
||||
const prompt = buildPlanPrompt({ threadId: threadIdFromStart(start), nerveRoot });
|
||||
const run = await cursorAgent({
|
||||
prompt,
|
||||
const runRole = createCursorRole<PlanMeta>({
|
||||
cwd,
|
||||
mode: "ask",
|
||||
model: "auto",
|
||||
cwd,
|
||||
env: null,
|
||||
env: {},
|
||||
timeoutMs: 300_000,
|
||||
dryRun: dry,
|
||||
prompt: async () => buildPlanPrompt({ threadId: threadIdFromStart(start), nerveRoot }),
|
||||
extract: { provider, schema: planMetaSchema },
|
||||
});
|
||||
|
||||
if (!run.ok) {
|
||||
try {
|
||||
return await runRole(start, messages);
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
return {
|
||||
content: `plan cursor-agent failed: ${formatSpawnFailure(run.error)}`,
|
||||
content: `plan failed: ${msg}`,
|
||||
meta: { ready: false },
|
||||
};
|
||||
}
|
||||
|
||||
const metaR = await llmExtract({
|
||||
text: run.value,
|
||||
schema: planMetaSchema,
|
||||
provider,
|
||||
dryRun: dry,
|
||||
});
|
||||
if (!metaR.ok) {
|
||||
return {
|
||||
content: `${run.value}\n\n[meta extract failed]`,
|
||||
meta: { ready: false },
|
||||
};
|
||||
}
|
||||
|
||||
return { content: run.value, meta: metaR.value };
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user