Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
46e3b2a
feat: implement Grep, Glob, LS, and Read tools with ripgrep support a…
kenryu42 Jun 2, 2026
558138b
feat: implement dynamic tool scoping and compact result rendering for…
kenryu42 Jun 2, 2026
980fe06
refactor: modularize codebase by decomposing index into dedicated ser…
kenryu42 Jun 2, 2026
6512248
test: add context window validation for default model configurations …
kenryu42 Jun 2, 2026
01f31d8
test: add comprehensive test suites for file, rendering, search, and …
kenryu42 Jun 2, 2026
ceb74e4
feat: add Edit tool and support for Cursor-style argument variations …
kenryu42 Jun 2, 2026
a67794a
chore: reformat codebase using biome with space indentation and singl…
kenryu42 Jun 2, 2026
dff7f82
docs: add Cursor tool compatibility documentation to README
kenryu42 Jun 2, 2026
0f79e0d
fix: improve file editing, grep robustness, and tool error handling w…
kenryu42 Jun 2, 2026
feafff5
refactor: update catalog model structure to support dynamic provider …
kenryu42 Jun 2, 2026
2096679
fix: improve tool output handling, file system robustness, quota cach…
kenryu42 Jun 2, 2026
6f89545
Merge branch 'main' into cursor-native-tools
kenryu42 Jun 2, 2026
d60be86
fix: add failed and error metadata to tool error details
kenryu42 Jun 2, 2026
ff16916
fix: enforce workspace boundary for file tool paths
kenryu42 Jun 2, 2026
e7ae2f7
fix: support basename-only glob patterns in find fallback
kenryu42 Jun 2, 2026
95a73d7
fix: improve OAuth error handling, timeouts, and transport robustness
kenryu42 Jun 2, 2026
13b1b0f
fix: add cross-platform shell command detection
kenryu42 Jun 2, 2026
294e966
fix: refine reasoning effort support check with model-level config
kenryu42 Jun 2, 2026
d8267a8
refactor: centralize GROK_TOOL_NAMES in register module
kenryu42 Jun 2, 2026
93bc1f4
fix: extract all system/developer instructions and preserve existing …
kenryu42 Jun 2, 2026
982c360
docs: clarify GROK_CLI_OAUTH_TOKEN bypass behavior
kenryu42 Jun 2, 2026
7982041
test: accept platform-specific tool errors
kenryu42 Jun 2, 2026
eb0bea0
fix: make tool fallbacks and image paths portable
kenryu42 Jun 2, 2026
eb1f664
Fix portable grep fallback
kenryu42 Jun 2, 2026
381868e
fix: make glob sorting resilient to deleted files
kenryu42 Jun 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
coverage
dist/
docs/
*.tgz
.DS_Store
1 change: 1 addition & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!docs/
30 changes: 15 additions & 15 deletions .release-tools/cache.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"scripts": {
"typecheck": "tsc --noEmit",
"knip": "knip --production",
"lint": "biome check --write .",
"lint:ci": "biome ci .",
"check-duplicates": "bunx jscpd src tests --exitCode 1 --reporters ai --noTips",
"check": "bun run lint && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"check:ci": "bun run lint:ci && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"prepare": "husky"
},
"lintStaged": {
"*": ["biome check --write --no-errors-on-unmatched"]
},
"tsconfig": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ES2022\",\n\t\t\"module\": \"ES2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"strict\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"declaration\": true,\n\t\t\"declarationMap\": true,\n\t\t\"sourceMap\": true,\n\t\t\"outDir\": \"./dist\",\n\t\t\"rootDir\": \".\"\n\t},\n\t\"include\": [\"src/**/*.ts\"],\n\t\"exclude\": [\"node_modules\", \"dist\"]\n}\n",
"installedDeps": []
"scripts": {
"typecheck": "tsc --noEmit",
"knip": "knip --production",
"lint": "biome check --write .",
"lint:ci": "biome ci .",
"check-duplicates": "bunx jscpd src tests --exitCode 1 --reporters ai --noTips",
"check": "bun run lint && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"check:ci": "bun run lint:ci && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"prepare": "husky"
},
"lintStaged": {
"*": ["biome check --write --no-errors-on-unmatched"]
},
"tsconfig": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ES2022\",\n\t\t\"module\": \"ES2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"strict\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"declaration\": true,\n\t\t\"declarationMap\": true,\n\t\t\"sourceMap\": true,\n\t\t\"outDir\": \"./dist\",\n\t\t\"rootDir\": \".\"\n\t},\n\t\"include\": [\"src/**/*.ts\"],\n\t\"exclude\": [\"node_modules\", \"dist\"]\n}\n",
"installedDeps": []
}
8 changes: 4 additions & 4 deletions .release-tools/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "release-tools/config";
import { defineConfig } from 'release-tools/config';

