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

Function fireAction

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

Source from the content-addressed store, hash-verified

1191 if (forced === "prompt" || forced === "ask")
1192 return "prompt";
1193 if (forced === "command" || forced === "cmd" || forced === "slash")
1194 return "command";
1195 if (forced === "shell")
1196 return "shell";
1197 if (text.startsWith("/"))
1198 return "command";
1199 if (text.startsWith("!") || text.startsWith("$"))
1200 return "shell";
1201 return "prompt";
1202}
1203function decoratePrompt(job) {
1204 const additions = [];
1205 const continuation = continuationProjectInstruction(job.action);
1206 if (continuation)
1207 additions.push(continuation);
1208 if (job.progressFile)
1209 additions.push(`Use ${job.progressFile} as the main progress/TODO state file. Read it before choosing the next task and update it after work.`);
1210 if (job.lastVerifyFailure)
1211 additions.push("Previous verify command failed. Fix this before moving on. Failure summary: " + String(job.lastVerifyFailure).slice(0, 1200));
1212 if (job.askNever)
1213 additions.push("Do not ask the user questions. Make reasonable assumptions and continue. Only write a short BLOCKED note if truly blocked.");
1214 if (job.safe)
1215 additions.push("Safety rules: do not run destructive commands such as git reset, git clean, rm -rf, del /s, rmdir /s, force push, production deploys, production migrations, terraform destroy, or deleting user data. If such an action seems needed, write a BLOCKED note instead.");
1216 if (job.batch > 0)
1217 additions.push(`Batch rule: in this run, work on at most ${job.batch} unfinished TODO item(s). Mark completed items with [x].`);
1218 if (job.quiet)
1219 additions.push("Keep replies short. Summarize only what changed, tests run, and next step.");
1220 if (job.testCommand)
1221 additions.push(`After making changes, run this test/check command if applicable: ${job.testCommand}. If it fails, fix the failure and try again.`);
1222 if (job.checkpointOnly || job.gitCheckpoint)
1223 additions.push("Keep changes incremental and easy to review because the loop will create a checkpoint after the run.");
1224 if (!additions.length)
1225 return job.action;
1226 return `${job.action}
1227
1228OpenCode loop instructions:
1229- ${additions.join(`
1230- `)}`;
1231}
1232function isGoalJob(job) {
1233 return String(job?.kind || "").toLowerCase() === "goal";
1234}
1235function goalStatusText(job) {
1236 const status = job?.goalStatus || (isGoalJob(job) ? "active" : "");
1237 if (!status)
1238 return "";

Callers 1

maybeRunDueJobsFunction · 0.85

Calls 10

actionKindFunction · 0.85
compactSessionFunction · 0.85
splitFirstFunction · 0.85
toastFunction · 0.85
compactTuiCommandNameFunction · 0.85
sdkCallFunction · 0.85
dangerousShellFunction · 0.85
appendLoopLogFunction · 0.85
fireSdkFunction · 0.85
buildPromptFunction · 0.85

Tested by

no test coverage detected