Query the wiki from any project session.
Query the wiki from any project session.
/wiki-search <query>
/wiki-search # (no args — ask what to search for)
When the user runs /wiki-search [query]:
Determine the wiki location in this order:
Check harness/config.yaml for wiki_path: key
grep -E "^\s*wiki_path:" harness/config.yaml
Check ~/.copilot/wiki.yaml for vault_path: key
grep -E "^\s*vault_path:" ~/.copilot/wiki.yaml
Fallback to ~/brain/
Store the resolved path in a variable: $WIKI_PATH
If argument provided: Use the argument as the search query directly.
If no argument: Ask the user:
What would you like to search for in the wiki?
Wait for their response and use it as the query.
Extract key search terms from the query (break on spaces, filter stop words, keep 3-5 terms).
For each term, use the Grep tool to search the wiki directory:
Search content:
Grep pattern: <term>
Path: <WIKI_PATH>/
Output mode: files_with_matches (to get a first pass)
Search metadata:
Grep pattern: <term>
Path: <WIKI_PATH>/
Patterns to search: Match in frontmatter tags, title fields, and page names
Output mode: files_with_matches
Compile a list of matching files. De-duplicate.
Index context:
Read <WIKI_PATH>/index.md if it exists to understand the wiki structure and get additional context clues.
For each matched file:
updated: or date: frontmatter field (recency)Select the top 3-5 matching pages.
For each top-ranked page:
[[Page Name]])Synthesize the answer across all pages:
[[Page Name]]After answering:
If the query reveals missing or insufficient wiki content:
The wiki doesn't have comprehensive coverage of [topic].
Would you like me to create a page on [topic]?
If user says yes:
<WIKI_PATH>/schema.md (if exists) for conventionstitle:, tags:, created:, updated:## headers<WIKI_PATH>/index.md under appropriate category<WIKI_PATH>/log.md:
- [wiki-search] Created "[Page Title]" in response to query: "[query]"
If user says no: Just acknowledge: "Got it. Let me know if you want to add it later."
Only if search returned meaningful results, append to <WIKI_PATH>/log.md:
- [wiki-search] "[query text]" → cited [N] pages
Keep log entries brief and scannable.
User: /wiki-search TypeScript type safety
Claude:
Searching wiki for: TypeScript, type, safety
Found 3 matching pages:
- TypeScript Best Practices (5 matches, updated 2 weeks ago)
- Type Safety Patterns (4 matches, updated 1 month ago)
- Angular Type System (2 matches, updated 3 months ago)
[Answer synthesized from pages]
Citing: [[TypeScript Best Practices]], [[Type Safety Patterns]]
User: /wiki-search
Claude:
What would you like to search for in the wiki?
User responds → proceeds with search.
User: /wiki-search Go error handling
Claude:
Searching wiki for: Go, error, handling
Found 1 matching page:
- Go Best Practices (2 matches)
[Answer from page]
The wiki doesn't have a dedicated page on Go error handling patterns.
Would you like me to create one?
If yes → creates page following schema.
The log at <WIKI_PATH>/log.md tracks useful searches:
# Wiki Search Log
- [wiki-search] "[query]" → cited [N] pages
- [wiki-search] "[query]" → no results found
- [wiki-search] Created "[Page Title]" in response to query: "[query]"
Log is optional but helpful for seeing what knowledge gets requested vs. what exists.