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
package/src/cli/mod.rs ADDED
@@ -0,0 +1,166 @@
1
+ //! CLI command handlers and utilities for grok-cli
2
+ //!
3
+ //! This module contains all the command-line interface logic, including
4
+ //! argument parsing, command dispatch, and user interaction utilities.
5
+
6
+ pub mod app;
7
+ pub mod commands;
8
+
9
+ use anyhow::Result;
10
+ use colored::*;
11
+ use indicatif::{ProgressBar, ProgressStyle};
12
+ use std::io::{self, Write};
13
+
14
+ /// Create a progress spinner with the given message
15
+ pub fn create_spinner(message: &str) -> ProgressBar {
16
+ let pb = ProgressBar::new_spinner();
17
+ pb.set_style(
18
+ ProgressStyle::default_spinner()
19
+ .tick_strings(&["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
20
+ .template("{spinner:.green} {msg}")
21
+ .unwrap(),
22
+ );
23
+ pb.set_message(message.to_string());
24
+ pb.enable_steady_tick(std::time::Duration::from_millis(100));
25
+ pb
26
+ }
27
+
28
+ /// Print a success message with green color
29
+ pub fn print_success(message: &str) {
30
+ println!("{} {}", "✓".green(), message);
31
+ }
32
+
33
+ /// Print an error message with red color
34
+ pub fn print_error(message: &str) {
35
+ eprintln!("{} {}", "✗".red(), message);
36
+ }
37
+
38
+ /// Print a warning message with yellow color
39
+ pub fn print_warning(message: &str) {
40
+ println!("{} {}", "⚠".yellow(), message);
41
+ }
42
+
43
+ /// Print an info message with blue color
44
+ pub fn print_info(message: &str) {
45
+ println!("{} {}", "ℹ".blue(), message);
46
+ }
47
+
48
+ /// Prompt user for confirmation
49
+ pub fn confirm(message: &str) -> Result<bool> {
50
+ print!("{} {} [y/N]: ", "?".cyan(), message);
51
+ io::stdout().flush()?;
52
+
53
+ let mut input = String::new();
54
+ io::stdin().read_line(&mut input)?;
55
+
56
+ Ok(input.trim().to_lowercase() == "y" || input.trim().to_lowercase() == "yes")
57
+ }
58
+
59
+ /// Format code with syntax highlighting (simplified version)
60
+ pub fn format_code(code: &str, language: Option<&str>) -> String {
61
+ // For now, just return the code as-is with some basic formatting
62
+ // In a full implementation, you'd use a syntax highlighter like syntect
63
+ let header = match language {
64
+ Some(lang) => format!("```{}", lang),
65
+ None => "```".to_string(),
66
+ };
67
+
68
+ format!("{}\n{}\n```", header, code)
69
+ }
70
+
71
+ /// Format a response from Grok with nice styling
72
+ pub fn format_grok_response(response: &str, show_thinking: bool) -> String {
73
+ let mut formatted = String::new();
74
+
75
+ if show_thinking {
76
+ formatted.push_str(&format!("{}\n", "🤔 Grok's response:".cyan()));
77
+ }
78
+
79
+ formatted.push_str("┌─────────────────────────────────────────────────────┐\n");
80
+
81
+ // Split response into lines and format each one
82
+ for line in response.lines() {
83
+ formatted.push_str(&format!("│ {:<51} │\n", line));
84
+ }
85
+
86
+ formatted.push_str("└─────────────────────────────────────────────────────┘\n");
87
+ formatted
88
+ }
89
+
90
+ /// Truncate text to fit in terminal width
91
+ pub fn truncate_text(text: &str, max_width: usize) -> String {
92
+ if text.len() <= max_width {
93
+ text.to_string()
94
+ } else {
95
+ format!("{}...", &text[..max_width.saturating_sub(3)])
96
+ }
97
+ }
98
+
99
+ /// Get terminal width, defaulting to 80 if unable to determine
100
+ pub fn get_terminal_width() -> usize {
101
+ terminal_size::terminal_size()
102
+ .map(|(terminal_size::Width(w), _)| w as usize)
103
+ .unwrap_or(80)
104
+ }
105
+
106
+ /// Format a table with headers and rows
107
+ pub fn format_table(headers: &[&str], rows: &[Vec<String>]) -> String {
108
+ let mut table = String::new();
109
+ let terminal_width = get_terminal_width();
110
+ let col_width = (terminal_width - headers.len() - 1) / headers.len();
111
+
112
+ // Header
113
+ table.push('┌');
114
+ for (i, _) in headers.iter().enumerate() {
115
+ if i > 0 {
116
+ table.push('┬');
117
+ }
118
+ table.push_str(&"─".repeat(col_width));
119
+ }
120
+ table.push_str("┐\n");
121
+
122
+ // Header content
123
+ table.push('│');
124
+ for header in headers {
125
+ let formatted_header = format!(" {:<width$} ", header, width = col_width - 2);
126
+ table.push_str(&truncate_text(&formatted_header, col_width));
127
+ table.push('│');
128
+ }
129
+ table.push('\n');
130
+
131
+ // Separator
132
+ table.push('├');
133
+ for (i, _) in headers.iter().enumerate() {
134
+ if i > 0 {
135
+ table.push('┼');
136
+ }
137
+ table.push_str(&"─".repeat(col_width));
138
+ }
139
+ table.push_str("┤\n");
140
+
141
+ // Rows
142
+ for row in rows {
143
+ table.push('│');
144
+ for (i, cell) in row.iter().enumerate() {
145
+ if i >= headers.len() {
146
+ break;
147
+ }
148
+ let formatted_cell = format!(" {:<width$} ", cell, width = col_width - 2);
149
+ table.push_str(&truncate_text(&formatted_cell, col_width));
150
+ table.push('│');
151
+ }
152
+ table.push('\n');
153
+ }
154
+
155
+ // Bottom
156
+ table.push('└');
157
+ for (i, _) in headers.iter().enumerate() {
158
+ if i > 0 {
159
+ table.push('┴');
160
+ }
161
+ table.push_str(&"─".repeat(col_width));
162
+ }
163
+ table.push_str("┘\n");
164
+
165
+ table
166
+ }