pi-xai-oauth AGENTS.md

pi-xai-oauth AGENTS.md is an instructions file for Codex, OpenCode from BlockedPath/pi-xai-oauth. It costs 2,961 tokens per session, scanned A, original, MIT.

An operations guide for adding xAI OAuth login and Grok model access to Pi, a coding assistant that supports configurable AI providers.

In plain words
What is it for?
Use it when installing or configuring the package, implementing xAI authentication, selecting models, or working on usage reporting and API streaming.
Why use it?
It gives agents the approved setup flow, provider boundaries, authentication steps, and catalog rules needed to change the package safely.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/blockedpath/pi-xai-oauth/agents-md
Clone the repo
git clone --depth 1 https://github.com/BlockedPath/pi-xai-oauth

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pi-xai-oauth AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/blockedpath/pi-xai-oauth/agents-md.svg)](https://agentmods.dev/instructions/blockedpath/pi-xai-oauth/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/blockedpath/pi-xai-oauth/agents-md"><img src="https://agentmods.dev/badge/instructions/blockedpath/pi-xai-oauth/agents-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,961 This file is loaded in full into every session.
When invoked 2,961 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02961 $0.02961
Opus 5 $0.01481 $0.01481
Sonnet 5 $0.00592 $0.00592
Haiku 4.5 $0.00296 $0.00296

Measured 5d ago against content hash c71e077f3a4d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pi-xai-oauth AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 182 lines

How it starts

The opening of the file, as written. The whole thing — 182 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — AI Agent Operations Manual for pi-xai-oauth

For AI coding agents only. Keep this file machine-readable and concise. Human-facing docs live in README.md.

Project Overview

pi-xai-oauth is a pi-package that registers the optional xAI OAuth provider (xai-auth) and the authenticated account's OAuth-visible Grok model catalog, with Grok 4.6 as the curated offline fallback. Opt-in network tools and /xai-usage also work with Pi's built-in xai SuperGrok/X Premium chat provider; setup seeds defaultProvider: xai only when unset and never overwrites an existing provider choice.

Core flow: bin/setup.jspi install → bounded catalog selection in extensions/xai/catalog.ts → provider registration in extensions/xai-oauth.ts → browser PKCE or bounded device authorization in extensions/xai/oauth.ts / extensions/xai/device-auth.ts → pinned browser OIDC/JWKS validation in extensions/xai/oidc.ts → streaming via xAI API helpers in extensions/xai/responses.ts; explicit revision-pinned subscription usage lives in extensions/xai/usage.ts.

Key Commands (Exact, Copy-Paste Ready)

  • Install / setup: node bin/setup.js or npm run setup
  • Install as pi extension: pi install npm:pi-xai-oauth
  • Full policy/unit/loader gate: npm test
  • Focused Vitest suite: npm run test:unit -- tests/oauth/browser-login.test.ts
  • V8 coverage: npm run test:coverage
  • Real Pi loader smoke: npm run test:loader
  • Run TypeScript: npm run typecheck (production, tests, fixtures, config)
  • Verify Pi policy/package metadata: npm run compatibility:check
  • Verify exact packed Pi boundaries: npm run compatibility:boundaries
  • Verify the scoped GitHub Packages mirror: node scripts/verify-github-package.js
  • Evaluate an unadvertised Pi candidate: node scripts/run-compatibility-matrix.js X.Y.Z --candidate
  • Git: Always work on feature branches and confirm the active branch before edits.

Architecture & Boundaries (MUST / MUST NOT)

MUST:

  • Register providers via pi.registerProvider("xai-auth", { ... })
  • Keep browser PKCE S256 with local callback server as the first/default login method
  • Offer device authorization through pi's native selector/device-code callbacks for remote/headless human login
  • Pin the device and token endpoints; wait before polling; honor interval plus cumulative slow-down; bound expiry; propagate cancellation
  • Require matching state for every HTTP or pasted browser authorization callback before token exchange
  • Validate retained fresh-login ID tokens against pinned first-party discovery/JWKS, ES256, issuer, audience, expiry, and nonce
  • Support reasoning levels: none / low / medium / high
  • Reuse ~/.grok/auth.json when possible without deleting or revoking it
  • Fetch OAuth-visible models only from the pinned authenticated CLI proxy /models-v2 endpoint
  • Treat successful catalog responses as exact entitlement state; additions appear and removals disappear
  • Keep the normalized token-free catalog cache atomic and apply the documented TTL/stale/fallback policy
  • Preserve known model metadata and compatibility behavior without inventing unentitled model families; known aliases and independently verified OAuth request slugs may be advertised only while their entitlement source is present at registration/runtime (cache stays exact)
  • Keep both Pi peers aligned to the checked-in bounded range in compatibility/pi-versions.json
  • Keep npmjs pi-xai-oauth canonical and publish GitHub Packages only as the exact scoped mirror @blockedpath/pi-xai-oauth; setup must treat both names as aliases and prevent duplicate registration
  • Install/report exact Pi matrix versions from a clean packed package; never reuse the repository lockfile for boundary jobs
  • Keep tests/, its fixtures, vitest.config.mts, and tsconfig.json inside the packed tarball; scripts/run-compatibility-matrix.js extracts the pack and runs npm test plus npm run typecheck inside it, so excluding them silently breaks both exact-Pi boundary jobs
  • Keep normal Pi dev dependencies exact at the policy's latest tested release and review candidate releases before widening support
  • Resolve x-userid transiently from the pinned authenticated CLI-proxy /user endpoint before any billing request
  • Keep /xai-usage explicit, and keep its optional status off by default, session-scoped, bounded, and inactive outside xAI models

Read the full file on GitHub · 182 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 182 lines · 2,961 tokens per session scan A c71e077f3a4d

Subscribe to this mod's changes

pi-xai-oauth AGENTS.md is an instructions file published in the GitHub repository BlockedPath/pi-xai-oauth (43 stars, last pushed today), licensed MIT. It adds 2,961 tokens to every session, about $0.0148 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other instructions, from other repositories