- 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
34 lines
952 B
Bash
Executable File
34 lines
952 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# bin/kb/search - Go deduction search over the brain (model served by daemon).
|
|
# Builds the kbsearch binary on first run / when source changes, then execs it.
|
|
set -euo pipefail
|
|
|
|
KB="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
BIN="$KB/var/bin/kbsearch"
|
|
SRC="$KB/bin/kbsearch"
|
|
|
|
mkdir -p "$KB/var/bin"
|
|
|
|
# Rebuild if binary missing or any .go source newer
|
|
need_build=0
|
|
if [ ! -x "$BIN" ]; then
|
|
need_build=1
|
|
else
|
|
# Check if any .go in kbsearch is newer than binary
|
|
while IFS= read -r -d '' f; do
|
|
if [ "$f" -nt "$BIN" ]; then
|
|
need_build=1
|
|
break
|
|
fi
|
|
done < <(find "$SRC" -name '*.go' -print0 2>/dev/null)
|
|
fi
|
|
|
|
if [ "$need_build" -eq 1 ]; then
|
|
echo "Building kbsearch..." >&2
|
|
(cd "$SRC" && \
|
|
CGO_CFLAGS="-I$KB/lib-ladybug" \
|
|
CGO_LDFLAGS="-L$KB/lib-ladybug -Wl,-rpath,$KB/lib-ladybug" \
|
|
go build -tags system_ladybug -o "$BIN" .) || exit 1
|
|
fi
|
|
|
|
exec "$BIN" "$@" |