registry

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package registry is the ONE table that maps language -> provider, answering FOUR independent queries (by name, by extension, by marker file, and the complete set) so internal/mcp and internal/scaffold never build a concrete provider on their own and never hand-diverge into a fifth answer to "what can codefit do for this language" (CLAUDE.md's layering rule).

The table distinguishes CAPABILITY — what a provider declares it implements, via LanguageProvider.Capability(), over the vocabulary that already lives in internal/core/surface — from EXPOSURE — which resolvers currently admit it (Entry.Exposure). A language can be registered here and deliberately NOT exposed to a given resolver; that gap is exactly what codefit declares to the agent rather than hiding.

internal/mcp/schemaparser.go stays outside this table by design (ADR 0018): it resolves by the shape of the INPUT (.prisma/.sql), not by language.

Layering: this package imports internal/providers/golang and internal/providers/typescript, but internal/providers (the root package, which owns the LanguageProvider interface and the Capability record) MUST NEVER import this package — that is the one edge that would let a concrete provider leak into the core's dependency graph. layering_test.go proves this holds by reading `go list -deps`, not by convention.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDetectMarkerFiles

func InitDetectMarkerFiles() []string

InitDetectMarkerFiles returns every marker file that can actually make ByMarkerFile resolve — the MarkerFiles of the InitDetect-eligible entries, in table order, entry order preserved within each entry.

It exists so that no user-facing text ever spells a marker name by hand. `codefit init`'s deleted refusal message was written against config.allowedLanguages instead of against this table: it named four manifests that resolve nothing (creating one changed nothing) and omitted tsconfig.json, which resolves TypeScript. The table's owner owns the query, exactly as ExposedForSecurity/ExposedForSurfaceTools already do for their own consumers.

Types

type Entry

type Entry struct {
	Canonical   string   // "typescript"
	Aliases     []string // "ts", "tsx"
	MarkerFiles []string // ordered within the entry: e.g. "package.json", "tsconfig.json"
	New         func(authzHelpers []string) providers.LanguageProvider
	Exposure    Exposure
}

Entry is one registered language. Deliberately has NO extensions field — extensions are read from New(nil).FileExtensions() (ByExtension, below), so they can never drift from what the provider itself declares.

func All

func All() []Entry

All returns every registered entry, in table order. Callers get a copy — the table itself is never mutated after init.

func ByExtension

func ByExtension(ext string) (Entry, bool)

ByExtension resolves an entry by file extension, read from each entry's real provider (New(nil).FileExtensions()) — never a stored table field, so this query cannot drift from what the provider itself declares.

func ByMarkerFile

func ByMarkerFile(root string) (Entry, bool)

ByMarkerFile resolves the first entry (in table order) with a marker file directly under root, restricted to entries whose Exposure.InitDetect is true — this query's only production caller is internal/scaffold's Detect (codefit init), so an entry with InitDetect: false is skipped exactly as Exposure.SecurityScan/SurfaceTools already make an entry unresolvable to their own consumers (providerForLanguage, providerFor). Table order remains the priority among the entries that stay eligible: in a polyglot root with both go.mod and package.json, "go" (listed first) wins when its InitDetect is true; skipping an ineligible entry falls through to the next one in table order rather than failing the whole resolution.

func ByName

func ByName(name string) (Entry, bool)

ByName resolves an entry by canonical name or any of its aliases.

func ExposedForSecurity

func ExposedForSecurity() []Entry

ExposedForSecurity returns the entries whose Exposure.SecurityScan is true, in table order — the set internal/mcp's providerForLanguage/ SupportedLanguageNames resolve a security provider for.

func ExposedForSurfaceTools

func ExposedForSurfaceTools() []Entry

ExposedForSurfaceTools returns the entries whose Exposure.SurfaceTools is true, in table order — the set internal/mcp/surface.go's providerFor resolves for the codefit-surface-* tools.

type Exposure

type Exposure struct {
	SecurityScan bool
	SurfaceTools bool
	InitDetect   bool
}

Exposure declares which resolvers currently admit a registered language, independent of Capability (what the provider implements). Each field names the consumer it gates:

  • SecurityScan: internal/mcp's providerForLanguage (codefit-scan-security, codefit-scan-endpoint, codefit-scan-all's security bucket, and codefit-coverage, which all resolve through it).
  • SurfaceTools: internal/mcp/surface.go's providerFor (the codefit-surface-* tools).
  • InitDetect: internal/scaffold's Detect (codefit init).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL