Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound reports a docs resource that is permanently absent upstream — typically a Context7 library ID that resolves to a 404. It is detected in this package (never by string matching at the surfaces) so both the CLI and the MCP server classify it as not-found (exit 3 / [not_found]) rather than a retryable upstream failure.
var ErrUnknownBackend = errors.New("unknown docs backend")
ErrUnknownBackend reports a backend name that is not a known docs backend. Callers classify errors wrapping it as validation failures; any other NewFromConfig error is a missing precondition (API key, unimplemented backend).
Functions ¶
This section is empty.
Types ¶
type Context7 ¶
type Context7 struct {
// contains filtered or unexported fields
}
Context7 searches library documentation via the Context7 API.
func NewContext7 ¶
NewContext7 creates a new Context7 docs backend.
func (*Context7) GetDocs ¶
func (c *Context7) GetDocs(ctx context.Context, libraryID, query string, tokens int) ([]Result, error)
GetDocs fetches documentation snippets for a resolved library ID.
func (*Context7) ResolveLibrary ¶
func (c *Context7) ResolveLibrary(ctx context.Context, name string, limit int) ([]LibraryMatch, error)
ResolveLibrary searches Context7 for libraries matching the given name, returning at most limit matches (limit <= 0 means all). The Context7 search endpoint has no server-side limit parameter, so the bound is applied here — in the shared layer — so the CLI and MCP surfaces cannot diverge.
type FTS5Local ¶
type FTS5Local struct{}
FTS5Local is a planned local SQLite FTS5 docs backend. Not yet implemented.
func NewFTS5Local ¶
func NewFTS5Local() *FTS5Local
NewFTS5Local creates a new FTS5Local backend stub.
type LibraryMatch ¶
type LibraryMatch struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
TotalSnippets int `json:"totalSnippets"`
TrustScore float64 `json:"trustScore"`
Versions []string `json:"versions"`
}
LibraryMatch is a resolved library from Context7's search endpoint. Field names track the upstream schema: "title" (not "name"), "totalSnippets" (not "codeSnippets"), and "trustScore" (numeric, not the older string "trust").
type Result ¶
type Result struct {
Library string `json:"library"`
Version string `json:"version,omitempty"`
Title string `json:"title"`
Breadcrumb string `json:"breadcrumb,omitempty"`
Snippet string `json:"snippet"`
URL string `json:"url"`
Source string `json:"source"` // "context7" | "local"
}
Result is a single docs search result.
type Searcher ¶
Searcher is the interface for docs backends.
func NewFromConfig ¶
NewFromConfig builds the docs Searcher for backend, resolving API keys from cfg exactly as the `ketch docs` CLI does. Both the CLI and the MCP server call this — it is the single owner of the backend switch.
The "local" FTS5 backend is a stub whose Search always errors, so it is rejected here — at construction time — instead of failing on first use.