grok-cli-acp 0.1.2
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/.env.example +42 -0
- package/.github/workflows/ci.yml +30 -0
- package/.github/workflows/rust.yml +22 -0
- package/.grok/.env.example +85 -0
- package/.grok/COMPLETE_FIX_SUMMARY.md +466 -0
- package/.grok/ENV_CONFIG_GUIDE.md +173 -0
- package/.grok/QUICK_REFERENCE.md +180 -0
- package/.grok/README.md +104 -0
- package/.grok/TESTING_GUIDE.md +393 -0
- package/CHANGELOG.md +465 -0
- package/CODE_REVIEW_SUMMARY.md +414 -0
- package/COMPLETE_FIX_SUMMARY.md +415 -0
- package/CONFIGURATION.md +489 -0
- package/CONTEXT_FILES_GUIDE.md +419 -0
- package/CONTRIBUTING.md +55 -0
- package/CURSOR_POSITION_FIX.md +206 -0
- package/Cargo.toml +88 -0
- package/ERROR_HANDLING_REPORT.md +361 -0
- package/FINAL_FIX_SUMMARY.md +462 -0
- package/FIXES.md +37 -0
- package/FIXES_SUMMARY.md +87 -0
- package/GROK_API_MIGRATION_SUMMARY.md +111 -0
- package/LICENSE +22 -0
- package/MIGRATION_TO_GROK_API.md +223 -0
- package/README.md +504 -0
- package/REVIEW_COMPLETE.md +416 -0
- package/REVIEW_QUICK_REFERENCE.md +173 -0
- package/SECURITY.md +463 -0
- package/SECURITY_AUDIT.md +661 -0
- package/SETUP.md +287 -0
- package/TESTING_TOOLS.md +88 -0
- package/TESTING_TOOL_EXECUTION.md +239 -0
- package/TOOL_EXECUTION_FIX.md +491 -0
- package/VERIFICATION_CHECKLIST.md +419 -0
- package/docs/API.md +74 -0
- package/docs/CHAT_LOGGING.md +39 -0
- package/docs/CURSOR_FIX_DEMO.md +306 -0
- package/docs/ERROR_HANDLING_GUIDE.md +547 -0
- package/docs/FILE_OPERATIONS.md +449 -0
- package/docs/INTERACTIVE.md +401 -0
- package/docs/PROJECT_CREATION_GUIDE.md +570 -0
- package/docs/QUICKSTART.md +378 -0
- package/docs/QUICK_REFERENCE.md +691 -0
- package/docs/RELEASE_NOTES_0.1.2.md +240 -0
- package/docs/TOOLS.md +459 -0
- package/docs/TOOLS_QUICK_REFERENCE.md +210 -0
- package/docs/ZED_INTEGRATION.md +371 -0
- package/docs/extensions.md +464 -0
- package/docs/settings.md +293 -0
- package/examples/extensions/logging-hook/README.md +91 -0
- package/examples/extensions/logging-hook/extension.json +22 -0
- package/package.json +30 -0
- package/scripts/test_acp.py +252 -0
- package/scripts/test_acp.sh +143 -0
- package/scripts/test_acp_simple.sh +72 -0
- package/src/acp/mod.rs +741 -0
- package/src/acp/protocol.rs +323 -0
- package/src/acp/security.rs +298 -0
- package/src/acp/tools.rs +697 -0
- package/src/bin/banner_demo.rs +216 -0
- package/src/bin/docgen.rs +18 -0
- package/src/bin/installer.rs +217 -0
- package/src/cli/app.rs +310 -0
- package/src/cli/commands/acp.rs +721 -0
- package/src/cli/commands/chat.rs +485 -0
- package/src/cli/commands/code.rs +513 -0
- package/src/cli/commands/config.rs +394 -0
- package/src/cli/commands/health.rs +442 -0
- package/src/cli/commands/history.rs +421 -0
- package/src/cli/commands/mod.rs +14 -0
- package/src/cli/commands/settings.rs +1384 -0
- package/src/cli/mod.rs +166 -0
- package/src/config/mod.rs +2212 -0
- package/src/display/ascii_art.rs +139 -0
- package/src/display/banner.rs +289 -0
- package/src/display/components/input.rs +323 -0
- package/src/display/components/mod.rs +2 -0
- package/src/display/components/settings_list.rs +306 -0
- package/src/display/interactive.rs +1255 -0
- package/src/display/mod.rs +62 -0
- package/src/display/terminal.rs +42 -0
- package/src/display/tips.rs +316 -0
- package/src/grok_client_ext.rs +177 -0
- package/src/hooks/loader.rs +407 -0
- package/src/hooks/mod.rs +158 -0
- package/src/lib.rs +174 -0
- package/src/main.rs +65 -0
- package/src/mcp/client.rs +195 -0
- package/src/mcp/config.rs +20 -0
- package/src/mcp/mod.rs +6 -0
- package/src/mcp/protocol.rs +67 -0
- package/src/utils/auth.rs +41 -0
- package/src/utils/chat_logger.rs +568 -0
- package/src/utils/context.rs +390 -0
- package/src/utils/mod.rs +16 -0
- package/src/utils/network.rs +320 -0
- package/src/utils/rate_limiter.rs +166 -0
- package/src/utils/session.rs +73 -0
- package/src/utils/shell_permissions.rs +389 -0
- package/src/utils/telemetry.rs +41 -0
package/CONFIGURATION.md
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
# Grok CLI Configuration Guide
|
|
2
|
+
|
|
3
|
+
This document explains how to configure the Grok CLI using `.env` files.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Grok CLI uses a hierarchical configuration system based on `.env` files. This approach provides:
|
|
8
|
+
|
|
9
|
+
- **Single configuration format** - All settings use environment variables
|
|
10
|
+
- **Project-specific overrides** - Different settings per project
|
|
11
|
+
- **System-wide defaults** - Shared settings across all projects
|
|
12
|
+
- **Clear precedence rules** - Predictable configuration behavior
|
|
13
|
+
|
|
14
|
+
## Configuration Hierarchy
|
|
15
|
+
|
|
16
|
+
Settings are loaded in this order (highest priority first):
|
|
17
|
+
|
|
18
|
+
1. **Shell/Process Environment Variables** - Set in your terminal or CI/CD
|
|
19
|
+
2. **CLI Arguments** - Flags like `--model`, `--config`
|
|
20
|
+
3. **Project Configuration** - `.grok/.env` in project root
|
|
21
|
+
4. **System Configuration** - `~/.grok/.env` (or `%USERPROFILE%\.grok\.env` on Windows)
|
|
22
|
+
5. **Built-in Defaults** - Fallback values
|
|
23
|
+
|
|
24
|
+
Later sources override earlier ones. For example, a project `.env` overrides system config, but environment variables override everything.
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### 1. Copy the Example File
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# For root project configuration
|
|
32
|
+
cp .env.example .env
|
|
33
|
+
|
|
34
|
+
# For project-specific configuration
|
|
35
|
+
mkdir -p .grok
|
|
36
|
+
cp .grok/.env.example .grok/.env
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Set Your API Key
|
|
40
|
+
|
|
41
|
+
Edit `.env` and add your X API key:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
GROK_API_KEY=xai-your-api-key-here
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. Customize Settings (Optional)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Set preferred model
|
|
51
|
+
GROK_MODEL=grok-code-fast-1
|
|
52
|
+
|
|
53
|
+
# Adjust temperature (0.0-2.0)
|
|
54
|
+
GROK_TEMPERATURE=0.7
|
|
55
|
+
|
|
56
|
+
# Set timeout for slow connections
|
|
57
|
+
GROK_TIMEOUT=60
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration Locations
|
|
61
|
+
|
|
62
|
+
### Project Configuration: `.grok/.env`
|
|
63
|
+
|
|
64
|
+
Place this in your project root for project-specific settings:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
your-project/
|
|
68
|
+
├── .grok/
|
|
69
|
+
│ └── .env ← Project-specific config
|
|
70
|
+
├── .git/
|
|
71
|
+
├── src/
|
|
72
|
+
└── README.md
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**When to use:**
|
|
76
|
+
- Project requires a specific model (e.g., code projects use `grok-code-fast-1`)
|
|
77
|
+
- Different timeout settings for specific projects
|
|
78
|
+
- Project-specific logging or debugging
|
|
79
|
+
|
|
80
|
+
### System Configuration: `~/.grok/.env`
|
|
81
|
+
|
|
82
|
+
Place this in your home directory for user-wide defaults:
|
|
83
|
+
|
|
84
|
+
**Linux/macOS:** `~/.grok/.env`
|
|
85
|
+
**Windows:** `%USERPROFILE%\.grok\.env` (e.g., `C:\Users\YourName\.grok\.env`)
|
|
86
|
+
|
|
87
|
+
**When to use:**
|
|
88
|
+
- Settings shared across all your projects
|
|
89
|
+
- Your API key (so you don't repeat it in every project)
|
|
90
|
+
- Personal preferences (colors, UI settings, etc.)
|
|
91
|
+
|
|
92
|
+
### Root Project: `.env`
|
|
93
|
+
|
|
94
|
+
The repository root `.env` file for development/testing of Grok CLI itself.
|
|
95
|
+
|
|
96
|
+
## Available Settings
|
|
97
|
+
|
|
98
|
+
### API Configuration
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# X API Key for Grok access (REQUIRED)
|
|
102
|
+
GROK_API_KEY=xai-your-api-key-here
|
|
103
|
+
|
|
104
|
+
# Alternative variable name (same effect)
|
|
105
|
+
X_API_KEY=xai-your-api-key-here
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Model Settings
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Default model to use
|
|
112
|
+
# Options: grok-3, grok-2-latest, grok-2, grok-code-fast-1, grok-vision-beta
|
|
113
|
+
GROK_MODEL=grok-3
|
|
114
|
+
|
|
115
|
+
# Temperature (0.0 = deterministic, 2.0 = very creative)
|
|
116
|
+
GROK_TEMPERATURE=0.7
|
|
117
|
+
|
|
118
|
+
# Maximum tokens in response
|
|
119
|
+
GROK_MAX_TOKENS=4096
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Network Configuration
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Request timeout in seconds
|
|
126
|
+
GROK_TIMEOUT=30
|
|
127
|
+
|
|
128
|
+
# Maximum number of retries for failed requests
|
|
129
|
+
GROK_MAX_RETRIES=3
|
|
130
|
+
|
|
131
|
+
# Enable Starlink-specific optimizations
|
|
132
|
+
GROK_STARLINK_OPTIMIZATIONS=true
|
|
133
|
+
|
|
134
|
+
# Retry delay settings (in seconds)
|
|
135
|
+
GROK_BASE_RETRY_DELAY=1
|
|
136
|
+
GROK_MAX_RETRY_DELAY=60
|
|
137
|
+
|
|
138
|
+
# Enable network health monitoring
|
|
139
|
+
GROK_HEALTH_MONITORING=true
|
|
140
|
+
|
|
141
|
+
# Connection and read timeouts
|
|
142
|
+
GROK_CONNECT_TIMEOUT=10
|
|
143
|
+
GROK_READ_TIMEOUT=30
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### UI Configuration
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Enable colored output
|
|
150
|
+
GROK_COLORS=true
|
|
151
|
+
|
|
152
|
+
# Enable progress bars
|
|
153
|
+
GROK_PROGRESS_BARS=true
|
|
154
|
+
|
|
155
|
+
# Enable Unicode characters in output
|
|
156
|
+
GROK_UNICODE=true
|
|
157
|
+
|
|
158
|
+
# Show verbose error information
|
|
159
|
+
GROK_VERBOSE_ERRORS=false
|
|
160
|
+
|
|
161
|
+
# Terminal width (0 = auto-detect)
|
|
162
|
+
GROK_TERMINAL_WIDTH=0
|
|
163
|
+
|
|
164
|
+
# Disable colors (useful for CI/CD)
|
|
165
|
+
NO_COLOR=1
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Logging Configuration
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Log level: trace, debug, info, warn, error
|
|
172
|
+
GROK_LOG_LEVEL=info
|
|
173
|
+
|
|
174
|
+
# Enable file logging
|
|
175
|
+
GROK_FILE_LOGGING=false
|
|
176
|
+
|
|
177
|
+
# Log file path (optional)
|
|
178
|
+
GROK_LOG_FILE=/path/to/grok.log
|
|
179
|
+
|
|
180
|
+
# Maximum log file size in MB
|
|
181
|
+
GROK_MAX_FILE_SIZE_MB=10
|
|
182
|
+
|
|
183
|
+
# Number of log files to rotate
|
|
184
|
+
GROK_ROTATION_COUNT=5
|
|
185
|
+
|
|
186
|
+
# Rust internal logging (overrides GROK_LOG_LEVEL)
|
|
187
|
+
RUST_LOG=grok_cli=debug
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Chat Logging Configuration
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Enable chat session logging (saves conversations to disk)
|
|
194
|
+
GROK_CHAT_LOGGING_ENABLED=true
|
|
195
|
+
|
|
196
|
+
# Directory for chat logs (default: ~/.grok/logs/chat_sessions)
|
|
197
|
+
GROK_CHAT_LOG_DIR=/path/to/chat/logs
|
|
198
|
+
|
|
199
|
+
# Maximum log file size in MB before rotation
|
|
200
|
+
GROK_CHAT_LOG_MAX_SIZE_MB=10
|
|
201
|
+
|
|
202
|
+
# Number of rotated chat log files to keep
|
|
203
|
+
GROK_CHAT_LOG_ROTATION_COUNT=5
|
|
204
|
+
|
|
205
|
+
# Include system messages in chat logs
|
|
206
|
+
GROK_CHAT_LOG_INCLUDE_SYSTEM=true
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Chat logs are saved in both JSON and human-readable text formats:
|
|
210
|
+
- **JSON format**: `~/.grok/logs/chat_sessions/<session-id>.json` - Machine-readable, full metadata
|
|
211
|
+
- **Text format**: `~/.grok/logs/chat_sessions/<session-id>.txt` - Human-readable conversation transcript
|
|
212
|
+
|
|
213
|
+
View chat history with:
|
|
214
|
+
```bash
|
|
215
|
+
grok history list # List all sessions
|
|
216
|
+
grok history view <session-id> # View specific session
|
|
217
|
+
grok history search "query" # Search through sessions
|
|
218
|
+
grok history clear --confirm # Clear all history
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### ACP (Agent Client Protocol) Configuration
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Enable ACP functionality
|
|
225
|
+
GROK_ACP_ENABLED=true
|
|
226
|
+
|
|
227
|
+
# Disable ACP (alternative way)
|
|
228
|
+
GROK_ACP_DISABLE=true
|
|
229
|
+
|
|
230
|
+
# Port for ACP server (0 = auto-assign)
|
|
231
|
+
GROK_ACP_PORT=0
|
|
232
|
+
|
|
233
|
+
# Host to bind ACP server to
|
|
234
|
+
GROK_ACP_BIND_HOST=127.0.0.1
|
|
235
|
+
|
|
236
|
+
# ACP protocol version
|
|
237
|
+
GROK_ACP_PROTOCOL_VERSION=1.0
|
|
238
|
+
|
|
239
|
+
# Enable development mode
|
|
240
|
+
GROK_ACP_DEV_MODE=false
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Telemetry Configuration
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Enable telemetry (opt-in)
|
|
247
|
+
GROK_TELEMETRY_ENABLED=false
|
|
248
|
+
|
|
249
|
+
# Path to telemetry log file (optional)
|
|
250
|
+
GROK_TELEMETRY_LOG_FILE=/path/to/telemetry.log
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Common Scenarios
|
|
254
|
+
|
|
255
|
+
### Scenario 1: Different Models per Project
|
|
256
|
+
|
|
257
|
+
**System config** (`~/.grok/.env`):
|
|
258
|
+
```bash
|
|
259
|
+
GROK_API_KEY=xai-your-key
|
|
260
|
+
GROK_MODEL=grok-3 # Default for most projects
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Code project** (`.grok/.env`):
|
|
264
|
+
```bash
|
|
265
|
+
GROK_MODEL=grok-code-fast-1 # Optimized for coding
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Creative project** (`.grok/.env`):
|
|
269
|
+
```bash
|
|
270
|
+
GROK_MODEL=grok-3
|
|
271
|
+
GROK_TEMPERATURE=1.5 # More creative
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Scenario 2: Satellite/Slow Connection
|
|
275
|
+
|
|
276
|
+
**Project config** (`.grok/.env`):
|
|
277
|
+
```bash
|
|
278
|
+
GROK_TIMEOUT=120
|
|
279
|
+
GROK_MAX_RETRIES=5
|
|
280
|
+
GROK_STARLINK_OPTIMIZATIONS=true
|
|
281
|
+
GROK_BASE_RETRY_DELAY=2
|
|
282
|
+
GROK_MAX_RETRY_DELAY=120
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Scenario 3: CI/CD Pipeline
|
|
286
|
+
|
|
287
|
+
**GitHub Actions** (`.github/workflows/test.yml`):
|
|
288
|
+
```yaml
|
|
289
|
+
env:
|
|
290
|
+
GROK_API_KEY: ${{ secrets.GROK_API_KEY }}
|
|
291
|
+
GROK_MODEL: grok-code-fast-1
|
|
292
|
+
GROK_TIMEOUT: 60
|
|
293
|
+
NO_COLOR: 1 # Disable colors in CI
|
|
294
|
+
GROK_PROGRESS_BARS: false
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Scenario 4: Debugging
|
|
298
|
+
|
|
299
|
+
**Temporary override** (in terminal):
|
|
300
|
+
```bash
|
|
301
|
+
# Enable debug logging for one run
|
|
302
|
+
GROK_LOG_LEVEL=debug RUST_LOG=grok_cli=debug grok
|
|
303
|
+
|
|
304
|
+
# Or export for session
|
|
305
|
+
export GROK_LOG_LEVEL=debug
|
|
306
|
+
export GROK_VERBOSE_ERRORS=true
|
|
307
|
+
grok
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Verifying Configuration
|
|
311
|
+
|
|
312
|
+
Check which settings are active:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
grok config show
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Output shows:
|
|
319
|
+
- Current values for all settings
|
|
320
|
+
- Configuration source (project/system/defaults)
|
|
321
|
+
|
|
322
|
+
Example:
|
|
323
|
+
```
|
|
324
|
+
Configuration Source:
|
|
325
|
+
project (H:\GitHub\grok-cli\.grok\.env)
|
|
326
|
+
|
|
327
|
+
API Configuration:
|
|
328
|
+
API Key: ✓ Set (hidden)
|
|
329
|
+
Default Model: grok-code-fast-1
|
|
330
|
+
Temperature: 0.7
|
|
331
|
+
...
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Troubleshooting
|
|
335
|
+
|
|
336
|
+
### Issue: Wrong Model Being Used
|
|
337
|
+
|
|
338
|
+
**Check the hierarchy:**
|
|
339
|
+
1. Is `GROK_MODEL` set in your shell? (`echo $GROK_MODEL` or `echo %GROK_MODEL%`)
|
|
340
|
+
2. Did you pass `--model` flag?
|
|
341
|
+
3. Check project `.env`: `cat .grok/.env | grep GROK_MODEL`
|
|
342
|
+
4. Check system `.env`: `cat ~/.grok/.env | grep GROK_MODEL`
|
|
343
|
+
|
|
344
|
+
**Solution:** Unset environment variable if unwanted:
|
|
345
|
+
```bash
|
|
346
|
+
unset GROK_MODEL # Linux/macOS
|
|
347
|
+
set GROK_MODEL= # Windows CMD
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Issue: Configuration Not Loading
|
|
351
|
+
|
|
352
|
+
**Verify file locations:**
|
|
353
|
+
```bash
|
|
354
|
+
# Check if .env exists
|
|
355
|
+
ls -la .grok/.env
|
|
356
|
+
ls -la ~/.grok/.env
|
|
357
|
+
|
|
358
|
+
# Check file contents
|
|
359
|
+
cat .grok/.env
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Common mistakes:**
|
|
363
|
+
- File named `.env.example` instead of `.env`
|
|
364
|
+
- `.env` file in wrong directory
|
|
365
|
+
- Syntax errors in `.env` file (check for quotes, spaces)
|
|
366
|
+
|
|
367
|
+
### Issue: API Key Not Found
|
|
368
|
+
|
|
369
|
+
**Check all possible locations:**
|
|
370
|
+
```bash
|
|
371
|
+
# 1. Check environment variables
|
|
372
|
+
echo $GROK_API_KEY
|
|
373
|
+
echo $X_API_KEY
|
|
374
|
+
|
|
375
|
+
# 2. Check project .env
|
|
376
|
+
grep GROK_API_KEY .grok/.env
|
|
377
|
+
|
|
378
|
+
# 3. Check system .env
|
|
379
|
+
grep GROK_API_KEY ~/.grok/.env
|
|
380
|
+
|
|
381
|
+
# 4. Check root .env
|
|
382
|
+
grep GROK_API_KEY .env
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Security Best Practices
|
|
386
|
+
|
|
387
|
+
### 1. Never Commit `.env` Files
|
|
388
|
+
|
|
389
|
+
Add to `.gitignore`:
|
|
390
|
+
```gitignore
|
|
391
|
+
.env
|
|
392
|
+
.grok/.env
|
|
393
|
+
**/.env
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### 2. Use `.env.example` Templates
|
|
397
|
+
|
|
398
|
+
Commit example files without secrets:
|
|
399
|
+
```bash
|
|
400
|
+
# .env.example
|
|
401
|
+
GROK_API_KEY=xai-your-key-here
|
|
402
|
+
GROK_MODEL=grok-3
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### 3. Use Secret Management in Production
|
|
406
|
+
|
|
407
|
+
For CI/CD and production:
|
|
408
|
+
- GitHub Actions: Use repository secrets
|
|
409
|
+
- GitLab CI: Use CI/CD variables
|
|
410
|
+
- Kubernetes: Use Secrets
|
|
411
|
+
- Docker: Use secrets or environment injection
|
|
412
|
+
|
|
413
|
+
### 4. Restrict File Permissions
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# Make .env readable only by you
|
|
417
|
+
chmod 600 .grok/.env
|
|
418
|
+
chmod 600 ~/.grok/.env
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## Migration from TOML
|
|
422
|
+
|
|
423
|
+
If you have existing `config.toml` files, convert them to `.env`:
|
|
424
|
+
|
|
425
|
+
**Old** (`config.toml`):
|
|
426
|
+
```toml
|
|
427
|
+
default_model = "grok-3"
|
|
428
|
+
default_temperature = 0.7
|
|
429
|
+
timeout_secs = 30
|
|
430
|
+
|
|
431
|
+
[ui]
|
|
432
|
+
colors = true
|
|
433
|
+
progress_bars = true
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**New** (`.env`):
|
|
437
|
+
```bash
|
|
438
|
+
GROK_MODEL=grok-3
|
|
439
|
+
GROK_TEMPERATURE=0.7
|
|
440
|
+
GROK_TIMEOUT=30
|
|
441
|
+
GROK_COLORS=true
|
|
442
|
+
GROK_PROGRESS_BARS=true
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Advanced Usage
|
|
446
|
+
|
|
447
|
+
### Using Multiple Configuration Files
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
# Load specific .env file
|
|
451
|
+
grok --config /path/to/custom/.env
|
|
452
|
+
|
|
453
|
+
# Override with temporary settings
|
|
454
|
+
GROK_MODEL=grok-2 grok query "test"
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Environment Variable Naming Convention
|
|
458
|
+
|
|
459
|
+
All Grok CLI variables follow this pattern:
|
|
460
|
+
```
|
|
461
|
+
GROK_<SECTION>_<SETTING>
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Examples:
|
|
465
|
+
- `GROK_MODEL` - Top-level model setting
|
|
466
|
+
- `GROK_ACP_ENABLED` - ACP section, enabled setting
|
|
467
|
+
- `GROK_LOG_LEVEL` - Logging section, level setting
|
|
468
|
+
|
|
469
|
+
### Programmatic Configuration
|
|
470
|
+
|
|
471
|
+
For scripts and automation:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
#!/bin/bash
|
|
475
|
+
export GROK_API_KEY="${MY_SECRET_KEY}"
|
|
476
|
+
export GROK_MODEL="grok-code-fast-1"
|
|
477
|
+
export GROK_TIMEOUT=60
|
|
478
|
+
|
|
479
|
+
grok query "What is the meaning of life?"
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## Getting Help
|
|
483
|
+
|
|
484
|
+
- Show current configuration: `grok config show`
|
|
485
|
+
- Validate configuration: `grok config validate`
|
|
486
|
+
- View help: `grok --help`
|
|
487
|
+
- Check version: `grok --version`
|
|
488
|
+
|
|
489
|
+
For more information, see the [README](README.md) or [API documentation](docs/API.md).
|