MCPcopy
hub / github.com/upstash/context7 / formatLibraryResult

Function formatLibraryResult

packages/cli/src/commands/docs.ts:27–50  ·  view source on GitHub ↗
(lib: LibrarySearchResult, index: number)

Source from the content-addressed store, hash-verified

25}
26
27function formatLibraryResult(lib: LibrarySearchResult, index: number): string {
28 const lines: string[] = [];
29 lines.push(`${pc.dim(`${index + 1}.`)} ${pc.bold(`Title: ${lib.title}`)}`);
30 lines.push(` ${pc.cyan(`Context7-compatible library ID: ${lib.id}`)}`);
31
32 if (lib.description) {
33 lines.push(` ${pc.dim(`Description: ${lib.description}`)}`);
34 }
35
36 if (lib.totalSnippets) {
37 lines.push(` ${pc.dim(`Code Snippets: ${lib.totalSnippets}`)}`);
38 }
39 if (lib.trustScore !== undefined) {
40 lines.push(` ${pc.dim(`Source Reputation: ${getReputationLabel(lib.trustScore)}`)}`);
41 }
42 if (lib.benchmarkScore !== undefined && lib.benchmarkScore > 0) {
43 lines.push(` ${pc.dim(`Benchmark Score: ${lib.benchmarkScore}`)}`);
44 }
45 if (lib.versions && lib.versions.length > 0) {
46 lines.push(` ${pc.dim(`Versions: ${lib.versions.join(", ")}`)}`);
47 }
48
49 return lines.join("\n");
50}
51
52async function resolveCommand(
53 library: string,

Callers 1

resolveCommandFunction · 0.85

Calls 1

getReputationLabelFunction · 0.85

Tested by

no test coverage detected