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

Function buildPrompt

src/index.js:671–685  ·  view source on GitHub ↗
(directory, job)

Source from the content-addressed store, hash-verified

669 if (!stat.isFile() || stat.size > maxBytes) return ""
670 return await fs.readFile(filePath, "utf8")
671 } catch { return "" }
672}
673
674async function runProcess(command, args, cwd, timeoutMs = 60_000) {
675 return await new Promise((resolve) => {
676 const child = spawn(command, args, { cwd, shell: false, windowsHide: true })
677 const stdout = []
678 const stderr = []
679 const timer = setTimeout(() => { try { child.kill("SIGTERM") } catch {} }, timeoutMs)
680 child.stdout?.on("data", (data) => stdout.push(Buffer.from(data)))
681 child.stderr?.on("data", (data) => stderr.push(Buffer.from(data)))
682 child.on("error", (error) => { clearTimeout(timer); resolve({ code: -1, stdout: "", stderr: String(error) }) })
683 child.on("close", (code) => { clearTimeout(timer); resolve({ code: code ?? 0, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") }) })
684 })
685}
686
687async function runShellCommand(command, cwd, timeoutMs = 120_000) {
688 return await new Promise((resolve) => {

Callers 1

fireActionFunction · 0.85

Calls 4

isGoalJobFunction · 0.85
buildGoalPromptFunction · 0.85
readSmallTextFileFunction · 0.85
decoratePromptFunction · 0.85

Tested by

no test coverage detected