(stdout: string)
| 152 | } |
| 153 | |
| 154 | function parseLastJson<T>(stdout: string): T { |
| 155 | const lines = stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean); |
| 156 | for (let i = lines.length - 1; i >= 0; i--) { |
| 157 | const line = lines[i]; |
| 158 | if (!line.startsWith("{")) continue; |
| 159 | return JSON.parse(line) as T; |
| 160 | } |
| 161 | throw new Error("Plannotator CLI did not return JSON."); |
| 162 | } |
| 163 | |
| 164 | export function buildCliBridgeEnv( |
| 165 | bridge: OpenCodeBridgeContext | undefined, |
no test coverage detected