Package: dappco.re/go/inference
File: go/discover.go
A backend-neutral filesystem scan that yields one DiscoveredModel per model directory under a root. Used by:
- CoreAgent / core/ide model picker UI
lab/to enumerate available models- Test harnesses that auto-find fixtures
Two entry points, with different coverage:
Discover(baseDir)(this file) — a lazyiter.Seq[DiscoveredModel]over safetensors model directories only (config.json+ at least one*.safetensors). This is the function documented below.DiscoverModels(basePath)(in gguf.md /gguf.go) — an eager[]DiscoveredModelthat includes both safetensors dirs (viaDiscover) and GGUF files, sorted by path. Reach for this when you also need.ggufmodels.
Architecture + quantisation metadata is extracted at scan time so callers don't have to load each model to decide whether it's interesting.
type DiscoveredModel struct {
Path string // absolute path to dir or .gguf file
ModelType string // architecture: gemma3, qwen3, llama, …
QuantBits int // 0 = unknown / unquantised
QuantGroup int
QuantType string // q4_k_m, q8_0, etc. (GGUF)
QuantFamily string // q4, q8 (coarse)
NumFiles int // number of weight files
Format string // "safetensors" or "gguf"
}for m := range inference.Discover("/Volumes/Data/models") {
fmt.Printf("%s arch=%s quant=%dbit\n", m.Path, m.ModelType, m.QuantBits)
}Returns iter.Seq[DiscoveredModel]. Iteration is lazy — caller can break early on first match. It is a pre-order directory walk; siblings within each directory are visited in alphabetical name order.
config.json→model_type,quantization/quantization_config(bits,group_size)NumFiles= count of*.safetensorsin the directoryFormatis always"safetensors"forDiscoverresults
Detection is metadata-only — weight tensors are not loaded. (GGUF header parsing lives in ReadGGUFInfo / DiscoverModels; see gguf.md.)
A directory yields a DiscoveredModel only when it contains both config.json and at least one *.safetensors file. Every other directory is walked but produces nothing. There is no explicit hidden-directory or symlink-loop handling — directories that lack the two markers are simply passed over, and the walk recurses into every subdirectory it can list.
Large model trees with 100+ models would cost noticeable RAM if returned all-at-once. The generator pattern lets a UI render the first row immediately while the scan continues.
- gguf.md —
GGUFInfo+ReadGGUFInfo+DiscoverModels(the GGUF-aware scan)