MCPcopy Index your code
hub / github.com/garrytan/gstack / parseSearchHits

Function parseSearchHits

lib/gstack-decision-semantic.ts:59–69  ·  view source on GitHub ↗
(stdout: string, minScore: number, limit: number)

Source from the content-addressed store, hash-verified

57 * unit testing of the parser without a live gbrain.
58 */
59export 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`

Callers 2

semanticRecallFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected