Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1broseidon Ketch code Provider

From Leeroopedia
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.

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment