fix: include cache bin directory in which() lookups#18320
Conversation
Move Global.Path.bin from the data directory to the cache directory, and append it to PATH in which() so tools installed via npm are discoverable without being on the system PATH.
Greptile SummaryThis PR relocates Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant which
participant whichPkg
participant Global
Caller->>which: which(cmd, env?)
which->>Global: Global.Path.bin
Global-->>which: ~/.cache/opencode/bin
which->>which: base = env.PATH ?? process.env.PATH ?? ""
which->>which: full = base + ":" + ~/.cache/opencode/bin
which->>whichPkg: sync(cmd, { path: full })
whichPkg-->>which: resolved path | null
which-->>Caller: string | null
|
| const base = env?.PATH ?? env?.Path ?? process.env.PATH ?? process.env.Path ?? "" | ||
| const full = base ? base + path.delimiter + Global.Path.bin : Global.Path.bin |
There was a problem hiding this comment.
Inline single-use variable per style guide
full is used exactly once (on line 10), so per the project style guide it should be inlined. base is used twice and should stay. Consider inlining full directly into the path: property, potentially simplifying via a helper or by restructuring the ternary inline.
| const base = env?.PATH ?? env?.Path ?? process.env.PATH ?? process.env.Path ?? "" | |
| const full = base ? base + path.delimiter + Global.Path.bin : Global.Path.bin | |
| const base = env?.PATH ?? env?.Path ?? process.env.PATH ?? process.env.Path ?? "" | |
| const result = whichPkg.sync(cmd, { | |
| nothrow: true, | |
| path: base ? base + path.delimiter + Global.Path.bin : Global.Path.bin, |
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Global.Path.binfrom data directory to cache directoryGlobal.Path.binto PATH inwhich()so tools installed via npm in the cache are discoverable