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.
Files changed (100) hide show
  1. package/.env.example +42 -0
  2. package/.github/workflows/ci.yml +30 -0
  3. package/.github/workflows/rust.yml +22 -0
  4. package/.grok/.env.example +85 -0
  5. package/.grok/COMPLETE_FIX_SUMMARY.md +466 -0
  6. package/.grok/ENV_CONFIG_GUIDE.md +173 -0
  7. package/.grok/QUICK_REFERENCE.md +180 -0
  8. package/.grok/README.md +104 -0
  9. package/.grok/TESTING_GUIDE.md +393 -0
  10. package/CHANGELOG.md +465 -0
  11. package/CODE_REVIEW_SUMMARY.md +414 -0
  12. package/COMPLETE_FIX_SUMMARY.md +415 -0
  13. package/CONFIGURATION.md +489 -0
  14. package/CONTEXT_FILES_GUIDE.md +419 -0
  15. package/CONTRIBUTING.md +55 -0
  16. package/CURSOR_POSITION_FIX.md +206 -0
  17. package/Cargo.toml +88 -0
  18. package/ERROR_HANDLING_REPORT.md +361 -0
  19. package/FINAL_FIX_SUMMARY.md +462 -0
  20. package/FIXES.md +37 -0
  21. package/FIXES_SUMMARY.md +87 -0
  22. package/GROK_API_MIGRATION_SUMMARY.md +111 -0
  23. package/LICENSE +22 -0
  24. package/MIGRATION_TO_GROK_API.md +223 -0
  25. package/README.md +504 -0
  26. package/REVIEW_COMPLETE.md +416 -0
  27. package/REVIEW_QUICK_REFERENCE.md +173 -0
  28. package/SECURITY.md +463 -0
  29. package/SECURITY_AUDIT.md +661 -0
  30. package/SETUP.md +287 -0
  31. package/TESTING_TOOLS.md +88 -0
  32. package/TESTING_TOOL_EXECUTION.md +239 -0
  33. package/TOOL_EXECUTION_FIX.md +491 -0
  34. package/VERIFICATION_CHECKLIST.md +419 -0
  35. package/docs/API.md +74 -0
  36. package/docs/CHAT_LOGGING.md +39 -0
  37. package/docs/CURSOR_FIX_DEMO.md +306 -0
  38. package/docs/ERROR_HANDLING_GUIDE.md +547 -0
  39. package/docs/FILE_OPERATIONS.md +449 -0
  40. package/docs/INTERACTIVE.md +401 -0
  41. package/docs/PROJECT_CREATION_GUIDE.md +570 -0
  42. package/docs/QUICKSTART.md +378 -0
  43. package/docs/QUICK_REFERENCE.md +691 -0
  44. package/docs/RELEASE_NOTES_0.1.2.md +240 -0
  45. package/docs/TOOLS.md +459 -0
  46. package/docs/TOOLS_QUICK_REFERENCE.md +210 -0
  47. package/docs/ZED_INTEGRATION.md +371 -0
  48. package/docs/extensions.md +464 -0
  49. package/docs/settings.md +293 -0
  50. package/examples/extensions/logging-hook/README.md +91 -0
  51. package/examples/extensions/logging-hook/extension.json +22 -0
  52. package/package.json +30 -0
  53. package/scripts/test_acp.py +252 -0
  54. package/scripts/test_acp.sh +143 -0
  55. package/scripts/test_acp_simple.sh +72 -0
  56. package/src/acp/mod.rs +741 -0
  57. package/src/acp/protocol.rs +323 -0
  58. package/src/acp/security.rs +298 -0
  59. package/src/acp/tools.rs +697 -0
  60. package/src/bin/banner_demo.rs +216 -0
  61. package/src/bin/docgen.rs +18 -0
  62. package/src/bin/installer.rs +217 -0
  63. package/src/cli/app.rs +310 -0
  64. package/src/cli/commands/acp.rs +721 -0
  65. package/src/cli/commands/chat.rs +485 -0
  66. package/src/cli/commands/code.rs +513 -0
  67. package/src/cli/commands/config.rs +394 -0
  68. package/src/cli/commands/health.rs +442 -0
  69. package/src/cli/commands/history.rs +421 -0
  70. package/src/cli/commands/mod.rs +14 -0
  71. package/src/cli/commands/settings.rs +1384 -0
  72. package/src/cli/mod.rs +166 -0
  73. package/src/config/mod.rs +2212 -0
  74. package/src/display/ascii_art.rs +139 -0
  75. package/src/display/banner.rs +289 -0
  76. package/src/display/components/input.rs +323 -0
  77. package/src/display/components/mod.rs +2 -0
  78. package/src/display/components/settings_list.rs +306 -0
  79. package/src/display/interactive.rs +1255 -0
  80. package/src/display/mod.rs +62 -0
  81. package/src/display/terminal.rs +42 -0
  82. package/src/display/tips.rs +316 -0
  83. package/src/grok_client_ext.rs +177 -0
  84. package/src/hooks/loader.rs +407 -0
  85. package/src/hooks/mod.rs +158 -0
  86. package/src/lib.rs +174 -0
  87. package/src/main.rs +65 -0
  88. package/src/mcp/client.rs +195 -0
  89. package/src/mcp/config.rs +20 -0
  90. package/src/mcp/mod.rs +6 -0
  91. package/src/mcp/protocol.rs +67 -0
  92. package/src/utils/auth.rs +41 -0
  93. package/src/utils/chat_logger.rs +568 -0
  94. package/src/utils/context.rs +390 -0
  95. package/src/utils/mod.rs +16 -0
  96. package/src/utils/network.rs +320 -0
  97. package/src/utils/rate_limiter.rs +166 -0
  98. package/src/utils/session.rs +73 -0
  99. package/src/utils/shell_permissions.rs +389 -0
  100. package/src/utils/telemetry.rs +41 -0
