MCPcopy Index your code
hub / github.com/ByBrawe/opencode-loop / jobDueAt

Function jobDueAt

src/index.js:892–902  ·  view source on GitHub ↗
(job, current = now())

Source from the content-addressed store, hash-verified

890 if (!job.checkpointOnly && !job.gitCheckpoint) return
891 const inRepo = await runProcess("git", ["rev-parse", "--is-inside-work-tree"], directory, 10_000)
892 if (inRepo.code !== 0) return
893 const status = await runProcess("git", ["status", "--short"], directory, 30_000)
894 if (!status.stdout.trim()) return
895 const timestamp = new Date().toISOString().replace(/[:.]/g, "-")
896 const checkpointDir = path.join(stateDir(directory), "checkpoints", safeID(sessionID))
897 await ensureDir(checkpointDir)
898 const diff = await runProcess("git", ["diff", "--binary"], directory, 120_000)
899 const staged = await runProcess("git", ["diff", "--cached", "--binary"], directory, 120_000)
900 const prefix = `${timestamp}-${safeID(job.name || job.id)}`
901 await fs.writeFile(path.join(checkpointDir, `${prefix}.status.txt`), status.stdout + status.stderr)
902 await fs.writeFile(path.join(checkpointDir, `${prefix}.patch`), `${diff.stdout}\n${staged.stdout}`)
903 if (job.gitCheckpoint) {
904 await runProcess("git", ["add", "-A"], directory, 120_000)
905 await runProcess("git", ["commit", "-m", `chore: opencode loop checkpoint ${timestamp}`], directory, 120_000)

Callers 1

nextDueDelayFunction · 0.85

Calls 2

nowFunction · 0.85
isGoalJobFunction · 0.85

Tested by

no test coverage detected