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
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
# Testing Guide: File Access & Zed Integration Fixes
|
|
2
|
+
|
|
3
|
+
## Quick Start Testing
|
|
4
|
+
|
|
5
|
+
### Prerequisites
|
|
6
|
+
```bash
|
|
7
|
+
# Build the latest version
|
|
8
|
+
cd H:\GitHub\grok-cli
|
|
9
|
+
cargo build --release
|
|
10
|
+
|
|
11
|
+
# Verify build
|
|
12
|
+
target\release\grok.exe --version
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Test 1: Basic File Access (Command Line)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Navigate to your project
|
|
19
|
+
cd H:\GitHub\grok-cli
|
|
20
|
+
|
|
21
|
+
# Test relative path
|
|
22
|
+
grok query "read README.md"
|
|
23
|
+
|
|
24
|
+
# Test with ./ prefix
|
|
25
|
+
grok query "read .\Cargo.toml"
|
|
26
|
+
|
|
27
|
+
# Test subdirectory
|
|
28
|
+
grok query "read src\main.rs"
|
|
29
|
+
|
|
30
|
+
# Test parent directory (from subdirectory)
|
|
31
|
+
cd src
|
|
32
|
+
grok query "read ..\README.md"
|
|
33
|
+
cd ..
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Expected:** All commands should successfully read and display file contents
|
|
37
|
+
|
|
38
|
+
**If fails:** Check `.grok/.env` has `GROK_API_KEY` set
|
|
39
|
+
|
|
40
|
+
### Test 2: Configuration Check
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Verify model configuration
|
|
44
|
+
grok config show
|
|
45
|
+
|
|
46
|
+
# Should show:
|
|
47
|
+
# Model: grok-code-fast-1 (or your configured model)
|
|
48
|
+
# Configuration: Project (.grok/.env) or Hierarchical
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**If shows wrong model:**
|
|
52
|
+
```bash
|
|
53
|
+
# Check .grok/.env exists
|
|
54
|
+
type .grok\.env
|
|
55
|
+
|
|
56
|
+
# Should contain:
|
|
57
|
+
# GROK_MODEL=grok-code-fast-1
|
|
58
|
+
|
|
59
|
+
# If not, create it
|
|
60
|
+
echo GROK_MODEL=grok-code-fast-1 > .grok\.env
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Test 3: ACP STDIO Mode (Direct)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Start ACP in stdio mode with logging
|
|
67
|
+
set RUST_LOG=info
|
|
68
|
+
grok acp stdio
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Send test JSON-RPC requests:**
|
|
72
|
+
|
|
73
|
+
1. Initialize:
|
|
74
|
+
```json
|
|
75
|
+
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocol_version":"1.0","client_info":{"name":"test","version":"1.0"}}}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
2. Create session:
|
|
79
|
+
```json
|
|
80
|
+
{"jsonrpc":"2.0","id":2,"method":"session/new","params":{"workspaceRoot":"H:\\GitHub\\grok-cli"}}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Expected log output:**
|
|
84
|
+
```
|
|
85
|
+
INFO Adding workspace root to trusted directories: "H:\\GitHub\\grok-cli"
|
|
86
|
+
INFO Initialized new ACP session: <session-id>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3. Test file read (replace <session-id> with actual ID from response):
|
|
90
|
+
```json
|
|
91
|
+
{"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{"sessionId":"<session-id>","prompt":[{"type":"text","text":"read README.md"}]}}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Expected:** Should return file contents in response
|
|
95
|
+
|
|
96
|
+
Press `Ctrl+C` to stop when done.
|
|
97
|
+
|
|
98
|
+
### Test 4: Zed Editor Integration
|
|
99
|
+
|
|
100
|
+
#### A. Configure Zed
|
|
101
|
+
|
|
102
|
+
Create or edit `%APPDATA%\Zed\settings.json`:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"language_models": {
|
|
107
|
+
"grok": {
|
|
108
|
+
"version": "1",
|
|
109
|
+
"provider": "agent",
|
|
110
|
+
"default_model": "grok-code-fast-1",
|
|
111
|
+
"agent": {
|
|
112
|
+
"command": "H:\\GitHub\\grok-cli\\target\\release\\grok.exe",
|
|
113
|
+
"args": ["acp", "stdio"],
|
|
114
|
+
"env": {
|
|
115
|
+
"GROK_API_KEY": "xai-your-key-here",
|
|
116
|
+
"GROK_MODEL": "grok-code-fast-1"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Important:** Replace `xai-your-key-here` with your actual API key!
|
|
125
|
+
|
|
126
|
+
#### B. Test in Zed
|
|
127
|
+
|
|
128
|
+
1. Open Zed editor
|
|
129
|
+
2. Open a project (File → Open Folder)
|
|
130
|
+
3. Press `Ctrl+Shift+A` to open Assistant
|
|
131
|
+
4. Select "grok" as the model (if multiple configured)
|
|
132
|
+
5. Try these prompts:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
read README.md
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
list files in the current directory
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
read src/main.rs and explain what it does
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Expected:** Should see file contents and AI responses
|
|
147
|
+
|
|
148
|
+
#### C. Debug Zed Integration
|
|
149
|
+
|
|
150
|
+
If it's not working, check logs:
|
|
151
|
+
|
|
152
|
+
**Option 1: Zed Output Panel**
|
|
153
|
+
- View → Output Panel → Assistant
|
|
154
|
+
- Look for errors
|
|
155
|
+
|
|
156
|
+
**Option 2: Run grok-cli with logging manually**
|
|
157
|
+
|
|
158
|
+
1. Stop Zed
|
|
159
|
+
2. Run manually:
|
|
160
|
+
```bash
|
|
161
|
+
set RUST_LOG=debug
|
|
162
|
+
H:\GitHub\grok-cli\target\release\grok.exe acp stdio
|
|
163
|
+
```
|
|
164
|
+
3. Leave this running
|
|
165
|
+
4. Check what messages Zed sends
|
|
166
|
+
5. Look for:
|
|
167
|
+
- "Adding workspace root to trusted directories: ..."
|
|
168
|
+
- "Resolved path to: ..."
|
|
169
|
+
- Any errors
|
|
170
|
+
|
|
171
|
+
### Test 5: Security Verification
|
|
172
|
+
|
|
173
|
+
Test that security is still working:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Should fail - outside workspace
|
|
177
|
+
grok query "read C:\Windows\System32\cmd.exe"
|
|
178
|
+
|
|
179
|
+
# Expected: Error: Access denied: Path is not in a trusted directory
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Should fail - sensitive file
|
|
184
|
+
grok query "read C:\Users\<username>\ntuser.dat"
|
|
185
|
+
|
|
186
|
+
# Expected: Error or Access denied
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Common Issues & Solutions
|
|
190
|
+
|
|
191
|
+
### Issue 1: "API key not configured"
|
|
192
|
+
|
|
193
|
+
**Solution:**
|
|
194
|
+
```bash
|
|
195
|
+
# Check API key
|
|
196
|
+
grok config get api_key
|
|
197
|
+
|
|
198
|
+
# If empty, set it:
|
|
199
|
+
grok config set api_key xai-your-key-here
|
|
200
|
+
|
|
201
|
+
# Or use environment variable:
|
|
202
|
+
set GROK_API_KEY=xai-your-key-here
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Issue 2: "Access denied: Path is not in a trusted directory"
|
|
206
|
+
|
|
207
|
+
**Cause:** Path resolution issue or file outside workspace
|
|
208
|
+
|
|
209
|
+
**Solution:**
|
|
210
|
+
```bash
|
|
211
|
+
# Verify you're in the project directory
|
|
212
|
+
cd
|
|
213
|
+
|
|
214
|
+
# Check the file exists
|
|
215
|
+
dir README.md
|
|
216
|
+
|
|
217
|
+
# Try absolute path
|
|
218
|
+
grok query "read H:\GitHub\grok-cli\README.md"
|
|
219
|
+
|
|
220
|
+
# If that works, it's a relative path issue - check this was fixed:
|
|
221
|
+
grok --version # Should be latest version
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Issue 3: Model not changing
|
|
225
|
+
|
|
226
|
+
**Solution:**
|
|
227
|
+
```bash
|
|
228
|
+
# Check config priority
|
|
229
|
+
grok config show
|
|
230
|
+
|
|
231
|
+
# Create project .env (higher priority than system)
|
|
232
|
+
echo GROK_MODEL=grok-code-fast-1 > .grok\.env
|
|
233
|
+
|
|
234
|
+
# Verify
|
|
235
|
+
grok config show
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Issue 4: Zed can't find grok.exe
|
|
239
|
+
|
|
240
|
+
**Solution:**
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"agent": {
|
|
244
|
+
"command": "H:\\GitHub\\grok-cli\\target\\release\\grok.exe"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Use full path with escaped backslashes!
|
|
250
|
+
|
|
251
|
+
### Issue 5: Workspace not detected in Zed
|
|
252
|
+
|
|
253
|
+
**Check logs:**
|
|
254
|
+
```bash
|
|
255
|
+
# Look for this line when session starts:
|
|
256
|
+
INFO Adding workspace root to trusted directories: ...
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**If missing:**
|
|
260
|
+
- Zed may not be sending workspaceRoot
|
|
261
|
+
- Try setting environment variable in Zed config:
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"env": {
|
|
265
|
+
"WORKSPACE_ROOT": "${workspaceFolder}"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Test Results Checklist
|
|
271
|
+
|
|
272
|
+
Use this to verify all fixes are working:
|
|
273
|
+
|
|
274
|
+
### File Access (Direct CLI)
|
|
275
|
+
- [ ] Read file with relative path (`read README.md`)
|
|
276
|
+
- [ ] Read file with ./ prefix (`read ./Cargo.toml`)
|
|
277
|
+
- [ ] Read file in subdirectory (`read src/main.rs`)
|
|
278
|
+
- [ ] Read file with parent dir (`read ../file.txt`)
|
|
279
|
+
- [ ] Security blocks outside files (`read C:\Windows\...`)
|
|
280
|
+
|
|
281
|
+
### Configuration
|
|
282
|
+
- [ ] Config shows correct model (`grok config show`)
|
|
283
|
+
- [ ] Project .env overrides system config
|
|
284
|
+
- [ ] API key is set
|
|
285
|
+
|
|
286
|
+
### ACP STDIO
|
|
287
|
+
- [ ] Initialize request succeeds
|
|
288
|
+
- [ ] Session/new with workspaceRoot logs "Adding workspace root..."
|
|
289
|
+
- [ ] Session/prompt with file operations works
|
|
290
|
+
|
|
291
|
+
### Zed Integration
|
|
292
|
+
- [ ] Zed launches grok-cli successfully
|
|
293
|
+
- [ ] Assistant panel opens
|
|
294
|
+
- [ ] File operations return results
|
|
295
|
+
- [ ] AI responses appear in Zed
|
|
296
|
+
|
|
297
|
+
## Performance Tests
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Test response time
|
|
301
|
+
Measure-Command { grok query "read README.md" }
|
|
302
|
+
|
|
303
|
+
# Should be: < 5 seconds for normal connections
|
|
304
|
+
# May be: 10-30 seconds with Starlink optimizations
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Debugging Commands
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Full debug output
|
|
311
|
+
set RUST_LOG=debug
|
|
312
|
+
grok acp stdio
|
|
313
|
+
|
|
314
|
+
# Test network
|
|
315
|
+
grok test-network --timeout 10
|
|
316
|
+
|
|
317
|
+
# Health check
|
|
318
|
+
grok health --all
|
|
319
|
+
|
|
320
|
+
# Validate config
|
|
321
|
+
grok config validate
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Success Criteria
|
|
325
|
+
|
|
326
|
+
✅ All file operations work with relative paths
|
|
327
|
+
✅ Zed integration extracts workspace context
|
|
328
|
+
✅ Security still blocks unauthorized access
|
|
329
|
+
✅ All tests pass
|
|
330
|
+
✅ Response times acceptable
|
|
331
|
+
|
|
332
|
+
## Next Steps After Testing
|
|
333
|
+
|
|
334
|
+
1. **If all tests pass:** Ready for production use!
|
|
335
|
+
|
|
336
|
+
2. **If file access works but Zed doesn't show results:**
|
|
337
|
+
- Issue is in response/notification flow
|
|
338
|
+
- Check `session/prompt` response format
|
|
339
|
+
- Debug tool result → SessionUpdate → Zed flow
|
|
340
|
+
|
|
341
|
+
3. **If workspace context missing in Zed:**
|
|
342
|
+
- Verify Zed sends workspaceRoot in session/new
|
|
343
|
+
- Try environment variable fallback
|
|
344
|
+
- Check Zed version compatibility
|
|
345
|
+
|
|
346
|
+
## Getting Help
|
|
347
|
+
|
|
348
|
+
**Enable debug logging:**
|
|
349
|
+
```bash
|
|
350
|
+
set RUST_LOG=debug
|
|
351
|
+
grok acp stdio > debug.log 2>&1
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**Check documentation:**
|
|
355
|
+
- `docs/ZED_INTEGRATION.md` - Zed setup
|
|
356
|
+
- `.grok/FILE_ACCESS_FIX_SUMMARY.md` - Technical details
|
|
357
|
+
- `.grok/ZED_WORKSPACE_ISSUE.md` - Workspace context
|
|
358
|
+
- `.grok/QUICK_REFERENCE.md` - Quick commands
|
|
359
|
+
|
|
360
|
+
**Report issues:**
|
|
361
|
+
- Include debug.log
|
|
362
|
+
- Zed version
|
|
363
|
+
- grok-cli version (`grok --version`)
|
|
364
|
+
- Steps to reproduce
|
|
365
|
+
|
|
366
|
+
## Test Script (PowerShell)
|
|
367
|
+
|
|
368
|
+
Save this as `test-grok.ps1`:
|
|
369
|
+
|
|
370
|
+
```powershell
|
|
371
|
+
# Test grok-cli fixes
|
|
372
|
+
Write-Host "Testing grok-cli file access and Zed integration..." -ForegroundColor Cyan
|
|
373
|
+
|
|
374
|
+
# Test 1: Version
|
|
375
|
+
Write-Host "`n[Test 1] Version check" -ForegroundColor Yellow
|
|
376
|
+
& .\target\release\grok.exe --version
|
|
377
|
+
|
|
378
|
+
# Test 2: Config
|
|
379
|
+
Write-Host "`n[Test 2] Configuration" -ForegroundColor Yellow
|
|
380
|
+
& .\target\release\grok.exe config show
|
|
381
|
+
|
|
382
|
+
# Test 3: File read
|
|
383
|
+
Write-Host "`n[Test 3] File read (README.md)" -ForegroundColor Yellow
|
|
384
|
+
& .\target\release\grok.exe query "read README.md"
|
|
385
|
+
|
|
386
|
+
Write-Host "`n✅ All tests completed!" -ForegroundColor Green
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Run with: `.\test-grok.ps1`
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
**Testing completed!** If all tests pass, the fixes are working correctly.
|