Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix: report Producer failures that no request carries in plan (#348)
牵强d56b5281e6d4
diff --git a/packages/cli/src/build-planning.ts b/packages/cli/src/build-planning.tsindex a678a930..4f5224ed 100644--- a/packages/cli/src/build-planning.ts+++ b/packages/cli/src/build-planning.ts@@ -122,9 +122,27 @@ export type EvaluatedPlanNeed = {readonly issue?: string;};+/** A Producer failure in a step that carries no planned need; no request report would show it. */+export type PlanProducerFailure = {+ readonly step: string;+ readonly message: string;+};++/** Keep only the failures no planned need reports; every other failure already reaches a request. */+export function unreportedFailures(+ reported: ReadonlySet<string>,+ failures: ReadonlyMap<string, string>,+): readonly PlanProducerFailure[] {+ return [...failures]+ .filter(([step]) => !reported.has(step))+ .map(([step, message]): PlanProducerFailure => ({ step, message }));+}+export type EvaluatedPlan = {readonly state: BuildState;readonly needs: ReadonlyMap<string, EvaluatedPlanNeed>;+ /** Producer failures no planned need reports, so no request would otherwise carry them. */+ readonly unreportedFailures: readonly PlanProducerFailure[];};export type PlanNeedView = {@@ -309,7 +327,12 @@ export async function evaluatePlanNeeds(: `${issue}; package also does not describe the complete request for ${capabilityName(planned.capability)} before Build`,});}- return { state, needs: result };+ const reported = new Set(plannedNeeds(state).map((planned) => planned.step));+ return {+ state,+ needs: result,+ unreportedFailures: unreportedFailures(reported, evaluation.failures),+ };}/** The complete pre-Build requests shared by Endpoint selection and Provider pricing reads. */diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.tsindex 212ed542..57d56719 100644--- a/packages/cli/src/main.ts+++ b/packages/cli/src/main.ts@@ -621,18 +621,22 @@ export async function runCli(const localRequestCount = providers?.filter((item) => item.status === "resolved" && item.pricing?.kind === "local").length ?? 0;const providerRequestCount = providers?.filter((item) => item.status === "resolved" && item.pricing?.kind !== "local").length;const requestIssueCount = needs.filter((item) => item.issue !== undefined).length;+ const producerFailureCount = evaluated.unreportedFailures.length;writeCliOutput(io, args.presentation, {kind: "plan",machine: createPlanOutput({format: "hypit.cli-plan@1",ok: (preflight?.ok ?? true) && unresolvedRequestCount === 0- && unsupportedRequestCount === 0 && requestIssueCount === 0,+ && unsupportedRequestCount === 0 && requestIssueCount === 0+ && producerFailureCount === 0,run: projectPath(loaded.path, effectiveWorkspaceRoot),targetCount: targets.length,targets,steps: result.definition.plan.steps.length,requestCount: needs.length,requestIssueCount,+ producerFailureCount,+ ...(producerFailureCount === 0 ? {} : { producerFailures: evaluated.unreportedFailures }),...(providerRequestCount === undefined ? {} : { providerRequestCount }),...(providers === undefined ? {} : { localRequestCount, unresolvedRequestCount, unsupportedRequestCount }),choiceCount: allChoices.length,@@ -650,7 +654,8 @@ export async function runCli(}, { verbose: args.presentation.verbose, limit: args.limit }),});if ((preflight !== undefined && !preflight.ok) || unresolvedRequestCount > 0- || unsupportedRequestCount > 0 || requestIssueCount > 0) io.setExitCode?.(1);+ || unsupportedRequestCount > 0 || requestIssueCount > 0+ || producerFailureCount > 0) io.setExitCode?.(1);} finally {await planResults?.close();}diff --git a/packages/cli/src/output.ts b/packages/cli/src/output.tsindex 897651fa..822c82c8 100644--- a/packages/cli/src/output.ts+++ b/packages/cli/src/output.ts@@ -124,6 +124,10 @@ export type PlanOutput = {readonly steps?: number;readonly requestCount: number;readonly requestIssueCount: number;+ /** Producers that failed in a step no request reports; a non-zero count makes the plan invalid. */+ readonly producerFailureCount: number;+ /** The failing step and message behind each count; present only when the plan has one. */+ readonly producerFailures?: readonly { readonly step: string; readonly message: string }[];/** Present when a Runtime Profile was selected. */readonly providerRequestCount?: number;readonly localRequestCount?: number;@@ -518,6 +522,7 @@ function renderPlan(["Requests", String(view.machine.requestCount)],...(view.machine.choiceCount === 0 ? [] : [["Run choices", String(view.machine.choiceCount)] as const]),...(view.machine.requestIssueCount === 0 ? [] : [["Request issues", String(view.machine.requestIssueCount)] as const]),+ ...(view.machine.producerFailureCount === 0 ? [] : [["Producer failures", String(view.machine.producerFailureCount)] as const]),...((view.machine.providerRequestCount ?? 0) === 0 ? [] : [["Provider requests", String(view.machine.providerRequestCount)] as const]),...((view.machine.localRequestCount ?? 0) === 0 ? [] : [["Local requests", String(view.machine.localRequestCount)] as const]),...((view.machine.unsupportedRequestCount ?? 0) === 0 ? [] : [["Unsupported", String(view.machine.unsupportedRequestCount)] as const]),@@ -527,6 +532,13 @@ function renderPlan(] as const]),...(!verbose || view.machine.steps === undefined ? [] : [["Steps", String(view.machine.steps)] as const]),], colors));+ const failures = view.machine.producerFailures ?? [];+ if (failures.length > 0) {+ lines.push("", colors.strong("Producer failures"));+ for (const item of failures) {+ lines.push(` ${colors.error(glyph(io, "×", "x"))} ${stepLabel(item.step)}: ${item.message}`);+ }+ }if (view.machine.providers !== undefined) {if (view.machine.providers.length > 0) lines.push("", colors.strong("Providers and price pages"));const groups = new Map<string, PlanProvider[]>();diff --git a/packages/cli/test/output.test.ts b/packages/cli/test/output.test.tsindex 762b07a2..378a2ddf 100644--- a/packages/cli/test/output.test.ts+++ b/packages/cli/test/output.test.ts@@ -82,6 +82,7 @@ test("plan presents useful choices and readable requests without default graph isteps: 2,requestCount: 1,requestIssueCount: 0,+ producerFailureCount: 0,preflight: {ok: true,capabilityCount: 1,@@ -108,6 +109,36 @@ test("plan presents useful choices and readable requests without default graph iassert.match(verbose, /take\.video\s+← preview/u);});+test("plan does not call a plan valid when a Producer failed outside every request", () => {+ const machine = {+ format: "hypit.cli-plan@1" as const,+ ok: false,+ run: "build.svrun",+ targetCount: 1,+ targets: ["final.video"],+ steps: 6,+ requestCount: 3,+ requestIssueCount: 0,+ producerFailureCount: 1,+ producerFailures: [{+ step: "assemble-timeline",+ message: "Timeline duration 8s must land on an exact frame boundary.",+ }],+ choiceCount: 0,+ choices: [],+ };++ const rendered = capture(human, { kind: "plan", machine });+ assert.match(rendered, /Build plan needs attention/u);+ assert.match(rendered, /Producer failures\s+1/u);+ assert.match(rendered, /assemble-timeline: Timeline duration 8s must land on an exact frame boundary\./u);+ assert.deepEqual(createPlanOutput(machine, { verbose: false, limit: 1 }).producerFailures, machine.producerFailures);++ const parsed = JSON.parse(capture({ ...human, json: true }, { kind: "plan", machine }));+ assert.equal(parsed.producerFailureCount, 1);+ assert.deepEqual(parsed.producerFailures, machine.producerFailures);+});+test("plan names the Provider and price page behind each request, and points at --runtime when it cannot", () => {const base = {format: "hypit.cli-plan@1",@@ -118,6 +149,7 @@ test("plan names the Provider and price page behind each request, and points atsteps: 3,requestCount: 2,requestIssueCount: 0,+ producerFailureCount: 0,choiceCount: 0,choices: [],} as const;@@ -323,6 +355,7 @@ test("plan scope omits unused branches while retaining every demanded request anconst plan = {format: "hypit.cli-plan@1" as const, ok: false, run: "build.svrun", targetCount: 2,targets: ["final.video", "poster.image"], steps: 400, requestCount: needs.length, requestIssueCount: 1,+ producerFailureCount: 0,choiceCount: 35, choices: Array.from({ length: 35 }, (_, i) => ({ output: `old-${i}`, candidate: `selected-${i}` })),unreached: Array.from({ length: 125 }, (_, i) => ({ output: `unused-${i}`, operation: "old-producer" })),needs, providers: needs.map((need) => ({ request: need.request, capability: need.capability, status: "resolved" as const, endpoint: "local" })),diff --git a/packages/cli/test/plan-needs.test.ts b/packages/cli/test/plan-needs.test.tsindex 55d2b79b..6926827c 100644--- a/packages/cli/test/plan-needs.test.ts+++ b/packages/cli/test/plan-needs.test.ts@@ -1,7 +1,7 @@import assert from "node:assert/strict";import test from "node:test";-import { summarizeConstraints } from "../src/build-planning.js";+import { summarizeConstraints, unreportedFailures } from "../src/build-planning.js";test("a generic request summary reads only declared top-level fields and counts references by kind", () => {const summary = summarizeConstraints({@@ -31,3 +31,17 @@ test("a Chinese request reports characters instead of pretending the whole prompconst summary = summarizeConstraints({ prompt: "一个女生在大学教室里拿着手麦说话".repeat(3) });assert.deepEqual(summary.fields, { prompt: "48 chars" });});++test("a Producer failure is kept only when no planned need already reports it", () => {+ const failures = new Map([+ ["assemble-timeline", "Timeline duration 8s must land on an exact frame boundary."],+ ["final:request-visual-render", "the Endpoint refused this range"],+ ]);++ assert.deepEqual(unreportedFailures(new Set(["final:request-visual-render"]), failures), [+ { step: "assemble-timeline", message: "Timeline duration 8s must land on an exact frame boundary." },+ ]);+ assert.deepEqual(unreportedFailures(new Set(), failures).map((item) => item.step),+ ["assemble-timeline", "final:request-visual-render"]);+ assert.deepEqual(unreportedFailures(new Set(failures.keys()), failures), []);+});