@xagent/x-cli 1.1.36

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/README.md ADDED
@@ -0,0 +1,942 @@
1
+ ## 1.1.36 โ€“ Repository Migration Complete
2
+
3
+ This release includes latest updates and automated publishing via GitHub Actions.
4
+
5
+ - Fixes all Read/Update tool reliability issues
6
+ - Ensures consistent FS imports (`node:` namespace)
7
+ - Adds proper Node shebang for global installs
8
+ - Temporarily removes experimental features (e.g. compress)
9
+
10
+ ---
11
+
12
+ # X CLI
13
+
14
+ [![NPM Version](https://img.shields.io/npm/v/@xagent/x-cli?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/@xagent/x-cli)
15
+ [![GitHub Release](https://img.shields.io/github/v/release/hinetapora/x-cli-hurry-mode?style=for-the-badge&logo=github&color=181717)](https://github.com/x-cli-team/x-cli/releases)
16
+ [![Downloads](https://img.shields.io/npm/dm/@xagent/x-cli?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/@xagent/x-cli)
17
+ [![License](https://img.shields.io/github/license/hinetapora/x-cli-hurry-mode?style=for-the-badge&color=green)](https://github.com/x-cli-team/x-cli/blob/main/LICENSE)
18
+ [![Discord](https://img.shields.io/badge/Discord-xAI_Community-5865F2?style=for-the-badge&logo=discord)](https://discord.com/channels/1315720379607679066/1315822328139223064)
19
+
20
+ A conversational AI CLI tool powered by Grok with **Claude Code-level intelligence** and advanced tool capabilities.
21
+
22
+ <div align="center">
23
+ <img src="docs/grok-welcome.png" alt="X CLI" width="600" />
24
+ </div>
25
+
26
+ ## ๐Ÿ”— Quick Links
27
+
28
+ - **๐Ÿ“ฆ [NPM Package](https://www.npmjs.com/package/@xagent/x-cli)** - Install globally with `npm install -g @xagent/x-cli`
29
+ - **๐Ÿ™ [GitHub Repository](https://github.com/x-cli-team/x-cli)** - Source code, issues, and contributions
30
+ - **๐ŸŽฏ [Competitive Parity Analysis](./.agent/parity/)** - Strategic analysis vs Claude Code, Cursor IDE, and OpenAI Codex
31
+ - **๐Ÿ’ฌ [xAI Community Discord](https://discord.com/channels/1315720379607679066/1315822328139223064)** - Official xAI API community support
32
+ - **๐Ÿ“š [Releases](https://github.com/x-cli-team/x-cli/releases)** - Version history and changelogs
33
+
34
+ ## ๐Ÿ†• What's New in v1.0+
35
+
36
+ ### ๐ŸŽฏ **P0: Plan Mode - Claude Code Parity** (Latest)
37
+
38
+ - **๐ŸŽฏ Shift+Tab Twice Activation**: Exact Claude Code Plan Mode with read-only exploration
39
+ - **๐Ÿ” Comprehensive Codebase Analysis**: Project structure, dependencies, complexity metrics, and architecture patterns
40
+ - **๐Ÿง  AI-Powered Implementation Planning**: Strategic plan generation using Grok models with risk assessment
41
+ - **๐Ÿ›ก๏ธ Read-Only Tool Execution**: Safe exploration with destructive operation blocking and simulation
42
+ - **๐Ÿ“Š Progress Visualization**: Real-time exploration and planning progress with phase-specific guidance
43
+ - **๐Ÿ“‹ User Approval Workflow**: Complete plan review and confirmation before execution
44
+ - **โšก Performance Optimized**: Fast exploration (1-15 seconds) with intelligent caching and filtering
45
+
46
+ ### ๐ŸŽจ **P4: UX Refinement - Claude Code Feel**
47
+
48
+ - **๐ŸŽญ Enhanced Welcome Banner**: Professional ASCII art with context-aware status display
49
+ - **๐ŸŒˆ Unified Color System**: Consistent Claude Code-inspired visual hierarchy across all interfaces
50
+ - **๐Ÿ”„ Contextual Spinners**: 8 operation-specific animated indicators (๐Ÿง  thinking, ๐Ÿ” search, ๐Ÿ“‚ indexing, ๐Ÿ“ write, etc.)
51
+ - **๐Ÿ“Š Progress Indicators**: Advanced progress bars with ETA calculations and breathing pulse effects
52
+ - **๐ŸŽ›๏ธ Background Activity**: Non-intrusive workspace awareness with file change monitoring
53
+ - **๐ŸŽฏ UI State Management**: Centralized coordination for all visual feedback and notifications
54
+ - **โšก Motion Design**: 120ms smooth animations with 1.5s breathing rhythm for calm, responsive feel
55
+ - **๐Ÿง  Context Tooltip**: Press `Ctrl+I` for instant workspace insights (project name, git branch, file count, session state)
56
+ - **๐Ÿ“ˆ Dynamic Status**: Real-time memory pressure, background activity, and workspace intelligence
57
+ - **๐ŸŽจ Context Awareness Surface**: Professional bordered layouts with organized information sections
58
+
59
+ ### ๐Ÿง  **P3: Code Intelligence Tools**
60
+
61
+ - **๐Ÿ” AST Parser**: Language-specific syntax tree analysis for TypeScript, JavaScript, Python
62
+ - **๐Ÿ”Ž Symbol Search**: Fuzzy search across codebases with cross-references and usage analysis
63
+ - **๐Ÿ“Š Dependency Analyzer**: Circular dependency detection and dependency graph generation
64
+ - **๐ŸŽฏ Code Context**: Semantic analysis with quality metrics and design pattern detection
65
+ - **๐Ÿ”ง Refactoring Assistant**: Safe rename, extract, inline operations with preview and rollback
66
+
67
+ ### ๐Ÿš€ **P2: Enhanced File Operations**
68
+
69
+ - **โšก Multi-File Editor**: Atomic operations with transaction support and rollback
70
+ - **๐Ÿ” Advanced Search Tool**: Regex patterns with bulk replace and context-aware results
71
+ - **๐ŸŒณ File Tree Operations**: Visual trees, bulk operations, and intelligent file organization
72
+ - **๐Ÿง  Code-Aware Editor**: Syntax-aware editing with smart refactoring capabilities
73
+ - **๐Ÿ“š Operation History**: Comprehensive undo/redo system with persistent history
74
+
75
+ **๐ŸŽฏ Result**: **Claude Code-level capabilities** with **Claude Code feel** in your terminal!
76
+
77
+ ### ๐Ÿ› ๏ธ **P1: Reliability & Workflow Enhancements**
78
+
79
+ - **๐Ÿค– .agent System**: AI-powered task management and documentation system for efficient workflows
80
+ - **๐Ÿ”ง Healer Script**: Automated issue detection and resolution for tool reliability
81
+ - **โšก FsPort Abstraction**: Improved file system operations with Node built-ins externalization
82
+ - **๐Ÿ“ฆ Automated Installer**: Enhanced installation UX with one-click setup options
83
+ - **๐Ÿ›ก๏ธ Tool Reliability Fixes**: Standardized imports, syntax error resolution, and fallback mechanisms
84
+ - **๐Ÿ“‹ Paste Text Summary**: Claude Code-style paste detection with smart summarization (`[Pasted text #1 +12 lines]`)
85
+
86
+ ## โœจ Features
87
+
88
+ ### ๐ŸŽฏ **Plan Mode - Claude Code's Signature Feature**
89
+
90
+ - **๐ŸŽฏ Shift+Tab Twice**: Activate read-only exploration mode (exact Claude Code parity)
91
+ - **๐Ÿ” Codebase Analysis**: Comprehensive project structure, dependencies, and complexity analysis
92
+ - **๐Ÿง  AI-Powered Planning**: Strategic implementation plans generated by Grok models
93
+ - **๐Ÿ›ก๏ธ Read-Only Safety**: Zero file modifications during exploration with tool simulation
94
+ - **๐Ÿ“Š Progress Tracking**: Real-time exploration progress with phase-specific guidance
95
+ - **๐Ÿ“‹ Plan Approval**: Review and approve implementation plans before execution
96
+
97
+ ### ๐Ÿง  **Claude Code-Level Intelligence**
98
+
99
+ - **๐Ÿ” AST Code Analysis**: Parse TypeScript, JavaScript, Python files to extract symbols, imports, and structure
100
+ - **๐Ÿ”Ž Symbol Search**: Fuzzy search for functions, classes, variables across entire codebases
101
+ - **๐Ÿ“Š Dependency Analysis**: Detect circular dependencies and generate dependency graphs
102
+ - **๐ŸŽฏ Code Context**: Intelligent relationship mapping with semantic analysis and quality metrics
103
+ - **๐Ÿ”ง Safe Refactoring**: Rename, extract, inline operations with preview and rollback support
104
+
105
+ ### ๐Ÿš€ **Advanced File Operations**
106
+
107
+ - **โšก MultiEdit**: Atomic operations across multiple files with transaction support
108
+ - **๐Ÿ” Grep/Glob**: Advanced search with regex patterns and file discovery
109
+ - **๐ŸŒ WebFetch/WebSearch**: Real-time web content retrieval and search capabilities
110
+ - **๐Ÿ“š Task/TodoWrite**: Specialized agent delegation and comprehensive task management
111
+ - **๐Ÿš€ Read/Write/Edit**: Claude Code-standard file operations at high speed
112
+
113
+ ๐ŸŒ **Visit [xclicli.dev](https://xclicli.dev)** for complete documentation and guides.
114
+
115
+ ### ๐Ÿค– **Core AI Capabilities**
116
+
117
+ - **๐Ÿ’ฌ Conversational Interface**: Natural language powered by Grok models
118
+ - **๐Ÿ”ง Intelligent Tool Selection**: AI automatically chooses the right tools for your requests
119
+ - **โšก Bash Integration**: Execute shell commands through natural conversation
120
+ - **๐Ÿ”Œ MCP Extension**: Extend capabilities with Model Context Protocol servers (Linear, GitHub, etc.)
121
+ - **๐Ÿ’ป Beautiful Terminal UI**: Interactive interface with Claude Code-style animations and feedback
122
+ - **๐Ÿ“‹ Smart Paste Detection**: Large pasted content automatically summarizes as `[Pasted text #1 +12 lines]` for clean chat history
123
+
124
+ ### ๐ŸŽจ **Enhanced User Experience**
125
+
126
+ - **๐ŸŽญ Professional Welcome Banner**: ASCII art with dynamic context status (`Context: Dynamic โ”‚ Files: indexed โ”‚ Session: Restored`)
127
+ - **๐Ÿ”„ Contextual Visual Feedback**: 8 operation-specific spinners with smooth 120ms animations
128
+ - **๐Ÿ“Š Progress Transparency**: Real-time progress bars with ETA calculations for long operations
129
+ - **๐ŸŽ›๏ธ Background Awareness**: Subtle workspace indexing and file watching indicators
130
+ - **๐ŸŒˆ Consistent Color Language**: Claude Code-inspired visual hierarchy (info=blue, success=green, warn=orange, error=red)
131
+ - **โšก Motion Design**: Breathing pulse effects and smooth transitions for calm, responsive interface
132
+
133
+ ### ๐Ÿ“š **Documentation System**
134
+
135
+ - **๐Ÿ—๏ธ Agent Documentation**: Complete `.agent/` system for AI context optimization
136
+ - **๐Ÿ“– Interactive Commands**: `/docs` menu, `/readme` generation, `/api-docs`, `/changelog`
137
+ - **๐Ÿ”„ Smart Updates**: `/update-agent-docs` with configurable auto-triggers
138
+ - **๐Ÿค– Subagent Framework**: Token-optimized processing with specialized agents
139
+ - **๐Ÿ›ก๏ธ Self-Healing**: `/heal` command captures incidents and generates guardrails
140
+ - **๐Ÿ“ Code Comments**: `/comments` command for automatic code documentation
141
+
142
+ ### ๐ŸŒ **Installation & Setup**
143
+
144
+ - **๐Ÿ“ฆ Global Installation**: Install anywhere with `npm install -g @xagent/x-cli`
145
+ - **โš™๏ธ Flexible Configuration**: Environment variables, user settings, or project-specific configs
146
+ - **๐Ÿ”„ CI/CD Ready**: Headless mode perfect for automation and scripting
147
+
148
+ ## Installation
149
+
150
+ ### Prerequisites
151
+
152
+ - Node.js 18+ (Node.js 20+ recommended)
153
+
154
+ ### ๐Ÿš€ Quick Start
155
+
156
+ **Option 1: Run without installing (Recommended)**
157
+
158
+ ```bash
159
+ npx -y @xagent/x-cli@latest
160
+ ```
161
+
162
+ _Always gets the latest version, no local installation needed_
163
+
164
+ **Option 2: Global installation**
165
+
166
+ ```bash
167
+ npm install -g @xagent/x-cli@latest
168
+ ```
169
+
170
+ **Option 3: Alternative package managers**
171
+
172
+ ```bash
173
+ # Using Yarn
174
+ yarn global add @xagent/x-cli@latest
175
+
176
+ # Using pnpm
177
+ pnpm add -g @xagent/x-cli@latest
178
+
179
+ # Using bun
180
+ bun add -g @xagent/x-cli@latest
181
+ ```
182
+
183
+ ### ๐Ÿ› ๏ธ PATH Setup (If `xcli` command not found)
184
+
185
+ After installation, if you get "command not found", add npm's global bin to your PATH:
186
+
187
+ **macOS/Linux:**
188
+
189
+ ```bash
190
+ # Add to ~/.zshrc (macOS) or ~/.bashrc (Linux)
191
+ echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
192
+ source ~/.zshrc
193
+
194
+ # Or for bash users:
195
+ echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.bashrc
196
+ source ~/.bashrc
197
+ ```
198
+
199
+ **Windows:**
200
+
201
+ ```bash
202
+ # PowerShell
203
+ $npmPath = npm config get prefix
204
+ $env:PATH += ";$npmPath"
205
+ ```
206
+
207
+ **Verify installation:**
208
+
209
+ ```bash
210
+ xcli --version # Should show current version
211
+ which xcli # Should show installation path
212
+ ```
213
+
214
+ ### โšก Quick Start (One-liner)
215
+
216
+ **Try without installing:**
217
+
218
+ ```bash
219
+ GROK_API_KEY=your_api_key_here npx -y @xagent/x-cli@latest --help
220
+ ```
221
+
222
+ **Or install globally:**
223
+
224
+ ```bash
225
+ npm install -g @xagent/x-cli@latest && \
226
+ echo 'export GROK_API_KEY=your_api_key_here' >> ~/.zshrc && \
227
+ source ~/.zshrc && \
228
+ xcli --help
229
+ ```
230
+
231
+ ### Local Development
232
+
233
+ ```bash
234
+ git clone <repository>
235
+ cd xcli-cli
236
+ npm install
237
+ npm run build
238
+ npm link
239
+ ```
240
+
241
+ ## Setup
242
+
243
+ 1. Get your Grok API key from [X.AI](https://x.ai)
244
+
245
+ 2. Set up your API key (choose one method):
246
+
247
+ **Method 1: Environment Variable**
248
+
249
+ ```bash
250
+ export GROK_API_KEY=your_api_key_here
251
+ ```
252
+
253
+ **Method 2: .env File**
254
+
255
+ ```bash
256
+ cp .env.example .env
257
+ # Edit .env and add your API key
258
+ ```
259
+
260
+ **Method 3: Command Line Flag**
261
+
262
+ ```bash
263
+ xcli --api-key your_api_key_here
264
+ ```
265
+
266
+ **Method 4: User Settings File**
267
+ Create `~/.xcli/user-settings.json`:
268
+
269
+ ```json
270
+ {
271
+ "apiKey": "your_api_key_here"
272
+ }
273
+ ```
274
+
275
+ 3. (Optional, Recommended) Get your Morph API key from [Morph Dashboard](https://morphllm.com/dashboard/api-keys)
276
+
277
+ 4. Set up your Morph API key for Fast Apply editing (choose one method):
278
+
279
+ **Method 1: Environment Variable**
280
+
281
+ ```bash
282
+ export MORPH_API_KEY=your_morph_api_key_here
283
+ ```
284
+
285
+ **Method 2: .env File**
286
+
287
+ ```bash
288
+ # Add to your .env file
289
+ MORPH_API_KEY=your_morph_api_key_here
290
+ ```
291
+
292
+ ### Custom Base URL (Optional)
293
+
294
+ By default, the CLI uses `https://api.x.ai/v1` as the Grok API endpoint. You can configure a custom endpoint if needed (choose one method):
295
+
296
+ **Method 1: Environment Variable**
297
+
298
+ ```bash
299
+ export GROK_BASE_URL=https://your-custom-endpoint.com/v1
300
+ ```
301
+
302
+ **Method 2: Command Line Flag**
303
+
304
+ ```bash
305
+ xcli --api-key your_api_key_here --base-url https://your-custom-endpoint.com/v1
306
+ ```
307
+
308
+ **Method 3: User Settings File**
309
+ Add to `~/.xcli/user-settings.json`:
310
+
311
+ ```json
312
+ {
313
+ "apiKey": "your_api_key_here",
314
+ "baseURL": "https://your-custom-endpoint.com/v1"
315
+ }
316
+ ```
317
+
318
+ ## Configuration Files
319
+
320
+ X CLI uses two types of configuration files to manage settings:
321
+
322
+ ### User-Level Settings (`~/.grok/user-settings.json`)
323
+
324
+ This file stores **global settings** that apply across all projects. These settings rarely change and include:
325
+
326
+ - **API Key**: Your Grok API key
327
+ - **Base URL**: Custom API endpoint (if needed)
328
+ - **Default Model**: Your preferred model (e.g., `grok-code-fast-1`)
329
+ - **Available Models**: List of models you can use
330
+
331
+ **Example:**
332
+
333
+ ```json
334
+ {
335
+ "apiKey": "your_api_key_here",
336
+ "baseURL": "https://api.x.ai/v1",
337
+ "defaultModel": "grok-code-fast-1",
338
+ "models": [
339
+ "grok-code-fast-1",
340
+ "grok-4-latest",
341
+ "grok-3-latest",
342
+ "grok-3-fast",
343
+ "grok-3-mini-fast"
344
+ ]
345
+ }
346
+ ```
347
+
348
+ ### Project-Level Settings (`.grok/settings.json`)
349
+
350
+ This file stores **project-specific settings** in your current working directory. It includes:
351
+
352
+ - **Current Model**: The model currently in use for this project
353
+ - **MCP Servers**: Model Context Protocol server configurations
354
+
355
+ **Example:**
356
+
357
+ ```json
358
+ {
359
+ "model": "grok-3-fast",
360
+ "mcpServers": {
361
+ "linear": {
362
+ "name": "linear",
363
+ "transport": "stdio",
364
+ "command": "npx",
365
+ "args": ["@linear/mcp-server"]
366
+ }
367
+ }
368
+ }
369
+ ```
370
+
371
+ ### How It Works
372
+
373
+ 1. **Global Defaults**: User-level settings provide your default preferences
374
+ 2. **Project Override**: Project-level settings override defaults for specific projects
375
+ 3. **Directory-Specific**: When you change directories, project settings are loaded automatically
376
+ 4. **Fallback Logic**: Project model โ†’ User default model โ†’ System default (`grok-code-fast-1`)
377
+
378
+ This means you can have different models for different projects while maintaining consistent global settings like your API key.
379
+
380
+ ### Using Other API Providers
381
+
382
+ **Important**: Grok CLI uses **OpenAI-compatible APIs**. You can use any provider that implements the OpenAI chat completions standard.
383
+
384
+ **Popular Providers**:
385
+
386
+ - **X.AI (Grok)**: `https://api.x.ai/v1` (default)
387
+ - **OpenAI**: `https://api.openai.com/v1`
388
+ - **OpenRouter**: `https://openrouter.ai/api/v1`
389
+ - **Groq**: `https://api.groq.com/openai/v1`
390
+
391
+ **Example with OpenRouter**:
392
+
393
+ ```json
394
+ {
395
+ "apiKey": "your_openrouter_key",
396
+ "baseURL": "https://openrouter.ai/api/v1",
397
+ "defaultModel": "anthropic/claude-3.5-sonnet",
398
+ "models": [
399
+ "anthropic/claude-3.5-sonnet",
400
+ "openai/gpt-4o",
401
+ "meta-llama/llama-3.1-70b-instruct"
402
+ ]
403
+ }
404
+ ```
405
+
406
+ ## Usage
407
+
408
+ ### Interactive Mode
409
+
410
+ Start the conversational AI assistant:
411
+
412
+ ```bash
413
+ xcli
414
+ ```
415
+
416
+ Or specify a working directory:
417
+
418
+ ```bash
419
+ xcli -d /path/to/project
420
+ ```
421
+
422
+ #### โŒจ๏ธ Keyboard Shortcuts
423
+
424
+ - **`Ctrl+I`** - Toggle context tooltip (workspace insights, git branch, project stats)
425
+ - **`Shift+Tab`** - Toggle auto-edit mode (hands-free file editing)
426
+ - **`Ctrl+C`** - Clear current input
427
+ - **`Esc`** - Interrupt current operation
428
+ - **`exit`** - Quit the application
429
+
430
+ ### Headless Mode
431
+
432
+ Process a single prompt and exit (useful for scripting and automation):
433
+
434
+ ```bash
435
+ xcli --prompt "show me the package.json file"
436
+ xcli -p "create a new file called example.js with a hello world function"
437
+ xcli --prompt "run bun test and show me the results" --directory /path/to/project
438
+ xcli --prompt "complex task" --max-tool-rounds 50 # Limit tool usage for faster execution
439
+ ```
440
+
441
+ This mode is particularly useful for:
442
+
443
+ - **CI/CD pipelines**: Automate code analysis and file operations
444
+ - **Scripting**: Integrate AI assistance into shell scripts
445
+ - **Terminal benchmarks**: Perfect for tools like Terminal Bench that need non-interactive execution
446
+ - **Batch processing**: Process multiple prompts programmatically
447
+
448
+ ### Tool Execution Control
449
+
450
+ By default, Grok CLI allows up to 400 tool execution rounds to handle complex multi-step tasks. You can control this behavior:
451
+
452
+ ```bash
453
+ # Limit tool rounds for faster execution on simple tasks
454
+ xcli --max-tool-rounds 10 --prompt "show me the current directory"
455
+
456
+ # Increase limit for very complex tasks (use with caution)
457
+ xcli --max-tool-rounds 1000 --prompt "comprehensive code refactoring"
458
+
459
+ # Works with all modes
460
+ xcli --max-tool-rounds 20 # Interactive mode
461
+ xcli git commit-and-push --max-tool-rounds 30 # Git commands
462
+ ```
463
+
464
+ **Use Cases**:
465
+
466
+ - **Fast responses**: Lower limits (10-50) for simple queries
467
+ - **Complex automation**: Higher limits (500+) for comprehensive tasks
468
+ - **Resource control**: Prevent runaway executions in automated environments
469
+
470
+ ### Model Selection
471
+
472
+ You can specify which AI model to use with the `--model` parameter or `GROK_MODEL` environment variable:
473
+
474
+ **Method 1: Command Line Flag**
475
+
476
+ ```bash
477
+ # Use Grok models
478
+ xcli --model grok-code-fast-1
479
+ xcli --model grok-4-latest
480
+ xcli --model grok-3-latest
481
+ xcli --model grok-3-fast
482
+
483
+ # Use other models (with appropriate API endpoint)
484
+ xcli --model gemini-2.5-pro --base-url https://api-endpoint.com/v1
485
+ xcli --model claude-sonnet-4-20250514 --base-url https://api-endpoint.com/v1
486
+ ```
487
+
488
+ **Method 2: Environment Variable**
489
+
490
+ ```bash
491
+ export GROK_MODEL=grok-code-fast-1
492
+ xcli
493
+ ```
494
+
495
+ **Method 3: User Settings File**
496
+ Add to `~/.xcli/user-settings.json`:
497
+
498
+ ```json
499
+ {
500
+ "apiKey": "your_api_key_here",
501
+ "defaultModel": "grok-code-fast-1"
502
+ }
503
+ ```
504
+
505
+ **Model Priority**: `--model` flag > `GROK_MODEL` environment variable > user default model > system default (grok-code-fast-1)
506
+
507
+ ### Command Line Options
508
+
509
+ ```bash
510
+ xcli [options]
511
+
512
+ Options:
513
+ -V, --version output the version number
514
+ -d, --directory <dir> set working directory
515
+ -k, --api-key <key> Grok API key (or set GROK_API_KEY env var)
516
+ -u, --base-url <url> Grok API base URL (or set GROK_BASE_URL env var)
517
+ -m, --model <model> AI model to use (e.g., grok-code-fast-1, grok-4-latest) (or set GROK_MODEL env var)
518
+ -p, --prompt <prompt> process a single prompt and exit (headless mode)
519
+ --max-tool-rounds <rounds> maximum number of tool execution rounds (default: 400)
520
+ -h, --help display help for command
521
+ ```
522
+
523
+ ### Custom Instructions
524
+
525
+ You can provide custom instructions to tailor Grok's behavior to your project by creating a `.grok/GROK.md` file in your project directory:
526
+
527
+ ```bash
528
+ mkdir .grok
529
+ ```
530
+
531
+ Create `.grok/GROK.md` with your custom instructions:
532
+
533
+ ```markdown
534
+ # Custom Instructions for X CLI
535
+
536
+ Always use TypeScript for any new code files.
537
+ When creating React components, use functional components with hooks.
538
+ Prefer const assertions and explicit typing over inference where it improves clarity.
539
+ Always add JSDoc comments for public functions and interfaces.
540
+ Follow the existing code style and patterns in this project.
541
+ ```
542
+
543
+ Grok will automatically load and follow these instructions when working in your project directory. The custom instructions are added to Grok's system prompt and take priority over default behavior.
544
+
545
+ ## Morph Fast Apply (Optional)
546
+
547
+ Grok CLI supports Morph's Fast Apply model for high-speed code editing at **4,500+ tokens/sec with 98% accuracy**. This is an optional feature that provides lightning-fast file editing capabilities.
548
+
549
+ **Setup**: Configure your Morph API key following the [setup instructions](#setup) above.
550
+
551
+ ### How It Works
552
+
553
+ When `MORPH_API_KEY` is configured:
554
+
555
+ - **`edit_file` tool becomes available** alongside the standard `str_replace_editor`
556
+ - **Optimized for complex edits**: Use for multi-line changes, refactoring, and large modifications
557
+ - **Intelligent editing**: Uses abbreviated edit format with `// ... existing code ...` comments
558
+ - **Fallback support**: Standard tools remain available if Morph is unavailable
559
+
560
+ **When to use each tool:**
561
+
562
+ - **`edit_file`** (Morph): Complex edits, refactoring, multi-line changes
563
+ - **`str_replace_editor`**: Simple text replacements, single-line edits
564
+
565
+ ### Example Usage
566
+
567
+ With Morph Fast Apply configured, you can request complex code changes:
568
+
569
+ ```bash
570
+ xcli --prompt "refactor this function to use async/await and add error handling"
571
+ xcli -p "convert this class to TypeScript and add proper type annotations"
572
+ ```
573
+
574
+ The AI will automatically choose between `edit_file` (Morph) for complex changes or `str_replace_editor` for simple replacements.
575
+
576
+ ## MCP Tools
577
+
578
+ Grok CLI supports MCP (Model Context Protocol) servers, allowing you to extend the AI assistant with additional tools and capabilities.
579
+
580
+ ### Adding MCP Tools
581
+
582
+ #### Add a custom MCP server:
583
+
584
+ ```bash
585
+ # Add an stdio-based MCP server
586
+ xcli mcp add my-server --transport stdio --command "bun" --args server.js
587
+
588
+ # Add an HTTP-based MCP server
589
+ xcli mcp add my-server --transport http --url "http://localhost:3000"
590
+
591
+ # Add with environment variables
592
+ xcli mcp add my-server --transport stdio --command "python" --args "-m" "my_mcp_server" --env "API_KEY=your_key"
593
+ ```
594
+
595
+ #### Add from JSON configuration:
596
+
597
+ ```bash
598
+ xcli mcp add-json my-server '{"command": "bun", "args": ["server.js"], "env": {"API_KEY": "your_key"}}'
599
+ ```
600
+
601
+ ### Linear Integration Example
602
+
603
+ To add Linear MCP tools for project management:
604
+
605
+ ```bash
606
+ # Add Linear MCP server
607
+ xcli mcp add linear --transport sse --url "https://mcp.linear.app/sse"
608
+ ```
609
+
610
+ This enables Linear tools like:
611
+
612
+ - Create and manage Linear issues
613
+ - Search and filter issues
614
+ - Update issue status and assignees
615
+ - Access team and project information
616
+
617
+ ### Managing MCP Servers
618
+
619
+ ```bash
620
+ # List all configured servers
621
+ xcli mcp list
622
+
623
+ # Test server connection
624
+ xcli mcp test server-name
625
+
626
+ # Remove a server
627
+ xcli mcp remove server-name
628
+ ```
629
+
630
+ ### Available Transport Types
631
+
632
+ - **stdio**: Run MCP server as a subprocess (most common)
633
+ - **http**: Connect to HTTP-based MCP server
634
+ - **sse**: Connect via Server-Sent Events
635
+
636
+ ## Development
637
+
638
+ ```bash
639
+ # Install dependencies
640
+ npm install
641
+
642
+ # Development mode
643
+ bun run dev
644
+
645
+ # Build project
646
+ npm run build
647
+
648
+ # Run linter
649
+ bun run lint
650
+
651
+ # Type check
652
+ bun run typecheck
653
+ ```
654
+
655
+ ### Pre-commit Hooks
656
+
657
+ This project uses [Husky](https://typicode.github.com/husky/) and [lint-staged](https://github.com/okonet/lint-staged) to run automated checks before commits:
658
+
659
+ - **ESLint**: Automatically fixes linting issues and checks for errors
660
+ - **TypeScript**: Runs type checking to prevent compilation errors
661
+ - **Staged files only**: Only checks files that are staged for commit
662
+
663
+ The pre-commit hook runs `npx lint-staged`, which processes `*.{ts,tsx}` files with:
664
+
665
+ 1. `eslint --fix` - Auto-fix linting issues where possible
666
+ 2. `tsc --noEmit` - Type check without emitting files
667
+
668
+ If checks fail, the commit is blocked until issues are resolved.
669
+
670
+ ## ๐Ÿค– Automated Release System
671
+
672
+ **Status**: โœ… **FULLY AUTOMATED** (as of 2025-10-17)
673
+
674
+ ### How It Works
675
+
676
+ Every push to the `main` branch automatically:
677
+
678
+ 1. **๐Ÿ”„ Bumps version** (patch increment: 1.0.X โ†’ 1.0.X+1)
679
+ 2. **๐Ÿ“ Updates README** with new version number
680
+ 3. **๐Ÿ—๏ธ Builds the project** with fresh dependencies
681
+ 4. **๐Ÿ“ฆ Publishes to NPM** at https://www.npmjs.com/package/@xagent/x-cli
682
+ 5. **๐Ÿท๏ธ Creates git tag** (e.g., `v1.0.87`)
683
+
684
+ **โฑ๏ธ Timeline**: ~3-5 minutes from push to NPM availability
685
+
686
+ ### What You Need to Do
687
+
688
+ **Nothing!** Just push your changes to main:
689
+
690
+ ```bash
691
+ git add .
692
+ git commit -m "your feature/fix"
693
+ git push origin main
694
+ # โœจ Automation handles the rest!
695
+ ```
696
+
697
+ ### ๐Ÿšจ Critical Dependencies
698
+
699
+ **โš ๏ธ DO NOT MODIFY without understanding the full impact:**
700
+
701
+ #### GitHub Secrets (Required)
702
+
703
+ - **`PAT_TOKEN`**: Personal Access Token with repo permissions (for git operations)
704
+ - **`NPM_TOKEN`**: NPM Automation token from `xcli_cli` account (for publishing)
705
+
706
+ #### Package Configuration (Sacred Settings)
707
+
708
+ ```json
709
+ {
710
+ "name": "@xagent/x-cli", // โš ๏ธ NEVER change - breaks publishing
711
+ "publishConfig": {
712
+ "access": "public" // โš ๏ธ Must NOT include registry override
713
+ }
714
+ }
715
+ ```
716
+
717
+ #### Workflow File (`.github/workflows/release.yml`)
718
+
719
+ **โš ๏ธ This took multiple attempts to get working - modify with extreme caution!**
720
+
721
+ ### ๐Ÿ”ง Manual Release (Emergency Only)
722
+
723
+ If automation fails and you need to publish immediately:
724
+
725
+ ```bash
726
+ # 1. Bump version locally
727
+ npm version patch # or minor/major
728
+
729
+ # 2. Test build
730
+ npm run build
731
+ npm run local # Test CLI locally
732
+
733
+ # 3. Manual publish
734
+ npm publish --access public
735
+
736
+ # 4. Push changes
737
+ git push origin main --follow-tags
738
+
739
+ # 5. Fix automation before next release!
740
+ ```
741
+
742
+ ### ๐Ÿ“Š Monitoring
743
+
744
+ - **GitHub Actions**: https://github.com/x-cli-team/x-cli/actions
745
+ - **NPM Package**: https://www.npmjs.com/package/@xagent/x-cli
746
+ - **Release History**: Check git tags or NPM version history
747
+
748
+ ### ๐Ÿ› ๏ธ Troubleshooting
749
+
750
+ If automation fails:
751
+
752
+ 1. **Check GitHub Actions logs** for specific errors
753
+ 2. **Verify secrets** (`PAT_TOKEN`, `NPM_TOKEN`) haven't expired
754
+ 3. **Confirm package.json** name hasn't been modified
755
+ 4. **See documentation**: `.agent/sop/npm-publishing-troubleshooting.md`
756
+
757
+ **Common Issues**:
758
+
759
+ - **Build fails**: Usually Rollup dependency cache (auto-fixed with clean install)
760
+ - **Publish fails**: Check NPM token is valid and from correct account
761
+ - **Git push fails**: Verify PAT_TOKEN has repo permissions
762
+
763
+ ### ๐Ÿ“š Related Documentation
764
+
765
+ - **๐Ÿ“‹ Release Management**: `.agent/sop/release-management.md`
766
+ - **๐Ÿšจ Incident History**: `.agent/incidents/incident-npm-publish-failure.md`
767
+ - **๐Ÿ”ง Troubleshooting**: `.agent/sop/npm-publishing-troubleshooting.md`
768
+
769
+ ---
770
+
771
+ ## Architecture
772
+
773
+ - **Agent**: Core command processing and execution logic
774
+ - **Tools**: Text editor and bash tool implementations
775
+ - **UI**: Ink-based terminal interface components
776
+ - **Types**: TypeScript definitions for the entire system
777
+
778
+ ## License
779
+
780
+ MIT
781
+
782
+ ## Credits
783
+
784
+ This project is based on [xcli-cli](https://github.com/superagent-ai/xcli-cli) by [@pelaseyed](https://x.com/pelaseyed).
785
+
786
+ ## Troubleshooting
787
+
788
+ ### Installation Issues
789
+
790
+ **๐Ÿšจ "Command not found: xcli"**
791
+
792
+ ```bash
793
+ # Check if xcli is installed
794
+ npm list -g @xagent/x-cli
795
+
796
+ # If installed but not in PATH, add npm global bin to PATH:
797
+ echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
798
+ source ~/.zshrc
799
+
800
+ # Verify it works
801
+ xcli --version
802
+ ```
803
+
804
+ **๐Ÿšจ "Permission denied" during installation**
805
+
806
+ ```bash
807
+ # Option 1: Use npx (no installation needed)
808
+ npx @xagent/x-cli@latest
809
+
810
+ # Option 2: Fix npm permissions (macOS/Linux)
811
+ sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
812
+
813
+ # Option 3: Configure npm to use different directory
814
+ mkdir ~/.npm-global
815
+ npm config set prefix '~/.npm-global'
816
+ echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
817
+ source ~/.zshrc
818
+ ```
819
+
820
+ **๐Ÿšจ "Cannot find module" errors**
821
+
822
+ ```bash
823
+ # Clear npm cache and reinstall
824
+ npm cache clean --force
825
+ npm uninstall -g @xagent/x-cli
826
+ npm install -g @xagent/x-cli@latest
827
+ ```
828
+
829
+ **๐Ÿšจ Outdated version**
830
+
831
+ ```bash
832
+ # Check current version
833
+ xcli --version
834
+ npm view @xagent/x-cli version
835
+
836
+ # Update to latest
837
+ npm update -g @xagent/x-cli@latest
838
+ ```
839
+
840
+ ### Tool Execution Errors
841
+
842
+ If you encounter errors like `fs.readFile is not a function` or `fs.stat is not a function` when using file operations:
843
+
844
+ 1. **This is a known issue** with the tool infrastructure
845
+ 2. **Automatic fallback**: The CLI will automatically fall back to bash commands for file operations
846
+ 3. **Warning messages**: You may see console warnings like "str_replace_editor tool failed, falling back to bash"
847
+ 4. **Functionality**: Despite the warnings, operations should still work via bash fallbacks
848
+
849
+ This issue is being tracked and the fallbacks ensure the CLI remains functional.
850
+
851
+ ### Runtime Issues
852
+
853
+ **๐Ÿšจ API Key errors**
854
+
855
+ ```bash
856
+ # Set your API key (replace with your actual key)
857
+ export GROK_API_KEY=your_actual_api_key_here
858
+
859
+ # Or add to your shell profile permanently
860
+ echo 'export GROK_API_KEY=your_actual_api_key_here' >> ~/.zshrc
861
+ source ~/.zshrc
862
+
863
+ # Verify it's set
864
+ echo $GROK_API_KEY
865
+ ```
866
+
867
+ **๐Ÿšจ Network/connectivity issues**
868
+
869
+ ```bash
870
+ # Test with verbose output
871
+ xcli --verbose "test message"
872
+
873
+ # Check API endpoint connectivity
874
+ curl -I https://api.x.ai/v1/models
875
+ ```
876
+
877
+ ### Common Issues
878
+
879
+ - **File operations fail**: Check that the file path exists and is accessible
880
+ - **Bash commands fail**: Ensure you have the necessary permissions
881
+ - **Tool timeouts**: Complex operations may take time; the spinner indicates progress
882
+ - **Slow responses**: Try a different model with `xcli --model grok-code-fast-1`
883
+
884
+ ## ๐Ÿ™ Credits
885
+
886
+ This project is built upon the excellent foundation of the original [Grok CLI](https://github.com/superagent-ai/xcli-cli) created by [Ismail Pelaseyed](https://github.com/homanp) at [Superagent.ai](https://github.com/superagent-ai).
887
+
888
+ **Original Project**: [superagent-ai/xcli-cli](https://github.com/superagent-ai/xcli-cli)
889
+ **Founder**: [Ismail Pelaseyed](https://github.com/homanp)
890
+ **Organization**: [Superagent.ai](https://github.com/superagent-ai)
891
+
892
+ This "Hurry Mode" fork extends the original with advanced file operations, enhanced tool systems, and comprehensive automation while maintaining the core vision of bringing AI-powered terminal intelligence to developers.
893
+
894
+ ## ๐Ÿ‘ฅ Contributors
895
+
896
+ We welcome contributions from the community! Add your details below when you contribute to the project.
897
+
898
+ <!--
899
+ To add yourself as a contributor:
900
+ 1. Fork the repository
901
+ 2. Add your entry below following the format
902
+ 3. Submit a pull request
903
+ -->
904
+
905
+ ### Core Contributors
906
+
907
+ - **[@hinetapora](https://github.com/hinetapora)** โ€” Fork maintainer, advanced tool systems, UX enhancements, auto-upgrade system
908
+ - **[@homanp](https://github.com/homanp)** โ€” Original Grok CLI creator and foundation
909
+
910
+ ### Community Contributors
911
+
912
+ <!-- Add your entry here! -->
913
+ <!-- Format:
914
+ - **[@yourusername](https://github.com/yourusername)** โ€” (project link) โ€” Brief description of your contributions
915
+ -->
916
+
917
+ - **[@unblock-everything](https://github.com/unblock-everything)** โ€” [x.ai](https://x.ai) โ€” Cold-ass honkey ๐Ÿ˜Ž
918
+ - **[@Bucko89](https://github.com/Bucko89)** โ€” [GMA](https://getmyagencies.com) โ€” Grinding daily
919
+ - **[@base-buzz](https://github.com/base-buzz)** โ€” [Meta](team.meta.com)
920
+
921
+ _Want to see your name here? Check out our [Contributing Guide](CONTRIBUTING.md) and submit a pull request!_
922
+
923
+ ### How to Contribute
924
+
925
+ 1. **Fork** the repository on GitHub
926
+ 2. **Clone** your fork locally: `git clone https://github.com/yourusername/x-cli-hurry-mode.git`
927
+ 3. **Create** a feature branch: `git checkout -b feature/your-feature-name`
928
+ 4. **Make** your changes and commit them: `git commit -m "feat: add awesome feature"`
929
+ 5. **Push** to your fork: `git push origin feature/your-feature-name`
930
+ 6. **Submit** a pull request with a clear description of your changes
931
+
932
+ ### Types of Contributions Welcome
933
+
934
+ - ๐Ÿ› **Bug fixes** - Help us squash those pesky bugs
935
+ - โšก **Performance improvements** - Make it faster and more efficient
936
+ - ๐Ÿ“– **Documentation** - Improve our docs and examples
937
+ - ๐ŸŽจ **UX/UI enhancements** - Better terminal experience
938
+ - ๐Ÿ”ง **New tools** - Add new capabilities to the tool system
939
+ - ๐Ÿงช **Tests** - Help us improve our test coverage
940
+ - ๐Ÿ’ก **Feature requests** - Suggest new functionality
941
+
942
+ Join our growing community of AI-powered terminal enthusiasts!