MCPcopy
hub / github.com/openclaw/clawsweeper / renderPrompt

Function renderPrompt

src/repair/lib.ts:232–296  ·  view source on GitHub ↗
(
  job: ParsedJob | LooseRecord,
  requestedMode?: JsonValue,
  context: LooseRecord = {},
)

Source from the content-addressed store, hash-verified

230}
231
232export function renderPrompt(
233 job: ParsedJob | LooseRecord,
234 requestedMode?: JsonValue,
235 context: LooseRecord = {},
236) {
237 const mode = requestedMode ?? job.frontmatter.mode;
238 const modePrompt =
239 mode === "autonomous"
240 ? "prompts/repair/autonomous.md"
241 : mode === "execute"
242 ? "prompts/repair/execute.md"
243 : "prompts/repair/plan-only.md";
244 const parts = [
245 readText("prompts/repair/worker-system.md"),
246 readText(modePrompt),
247 "## Security boundary",
248 readText("instructions/security-boundary.md"),
249 "## Dedupe policy",
250 readText("instructions/dedupe.md"),
251 "## Closure policy",
252 readText("instructions/closure-policy.md"),
253 "## Merge policy",
254 readText("instructions/merge-policy.md"),
255 ...(job.frontmatter.triage_policy === "low_signal_prs"
256 ? ["## Low-signal PR policy", readText("instructions/low-signal-prs.md")]
257 : []),
258 "## Job file",
259 "```md",
260 job.raw.trim(),
261 "```",
262 ];
263
264 for (const [title, filePath] of [
265 ["Cluster preflight artifact", context.clusterPlanPath],
266 ["Fix artifact", context.fixArtifactPath],
267 ]) {
268 if (!filePath) continue;
269 const absolute = path.resolve(filePath);
270 const artifact = promptArtifactText(title, absolute);
271 parts.push(
272 `## ${title}`,
273 `Path: \`${path.relative(repoRoot(), absolute)}\``,
274 artifact.compacted
275 ? `Note: compacted for the Codex input budget; use counts, refs, timestamps, review-bot excerpts, and safety gates as authoritative.`
276 : "",
277 "```json",
278 artifact.text,
279 "```",
280 );
281 }
282
283 if (context.targetCheckout) {
284 parts.push(
285 "## Target checkout",
286 `The target repository checkout is \`${context.targetCheckout}\`. Run target-repo inspection commands from that checkout. The ClawSweeper repository is only the automation harness.`,
287 );
288 }
289

Callers 3

run-worker.tsFile · 0.70
render-prompt.tsFile · 0.70
lib.test.tsFile · 0.50

Calls 3

readTextFunction · 0.85
promptArtifactTextFunction · 0.85
repoRootFunction · 0.70

Tested by

no test coverage detected