(runtime: SemanticDiffRuntime)
| 226 | } |
| 227 | |
| 228 | async function resolveSem(runtime: SemanticDiffRuntime): Promise<ResolvedSem | SemResolveFailure> { |
| 229 | for (const candidate of semCandidates(runtime)) { |
| 230 | if (candidate.explicit && isPathLike(candidate.command) && !runtime.fileExists(candidate.command)) { |
| 231 | return { |
| 232 | status: "unavailable", |
| 233 | reason: "sem-path-missing", |
| 234 | message: `PLANNOTATOR_SEM_PATH points to a missing file: ${candidate.command}`, |
| 235 | }; |
| 236 | } |
| 237 | |
| 238 | const versionResult = await runtime.runCommand(candidate.command, ["--version"], { |
| 239 | timeoutMs: SEM_VERSION_TIMEOUT_MS, |
| 240 | }); |
| 241 | const version = parseSemVersion(versionResult.stdout); |
| 242 | if (versionResult.exitCode === 0 && version) { |
| 243 | return { command: candidate.command, source: candidate.source, version }; |
| 244 | } |
| 245 | |
| 246 | if (candidate.explicit) { |
| 247 | return { |
| 248 | status: "unavailable", |
| 249 | reason: "invalid-sem-binary", |
| 250 | message: `PLANNOTATOR_SEM_PATH did not resolve to the Ataraxy sem CLI.`, |
| 251 | }; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | return { |
| 256 | status: "unavailable", |
| 257 | reason: "sem-not-found", |
| 258 | message: "Semantic diff is unavailable because the Ataraxy sem CLI was not found.", |
| 259 | }; |
| 260 | } |
| 261 | |
| 262 | export async function getSemanticDiffAvailability( |
| 263 | runtime: SemanticDiffRuntime = createDefaultSemanticDiffRuntime(), |
no test coverage detected