MCPcopy Index your code
hub / github.com/ByBrawe/opencode-loop / createCheckpoint

Function createCheckpoint

src/index.js:760–779  ·  view source on GitHub ↗
(directory, sessionID, job, client)

Source from the content-addressed store, hash-verified

758 const text = await readSmallTextFile(path.resolve(directory, job.goalFile), 120_000)
759 if (text.trim()) sections.push(`Goal file ${job.goalFile}:\n${text.trim()}`)
760 else sections.push(`Goal file ${job.goalFile} was requested but could not be read. Continue from the inline goal objective.`)
761 }
762 if (job.promptFile) {
763 const text = await readSmallTextFile(path.resolve(directory, job.promptFile), 120_000)
764 if (text.trim()) sections.push(`Extra goal instructions from ${job.promptFile}:\n${text.trim()}`)
765 }
766 if (job.goalAcceptance?.length) sections.push("Acceptance criteria:\n" + job.goalAcceptance.map((item, index) => `${index + 1}. ${item}`).join("\n"))
767 if (job.goalChecks?.length) sections.push("Verification commands that define useful evidence:\n" + job.goalChecks.map((item, index) => `${index + 1}. ${item}`).join("\n"))
768 if (job.verifyCommand) sections.push(`Post-turn verify command configured by the loop: ${job.verifyCommand}`)
769 if (job.lastGoalChecks?.length) sections.push("Latest goal check results:\n" + job.lastGoalChecks.map((item) => `- ${item.command}: exit ${item.code}`).join("\n"))
770 if (job.lastVerifyFailure) sections.push("Previous verify/check failure summary:\n" + String(job.lastVerifyFailure).slice(0, 1600))
771 if (job.goalCompletionRejectedReason) sections.push(`Previous completion attempt was rejected:\n${job.goalCompletionRejectedReason}`)
772 if ((job.maxNoProgress ?? DEFAULT_GOAL_MAX_NO_PROGRESS) > 0) sections.push(`No-progress guard:\n${job.noProgressCount || 0}/${job.maxNoProgress ?? DEFAULT_GOAL_MAX_NO_PROGRESS} recent turn(s) without recorded meaningful progress.`)
773 if (job.goalProgress?.length) sections.push("Recent goal progress:\n" + job.goalProgress.slice(-5).map((item) => `- ${item.time}: ${item.summary}`).join("\n"))
774 for (const file of job.includeFiles || []) {
775 const text = await readSmallTextFile(path.resolve(directory, file), 80_000)
776 if (text.trim()) sections.push(`Context from ${file}:\n${text.trim().slice(0, 20_000)}`)
777 }
778
779 return `${GOAL_PROMPT_PREFIX}.
780
781You are pursuing an experimental persistent goal for this OpenCode session. This is not a timer loop and not a one-shot prompt. Keep working toward the goal until it is completed, blocked, paused, cleared, or stopped by safety limits.
782

Callers 1

finalizeActiveRunFunction · 0.85

Calls 5

runProcessFunction · 0.85
stateDirFunction · 0.85
safeIDFunction · 0.85
ensureDirFunction · 0.85
toastFunction · 0.85

Tested by

no test coverage detected