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

Function goalTools

src/index.js:1629–1665  ·  view source on GitHub ↗
(defaultDirectory)

Source from the content-addressed store, hash-verified

1627 const state = await readState2(directory, sessionID);
1628 const goals = (state.jobs || []).filter(isGoalJob);
1629 const lines = goals.length ? goals.map((job, index) => {
1630 const status = goalStatusText(job);
1631 const checks = job.goalChecks?.length ? ` | checks=${job.goalChecks.length}` : "";
1632 const acceptance = job.goalAcceptance?.length ? ` | acceptance=${job.goalAcceptance.length}` : "";
1633 const progress = job.goalProgress?.length ? ` | progress=${job.goalProgress.length}` : "";
1634 const noProgress = (job.maxNoProgress ?? DEFAULT_GOAL_MAX_NO_PROGRESS) > 0 ? ` | no-progress=${job.noProgressCount || 0}/${job.maxNoProgress ?? DEFAULT_GOAL_MAX_NO_PROGRESS}` : "";
1635 const rejected = job.goalCompletionRejectedReason ? " | completion-rejected" : "";
1636 return `${index + 1}. ${job.id}${job.name ? ` (${job.name})` : ""}: ${status} | turns=${job.runCount || 0} | objective=${String(job.action || job.goalFile || "").slice(0, 220)}${checks}${acceptance}${progress}${noProgress}${rejected}`;
1637 }) : ["No experimental goal jobs."];
1638 await toast2(client, goals.length ? `${goals.length} experimental goal(s).` : "No experimental goal jobs.", goals.length ? "info" : "warning");
1639 await say2(client, sessionID, `OpenCode Loop experimental goal status:
1640` + lines.join(`
1641`));
1642 }
1643 async function pauseGoal(directory, client, sessionID, args) {
1644 const target = String(args || "").trim() || "goal";
1645 const state = await readState2(directory, sessionID);
1646 let count = 0;
1647 state.jobs = (state.jobs || []).map((job, index) => isGoalJob(job) && matchJob(job, target, index) ? (count++, { ...job, paused: true }) : job);
1648 await writeState2(directory, sessionID, state);
1649 await scheduleDueWork(directory, client, sessionID);
1650 await toast2(client, `Paused ${count} experimental goal(s).`, count ? "success" : "warning");
1651 }
1652 async function resumeGoal(directory, client, sessionID, args) {
1653 const target = String(args || "").trim() || "goal";
1654 const state = await readState2(directory, sessionID);
1655 let count = 0;
1656 state.jobs = (state.jobs || []).map((job, index) => {
1657 if (!isGoalJob(job) || !matchJob(job, target, index))
1658 return job;
1659 count++;
1660 return { ...job, paused: false, enabled: true, goalStatus: job.goalStatus === "blocked" ? "active" : job.goalStatus || "active", lastRunAt: 0, noProgressCount: 0, goalNoProgressReason: "", goalInterruptedReason: "" };
1661 });
1662 await writeState2(directory, sessionID, state);
1663 await toast2(client, `Resumed ${count} experimental goal(s).`, count ? "success" : "warning");
1664 if (count) {
1665 await scheduleDueWork(directory, client, sessionID);
1666 scheduleIdleWork(directory, client, sessionID);
1667 }
1668 }

Callers 1

OpenCodeLoopPluginFunction · 0.85

Calls 3

setGoalCompleteFunction · 0.85
setGoalBlockedFunction · 0.85
setGoalProgressFunction · 0.85

Tested by

no test coverage detected