Skip to content

feat(grok): add xAI Grok Build CLI as a first-class provider#7

Merged
bbingz merged 2 commits into
mainfrom
feat/grok-provider-2026-06-02
Jun 2, 2026
Merged

feat(grok): add xAI Grok Build CLI as a first-class provider#7
bbingz merged 2 commits into
mainfrom
feat/grok-provider-2026-06-02

Conversation

@bbingz
Copy link
Copy Markdown
Owner

@bbingz bbingz commented Jun 2, 2026

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)

  • One-shot grok -p <prompt> --output-format json (sync) / streaming-json (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) — both verified to compose with -p. -m (default grok-composer-2.5-fast = "Compose 2.5", or grok-build), --effort, -r/-c resume.
  • stderr noise handled: grok prints transient ERROR worker quit … UnexpectedContentType to stderr even on success → success judged by exit 0 + valid stdout JSON + text only.
  • Auth inferred from grok models (prints "logged in" + default model) — zero LLM/token cost; transient/timeout stays inconclusive.

Wiring (all surfaces)

PROVIDER_IDS · registry (TIMING_SUPPORT session; ttft/gen/tail; terminal event = 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).

Validation

npm test 462/462 (grok.test.js: 9 cases); companion bundles byte-identical. Flag compatibility (-p + --permission-mode plan / --always-approve) verified against the live CLI.

Notes

  • Sits at the structured-provider tier (claude/copilot/gemini). Independent of the kimi-code PR; both touch 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).

bbingz added 2 commits June 2, 2026 12:32
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.
@bbingz bbingz merged commit a72d104 into main Jun 2, 2026
1 check failed
@bbingz bbingz deleted the feat/grok-provider-2026-06-02 branch June 2, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant