Implementation:1broseidon Ketch code Provider
| Knowledge Sources | |
|---|---|
| Domains | Code_Search, Provider_Registry |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
The descriptor wiring one code-search backend — including regex support, qualifier application, and partial-index flags unique to code search.
Description
The code.Provider is the code-search analogue of `search.Provider`. Beyond the shared `ID`/`Usable`/`New`/`Probe`/`Settings` fields, it declares code-specific capabilities: Regexp (the backend can do regex search), Qualifiers (the backend applies `repo:`/`lang:`/`path:` qualifiers written into the query — without it, `LiteralQualifiers` warns that such tokens were searched as text), and PartialIndex (the backend indexes only some repositories, so a repo-scoped search can come back empty because the repo is missing). `Query.Repo` is exact on every backend; a backend whose native filter is looser narrows its own results and returns `ErrRepoNotFound` when the service says the repository is missing.
Usage
Register by appending a `*Provider()` call to the package-level `providers` slice in `code/registry.go` (explicit, no `init()`). Resolved via `code.NewFromConfig`.
Code Reference
Source Location
- Repository: ketch
- File: code/registry.go, code/filter.go
Signature
type Provider struct {
ID string
CLIName string
Regexp bool
Setup string
Name string
Hidden bool
Usable func(*config.Config) bool
Settings []config.Setting
New func(*config.Config) (Searcher, error)
Probe func(context.Context, *http.Client, *config.Config) (health.Status, string)
Qualifiers bool
PartialIndex bool
}
// NormalizeRepo normalizes a repo ref to owner/name (or returns ErrInvalidRepo).
func NormalizeRepo(ref string) (string, error)
func (p Provider) Required(cfg *config.Config) bool
Import
import (
"github.com/1broseidon/ketch/code"
config "github.com/1broseidon/ketch/internal/configbase"
)
I/O Contract
Outputs
| Name | Type | Description |
|---|---|---|
| Provider.Qualifiers | bool | Backend applies repo:/lang: qualifiers |
| Provider.PartialIndex | bool | Backend indexes only some repos |
| Provider.Regexp | bool | Backend supports regex search |
Usage Examples
Registering a Code Backend
var providers = []Provider{
grepappProvider(), // Qualifiers:false, PartialIndex:true
sourcegraphProvider(), // Regexp:true, Qualifiers:true
githubProvider(), // Qualifiers:true
}
func grepappProvider() Provider {
return Provider{
ID: "grepapp",
Name: "Grep.app",
PartialIndex: true,
New: newGrepapp,
// …
}
}
Repo Normalization
repo, err := code.NormalizeRepo("https://github.com/golang/go")
// repo == "golang/go"; err == code.ErrInvalidRepo on a bad ref.