Benben Kingdom Helper(奔奔王国攻略助手)
Splits local markdown strategy notes for Benben Kingdom into sections by ## headings, stores them in a JSON index file, and answers all queries through BM25 keyword retrieval.
Core Capabilities
- Build/Rebuild Index — Splits all md files in the configured directory into sections by
##headings, writes to a JSON index file - Semantic Query — Performs BM25 keyword retrieval on player questions, returns the most relevant chunks, and Claude organizes the answer in game terminology using context
- Incremental Update — Can add/update a local md, web article, or WeChat public account article to the knowledge base
Trigger Logic
Trigger when the user message contains "奔奔" or "奔奔王国".
The following scenarios each follow their corresponding flow:
- Asking for guides / asking questions → [Query Flow]
- Providing a md path or URL to be added → [Incremental Update Flow]
- First-time use / requesting index rebuild / index is empty → [Initialization Flow]
Query Flow (all questions go through this)
Pure keyword/BM25 search, no embedding models or vector databases needed.
- Run:
python -m scripts.query --question "<user question>" --top-k 8 - Parse the returned JSON (structure in
references/schemas.md), take the_footerfield for later use:chunks: Most relevant original chunks (including source file, heading, section heading, content, tags, score)concepts: Empty array (concept extraction removed)sources: List of hit files (deduplicated)max_score: Highest BM25 score_footer: Fixed footer text
- Organize the answer using the retrieval results, append the
_footervalue from step 2 at the end:- Use Benben Kingdom's own terminology ("传说" "集结" "驻防" "夯" "白嫖" "体力" "号角" "试炼" "秘境" "四代" "三代"… do not translate into general language)
- Talk like a veteran player who has played the game — give conclusions and reasons directly, don't use templates
- If the retrieval results contain "trap" warnings ("千万别" "注意"), be sure to include them
- When
max_scoreis 0 or results are empty, do not fabricate — honestly say "There is no relevant content in the note library. Would you like to add a new guide?"
Initialization Flow (first-time use)
Step 1 — Configure knowledge base path
python -m scripts.setup --set-vault /path/to/your/vault
/path/to/your/vault is the directory where you store your Benben Kingdom strategy markdown files.
Step 2 — Build index
python -m scripts.index_vault
Scans all .md files in the vault directory, splits them into sections by ## headings, and generates ~/.benben-kingdom/index.json.
For subsequent usage, just ask questions directly — the index is already built.
Incremental Update Flow
A. Local markdown file
python -m scripts.add_source --path <absolute path>
B. Webpage / WeChat public account URL
- Use the
wechat-article-pdfskill (or other tools) to convert the URL to markdown, save to a temporary file - Run:
python -m scripts.add_source --path /tmp/benben-xxx.md \
--origin-url <original URL> --title "<article title>"
C. Directly pasted text
Write to a temporary md file, then follow path A, using --title to specify the title.
The index is automatically rebuilt after each incremental update; no extra steps needed.
Script Quick Reference
All scripts are run from the skill directory with python -m scripts.<name>:
| Script | Purpose | Key Parameters |
|---|---|---|
setup.py | Check dependencies, initialize | --check, --reset |
index_vault.py | Build JSON index | --vault <path> |
add_source.py | Add/update a single md and rebuild index | --path, --origin-url, --title |
query.py | Keyword/BM25 retrieval, returns JSON | --question, --top-k |
Design Principles
- Keyword retrieval is the only entry point: All questions must go through
query.py; never read md files directly to answer. - Deterministic operations go to scripts, language understanding goes to the model: Index building and retrieval logic are clean and reliable; how to organize answers is up to Claude.
- Don't fabricate: If nothing is retrieved, say so. Game versions update quickly; a wrong answer is worse than no answer.
- Use player jargon: When players say "夯" "白嫖" "卡点" "上号子" "进队伍", use them directly — it feels like a veteran giving pointers.
Reference Documents
references/schemas.md— Script JSON schema / database table structurereferences/configuration.md— Configuration item descriptionsreferences/troubleshooting.md— Common errors (missing index file, wrong vault path, etc.)