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: inject project schema into the analysis prompt
Dongmin, Yuf7140761480b
diff --git a/src/lib/ingest.prompt.test.ts b/src/lib/ingest.prompt.test.tsindex c74f2f8f..757a1a4e 100644--- a/src/lib/ingest.prompt.test.ts+++ b/src/lib/ingest.prompt.test.ts@@ -53,6 +53,25 @@ describe("buildAnalysisPrompt language directive", () => {expect(prompt).toContain("Which named subject is each claim about")expect(prompt).toContain("Do not transfer claims, limits, or evaluations")})++ it("injects the project schema so analysis can recommend custom-typed pages", () => {+ const schema = "## Page Types\n| goal | wiki/goals/ | Outcomes |\n| habit | wiki/habits/ | Behaviours |"+ const prompt = buildAnalysisPrompt("", "", "", schema)+ expect(prompt).toContain("## Project Schema")+ expect(prompt).toContain("wiki/goals/")+ // Recommendations guidance must mention schema-defined types+ expect(prompt).toContain("goal, habit")+ })++ it("omits the schema section when no schema is provided", () => {+ const prompt = buildAnalysisPrompt("", "", "")+ expect(prompt).not.toContain("## Project Schema")+ })++ it("does not invent schema content not present in the source", () => {+ const prompt = buildAnalysisPrompt("", "", "", "| goal | wiki/goals/ | x |")+ expect(prompt).toContain("never invent")+ })})describe("buildGenerationPrompt language directive", () => {diff --git a/src/lib/ingest.ts b/src/lib/ingest.tsindex 71121622..0f746498 100644--- a/src/lib/ingest.ts+++ b/src/lib/ingest.ts@@ -809,7 +809,7 @@ async function autoIngestImpl(await streamChat(llmConfig,[- { role: "system", content: buildAnalysisPrompt(purpose, index, sourceContext) },+ { role: "system", content: buildAnalysisPrompt(purpose, index, sourceContext, schema) },{ role: "user", content: `Analyze this source document:\n\n**File:** ${sourceIdentity}${folderContext ? `\n**Folder context:** ${folderContext}` : ""}\n\n---\n\n${sourceContext}` },],{@@ -1744,7 +1744,12 @@ function shouldRunDedicatedReviewStage(generation: string): boolean {* Step 1 prompt: AI reads the source and produces a structured analysis.* This is the "discussion" step — the AI reasons about the source before writing wiki pages.*/-export function buildAnalysisPrompt(purpose: string, index: string, sourceContent: string = ""): string {+export function buildAnalysisPrompt(+ purpose: string,+ index: string,+ sourceContent: string = "",+ schema: string = "",+): string {return ["You are an expert research analyst. Read the source document and produce a structured analysis.","Do not output chain-of-thought, hidden reasoning, or a thinking transcript. Reason internally and write only the concise final analysis.",@@ -1781,6 +1786,7 @@ export function buildAnalysisPrompt(purpose: string, index: string, sourceConten"","## Recommendations","- What wiki pages should be created or updated?",+ "- If the project schema (below) defines page types beyond entity/concept (e.g. goal, habit, reflection, finding, decision, meeting), and the source genuinely contains matching content, recommend pages of those types — name the type explicitly. Only when the source actually supports it; never invent goals/habits/journal entries that aren't in the source.","- What should be emphasized vs. de-emphasized?","- Any open questions worth flagging for the user?","",@@ -1788,6 +1794,9 @@ export function buildAnalysisPrompt(purpose: string, index: string, sourceConten"","If a folder context is provided, use it as a hint for categorization — the folder structure often reflects the user's organizational intent (e.g., 'papers/energy' suggests the file is an energy-related paper).","",+ schema+ ? `## Project Schema (page types available — map source content to schema-defined types when it fits)\n${schema}`+ : "",purpose ? `## Wiki Purpose (for context)\n${purpose}` : "",index ? `## Current Wiki Index (for checking existing content)\n${index}` : "",].filter(Boolean).join("\n")