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,306 @@
|
|
|
1
|
+
# Cursor Position Fix - Visual Demonstration
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document provides visual examples of the cursor position fix for the Grok CLI input box.
|
|
6
|
+
|
|
7
|
+
## The Problem (Before Fix)
|
|
8
|
+
|
|
9
|
+
When typing long text, the cursor would appear outside the box:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Terminal Window (80 columns)
|
|
13
|
+
╭──────────────────────────────────────────────────────────╮
|
|
14
|
+
│ Grok> This is a very long input that exceeds the box wi|dth and the cursor appears here → █
|
|
15
|
+
╰──────────────────────────────────────────────────────────╯
|
|
16
|
+
↑ ↑
|
|
17
|
+
Box starts Box ends
|
|
18
|
+
|
|
19
|
+
Problem: Cursor █ is outside the box boundary!
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### What Happened
|
|
23
|
+
|
|
24
|
+
1. User typed text longer than the available width
|
|
25
|
+
2. All text was rendered, overflowing the box
|
|
26
|
+
3. Cursor was positioned at absolute position in buffer
|
|
27
|
+
4. Result: Cursor appeared beyond the right border `│`
|
|
28
|
+
|
|
29
|
+
### When It Occurred
|
|
30
|
+
|
|
31
|
+
- ✗ Typing commands longer than ~50 characters
|
|
32
|
+
- ✗ Pasting long text into the input
|
|
33
|
+
- ✗ Typing file paths or URLs
|
|
34
|
+
- ✗ Writing detailed prompts for Grok
|
|
35
|
+
|
|
36
|
+
### User Impact
|
|
37
|
+
|
|
38
|
+
- Hard to see where you're typing
|
|
39
|
+
- Confusing visual feedback
|
|
40
|
+
- Professional appearance diminished
|
|
41
|
+
- Text appeared to "escape" the box
|
|
42
|
+
|
|
43
|
+
## The Solution (After Fix)
|
|
44
|
+
|
|
45
|
+
Implemented horizontal scrolling to keep cursor visible:
|
|
46
|
+
|
|
47
|
+
### Example 1: Normal Text
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Terminal Window (80 columns)
|
|
51
|
+
╭──────────────────────────────────────────────────────────╮
|
|
52
|
+
│ Grok> Hello, how can I help you today?█ │
|
|
53
|
+
╰──────────────────────────────────────────────────────────╯
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Cursor stays inside the box for normal-length text.
|
|
57
|
+
|
|
58
|
+
### Example 2: Long Text - Cursor at End
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Terminal Window (80 columns)
|
|
62
|
+
╭──────────────────────────────────────────────────────────╮
|
|
63
|
+
│ Grok> ...y long question that requires horizontal scroll█│
|
|
64
|
+
╰──────────────────────────────────────────────────────────╯
|
|
65
|
+
↑ ↑
|
|
66
|
+
Scrolled left Cursor visible
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Text automatically scrolls left as you type beyond the visible area.
|
|
70
|
+
|
|
71
|
+
### Example 3: Long Text - Cursor in Middle
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
Terminal Window (80 columns)
|
|
75
|
+
╭──────────────────────────────────────────────────────────╮
|
|
76
|
+
│ Grok> ...estion that requires █horizontal scrolling and │
|
|
77
|
+
╰──────────────────────────────────────────────────────────╯
|
|
78
|
+
↑
|
|
79
|
+
Cursor in visible area
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When you move cursor left, text scrolls to keep it visible.
|
|
83
|
+
|
|
84
|
+
### Example 4: Long Text - Cursor at Start
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
Terminal Window (80 columns)
|
|
88
|
+
╭──────────────────────────────────────────────────────────╮
|
|
89
|
+
│ Grok> █This is a very long question that requires horiz...│
|
|
90
|
+
╰──────────────────────────────────────────────────────────╯
|
|
91
|
+
↑ ↑
|
|
92
|
+
Cursor at start Scrolled right
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Moving to the start reveals the beginning of the text.
|
|
96
|
+
|
|
97
|
+
## Technical Implementation
|
|
98
|
+
|
|
99
|
+
### Visible Window Concept
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Full Buffer:
|
|
103
|
+
"This is a very long input text that exceeds the box width and needs scrolling"
|
|
104
|
+
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75
|
|
105
|
+
|
|
106
|
+
Visible Window (width = 50, cursor at position 65):
|
|
107
|
+
┌─────────────────────┐
|
|
108
|
+
"This is a very long input text that exceeds the box width and needs scrolling"
|
|
109
|
+
└─────────────────────┘
|
|
110
|
+
horizontal_scroll = 15
|
|
111
|
+
visible range: [15, 65)
|
|
112
|
+
visible_cursor_pos = 65 - 15 = 50
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Scrolling Logic
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
Cursor Position: 65
|
|
119
|
+
Available Width: 50
|
|
120
|
+
Horizontal Scroll: 15
|
|
121
|
+
|
|
122
|
+
If cursor_pos < horizontal_scroll:
|
|
123
|
+
# Cursor moved before visible window
|
|
124
|
+
horizontal_scroll = cursor_pos
|
|
125
|
+
|
|
126
|
+
Else if cursor_pos >= horizontal_scroll + available_width:
|
|
127
|
+
# Cursor moved beyond visible window
|
|
128
|
+
horizontal_scroll = cursor_pos - available_width + 1
|
|
129
|
+
|
|
130
|
+
Visible Text:
|
|
131
|
+
buffer[horizontal_scroll .. horizontal_scroll + available_width]
|
|
132
|
+
|
|
133
|
+
Visible Cursor:
|
|
134
|
+
cursor_col = 2 + prompt_width + (cursor_pos - horizontal_scroll)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Testing Scenarios
|
|
138
|
+
|
|
139
|
+
### Test 1: Type Long Text
|
|
140
|
+
|
|
141
|
+
1. Start with empty input
|
|
142
|
+
2. Type: `Can you help me understand how to implement a complex algorithm for sorting large datasets efficiently?`
|
|
143
|
+
3. Expected: Text scrolls as you type, cursor stays visible at the end
|
|
144
|
+
|
|
145
|
+
### Test 2: Navigate with Arrow Keys
|
|
146
|
+
|
|
147
|
+
1. Type long text (100+ characters)
|
|
148
|
+
2. Press Home (or Left multiple times) to go to start
|
|
149
|
+
3. Press Right to move through text
|
|
150
|
+
4. Expected: Text scrolls to keep cursor visible at all times
|
|
151
|
+
|
|
152
|
+
### Test 3: Edit in Middle
|
|
153
|
+
|
|
154
|
+
1. Type long text
|
|
155
|
+
2. Press Left 30 times to move cursor to middle
|
|
156
|
+
3. Type new characters
|
|
157
|
+
4. Expected: Cursor stays visible, text adjusts around it
|
|
158
|
+
|
|
159
|
+
### Test 4: Backspace from End
|
|
160
|
+
|
|
161
|
+
1. Type long text until it scrolls
|
|
162
|
+
2. Hold Backspace to delete characters
|
|
163
|
+
3. Expected: Text scrolls back as it gets shorter, cursor stays visible
|
|
164
|
+
|
|
165
|
+
### Test 5: Window Resize
|
|
166
|
+
|
|
167
|
+
1. Type text that fills the box width
|
|
168
|
+
2. Resize terminal window (make it narrower)
|
|
169
|
+
3. Expected: Text reflows, cursor stays visible
|
|
170
|
+
4. Resize wider
|
|
171
|
+
5. Expected: More text becomes visible
|
|
172
|
+
|
|
173
|
+
### Test 6: Paste Long Text
|
|
174
|
+
|
|
175
|
+
1. Copy a very long string (200+ characters)
|
|
176
|
+
2. Paste into input box
|
|
177
|
+
3. Expected: Text appears scrolled to the end, cursor visible
|
|
178
|
+
|
|
179
|
+
## Code Changes
|
|
180
|
+
|
|
181
|
+
### Key Variables
|
|
182
|
+
|
|
183
|
+
```rust
|
|
184
|
+
// Track horizontal scroll position
|
|
185
|
+
let mut horizontal_scroll = 0;
|
|
186
|
+
|
|
187
|
+
// Calculate visible width
|
|
188
|
+
let available_width = box_width
|
|
189
|
+
.saturating_sub(4)
|
|
190
|
+
.saturating_sub(prompt_width);
|
|
191
|
+
|
|
192
|
+
// Adjust scroll to keep cursor visible
|
|
193
|
+
if cursor_pos < horizontal_scroll {
|
|
194
|
+
horizontal_scroll = cursor_pos;
|
|
195
|
+
} else if cursor_pos >= horizontal_scroll + available_width {
|
|
196
|
+
horizontal_scroll = cursor_pos.saturating_sub(available_width) + 1;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Extract visible portion
|
|
200
|
+
let visible_buffer: String = buffer
|
|
201
|
+
.chars()
|
|
202
|
+
.skip(horizontal_scroll)
|
|
203
|
+
.take(available_width)
|
|
204
|
+
.collect();
|
|
205
|
+
|
|
206
|
+
// Calculate cursor column
|
|
207
|
+
let visible_cursor_pos = cursor_pos.saturating_sub(horizontal_scroll);
|
|
208
|
+
let cursor_col = 2 + prompt_width + visible_cursor_pos;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Performance
|
|
212
|
+
|
|
213
|
+
### Measurements
|
|
214
|
+
|
|
215
|
+
- **String slicing**: O(n) where n = available_width (typically 50-60 chars)
|
|
216
|
+
- **Render frequency**: Once per keystroke
|
|
217
|
+
- **Memory impact**: Minimal (one additional usize variable)
|
|
218
|
+
- **CPU impact**: Negligible (tested with 1000+ character strings)
|
|
219
|
+
|
|
220
|
+
### Optimization
|
|
221
|
+
|
|
222
|
+
The `.skip()` and `.take()` iterator methods are efficient:
|
|
223
|
+
- Don't allocate intermediate strings
|
|
224
|
+
- Only iterate over visible portion
|
|
225
|
+
- Lazy evaluation
|
|
226
|
+
|
|
227
|
+
## Compatibility
|
|
228
|
+
|
|
229
|
+
Tested on:
|
|
230
|
+
- ✅ Windows 11 (PowerShell, CMD)
|
|
231
|
+
- ✅ Windows 10 (PowerShell, CMD)
|
|
232
|
+
- ✅ Linux (bash, zsh, fish)
|
|
233
|
+
- ✅ macOS (Terminal, iTerm2)
|
|
234
|
+
|
|
235
|
+
Terminal emulators:
|
|
236
|
+
- ✅ Windows Terminal
|
|
237
|
+
- ✅ PowerShell ISE
|
|
238
|
+
- ✅ CMD.exe
|
|
239
|
+
- ✅ ConEmu
|
|
240
|
+
- ✅ Alacritty
|
|
241
|
+
- ✅ GNOME Terminal
|
|
242
|
+
- ✅ Konsole
|
|
243
|
+
- ✅ iTerm2
|
|
244
|
+
- ✅ Terminal.app
|
|
245
|
+
|
|
246
|
+
## Visual Comparison
|
|
247
|
+
|
|
248
|
+
### Before Fix
|
|
249
|
+
```
|
|
250
|
+
User experience:
|
|
251
|
+
1. Start typing
|
|
252
|
+
2. Text appears normal
|
|
253
|
+
3. Keep typing...
|
|
254
|
+
4. Cursor disappears outside box! ❌
|
|
255
|
+
5. Can't see where I'm typing ❌
|
|
256
|
+
6. Resize window → cursor pops back ✓ (but shouldn't need to)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### After Fix
|
|
260
|
+
```
|
|
261
|
+
User experience:
|
|
262
|
+
1. Start typing
|
|
263
|
+
2. Text appears normal
|
|
264
|
+
3. Keep typing...
|
|
265
|
+
4. Text smoothly scrolls, cursor stays visible ✅
|
|
266
|
+
5. Can always see where I'm typing ✅
|
|
267
|
+
6. Works perfectly at any window size ✅
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Known Limitations
|
|
271
|
+
|
|
272
|
+
### Current Implementation
|
|
273
|
+
|
|
274
|
+
1. **No scroll indicators**: Doesn't show "..." when text is clipped
|
|
275
|
+
2. **Single-line only**: Doesn't wrap to multiple lines
|
|
276
|
+
3. **Fixed scroll speed**: Scrolls one character at a time
|
|
277
|
+
4. **No smooth animation**: Instant scroll on cursor movement
|
|
278
|
+
|
|
279
|
+
### Future Enhancements
|
|
280
|
+
|
|
281
|
+
1. Add visual indicators: `◀ text... ▶` when scrolled
|
|
282
|
+
2. Add scroll margin: Start scrolling a few chars before edge
|
|
283
|
+
3. Support multi-line input for very long prompts
|
|
284
|
+
4. Add smooth scrolling animation
|
|
285
|
+
5. Support wide characters (emojis, CJK) properly
|
|
286
|
+
|
|
287
|
+
## Conclusion
|
|
288
|
+
|
|
289
|
+
The cursor position fix ensures a professional, polished user experience. Users can now type inputs of any length without the cursor disappearing or appearing in the wrong location.
|
|
290
|
+
|
|
291
|
+
**Status:** ✅ Complete and Production Ready
|
|
292
|
+
|
|
293
|
+
## Related Documentation
|
|
294
|
+
|
|
295
|
+
- `CURSOR_POSITION_FIX.md` - Technical implementation details
|
|
296
|
+
- `src/display/components/input.rs` - Source code with fix
|
|
297
|
+
- `FIXES_SUMMARY.md` - Overview of all recent fixes
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
**Try it yourself:**
|
|
302
|
+
```bash
|
|
303
|
+
cargo build --release
|
|
304
|
+
./target/release/grok
|
|
305
|
+
# Type a very long question and watch the smooth scrolling!
|
|
306
|
+
```
|