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

fix: guarantee source summary page is always created after ingest

nash_su64093eb3cba3
diff --git a/src/lib/ingest.ts b/src/lib/ingest.ts
index 2d6d6c33..2e86f502 100644
--- a/src/lib/ingest.ts
+++ b/src/lib/ingest.ts
@@ -109,6 +109,38 @@ export async function autoIngest(
activity.updateItem(activityId, { detail: "Writing files..." })
const writtenPaths = await writeFileBlocks(projectPath, generation)
+ // Ensure source summary page exists (LLM may not have generated it correctly)
+ const sourceBaseName = fileName.replace(/\.[^.]+$/, "")
+ const sourceSummaryPath = `wiki/sources/${sourceBaseName}.md`
+ const sourceSummaryFullPath = `${projectPath}/${sourceSummaryPath}`
+ const hasSourceSummary = writtenPaths.some((p) => p.startsWith("wiki/sources/"))
+
+ if (!hasSourceSummary) {
+ const date = new Date().toISOString().slice(0, 10)
+ const fallbackContent = [
+ "---",
+ `type: source`,
+ `title: "Source: ${fileName}"`,
+ `created: ${date}`,
+ `updated: ${date}`,
+ `sources: ["${fileName}"]`,
+ `tags: []`,
+ `related: []`,
+ "---",
+ "",
+ `# Source: ${fileName}`,
+ "",
+ analysis ? analysis.slice(0, 3000) : "(Analysis not available)",
+ "",
+ ].join("\n")
+ try {
+ await writeFile(sourceSummaryFullPath, fallbackContent)
+ writtenPaths.push(sourceSummaryPath)
+ } catch {
+ // non-critical
+ }
+ }
+
if (writtenPaths.length > 0) {
try {
const tree = await listDirectory(projectPath)