Context7 Platform -- Up-to-date docs for AI agents
add benchmark score, rnemae trust score
enesakar08e43bad8dea
diff --git a/src/index.ts b/src/index.tsindex e8cdc05c..ca11d40c 100644--- a/src/index.ts+++ b/src/index.ts@@ -122,7 +122,8 @@ Selection Process:- Name similarity to the query (exact matches prioritized)- Description relevance to the query's intent- Documentation coverage (prioritize libraries with higher Code Snippet counts)-- Trust score (consider libraries with scores of 7-10 more authoritative)+- Source reputation (consider libraries with High or Medium reputation more authoritative)+- Benchmark Score: Quality indicator (100 is the highest score)Response Format:- Return the selected library ID in a clearly marked section@@ -167,10 +168,11 @@ Each result includes:- Name: Library or package name- Description: Short summary- Code Snippets: Number of available code examples-- Trust Score: Authority indicator+- Source Reputation: Authority indicator (High, Medium, Low, or Unknown)+- Benchmark Score: Quality indicator (100 is the highest score)- Versions: List of versions if available. Use one of those versions if the user provides a version in their query. The format of the version is /org/project/version.-For best results, select libraries based on name match, trust score, snippet coverage, and relevance to your use case.+For best results, select libraries based on name match, source reputation, snippet coverage, and relevance to your use case.----------diff --git a/src/lib/types.ts b/src/lib/types.tsindex 9972a6fd..c1935a53 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -10,6 +10,7 @@ export interface SearchResult {totalPages: number;stars?: number;trustScore?: number;+ benchmarkScore?: number;versions?: string[];}diff --git a/src/lib/utils.ts b/src/lib/utils.tsindex bb4912c1..814a4a81 100644--- a/src/lib/utils.ts+++ b/src/lib/utils.ts@@ -1,5 +1,19 @@import { SearchResponse, SearchResult } from "./types.js";+/**+ * Maps numeric source reputation score to an interpretable label for LLM consumption.+ *+ * @returns One of: "High", "Medium", "Low", or "Unknown"+ */+function getSourceReputationLabel(+ sourceReputation?: number+): "High" | "Medium" | "Low" | "Unknown" {+ if (sourceReputation === undefined || sourceReputation < 0) return "Unknown";+ if (sourceReputation >= 7) return "High";+ if (sourceReputation >= 4) return "Medium";+ return "Low";+}+/*** Formats a search result into a human-readable string representation.* Only shows code snippet count and GitHub stars when available (not equal to -1).@@ -20,9 +34,13 @@ export function formatSearchResult(result: SearchResult): string {formattedResult.push(`- Code Snippets: ${result.totalSnippets}`);}- // Only add trust score if it's a valid value- if (result.trustScore !== -1 && result.trustScore !== undefined) {- formattedResult.push(`- Trust Score: ${result.trustScore}`);+ // Always add categorized source reputation+ const reputationLabel = getSourceReputationLabel(result.trustScore);+ formattedResult.push(`- Source Reputation: ${reputationLabel}`);++ // Only add benchmark score if it's a valid value+ if (result.benchmarkScore !== undefined && result.benchmarkScore > 0) {+ formattedResult.push(`- Benchmark Score: ${result.benchmarkScore}`);}// Only add versions if it's a valid value