CommunityResearch & Data Analysisgithub.com

colin4k/benben-kingdom-skill

A dedicated strategy guide assistant for players of Benben Kingdom. It reads a local directory of markdown files, builds a JSON index, and answers questions about the game using keyword/BM25 retrieval. **This skill must trigger whenever the user message contains "Benben" or "Benben Kingdom"** — whether asking for guides, hero builds, exchange tips, event strategies, or adding a new public account article / webpage / local md to the knowledge base.

What is benben-kingdom-skill?

This skill is a specialized game assistant for "Benben Kingdom" (奔奔王国) players. It operates by scanning a configured local directory of markdown strategy notes, splitting each file into sections based on `##` headings, and building a persistent JSON index (stored at `~/.benben-kingdom/index.json`). All queries are answered via BM25 keyword retrieval — no embedding models or vector databases are used. The skill supports three main workflows: an initial setup and indexing phase, a query flow that runs `python -m scripts.query --question "<question>" --top-k 8` to retrieve the most relevant chunks and answer with authentic in-game slang, and an incremental update flow that can add new content from local markdown files, web URLs (including WeChat public account articles), or pasted text. It explicitly triggers whenever the user's message contains "Benben" or "Benben Kingdom". The design philosophy emphasizes deterministic script operations, keeping language understanding to the model, never fabricating content, and always using player-specific terminology (like "夯", "白嫖", "号角", "试炼"). It is useful for any developer or AI agent user integrating a fan-made wiki into a chat assistant, ensuring consistent, offline-capable, and human-readable retrieval.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add colin4k/benben-kingdom-skill

Installed? Explore more Research & Data Analysis skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

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

  1. Build/Rebuild Index — Splits all md files in the configured directory into sections by ## headings, writes to a JSON index file
  2. Semantic Query — Performs BM25 keyword retrieval on player questions, returns the most relevant chunks, and Claude organizes the answer in game terminology using context
  3. 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.

  1. Run: python -m scripts.query --question "<user question>" --top-k 8
  2. Parse the returned JSON (structure in references/schemas.md), take the _footer field 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
  3. Organize the answer using the retrieval results, append the _footer value 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
  4. When max_score is 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

  1. Use the wechat-article-pdf skill (or other tools) to convert the URL to markdown, save to a temporary file
  2. 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>:

ScriptPurposeKey Parameters
setup.pyCheck dependencies, initialize--check, --reset
index_vault.pyBuild JSON index--vault <path>
add_source.pyAdd/update a single md and rebuild index--path, --origin-url, --title
query.pyKeyword/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 structure
  • references/configuration.md — Configuration item descriptions
  • references/troubleshooting.md — Common errors (missing index file, wrong vault path, etc.)

Related Skills