feat(prompts): migrate remaining builders to composeUnitContext

This commit is contained in:
Mikael Hugo 2026-05-15 19:34:53 +02:00
parent 3e1e177466
commit bd27f61da7

View file

@ -78,10 +78,7 @@ import {
getDependencyTaskSummaryPaths,
getPriorTaskSummaryPaths,
} from "./summary-helpers.js";
import {
composeInlinedContext,
composeUnitContext,
} from "./unit-context-composer.js";
import { composeUnitContext } from "./unit-context-composer.js";
import { getUatType } from "./verdict-parser.js";
import {
buildCarryForwardSection,
@ -1229,10 +1226,9 @@ export async function buildResearchMilestonePrompt(mid, midTitle, base) {
return null;
}
};
const composed = await composeInlinedContext(
"research-milestone",
const { inline: composed } = await composeUnitContext("research-milestone", {
resolveArtifact,
);
});
// Knowledge block stays outside the composer — budgeted, scoped via
// keyword extraction (#4719). Inserted between decisions and the
// templates block to match the pre-migration output order. We split
@ -2238,10 +2234,9 @@ export async function buildCompleteSlicePrompt(
return null;
}
};
const composed = await composeInlinedContext(
"complete-slice",
const { inline: composed } = await composeUnitContext("complete-slice", {
resolveArtifact,
);
});
// Knowledge splices in between requirements and prior-task-summaries
// so overall order matches pre-migration: roadmap → slice-context →
// slice-plan → requirements → KNOWLEDGE → task summaries → templates.
@ -2768,9 +2763,8 @@ export async function buildRunUatPrompt(
uatContent,
base,
) {
// #4782 phase 3: run-uat migrated to compose its inlined context via
// the manifest. Behavior-equivalent — resolver dispatches to the same
// inline* helpers as the pre-migration builder.
// #4782 phase 3: run-uat migrated to composeUnitContext v2.
// Behavior-equivalent — resolver dispatches to the same inline* helpers.
const resolveArtifact = async (key) => {
switch (key) {
case "slice-uat": {
@ -2789,7 +2783,9 @@ export async function buildRunUatPrompt(
return null;
}
};
const composed = await composeInlinedContext("run-uat", resolveArtifact);
const { inline: composed } = await composeUnitContext("run-uat", {
resolveArtifact,
});
const inlinedContext = capPreamble(
`## Inlined Context (preloaded — do not re-read these files)\n\n${composed}`,
);
@ -2869,10 +2865,9 @@ export async function buildReassessRoadmapPrompt(
return null;
}
};
const composed = await composeInlinedContext(
"reassess-roadmap",
const { inline: composed } = await composeUnitContext("reassess-roadmap", {
resolveArtifact,
);
});
const parts = [];
if (composed) parts.push(composed);
// Knowledge block stays outside the composer — budgeted, scoped via
@ -3328,7 +3323,9 @@ export async function buildDeployPrompt(mid, midTitle, base) {
return null;
}
};
const composed = await composeInlinedContext("deploy", resolveArtifact);
const { inline: composed } = await composeUnitContext("deploy", {
resolveArtifact,
});
const inlinedContext = capPreamble(
`## Inlined Context (preloaded — do not re-read these files)\n\n${composed}`,
);
@ -3375,10 +3372,9 @@ export async function buildSmokeProductionPrompt(
return null;
}
};
const composed = await composeInlinedContext(
"smoke-production",
const { inline: composed } = await composeUnitContext("smoke-production", {
resolveArtifact,
);
});
const inlinedContext = capPreamble(
`## Inlined Context (preloaded — do not re-read these files)\n\n${composed}`,
);
@ -3421,7 +3417,9 @@ export async function buildReleasePrompt(mid, midTitle, base) {
return null;
}
};
const composed = await composeInlinedContext("release", resolveArtifact);
const { inline: composed } = await composeUnitContext("release", {
resolveArtifact,
});
const inlinedContext = capPreamble(
`## Inlined Context (preloaded — do not re-read these files)\n\n${composed}`,
);
@ -3469,7 +3467,9 @@ export async function buildRollbackPrompt(
return null;
}
};
const composed = await composeInlinedContext("rollback", resolveArtifact);
const { inline: composed } = await composeUnitContext("rollback", {
resolveArtifact,
});
const inlinedContext = capPreamble(
`## Inlined Context (preloaded — do not re-read these files)\n\n${composed}`,
);
@ -3517,7 +3517,9 @@ export async function buildChallengePrompt(
return null;
}
};
const composed = await composeInlinedContext("challenge", resolveArtifact);
const { inline: composed } = await composeUnitContext("challenge", {
resolveArtifact,
});
const inlinedContext = capPreamble(
`## Inlined Context (preloaded — do not re-read these files)\n\n${composed}`,
);