MCPcopy Create free account
hub / github.com/idosal/git-mcp / searchRepositoryDocumentation

Function searchRepositoryDocumentation

src/api/tools/commonTools.ts:341–392  ·  view source on GitHub ↗
({
  repoData,
  query,
  env,
  ctx,
  fallbackSearch = searchRepositoryDocumentationNaive,
}: {
  repoData: RepoData;
  query: string;
  env: CloudflareEnvironment;
  ctx: any;
  fallbackSearch?: typeof searchRepositoryDocumentationNaive;
})

Source from the content-addressed store, hash-verified

339}
340
341export async function searchRepositoryDocumentation({
342 repoData,
343 query,
344 env,
345 ctx,
346 fallbackSearch = searchRepositoryDocumentationNaive,
347}: {
348 repoData: RepoData;
349 query: string;
350 env: CloudflareEnvironment;
351 ctx: any;
352 fallbackSearch?: typeof searchRepositoryDocumentationNaive;
353}): Promise<{
354 searchQuery: string;
355 content: { type: "text"; text: string }[];
356}> {
357 if (!env.DOCS_BUCKET) {
358 throw new Error("DOCS_BUCKET is not available in environment");
359 }
360 const docsInR2 = !!(await env.DOCS_BUCKET.head(
361 `${repoData.owner}/${repoData.repo}/llms.txt`,
362 ));
363 if (docsInR2) {
364 try {
365 const autoragResult = await searchRepositoryDocumentationAutoRag({
366 repoData,
367 query,
368 env,
369 ctx,
370 autoragPipeline: "docs-rag",
371 });
372 if (
373 autoragResult?.content[0]?.text?.startsWith("No results found") ===
374 false
375 ) {
376 console.log("Found results in AutoRAG", autoragResult);
377 return autoragResult;
378 }
379
380 console.log("No results in AutoRAG", autoragResult);
381 } catch (error) {
382 console.error("Error in AutoRAG search", error);
383 }
384 }
385
386 return await fallbackSearch({
387 repoData,
388 query,
389 env,
390 ctx,
391 });
392}
393
394export async function searchRepositoryDocumentationAutoRag({
395 repoData,

Callers 8

getToolsMethod · 0.85
getToolsMethod · 0.85
getToolsMethod · 0.85
getToolsMethod · 0.85

Calls 3

logMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected