MCPcopy Create free account
hub / github.com/ByBrawe/opencode-loop / addLoop

Function addLoop

src/index.js:1376–1408  ·  view source on GitHub ↗
(directory, client, sessionID, args, defaults = {})

Source from the content-addressed store, hash-verified

1374function goalReportText(job) {
1375 const lines = [];
1376 lines.push(`# OpenCode Loop Goal Report`);
1377 lines.push("");
1378 lines.push(`Status: ${goalStatusText(job) || "unknown"}`);
1379 lines.push(`Goal: ${job.action || job.goalFile || ""}`);
1380 lines.push(`Created: ${job.createdAt || ""}`);
1381 if (job.goalCompletedAt)
1382 lines.push(`Completed: ${new Date(job.goalCompletedAt).toISOString()}`);
1383 if (job.goalBlockedAt)
1384 lines.push(`Blocked: ${new Date(job.goalBlockedAt).toISOString()}`);
1385 if (job.lastUserInterruptAt)
1386 lines.push(`Paused by user message: ${new Date(job.lastUserInterruptAt).toISOString()}`);
1387 if (job.goalNoProgressPausedAt)
1388 lines.push(`Paused by no-progress guard: ${new Date(job.goalNoProgressPausedAt).toISOString()}`);
1389 if (job.runCount)
1390 lines.push(`Turns: ${job.runCount}`);
1391 if ((job.maxNoProgress ?? DEFAULT_GOAL_MAX_NO_PROGRESS) > 0)
1392 lines.push(`No-progress: ${job.noProgressCount || 0}/${job.maxNoProgress ?? DEFAULT_GOAL_MAX_NO_PROGRESS}`);
1393 lines.push("");
1394 if (job.goalSummary)
1395 lines.push("## Summary", "", String(job.goalSummary), "");
1396 if (job.goalEvidence)
1397 lines.push("## Evidence", "", String(job.goalEvidence), "");
1398 if (job.goalBlockedReason)
1399 lines.push("## Blocked reason", "", String(job.goalBlockedReason), "");
1400 if (job.goalCompletionRejectedReason)
1401 lines.push("## Last completion rejection", "", String(job.goalCompletionRejectedReason), "");
1402 if (job.goalInterruptedReason)
1403 lines.push("## Interrupt", "", String(job.goalInterruptedReason), "");
1404 if (job.goalNoProgressReason)
1405 lines.push("## No-progress guard", "", String(job.goalNoProgressReason), "");
1406 if (job.goalAcceptance?.length)
1407 lines.push("## Acceptance criteria", "", ...job.goalAcceptance.map((item) => `- ${item}`), "");
1408 if (job.lastGoalChecks?.length) {
1409 lines.push("## Latest checks", "");
1410 for (const item of job.lastGoalChecks)
1411 lines.push(`- ${item.command}: exit ${item.code}`);

Callers 2

addGoalFunction · 0.85
handleCommandFunction · 0.85

Calls 11

parseLoopArgsFunction · 0.85
toastFunction · 0.85
snapshotPathsFunction · 0.85
jobLabelFunction · 0.85
sayFunction · 0.85
readStateFunction · 0.85
sameLoopDefinitionFunction · 0.85
writeStateFunction · 0.85
scheduleDueWorkFunction · 0.85
scheduleIdleWorkFunction · 0.85
appendLoopLogFunction · 0.85

Tested by

no test coverage detected