skills/llm-wiki/phases/query.md

90 lines
2.5 KiB
Markdown

# Phase: Query — Answer Questions from the Wiki
Run when user asks a question about wiki content: "what does my wiki say about X", "summarize X", "compare A and B", "what's the latest on X".
## Step 1 — Read the index
```bash
Read wiki/index.md
```
Scan all entries. Identify which pages are most relevant to the question. Note their paths.
## Step 2 — Read relevant pages (parallel)
Read 3-7 most relevant pages simultaneously. Prioritize:
- Pages directly about the topic
- Pages of key entities mentioned
- Recent sources (check dates in index)
```bash
# Use parallel Read calls
Read wiki/sources/<slug>.md
Read wiki/concepts/<slug>.md
Read wiki/entities/<slug>.md
```
For large pages, use `grep` to find the relevant sections:
```bash
grep -n "keyword" wiki/sources/source-slug.md
```
## Step 3 — Synthesize answer
Write the answer with:
- `[[WikiLink]]` citations for every claim (Obsidian-compatible)
- Explicit notes on contradictions: "Source A says X, but [[Source B]] argues Y"
- Confidence indicators when information is sparse
- Date context: "As of [[2026-01-15 ingest]], the consensus was..."
Answer formats depending on question type:
**Factual question:** bullet list with citations
**Comparison:** markdown table
**Overview:** structured prose with headers
**Trend analysis:** chronological summary
## Step 4 — Offer to file the answer
After answering, say:
> "Want me to save this as a wiki page? It'll be available for future queries and show up in the graph view."
If yes, write to `wiki/queries/<slug>.md`:
```markdown
---
title: "Query: [Question]"
date: YYYY-MM-DD
type: query
tags: [relevant-tags]
---
# [Question]
[Full answer with WikiLinks]
## Sources Consulted
- [[Source A]]
- [[Concept B]]
- [[Entity C]]
```
Then add to `wiki/index.md` and append to `wiki/log.md`:
```
## [YYYY-MM-DD] query | Question text
- Answer filed: wiki/queries/<slug>.md
- Sources consulted: [[A]], [[B]], [[C]]
```
## Step 5 — Suggest follow-up
End every query response with 1-2 suggested follow-up questions or sources to investigate. Example:
> "Related: you might also want to ask about [[Concept X]] — it's referenced in 4 sources but doesn't have its own page yet. Want me to create one?"
## Output Formats
For complex queries, offer alternate formats:
- **Comparison table** — for "compare A vs B" questions
- **Timeline** — for "history of X" questions
- **Marp slide deck** — for presentations (`---` slide separators, works in Obsidian Marp plugin)
- **New wiki page** — for analyses worth keeping permanently