--- Legacy parsing functions --- Deprecated: These are kept only for existing tests in memory_worker_test.go. Production code uses memory.Manager.ProcessExtraction() with the enhanced parser. parseMemoryResponse splits the LLM response into daily notes and long-term facts. nolint:unused // used by
(response string)
| 476 | // |
| 477 | //nolint:unused // used by memory_worker_test; golangci run.tests=false hides the call site. |
| 478 | func parseMemoryResponse(response string) (daily string, longTerm string) { |
| 479 | upper := strings.ToUpper(response) |
| 480 | |
| 481 | dailyIdx := findSectionIndex(upper, "DAILY") |
| 482 | longTermIdx := findSectionIndex(upper, "LONGTERM") |
| 483 | if longTermIdx < 0 { |
| 484 | longTermIdx = findSectionIndex(upper, "LONG-TERM") |
| 485 | } |
| 486 | if longTermIdx < 0 { |
| 487 | longTermIdx = findSectionIndex(upper, "LONG_TERM") |
| 488 | } |
| 489 | |
| 490 | extractAfter := func(idx int) string { |
| 491 | nlIdx := strings.Index(response[idx:], "\n") |
| 492 | if nlIdx < 0 { |
| 493 | return "" |
| 494 | } |
| 495 | return strings.TrimSpace(response[idx+nlIdx+1:]) |
| 496 | } |
| 497 | |
| 498 | switch { |
| 499 | case dailyIdx >= 0 && longTermIdx >= 0: |
| 500 | if dailyIdx < longTermIdx { |
| 501 | nlIdx := strings.Index(response[dailyIdx:], "\n") |
| 502 | if nlIdx >= 0 { |
| 503 | daily = strings.TrimSpace(response[dailyIdx+nlIdx+1 : longTermIdx]) |
| 504 | } |
| 505 | longTerm = extractAfter(longTermIdx) |
| 506 | } else { |
| 507 | nlIdx := strings.Index(response[longTermIdx:], "\n") |
| 508 | if nlIdx >= 0 { |
| 509 | longTerm = strings.TrimSpace(response[longTermIdx+nlIdx+1 : dailyIdx]) |
| 510 | } |
| 511 | daily = extractAfter(dailyIdx) |
| 512 | } |
| 513 | case dailyIdx >= 0: |
| 514 | daily = extractAfter(dailyIdx) |
| 515 | case longTermIdx >= 0: |
| 516 | longTerm = extractAfter(longTermIdx) |
| 517 | default: |
| 518 | daily = response |
| 519 | } |
| 520 | |
| 521 | if isNothingNew(daily) { |
| 522 | daily = "" |
| 523 | } |
| 524 | if isNothingNew(longTerm) { |
| 525 | longTerm = "" |
| 526 | } |
| 527 | |
| 528 | return daily, longTerm |
| 529 | } |
| 530 | |
| 531 | func isNothingNew(s string) bool { |
| 532 | normalized := strings.ToUpper(strings.TrimSpace(s)) |