wiki-query
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWiki Query — Knowledge Retrieval
Wiki Query — 知识检索
You are answering questions against a compiled Obsidian wiki, not raw source documents. The wiki contains pre-synthesized, cross-referenced knowledge.
你将基于已编译的Obsidian wiki而非原始源文档回答问题,该wiki包含预先整合、交叉引用的知识。
Before You Start
开始之前
- Read to get
~/.obsidian-wiki/config(works from any project). Fall back toOBSIDIAN_VAULT_PATHif you're inside the obsidian-wiki repo..env - Read to understand the wiki's scope and structure
$OBSIDIAN_VAULT_PATH/index.md
- 读取获取
~/.obsidian-wiki/config(可在任意项目中使用)。如果你处于obsidian-wiki仓库内,则降级读取OBSIDIAN_VAULT_PATH文件获取路径。.env - 读取了解该wiki的覆盖范围和结构。
$OBSIDIAN_VAULT_PATH/index.md
Retrieval Protocol
检索协议
Follow the Retrieval Primitives table in . Reading is the dominant cost of this skill — use the cheapest primitive that answers the question and escalate only when it can't. Never jump straight to full-page reads.
llm-wiki/SKILL.md请遵循中的检索原语表。 读取操作是本技能的主要成本——使用可解答问题的最低成本原语,仅在无法解答时才升级操作,永远不要直接进行全页读取。
llm-wiki/SKILL.mdStep 1: Understand the Question
步骤1:理解问题
Classify the query type:
- Factual lookup — "What is X?" → Find the relevant page(s)
- Relationship query — "How does X relate to Y?" → Find both pages and their cross-references
- Synthesis query — "What's the current thinking on X?" → Find all pages that touch X, synthesize
- Gap query — "What don't I know about X?" → Find what's missing, check open questions sections
Also decide the mode:
- Index-only mode — triggered by "quick answer", "just scan", "don't read the pages", "fast lookup". Stops at Step 3. Answers from frontmatter + only.
index.md - Normal mode — the full tiered pipeline below.
对查询类型进行分类:
- 事实查找 — “X是什么?” → 查找相关页面
- 关联查询 — “X和Y有什么关联?” → 查找两个页面及其交叉引用内容
- 整合查询 — “目前对X的共识是什么?” → 查找所有涉及X的页面,整合内容
- 缺口查询 — “我对X的哪些内容还不了解?” → 查找缺失的内容,检查开放问题板块
同时确定运行模式:
- 仅索引模式 — 由“quick answer”“just scan”“don't read the pages”“fast lookup”触发,执行到步骤3即停止,仅基于frontmatter + 内容回答。
index.md - 正常模式 — 执行下文完整的分层流程。
Step 2: Index Pass (cheap)
步骤2:索引扫描(低成本)
Build a candidate set without opening any page bodies:
- You've already read above — use it as the first filter. It lists every page with a one-line description and tags.
index.md - Use to scan page frontmatter only for title, tag, alias, and summary matches. A pattern like
Grepscoped to vault^(title|tags|aliases|summary):files is far cheaper than content grep..md - Collect the top 5–10 candidate page paths ranked by:
- Exact title or alias match
- Tag match
- Summary field contains the query term
- entry contains the query term
index.md
If you're in index-only mode, stop here. Answer from fields, titles, and descriptions only. Label the answer clearly: "(index-only answer — page bodies not read; facts below are from page summaries and may miss nuance)". Then skip to Step 5.
summary:index.md无需打开任何页面正文即可构建候选集:
- 你已经读取过上文提到的——将其作为第一层筛选,它列出了所有页面的单行描述和标签。
index.md - 使用仅扫描页面的frontmatter,匹配标题、标签、别名和摘要。限定在知识库的
Grep文件中匹配.md模式的成本远低于内容全局grep。^(title|tags|aliases|summary): - 按以下规则排序,收集排名前5-10的候选页面路径:
- 标题或别名精确匹配
- 标签匹配
- 摘要字段包含查询词
- 条目包含查询词
index.md
如果你处于仅索引模式,在此处停止流程,仅基于字段、标题和描述回答问题,并明确标注答案:"(仅索引答案——未读取页面正文;以下事实来自页面摘要,可能遗漏细节)",然后直接跳至步骤5。
summary:index.mdStep 2b: QMD Semantic Pass (optional — requires QMD_WIKI_COLLECTION
in .env
)
QMD_WIKI_COLLECTION.env步骤2b:QMD语义扫描(可选——需要.env
中配置QMD_WIKI_COLLECTION
)
.envQMD_WIKI_COLLECTIONGUARD: If is empty or unset, skip this entire step and proceed to Step 3.
$QMD_WIKI_COLLECTIONNo QMD? Skip to Step 3 and usedirectly on the vault. QMD is faster and concept-aware but the grep path is fully functional. SeeGrepfor setup..env.example
If is set and the index pass didn't produce clear candidates — or the question requires semantic matching rather than exact terms — use QMD before reaching for :
QMD_WIKI_COLLECTIONGrepmcp__qmd__query:
collection: <QMD_WIKI_COLLECTION> # e.g. "knowledge-base-wiki"
intent: <the user's question>
searches:
- type: lex # keyword match — good for exact names, file paths, error messages
query: <key terms>
- type: vec # semantic match — good for concepts, patterns, "what is X like"
query: <question rephrased as a description>The returned snippets act as pre-read section summaries. If they answer the question fully, skip Step 3 and go straight to Step 4 (reading only the pages QMD ranked highest). If not, use the ranked file list to guide which files to grep or read in Step 3.
Also search when the question may have source material in :
papers_raw/If is set and the user is asking about a topic likely covered by ingested papers (research, theory, background), run a parallel search against the papers collection. Cite raw sources separately from compiled wiki pages in your answer.
QMD_PAPERS_COLLECTION防护逻辑:如果为空或未配置,跳过整个步骤直接进入步骤3。
$QMD_WIKI_COLLECTION没有QMD? 跳至步骤3直接对知识库使用即可。QMD速度更快且具备概念感知能力,但grep路径也可完全正常运行,查看Grep了解配置方法。.env.example
如果已配置,且索引扫描没有得到明确的候选集——或是问题需要语义匹配而非精确术语匹配,则在使用前先使用QMD:
QMD_WIKI_COLLECTIONGrepmcp__qmd__query:
collection: <QMD_WIKI_COLLECTION> # e.g. "knowledge-base-wiki"
intent: <the user's question>
searches:
- type: lex # keyword match — good for exact names, file paths, error messages
query: <key terms>
- type: vec # semantic match — good for concepts, patterns, "what is X like"
query: <question rephrased as a description>返回的片段可作为预读的章节摘要。如果这些内容已经可以完整回答问题,跳过步骤3直接进入步骤4(仅读取QMD排名最高的页面即可)。如果不能,则使用排序后的文件列表引导你在步骤3中对哪些文件进行grep或读取操作。
当问题可能存在目录下的源材料时,同时搜索集合:
_raw/papers如果已配置,且用户询问的主题可能被已收录的论文覆盖(研究、理论、背景知识),则并行对论文集合执行搜索。在回答中单独引用原始来源和已编译的wiki页面。
QMD_PAPERS_COLLECTIONStep 3: Section Pass (medium cost — only if Steps 2/2b are inconclusive)
步骤3:段落扫描(中等成本——仅当步骤2/2b无法得出明确结论时使用)
For each of the top candidates, pull the relevant section without reading the whole page:
- Use to get just the lines around the match.
Grep -A 10 -B 2 "<query-term>" <candidate-file> - This usually returns 15–30 lines per hit instead of 100–500.
- If the section grep gives a clear answer, go straight to Step 5.
对每个排名靠前的候选页面,仅提取相关段落,无需读取整个页面:
- 使用仅获取匹配项前后的行内容。
Grep -A 10 -B 2 "<query-term>" <candidate-file> - 通常每次命中仅返回15-30行内容,而非100-500行全页内容。
- 如果段落grep已经给出明确答案,直接进入步骤5。
Step 4: Full Read (expensive — last resort)
步骤4:全页读取(高成本——最后手段)
Only when Steps 2 and 3 don't answer the question:
- the top 3 candidates in full.
Read - Follow at most one hop of from those pages if the answer requires cross-references.
[[wikilinks]] - Check "Open Questions" sections for known gaps.
- If you're still short, then fall back to a broad content grep across the vault. Tell the user you escalated — this is the expensive path and they should know.
仅当步骤2和步骤3都无法解答问题时执行:
- 完整排名前3的候选页面。
Read - 如果答案需要交叉引用,最多从这些页面出发跟随1跳。
[[wikilinks]] - 检查“开放问题”板块确认已知的内容缺口。
- 如果仍然缺少信息,再降级对整个知识库执行广泛的内容grep。告知用户你升级了检索策略——这是高成本路径,用户有权知晓。
Step 5: Synthesize an Answer
步骤5:整合回答
Compose your answer from wiki content:
- Cite specific wiki pages using notation
[[page-name]] - Note which step the answer came from ("found in summary" vs "grepped section" vs "full page read") — helps the user understand confidence
- If the wiki has contradictions, present both sides
- If the wiki doesn't cover something, say so explicitly
- Suggest which sources might fill the gap
基于wiki内容组织你的答案:
- 使用格式引用具体的wiki页面
[[page-name]] - 注明答案来自哪个步骤(“摘要中找到”/“grep段落”/“全页读取”)——帮助用户理解答案置信度
- 如果wiki内容存在矛盾,同时呈现两方观点
- 如果wiki没有覆盖相关内容,明确告知用户
- 建议可以填补内容缺口的潜在来源
Step 6: Log the Query
步骤6:记录查询
Append to :
log.md- [TIMESTAMP] QUERY query="the user's question" result_pages=N mode=normal|index_only escalated=true|false追加到:
log.md- [TIMESTAMP] QUERY query="the user's question" result_pages=N mode=normal|index_only escalated=true|falseAnswer Format
回答格式
Structure answers like this:
Based on the wiki:[Your synthesized answer with [[wikilinks]] to source pages]Pages consulted: [[page-a]], [[page-b]], [[page-c]]Gaps: [What the wiki doesn't cover that might be relevant]
按如下结构组织回答:
基于wiki内容:[你整合后的回答,附带指向源页面的[[wikilinks]]]参考页面: [[page-a]], [[page-b]], [[page-c]]内容缺口: [wiki未覆盖的可能相关内容]