()
| 325 | private cachedWhoami: CoderWhoamiData | null = null; |
| 326 | |
| 327 | private async resolveCoderBinaryPath(): Promise<string | null> { |
| 328 | if (process.platform === "win32") { |
| 329 | // Prefer native Windows lookup — returns paths cmd.exe can execute directly. |
| 330 | try { |
| 331 | using proc = execAsync("where.exe coder"); |
| 332 | const { stdout } = await proc.result; |
| 333 | const firstLine = stdout.split(/\r?\n/)[0]?.trim(); |
| 334 | if (firstLine) return firstLine; |
| 335 | } catch { |
| 336 | // where.exe may not find coder; fall through to Git Bash lookup. |
| 337 | } |
| 338 | |
| 339 | // Fallback: Git Bash lookup. Normalize MSYS paths (/c/...) to Windows (C:\...). |
| 340 | let shell: string | undefined; |
| 341 | try { |
| 342 | shell = getBashPath(); |
| 343 | } catch { |
| 344 | return null; |
| 345 | } |
| 346 | |
| 347 | try { |
| 348 | using proc = execAsync("command -v coder", { shell }); |
| 349 | const { stdout } = await proc.result; |
| 350 | const firstLine = stdout.split(/\r?\n/)[0]?.trim(); |
| 351 | // Convert MSYS path format to native Windows path for cmd.exe compatibility. |
| 352 | // SSH ProxyCommand runs through cmd.exe, not Git Bash. |
| 353 | return firstLine ? toWindowsPath(firstLine) : null; |
| 354 | } catch { |
| 355 | return null; |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | // POSIX: command -v is universally available |
| 360 | try { |
| 361 | using proc = execAsync("command -v coder"); |
| 362 | const { stdout } = await proc.result; |
| 363 | const firstLine = stdout.split(/\r?\n/)[0]?.trim(); |
| 364 | return firstLine || null; |
| 365 | } catch { |
| 366 | return null; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Get Coder CLI info. Caches result for the session. |
no test coverage detected