@caretive/caret-cli 0.0.1

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 (85) hide show
  1. package/.npmrc.tmp +2 -0
  2. package/README.md +72 -0
  3. package/cmd/cline/main.go +348 -0
  4. package/cmd/cline-host/main.go +71 -0
  5. package/e2e/default_update_test.go +154 -0
  6. package/e2e/helpers_test.go +378 -0
  7. package/e2e/main_test.go +47 -0
  8. package/e2e/mixed_stress_test.go +120 -0
  9. package/e2e/sqlite_helper.go +161 -0
  10. package/e2e/start_list_test.go +178 -0
  11. package/go.mod +64 -0
  12. package/go.sum +162 -0
  13. package/man/cline.1 +331 -0
  14. package/man/cline.1.md +332 -0
  15. package/package.json +54 -0
  16. package/pkg/cli/auth/auth_cline_provider.go +285 -0
  17. package/pkg/cli/auth/auth_menu.go +323 -0
  18. package/pkg/cli/auth/auth_subscription.go +130 -0
  19. package/pkg/cli/auth/byo_quick_setup.go +247 -0
  20. package/pkg/cli/auth/models_cline.go +141 -0
  21. package/pkg/cli/auth/models_list_fetch.go +156 -0
  22. package/pkg/cli/auth/models_list_static.go +69 -0
  23. package/pkg/cli/auth/providers_byo.go +184 -0
  24. package/pkg/cli/auth/providers_list.go +517 -0
  25. package/pkg/cli/auth/update_api_configurations.go +647 -0
  26. package/pkg/cli/auth/wizard_byo.go +764 -0
  27. package/pkg/cli/auth/wizard_byo_bedrock.go +193 -0
  28. package/pkg/cli/auth/wizard_byo_oca.go +366 -0
  29. package/pkg/cli/auth.go +43 -0
  30. package/pkg/cli/clerror/cline_error.go +187 -0
  31. package/pkg/cli/config/manager.go +208 -0
  32. package/pkg/cli/config/settings_renderer.go +198 -0
  33. package/pkg/cli/config.go +152 -0
  34. package/pkg/cli/display/ansi.go +27 -0
  35. package/pkg/cli/display/banner.go +211 -0
  36. package/pkg/cli/display/deduplicator.go +95 -0
  37. package/pkg/cli/display/markdown_renderer.go +139 -0
  38. package/pkg/cli/display/renderer.go +304 -0
  39. package/pkg/cli/display/segment_streamer.go +212 -0
  40. package/pkg/cli/display/streaming.go +134 -0
  41. package/pkg/cli/display/system_renderer.go +269 -0
  42. package/pkg/cli/display/tool_renderer.go +455 -0
  43. package/pkg/cli/display/tool_result_parser.go +371 -0
  44. package/pkg/cli/display/typewriter.go +210 -0
  45. package/pkg/cli/doctor.go +65 -0
  46. package/pkg/cli/global/cline-clients.go +501 -0
  47. package/pkg/cli/global/global.go +113 -0
  48. package/pkg/cli/global/registry.go +304 -0
  49. package/pkg/cli/handlers/ask_handlers.go +339 -0
  50. package/pkg/cli/handlers/handler.go +130 -0
  51. package/pkg/cli/handlers/say_handlers.go +521 -0
  52. package/pkg/cli/instances.go +506 -0
  53. package/pkg/cli/logs.go +382 -0
  54. package/pkg/cli/output/coordinator.go +167 -0
  55. package/pkg/cli/output/input_model.go +497 -0
  56. package/pkg/cli/sqlite/locks.go +366 -0
  57. package/pkg/cli/task/history_handler.go +72 -0
  58. package/pkg/cli/task/input_handler.go +577 -0
  59. package/pkg/cli/task/manager.go +1283 -0
  60. package/pkg/cli/task/settings_parser.go +754 -0
  61. package/pkg/cli/task/stream_coordinator.go +60 -0
  62. package/pkg/cli/task.go +675 -0
  63. package/pkg/cli/terminal/keyboard.go +695 -0
  64. package/pkg/cli/tui/HELP_WANTED.md +1 -0
  65. package/pkg/cli/types/history.go +17 -0
  66. package/pkg/cli/types/messages.go +329 -0
  67. package/pkg/cli/types/state.go +59 -0
  68. package/pkg/cli/updater/updater.go +409 -0
  69. package/pkg/cli/version.go +43 -0
  70. package/pkg/common/constants.go +6 -0
  71. package/pkg/common/schema.go +54 -0
  72. package/pkg/common/types.go +54 -0
  73. package/pkg/common/utils.go +185 -0
  74. package/pkg/generated/field_overrides.go +39 -0
  75. package/pkg/generated/providers.go +1584 -0
  76. package/pkg/hostbridge/diff.go +351 -0
  77. package/pkg/hostbridge/disabled/watch.go +39 -0
  78. package/pkg/hostbridge/disabled/window.go +63 -0
  79. package/pkg/hostbridge/disabled/workspace.go +66 -0
  80. package/pkg/hostbridge/env.go +166 -0
  81. package/pkg/hostbridge/grpc_server.go +113 -0
  82. package/pkg/hostbridge/simple.go +43 -0
  83. package/pkg/hostbridge/simple_workspace.go +85 -0
  84. package/pkg/hostbridge/window.go +129 -0
  85. package/scripts/publish-caret-cli.sh +39 -0
