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 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 type { LlmProvider } from "@uncaged/nerve-workflow-utils";
|
||||||
|
import { createCursorRole } from "@uncaged/nerve-workflow-utils";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { resolveRepoCwd } from "../../lib/repo-context.js";
|
import { resolveRepoCwd } from "../../lib/repo-context.js";
|
||||||
import { threadIdFromStart } from "../../lib/start-meta.js";
|
import { threadIdFromStart } from "../../lib/start-meta.js";
|
||||||
import { formatSpawnFailure } from "../../lib/spawn-utils.js";
|
|
||||||
import { buildPlanPrompt } from "./prompt.js";
|
import { buildPlanPrompt } from "./prompt.js";
|
||||||
|
|
||||||
export const planMetaSchema = z.object({
|
export const planMetaSchema = z.object({
|
||||||
@ -27,38 +26,24 @@ export function buildPlanRole({ provider, nerveRoot }: BuildPlanDeps): Role<Plan
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const dry = isDryRun(start);
|
const runRole = createCursorRole<PlanMeta>({
|
||||||
const prompt = buildPlanPrompt({ threadId: threadIdFromStart(start), nerveRoot });
|
cwd,
|
||||||
const run = await cursorAgent({
|
|
||||||
prompt,
|
|
||||||
mode: "ask",
|
mode: "ask",
|
||||||
model: "auto",
|
model: "auto",
|
||||||
cwd,
|
env: {},
|
||||||
env: null,
|
|
||||||
timeoutMs: 300_000,
|
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 {
|
return {
|
||||||
content: `plan cursor-agent failed: ${formatSpawnFailure(run.error)}`,
|
content: `plan failed: ${msg}`,
|
||||||
meta: { ready: false },
|
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