(rec, { recheckEnv = false } = {})
| 31 | * (real instances), so unit tests stay fast and deterministic. |
| 32 | */ |
| 33 | export async function buildState(rec, { recheckEnv = false } = {}) { |
| 34 | const state = await scanRepo(rec.repoPath); |
| 35 | if (state && state.ok && typeof rec.runDoctor === "function") { |
| 36 | if (recheckEnv || rec.doctor == null) { |
| 37 | try { |
| 38 | rec.doctor = await rec.runDoctor(state); |
| 39 | } catch { |
| 40 | rec.doctor = rec.doctor || null; |
| 41 | } |
| 42 | } |
| 43 | state.doctor = rec.doctor; |
| 44 | } else if (state && state.ok) { |
| 45 | state.doctor = rec.doctor || null; |
| 46 | } |
| 47 | if (state && state.ok) state.autopilot = rec.autopilot || null; |
| 48 | return state; |
| 49 | } |
| 50 | |
| 51 | /** Write an SSE payload to every connected client of an instance. */ |
| 52 | export function broadcast(rec, payload) { |
no test coverage detected