@@ -0,0 +1,269 @@
1
+ package display
2
+
3
+ import (
4
+ "fmt"
5
+ "strings"
6
+
7
+ "github.com/cline/cli/pkg/cli/clerror"
8
+ )
9
+
10
+ // ErrorSeverity represents the severity level of an error
11
+ type ErrorSeverity string
12
+
13
+ const (
14
+ SeverityCritical ErrorSeverity = "critical"
15
+ SeverityWarning ErrorSeverity = "warning"
16
+ SeverityInfo ErrorSeverity = "info"
17
+ )
18
+
19
+ // SystemMessageRenderer handles rendering of system messages (errors, warnings, info)
20
+ type SystemMessageRenderer struct {
21
+ renderer *Renderer
22
+ mdRenderer *MarkdownRenderer
23
+ outputFormat string
24
+ }
25
+
26
+ // NewSystemMessageRenderer creates a new system message renderer
27
+ func NewSystemMessageRenderer(renderer *Renderer, mdRenderer *MarkdownRenderer, outputFormat string) *SystemMessageRenderer {
28
+ return &SystemMessageRenderer{
29
+ renderer: renderer,
30
+ mdRenderer: mdRenderer,
31
+ outputFormat: outputFormat,
32
+ }
33
+ }
34
+
35
+ // RenderError renders a beautiful error message with optional details
36
+ func (sr *SystemMessageRenderer) RenderError(severity ErrorSeverity, title, body string, details map[string]string) error {
37
+ var colorMarkdown string
38
+
39
+ switch severity {
40
+ case SeverityCritical:
41
+ colorMarkdown = "**[ERROR]**"
42
+ case SeverityWarning:
43
+ colorMarkdown = "**[WARNING]**"
44
+ case SeverityInfo:
45
+ colorMarkdown = "**[INFO]**"
46
+ }
47
+
48
+ // Build the error message in markdown
49
+ var parts []string
50
+
51
+ // Header
52
+ header := fmt.Sprintf("### %s %s", colorMarkdown, title)
53
+ parts = append(parts, header)
54
+
55
+ // Body
56
+ if body != "" {
57
+ parts = append(parts, "", body)
58
+ }
59
+
60
+ // Details
61
+ if len(details) > 0 {
62
+ parts = append(parts, "", "**Details:**")
63
+ for key, value := range details {
64
+ parts = append(parts, fmt.Sprintf("- %s: `%s`", key, value))
65
+ }
66
+ }
67
+
68
+ markdown := strings.Join(parts, "\n")
69
+ rendered := sr.renderer.RenderMarkdown(markdown)
70
+ fmt.Printf("\n%s\n", rendered)
71
+
72
+ return nil
73
+ }
74
+
75
+ // RenderBalanceError renders a special balance/credits error with helpful info
76
+ func (sr *SystemMessageRenderer) RenderBalanceError(err *clerror.ClineError) error {
77
+ var parts []string
78
+
79
+ // Header
80
+ parts = append(parts, "### **[ERROR]** Credit Limit Reached")
81
+ parts = append(parts, "")
82
+
83
+ // Message - prefer detail message from error.details, fallback to main message
84
+ message := err.Message
85
+ if detailMsg := err.GetDetailMessage(); detailMsg != "" {
86
+ message = detailMsg
87
+ }
88
+ parts = append(parts, message)
89
+ parts = append(parts, "")
90
+
91
+ // Account Balance section
92
+ parts = append(parts, "**Account Balance:**")
93
+
94
+ // Current balance
95
+ if balance := err.GetCurrentBalance(); balance != nil {
96
+ parts = append(parts, fmt.Sprintf("- Current Balance: **$%.2f**", *balance))
97
+ }
98
+
99
+ // Total spent
100
+ if spent := err.GetTotalSpent(); spent != nil {
101
+ parts = append(parts, fmt.Sprintf("- Total Spent: $%.2f", *spent))
102
+ }
103
+
104
+ // Promotions applied
105
+ if promos := err.GetTotalPromotions(); promos != nil {
106
+ parts = append(parts, fmt.Sprintf("- Promotions Applied: $%.2f", *promos))
107
+ }
108
+
109
+ parts = append(parts, "")
110
+
111
+ // Buy credits link
112
+ if url := err.GetBuyCreditsURL(); url != "" {
113
+ parts = append(parts, fmt.Sprintf("**→ Buy credits:** %s", url))
114
+ } else {
115
+ // Fallback - show both personal and org URLs
116
+ parts = append(parts, "**→ Buy credits:**")
117
+ parts = append(parts, " - Personal: https://app.cline.bot/dashboard/account?tab=credits")
118
+ parts = append(parts, " - Organization: https://app.cline.bot/dashboard/organization?tab=credits")
119
+ }
120
+
121
+ // Request ID (less prominent at the end)
122
+ if err.RequestID != "" {
123
+ parts = append(parts, "")
124
+ parts = append(parts, fmt.Sprintf("*Request ID: %s*", err.RequestID))
125
+ }
126
+
127
+ markdown := strings.Join(parts, "\n")
128
+ rendered := sr.renderer.RenderMarkdown(markdown)
129
+ fmt.Printf("\n%s\n", rendered)
130
+
131
+ return nil
132
+ }
133
+
134
+ // RenderAuthError renders an authentication error with helpful guidance
135
+ func (sr *SystemMessageRenderer) RenderAuthError(err *clerror.ClineError) error {
136
+ var parts []string
137
+
138
+ // Header
139
+ parts = append(parts, "### **[ERROR]** Authentication Failed")
140
+ parts = append(parts, "")
141
+
142
+ // Message - prefer detail message if available
143
+ message := err.Message
144
+ if detailMsg := err.GetDetailMessage(); detailMsg != "" {
145
+ message = detailMsg
146
+ }
147
+ parts = append(parts, message)
148
+ parts = append(parts, "")
149
+
150
+ // Guidance
151
+ parts = append(parts, "**Next Steps:**")
152
+ parts = append(parts, "- Check your API key configuration")
153
+ parts = append(parts, "- Run `cline auth` to authenticate")
154
+ parts = append(parts, "- Verify your account status at https://app.cline.bot")
155
+
156
+ // Request ID
157
+ if err.RequestID != "" {
158
+ parts = append(parts, "")
159
+ parts = append(parts, fmt.Sprintf("*Request ID: `%s`*", err.RequestID))
160
+ }
161
+
162
+ markdown := strings.Join(parts, "\n")
163
+ rendered := sr.renderer.RenderMarkdown(markdown)
164
+ fmt.Printf("\n%s\n", rendered)
165
+
166
+ return nil
167
+ }
168
+
169
+ // RenderRateLimitError renders a rate limit error with request ID
170
+ func (sr *SystemMessageRenderer) RenderRateLimitError(err *clerror.ClineError) error {
171
+ var parts []string
172
+
173
+ // Header
174
+ parts = append(parts, "### **[WARNING]** Rate Limit Reached")
175
+ parts = append(parts, "")
176
+
177
+ // Message - prefer detail message if available
178
+ message := err.Message
179
+ if detailMsg := err.GetDetailMessage(); detailMsg != "" {
180
+ message = detailMsg
181
+ }
182
+ parts = append(parts, message)
183
+ parts = append(parts, "")
184
+
185
+ // Guidance
186
+ parts = append(parts, "The API will automatically retry this request.")
187
+
188
+ // Request ID
189
+ if err.RequestID != "" {
190
+ parts = append(parts, "")
191
+ parts = append(parts, fmt.Sprintf("*Request ID: `%s`*", err.RequestID))
192
+ }
193
+
194
+ markdown := strings.Join(parts, "\n")
195
+ rendered := sr.renderer.RenderMarkdown(markdown)
196
+ fmt.Printf("\n%s\n", rendered)
197
+
198
+ return nil
199
+ }
200
+
201
+ // RenderAPIError renders a generic API error with all available details
202
+ func (sr *SystemMessageRenderer) RenderAPIError(err *clerror.ClineError) error {
203
+ var parts []string
204
+
205
+ // Header
206
+ parts = append(parts, "### **[ERROR]** API Request Failed")
207
+ parts = append(parts, "")
208
+
209
+ // Message - prefer detail message if available
210
+ message := err.Message
211
+ if detailMsg := err.GetDetailMessage(); detailMsg != "" {
212
+ message = detailMsg
213
+ }
214
+ parts = append(parts, message)
215
+
216
+ // Details
217
+ var details []string
218
+ if err.RequestID != "" {
219
+ details = append(details, fmt.Sprintf("- Request ID: `%s`", err.RequestID))
220
+ }
221
+ if code := err.GetCodeString(); code != "" {
222
+ details = append(details, fmt.Sprintf("- Error Code: `%s`", code))
223
+ }
224
+ if err.Status > 0 {
225
+ details = append(details, fmt.Sprintf("- HTTP Status: `%d`", err.Status))
226
+ }
227
+ if err.ModelID != "" {
228
+ details = append(details, fmt.Sprintf("- Model: `%s`", err.ModelID))
229
+ }
230
+ if err.ProviderID != "" {
231
+ details = append(details, fmt.Sprintf("- Provider: `%s`", err.ProviderID))
232
+ }
233
+
234
+ if len(details) > 0 {
235
+ parts = append(parts, "")
236
+ parts = append(parts, "**Details:**")
237
+ parts = append(parts, strings.Join(details, "\n"))
238
+ }
239
+
240
+ markdown := strings.Join(parts, "\n")
241
+ rendered := sr.renderer.RenderMarkdown(markdown)
242
+ fmt.Printf("\n%s\n", rendered)
243
+
244
+ return nil
245
+ }
246
+
247
+ // RenderWarning renders a warning message
248
+ func (sr *SystemMessageRenderer) RenderWarning(title, message string) error {
249
+ markdown := fmt.Sprintf("### **[WARNING]** %s\n\n%s", title, message)
250
+ rendered := sr.renderer.RenderMarkdown(markdown)
251
+ fmt.Printf("\n%s\n", rendered)
252
+ return nil
253
+ }
254
+
255
+ // RenderInfo renders an info message
256
+ func (sr *SystemMessageRenderer) RenderInfo(title, message string) error {
257
+ markdown := fmt.Sprintf("### **[INFO]** %s\n\n%s", title, message)
258
+ rendered := sr.renderer.RenderMarkdown(markdown)
259
+ fmt.Printf("\n%s\n", rendered)
260
+ return nil
261
+ }
262
+
263
+ // RenderCheckpoint renders a checkpoint creation message
264
+ func (sr *SystemMessageRenderer) RenderCheckpoint(timestamp string, id int64) error {
265
+ markdown := fmt.Sprintf("## [%s] Checkpoint created `%d`", timestamp, id)
266
+ rendered := sr.renderer.RenderMarkdown(markdown)
267
+ fmt.Printf(rendered)
268
+ return nil
269
+ }