- New nested module bin/kbsearch with Go implementation of bin/kb/search - Embedding model (potion-multilingual-128M) served by localhost daemon so repeated CLI calls reuse the loaded model - Bash launcher bin/kb/search builds binary on first run, caches to var/bin/ - Hybrid FTS + vector search (RRF k=60) matching Python kblib behavior - YAML output via port of yamlout.py (ordered keys, same format) - JSON output with proper field order - All flags: --root, --repo, -n, --json, --list-model - Root go.mod reverted to 1.25.0 (kbsearch is isolated nested module) - CI passes: go test ./... and go vet ./... unaffected by kbsearch
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
// bin/kbsearch - the Go implementation of bin/kb/search (nested module so the
|
|
// root `go test ./...` and CI never compile it against native ladyships).
|
|
//
|
|
// Usage (built/run by ./bin/kb/search):
|
|
//
|
|
// kbsearch "query" [--root facts|info] [--repo P] [-n N] [--json]
|
|
// kbsearch serve [port] start the embedding daemon
|
|
// kbsearch --list-model print the resolved model dir
|
|
//
|
|
// The potion-multilingual model is loaded only in `serve`; a CLI reuses the
|
|
// daemon over localhost HTTP (falling back to in-process embedding).
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) > 1 && os.Args[1] == "serve" {
|
|
port := 17830
|
|
if len(os.Args) > 2 {
|
|
if p, err := strconv.Atoi(os.Args[2]); err == nil {
|
|
port = p
|
|
}
|
|
}
|
|
if err := serve(port); err != nil {
|
|
log.Fatalf("kbsearch serve: %v", err)
|
|
}
|
|
return
|
|
}
|
|
if len(os.Args) > 1 && os.Args[1] == "--list-model" {
|
|
dir, err := modelDir()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
fmt.Println(dir)
|
|
return
|
|
}
|
|
os.Exit(runSearch(os.Args[1:]))
|
|
} |