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

Complete research wiki type support

nash_sub1d0fea8b3a5
diff --git a/src/components/chat/chat-message.tsx b/src/components/chat/chat-message.tsx
index ae23d8eb..2636dc83 100644
--- a/src/components/chat/chat-message.tsx
+++ b/src/components/chat/chat-message.tsx
@@ -7,7 +7,7 @@ import "katex/dist/katex.min.css"
import {
Bot, User, FileText, BookmarkPlus, ChevronDown, ChevronRight, RefreshCw, Copy, Check,
Users, Lightbulb, BookOpen, HelpCircle, GitMerge, BarChart3, Layout, Globe,
- Image as ImageIcon,
+ TrendingUp, Target, Image as ImageIcon,
} from "lucide-react"
import { useWikiStore } from "@/stores/wiki-store"
import { readFile, writeFile, listDirectory } from "@/commands/fs"
@@ -24,6 +24,7 @@ import { findRawSourceForImage, imageUrlToAbsolute } from "@/lib/raw-source-reso
import { detectLanguage } from "@/lib/detect-language"
import { getHtmlLang, getTextDirection } from "@/lib/language-metadata"
import { MermaidDiagram, unwrapMermaidPre } from "@/components/mermaid-diagram"
+import { inferWikiTypeFromPath } from "@/lib/wiki-page-types"
// Module-level cache of source file names
let cachedSourceFiles: string[] = []
@@ -276,20 +277,16 @@ const REF_TYPE_CONFIG: Record<string, { icon: typeof FileText; color: string }>
query: { icon: HelpCircle, color: "text-green-500" },
synthesis: { icon: GitMerge, color: "text-red-500" },
comparison: { icon: BarChart3, color: "text-teal-500" },
+ finding: { icon: TrendingUp, color: "text-purple-500" },
+ thesis: { icon: Target, color: "text-rose-500" },
+ methodology: { icon: BookOpen, color: "text-teal-500" },
overview: { icon: Layout, color: "text-yellow-500" },
clip: { icon: Globe, color: "text-blue-400" },
}
function getRefType(path: string): string {
- if (path.includes("/entities/")) return "entity"
- if (path.includes("/concepts/")) return "concept"
- if (path.includes("/sources/")) return "source"
- if (path.includes("/queries/")) return "query"
- if (path.includes("/synthesis/")) return "synthesis"
- if (path.includes("/comparisons/")) return "comparison"
- if (path.includes("overview")) return "overview"
if (path.includes("raw/sources/")) return "clip"
- return "source"
+ return inferWikiTypeFromPath(path) ?? "source"
}
/**
diff --git a/src/components/graph/graph-view.tsx b/src/components/graph/graph-view.tsx
index b0947f63..34482123 100644
--- a/src/components/graph/graph-view.tsx
+++ b/src/components/graph/graph-view.tsx
@@ -27,6 +27,9 @@ const NODE_TYPE_COLORS: Record<string, string> = {
synthesis: "#f87171", // red-400
overview: "#facc15", // yellow-400
comparison: "#2dd4bf", // teal-400
+ finding: "#a855f7", // purple-500
+ thesis: "#f43f5e", // rose-500
+ methodology: "#14b8a6", // teal-500
other: "#94a3b8", // slate-400
}
@@ -385,6 +388,9 @@ export function GraphView() {
synthesis: t("graph.nodeTypeLabels.synthesis"),
overview: t("graph.nodeTypeLabels.overview"),
comparison: t("graph.nodeTypeLabels.comparison"),
+ finding: t("graph.nodeTypeLabels.finding"),
+ thesis: t("graph.nodeTypeLabels.thesis"),
+ methodology: t("graph.nodeTypeLabels.methodology"),
other: t("graph.nodeTypeLabels.other"),
})
}, [t])
diff --git a/src/components/layout/activity-panel.tsx b/src/components/layout/activity-panel.tsx
index b28d2222..35902898 100644
--- a/src/components/layout/activity-panel.tsx
+++ b/src/components/layout/activity-panel.tsx
@@ -2,7 +2,7 @@ import { useState, useEffect, useRef, useCallback } from "react"
import {
ChevronUp, ChevronDown, Loader2, CheckCircle2, AlertCircle,
FileText, Users, Lightbulb, BookOpen, GitMerge, BarChart3, HelpCircle, Layout,
- RotateCcw, X, Clock,
+ RotateCcw, X, Clock, TrendingUp, Target,
} from "lucide-react"
import { useActivityStore, type ActivityItem } from "@/stores/activity-store"
import { useWikiStore } from "@/stores/wiki-store"
@@ -23,6 +23,7 @@ import {
retryFileChangeTask,
type FileChangeTask,
} from "@/commands/file-sync"
+import { inferWikiTypeFromPath, wikiTypeLabel } from "@/lib/wiki-page-types"
const FILE_TYPE_ICONS: Record<string, typeof FileText> = {
sources: BookOpen,
@@ -31,9 +32,31 @@ const FILE_TYPE_ICONS: Record<string, typeof FileText> = {
queries: HelpCircle,
synthesis: GitMerge,
comparisons: BarChart3,
+ findings: TrendingUp,
+ thesis: Target,
+ methodology: BookOpen,
+ overview: Layout,
+}
+
+const WIKI_TYPE_ICON_KEYS: Record<string, keyof typeof FILE_TYPE_ICONS> = {
+ entity: "entities",
+ concept: "concepts",
+ source: "sources",
+ query: "queries",
+ synthesis: "synthesis",
+ comparison: "comparisons",
+ finding: "findings",
+ thesis: "thesis",
+ methodology: "methodology",
+ overview: "overview",
}
function getFileTypeInfo(path: string): { icon: typeof FileText; type: string } {
+ const inferred = inferWikiTypeFromPath(path)
+ if (inferred) {
+ const directoryIcon = FILE_TYPE_ICONS[WIKI_TYPE_ICON_KEYS[inferred]]
+ return { icon: directoryIcon ?? FileText, type: wikiTypeLabel(inferred) }
+ }
for (const [dir, icon] of Object.entries(FILE_TYPE_ICONS)) {
if (path.includes(`/${dir}/`) || path.startsWith(`wiki/${dir}/`)) {
return { icon, type: dir.charAt(0).toUpperCase() + dir.slice(1, -1) }
diff --git a/src/components/layout/knowledge-tree.tsx b/src/components/layout/knowledge-tree.tsx
index a693def9..1368f792 100644
--- a/src/components/layout/knowledge-tree.tsx
+++ b/src/components/layout/knowledge-tree.tsx
@@ -9,6 +9,7 @@ import { readFile, listDirectory } from "@/commands/fs"
import type { FileNode } from "@/types/wiki"
import { normalizePath } from "@/lib/path-utils"
import { cascadeDeleteWikiPagesWithRefs } from "@/lib/wiki-page-delete"
+import { inferWikiTypeFromPath } from "@/lib/wiki-page-types"
interface WikiPageInfo {
path: string
@@ -326,16 +327,7 @@ function parsePageInfo(path: string, fileName: string, content: string): WikiPag
// Fallback: infer type from path
if (type === "other") {
- if (path.includes("/entities/")) type = "entity"
- else if (path.includes("/concepts/")) type = "concept"
- else if (path.includes("/sources/")) type = "source"
- else if (path.includes("/queries/")) type = "query"
- else if (path.includes("/comparisons/")) type = "comparison"
- else if (path.includes("/synthesis/")) type = "synthesis"
- else if (path.includes("/findings/")) type = "finding"
- else if (path.includes("/thesis/")) type = "thesis"
- else if (path.includes("/methodology/")) type = "methodology"
- else if (fileName === "overview.md") type = "overview"
+ type = inferWikiTypeFromPath(path, fileName) ?? "other"
}
return { path, title, type, tags, origin }
diff --git a/src/i18n/en.json b/src/i18n/en.json
index a61ca6e5..4cb3e028 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -570,6 +570,9 @@
"synthesis": "Synthesis",
"overview": "Overview",
"comparison": "Comparison",
+ "finding": "Finding",
+ "thesis": "Thesis",
+ "methodology": "Methodology",
"other": "Other"
}
},
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 1e4d09e1..39b2146e 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -570,6 +570,9 @@
"synthesis": "综合",
"overview": "概述",
"comparison": "比较",
+ "finding": "发现",
+ "thesis": "论点",
+ "methodology": "方法论",
"other": "其他"
}
},
diff --git a/src/lib/ingest.ts b/src/lib/ingest.ts
index a64616a6..5b5ade67 100644
--- a/src/lib/ingest.ts
+++ b/src/lib/ingest.ts
@@ -21,6 +21,7 @@ import {
} from "@/lib/extract-source-images"
import { captionMarkdownImages, loadCaptionCache } from "@/lib/image-caption-pipeline"
import type { MultimodalConfig } from "@/stores/wiki-store"
+import { GENERATION_WIKI_TYPES } from "@/lib/wiki-page-types"
/**
* Resolve the LLM config that the caption pipeline should use.
@@ -1127,7 +1128,7 @@ export function buildGenerationPrompt(
" write `related: [a, b]` with bare slugs.",
"",
"Required fields and types:",
- " • type — one of: source | entity | concept | comparison | query | synthesis",
+ ` • type — one of: ${GENERATION_WIKI_TYPES.join(" | ")}`,
" • title — string (quote it if it contains a colon, e.g. `title: \"Foo: Bar\"`)",
" • created — date in YYYY-MM-DD form (no quotes)",
" • updated — same as created",
diff --git a/src/lib/wiki-page-types.test.ts b/src/lib/wiki-page-types.test.ts
new file mode 100644
index 00000000..f51a9832
--- /dev/null
+++ b/src/lib/wiki-page-types.test.ts
@@ -0,0 +1,39 @@
+import { describe, expect, it } from "vitest"
+import { GENERATION_WIKI_TYPES, inferWikiTypeFromPath, wikiTypeLabel } from "./wiki-page-types"
+
+describe("inferWikiTypeFromPath", () => {
+ it("recognizes core wiki directories", () => {
+ expect(inferWikiTypeFromPath("/project/wiki/entities/ada-lovelace.md")).toBe("entity")
+ expect(inferWikiTypeFromPath("/project/wiki/concepts/attention.md")).toBe("concept")
+ expect(inferWikiTypeFromPath("/project/wiki/sources/paper.md")).toBe("source")
+ expect(inferWikiTypeFromPath("/project/wiki/queries/open-question.md")).toBe("query")
+ expect(inferWikiTypeFromPath("/project/wiki/comparisons/model-a-vs-b.md")).toBe("comparison")
+ expect(inferWikiTypeFromPath("/project/wiki/synthesis/summary.md")).toBe("synthesis")
+ })
+
+ it("recognizes research-template wiki directories", () => {
+ expect(inferWikiTypeFromPath("/project/wiki/findings/result.md")).toBe("finding")
+ expect(inferWikiTypeFromPath("/project/wiki/thesis/main-claim.md")).toBe("thesis")
+ expect(inferWikiTypeFromPath("/project/wiki/methodology/systematic-review.md")).toBe("methodology")
+ })
+
+ it("handles Windows separators and overview pages", () => {
+ expect(inferWikiTypeFromPath("C:\\wiki\\findings\\result.md")).toBe("finding")
+ expect(inferWikiTypeFromPath("/project/wiki/overview.md")).toBe("overview")
+ expect(inferWikiTypeFromPath("/project/wiki/misc/foo.md")).toBeNull()
+ })
+})
+
+describe("wikiTypeLabel", () => {
+ it("uses readable singular labels for research-template types", () => {
+ expect(wikiTypeLabel("finding")).toBe("Finding")
+ expect(wikiTypeLabel("thesis")).toBe("Thesis")
+ expect(wikiTypeLabel("methodology")).toBe("Methodology")
+ })
+
+ it("keeps generation prompt type list aligned with research-template types", () => {
+ expect(GENERATION_WIKI_TYPES).toContain("finding")
+ expect(GENERATION_WIKI_TYPES).toContain("thesis")
+ expect(GENERATION_WIKI_TYPES).toContain("methodology")
+ })
+})
diff --git a/src/lib/wiki-page-types.ts b/src/lib/wiki-page-types.ts
new file mode 100644
index 00000000..cbf61718
--- /dev/null
+++ b/src/lib/wiki-page-types.ts
@@ -0,0 +1,42 @@
+export const GENERATION_WIKI_TYPES = [
+ "source",
+ "entity",
+ "concept",
+ "comparison",
+ "query",
+ "synthesis",
+ "thesis",
+ "methodology",
+ "finding",
+] as const
+
+const WIKI_TYPE_DIRS: Array<{ dir: string; type: string }> = [
+ { dir: "entities", type: "entity" },
+ { dir: "concepts", type: "concept" },
+ { dir: "sources", type: "source" },
+ { dir: "queries", type: "query" },
+ { dir: "comparisons", type: "comparison" },
+ { dir: "synthesis", type: "synthesis" },
+ { dir: "findings", type: "finding" },
+ { dir: "thesis", type: "thesis" },
+ { dir: "methodology", type: "methodology" },
+]
+
+export function inferWikiTypeFromPath(path: string, fileName?: string): string | null {
+ const normalized = path.replace(/\\/g, "/").toLowerCase()
+ for (const { dir, type } of WIKI_TYPE_DIRS) {
+ if (normalized.includes(`/wiki/${dir}/`) || normalized.includes(`/${dir}/`) || normalized.startsWith(`wiki/${dir}/`)) {
+ return type
+ }
+ }
+ const name = (fileName ?? normalized.split("/").pop() ?? "").toLowerCase()
+ if (name === "overview.md" || normalized.includes("/overview.md")) return "overview"
+ return null
+}
+
+export function wikiTypeLabel(type: string): string {
+ if (type === "thesis") return "Thesis"
+ if (type === "methodology") return "Methodology"
+ if (type === "finding") return "Finding"
+ return type.charAt(0).toUpperCase() + type.slice(1)
+}
diff --git a/src/lib/wiki-type-style.test.ts b/src/lib/wiki-type-style.test.ts
index d0215364..7d99dcd2 100644
--- a/src/lib/wiki-type-style.test.ts
+++ b/src/lib/wiki-type-style.test.ts
@@ -38,7 +38,7 @@ describe("getWikiTypeStyle", () => {
it("covers every documented page type", () => {
const expected = [
"entity", "concept", "query", "source",
- "thesis", "finding", "event", "overview",
+ "thesis", "finding", "methodology", "event", "overview",
]
for (const t of expected) {
const style = getWikiTypeStyle(t)
diff --git a/src/lib/wiki-type-style.ts b/src/lib/wiki-type-style.ts
index f75e1665..1537d87d 100644
--- a/src/lib/wiki-type-style.ts
+++ b/src/lib/wiki-type-style.ts
@@ -65,6 +65,12 @@ export const WIKI_TYPE_STYLES: Record<string, WikiTypeStyle> = {
chipClass: "bg-purple-500/15 text-purple-700 dark:text-purple-300",
dotClass: "bg-purple-500",
},
+ methodology: {
+ label: "Methodology",
+ icon: BookOpen,
+ chipClass: "bg-teal-500/15 text-teal-700 dark:text-teal-300",
+ dotClass: "bg-teal-500",
+ },
event: {
label: "Event",
icon: Calendar,