Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRegexpUnsupported = errors.New("regular expression search not supported by this backend")
ErrRegexpUnsupported is returned by a backend that was asked for a regular expression search it cannot perform. The CLI maps this to a precondition error so the user can pick a different backend.
var ErrUnknownBackend = errors.New("unknown code backend")
ErrUnknownBackend reports a backend name that is not a known code search backend. Callers classify errors wrapping it as validation failures; any other NewFromConfig error is a missing precondition (e.g. token).
Functions ¶
This section is empty.
Types ¶
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
GitHub searches code via the GitHub Code Search REST API.
type GrepApp ¶
type GrepApp struct {
// contains filtered or unexported fields
}
GrepApp searches code via the Grep MCP server (mcp.grep.app). Unlike Sourcegraph/GitHub it needs no token, but it searches literal code patterns (grep-style) rather than keywords.
func NewGrepApp ¶
func NewGrepApp() *GrepApp
type Query ¶
type Query struct {
Term string // the search string (literal, or a regex when Regexp is set)
Lang string // language filter ("" = any)
Limit int // max results
Regexp bool // interpret Term as a regular expression
}
Query describes a code search request. Required fields are Term and Limit; the rest are optional refinements. Backends that do not support a given option should ignore it or, where it would silently change semantics (e.g. Regexp), return ErrRegexpUnsupported.
type Result ¶
type Result struct {
Repo string `json:"repo"`
Path string `json:"path"`
Line int `json:"line,omitempty"`
Snippet string `json:"snippet"`
Language string `json:"language,omitempty"`
Stars int `json:"stars,omitempty"`
URL string `json:"url"`
Source string `json:"source"` // "sourcegraph" | "grepapp" | "github"
}
Result is a single code search result.
type Searcher ¶
Searcher is the interface for code search backends. Each backend owns its own query dialect — language filtering and safety qualifiers (archived/fork exclusion) are applied internally so that callers pass plain user input.
func NewFromConfig ¶
NewFromConfig builds the code Searcher for backend, resolving tokens and instance URLs from cfg exactly as the `ketch code` CLI does. Both the CLI and the MCP server call this — it is the single owner of the backend switch.
type Sourcegraph ¶
type Sourcegraph struct {
// contains filtered or unexported fields
}
Sourcegraph searches code via the Sourcegraph streaming search API.
func NewSourcegraph ¶
func NewSourcegraph(baseURL string) *Sourcegraph