- Fix SQL syntax error when collectionId is empty string (searchFTS, searchVec) - Add 1-second timeout to llama.dispose() to prevent indefinite hang - Add process.exit(0) after cleanup for clean CLI exit - Include hash/docid in search results mapping - Update query expansion to use structured Queryable types - Switch to Qwen3-1.7B model for better query expansion - Improve bun discovery in qmd wrapper script Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.4 KiB
Bash
Executable File
56 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# qmd - Quick Markdown Search
|
|
set -euo pipefail
|
|
|
|
# Find bun - prefer PATH, fallback to known locations
|
|
find_bun() {
|
|
# First: check if bun is in PATH and modern enough
|
|
if command -v bun &>/dev/null; then
|
|
local ver=$(bun --version 2>/dev/null || echo "0")
|
|
if [[ "$ver" =~ ^1\. ]]; then
|
|
command -v bun
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
# Fallback: derive paths (need HOME)
|
|
: "${HOME:=$(eval echo ~)}"
|
|
|
|
# If running from .bun tree, use that bun
|
|
if [[ "${BASH_SOURCE[0]}" == */.bun/* ]]; then
|
|
local bun_home="${BASH_SOURCE[0]%%/.bun/*}/.bun"
|
|
if [[ -x "$bun_home/bin/bun" ]]; then
|
|
echo "$bun_home/bin/bun"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
# Check known locations
|
|
local candidates=(
|
|
"$HOME/.local/share/mise/installs/bun/latest/bin/bun"
|
|
"$HOME/.local/share/mise/shims/bun"
|
|
"$HOME/.asdf/shims/bun"
|
|
"/opt/homebrew/bin/bun"
|
|
"/usr/local/bin/bun"
|
|
"$HOME/.bun/bin/bun"
|
|
)
|
|
for c in "${candidates[@]}"; do
|
|
[[ -x "$c" ]] && { echo "$c"; return 0; }
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
BUN=$(find_bun) || { echo "Error: bun not found. Install from https://bun.sh" >&2; exit 1; }
|
|
|
|
# Resolve symlinks to find script location
|
|
SOURCE="${BASH_SOURCE[0]}"
|
|
while [[ -L "$SOURCE" ]]; do
|
|
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
SOURCE="$(readlink "$SOURCE")"
|
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
done
|
|
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
|
|
exec "$BUN" "$SCRIPT_DIR/src/qmd.ts" "$@"
|