parseActiveFile extracts the active file name and extension from prompt
(prompt string)
| 376 | |
| 377 | // parseActiveFile extracts the active file name and extension from prompt |
| 378 | func parseActiveFile(prompt string) (string, string) { |
| 379 | start := strings.Index(prompt, "<ACTIVE-EDITOR-FILE>") |
| 380 | if start == -1 { |
| 381 | return "", "" |
| 382 | } |
| 383 | end := strings.Index(prompt[start:], "</ACTIVE-EDITOR-FILE>") |
| 384 | if end == -1 { |
| 385 | return "", "" |
| 386 | } |
| 387 | block := prompt[start : start+end] |
| 388 | nameStart := strings.Index(block, "name=\"") |
| 389 | if nameStart == -1 { |
| 390 | return "", "" |
| 391 | } |
| 392 | nameStart += len("name=\"") |
| 393 | nameEnd := strings.Index(block[nameStart:], "\"") |
| 394 | if nameEnd == -1 { |
| 395 | return "", "" |
| 396 | } |
| 397 | fileName := block[nameStart : nameStart+nameEnd] |
| 398 | ext := filepath.Ext(fileName) |
| 399 | return fileName, ext |
| 400 | } |
| 401 | |
| 402 | func parseCompletionRecord(raw json.RawMessage, fileMeta *models.QDevS3FileMeta, identityClient UserDisplayNameResolver, cache *sync.Map) (*models.QDevCompletionLog, error) { |
| 403 | var record completionLogRecord |