Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
153 lines
3.7 KiB
Plaintext
153 lines
3.7 KiB
Plaintext
---
|
|
title: "Search Library"
|
|
description: "Search available libraries"
|
|
---
|
|
|
|
# Search Library
|
|
|
|
Search across available libraries. Returns an array of matching libraries with metadata useful for selection.
|
|
|
|
## Arguments
|
|
|
|
<ParamField path="query" type="string" required>
|
|
The user's question or task (used for relevance ranking)
|
|
</ParamField>
|
|
|
|
<ParamField path="libraryName" type="string" required>
|
|
The library name to search for
|
|
</ParamField>
|
|
|
|
## Response
|
|
|
|
Returns `Library[]` - an array of library objects.
|
|
|
|
<ResponseField name="Library" type="object">
|
|
<Expandable title="properties">
|
|
<ResponseField name="id" type="string" required>
|
|
Unique identifier for the library (e.g., `/facebook/react`)
|
|
</ResponseField>
|
|
<ResponseField name="name" type="string" required>
|
|
Display name of the library
|
|
</ResponseField>
|
|
<ResponseField name="description" type="string" required>
|
|
Brief description of the library
|
|
</ResponseField>
|
|
<ResponseField name="totalSnippets" type="number" required>
|
|
Total number of documentation snippets available
|
|
</ResponseField>
|
|
<ResponseField name="trustScore" type="number" required>
|
|
Trust score of the library
|
|
</ResponseField>
|
|
<ResponseField name="benchmarkScore" type="number" required>
|
|
Benchmark score indicating documentation quality
|
|
</ResponseField>
|
|
<ResponseField name="versions" type="string[]">
|
|
Available versions
|
|
</ResponseField>
|
|
</Expandable>
|
|
</ResponseField>
|
|
|
|
## Examples
|
|
|
|
<RequestExample>
|
|
```typescript Basic Search
|
|
import { Context7 } from "@upstash/context7-sdk";
|
|
|
|
const client = new Context7();
|
|
|
|
const libraries = await client.searchLibrary(
|
|
"I need to build a UI",
|
|
"react"
|
|
);
|
|
|
|
console.log(`Found ${libraries.length} libraries`);
|
|
libraries.forEach((library) => {
|
|
console.log(`${library.name}: ${library.description}`);
|
|
});
|
|
```
|
|
|
|
```typescript Selecting Best Library
|
|
import { Context7 } from "@upstash/context7-sdk";
|
|
|
|
const client = new Context7();
|
|
|
|
const libraries = await client.searchLibrary(
|
|
"I want to build a web app",
|
|
"next"
|
|
);
|
|
|
|
const sorted = libraries.sort((a, b) => b.benchmarkScore - a.benchmarkScore);
|
|
const best = sorted[0];
|
|
|
|
console.log(`Best match: ${best.name} (score: ${best.benchmarkScore})`);
|
|
console.log(`Available snippets: ${best.totalSnippets}`);
|
|
```
|
|
|
|
```typescript Error Handling
|
|
import { Context7, Context7Error } from "@upstash/context7-sdk";
|
|
|
|
const client = new Context7();
|
|
|
|
try {
|
|
const libraries = await client.searchLibrary("query", "express");
|
|
|
|
if (libraries.length === 0) {
|
|
console.log("No libraries found");
|
|
} else {
|
|
console.log(`Found ${libraries.length} libraries`);
|
|
}
|
|
} catch (error) {
|
|
if (error instanceof Context7Error) {
|
|
console.error("API Error:", error.message);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
```
|
|
</RequestExample>
|
|
|
|
## Use Cases
|
|
|
|
### Finding Libraries by Score
|
|
|
|
```typescript
|
|
const libraries = await client.searchLibrary("state management", "redux");
|
|
|
|
const trusted = libraries.sort((a, b) => b.trustScore - a.trustScore);
|
|
console.log("Most trusted:", trusted[0].name);
|
|
```
|
|
|
|
### Checking Available Versions
|
|
|
|
```typescript
|
|
const libraries = await client.searchLibrary("I want to use lodash", "lodash");
|
|
|
|
const library = libraries[0];
|
|
if (library.versions) {
|
|
console.log(`Available versions: ${library.versions.join(", ")}`);
|
|
}
|
|
```
|
|
|
|
### Full Workflow
|
|
|
|
```typescript
|
|
import { Context7 } from "@upstash/context7-sdk";
|
|
|
|
const client = new Context7();
|
|
|
|
const libraries = await client.searchLibrary(
|
|
"I want to build a React app",
|
|
"react"
|
|
);
|
|
|
|
const library = libraries[0];
|
|
console.log(`Using: ${library.name} (${library.id})`);
|
|
|
|
const context = await client.getContext(
|
|
"How do I create a component?",
|
|
library.id
|
|
);
|
|
|
|
console.log(context);
|
|
```
|