@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.
- package/.npmrc.tmp +2 -0
- package/README.md +72 -0
- package/cmd/cline/main.go +348 -0
- package/cmd/cline-host/main.go +71 -0
- package/e2e/default_update_test.go +154 -0
- package/e2e/helpers_test.go +378 -0
- package/e2e/main_test.go +47 -0
- package/e2e/mixed_stress_test.go +120 -0
- package/e2e/sqlite_helper.go +161 -0
- package/e2e/start_list_test.go +178 -0
- package/go.mod +64 -0
- package/go.sum +162 -0
- package/man/cline.1 +331 -0
- package/man/cline.1.md +332 -0
- package/package.json +54 -0
- package/pkg/cli/auth/auth_cline_provider.go +285 -0
- package/pkg/cli/auth/auth_menu.go +323 -0
- package/pkg/cli/auth/auth_subscription.go +130 -0
- package/pkg/cli/auth/byo_quick_setup.go +247 -0
- package/pkg/cli/auth/models_cline.go +141 -0
- package/pkg/cli/auth/models_list_fetch.go +156 -0
- package/pkg/cli/auth/models_list_static.go +69 -0
- package/pkg/cli/auth/providers_byo.go +184 -0
- package/pkg/cli/auth/providers_list.go +517 -0
- package/pkg/cli/auth/update_api_configurations.go +647 -0
- package/pkg/cli/auth/wizard_byo.go +764 -0
- package/pkg/cli/auth/wizard_byo_bedrock.go +193 -0
- package/pkg/cli/auth/wizard_byo_oca.go +366 -0
- package/pkg/cli/auth.go +43 -0
- package/pkg/cli/clerror/cline_error.go +187 -0
- package/pkg/cli/config/manager.go +208 -0
- package/pkg/cli/config/settings_renderer.go +198 -0
- package/pkg/cli/config.go +152 -0
- package/pkg/cli/display/ansi.go +27 -0
- package/pkg/cli/display/banner.go +211 -0
- package/pkg/cli/display/deduplicator.go +95 -0
- package/pkg/cli/display/markdown_renderer.go +139 -0
- package/pkg/cli/display/renderer.go +304 -0
- package/pkg/cli/display/segment_streamer.go +212 -0
- package/pkg/cli/display/streaming.go +134 -0
- package/pkg/cli/display/system_renderer.go +269 -0
- package/pkg/cli/display/tool_renderer.go +455 -0
- package/pkg/cli/display/tool_result_parser.go +371 -0
- package/pkg/cli/display/typewriter.go +210 -0
- package/pkg/cli/doctor.go +65 -0
- package/pkg/cli/global/cline-clients.go +501 -0
- package/pkg/cli/global/global.go +113 -0
- package/pkg/cli/global/registry.go +304 -0
- package/pkg/cli/handlers/ask_handlers.go +339 -0
- package/pkg/cli/handlers/handler.go +130 -0
- package/pkg/cli/handlers/say_handlers.go +521 -0
- package/pkg/cli/instances.go +506 -0
- package/pkg/cli/logs.go +382 -0
- package/pkg/cli/output/coordinator.go +167 -0
- package/pkg/cli/output/input_model.go +497 -0
- package/pkg/cli/sqlite/locks.go +366 -0
- package/pkg/cli/task/history_handler.go +72 -0
- package/pkg/cli/task/input_handler.go +577 -0
- package/pkg/cli/task/manager.go +1283 -0
- package/pkg/cli/task/settings_parser.go +754 -0
- package/pkg/cli/task/stream_coordinator.go +60 -0
- package/pkg/cli/task.go +675 -0
- package/pkg/cli/terminal/keyboard.go +695 -0
- package/pkg/cli/tui/HELP_WANTED.md +1 -0
- package/pkg/cli/types/history.go +17 -0
- package/pkg/cli/types/messages.go +329 -0
- package/pkg/cli/types/state.go +59 -0
- package/pkg/cli/updater/updater.go +409 -0
- package/pkg/cli/version.go +43 -0
- package/pkg/common/constants.go +6 -0
- package/pkg/common/schema.go +54 -0
- package/pkg/common/types.go +54 -0
- package/pkg/common/utils.go +185 -0
- package/pkg/generated/field_overrides.go +39 -0
- package/pkg/generated/providers.go +1584 -0
- package/pkg/hostbridge/diff.go +351 -0
- package/pkg/hostbridge/disabled/watch.go +39 -0
- package/pkg/hostbridge/disabled/window.go +63 -0
- package/pkg/hostbridge/disabled/workspace.go +66 -0
- package/pkg/hostbridge/env.go +166 -0
- package/pkg/hostbridge/grpc_server.go +113 -0
- package/pkg/hostbridge/simple.go +43 -0
- package/pkg/hostbridge/simple_workspace.go +85 -0
- package/pkg/hostbridge/window.go +129 -0
- package/scripts/publish-caret-cli.sh +39 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
package types
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"fmt"
|
|
6
|
+
"strconv"
|
|
7
|
+
"time"
|
|
8
|
+
|
|
9
|
+
"github.com/cline/grpc-go/cline"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// ClineMessage represents a conversation message in the CLI
|
|
13
|
+
type ClineMessage struct {
|
|
14
|
+
Type MessageType `json:"type"`
|
|
15
|
+
Text string `json:"text"`
|
|
16
|
+
Timestamp int64 `json:"ts"`
|
|
17
|
+
Reasoning string `json:"reasoning,omitempty"`
|
|
18
|
+
Say string `json:"say,omitempty"`
|
|
19
|
+
Ask string `json:"ask,omitempty"`
|
|
20
|
+
Partial bool `json:"partial,omitempty"`
|
|
21
|
+
Images []string `json:"images,omitempty"`
|
|
22
|
+
Files []string `json:"files,omitempty"`
|
|
23
|
+
LastCheckpointHash string `json:"lastCheckpointHash,omitempty"`
|
|
24
|
+
IsCheckpointCheckedOut bool `json:"isCheckpointCheckedOut,omitempty"`
|
|
25
|
+
IsOperationOutsideWorkspace bool `json:"isOperationOutsideWorkspace,omitempty"`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// MessageType represents the type of message
|
|
29
|
+
type MessageType string
|
|
30
|
+
|
|
31
|
+
const (
|
|
32
|
+
MessageTypeAsk MessageType = "ask"
|
|
33
|
+
MessageTypeSay MessageType = "say"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
// AskType represents different types of ASK messages
|
|
37
|
+
type AskType string
|
|
38
|
+
|
|
39
|
+
const (
|
|
40
|
+
AskTypeFollowup AskType = "followup"
|
|
41
|
+
AskTypePlanModeRespond AskType = "plan_mode_respond"
|
|
42
|
+
AskTypeCommand AskType = "command"
|
|
43
|
+
AskTypeCommandOutput AskType = "command_output"
|
|
44
|
+
AskTypeCompletionResult AskType = "completion_result"
|
|
45
|
+
AskTypeTool AskType = "tool"
|
|
46
|
+
AskTypeAPIReqFailed AskType = "api_req_failed"
|
|
47
|
+
AskTypeResumeTask AskType = "resume_task"
|
|
48
|
+
AskTypeResumeCompletedTask AskType = "resume_completed_task"
|
|
49
|
+
AskTypeMistakeLimitReached AskType = "mistake_limit_reached"
|
|
50
|
+
AskTypeBrowserActionLaunch AskType = "browser_action_launch"
|
|
51
|
+
AskTypeUseMcpServer AskType = "use_mcp_server"
|
|
52
|
+
AskTypeNewTask AskType = "new_task"
|
|
53
|
+
AskTypeCondense AskType = "condense"
|
|
54
|
+
AskTypeReportBug AskType = "report_bug"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
// SayType represents different types of SAY messages
|
|
58
|
+
type SayType string
|
|
59
|
+
|
|
60
|
+
const (
|
|
61
|
+
SayTypeTask SayType = "task"
|
|
62
|
+
SayTypeError SayType = "error"
|
|
63
|
+
SayTypeAPIReqStarted SayType = "api_req_started"
|
|
64
|
+
SayTypeAPIReqFinished SayType = "api_req_finished"
|
|
65
|
+
SayTypeText SayType = "text"
|
|
66
|
+
SayTypeReasoning SayType = "reasoning"
|
|
67
|
+
SayTypeCompletionResult SayType = "completion_result"
|
|
68
|
+
SayTypeUserFeedback SayType = "user_feedback"
|
|
69
|
+
SayTypeUserFeedbackDiff SayType = "user_feedback_diff"
|
|
70
|
+
SayTypeAPIReqRetried SayType = "api_req_retried"
|
|
71
|
+
SayTypeErrorRetry SayType = "error_retry"
|
|
72
|
+
SayTypeCommand SayType = "command"
|
|
73
|
+
SayTypeCommandOutput SayType = "command_output"
|
|
74
|
+
SayTypeTool SayType = "tool"
|
|
75
|
+
SayTypeShellIntegrationWarning SayType = "shell_integration_warning"
|
|
76
|
+
SayTypeBrowserActionLaunch SayType = "browser_action_launch"
|
|
77
|
+
SayTypeBrowserAction SayType = "browser_action"
|
|
78
|
+
SayTypeBrowserActionResult SayType = "browser_action_result"
|
|
79
|
+
SayTypeMcpServerRequestStarted SayType = "mcp_server_request_started"
|
|
80
|
+
SayTypeMcpServerResponse SayType = "mcp_server_response"
|
|
81
|
+
SayTypeMcpNotification SayType = "mcp_notification"
|
|
82
|
+
SayTypeUseMcpServer SayType = "use_mcp_server"
|
|
83
|
+
SayTypeDiffError SayType = "diff_error"
|
|
84
|
+
SayTypeDeletedAPIReqs SayType = "deleted_api_reqs"
|
|
85
|
+
SayTypeClineignoreError SayType = "clineignore_error"
|
|
86
|
+
SayTypeCheckpointCreated SayType = "checkpoint_created"
|
|
87
|
+
SayTypeLoadMcpDocumentation SayType = "load_mcp_documentation"
|
|
88
|
+
SayTypeInfo SayType = "info"
|
|
89
|
+
SayTypeTaskProgress SayType = "task_progress"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
// ToolMessage represents a tool-related message
|
|
93
|
+
type ToolMessage struct {
|
|
94
|
+
Tool string `json:"tool"`
|
|
95
|
+
Path string `json:"path,omitempty"`
|
|
96
|
+
Content string `json:"content,omitempty"`
|
|
97
|
+
Diff string `json:"diff,omitempty"`
|
|
98
|
+
Regex string `json:"regex,omitempty"`
|
|
99
|
+
FilePattern string `json:"filePattern,omitempty"`
|
|
100
|
+
OperationIsLocatedInWorkspace *bool `json:"operationIsLocatedInWorkspace,omitempty"`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ToolType represents different types of tools
|
|
104
|
+
type ToolType string
|
|
105
|
+
|
|
106
|
+
const (
|
|
107
|
+
ToolTypeEditedExistingFile ToolType = "editedExistingFile"
|
|
108
|
+
ToolTypeNewFileCreated ToolType = "newFileCreated"
|
|
109
|
+
ToolTypeReadFile ToolType = "readFile"
|
|
110
|
+
ToolTypeFileDeleted ToolType = "fileDeleted"
|
|
111
|
+
ToolTypeListFilesTopLevel ToolType = "listFilesTopLevel"
|
|
112
|
+
ToolTypeListFilesRecursive ToolType = "listFilesRecursive"
|
|
113
|
+
ToolTypeListCodeDefinitionNames ToolType = "listCodeDefinitionNames"
|
|
114
|
+
ToolTypeSearchFiles ToolType = "searchFiles"
|
|
115
|
+
ToolTypeWebFetch ToolType = "webFetch"
|
|
116
|
+
ToolTypeSummarizeTask ToolType = "summarizeTask"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
// AskData represents the parsed structure of an ASK message
|
|
120
|
+
type AskData struct {
|
|
121
|
+
Question string `json:"question"`
|
|
122
|
+
Response string `json:"response"`
|
|
123
|
+
Options []string `json:"options,omitempty"`
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// APIRequestInfo represents API request information
|
|
127
|
+
type APIRequestInfo struct {
|
|
128
|
+
Request string `json:"request,omitempty"`
|
|
129
|
+
TokensIn int `json:"tokensIn,omitempty"`
|
|
130
|
+
TokensOut int `json:"tokensOut,omitempty"`
|
|
131
|
+
CacheWrites int `json:"cacheWrites,omitempty"`
|
|
132
|
+
CacheReads int `json:"cacheReads,omitempty"`
|
|
133
|
+
Cost float64 `json:"cost,omitempty"`
|
|
134
|
+
CancelReason string `json:"cancelReason,omitempty"`
|
|
135
|
+
StreamingFailedMessage string `json:"streamingFailedMessage,omitempty"`
|
|
136
|
+
RetryStatus *APIRequestRetryStatus `json:"retryStatus,omitempty"`
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// APIRequestRetryStatus represents retry status information
|
|
140
|
+
type APIRequestRetryStatus struct {
|
|
141
|
+
Attempt int `json:"attempt"`
|
|
142
|
+
MaxAttempts int `json:"maxAttempts"`
|
|
143
|
+
DelaySec int `json:"delaySec"`
|
|
144
|
+
ErrorSnippet string `json:"errorSnippet,omitempty"`
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// GetTimestamp returns a formatted timestamp string
|
|
148
|
+
func (m *ClineMessage) GetTimestamp() string {
|
|
149
|
+
return time.Unix(m.Timestamp/1000, 0).Format("15:04:05")
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// IsAsk returns true if this is an ASK message
|
|
153
|
+
func (m *ClineMessage) IsAsk() bool {
|
|
154
|
+
return m.Type == MessageTypeAsk
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// IsSay returns true if this is a SAY message
|
|
158
|
+
func (m *ClineMessage) IsSay() bool {
|
|
159
|
+
return m.Type == MessageTypeSay
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// GetMessageKey returns a unique key for this message based on timestamp
|
|
163
|
+
func (m *ClineMessage) GetMessageKey() string {
|
|
164
|
+
return strconv.FormatInt(m.Timestamp, 10)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ExtractMessagesFromStateJSON parses the state JSON and extracts messages
|
|
168
|
+
func ExtractMessagesFromStateJSON(stateJson string) ([]*ClineMessage, error) {
|
|
169
|
+
// Parse the state JSON to extract clineMessages
|
|
170
|
+
var rawState map[string]interface{}
|
|
171
|
+
if err := json.Unmarshal([]byte(stateJson), &rawState); err != nil {
|
|
172
|
+
return nil, fmt.Errorf("failed to parse state JSON: %w", err)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Try to extract clineMessages
|
|
176
|
+
clineMessagesRaw, exists := rawState["clineMessages"]
|
|
177
|
+
if !exists {
|
|
178
|
+
return []*ClineMessage{}, nil
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Convert to JSON and back to get proper Message structs
|
|
182
|
+
clineMessagesJson, err := json.Marshal(clineMessagesRaw)
|
|
183
|
+
if err != nil {
|
|
184
|
+
return nil, fmt.Errorf("failed to marshal clineMessages: %w", err)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var messages []*ClineMessage
|
|
188
|
+
if err := json.Unmarshal(clineMessagesJson, &messages); err != nil {
|
|
189
|
+
return nil, fmt.Errorf("failed to unmarshal clineMessages: %w", err)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return messages, nil
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ConvertProtoToMessage converts a protobuf ClineMessage to our local Message struct
|
|
196
|
+
func ConvertProtoToMessage(protoMsg *cline.ClineMessage) *ClineMessage {
|
|
197
|
+
var msgType MessageType
|
|
198
|
+
var say, ask string
|
|
199
|
+
|
|
200
|
+
// Convert message type
|
|
201
|
+
switch protoMsg.Type {
|
|
202
|
+
case cline.ClineMessageType_ASK:
|
|
203
|
+
msgType = MessageTypeAsk
|
|
204
|
+
ask = convertProtoAskType(protoMsg.Ask)
|
|
205
|
+
case cline.ClineMessageType_SAY:
|
|
206
|
+
msgType = MessageTypeSay
|
|
207
|
+
say = convertProtoSayType(protoMsg.Say)
|
|
208
|
+
default:
|
|
209
|
+
msgType = MessageTypeSay
|
|
210
|
+
say = "unknown"
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return &ClineMessage{
|
|
214
|
+
Type: msgType,
|
|
215
|
+
Text: protoMsg.Text,
|
|
216
|
+
Timestamp: protoMsg.Ts,
|
|
217
|
+
Reasoning: protoMsg.Reasoning,
|
|
218
|
+
Say: say,
|
|
219
|
+
Ask: ask,
|
|
220
|
+
Partial: protoMsg.Partial,
|
|
221
|
+
LastCheckpointHash: protoMsg.LastCheckpointHash,
|
|
222
|
+
IsCheckpointCheckedOut: protoMsg.IsCheckpointCheckedOut,
|
|
223
|
+
IsOperationOutsideWorkspace: protoMsg.IsOperationOutsideWorkspace,
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// convertProtoAskType converts protobuf ask type to string
|
|
228
|
+
func convertProtoAskType(askType cline.ClineAsk) string {
|
|
229
|
+
switch askType {
|
|
230
|
+
case cline.ClineAsk_FOLLOWUP:
|
|
231
|
+
return string(AskTypeFollowup)
|
|
232
|
+
case cline.ClineAsk_PLAN_MODE_RESPOND:
|
|
233
|
+
return string(AskTypePlanModeRespond)
|
|
234
|
+
case cline.ClineAsk_COMMAND:
|
|
235
|
+
return string(AskTypeCommand)
|
|
236
|
+
case cline.ClineAsk_COMMAND_OUTPUT:
|
|
237
|
+
return string(AskTypeCommandOutput)
|
|
238
|
+
case cline.ClineAsk_COMPLETION_RESULT:
|
|
239
|
+
return string(AskTypeCompletionResult)
|
|
240
|
+
case cline.ClineAsk_TOOL:
|
|
241
|
+
return string(AskTypeTool)
|
|
242
|
+
case cline.ClineAsk_API_REQ_FAILED:
|
|
243
|
+
return string(AskTypeAPIReqFailed)
|
|
244
|
+
case cline.ClineAsk_RESUME_TASK:
|
|
245
|
+
return string(AskTypeResumeTask)
|
|
246
|
+
case cline.ClineAsk_RESUME_COMPLETED_TASK:
|
|
247
|
+
return string(AskTypeResumeCompletedTask)
|
|
248
|
+
case cline.ClineAsk_MISTAKE_LIMIT_REACHED:
|
|
249
|
+
return string(AskTypeMistakeLimitReached)
|
|
250
|
+
case cline.ClineAsk_BROWSER_ACTION_LAUNCH:
|
|
251
|
+
return string(AskTypeBrowserActionLaunch)
|
|
252
|
+
case cline.ClineAsk_USE_MCP_SERVER:
|
|
253
|
+
return string(AskTypeUseMcpServer)
|
|
254
|
+
case cline.ClineAsk_NEW_TASK:
|
|
255
|
+
return string(AskTypeNewTask)
|
|
256
|
+
case cline.ClineAsk_CONDENSE:
|
|
257
|
+
return string(AskTypeCondense)
|
|
258
|
+
case cline.ClineAsk_REPORT_BUG:
|
|
259
|
+
return string(AskTypeReportBug)
|
|
260
|
+
default:
|
|
261
|
+
return "unknown"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// convertProtoSayType converts protobuf say type to string
|
|
266
|
+
func convertProtoSayType(sayType cline.ClineSay) string {
|
|
267
|
+
switch sayType {
|
|
268
|
+
case cline.ClineSay_TASK:
|
|
269
|
+
return string(SayTypeTask)
|
|
270
|
+
case cline.ClineSay_ERROR:
|
|
271
|
+
return string(SayTypeError)
|
|
272
|
+
case cline.ClineSay_API_REQ_STARTED:
|
|
273
|
+
return string(SayTypeAPIReqStarted)
|
|
274
|
+
case cline.ClineSay_API_REQ_FINISHED:
|
|
275
|
+
return string(SayTypeAPIReqFinished)
|
|
276
|
+
case cline.ClineSay_TEXT:
|
|
277
|
+
return string(SayTypeText)
|
|
278
|
+
case cline.ClineSay_REASONING:
|
|
279
|
+
return string(SayTypeReasoning)
|
|
280
|
+
case cline.ClineSay_COMPLETION_RESULT_SAY:
|
|
281
|
+
return string(SayTypeCompletionResult)
|
|
282
|
+
case cline.ClineSay_USER_FEEDBACK:
|
|
283
|
+
return string(SayTypeUserFeedback)
|
|
284
|
+
case cline.ClineSay_USER_FEEDBACK_DIFF:
|
|
285
|
+
return string(SayTypeUserFeedbackDiff)
|
|
286
|
+
case cline.ClineSay_API_REQ_RETRIED:
|
|
287
|
+
return string(SayTypeAPIReqRetried)
|
|
288
|
+
case cline.ClineSay_ERROR_RETRY:
|
|
289
|
+
return string(SayTypeErrorRetry)
|
|
290
|
+
case cline.ClineSay_COMMAND_SAY:
|
|
291
|
+
return string(SayTypeCommand)
|
|
292
|
+
case cline.ClineSay_COMMAND_OUTPUT_SAY:
|
|
293
|
+
return string(SayTypeCommandOutput)
|
|
294
|
+
case cline.ClineSay_TOOL_SAY:
|
|
295
|
+
return string(SayTypeTool)
|
|
296
|
+
case cline.ClineSay_SHELL_INTEGRATION_WARNING:
|
|
297
|
+
return string(SayTypeShellIntegrationWarning)
|
|
298
|
+
case cline.ClineSay_BROWSER_ACTION_LAUNCH_SAY:
|
|
299
|
+
return string(SayTypeBrowserActionLaunch)
|
|
300
|
+
case cline.ClineSay_BROWSER_ACTION:
|
|
301
|
+
return string(SayTypeBrowserAction)
|
|
302
|
+
case cline.ClineSay_BROWSER_ACTION_RESULT:
|
|
303
|
+
return string(SayTypeBrowserActionResult)
|
|
304
|
+
case cline.ClineSay_MCP_SERVER_REQUEST_STARTED:
|
|
305
|
+
return string(SayTypeMcpServerRequestStarted)
|
|
306
|
+
case cline.ClineSay_MCP_SERVER_RESPONSE:
|
|
307
|
+
return string(SayTypeMcpServerResponse)
|
|
308
|
+
case cline.ClineSay_MCP_NOTIFICATION:
|
|
309
|
+
return string(SayTypeMcpNotification)
|
|
310
|
+
case cline.ClineSay_USE_MCP_SERVER_SAY:
|
|
311
|
+
return string(SayTypeUseMcpServer)
|
|
312
|
+
case cline.ClineSay_DIFF_ERROR:
|
|
313
|
+
return string(SayTypeDiffError)
|
|
314
|
+
case cline.ClineSay_DELETED_API_REQS:
|
|
315
|
+
return string(SayTypeDeletedAPIReqs)
|
|
316
|
+
case cline.ClineSay_CLINEIGNORE_ERROR:
|
|
317
|
+
return string(SayTypeClineignoreError)
|
|
318
|
+
case cline.ClineSay_CHECKPOINT_CREATED:
|
|
319
|
+
return string(SayTypeCheckpointCreated)
|
|
320
|
+
case cline.ClineSay_LOAD_MCP_DOCUMENTATION:
|
|
321
|
+
return string(SayTypeLoadMcpDocumentation)
|
|
322
|
+
case cline.ClineSay_INFO:
|
|
323
|
+
return string(SayTypeInfo)
|
|
324
|
+
case cline.ClineSay_TASK_PROGRESS:
|
|
325
|
+
return string(SayTypeTaskProgress)
|
|
326
|
+
default:
|
|
327
|
+
return "unknown"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package types
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"sync"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
// ConversationState manages the state of the conversation
|
|
8
|
+
type ConversationState struct {
|
|
9
|
+
mu sync.RWMutex
|
|
10
|
+
StreamingMessage *StreamingMessage `json:"streamingMessage,omitempty"`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// StreamingMessage manages state for streaming message display
|
|
14
|
+
type StreamingMessage struct {
|
|
15
|
+
CurrentKey string `json:"currentKey"`
|
|
16
|
+
LastText string `json:"lastText"`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// NewConversationState creates a new conversation state
|
|
20
|
+
func NewConversationState() *ConversationState {
|
|
21
|
+
return &ConversationState{
|
|
22
|
+
StreamingMessage: &StreamingMessage{},
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// SetStreamingMessage updates the streaming message state
|
|
27
|
+
func (cs *ConversationState) SetStreamingMessage(key, text string) {
|
|
28
|
+
cs.mu.Lock()
|
|
29
|
+
defer cs.mu.Unlock()
|
|
30
|
+
cs.StreamingMessage.CurrentKey = key
|
|
31
|
+
cs.StreamingMessage.LastText = text
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// GetStreamingMessage returns the current streaming message state
|
|
35
|
+
func (cs *ConversationState) GetStreamingMessage() *StreamingMessage {
|
|
36
|
+
cs.mu.RLock()
|
|
37
|
+
defer cs.mu.RUnlock()
|
|
38
|
+
return &StreamingMessage{
|
|
39
|
+
CurrentKey: cs.StreamingMessage.CurrentKey,
|
|
40
|
+
LastText: cs.StreamingMessage.LastText,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Clear resets state
|
|
45
|
+
func (cs *ConversationState) Clear() {
|
|
46
|
+
cs.mu.Lock()
|
|
47
|
+
defer cs.mu.Unlock()
|
|
48
|
+
cs.StreamingMessage = &StreamingMessage{}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ExtensionState represents the server-side extension state structure
|
|
52
|
+
type ExtensionState struct {
|
|
53
|
+
CurrentTaskItem *CurrentTaskItem `json:"currentTaskItem,omitempty"`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// CurrentTaskItem - minimal struct with just what we need
|
|
57
|
+
type CurrentTaskItem struct {
|
|
58
|
+
Id string `json:"id"`
|
|
59
|
+
}
|