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.
npx agentmods add instructions/blockedpath/pi-xai-oauth/agents-mdgit clone --depth 1 https://github.com/BlockedPath/pi-xai-oauthWrote 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.
[](https://agentmods.dev/instructions/blockedpath/pi-xai-oauth/agents-md)<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>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.
| Model | Per session | Once 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 |
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.
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.js → pi 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.jsornpm 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.jsonwhen possible without deleting or revoking it - Fetch OAuth-visible models only from the pinned authenticated CLI proxy
/models-v2endpoint - 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-oauthcanonical 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, andtsconfig.jsoninside the packed tarball;scripts/run-compatibility-matrix.jsextracts the pack and runsnpm testplusnpm run typecheckinside 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-useridtransiently from the pinned authenticated CLI-proxy/userendpoint before any billing request - Keep
/xai-usageexplicit, and keep its optional status off by default, session-scoped, bounded, and inactive outside xAI models
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.
- 5d ago First seen · 182 lines · 2,961 tokens per session scan A c71e077f3a4d
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.
Other instructions, from other repositories
grok-keysmith AGENTS.md
AGENTS.md instructions for Jia-Ethan/grok-keysmith, covering repository agent guide, scope, release and external state, change boundaries and documentation rules.
grok-cli AGENTS.md
Instructions for superagent-ai/grok-cli, covering agents.md, cursor cloud specific instructions, quick reference, known issues and environment.
grokbuild-proxy CLAUDE.md
Instructions for GreyGunG/grokbuild-proxy, covering grokbuild, 项目状态, 架构, 开发与验证 and 变更约束.
goal-engineering AGENTS.md
Instructions for cobusgreyling/goal-engineering, covering agents.md — goal engineering reference, project purpose, verification, goal discipline and deny list.
grok-subagent AGENTS.md
Instructions for Walvez/grok-subagent, covering agents.md, 项目定位, 怎么跑起来, 依赖:node.js 22+、已登录的官方 grok cli(/.grok/bin/grok 或 grok) and 安装后必须新建 codex 任务,旧会话不会热加载 skill/mcp.
grok-build-mcp AGENTS.md
AGENTS.md instructions for zai-one/grok-build-mcp, covering agents.md — grok-delegate / unofficial grok mcp, язык, typed tools vs navigator, откуда берётся корень and проект должен сам включить мост.