BM25 inverted index + LLM query expansion + grep. Zero external dependencies.
Follow these steps in order every time:
Check if the user mentioned a docs directory. If not, ask:
"Which directory should I search? (e.g. ~/obsidian, ~/notes)"
bash
ls <docs_dir>/.cache/index.json
bash
python3 ~/.claude/skills/doc-search/scripts/build_index.py <docs_dir>
Index saved to <docs_dir>/.doc-search/index.json. Incremental on subsequent runs.
Before searching, expand the user's query to cover synonyms, Chinese/English variants, and likely headings. Combine into one string:
text
"获取音色列表" → "获取 查询 list voice 音色 tts ListVoice 音色列表"
bash
python3 ~/.claude/skills/doc-search/scripts/search.py "<expanded query>" \
--docs-dir <docs_dir> --topk 5
Output: JSON array [{path, rel, score, title, summary}, ...]
For each result file, grep with the original keywords:
bash
grep -ni -e "keyword1" -e "keyword2" /path/to/doc.md
Report file path + matching line numbers to the user.
FlagDefaultDescription--topk``5Number of BM25 results--ext``md,txt,rst,orgFile extensions to index--index``<docs_dir>/.doc-search/index.jsonOverride index path