(stdout: string, minScore: number, limit: number)
| 57 | * unit testing of the parser without a live gbrain. |
| 58 | */ |
| 59 | export function parseSearchHits(stdout: string, minScore: number, limit: number): SemanticHit[] { |
| 60 | const hits: SemanticHit[] = []; |
| 61 | for (const line of stdout.split("\n")) { |
| 62 | const m = line.match(/^\[([\d.]+)\]\s+(\S+)\s+--\s+(.*)$/); |
| 63 | if (!m) continue; |
| 64 | const score = parseFloat(m[1]); |
| 65 | if (!Number.isFinite(score) || score < minScore) continue; |
| 66 | hits.push({ score, slug: m[2], snippet: m[3].trim() }); |
| 67 | } |
| 68 | return hits.slice(0, limit); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Semantic recall over the curated-memory source. Returns parsed hits, or `null` |
no test coverage detected