feat(llm_cli): add xAI Grok Build CLI adapter as grok-cli provider#2662
feat(llm_cli): add xAI Grok Build CLI adapter as grok-cli provider#2662AniketR10 wants to merge 3 commits into
Conversation
Greptile code reviewThis repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md. Run a review — add a PR comment with: Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5. Optional: automate with the greploop skill. |
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge. The adapter follows existing patterns faithfully, credential scoping is correctly implemented, and all required config/registry wiring sites are updated. The changes are well-contained — a new adapter file, its registry/config wiring, and a test suite. The No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Runner as OpenSRE Runner
participant Adapter as GrokCLIAdapter
participant Resolver as BinaryResolver
participant Env as os.environ
participant Grok as grok CLI subprocess
Runner->>Adapter: detect()
Adapter->>Resolver: resolve_cli_binary(GROK_CLI_BIN, "grok", fallbacks)
Resolver-->>Adapter: binary_path
Adapter->>Grok: grok --version (probe, 5s timeout)
Grok-->>Adapter: version string
Adapter->>Env: XAI_API_KEY present?
alt API key set
Env-->>Adapter: "True - logged_in=True"
else No API key
Adapter->>Adapter: scan ~/.grok-build/, ~/.grok/ for session files
Adapter-->>Adapter: "logged_in=True/False/None"
end
Adapter-->>Runner: CLIProbe(installed, version, logged_in, detail)
Runner->>Adapter: build(prompt, model, workspace)
Adapter->>Env: nonempty_env_values(XAI_CLI_ENV_KEYS)
Env-->>Adapter: XAI_API_KEY, XAI_BASE_URL (if set)
Adapter-->>Runner: "CLIInvocation(argv, env={NO_COLOR:1, ...xAI creds})"
Runner->>Grok: "exec CLIInvocation (cwd=workspace, timeout=300s)"
Grok-->>Runner: stdout, stderr, returncode
alt "returncode == 0"
Runner->>Adapter: parse(stdout, stderr, returncode)
Adapter-->>Runner: stdout.strip()
else "returncode != 0"
Runner->>Adapter: explain_failure(stdout, stderr, returncode)
Adapter-->>Runner: error message
end
Reviews (3): Last reviewed commit: "fix(grok-cli): don't abandon credential ..." | Re-trigger Greptile |
|
@muddlebee i was in not in good health from past few days, so couldnt work on it, will get it done asap |
|
@greptile review |
|
@muddlebee please review |
|
Add demo also update .env.example |
|
@Devesh36 @muddlebee added the demo and .env.example |
Fixes #2552
Describe the changes you have made in this PR -
Adds support for xAI's Grok Build CLI as a new local-CLI LLM provider (grok-cli), so users on Grok Build can use the same onboarding and runtime flow as the other CLI adapters (Codex, Claude Code, etc.). It includes the adapter itself (binary discovery, --version/auth detection, headless grok -p invocation, and clear failure messages), registry/config/wizard wiring so it's selectable and reported by opensre doctor, secure forwarding of XAI_API_KEY only to the Grok subprocess, unit tests mirroring the existing adapters, and docs covering setup and usage.
Demo/Screenshot for feature changes and bug fixes -
Screencast.From.2026-05-30.10-45-40.mp4
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:
Followed the existing CLI adapter pattern: GrokCLIAdapter implements the shared contract and reuses common helpers for binary resolution, version probe, and timeouts. Auth is best-effort (no grok auth status), treating XAI_API_KEY or a login session file as authenticated. The key is forwarded only to the Grok subprocess (not the shared allowlist) to avoid leaks, and --always-approve is omitted so OpenSRE drives its own tools. Registry/config/wizard wiring is mechanical, with tests mirroring the other adapters.
Checklist before requesting a review
Note: Please check Allow edits from maintainers if you would like us to assist in the PR.