diff --git a/bin/qmd b/bin/qmd new file mode 100644 index 00000000..4db8227a --- /dev/null +++ b/bin/qmd @@ -0,0 +1,12 @@ +#!/bin/sh +# Detect the runtime used to install this package and use the matching one +# to avoid native module ABI mismatches (e.g., better-sqlite3 compiled for bun vs node) + +DIR="$(cd "$(dirname "$0")/.." && pwd)" + +# Check if we were installed with bun (look for bun.lock or bun-lockb) +if [ -f "$DIR/bun.lock" ] || [ -f "$DIR/bun.lockb" ] || [ -n "$BUN_INSTALL" ]; then + exec bun "$DIR/dist/qmd.js" "$@" +else + exec node "$DIR/dist/qmd.js" "$@" +fi diff --git a/package.json b/package.json index 2341cd20..180c3d68 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "description": "Query Markup Documents - On-device hybrid search for markdown files with BM25, vector search, and LLM reranking", "type": "module", "bin": { - "qmd": "dist/qmd.js" + "qmd": "bin/qmd" }, "files": [ + "bin/", "dist/", "LICENSE", "CHANGELOG.md"