(directory, client, sessionID, options = {})
| 1235 | function goalStatusText(job) { |
| 1236 | const status = job?.goalStatus || (isGoalJob(job) ? "active" : ""); |
| 1237 | if (!status) |
| 1238 | return ""; |
| 1239 | if (status === "completed") |
| 1240 | return "completed"; |
| 1241 | if (status === "blocked") |
| 1242 | return "blocked"; |
| 1243 | if (job?.paused) |
| 1244 | return "paused"; |
| 1245 | return status; |
| 1246 | } |
| 1247 | function applyTestfixPreset(job, defaults = {}) { |
| 1248 | if (defaults.testfixPreset) { |
| 1249 | const defaultCommand = String(defaults.verifyCommand || "npm test"); |
| 1250 | const parsedAction = String(job.action || "").trim(); |
| 1251 | const usedDefaultAction = parsedAction === String(defaults.action || "").trim(); |
| 1252 | if (!usedDefaultAction && job.verifyCommand === defaults.verifyCommand) { |
| 1253 | job.verifyCommand = parsedAction; |
| 1254 | job.action = `Run the project tests. Fix failures. Re-run the tests. Test command hint: ${parsedAction}`; |
| 1255 | } else if (usedDefaultAction && job.verifyCommand !== defaults.verifyCommand) { |
| 1256 | job.action = `Run the project tests. Fix failures. Re-run the tests. Test command hint: ${job.verifyCommand || defaultCommand}`; |
| 1257 | } |
| 1258 | } |
| 1259 | return job; |
| 1260 | } |
| 1261 | |
| 1262 | // src/source/opencode/command-router.js |
| 1263 | var HANDLER_NAMES = [ |
| 1264 | "addGoal", |
| 1265 | "statusGoal", |
| 1266 | "pauseGoal", |
| 1267 | "resumeGoal", |
| 1268 | "clearGoal", |
| 1269 | "completeGoalCommand", |
| 1270 | "blockGoalCommand", |
| 1271 | "addLoop", |
| 1272 | "stopLoop", |
| 1273 | "statusLoop", |
| 1274 | "logsLoop", |
| 1275 | "helpLoop", |
| 1276 | "runNow", |
| 1277 | "updateJobState", |
| 1278 | "doctorLoop", |
| 1279 | "initLoop", |
| 1280 | "exportLoop" |
| 1281 | ]; |
| 1282 | function requireFunction(value, name) { |
| 1283 | if (typeof value !== "function") |
| 1284 | throw new TypeError(`createCommandRouter requires ${name}`); |
| 1285 | return value; |
| 1286 | } |
| 1287 | function createCommandRouter(options = {}) { |
| 1288 | const rememberSession = requireFunction(options.rememberSession, "rememberSession"); |
| 1289 | const captureSessionExecutionContext2 = typeof options.captureSessionExecutionContext === "function" ? options.captureSessionExecutionContext : captureSessionExecutionContext; |
| 1290 | const guardLoopOwnedUserMessage2 = typeof options.guardLoopOwnedUserMessage === "function" ? options.guardLoopOwnedUserMessage : guardLoopOwnedUserMessage; |
| 1291 | const handlers = {}; |
| 1292 | for (const name of HANDLER_NAMES) |
| 1293 | handlers[name] = requireFunction(options.handlers?.[name], `handlers.${name}`); |
| 1294 | return async function handleCommand(directory, client, input, fallbackName, fallbackArgs, output, source = "before") { |
no test coverage detected