@@ -0,0 +1,143 @@
1
+ #!/bin/bash
2
+ # Test script for ACP stdio communication
3
+
4
+ echo "Testing ACP stdio mode..."
5
+ echo ""
6
+
7
+ # Set environment to show debug logs
8
+ export RUST_LOG=grok_cli=info
9
+
10
+ # Create a temporary file for the ACP conversation
11
+ TEMP_INPUT=$(mktemp)
12
+ TEMP_OUTPUT=$(mktemp)
13
+
14
+ # Cleanup on exit
15
+ trap "rm -f $TEMP_INPUT $TEMP_OUTPUT" EXIT
16
+
17
+ # Step 1: Initialize
18
+ echo "Step 1: Sending initialize request..."
19
+ echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"1","clientInfo":{"name":"test-client","version":"1.0.0"}}}' | ./target/release/grok.exe acp stdio > $TEMP_OUTPUT 2>&1 &
20
+ GROK_PID=$!
21
+ sleep 2
22
+
23
+ # Get the session ID from the response
24
+ SESSION_ID=$(grep -o '"sessionId":"[^"]*"' $TEMP_OUTPUT | head -1 | cut -d'"' -f4)
25
+
26
+ if [ -z "$SESSION_ID" ]; then
27
+ echo "Failed to get session ID, creating
28
+ full test..."
29
+
30
+ # Write all ACP protocol messages in one go
31
+ cat > $TEMP_INPUT <<'EOF'
32
+ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"1","clientInfo":{"name":"test-client","version":"1.0.0"}}}
33
+ {"jsonrpc":"2.0","id":2,"method":"session/new","params":{}}
34
+ EOF
35
+
36
+ echo ""
37
+ echo "=== Sending initialization messages ==="
38
+ cat $TEMP_INPUT
39
+ echo ""
40
+
41
+ # Get session ID from session/new
42
+ cat $TEMP_INPUT | ./target/release/grok.exe acp stdio 2>&1 | tee $TEMP_OUTPUT &
43
+ GROK_PID=$!
44
+ sleep 3
45
+
46
+ # Extract session ID from output
47
+ SESSION_ID=$(grep -o '"sessionId":"[^"]*"' $TEMP_OUTPUT | head -1 | cut -d'"' -f4)
48
+
49
+ if [ -z "$SESSION_ID" ]; then
50
+ echo "❌ Could not extract session ID from response"
51
+ echo ""
52
+ echo "=== Full Output ==="
53
+ cat $TEMP_OUTPUT
54
+ exit 1
55
+ fi
56
+
57
+ echo "✓ Got session ID: $SESSION_ID"
58
+ fi
59
+
60
+ # Now create a complete test with the actual session ID
61
+ cat > $TEMP_INPUT <<EOF
62
+ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"1","clientInfo":{"name":"test-client","version":"1.0.0"}}}
63
+ {"jsonrpc":"2.0","id":2,"method":"session/new","params":{}}
64
+ {"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{"sessionId":"$SESSION_ID","prompt":[{"type":"text","text":"Hello, please respond with exactly: Hello World!"}]}}
65
+ EOF
66
+
67
+ echo ""
68
+ echo "=== Running complete ACP test ==="
69
+ echo "Using session ID: $SESSION_ID"
70
+ echo ""
71
+ echo "=== Input messages ==="
72
+ cat $TEMP_INPUT
73
+ echo ""
74
+ echo "=== Response from grok ==="
75
+ echo ""
76
+
77
+ # Run grok in ACP stdio mode with timeout
78
+ timeout 15s bash -c "cat $TEMP_INPUT | ./target/release/grok.exe acp stdio 2>&1" | tee $TEMP_OUTPUT
79
+
80
+ echo ""
81
+ echo "=== Analysis ==="
82
+ echo ""
83
+
84
+ # Check for initialize response
85
+ if grep -q '"id":1' $TEMP_OUTPUT && grep -q '"result"' $TEMP_OUTPUT; then
86
+ echo "✓ Initialize response received"
87
+ else
88
+ echo "❌ No initialize response found"
89
+ fi
90
+
91
+ # Check for session/new response
92
+ if grep -q '"id":2' $TEMP_OUTPUT && grep -q '"sessionId"' $TEMP_OUTPUT; then
93
+ echo "✓ Session created successfully"
94
+ else
95
+ echo "❌ No session creation response found"
96
+ fi
97
+
98
+ # Check for session/update notifications
99
+ if grep -q 'session/update' $TEMP_OUTPUT; then
100
+ echo "✓ session/update notification found"
101
+
102
+ # Count how many chunks
103
+ CHUNK_COUNT=$(grep -c 'session/update' $TEMP_OUTPUT)
104
+ echo " Found $CHUNK_COUNT update notification(s)"
105
+ else
106
+ echo "❌ No session/update notifications found"
107
+ fi
108
+
109
+ # Check for agent_message_chunk
110
+ if grep -q 'agent_message_chunk' $TEMP_OUTPUT; then
111
+ echo "✓ agent_message_chunk found"
112
+ else
113
+ echo "❌ No agent_message_chunk found"
114
+ fi
115
+
116
+ # Check for content in the update
117
+ if grep -q '"text"' $TEMP_OUTPUT && grep -q 'Hello' $TEMP_OUTPUT; then
118
+ echo "✓ Text content found in response"
119
+
120
+ # Extract and display the content
121
+ echo ""
122
+ echo "=== Extracted Content ==="
123
+ grep -o '"text":"[^"]*"' $TEMP_OUTPUT | cut -d'"' -f4
124
+ else
125
+ echo "❌ No text content found in response"
126
+ fi
127
+
128
+ # Check for stopReason
129
+ if grep -q '"stopReason"' $TEMP_OUTPUT; then
130
+ echo "✓ stopReason found in final response"
131
+ else
132
+ echo "❌ No stopReason found"
133
+ fi
134
+
135
+ # Check for errors
136
+ if grep -q '"error"' $TEMP_OUTPUT; then
137
+ echo ""
138
+ echo "⚠️ Errors detected:"
139
+ grep '"error"' $TEMP_OUTPUT
140
+ fi
141
+
142
+ echo ""
143
+ echo "=== Test Complete ==="
@@ -0,0 +1,72 @@
1
+ #!/bin/bash
2
+ # Simple ACP test - sends all messages in one stream
3
+
4
+ echo "=== Testing ACP stdio mode ==="
5
+ echo ""
6
+
7
+ # Set log level
8
+ export RUST_LOG=grok_cli=info
9
+
10
+ # Create a test script that will feed all messages at once
11
+ # and keep the connection open
12
+ {
13
+ # 1. Initialize
14
+ echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"1","clientInfo":{"name":"test-client","version":"1.0.0"}}}'
15
+
16
+ # 2. Create new session
17
+ echo '{"jsonrpc":"2.0","id":2,"method":"session/new","params":{}}'
18
+
19
+ # Small delay to let it process
20
+ sleep 1
21
+
22
+ # 3. Send prompt - NOTE: We need to extract the session ID from step 2 response
23
+ # For this simple test, we'll use a placeholder and manually check the output
24
+ # In real usage, Zed would parse the session ID from the session/new response
25
+
26
+ # We need to get the session ID dynamically, so let's use a different approach
27
+ } | ./target/release/grok.exe acp stdio 2>&1 | tee /tmp/acp_test_output.txt &
28
+
29
+ GROK_PID=$!
30
+ sleep 3
31
+
32
+ # Extract session ID from output
33
+ SESSION_ID=$(grep -o '"sessionId":"[^"]*"' /tmp/acp_test_output.txt | head -1 | cut -d'"' -f4)
34
+
35
+ if [ -z "$SESSION_ID" ]; then
36
+ echo "❌ Could not get session ID from initial setup"
37
+ cat /tmp/acp_test_output.txt
38
+ kill $GROK_PID 2>/dev/null
39
+ exit 1
40
+ fi
41
+
42
+ echo "✓ Got session ID: $SESSION_ID"
43
+ echo ""
44
+
45
+ # Now run the full test with actual session ID
46
+ echo "=== Running full ACP conversation ==="
47
+ echo ""
48
+
49
+ (
50
+ echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"1","clientInfo":{"name":"test-client","version":"1.0.0"}}}'
51
+ echo '{"jsonrpc":"2.0","id":2,"method":"session/new","params":{}}'
52
+
53
+ # Wait a moment for session creation
54
+ sleep 2
55
+
56
+ # Send the prompt with the correct session ID
57
+ # We'll extract it from the previous response
58
+ cat <<EOF | while read line; do
59
+ if echo "$line" | grep -q "sessionId"; then
60
+ SESS_ID=\$(echo "\$line" | grep -o '"sessionId":"[^"]*"' | cut -d'"' -f4)
61
+ echo "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"session/prompt\",\"params\":{\"sessionId\":\"\$SESS_ID\",\"prompt\":[{\"type\":\"text\",\"text\":\"Say exactly: Hello World!\"}]}}"
62
+ fi
63
+ echo "\$line" >&2
64
+ done
65
+ EOF
66
+
67
+ # Keep connection alive for response
68
+ sleep 10
69
+ ) | ./target/release/grok.exe acp stdio 2>&1
70
+
71
+ echo ""
72
+ echo "=== Test Complete ==="