mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 01:27:35 +00:00
Packaged macOS builds now append /opt/local/bin and /opt/local/sbin to the seeded PATH when the default-prefix `port` binary exists, and the agent CLI install-dir fallback also checks /opt/local/bin. Both are appended last so existing Homebrew/system resolutions never change. Co-authored-by: Neil <neil@stably.ai>
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import { join } from 'node:path'
|
||
|
||
/** Lookup-only fallback: prepending system dirs to inherited PATH would reorder the user’s binaries (#18234).
|
||
* Keep system-block order aligned with patchPackagedProcessPath/POSIX_VERSION_MANAGER_BIN_DIRS; cross-block precedence differs
|
||
* for ~/.local/bin, which precedes this fallback but follows seeded system dirs. Do not hoist system paths above version managers.
|
||
* Omit sbin/~/bin and off-darwin /opt/homebrew; Linuxbrew has its own prefix. Include installer-owned .opencode/.vite-plus (#829) and .grok (#17590) bins.
|
||
* Exception: a newly discovered CLI with sibling node may prepend that dir only to its child PATH for runtime pairing (#10932). */
|
||
export function getSystemCliInstallDirectories(
|
||
platform: NodeJS.Platform,
|
||
homePath: string
|
||
): string[] {
|
||
// Both lookup and seeded system blocks cover POSIX only; Windows installer paths remain outside this fallback.
|
||
if (platform === 'win32') {
|
||
return []
|
||
}
|
||
const directories: string[] = []
|
||
if (platform === 'darwin') {
|
||
// Apple Silicon Homebrew; Intel Homebrew shares /usr/local with npm's prefix.
|
||
directories.push('/opt/homebrew/bin')
|
||
}
|
||
directories.push('/usr/local/bin')
|
||
if (platform === 'linux') {
|
||
// Avoid phantom snap/Linuxbrew probes off Linux, matching seeded PATH.
|
||
directories.push('/snap/bin', '/home/linuxbrew/.linuxbrew/bin')
|
||
}
|
||
directories.push(
|
||
'/nix/var/nix/profiles/default/bin',
|
||
join(homePath, '.nix-profile', 'bin'),
|
||
join(homePath, '.opencode', 'bin'),
|
||
join(homePath, '.vite-plus', 'bin'),
|
||
join(homePath, '.grok', 'bin')
|
||
)
|
||
if (platform === 'darwin') {
|
||
// MacPorts last, matching the seed; ungated since a lookup miss costs the same stat as the seed's `port` gate.
|
||
directories.push('/opt/local/bin')
|
||
}
|
||
return directories
|
||
}
|