pi-all-search 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-all-search",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "All-in-one web search extension for Pi — exa, tavily, anysearch, firecrawl, context7",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,15 +20,30 @@ export class Context7Provider implements SearchProvider {
20
20
  if (!lib) return { results: [] };
21
21
 
22
22
  const resp = await fetch(
23
- `https://context7.com/api/v2/context?libraryId=${encodeURIComponent(lib.id)}&query=${encodeURIComponent(query)}`,
23
+ `https://context7.com/api/v2/context?libraryId=${encodeURIComponent(lib.id)}&query=${encodeURIComponent(query)}&type=json`,
24
24
  { headers: { Authorization: `Bearer ${this.apiKey}` } }
25
25
  );
26
26
  const data = await resp.json();
27
- const results: SearchResult[] = (data.context ?? data.results ?? []).slice(0, maxResults).map((r: any) => ({
28
- title: r.title ?? r.name ?? lib.title,
29
- url: r.url ?? r.source ?? `https://context7.com${lib.id}`,
30
- snippet: r.content ?? r.snippet ?? r.description ?? "",
31
- }));
27
+ const results: SearchResult[] = [];
28
+
29
+ for (const snippet of data.codeSnippets ?? []) {
30
+ if (results.length >= maxResults) break;
31
+ results.push({
32
+ title: snippet.pageTitle ?? snippet.codeTitle ?? lib.title,
33
+ url: snippet.codeId ?? `https://context7.com${lib.id}`,
34
+ snippet: snippet.codeDescription ?? snippet.codeList?.map((c: any) => c.code).join("\n") ?? "",
35
+ });
36
+ }
37
+
38
+ for (const snippet of data.infoSnippets ?? []) {
39
+ if (results.length >= maxResults) break;
40
+ results.push({
41
+ title: snippet.breadcrumb ?? snippet.pageId ?? lib.title,
42
+ url: snippet.pageId ?? `https://context7.com${lib.id}`,
43
+ snippet: snippet.content ?? "",
44
+ });
45
+ }
46
+
32
47
  return { results };
33
48
  }
34
49
  }