feat(grok): add xAI Grok Build CLI as a first-class provider#7
Merged
Conversation
New provider `grok` wrapping the local Grok Build CLI (xAI, v0.2.x). Full integration across the
runtime + host surfaces; matches the structured-provider tier (claude/copilot/gemini).
Runtime (packages/polycli-runtime/src/grok.js, NEW):
- one-shot `grok -p <prompt> --output-format json` (sync, single {text,stopReason,sessionId,
requestId,thought} object) and `--output-format streaming-json` (line events thought/text/end).
- session id read STRUCTURALLY (json sessionId / streaming end.sessionId, UUIDv7) — no prose scan.
- YOLO via --always-approve (ask/rescue), read-only via --permission-mode plan (review), -m model
(grok-composer-2.5-fast default = "Compose 2.5", or grok-build), --effort, -r/-c resume.
- IMPORTANT: grok prints transient "ERROR worker quit ... UnexpectedContentType" to stderr even on
success — success is judged by exit 0 + valid stdout JSON + visible text, never stderr.
- auth inferred from `grok models` (prints "logged in" + default model; ZERO LLM/token cost);
ETIMEDOUT/transient stays inconclusive, never regresses to loggedOut.
Wiring: PROVIDER_IDS + registry (TIMING_SUPPORT session; ttft/gen/tail; isTerminalSummaryEvent=end)
+ timing extractProviderEventText + index export + review-flags (--permission-mode plan, readOnly
"plan") + REVIEW_HARD_CONSTRAINTS.grok + companion flag-dispatch (resume/effort) + sessions purge
honest-skip (url-encoded cwd dir) + check-review-cli-drift CHECK + all 7 command argument-hints +
3 skills (grok-cli-runtime / grok-prompting / grok-result-handling).
Tests: grok.test.js (NEW, 9 cases) + exports/registry/review-flags/consistency/integration-health
updated for the 11th provider. npm test 462/462; companion bundles byte-identical.
…isement Addresses the pre-merge Codex review gate for PR #7. - auth probe (BLOCKER): grok.js checked the generic "logged in" banner before the explicit auth-error regex, so a logged-out "not logged in" message (which contains the substring "logged in") was misclassified as loggedIn:true. Reorder so GROK_EXPLICIT_AUTH_ERROR_RE wins first; add a regression test using "not logged in" text (the prior logged-out test used "Please log in", which never exercised the substring trap). - host advertisement (MAJOR): grok was half-wired — present in the registry/commands but missing from every host-adapter provider list where agy appears. Add grok to polycli-codex + polycli-copilot skill descriptions and setup arg-hints, polycli-codex README + plugin.json longDescription, the root README, and docs/host-command-map. Add grok to validate-codex-adapter PROVIDERS so the gap is enforced; update the adapter test fixtures accordingly. - effort doc (MINOR): grok-cli-runtime SKILL claimed --effort is "mapped from polycli --effort", but polycli --effort is gemini-only and dropped for grok. Correct the doc to describe grok's native flag without the false mapping. npm test 463/463 (was 462; +1 grok auth regression). All 5 companion bundles regenerated byte-identical; validate:host-map + validate:codex-adapter green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch 3 of 3. Adds grok (xAI Grok Build CLI, v0.2.x) as the 11th polycli provider — full, release-ready integration.
Runtime (
grok.js, new)grok -p <prompt> --output-format json(sync) /streaming-json(eventsthought/text/end).sessionId/ streamingend.sessionId, UUIDv7) — no prose scan.--always-approve(ask/rescue); read-only via--permission-mode plan(review) — both verified to compose with-p.-m(defaultgrok-composer-2.5-fast= "Compose 2.5", orgrok-build),--effort,-r/-cresume.ERROR worker quit … UnexpectedContentTypeto stderr even on success → success judged by exit 0 + valid stdout JSON + text only.grok models(prints "logged in" + default model) — zero LLM/token cost; transient/timeout stays inconclusive.Wiring (all surfaces)
PROVIDER_IDS· registry (TIMING_SUPPORTsession; ttft/gen/tail; terminal event =end) · timingextractProviderEventText· index export ·review-flags(--permission-mode plan, readOnlyplan) ·REVIEW_HARD_CONSTRAINTS.grok· companion flag-dispatch (resume/effort) ·sessions purgehonest-skip (url-encoded cwd dir) ·check-review-cli-driftCHECK · all 7 commandargument-hints · 3 skills (grok-cli-runtime/grok-prompting/grok-result-handling).Validation
npm test462/462 (grok.test.js: 9 cases); companion bundles byte-identical. Flag compatibility (-p+--permission-mode plan/--always-approve) verified against the live CLI.Notes
review-flags.js/sessions.mjs/review.mjs/bundles, so expect a merge conflict on the second of the two to land (resolve by keeping both providers' entries).