(client, sessionID, directory)
| 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 | |
| 816 | async 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 | |
| 829 | async function maybeCompact(client, sessionID, job) { |
no test coverage detected