grok-dev 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/worktrees/vigilant-johnson/.cursor/hooks/state/continual-learning.json +8 -0
- package/.claude/worktrees/vigilant-johnson/.cursor/rules/development-workflow.mdc +66 -0
- package/.claude/worktrees/vigilant-johnson/.cursor/rules/project-overview.mdc +66 -0
- package/.claude/worktrees/vigilant-johnson/.cursor/rules/react-ink-components.mdc +45 -0
- package/.claude/worktrees/vigilant-johnson/.cursor/rules/tools-and-agent.mdc +62 -0
- package/.claude/worktrees/vigilant-johnson/.cursor/rules/typescript-conventions.mdc +54 -0
- package/.claude/worktrees/vigilant-johnson/.husky/pre-commit +1 -0
- package/.claude/worktrees/vigilant-johnson/LICENSE +21 -0
- package/.claude/worktrees/vigilant-johnson/README.md +341 -0
- package/.claude/worktrees/vigilant-johnson/biome.json +51 -0
- package/.claude/worktrees/vigilant-johnson/package.json +74 -0
- package/.claude/worktrees/vigilant-johnson/telegram-pair-code.txt +0 -0
- package/.claude/worktrees/vigilant-johnson/vitest.config.ts +7 -0
- package/README.md +20 -2
- package/dist/agent/agent.d.ts +9 -1
- package/dist/agent/agent.js +704 -18
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/batch-mode.test.d.ts +1 -0
- package/dist/agent/batch-mode.test.js.map +1 -0
- package/dist/agent/delegations.d.ts +2 -0
- package/dist/agent/delegations.js +9 -1
- package/dist/agent/delegations.js.map +1 -1
- package/dist/agent/delegations.test.js.map +1 -1
- package/dist/grok/batch.d.ts +136 -0
- package/dist/grok/batch.js +204 -0
- package/dist/grok/batch.js.map +1 -0
- package/dist/grok/batch.test.d.ts +1 -0
- package/dist/grok/batch.test.js.map +1 -0
- package/dist/grok/tool-schemas.d.ts +3 -0
- package/dist/grok/tool-schemas.js +24 -0
- package/dist/grok/tool-schemas.js.map +1 -0
- package/dist/grok/tool-schemas.test.d.ts +1 -0
- package/dist/grok/tool-schemas.test.js.map +1 -0
- package/dist/grok/tools.js +3 -3
- package/dist/grok/tools.js.map +1 -1
- package/dist/grok/tools.test.js.map +1 -1
- package/dist/headless/output.d.ts +1 -0
- package/dist/headless/output.js +29 -4
- package/dist/headless/output.js.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/dist/tools/bash.d.ts +3 -1
- package/dist/tools/bash.js +101 -12
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/bash.test.js.map +1 -1
- package/dist/types/index.d.ts +18 -1
- package/dist/types/index.js.map +1 -1
- package/dist/ui/app.js +14 -0
- package/dist/ui/app.js.map +1 -1
- package/dist/utils/settings.d.ts +6 -0
- package/dist/utils/settings.js +9 -1
- package/dist/utils/settings.js.map +1 -1
- package/dist/utils/skills.d.ts +3 -2
- package/dist/utils/skills.js +27 -7
- package/dist/utils/skills.js.map +1 -1
- package/dist/utils/skills.test.d.ts +1 -0
- package/dist/utils/skills.test.js.map +1 -0
- package/dist/utils/subagents-settings.test.js.map +1 -1
- package/dist/verify/checkpoint.d.ts +11 -0
- package/dist/verify/checkpoint.js +158 -0
- package/dist/verify/checkpoint.js.map +1 -0
- package/dist/verify/checkpoint.test.d.ts +1 -0
- package/dist/verify/checkpoint.test.js.map +1 -0
- package/dist/verify/entrypoint.d.ts +34 -0
- package/dist/verify/entrypoint.js +642 -0
- package/dist/verify/entrypoint.js.map +1 -0
- package/dist/verify/entrypoint.test.d.ts +1 -0
- package/dist/verify/entrypoint.test.js.map +1 -0
- package/package.json +2 -1
- package/tmp/.grok/verify-artifacts/screenshot-1774806349456.png +0 -0
- package/tmp/.grok/verify-artifacts/verify-smoke.webm +0 -0
- package/tmp/README.md +36 -0
- package/tmp/eslint.config.mjs +18 -0
- package/tmp/next.config.ts +7 -0
- package/tmp/package.json +34 -0
- package/tmp/postcss.config.mjs +7 -0
- package/tmp/public/file.svg +1 -0
- package/tmp/public/globe.svg +1 -0
- package/tmp/public/next.svg +1 -0
- package/tmp/public/vercel.svg +1 -0
- package/tmp/public/window.svg +1 -0
- package/tmp/large_class.py +0 -633
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Development workflow and common commands
|
|
3
|
+
globs: "**/*"
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Development Workflow
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Bun 1.0+ (required)
|
|
12
|
+
|
|
13
|
+
## Common Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install dependencies
|
|
17
|
+
bun install
|
|
18
|
+
|
|
19
|
+
# Development (runs from source with Bun)
|
|
20
|
+
bun run dev
|
|
21
|
+
|
|
22
|
+
# Build (compile TypeScript to dist/)
|
|
23
|
+
bun run build
|
|
24
|
+
|
|
25
|
+
# Type checking (no emit)
|
|
26
|
+
bun run typecheck
|
|
27
|
+
|
|
28
|
+
# Linting
|
|
29
|
+
bun run lint
|
|
30
|
+
|
|
31
|
+
# Format (check / write)
|
|
32
|
+
bun run format
|
|
33
|
+
bun run format:fix
|
|
34
|
+
|
|
35
|
+
# Run the built CLI
|
|
36
|
+
bun run start
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Environment Variables
|
|
40
|
+
|
|
41
|
+
| Variable | Required | Description |
|
|
42
|
+
|----|----|----|
|
|
43
|
+
| `GROK_API_KEY` | Yes | API key for xAI Grok |
|
|
44
|
+
| `GROK_BASE_URL` | No | Custom API endpoint (default: `https://api.x.ai/v1`) |
|
|
45
|
+
| `GROK_MODEL` | No | Model override (default: `grok-4-1-fast`) |
|
|
46
|
+
| `GROK_MAX_TOKENS` | No | Max tokens per response (default: 16384) |
|
|
47
|
+
|
|
48
|
+
Copy `.env.example` to `.env` and fill in your values.
|
|
49
|
+
|
|
50
|
+
## Git hooks
|
|
51
|
+
|
|
52
|
+
After `bun install`, **Husky** installs a **pre-commit** hook that runs **`lint-staged`**: Biome **format + lint** (`check --write`) on staged `*.{ts,tsx,js,mjs,cjs,json}` files. Fixes are written to disk and re-staged automatically when possible.
|
|
53
|
+
|
|
54
|
+
## Before Submitting Changes
|
|
55
|
+
|
|
56
|
+
1. Run `bun run typecheck` — CI enforces this on every PR.
|
|
57
|
+
2. Run `bun run lint` — fix any Biome issues (or let pre-commit apply safe fixes).
|
|
58
|
+
3. Ensure no secrets or `.env` files are committed.
|
|
59
|
+
4. Follow the PR template in `.github/pull_request_template.md`.
|
|
60
|
+
|
|
61
|
+
## Project Structure Conventions
|
|
62
|
+
|
|
63
|
+
- Source code lives in `src/`, compiled output in `dist/` (gitignored).
|
|
64
|
+
- The CLI entry point is `src/index.ts` which uses Commander.js for argument parsing.
|
|
65
|
+
- UI is built with OpenTUI React (`@opentui/react`).
|
|
66
|
+
- Only tool is bash — all file operations happen through shell commands.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Project overview and architecture reference
|
|
3
|
+
globs: "**/*"
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Grok CLI — Project Overview
|
|
8
|
+
|
|
9
|
+
Grok CLI (`@vibe-kit/grok-cli`) is an open-source AI coding agent powered by Grok that brings AI assistance directly into the terminal.
|
|
10
|
+
|
|
11
|
+
## Tech Stack
|
|
12
|
+
|
|
13
|
+
- **Language**: TypeScript (ES2022, ESNext modules)
|
|
14
|
+
- **Runtime**: Bun (primary)
|
|
15
|
+
- **UI Framework**: React with [OpenTUI](https://github.com/anomalyco/opentui) for terminal rendering
|
|
16
|
+
- **Build**: `tsc` (TypeScript compiler)
|
|
17
|
+
- **Package Manager**: Bun
|
|
18
|
+
- **API Client**: OpenAI SDK (for OpenAI-compatible xAI API)
|
|
19
|
+
- **Tools**: Bash-only (all file operations via shell commands)
|
|
20
|
+
- **Search**: X Search API + Web Search via xAI Responses API
|
|
21
|
+
|
|
22
|
+
## Architecture
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
src/
|
|
26
|
+
├── index.ts # CLI entry point (Commander.js + OpenTUI)
|
|
27
|
+
├── agent/
|
|
28
|
+
│ └── agent.ts # Agent — orchestrates client, bash tool, search
|
|
29
|
+
├── grok/
|
|
30
|
+
│ ├── client.ts # Grok API client (Chat Completions + Responses API)
|
|
31
|
+
│ ├── models.ts # Model definitions and metadata
|
|
32
|
+
│ └── tools.ts # Tool schemas (bash, search_web, search_x)
|
|
33
|
+
├── tools/
|
|
34
|
+
│ └── bash.ts # Bash command execution
|
|
35
|
+
├── ui/
|
|
36
|
+
│ └── app.tsx # OpenTUI React terminal UI
|
|
37
|
+
├── utils/
|
|
38
|
+
│ ├── settings.ts # User and project settings
|
|
39
|
+
│ ├── git-root.ts # Resolve git repository root for AGENTS.md discovery
|
|
40
|
+
│ └── instructions.ts # AGENTS.md (ecosystem) custom instructions
|
|
41
|
+
└── types/
|
|
42
|
+
└── index.ts # Shared TypeScript types
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Key Patterns
|
|
46
|
+
|
|
47
|
+
- **Agent loop**: `Agent.processMessage()` is an async generator that yields `StreamChunk` objects — the LLM responds, tools execute, results feed back until no more tool calls remain.
|
|
48
|
+
- **Bash-only tools**: The agent uses bash for everything (file editing, searching, git, builds, etc.).
|
|
49
|
+
- **X Search & Web Search**: Integrated via the xAI Responses API for real-time information.
|
|
50
|
+
- **Settings hierarchy**: Environment variables → User-level (`~/.grok/user-settings.json`) → Project-level (`.grok/settings.json`).
|
|
51
|
+
- **Custom instructions**: `~/.grok/AGENTS.md`, then `AGENTS.override.md` / `AGENTS.md` per directory from git root through the workspace cwd (Codex-style merge).
|
|
52
|
+
- **ESM only**: The project uses `"type": "module"` — all imports use `.js` extensions for compiled output.
|
|
53
|
+
|
|
54
|
+
## Latest Grok Models
|
|
55
|
+
|
|
56
|
+
- grok-4-0709 (flagship reasoning)
|
|
57
|
+
- grok-4.20-beta-0309 (multi-agent, 2M context)
|
|
58
|
+
- grok-4-fast (fast reasoning, 2M context)
|
|
59
|
+
- grok-4-1-fast (latest fast, 2M context)
|
|
60
|
+
- grok-code-fast-1 (code optimized)
|
|
61
|
+
- grok-3, grok-3-mini
|
|
62
|
+
|
|
63
|
+
## CI/CD
|
|
64
|
+
|
|
65
|
+
- **typecheck.yml**: Runs `tsc --noEmit` on push/PR to `main`/`develop`.
|
|
66
|
+
- **security.yml**: Runs `npm audit` and TruffleHog secret scanning.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Guidelines for React components using Ink for terminal UI
|
|
3
|
+
globs: "src/ui/**/*.tsx,src/hooks/**/*.ts"
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# React + Ink Terminal UI
|
|
8
|
+
|
|
9
|
+
## Framework
|
|
10
|
+
|
|
11
|
+
This project uses [Ink](https://github.com/vadimdemedes/ink) v4 to render React components in the terminal. Ink provides `<Box>`, `<Text>`, and other primitives instead of HTML elements.
|
|
12
|
+
|
|
13
|
+
## Component Patterns
|
|
14
|
+
|
|
15
|
+
- Use **functional components** with hooks — no class components.
|
|
16
|
+
- JSX is compiled with `"jsx": "react"` (classic transform), so `import React from "react"` is required in every `.tsx` file.
|
|
17
|
+
- Components are in `src/ui/components/` and follow kebab-case naming (`chat-interface.tsx`, `diff-renderer.tsx`).
|
|
18
|
+
|
|
19
|
+
## Key Components
|
|
20
|
+
|
|
21
|
+
| Component | Purpose |
|
|
22
|
+
|-----------|---------|
|
|
23
|
+
| `ChatInterface` | Main chat loop, orchestrates agent interaction |
|
|
24
|
+
| `ChatHistory` | Renders conversation entries |
|
|
25
|
+
| `ChatInput` | User text input with key bindings |
|
|
26
|
+
| `DiffRenderer` | Displays file diffs |
|
|
27
|
+
| `ModelSelection` | Model picker UI |
|
|
28
|
+
| `LoadingSpinner` | Animated loading indicator |
|
|
29
|
+
| `ConfirmationDialog` | User confirmation prompts for tool operations |
|
|
30
|
+
| `McpStatus` | MCP server connection status |
|
|
31
|
+
| `CommandSuggestions` | Autocomplete suggestions |
|
|
32
|
+
| `ApiKeyInput` | API key entry prompt |
|
|
33
|
+
|
|
34
|
+
## Ink-Specific Guidelines
|
|
35
|
+
|
|
36
|
+
- Use `<Box>` for layout (flexbox model) and `<Text>` for styled text.
|
|
37
|
+
- Use Ink's `useInput` hook for keyboard handling.
|
|
38
|
+
- Use `chalk` for color utilities in `src/ui/utils/colors.ts`.
|
|
39
|
+
- Markdown rendering for chat output uses `marked` + `marked-terminal`.
|
|
40
|
+
- The app is rendered via `render(React.createElement(ChatInterface, { agent, initialMessage }))` in the entry point.
|
|
41
|
+
|
|
42
|
+
## Hooks
|
|
43
|
+
|
|
44
|
+
- Custom hooks live in `src/hooks/`.
|
|
45
|
+
- Follow the `use` prefix convention (`useInput`, `useChat`, etc.).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Guidelines for the agent system and tool implementations
|
|
3
|
+
globs: "src/agent/**/*.ts,src/tools/**/*.ts,src/grok/**/*.ts"
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Agent & Tools System
|
|
8
|
+
|
|
9
|
+
## Agent
|
|
10
|
+
|
|
11
|
+
`Agent` (in `src/agent/agent.ts`) is the core orchestrator. It manages:
|
|
12
|
+
|
|
13
|
+
- The Grok API client (`GrokClient`)
|
|
14
|
+
- Bash tool for all shell operations
|
|
15
|
+
- Web search and X search via the Responses API
|
|
16
|
+
- Chat history and message accumulation
|
|
17
|
+
- Abort/cancellation support
|
|
18
|
+
|
|
19
|
+
### Agent Loop
|
|
20
|
+
|
|
21
|
+
The agent uses an iterative tool-call pattern via `processMessage` (async generator):
|
|
22
|
+
|
|
23
|
+
1. Send messages to the LLM via Chat Completions API (streaming).
|
|
24
|
+
2. If the response contains `tool_calls`, execute each tool.
|
|
25
|
+
3. Append tool results to the message history.
|
|
26
|
+
4. Repeat until no tool calls remain or `maxToolRounds` is reached.
|
|
27
|
+
5. Yield `StreamChunk` objects for real-time UI updates.
|
|
28
|
+
|
|
29
|
+
## Tool Interface
|
|
30
|
+
|
|
31
|
+
All tools return a `ToolResult`:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
interface ToolResult {
|
|
35
|
+
success: boolean;
|
|
36
|
+
output?: string;
|
|
37
|
+
error?: string;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Tools should never throw — wrap errors in `{ success: false, error: "..." }`.
|
|
42
|
+
|
|
43
|
+
## Built-in Tools
|
|
44
|
+
|
|
45
|
+
| Tool | File | Purpose |
|
|
46
|
+
|------|------|---------|
|
|
47
|
+
| `BashTool` | `src/tools/bash.ts` | Execute any shell command |
|
|
48
|
+
| `search_web` | via `GrokClient.searchWeb()` | Web search using Responses API |
|
|
49
|
+
| `search_x` | via `GrokClient.searchX()` | X/Twitter search using Responses API |
|
|
50
|
+
|
|
51
|
+
## Grok Client
|
|
52
|
+
|
|
53
|
+
`GrokClient` (in `src/grok/client.ts`) handles two API endpoints:
|
|
54
|
+
|
|
55
|
+
- **Chat Completions** (`/v1/chat/completions`): Main agent loop with streaming and tool calling
|
|
56
|
+
- **Responses API** (`/v1/responses`): X Search and Web Search with server-side tools
|
|
57
|
+
|
|
58
|
+
## Adding a New Tool
|
|
59
|
+
|
|
60
|
+
1. Add the tool schema to `src/grok/tools.ts` (in the `TOOLS` array).
|
|
61
|
+
2. Add the execution case in `Agent.executeTool()`.
|
|
62
|
+
3. Update the system prompt in `Agent` to document the tool.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: TypeScript coding conventions and style guidelines
|
|
3
|
+
globs: "**/*.ts,**/*.tsx"
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TypeScript Conventions
|
|
8
|
+
|
|
9
|
+
## Module System
|
|
10
|
+
|
|
11
|
+
- This is an ESM project (`"type": "module"` in package.json).
|
|
12
|
+
- Always use ES module `import`/`export` syntax — never `require()`.
|
|
13
|
+
- When importing local modules, include the `.js` extension (TypeScript compiles `.ts` → `.js`):
|
|
14
|
+
```typescript
|
|
15
|
+
import { GrokAgent } from "./agent/grok-agent.js";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## TypeScript Configuration
|
|
19
|
+
|
|
20
|
+
- Target: ES2022, Module: ESNext, JSX: react
|
|
21
|
+
- `strict: false` and `noImplicitAny: false` — the codebase does not enforce strict mode.
|
|
22
|
+
- `moduleResolution: "Bundler"` is used.
|
|
23
|
+
- Source files live in `src/`, compiled output goes to `dist/`.
|
|
24
|
+
|
|
25
|
+
## Type Practices
|
|
26
|
+
|
|
27
|
+
- Prefer explicit interfaces for public API boundaries (e.g. `ChatEntry`, `ToolResult`, `GrokToolCall`).
|
|
28
|
+
- Use `type` imports when importing only types:
|
|
29
|
+
```typescript
|
|
30
|
+
import type { ChatCompletionMessageParam } from "openai/resources/chat";
|
|
31
|
+
```
|
|
32
|
+
- `any` is acceptable where strict typing would add friction, but prefer narrower types when practical.
|
|
33
|
+
- Shared types belong in `src/types/index.ts`.
|
|
34
|
+
|
|
35
|
+
## Naming Conventions
|
|
36
|
+
|
|
37
|
+
- **Files**: kebab-case (`grok-agent.ts`, `chat-interface.tsx`, `settings-manager.ts`).
|
|
38
|
+
- **Classes**: PascalCase (`GrokAgent`, `TextEditorTool`, `BashTool`).
|
|
39
|
+
- **Interfaces/Types**: PascalCase (`ChatEntry`, `ToolResult`, `StreamingChunk`).
|
|
40
|
+
- **Functions/variables**: camelCase (`processUserMessage`, `loadApiKey`).
|
|
41
|
+
- **Constants**: camelCase or UPPER_SNAKE_CASE for true constants (`GROK_TOOLS`).
|
|
42
|
+
|
|
43
|
+
## Error Handling
|
|
44
|
+
|
|
45
|
+
- Catch errors as `error: any` and access `.message` for display.
|
|
46
|
+
- Tool execution methods return `ToolResult` objects (`{ success, output?, error? }`) rather than throwing.
|
|
47
|
+
- Use `process.exit(1)` for fatal CLI errors.
|
|
48
|
+
|
|
49
|
+
## ESLint Rules
|
|
50
|
+
|
|
51
|
+
- `@typescript-eslint/no-unused-vars`: error
|
|
52
|
+
- `@typescript-eslint/no-explicit-any`: warn
|
|
53
|
+
|
|
54
|
+
Run `bun run lint` to check and `bun run typecheck` to verify types.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bun run pre-commit
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [copyright holders]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission statement shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# There are many coding agents. **This is Grok’s.**
|
|
2
|
+
|
|
3
|
+
[](https://github.com/superagent-ai/grok-cli/actions/workflows/typecheck.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/grok-dev)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://bun.sh/)
|
|
8
|
+
|
|
9
|
+
The rest borrowed from each other. We borrowed from *all of them*, then wired it to **Grok**—real-time **X search**, **web search**, **`grok-code-fast-1`** and the full Grok model lineup, **sub-agents on by default**, **remote control via Telegram** (pair once, drive the agent from your phone while the CLI runs), and a terminal UI that doesn’t feel like it was assembled in a hurry.
|
|
10
|
+
|
|
11
|
+
Open source. Terminal-native. Built with **Bun** and **OpenTUI**. If you want vibes *and* velocity, you’re in the right repo.
|
|
12
|
+
|
|
13
|
+
Community-built and unofficial. This project is not affiliated with or endorsed by xAI, and it is not the official Grok CLI.
|
|
14
|
+
|
|
15
|
+
https://github.com/user-attachments/assets/7ca4f6df-50ca-4e9c-91b2-d4abad5c66cb
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm i -g grok-dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The CLI binary is **`grok`** (yes, the package name and the command differ—deal with it).
|
|
26
|
+
|
|
27
|
+
**Prerequisites:** Node 18+ (for the global install), a **Grok API key** from [x.ai](https://x.ai), and a modern terminal emulator for the interactive OpenTUI experience. Headless `--prompt` mode does not depend on terminal UI support.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Run it
|
|
32
|
+
|
|
33
|
+
**Interactive (default)** — launches the OpenTUI coding agent:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
grok
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Supported terminals
|
|
40
|
+
|
|
41
|
+
For the most reliable interactive OpenTUI experience, use a modern terminal emulator. We currently document and recommend:
|
|
42
|
+
|
|
43
|
+
- **WezTerm** (cross-platform)
|
|
44
|
+
- **Alacritty** (cross-platform)
|
|
45
|
+
- **Ghostty** (macOS and Linux)
|
|
46
|
+
- **Kitty** (macOS and Linux)
|
|
47
|
+
|
|
48
|
+
Other modern terminals may work, but these are the terminal apps we currently recommend and document for interactive use.
|
|
49
|
+
|
|
50
|
+
**Pick a project directory:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
grok -d /path/to/your/repo
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Headless** — one prompt, then exit (scripts, CI, automation):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
grok --prompt "run the test suite and summarize failures"
|
|
60
|
+
grok -p "show me package.json" --directory /path/to/project
|
|
61
|
+
grok --prompt "refactor X" --max-tool-rounds 30
|
|
62
|
+
grok --prompt "summarize the repo state" --format json
|
|
63
|
+
grok --verify
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Continue a saved session:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
grok --session latest
|
|
70
|
+
grok -s <session-id>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Works in interactive mode too—same flag.
|
|
74
|
+
|
|
75
|
+
**Structured headless output:**
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
grok --prompt "summarize the repo state" --format json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`--format json` emits a newline-delimited JSON event stream instead of the
|
|
82
|
+
default human-readable text output. Events are semantic, step-level records such
|
|
83
|
+
as `step_start`, `text`, `tool_use`, `step_finish`, and `error`.
|
|
84
|
+
|
|
85
|
+
### Scheduling
|
|
86
|
+
|
|
87
|
+
Schedules let Grok run a headless prompt on a recurring schedule or once. Ask
|
|
88
|
+
for it in natural language, for example:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
Create a schedule named daily-changelog-update that runs every weekday at 9am
|
|
92
|
+
and updates CHANGELOG.md from the latest merged commits.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Recurring schedules require the background daemon:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
grok daemon --background
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Use `/schedule` in the TUI to browse saved schedules. One-time schedules start
|
|
102
|
+
immediately in the background; recurring schedules keep running as long as the
|
|
103
|
+
daemon is active.
|
|
104
|
+
|
|
105
|
+
**List Grok models and pricing hints:**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
grok models
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Pass an opening message without another prompt:**
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
grok fix the flaky test in src/foo.test.ts
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Generate images or short videos from chat:**
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
grok "Generate a retro-futuristic logo for my CLI called Grok Forge"
|
|
121
|
+
grok "Edit ./assets/hero.png into a watercolor poster"
|
|
122
|
+
grok "Animate ./assets/cover.jpg into a 6 second cinematic push-in"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Image and video generation are exposed as agent tools inside normal chat sessions.
|
|
126
|
+
You keep using a text model for the session, and Grok saves generated media under
|
|
127
|
+
`.grok/generated-media/` by default unless you ask for a specific output path.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## What you actually get
|
|
132
|
+
|
|
133
|
+
| Thing | What it means |
|
|
134
|
+
|--------|----------------|
|
|
135
|
+
| **Grok-native** | Defaults tuned for Grok; models like **`grok-code-fast-1`**, **`grok-4-1-fast-reasoning`**, **`grok-4.20-multi-agent-0309`**, plus flagship and fast variants—run `grok models` for the full menu. |
|
|
136
|
+
| **X + web search** | **`search_x`** and **`search_web`** tools—live posts and docs without pretending the internet stopped in 2023. |
|
|
137
|
+
| **Media generation** | Built-in **`generate_image`** and **`generate_video`** tools for text-to-image, image editing, text-to-video, and image-to-video flows. Generated files are saved locally so you can reuse them after the xAI URLs expire. |
|
|
138
|
+
| **Sub-agents (default behavior)** | Foreground **`task`** delegation (e.g. explore vs general) plus background **`delegate`** for read-only deep dives—parallelize like you mean it. |
|
|
139
|
+
| **Verify** | **`/verify`** or **`--verify`** — inspects your app, builds, tests, boots it, and runs browser smoke checks in a sandboxed environment. Screenshots and video included. |
|
|
140
|
+
| **Custom sub-agents** | Define named agents with **`subAgents`** in **`~/.grok/user-settings.json`** and manage them from the TUI with **`/agents`**. |
|
|
141
|
+
| **Remote control** | Pair **Telegram** from the TUI (`/remote-control` → Telegram): DM your bot, **`/pair`**, approve the code in-terminal. Keep the CLI running while you ping it from your phone. |
|
|
142
|
+
| **No “mystery meat” UI** | OpenTUI React terminal UI—fast, keyboard-driven, not whatever glitchy thing you’re thinking of. |
|
|
143
|
+
| **Skills** | Agent Skills under **`.agents/skills/<name>/SKILL.md`** (project) or **`~/.agents/skills/`** (user). Use **`/skills`** in the TUI to list what’s installed. |
|
|
144
|
+
| **MCPs** | Extend with Model Context Protocol servers—configure via **`/mcps`** in the TUI or **`.grok/settings.json`** (`mcpServers`). |
|
|
145
|
+
| **Sessions** | Conversations persist; **`--session latest`** picks up where you left off. |
|
|
146
|
+
| **Headless** | **`--prompt`** / **`-p`** for non-interactive runs—pipe it, script it, bench it. |
|
|
147
|
+
| **Hackable** | TypeScript, clear agent loop, bash-first tools—fork it, shamelessly. |
|
|
148
|
+
|
|
149
|
+
### Coming soon
|
|
150
|
+
|
|
151
|
+
**Deeper autonomous agent testing** — persistent sandbox sessions, richer browser workflows, and stronger "prove it works" evidence.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## API key (pick one)
|
|
156
|
+
|
|
157
|
+
**Environment (good for CI):**
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
export GROK_API_KEY=your_key_here
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**`.env`** in the project (see `.env.example` if present):
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
GROK_API_KEY=your_key_here
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**CLI once:**
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
grok -k your_key_here
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Saved in user settings** — `~/.grok/user-settings.json`:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{ "apiKey": "your_key_here" }
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Optional **`subAgents`** — custom foreground sub-agents. Each entry needs **`name`**, **`model`**, and **`instruction`**:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"subAgents": [
|
|
186
|
+
{
|
|
187
|
+
"name": "security-review",
|
|
188
|
+
"model": "grok-code-fast-1",
|
|
189
|
+
"instruction": "Prioritize security implications and suggest concrete fixes."
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Names cannot be `general`, `explore`, `vision`, or `verify` because those are reserved for the built-in sub-agents.
|
|
196
|
+
|
|
197
|
+
Optional: **`GROK_BASE_URL`** (default `https://api.x.ai/v1`), **`GROK_MODEL`**, **`GROK_MAX_TOKENS`**.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Telegram (remote control) — short version
|
|
202
|
+
|
|
203
|
+
1. Create a bot with [@BotFather](https://t.me/BotFather), copy the token.
|
|
204
|
+
2. Set **`TELEGRAM_BOT_TOKEN`** or add **`telegram.botToken`** in `~/.grok/user-settings.json` (the TUI **`/remote-control`** flow can save it).
|
|
205
|
+
3. Start **`grok`**, open **`/remote-control`** → **Telegram** if needed, then in Telegram DM your bot: **`/pair`**, enter the **6-character code** in the terminal when asked.
|
|
206
|
+
4. First user must be approved once; after that, it’s remembered. **Keep the CLI process running** while you use the bot (long polling lives in that process).
|
|
207
|
+
|
|
208
|
+
### Voice & audio messages
|
|
209
|
+
|
|
210
|
+
Send a voice note or audio attachment in Telegram and Grok will transcribe it locally with **[whisper.cpp](https://github.com/ggml-org/whisper.cpp)** before passing the text to the agent. No cloud STT service is involved — everything runs on your machine.
|
|
211
|
+
|
|
212
|
+
#### Prerequisites
|
|
213
|
+
|
|
214
|
+
| Dependency | Why | Install (macOS) |
|
|
215
|
+
|---|---|---|
|
|
216
|
+
| **whisper-cli** | Runs the actual speech-to-text inference | `brew install whisper-cpp` |
|
|
217
|
+
| **ffmpeg** | Converts Telegram voice notes (OGG/Opus) to WAV for whisper.cpp | `brew install ffmpeg` |
|
|
218
|
+
|
|
219
|
+
After installing, verify both are available:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
whisper-cli -h
|
|
223
|
+
ffmpeg -version
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### Download a Whisper model
|
|
227
|
+
|
|
228
|
+
Grok CLI auto-downloads the configured model on first use, but you can pre-download it:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
mkdir -p ~/.grok/models/stt/whisper.cpp
|
|
232
|
+
curl -L https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin \
|
|
233
|
+
-o ~/.grok/models/stt/whisper.cpp/ggml-tiny.en.bin
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Available models (trade size for accuracy): `tiny.en` (75 MB), `base.en` (142 MB), `small.en` (466 MB).
|
|
237
|
+
|
|
238
|
+
#### Configure in `~/.grok/user-settings.json`
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"telegram": {
|
|
243
|
+
"botToken": "YOUR_BOT_TOKEN",
|
|
244
|
+
"audioInput": {
|
|
245
|
+
"enabled": true,
|
|
246
|
+
"binaryPath": "/opt/homebrew/bin/whisper-cli",
|
|
247
|
+
"model": "tiny.en",
|
|
248
|
+
"modelPath": "~/.grok/models/stt/whisper.cpp/ggml-tiny.en.bin",
|
|
249
|
+
"autoDownloadModel": true,
|
|
250
|
+
"language": "en"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
| Setting | Default | Description |
|
|
257
|
+
|---|---|---|
|
|
258
|
+
| `enabled` | `true` | Set to `false` to ignore voice/audio messages entirely. |
|
|
259
|
+
| `binaryPath` | `whisper-cli` | Absolute path or command name for the whisper.cpp CLI binary. |
|
|
260
|
+
| `model` | `tiny.en` | Model alias used for auto-download resolution. |
|
|
261
|
+
| `modelPath` | _(auto-resolved)_ | Explicit path to a `.bin` model file. Overrides `model` + auto-download. |
|
|
262
|
+
| `autoDownloadModel` | `true` | Download the model into `~/.grok/models/stt/whisper.cpp` on first use. |
|
|
263
|
+
| `language` | `en` | Whisper language code passed to the CLI. |
|
|
264
|
+
|
|
265
|
+
Optional headless flow when you do not want the TUI open:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
grok telegram-bridge
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Treat the bot token like a password.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Instructions & project brain
|
|
276
|
+
|
|
277
|
+
- **`AGENTS.md`** — merged from git root down to your cwd (Codex-style; see repo docs). **`AGENTS.override.md`** wins per directory when present.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Project settings
|
|
282
|
+
|
|
283
|
+
Project file: **`.grok/settings.json`** — e.g. the current model for this project.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Sandbox
|
|
288
|
+
|
|
289
|
+
Grok CLI can run shell commands inside a [Shuru](https://github.com/superhq-ai/shuru) microVM sandbox so the agent can't touch your host filesystem or network.
|
|
290
|
+
|
|
291
|
+
**Requires macOS 14+ on Apple Silicon.**
|
|
292
|
+
|
|
293
|
+
Enable it with `--sandbox` on the CLI, or toggle it from the TUI with `/sandbox`.
|
|
294
|
+
|
|
295
|
+
When sandbox mode is active you can configure:
|
|
296
|
+
|
|
297
|
+
- **Network** — off by default; enable with `--allow-net`, restrict with `--allow-host`
|
|
298
|
+
- **Port forwards** — `--port 8080:80`
|
|
299
|
+
- **Resource limits** — CPUs, memory, disk size (via settings or `/sandbox` panel)
|
|
300
|
+
- **Checkpoints** — start from a saved environment snapshot
|
|
301
|
+
- **Secrets** — inject API keys without exposing them inside the VM
|
|
302
|
+
|
|
303
|
+
All settings are saved in `~/.grok/user-settings.json` (user) and `.grok/settings.json` (project).
|
|
304
|
+
|
|
305
|
+
### Verify
|
|
306
|
+
|
|
307
|
+
Run **`/verify`** in the TUI or **`--verify`** on the CLI to verify your app locally:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
grok --verify
|
|
311
|
+
grok -d /path/to/your/app --verify
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The agent inspects your project, figures out how to build and run it, spins up a sandbox, and produces a verification report with screenshots and video evidence. Works with any app type.
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Development
|
|
319
|
+
|
|
320
|
+
From a clone:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
bun install
|
|
324
|
+
bun run build
|
|
325
|
+
bun run start
|
|
326
|
+
# or: node dist/index.js
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Other useful commands:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
bun run dev # run from source (Bun)
|
|
333
|
+
bun run typecheck
|
|
334
|
+
bun run lint
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## License
|
|
340
|
+
|
|
341
|
+
MIT
|