# d-wiki Lightweight local knowledge retrieval for agent-facing context packs. The first version intentionally avoids embedding models and qmd runtime dependencies. It uses BM25 plus local metadata (`d-wiki.yml`, aliases, query entries, and page frontmatter) to return structured context that a caller can use to synthesize an answer. ## Language choice `d-wiki` is implemented in Python for v1. The main reasons are lower integration friction with `robogo_assistant_service`, a dependency-light local CLI, and a better fit for retrieval/evaluation scripts. See [`docs/language-decision.md`](docs/language-decision.md) for the Python vs TypeScript trade-off. ## CLI ```bash d-wiki status --format json d-wiki index --kb x5 d-wiki compile --kb robogo --force d-wiki compile --kb x5 --force --llm auto d-wiki search --kb x5 --query "如何在X5平台上点亮camera" --format json d-wiki get --kb x5 --id multimedia_development/7-camsys_debug --format json ``` `compile` builds an llm-wiki style `wiki/` under the knowledge base's `.d_wiki/` directory. After compilation, `search` prefers compiled wiki pages and falls back to raw sources when no compiled wiki exists. v2 adds optional LLM-assisted compilation: - `--llm off`: deterministic compile only. - `--llm auto`: use LLM synthesis when `D_WIKI_LLM_*` or `ROBOGO_LLM_*` environment variables are present; otherwise fall back to deterministic compile. - `--llm require`: fail if LLM configuration is missing or synthesis fails. - `--llm-scope queries`: default, only synthesize curated `queries/*.md` concept pages. - `--llm-scope all`: synthesize every compiled concept page. LLM synthesis produces a stronger summary, answer blueprint, and synthesized evidence while preserving raw `Key Evidence` and source-map provenance. Use `D_WIKI_CONFIG=/path/to/d-wiki.yml` or `--config /path/to/d-wiki.yml`.