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

Function handleCommand

src/index.js:1588–1627  ·  view source on GitHub ↗
(directory, client, input, fallbackName, fallbackArgs, output)

Source from the content-addressed store, hash-verified

1586 await writeState(directory, sessionID, state);
1587 await writeGoalReport(directory, sessionID, job);
1588 await appendLoopLog(directory, "goal-blocked", { sessionID, job: job.name || job.id, reason: job.goalBlockedReason });
1589 return { ok: true, job, message: `Goal blocked: ${job.goalBlockedReason}` };
1590}
1591async function setGoalProgress(directory, sessionID, args = {}) {
1592 const state = await readState(directory, sessionID);
1593 const job = pickGoalJob(state, args.target);
1594 if (!job)
1595 return { ok: false, message: "No active experimental goal was found." };
1596 const parsed = parseGoalToolText(args, ["summary", "next", "evidence"]);
1597 const item = { time: new Date().toISOString(), summary: parsed.summary || "Progress recorded.", next: parsed.next || "", evidence: parsed.evidence || "" };
1598 job.goalProgress = [...job.goalProgress || [], item].slice(-30);
1599 if (parsed.evidence)
1600 job.goalEvidence = parsed.evidence;
1601 job.noProgressCount = 0;
1602 job.lastProgressAt = now();
1603 state.jobs = (state.jobs || []).map((candidate) => candidate.id === job.id ? job : candidate);
1604 await writeState(directory, sessionID, state);
1605 await writeGoalReport(directory, sessionID, job);
1606 await appendLoopLog(directory, "goal-progress", { sessionID, job: job.name || job.id, summary: item.summary });
1607 return { ok: true, job, message: `Goal progress recorded: ${item.summary}` };
1608}
1609
1610// src/source/opencode/goal-commands.js
1611function requireFunction2(value, name) {
1612 if (typeof value !== "function")
1613 throw new TypeError(`createGoalCommandHandlers requires ${name}`);
1614 return value;
1615}
1616function createGoalCommandHandlers(options = {}) {
1617 const addLoop = requireFunction2(options.addLoop, "addLoop");
1618 const scheduleDueWork = requireFunction2(options.scheduleDueWork, "scheduleDueWork");
1619 const scheduleIdleWork = requireFunction2(options.scheduleIdleWork, "scheduleIdleWork");
1620 const toast2 = requireFunction2(options.toast, "toast");
1621 const say2 = requireFunction2(options.say, "say");
1622 const readState2 = typeof options.readState === "function" ? options.readState : readState;
1623 const writeState2 = typeof options.writeState === "function" ? options.writeState : writeState;
1624 const setGoalComplete2 = typeof options.setGoalComplete === "function" ? options.setGoalComplete : setGoalComplete;
1625 const setGoalBlocked2 = typeof options.setGoalBlocked === "function" ? options.setGoalBlocked : setGoalBlocked;
1626 async function statusGoal(directory, client, sessionID) {
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);

Callers 1

OpenCodeLoopPluginFunction · 0.85

Calls 15

commandNameFunction · 0.85
rememberSessionFunction · 0.85
wasHandledFunction · 0.85
markHandledFunction · 0.85
addGoalFunction · 0.85
handledFunction · 0.85
statusGoalFunction · 0.85
pauseGoalFunction · 0.85
resumeGoalFunction · 0.85
clearGoalFunction · 0.85
completeGoalCommandFunction · 0.85
blockGoalCommandFunction · 0.85

Tested by

no test coverage detected