export default defineConfig({
packageName: "pi-grok-cli",
repo: "kenryu42/pi-grok-cli",
excludedAuthors: ["kenryu42"],
packageName: 'pi-grok-cli',
repo: 'kenryu42/pi-grok-cli',
excludedAuthors: ['kenryu42'],
});
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
[![Version](https://img.shields.io/github/v/tag/kenryu42/pi-grok-cli?label=version&color=blue)](https://github.com/kenryu42/pi-grok-cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)

A pi extension that connects to **Grok CLI's API endpoint** .

## Why?

The Grok CLI uhas access to models **not available** on the public `api.x.ai` API yet:
A pi extension that connects to **Grok CLI's API endpoint**.
The Grok CLI has access to models **not available** on the public `api.x.ai` API yet:

| Model | Public API (`api.x.ai`) | Grok CLI |
|---|---|---|
Expand All @@ -18,6 +15,16 @@ The Grok CLI uhas access to models **not available** on the public `api.x.ai` AP

`grok-composer-2.5-fast` is Cursor's Composer 2.5 model, a purpose-built agentic coding model optimized for long-horizon coding tasks.

## Cursor Tool Compatibility

Grok CLI models are trained to use Cursor-style coding tools. This extension includes compatibility shims so those models can keep using familiar tool calls inside pi:

- File tools: `Read`, `Write`, `StrReplace`, `Edit`, `Delete`, and `LS`
- Search tools: `Grep` and `Glob`
- Terminal tool: `Shell`

The shims also normalize common Cursor/Grok argument shapes, such as `contents` for writes, `glob_pattern` for file search, `glob_filter` for grep filters, and `old_string`/`new_string` or `oldText`/`newText` for exact replacements. This keeps agentic coding workflows moving instead of failing on tool schema mismatches.

## Requirements

You need an active Grok subscription or an X Premium subscription with Grok access to use this extension.
Expand Down Expand Up @@ -66,4 +73,4 @@ Select **"Grok CLI"** from the provider list. This opens the xAI OAuth page in y
| `PI_GROK_CLI_MODELS` | (all models) | Comma-separated model IDs to expose |
| `PI_GROK_CLI_OAUTH_CLIENT_ID` | `b1a00492-...` | Override OAuth client ID |
| `PI_GROK_CLI_OAUTH_SCOPE` | `openid profile email offline_access grok-cli:access api:access` | Override OAuth scopes |
| `GROK_CLI_OAUTH_TOKEN` | — | Direct token bypass (no auto-refresh) |
| `GROK_CLI_OAUTH_TOKEN` | — | Direct token bypass that skips OAuth entirely. No automatic refresh or renewal is performed; provide a valid external access token and replace or rotate it when it expires. |
68 changes: 36 additions & 32 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "all",
"semicolons": "always"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
2 changes: 2 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entry": ["src/shared/backup_worker.ts"],
"project": ["**/*.ts", "!**/*.d.ts", "!.release-tools/**"],
"ignoreDependencies": ["lint-staged"]
"entry": ["src/shared/backup_worker.ts"],
"project": ["**/*.ts", "!**/*.d.ts", "!.release-tools/**"],
"ignoreDependencies": ["lint-staged"]
}
146 changes: 74 additions & 72 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,74 +1,76 @@
{
"name": "pi-grok-cli",
"version": "0.1.1",
"description": "Use Grok CLI's API endpoint in pi.",
"keywords": [
"pi-package",
"pi-extension",
"xai",
"grok",
"grok-cli",
"oauth",
"xai-oauth"
],
"type": "module",
"main": "./src/index.ts",
"files": [
"README.md",
"src",
"tsconfig.json"
],
"scripts": {
"test": "vitest run --reporter=agent",
"coverage": "vitest run --reporter=agent --coverage",
"typecheck": "tsc --noEmit",
"prepack": "bun run test && bun run coverage && bun run typecheck",
"knip": "knip --production",
"lint": "biome check --write .",
"lint:ci": "biome ci .",
"check": "bun run lint && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"check:ci": "bun run lint:ci && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"prepare": "husky",
"check-duplicates": "bunx jscpd src tests --exitCode 1 --reporters ai --noTips"
},
"author": {
"name": "J Liew",
"email": "jliew@420024lab.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/kenryu42/pi-grok-cli.git"
},
"bugs": {
"url": "https://github.com/kenryu42/pi-grok-cli/issues"
},
"homepage": "https://github.com/kenryu42/pi-grok-cli#readme",
"pi": {
"extensions": [
"./src/index.ts"
]
},
"peerDependencies": {
"@earendil-works/pi-ai": "*",
"@earendil-works/pi-coding-agent": "*"
},
"devDependencies": {
"@biomejs/biome": "2.4.16",
"@earendil-works/pi-ai": "^0.78.0",
"@earendil-works/pi-coding-agent": "^0.78.0",
"@vitest/coverage-v8": "^4.1.8",
"husky": "^9.1.7",
"jscpd": "^4.2.4",
"knip": "^6.15.0",
"lint-staged": "^17.0.7",
"release-tools": "github:kenryu42/release-tools",
"typescript": "^6.0.3",
"vitest": "^4.1.8"
},
"lint-staged": {
"*": [
"biome check --write --no-errors-on-unmatched"
]
}
"name": "pi-grok-cli",
"version": "0.1.1",
"description": "Use Grok CLI's API endpoint in pi.",
"keywords": [
"pi-package",
"pi-extension",
"xai",
"grok",
"grok-cli",
"oauth",
"xai-oauth"
],
"type": "module",
"main": "./src/index.ts",
"files": [
"README.md",
"src",
"tsconfig.json"
],
"scripts": {
"test": "vitest run --reporter=agent",
"coverage": "vitest run --reporter=agent --coverage",
"typecheck": "tsc --noEmit",
"prepack": "bun run test && bun run coverage && bun run typecheck",
"knip": "knip --production",
"lint": "biome check --write .",
"lint:ci": "biome ci .",
"check": "bun run lint && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"check:ci": "bun run lint:ci && bun run typecheck && bun run knip && bun run check-duplicates && AGENT=1 bun run coverage",
"prepare": "husky",
"check-duplicates": "bunx jscpd src tests --exitCode 1 --reporters ai --noTips"
},
"author": {
"name": "J Liew",
"email": "jliew@420024lab.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/kenryu42/pi-grok-cli.git"
},
"bugs": {
"url": "https://github.com/kenryu42/pi-grok-cli/issues"
},
"homepage": "https://github.com/kenryu42/pi-grok-cli#readme",
"pi": {
"extensions": [
"./src/index.ts"
]
},
"peerDependencies": {
"@earendil-works/pi-ai": "*",
"@earendil-works/pi-coding-agent": "*",
"@earendil-works/pi-tui": "*"
},
"devDependencies": {
"@biomejs/biome": "2.4.16",
"@earendil-works/pi-ai": "^0.78.0",
"@earendil-works/pi-coding-agent": "^0.78.0",
"@earendil-works/pi-tui": "^0.78.0",
"@vitest/coverage-v8": "^4.1.8",
"husky": "^9.1.7",
"jscpd": "^4.2.4",
"knip": "^6.15.0",
"lint-staged": "^17.0.7",
"release-tools": "github:kenryu42/release-tools",
"typescript": "^6.0.3",
"vitest": "^4.1.8"
},
"lint-staged": {
"*": [
"biome check --write --no-errors-on-unmatched"
]
}
}
Loading
Loading