feat(llm-cli): modularize CLI binary resolution#795
feat(llm-cli): modularize CLI binary resolution#795muddlebee wants to merge 4 commits intoTracer-Cloud:mainfrom
Conversation
- add shared binary resolver utilities for env, PATH, and fallback path resolution - refactor Codex adapter to use the shared resolver while keeping compatibility behavior - update llm_cli AGENTS guidance with optional env usage and provider implementation checklist Made-with: Cursor
Greptile SummaryThis PR extracts binary resolution logic from Key findings:
Confidence Score: 2/5Not safe to merge as-is — existing tests will fail on Linux/macOS CI because the The refactoring intent and the new module are well-structured, but the compatibility shim introduced in Focus on Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CodexAdapter._resolve_binary] --> B[resolve_cli_binary in binary_resolver.py]
B --> C{CODEX_BIN set and runnable?}
C -- Yes --> D[Return explicit path]
C -- No --> E[shutil.which each candidate_binary_names]
E --> F{Found on PATH?}
F -- Yes --> G[Return PATH hit]
F -- No --> H[_fallback_codex_paths in codex.py]
H --> I[default_cli_fallback_paths in binary_resolver.py]
I --> J{npm_prefix_bin_dirs cached lookup}
J --> K[Return ordered fallback list]
K --> L{Any candidate runnable?}
L -- Yes --> M[Return first runnable]
L -- No --> N[Return None]
Reviews (1): Last reviewed commit: "feat(llm-cli): centralize cli binary res..." | Re-trigger Greptile |
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
|
@Devesh36 @rrajan94 @yashksaini-coder quick refactor on top of my recent CLI PR :D then we can open issues for new CLI like gemini and others.. |
Refactor and modularize CLI path resolution #781 to be used in generic way by other CLI providers.
Describe the changes you have made in this PR -
app/integrations/llm_cli/binary_resolver.pyas a shared resolver for CLI binaries.CodexAdapterinapp/integrations/llm_cli/codex.pyto use the shared resolver (env -> PATH -> fallback paths) while preserving compatibility behavior.app/integrations/llm_cli/AGENTS.mdwith up-to-date guidance, optional env handling (CODEX_MODEL,CODEX_BIN), and a provider checklist.CODEX_BINandCODEX_MODELremain optional and fallback resolution remains active when unset/invalid.Screenshots of the UI changes (If any) -
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
I extracted executable lookup concerns from the Codex adapter into a reusable utility module so new CLI adapters can share one consistent resolution strategy. The resolver keeps explicit override support (
*_BIN) while preserving robust PATH and conventional install path fallback behavior.I chose this approach over duplicating resolver code into future adapters because it reduces repeated platform-specific logic and makes behavior changes easier to maintain in one place. I retained compatibility hooks that existing tests expect in
codex.pyto avoid regressions while still reducing adapter complexity.Checklist before requesting a review
Concise explainer: this PR introduces a shared CLI binary resolver and updates Codex integration/docs so optional envs and fallback behavior are explicit and reusable for upcoming CLI provider sub-issues.