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

Function readLiveSessionStatus

src/index.js:810–826  ·  view source on GitHub ↗
(client, sessionID, directory)

Source from the content-addressed store, hash-verified

808 if (job.action) sections.push(decoratePrompt(job))
809 for (const file of job.includeFiles || []) {
810 const text = await readSmallTextFile(path.resolve(directory, file), 80_000)
811 if (text.trim()) sections.push(`Context from ${file}:\n${text.trim().slice(0, 20_000)}`)
812 }
813 return sections.join("\n\n---\n\n") || decoratePrompt(job)
814}
815
816async function ensureBranch(directory, job, client, sessionID) {
817 if (!job.branch || job.branchDone) return job
818 const branch = safeID(job.branch)
819 const inRepo = await runProcess("git", ["rev-parse", "--is-inside-work-tree"], directory, 10_000)
820 if (inRepo.code !== 0) { job.branchDone = true; return job }
821 let result = await runProcess("git", ["switch", branch], directory, 30_000)
822 if (result.code !== 0) result = await runProcess("git", ["switch", "-c", branch], directory, 30_000)
823 job.branchDone = true
824 await toast(client, result.code === 0 ? `Loop branch active: ${branch}` : `Could not switch/create branch: ${branch}`, result.code === 0 ? "success" : "warning")
825 await appendLoopLog(directory, "branch", { sessionID, branch, code: result.code })
826 return job
827}
828
829async function maybeCompact(client, sessionID, job) {

Callers 1

sessionStatusTypeFunction · 0.85

Calls 2

sdkErrorFunction · 0.85
sdkDataFunction · 0.85

Tested by

no test coverage detected