Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

feat: LLM generates optimized search queries during ingest for Deep Research

nash_su1d4e71cbe2f1
diff --git a/src/components/review/review-view.tsx b/src/components/review/review-view.tsx
index 6b808525..dac1bfde 100644
--- a/src/components/review/review-view.tsx
+++ b/src/components/review/review-view.tsx
@@ -44,9 +44,18 @@ export function ReviewView() {
const item = items.find((i) => i.id === id)
if (item) {
const llmConfig = useWikiStore.getState().llmConfig
- const topic = item.title.replace(/^(Save to Wiki|Create|Research)[:\s]*/i, "").trim() || item.description.split("\n")[0]
- queueResearch(project.path, topic, llmConfig, searchConfig)
- resolveItem(id, "Queued for research")
+ // Use pre-generated search queries if available, otherwise fall back to title
+ if (item.searchQueries && item.searchQueries.length > 0) {
+ // Queue a research task for each search query
+ for (const query of item.searchQueries) {
+ queueResearch(project.path, query, llmConfig, searchConfig)
+ }
+ resolveItem(id, `Queued ${item.searchQueries.length} research tasks`)
+ } else {
+ const topic = item.title.replace(/^(Save to Wiki|Create|Research)[:\s]*/i, "").trim() || item.description.split("\n")[0]
+ queueResearch(project.path, topic, llmConfig, searchConfig)
+ resolveItem(id, "Queued for research")
+ }
} else {
resolveItem(id, action)
}
diff --git a/src/lib/ingest.ts b/src/lib/ingest.ts
index bed31681..81410f09 100644
--- a/src/lib/ingest.ts
+++ b/src/lib/ingest.ts
@@ -203,10 +203,17 @@ function parseReviewBlocks(
? pagesMatch[1].split(",").map((p) => p.trim())
: undefined
- // Description is the body minus OPTIONS and PAGES lines
+ // Parse SEARCH line (optimized search queries for Deep Research)
+ const searchMatch = body.match(/^SEARCH:\s*(.+)$/m)
+ const searchQueries = searchMatch
+ ? searchMatch[1].split("|").map((q) => q.trim()).filter((q) => q.length > 0)
+ : undefined
+
+ // Description is the body minus OPTIONS, PAGES, and SEARCH lines
const description = body
.replace(/^OPTIONS:.*$/m, "")
.replace(/^PAGES:.*$/m, "")
+ .replace(/^SEARCH:.*$/m, "")
.trim()
items.push({
@@ -215,6 +222,7 @@ function parseReviewBlocks(
description,
sourcePath,
affectedPages,
+ searchQueries,
options,
})
}
@@ -306,6 +314,7 @@ function buildGenerationPrompt(schema: string, purpose: string, index: string):
"Description of what needs the user's attention.",
"OPTIONS: Option A | Option B | Option C",
"PAGES: wiki/page1.md, wiki/page2.md",
+ "SEARCH: search query 1 | search query 2 | search query 3",
"---END REVIEW---",
"",
"Review types and when to use:",
@@ -314,6 +323,12 @@ function buildGenerationPrompt(schema: string, purpose: string, index: string):
"- missing-page: an important concept is referenced but has no dedicated page",
"- suggestion: ideas for further research, related sources to look for, or connections worth exploring",
"",
+ "IMPORTANT for suggestion and missing-page types:",
+ "- The SEARCH field must contain 2-3 web search queries optimized for finding relevant papers, articles, or documentation.",
+ "- These should be specific, keyword-rich queries suitable for a search engine — NOT titles or sentences.",
+ "- Example: for a suggestion about 'automated debt detection in AI-generated code', good SEARCH queries would be:",
+ " SEARCH: automated technical debt detection AI generated code | software quality metrics LLM code generation | static analysis tools agentic software development",
+ "",
"Only create reviews for things that genuinely need human input. Don't create trivial reviews.",
"",
purpose ? `## Wiki Purpose\n${purpose}` : "",
diff --git a/src/stores/review-store.ts b/src/stores/review-store.ts
index a563e4bd..541bdfd0 100644
--- a/src/stores/review-store.ts
+++ b/src/stores/review-store.ts
@@ -12,6 +12,7 @@ export interface ReviewItem {
description: string
sourcePath?: string
affectedPages?: string[]
+ searchQueries?: string[]
options: ReviewOption[]
resolved: boolean
resolvedAction?: string