MCPcopy Create free account
hub / github.com/KnockOutEZ/wigolo / parseItems

Method parseItems

src/search/engines/github-code.ts:70–99  ·  view source on GitHub ↗
(items: GhCodeItem[])

Source from the content-addressed store, hash-verified

68 }
69
70 private parseItems(items: GhCodeItem[]): RawSearchResult[] {
71 const results: RawSearchResult[] = [];
72 const total = items.length;
73
74 for (let i = 0; i < total; i++) {
75 const item = items[i];
76 const repoName = asString(item.repository?.full_name);
77 const path = asString(item.path);
78 const htmlUrl = asString(item.html_url);
79 if (!repoName || !path || !htmlUrl) continue;
80
81 const description = asString(item.repository?.description);
82 // S11b: include both repo description and path in the snippet when
83 // both are present. Lexical alignment scoring downstream uses snippet
84 // tokens; pre-S11b we lost ~half the queryable surface by emitting
85 // only one or the other. When description is missing, fall back to
86 // path alone so we don't pad noise.
87 const snippet = description ? `${description} — ${path}` : path;
88
89 results.push({
90 title: `${repoName} — ${path}`,
91 url: htmlUrl,
92 snippet,
93 relevance_score: 1 - i / Math.max(total, 1),
94 engine: 'github-code',
95 });
96 }
97
98 return results;
99 }
100}

Callers 1

searchMethod · 0.95

Calls 2

asStringFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected