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: Windows path compatibility — normalize all paths to forward slashes
nash_su9a09c0369d48
diff --git a/src/components/chat/chat-message.tsx b/src/components/chat/chat-message.tsxindex 8cbd00ab..83cd0310 100644--- a/src/components/chat/chat-message.tsx+++ b/src/components/chat/chat-message.tsx@@ -13,6 +13,7 @@ import type { FileNode } from "@/types/wiki"import { convertLatexToUnicode } from "@/lib/latex-to-unicode"import { enrichWithWikilinks } from "@/lib/enrich-wikilinks"+import { normalizePath, getFileName } from "@/lib/path-utils"// Module-level cache of source file nameslet cachedSourceFiles: string[] = []@@ -22,7 +23,8 @@ export function useSourceFiles() {useEffect(() => {if (!project) return- listDirectory(`${project.path}/raw/sources`)+ const pp = normalizePath(project.path)+ listDirectory(`${pp}/raw/sources`).then((tree) => {cachedSourceFiles = flattenNames(tree)})@@ -118,6 +120,7 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: boolconst handleSave = useCallback(async () => {if (!project || saving) return+ const pp = normalizePath(project.path)setSaving(true)try {// Generate slug from first line or first 50 chars@@ -131,7 +134,7 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: bool.slice(0, 50)const date = new Date().toISOString().slice(0, 10)const fileName = `${slug}-${date}.md`- const filePath = `${project.path}/wiki/queries/${fileName}`+ const filePath = `${pp}/wiki/queries/${fileName}`// Strip hidden sources comment from contentconst cleanContent = content.replace(/<!--\s*sources:.*?-->/g, "").trimEnd()@@ -149,7 +152,7 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: boolawait writeFile(filePath, frontmatter + cleanContent)// Update index.md — append under ## Queries section- const indexPath = `${project.path}/wiki/index.md`+ const indexPath = `${pp}/wiki/index.md`let indexContent = ""try {indexContent = await readFile(indexPath)@@ -168,7 +171,7 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: boolawait writeFile(indexPath, indexContent)// Append to log.md- const logPath = `${project.path}/wiki/log.md`+ const logPath = `${pp}/wiki/log.md`let logContent = ""try {logContent = await readFile(logPath)@@ -179,7 +182,7 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: boolawait writeFile(logPath, logContent.trimEnd() + "\n" + logEntry)// Refresh file tree and update graph- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)useWikiStore.getState().bumpDataVersion()@@ -190,7 +193,7 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: boolconst llmConfig = useWikiStore.getState().llmConfigif (llmConfig.apiKey || llmConfig.provider === "ollama") {const { autoIngest } = await import("@/lib/ingest")- autoIngest(project.path, filePath, llmConfig).catch((err) =>+ autoIngest(pp, filePath, llmConfig).catch((err) =>console.error("Failed to auto-ingest saved query:", err))}@@ -288,17 +291,18 @@ function CitedReferencesPanel({ content, savedReferences }: { content: string; stype="button"onClick={async () => {if (!project) return+ const pp = normalizePath(project.path)// Try the given path first, then search all wiki subdirectories- const id = page.path.replace(/^wiki\//, "").replace(/\.md$/, "").split("/").pop() ?? ""+ const id = getFileName(page.path.replace(/^wiki\//, "").replace(/\.md$/, ""))const candidates = [- `${project.path}/${page.path}`,- `${project.path}/wiki/entities/${id}.md`,- `${project.path}/wiki/concepts/${id}.md`,- `${project.path}/wiki/sources/${id}.md`,- `${project.path}/wiki/queries/${id}.md`,- `${project.path}/wiki/synthesis/${id}.md`,- `${project.path}/wiki/comparisons/${id}.md`,- `${project.path}/wiki/${id}.md`,+ `${pp}/${page.path}`,+ `${pp}/wiki/entities/${id}.md`,+ `${pp}/wiki/concepts/${id}.md`,+ `${pp}/wiki/sources/${id}.md`,+ `${pp}/wiki/queries/${id}.md`,+ `${pp}/wiki/synthesis/${id}.md`,+ `${pp}/wiki/comparisons/${id}.md`,+ `${pp}/wiki/${id}.md`,]for (const candidate of candidates) {try {@@ -310,7 +314,7 @@ function CitedReferencesPanel({ content, savedReferences }: { content: string; s}}// Last resort: set the original path anyway- setSelectedFile(`${project.path}/${page.path}`)+ setSelectedFile(`${pp}/${page.path}`)}}className="flex w-full items-center gap-1.5 rounded px-1 py-0.5 text-left hover:bg-accent/50 transition-colors"title={page.path}@@ -605,10 +609,11 @@ function SourceRef({ fileName }: { fileName: string }) {e.preventDefault()e.stopPropagation()if (!project) return+ const pp = normalizePath(project.path)// Try exact match first, then search with the name as givenconst candidates = [- `${project.path}/raw/sources/${fileName}`,+ `${pp}/raw/sources/${fileName}`,]// If fileName has no extension, try to find a matching file@@ -616,7 +621,7 @@ function SourceRef({ fileName }: { fileName: string }) {for (const sf of cachedSourceFiles) {const stem = sf.replace(/\.[^.]+$/, "")if (stem === fileName || sf.startsWith(fileName)) {- candidates.unshift(`${project.path}/raw/sources/${sf}`)+ candidates.unshift(`${pp}/raw/sources/${sf}`)}}}@@ -662,14 +667,15 @@ function WikiLink({ pageName, children }: { pageName: string; children: React.ReuseEffect(() => {if (!project) return+ const pp = normalizePath(project.path)const candidates = [- `${project.path}/wiki/entities/${pageName}.md`,- `${project.path}/wiki/concepts/${pageName}.md`,- `${project.path}/wiki/sources/${pageName}.md`,- `${project.path}/wiki/queries/${pageName}.md`,- `${project.path}/wiki/comparisons/${pageName}.md`,- `${project.path}/wiki/synthesis/${pageName}.md`,- `${project.path}/wiki/${pageName}.md`,+ `${pp}/wiki/entities/${pageName}.md`,+ `${pp}/wiki/concepts/${pageName}.md`,+ `${pp}/wiki/sources/${pageName}.md`,+ `${pp}/wiki/queries/${pageName}.md`,+ `${pp}/wiki/comparisons/${pageName}.md`,+ `${pp}/wiki/synthesis/${pageName}.md`,+ `${pp}/wiki/${pageName}.md`,]let cancelled = falsediff --git a/src/components/chat/chat-panel.tsx b/src/components/chat/chat-panel.tsxindex 8e37382d..461c9889 100644--- a/src/components/chat/chat-panel.tsx+++ b/src/components/chat/chat-panel.tsx@@ -12,6 +12,7 @@ import { searchWiki } from "@/lib/search"import { buildRetrievalGraph, getRelatedNodes } from "@/lib/graph-relevance"import { useReviewStore } from "@/stores/review-store"import type { FileNode } from "@/types/wiki"+import { normalizePath, getFileName, getRelativePath } from "@/lib/path-utils"// Store the page mapping from the last query so SourceFilesBar can show which pages were citedexport let lastQueryPages: { title: string; path: string }[] = []@@ -167,6 +168,7 @@ export function ChatPanel() {const systemMessages: LLMMessage[] = []let queryRefs: { title: string; path: string }[] = []if (project) {+ const pp = normalizePath(project.path)const dataVersion = useWikiStore.getState().dataVersionconst maxCtx = llmConfig.maxContextSize || 204800@@ -176,12 +178,12 @@ export function ChatPanel() {const MAX_PAGE_SIZE = Math.min(Math.floor(PAGE_BUDGET * 0.3), 30_000)const [rawIndex, purpose] = await Promise.all([- readFile(`${project.path}/wiki/index.md`).catch(() => ""),- readFile(`${project.path}/purpose.md`).catch(() => ""),+ readFile(`${pp}/wiki/index.md`).catch(() => ""),+ readFile(`${pp}/purpose.md`).catch(() => ""),])// ── Phase 1: Tokenized search → top 10 ────────────────- const searchResults = await searchWiki(project.path, text)+ const searchResults = await searchWiki(pp, text)const topSearchResults = searchResults.slice(0, 10)// ── Trim index by relevance if over budget ─────────────@@ -212,13 +214,13 @@ export function ChatPanel() {}// ── Phase 2: Graph 1-level expansion ───────────────────- const graph = await buildRetrievalGraph(project.path, dataVersion)+ const graph = await buildRetrievalGraph(pp, dataVersion)const expandedIds = new Set<string>()const searchHitPaths = new Set(topSearchResults.map((r) => r.path))const graphExpansions: { title: string; path: string; relevance: number }[] = []for (const result of topSearchResults) {- const fileName = result.path.split("/").pop() ?? ""+ const fileName = getFileName(result.path)const nodeId = fileName.replace(/\.md$/, "")const related = getRelatedNodes(nodeId, graph, 3)for (const { node, relevance } of related) {@@ -240,7 +242,7 @@ export function ChatPanel() {if (usedChars >= PAGE_BUDGET) return falsetry {const raw = await readFile(filePath)- const relativePath = filePath.replace(project.path + "/", "")+ const relativePath = getRelativePath(filePath, pp)const truncated = raw.length > MAX_PAGE_SIZE? raw.slice(0, MAX_PAGE_SIZE) + "\n\n[...truncated...]": raw@@ -265,7 +267,7 @@ export function ChatPanel() {}// P3: Overview fallbackif (relevantPages.length === 0) {- await tryAddPage("Overview", `${project.path}/wiki/overview.md`, 3)+ await tryAddPage("Overview", `${pp}/wiki/overview.md`, 3)}const pagesContext = relevantPages.length > 0@@ -376,10 +378,11 @@ export function ChatPanel() {const handleWriteToWiki = useCallback(async () => {if (!project) return+ const pp = normalizePath(project.path)try {- await executeIngestWrites(project.path, llmConfig, undefined, undefined)+ await executeIngestWrites(pp, llmConfig, undefined, undefined)try {- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)} catch {// ignorediff --git a/src/components/editor/file-preview.tsx b/src/components/editor/file-preview.tsxindex 1e84b6d6..c996c6db 100644--- a/src/components/editor/file-preview.tsx+++ b/src/components/editor/file-preview.tsx@@ -10,6 +10,7 @@ import {} from "lucide-react"import { getFileCategory, getCodeLanguage } from "@/lib/file-types"import type { FileCategory } from "@/lib/file-types"+import { getFileName } from "@/lib/path-utils"interface FilePreviewProps {filePath: string@@ -18,7 +19,7 @@ interface FilePreviewProps {export function FilePreview({ filePath, textContent }: FilePreviewProps) {const category = getFileCategory(filePath)- const fileName = filePath.split("/").pop() ?? filePath+ const fileName = getFileName(filePath)switch (category) {case "image":diff --git a/src/components/graph/graph-view.tsx b/src/components/graph/graph-view.tsxindex a19dda84..d76bde8c 100644--- a/src/components/graph/graph-view.tsx+++ b/src/components/graph/graph-view.tsx@@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button"import { useWikiStore } from "@/stores/wiki-store"import { readFile } from "@/commands/fs"import { buildWikiGraph, type GraphNode, type GraphEdge } from "@/lib/wiki-graph"+import { normalizePath } from "@/lib/path-utils"const NODE_TYPE_COLORS: Record<string, string> = {entity: "#60a5fa", // blue-400@@ -247,7 +248,7 @@ export function GraphView() {setLoading(true)setError(null)try {- const result = await buildWikiGraph(project.path)+ const result = await buildWikiGraph(normalizePath(project.path))setNodes(result.nodes)setEdges(result.edges)lastLoadedVersion.current = useWikiStore.getState().dataVersiondiff --git a/src/components/layout/activity-panel.tsx b/src/components/layout/activity-panel.tsxindex 42ba38c5..16d3463b 100644--- a/src/components/layout/activity-panel.tsx+++ b/src/components/layout/activity-panel.tsx@@ -5,6 +5,7 @@ import {} from "lucide-react"import { useActivityStore, type ActivityItem } from "@/stores/activity-store"import { useWikiStore } from "@/stores/wiki-store"+import { normalizePath, getFileName } from "@/lib/path-utils"const FILE_TYPE_ICONS: Record<string, typeof FileText> = {sources: BookOpen,@@ -95,7 +96,8 @@ function ActivityRow({ item }: { item: ActivityItem }) {function handleFileClick(filePath: string) {if (!project) return- const fullPath = filePath.startsWith("/") ? filePath : `${project.path}/${filePath}`+ const pp = normalizePath(project.path)+ const fullPath = filePath.startsWith("/") ? normalizePath(filePath) : `${pp}/${filePath}`setSelectedFile(fullPath)}@@ -118,7 +120,7 @@ function ActivityRow({ item }: { item: ActivityItem }) {<div className="mt-1.5 ml-5 flex flex-col gap-0.5">{item.filesWritten.map((filePath) => {const { icon: Icon, type } = getFileTypeInfo(filePath)- const fileName = filePath.split("/").pop() ?? filePath+ const fileName = getFileName(filePath)return (<buttonkey={filePath}diff --git a/src/components/layout/app-layout.tsx b/src/components/layout/app-layout.tsxindex 50887df2..d410698e 100644--- a/src/components/layout/app-layout.tsx+++ b/src/components/layout/app-layout.tsx@@ -1,6 +1,7 @@import { useCallback, useEffect, useRef, useState } from "react"import { useWikiStore } from "@/stores/wiki-store"import { listDirectory } from "@/commands/fs"+import { normalizePath } from "@/lib/path-utils"import { IconSidebar } from "./icon-sidebar"import { SidebarPanel } from "./sidebar-panel"import { ContentArea } from "./content-area"@@ -27,7 +28,7 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {const loadFileTree = useCallback(async () => {if (!project) returntry {- const tree = await listDirectory(project.path)+ const tree = await listDirectory(normalizePath(project.path))setFileTree(tree)} catch (err) {console.error("Failed to load file tree:", err)diff --git a/src/components/layout/knowledge-tree.tsx b/src/components/layout/knowledge-tree.tsxindex 920d0b37..44be8a68 100644--- a/src/components/layout/knowledge-tree.tsx+++ b/src/components/layout/knowledge-tree.tsx@@ -6,6 +6,7 @@ import { ScrollArea } from "@/components/ui/scroll-area"import { useWikiStore } from "@/stores/wiki-store"import { readFile, listDirectory } from "@/commands/fs"import type { FileNode } from "@/types/wiki"+import { normalizePath } from "@/lib/path-utils"interface WikiPageInfo {path: string@@ -37,8 +38,9 @@ export function KnowledgeTree() {const loadPages = useCallback(async () => {if (!project) return+ const pp = normalizePath(project.path)try {- const wikiTree = await listDirectory(`${project.path}/wiki`)+ const wikiTree = await listDirectory(`${pp}/wiki`)const mdFiles = flattenMdFiles(wikiTree)const pageInfos: WikiPageInfo[] = []@@ -178,7 +180,8 @@ function RawSourcesSection() {useEffect(() => {if (!project) return- listDirectory(`${project.path}/raw/sources`)+ const pp = normalizePath(project.path)+ listDirectory(`${pp}/raw/sources`).then((tree) => setSources(flattenAllFiles(tree))).catch(() => setSources([]))}, [project])diff --git a/src/components/layout/preview-panel.tsx b/src/components/layout/preview-panel.tsxindex 1fcee9e4..b3b5bc2a 100644--- a/src/components/layout/preview-panel.tsx+++ b/src/components/layout/preview-panel.tsx@@ -5,6 +5,7 @@ import { readFile, writeFile } from "@/commands/fs"import { getFileCategory, isBinary } from "@/lib/file-types"import { WikiEditor } from "@/components/editor/wiki-editor"import { FilePreview } from "@/components/editor/file-preview"+import { getFileName } from "@/lib/path-utils"export function PreviewPanel() {const selectedFile = useWikiStore((s) => s.selectedFile)@@ -59,7 +60,7 @@ export function PreviewPanel() {}const category = getFileCategory(selectedFile)- const fileName = selectedFile.split("/").pop() ?? selectedFile+ const fileName = getFileName(selectedFile)return (<div className="flex h-full flex-col">diff --git a/src/components/layout/research-panel.tsx b/src/components/layout/research-panel.tsxindex 933063e1..abcb8850 100644--- a/src/components/layout/research-panel.tsx+++ b/src/components/layout/research-panel.tsx@@ -9,6 +9,7 @@ import { useResearchStore, type ResearchTask } from "@/stores/research-store"import { useWikiStore } from "@/stores/wiki-store"import { readFile } from "@/commands/fs"import { queueResearch } from "@/lib/deep-research"+import { normalizePath } from "@/lib/path-utils"export function ResearchPanel() {const tasks = useResearchStore((s) => s.tasks)@@ -30,7 +31,7 @@ export function ResearchPanel() {window.alert("Web Search not configured. Go to Settings → Web Search to add a Tavily API key.")return}- queueResearch(project.path, topic, llmConfig, searchApiConfig)+ queueResearch(normalizePath(project.path), topic, llmConfig, searchApiConfig)setInputValue("")}@@ -121,7 +122,7 @@ function ResearchTaskCard({ task, onRemove }: { task: ResearchTask; onRemove: (iasync function handleOpenSaved() {if (!project || !task.savedPath) return- const path = `${project.path}/${task.savedPath}`+ const path = `${normalizePath(project.path)}/${task.savedPath}`try {const content = await readFile(path)setSelectedFile(path)diff --git a/src/components/lint/lint-view.tsx b/src/components/lint/lint-view.tsxindex 96ac631f..50bba4b5 100644--- a/src/components/lint/lint-view.tsx+++ b/src/components/lint/lint-view.tsx@@ -16,6 +16,7 @@ import { useWikiStore } from "@/stores/wiki-store"import { useReviewStore } from "@/stores/review-store"import { runStructuralLint, runSemanticLint, type LintResult } from "@/lib/lint"import { readFile, writeFile, deleteFile, listDirectory } from "@/commands/fs"+import { normalizePath } from "@/lib/path-utils"const typeConfig: Record<string, { icon: typeof AlertTriangle; label: string }> = {orphan: { icon: Unlink, label: "Orphan Page" },@@ -41,14 +42,15 @@ export function LintView() {const handleRunLint = useCallback(async () => {if (!project || running) return+ const pp = normalizePath(project.path)setRunning(true)setResults([])try {- const structural = await runStructuralLint(project.path)+ const structural = await runStructuralLint(pp)let all = structuralif (runSemantic && (llmConfig.apiKey || llmConfig.provider === "ollama")) {- const semantic = await runSemanticLint(project.path, llmConfig)+ const semantic = await runSemanticLint(pp, llmConfig)all = [...structural, ...semantic]}@@ -63,9 +65,10 @@ export function LintView() {async function handleOpenPage(page: string) {if (!project) return+ const pp = normalizePath(project.path)const candidates = [- `${project.path}/wiki/${page}`,- `${project.path}/wiki/${page}.md`,+ `${pp}/wiki/${page}`,+ `${pp}/wiki/${page}.md`,]setActiveView("wiki")for (const path of candidates) {@@ -84,6 +87,7 @@ export function LintView() {async function handleFix(result: LintResult, index: number) {if (!project) return+ const pp = normalizePath(project.path)const id = `${result.type}-${index}`setFixingId(id)@@ -91,7 +95,7 @@ export function LintView() {switch (result.type) {case "orphan": {// Add a link to this page from index.md- const indexPath = `${project.path}/wiki/index.md`+ const indexPath = `${pp}/wiki/index.md`let indexContent = ""try { indexContent = await readFile(indexPath) } catch { indexContent = "# Wiki Index\n" }@@ -108,7 +112,7 @@ export function LintView() {case "broken-link": {// Option: remove the broken link from the page, or send to Review for manual fix- const pagePath = `${project.path}/wiki/${result.page}`+ const pagePath = `${pp}/wiki/${result.page}`useReviewStore.getState().addItem({type: "confirm",title: `Fix broken link in ${result.page}`,@@ -158,7 +162,7 @@ export function LintView() {}// Refresh tree- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)bumpDataVersion()} catch (err) {@@ -170,14 +174,15 @@ export function LintView() {async function handleDeleteOrphan(result: LintResult, index: number) {if (!project) return- const pagePath = `${project.path}/wiki/${result.page}`+ const pp = normalizePath(project.path)+ const pagePath = `${pp}/wiki/${result.page}`const confirmed = window.confirm(`Delete orphan page "${result.page}"?`)if (!confirmed) returntry {await deleteFile(pagePath)setResults((prev) => prev.filter((_, i) => i !== index))- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)bumpDataVersion()} catch (err) {diff --git a/src/components/project/create-project-dialog.tsx b/src/components/project/create-project-dialog.tsxindex 657a731d..4a8656da 100644--- a/src/components/project/create-project-dialog.tsx+++ b/src/components/project/create-project-dialog.tsx@@ -11,6 +11,7 @@ import { createProject, writeFile, createDirectory } from "@/commands/fs"import { getTemplate } from "@/lib/templates"import { TemplatePicker } from "@/components/project/template-picker"import type { WikiProject } from "@/types/wiki"+import { normalizePath } from "@/lib/path-utils"interface CreateProjectDialogProps {open: boolean@@ -45,12 +46,13 @@ export function CreateProjectDialog({ open: isOpen, onOpenChange, onCreated }: CsetError("")try {const project = await createProject(name.trim(), path.trim())+ const pp = normalizePath(project.path)const template = getTemplate(selectedTemplate)- await writeFile(`${project.path}/schema.md`, template.schema)- await writeFile(`${project.path}/purpose.md`, template.purpose)+ await writeFile(`${pp}/schema.md`, template.schema)+ await writeFile(`${pp}/purpose.md`, template.purpose)for (const dir of template.extraDirs) {- await createDirectory(`${project.path}/${dir}`)+ await createDirectory(`${pp}/${dir}`)}onCreated(project)diff --git a/src/components/review/review-view.tsx b/src/components/review/review-view.tsxindex 97eeaacb..6f0b0678 100644--- a/src/components/review/review-view.tsx+++ b/src/components/review/review-view.tsx@@ -15,6 +15,7 @@ import { Button } from "@/components/ui/button"import { useReviewStore, type ReviewItem } from "@/stores/review-store"import { useWikiStore } from "@/stores/wiki-store"import { writeFile, readFile, listDirectory, deleteFile } from "@/commands/fs"+import { normalizePath } from "@/lib/path-utils"const typeConfig: Record<ReviewItem["type"], { icon: typeof AlertTriangle; label: string; color: string }> = {contradiction: { icon: AlertTriangle, label: "Contradiction", color: "text-amber-500" },@@ -33,6 +34,7 @@ export function ReviewView() {const setFileTree = useWikiStore((s) => s.setFileTree)const handleResolve = useCallback(async (id: string, action: string) => {+ const pp = project ? normalizePath(project.path) : ""// Deep Research — must be checked FIRST before any fuzzy matchingif (action === "__deep_research__" && project) {const searchConfig = useWikiStore.getState().searchApiConfig@@ -45,7 +47,7 @@ export function ReviewView() {const llmConfig = useWikiStore.getState().llmConfig// Use pre-generated search queries if available, otherwise fall back to titleconst topic = item.title.replace(/^(Save to Wiki|Create|Research)[:\s]*/i, "").trim() || item.description.split("\n")[0]- queueResearch(project.path, topic, llmConfig, searchConfig, item.searchQueries)+ queueResearch(pp, topic, llmConfig, searchConfig, item.searchQueries)resolveItem(id, "Queued for research")} else {resolveItem(id, action)@@ -71,13 +73,13 @@ export function ReviewView() {const slug = title.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").slice(0, 50)const date = new Date().toISOString().slice(0, 10)const fileName = `${slug}-${date}.md`- const filePath = `${project.path}/wiki/queries/${fileName}`+ const filePath = `${pp}/wiki/queries/${fileName}`const frontmatter = `---\ntype: query\ntitle: "${title.replace(/"/g, '\\"')}"\ncreated: ${date}\ntags: []\n---\n\n`await writeFile(filePath, frontmatter + cleanContent)// Update index- const indexPath = `${project.path}/wiki/index.md`+ const indexPath = `${pp}/wiki/index.md`let indexContent = ""try { indexContent = await readFile(indexPath) } catch { indexContent = "# Wiki Index\n" }const entry = `- [[queries/${slug}-${date}|${title}]]`@@ -89,13 +91,13 @@ export function ReviewView() {await writeFile(indexPath, indexContent)// Append log- const logPath = `${project.path}/wiki/log.md`+ const logPath = `${pp}/wiki/log.md`let logContent = ""try { logContent = await readFile(logPath) } catch { logContent = "# Wiki Log\n" }await writeFile(logPath, logContent.trimEnd() + `\n- ${date}: Saved query page \`${fileName}\`\n`)// Refresh tree- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)resolveItem(id, "Saved to Wiki")@@ -107,8 +109,8 @@ export function ReviewView() {// Open a page for editingconst page = action.slice(5)const candidates = [- `${project.path}/wiki/${page}`,- `${project.path}/wiki/${page}.md`,+ `${pp}/wiki/${page}`,+ `${pp}/wiki/${page}.md`,]for (const path of candidates) {try {@@ -127,7 +129,7 @@ export function ReviewView() {const filePath = action.slice(7)try {await deleteFile(filePath)- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)resolveItem(id, "Deleted")} catch (err) {@@ -149,7 +151,7 @@ export function ReviewView() {if (item) {const llmConfig = useWikiStore.getState().llmConfigconst topic = action.replace(/^research\s*/i, "").trim() || item.description.split("\n")[0]- queueResearch(project.path, topic, llmConfig, searchConfig)+ queueResearch(pp, topic, llmConfig, searchConfig)resolveItem(id, "Queued for deep research")} else {resolveItem(id, action)@@ -157,7 +159,7 @@ export function ReviewView() {} else if (action.startsWith("__create_page__:") && project) {// Explicit create page fallbackconst realAction = action.slice("__create_page__:".length)- await createPageFromReview(id, realAction, items, project.path)+ await createPageFromReview(id, realAction, items, pp)} else if (actionLooksLikeCreate(action) && project) {// Create a wiki page from the review item's contentconst item = items.find((i) => i.id === id)@@ -171,14 +173,14 @@ export function ReviewView() {const pageType = detectPageType(action, item.type)const dir = pageType === "query" ? "queries" : pageType === "entity" ? "entities" : pageType === "concept" ? "concepts" : "queries"const fileName = `${slug}-${date}.md`- const filePath = `${project.path}/wiki/${dir}/${fileName}`+ const filePath = `${pp}/wiki/${dir}/${fileName}`const frontmatter = `---\ntype: ${pageType}\ntitle: "${title.replace(/"/g, '\\"')}"\ncreated: ${date}\ntags: []\nrelated: []\n---\n\n`const body = `# ${title}\n\n${item.description}\n`await writeFile(filePath, frontmatter + body)// Update index- const indexPath = `${project.path}/wiki/index.md`+ const indexPath = `${pp}/wiki/index.md`let indexContent = ""try { indexContent = await readFile(indexPath) } catch { indexContent = "# Wiki Index\n" }const sectionHeader = `## ${dir.charAt(0).toUpperCase() + dir.slice(1)}`@@ -191,13 +193,13 @@ export function ReviewView() {await writeFile(indexPath, indexContent)// Log- const logPath = `${project.path}/wiki/log.md`+ const logPath = `${pp}/wiki/log.md`let logContent = ""try { logContent = await readFile(logPath) } catch { logContent = "# Wiki Log\n" }await writeFile(logPath, logContent.trimEnd() + `\n- ${date}: Created ${pageType} page \`${fileName}\` from review\n`)// Refresh- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)useWikiStore.getState().bumpDataVersion()diff --git a/src/components/search/search-view.tsx b/src/components/search/search-view.tsxindex ff932fa2..2aa6a660 100644--- a/src/components/search/search-view.tsx+++ b/src/components/search/search-view.tsx@@ -5,6 +5,7 @@ import { useWikiStore } from "@/stores/wiki-store"import { readFile } from "@/commands/fs"import { searchWiki, type SearchResult } from "@/lib/search"import { useTranslation } from "react-i18next"+import { normalizePath } from "@/lib/path-utils"export function SearchView() {const { t } = useTranslation()@@ -26,7 +27,7 @@ export function SearchView() {}setSearching(true)try {- const found = await searchWiki(project.path, q)+ const found = await searchWiki(normalizePath(project.path), q)setResults(found)} catch (err) {console.error("Search failed:", err)diff --git a/src/components/sources/sources-view.tsx b/src/components/sources/sources-view.tsxindex 88039585..176c492d 100644--- a/src/components/sources/sources-view.tsx+++ b/src/components/sources/sources-view.tsx@@ -8,6 +8,7 @@ import { copyFile, listDirectory, readFile, writeFile, deleteFile, findRelatedWiimport type { FileNode } from "@/types/wiki"import { startIngest, autoIngest } from "@/lib/ingest"import { useTranslation } from "react-i18next"+import { normalizePath, getFileName } from "@/lib/path-utils"export function SourcesView() {const { t } = useTranslation()@@ -25,8 +26,9 @@ export function SourcesView() {const loadSources = useCallback(async () => {if (!project) return+ const pp = normalizePath(project.path)try {- const tree = await listDirectory(`${project.path}/raw/sources`)+ const tree = await listDirectory(`${pp}/raw/sources`)const files = flattenFiles(tree)setSources(files)} catch {@@ -80,12 +82,13 @@ export function SourcesView() {if (!selected || selected.length === 0) returnsetImporting(true)+ const pp = normalizePath(project.path)const paths = Array.isArray(selected) ? selected : [selected]const importedPaths: string[] = []for (const sourcePath of paths) {- const originalName = sourcePath.split("/").pop() || sourcePath.split("\\").pop() || "unknown"- const destPath = await getUniqueDestPath(`${project.path}/raw/sources`, originalName)+ const originalName = getFileName(sourcePath) || "unknown"+ const destPath = await getUniqueDestPath(`${pp}/raw/sources`, originalName)try {await copyFile(sourcePath, destPath)importedPaths.push(destPath)@@ -102,8 +105,8 @@ export function SourcesView() {// Auto-ingest each imported file (runs in background, progress shown in activity panel)if (llmConfig.apiKey || llmConfig.provider === "ollama") {for (const destPath of importedPaths) {- const name = destPath.split("/").pop() ?? destPath- autoIngest(project.path, destPath, llmConfig).catch((err) =>+ const name = getFileName(destPath)+ autoIngest(pp, destPath, llmConfig).catch((err) =>console.error(`Failed to auto-ingest ${name}:`, err))}@@ -123,6 +126,7 @@ export function SourcesView() {async function handleDelete(node: FileNode) {if (!project) return+ const pp = normalizePath(project.path)const fileName = node.nameconst confirmed = window.confirm(t("sources.deleteConfirm", { name: fileName })@@ -131,9 +135,9 @@ export function SourcesView() {try {// Step 1: Find related wiki pages before deleting- const relatedPages = await findRelatedWikiPages(project.path, fileName)+ const relatedPages = await findRelatedWikiPages(pp, fileName)const deletedSlugs = relatedPages.map((p) => {- const name = p.split("/").pop()?.replace(".md", "") ?? ""+ const name = getFileName(p).replace(".md", "")return name}).filter(Boolean)@@ -142,7 +146,7 @@ export function SourcesView() {// Step 3: Delete preprocessed cachetry {- await deleteFile(`${project.path}/raw/sources/.cache/${fileName}.txt`)+ await deleteFile(`${pp}/raw/sources/.cache/${fileName}.txt`)} catch {// cache file may not exist}@@ -185,13 +189,13 @@ export function SourcesView() {// Step 5: Clean index.md — remove entries for actually deleted pages onlyconst deletedPageSlugs = actuallyDeleted.map((p) => {- const name = p.split("/").pop()?.replace(".md", "") ?? ""+ const name = getFileName(p).replace(".md", "")return name}).filter(Boolean)if (deletedPageSlugs.length > 0) {try {- const indexPath = `${project.path}/wiki/index.md`+ const indexPath = `${pp}/wiki/index.md`const indexContent = await readFile(indexPath)const updatedIndex = indexContent.split("\n")@@ -206,7 +210,7 @@ export function SourcesView() {// Step 6: Clean [[wikilinks]] to deleted pages from remaining wiki filesif (deletedPageSlugs.length > 0) {try {- const wikiTree = await listDirectory(`${project.path}/wiki`)+ const wikiTree = await listDirectory(`${pp}/wiki`)const allMdFiles = flattenMdFiles(wikiTree)for (const file of allMdFiles) {try {@@ -230,7 +234,7 @@ export function SourcesView() {// Step 7: Append deletion record to log.mdtry {- const logPath = `${project.path}/wiki/log.md`+ const logPath = `${pp}/wiki/log.md`const logContent = await readFile(logPath).catch(() => "# Wiki Log\n")const date = new Date().toISOString().slice(0, 10)const keptCount = relatedPages.length - actuallyDeleted.length@@ -242,7 +246,7 @@ export function SourcesView() {// Step 8: Refresh everythingawait loadSources()- const tree = await listDirectory(project.path)+ const tree = await listDirectory(pp)setFileTree(tree)useWikiStore.getState().bumpDataVersion()@@ -262,7 +266,7 @@ export function SourcesView() {try {setChatExpanded(true)setActiveView("wiki")- await startIngest(project.path, node.path, llmConfig)+ await startIngest(normalizePath(project.path), node.path, llmConfig)} catch (err) {console.error("Failed to start ingest:", err)} finally {diff --git a/src/lib/deep-research.ts b/src/lib/deep-research.tsindex 2c7e67f5..71b13519 100644--- a/src/lib/deep-research.ts+++ b/src/lib/deep-research.ts@@ -4,6 +4,7 @@ import { autoIngest } from "./ingest"import { writeFile, readFile, listDirectory } from "@/commands/fs"import { useWikiStore, type LlmConfig, type SearchApiConfig } from "@/stores/wiki-store"import { useResearchStore } from "@/stores/research-store"+import { normalizePath } from "@/lib/path-utils"let processing = false@@ -58,6 +59,7 @@ async function executeResearch(llmConfig: LlmConfig,searchConfig: SearchApiConfig,) {+ const pp = normalizePath(projectPath)const store = useResearchStore.getState()try {@@ -91,7 +93,7 @@ async function executeResearch(if (webResults.length === 0) {store.updateTask(taskId, { status: "done", synthesis: "No web results found." })- onTaskFinished(projectPath, llmConfig, searchConfig)+ onTaskFinished(pp, llmConfig, searchConfig)return}@@ -105,7 +107,7 @@ async function executeResearch(// Read existing wiki index to enable cross-referencinglet wikiIndex = ""try {- wikiIndex = await readFile(`${projectPath}/wiki/index.md`)+ wikiIndex = await readFile(`${pp}/wiki/index.md`)} catch {// no index yet}@@ -158,7 +160,7 @@ async function executeResearch(// Check if errored during streamingif (useResearchStore.getState().tasks.find((t) => t.id === taskId)?.status === "error") {- onTaskFinished(projectPath, llmConfig, searchConfig)+ onTaskFinished(pp, llmConfig, searchConfig)return}@@ -168,7 +170,7 @@ async function executeResearch(const date = new Date().toISOString().slice(0, 10)const slug = topic.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").slice(0, 50)const fileName = `research-${slug}-${date}.md`- const filePath = `${projectPath}/wiki/queries/${fileName}`+ const filePath = `${pp}/wiki/queries/${fileName}`const references = webResults.map((r, i) => `${i + 1}. [${r.title}](${r.url}) — ${r.source}`)@@ -203,7 +205,7 @@ async function executeResearch(// Refresh treetry {- const tree = await listDirectory(projectPath)+ const tree = await listDirectory(pp)useWikiStore.getState().setFileTree(tree)useWikiStore.getState().bumpDataVersion()} catch {@@ -211,7 +213,7 @@ async function executeResearch(}// Auto-ingest the research result to generate entities, concepts, cross-references- autoIngest(projectPath, `${projectPath}/${savedPath}`, llmConfig).catch((err) => {+ autoIngest(pp, `${pp}/${savedPath}`, llmConfig).catch((err) => {console.error("Failed to auto-ingest research result:", err)})} catch (err) {@@ -222,7 +224,7 @@ async function executeResearch(})}- onTaskFinished(projectPath, llmConfig, searchConfig)+ onTaskFinished(pp, llmConfig, searchConfig)}function onTaskFinished(diff --git a/src/lib/enrich-wikilinks.ts b/src/lib/enrich-wikilinks.tsindex df881016..a6d71b6b 100644--- a/src/lib/enrich-wikilinks.ts+++ b/src/lib/enrich-wikilinks.ts@@ -2,6 +2,7 @@ import { readFile, writeFile } from "@/commands/fs"import { streamChat } from "./llm-client"import { useWikiStore, type LlmConfig } from "@/stores/wiki-store"import { LANGUAGE_RULE } from "./ingest"+import { normalizePath } from "@/lib/path-utils"/*** Lightweight post-save enrichment: ask LLM to add [[wikilinks]] to a saved wiki page.@@ -12,9 +13,11 @@ export async function enrichWithWikilinks(filePath: string,llmConfig: LlmConfig,): Promise<void> {+ const pp = normalizePath(projectPath)+ const fp = normalizePath(filePath)const [content, index] = await Promise.all([- readFile(filePath),- readFile(`${projectPath}/wiki/index.md`).catch(() => ""),+ readFile(fp),+ readFile(`${pp}/wiki/index.md`).catch(() => ""),])if (!content || !index) return@@ -63,7 +66,7 @@ export async function enrichWithWikilinks(}// Write the enriched version back- await writeFile(filePath, enriched)+ await writeFile(fp, enriched)// Refresh graphuseWikiStore.getState().bumpDataVersion()diff --git a/src/lib/graph-relevance.ts b/src/lib/graph-relevance.tsindex d2821573..057f00a2 100644--- a/src/lib/graph-relevance.ts+++ b/src/lib/graph-relevance.ts@@ -1,5 +1,6 @@import { readFile, listDirectory } from "@/commands/fs"import type { FileNode } from "@/types/wiki"+import { normalizePath } from "@/lib/path-utils"// ---------------------------------------------------------------------------// Types@@ -160,7 +161,7 @@ export async function buildRetrievalGraph(return cachedGraph}- const wikiRoot = `${projectPath}/wiki`+ const wikiRoot = `${normalizePath(projectPath)}/wiki`let tree: FileNode[]try {tree = await listDirectory(wikiRoot)diff --git a/src/lib/ingest.ts b/src/lib/ingest.tsindex 9905796d..4567c9a9 100644--- a/src/lib/ingest.ts+++ b/src/lib/ingest.ts@@ -5,6 +5,7 @@ import { useWikiStore } from "@/stores/wiki-store"import { useChatStore } from "@/stores/chat-store"import { useActivityStore } from "@/stores/activity-store"import { useReviewStore, type ReviewItem } from "@/stores/review-store"+import { getFileName, normalizePath } from "@/lib/path-utils"const FILE_BLOCK_REGEX = /---FILE:\s*([^\n-]+?)\s*---\n([\s\S]*?)---END FILE---/g@@ -20,8 +21,10 @@ export async function autoIngest(llmConfig: LlmConfig,signal?: AbortSignal,): Promise<string[]> {+ const pp = normalizePath(projectPath)+ const sp = normalizePath(sourcePath)const activity = useActivityStore.getState()- const fileName = sourcePath.split("/").pop() ?? sourcePath+ const fileName = getFileName(sp)const activityId = activity.addItem({type: "ingest",title: fileName,@@ -31,11 +34,11 @@ export async function autoIngest(})const [sourceContent, schema, purpose, index, overview] = await Promise.all([- tryReadFile(sourcePath),- tryReadFile(`${projectPath}/schema.md`),- tryReadFile(`${projectPath}/purpose.md`),- tryReadFile(`${projectPath}/wiki/index.md`),- tryReadFile(`${projectPath}/wiki/overview.md`),+ tryReadFile(sp),+ tryReadFile(`${pp}/schema.md`),+ tryReadFile(`${pp}/purpose.md`),+ tryReadFile(`${pp}/wiki/index.md`),+ tryReadFile(`${pp}/wiki/overview.md`),])const truncatedContent = sourceContent.length > 50000@@ -110,12 +113,12 @@ export async function autoIngest(// ── Step 3: Write files ───────────────────────────────────────activity.updateItem(activityId, { detail: "Writing files..." })- const writtenPaths = await writeFileBlocks(projectPath, generation)+ const writtenPaths = await writeFileBlocks(pp, 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 sourceSummaryFullPath = `${pp}/${sourceSummaryPath}`const hasSourceSummary = writtenPaths.some((p) => p.startsWith("wiki/sources/"))if (!hasSourceSummary) {@@ -146,7 +149,7 @@ export async function autoIngest(if (writtenPaths.length > 0) {try {- const tree = await listDirectory(projectPath)+ const tree = await listDirectory(pp)useWikiStore.getState().setFileTree(tree)useWikiStore.getState().bumpDataVersion()} catch {@@ -155,7 +158,7 @@ export async function autoIngest(}// ── Step 4: Parse review items ────────────────────────────────- const reviewItems = parseReviewBlocks(generation, sourcePath)+ const reviewItems = parseReviewBlocks(generation, sp)if (reviewItems.length > 0) {useReviewStore.getState().addItems(reviewItems)}@@ -431,20 +434,22 @@ export async function startIngest(llmConfig: LlmConfig,signal?: AbortSignal,): Promise<void> {+ const pp = normalizePath(projectPath)+ const sp = normalizePath(sourcePath)const store = getStore()store.setMode("ingest")- store.setIngestSource(sourcePath)+ store.setIngestSource(sp)store.clearMessages()store.setStreaming(false)const [sourceContent, schema, purpose, index] = await Promise.all([- tryReadFile(sourcePath),- tryReadFile(`${projectPath}/wiki/schema.md`),- tryReadFile(`${projectPath}/wiki/purpose.md`),- tryReadFile(`${projectPath}/wiki/index.md`),+ tryReadFile(sp),+ tryReadFile(`${pp}/wiki/schema.md`),+ tryReadFile(`${pp}/wiki/purpose.md`),+ tryReadFile(`${pp}/wiki/index.md`),])- const fileName = sourcePath.split("/").pop() ?? sourcePath+ const fileName = getFileName(sp)const systemPrompt = ["You are a knowledgeable assistant helping to build a wiki from source documents.",@@ -503,11 +508,12 @@ export async function executeIngestWrites(userGuidance?: string,signal?: AbortSignal,): Promise<string[]> {+ const pp = normalizePath(projectPath)const store = getStore()const [schema, index] = await Promise.all([- tryReadFile(`${projectPath}/wiki/schema.md`),- tryReadFile(`${projectPath}/wiki/index.md`),+ tryReadFile(`${pp}/wiki/schema.md`),+ tryReadFile(`${pp}/wiki/index.md`),])const conversationHistory = store.messages@@ -579,7 +585,7 @@ export async function executeIngestWrites(if (!relativePath) continue- const fullPath = `${projectPath}/${relativePath}`+ const fullPath = `${pp}/${relativePath}`try {if (relativePath === "wiki/log.md" || relativePath.endsWith("/log.md")) {diff --git a/src/lib/lint.ts b/src/lib/lint.tsindex 6f6b5838..87f4e152 100644--- a/src/lib/lint.ts+++ b/src/lib/lint.ts@@ -3,6 +3,7 @@ import { streamChat } from "@/lib/llm-client"import type { LlmConfig } from "@/stores/wiki-store"import type { FileNode } from "@/types/wiki"import { useActivityStore } from "@/stores/activity-store"+import { getFileName, normalizePath } from "@/lib/path-utils"export interface LintResult {type: "orphan" | "broken-link" | "no-outlinks" | "semantic"@@ -60,7 +61,7 @@ function buildSlugMap(// ── Structural lint ───────────────────────────────────────────────────────────export async function runStructuralLint(projectPath: string): Promise<LintResult[]> {- const wikiRoot = `${projectPath}/wiki`+ const wikiRoot = `${normalizePath(projectPath)}/wiki`let tree: FileNode[]try {tree = await listDirectory(wikiRoot)@@ -130,7 +131,7 @@ export async function runStructuralLint(projectPath: string): Promise<LintResult// Broken linksfor (const link of p.outlinks) {- const exists = slugMap.has(link) || slugMap.has(link.split("/").pop() ?? "")+ const exists = slugMap.has(link) || slugMap.has(getFileName(link).replace(/\.md$/, ""))if (!exists) {results.push({type: "broken-link",@@ -154,6 +155,7 @@ export async function runSemanticLint(projectPath: string,llmConfig: LlmConfig,): Promise<LintResult[]> {+ const pp = normalizePath(projectPath)const activity = useActivityStore.getState()const activityId = activity.addItem({type: "lint",@@ -163,7 +165,7 @@ export async function runSemanticLint(filesWritten: [],})- const wikiRoot = `${projectPath}/wiki`+ const wikiRoot = `${pp}/wiki`let tree: FileNode[]try {tree = await listDirectory(wikiRoot)diff --git a/src/lib/path-utils.ts b/src/lib/path-utils.tsnew file mode 100644index 00000000..e468d87e--- /dev/null+++ b/src/lib/path-utils.ts@@ -0,0 +1,46 @@+/**+ * Normalize a path to use forward slashes (works on both macOS and Windows).+ * Windows APIs accept forward slashes, so normalizing to / is safe everywhere.+ */+export function normalizePath(p: string): string {+ return p.replace(/\\/g, "/")+}++/**+ * Join path segments with forward slashes.+ */+export function joinPath(...segments: string[]): string {+ return segments+ .map((s) => s.replace(/\\/g, "/"))+ .join("/")+ .replace(/\/+/g, "/")+}++/**+ * Get the filename from a path (handles both / and \).+ */+export function getFileName(p: string): string {+ const normalized = p.replace(/\\/g, "/")+ return normalized.split("/").pop() ?? p+}++/**+ * Get the file stem (filename without extension).+ */+export function getFileStem(p: string): string {+ const name = getFileName(p)+ const lastDot = name.lastIndexOf(".")+ return lastDot > 0 ? name.slice(0, lastDot) : name+}++/**+ * Get relative path from base.+ */+export function getRelativePath(fullPath: string, basePath: string): string {+ const normalFull = normalizePath(fullPath)+ const normalBase = normalizePath(basePath).replace(/\/$/, "")+ if (normalFull.startsWith(normalBase + "/")) {+ return normalFull.slice(normalBase.length + 1)+ }+ return normalFull+}diff --git a/src/lib/persist.ts b/src/lib/persist.tsindex df818235..443900de 100644--- a/src/lib/persist.ts+++ b/src/lib/persist.ts@@ -1,6 +1,7 @@import { writeFile, readFile, createDirectory } from "@/commands/fs"import type { ReviewItem } from "@/stores/review-store"import type { DisplayMessage, Conversation } from "@/stores/chat-store"+import { normalizePath } from "@/lib/path-utils"async function ensureDir(projectPath: string): Promise<void> {await createDirectory(`${projectPath}/.llm-wiki`).catch(() => {})@@ -8,13 +9,15 @@ async function ensureDir(projectPath: string): Promise<void> {}export async function saveReviewItems(projectPath: string, items: ReviewItem[]): Promise<void> {- await ensureDir(projectPath)- await writeFile(`${projectPath}/.llm-wiki/review.json`, JSON.stringify(items, null, 2))+ const pp = normalizePath(projectPath)+ await ensureDir(pp)+ await writeFile(`${pp}/.llm-wiki/review.json`, JSON.stringify(items, null, 2))}export async function loadReviewItems(projectPath: string): Promise<ReviewItem[]> {+ const pp = normalizePath(projectPath)try {- const content = await readFile(`${projectPath}/.llm-wiki/review.json`)+ const content = await readFile(`${pp}/.llm-wiki/review.json`)return JSON.parse(content) as ReviewItem[]} catch {return []@@ -31,11 +34,12 @@ export async function saveChatHistory(conversations: Conversation[],messages: DisplayMessage[]): Promise<void> {- await ensureDir(projectPath)+ const pp = normalizePath(projectPath)+ await ensureDir(pp)// Save conversation listawait writeFile(- `${projectPath}/.llm-wiki/conversations.json`,+ `${pp}/.llm-wiki/conversations.json`,JSON.stringify(conversations, null, 2))@@ -51,22 +55,23 @@ export async function saveChatHistory(// Keep last 100 messages per conversationconst toSave = msgs.slice(-100)await writeFile(- `${projectPath}/.llm-wiki/chats/${convId}.json`,+ `${pp}/.llm-wiki/chats/${convId}.json`,JSON.stringify(toSave, null, 2))}}export async function loadChatHistory(projectPath: string): Promise<PersistedChatData> {+ const pp = normalizePath(projectPath)try {// Try new format: separate files per conversation- const convContent = await readFile(`${projectPath}/.llm-wiki/conversations.json`)+ const convContent = await readFile(`${pp}/.llm-wiki/conversations.json`)const conversations = JSON.parse(convContent) as Conversation[]const allMessages: DisplayMessage[] = []for (const conv of conversations) {try {- const msgContent = await readFile(`${projectPath}/.llm-wiki/chats/${conv.id}.json`)+ const msgContent = await readFile(`${pp}/.llm-wiki/chats/${conv.id}.json`)const msgs = JSON.parse(msgContent) as DisplayMessage[]allMessages.push(...msgs)} catch {@@ -78,7 +83,7 @@ export async function loadChatHistory(projectPath: string): Promise<PersistedCha} catch {// Fall back to old formattry {- const content = await readFile(`${projectPath}/.llm-wiki/chat-history.json`)+ const content = await readFile(`${pp}/.llm-wiki/chat-history.json`)const parsed = JSON.parse(content)if (Array.isArray(parsed)) {diff --git a/src/lib/search.ts b/src/lib/search.tsindex 5c97883f..8fb6981f 100644--- a/src/lib/search.ts+++ b/src/lib/search.ts@@ -1,5 +1,6 @@import { readFile, listDirectory } from "@/commands/fs"import type { FileNode } from "@/types/wiki"+import { normalizePath } from "@/lib/path-utils"export interface SearchResult {path: string@@ -113,6 +114,7 @@ export async function searchWiki(query: string,): Promise<SearchResult[]> {if (!query.trim()) return []+ const pp = normalizePath(projectPath)const tokens = tokenizeQuery(query)// Fallback: if all tokens were filtered out, use the trimmed query as a single token@@ -121,7 +123,7 @@ export async function searchWiki(// Search wiki pagestry {- const wikiTree = await listDirectory(`${projectPath}/wiki`)+ const wikiTree = await listDirectory(`${pp}/wiki`)const wikiFiles = flattenMdFiles(wikiTree)await searchFiles(wikiFiles, effectiveTokens, query, results)} catch {@@ -130,7 +132,7 @@ export async function searchWiki(// Also search raw sources (extracted text)try {- const rawTree = await listDirectory(`${projectPath}/raw/sources`)+ const rawTree = await listDirectory(`${pp}/raw/sources`)const rawFiles = flattenAllFiles(rawTree)await searchFiles(rawFiles, effectiveTokens, query, results)} catch {diff --git a/src/lib/wiki-graph.ts b/src/lib/wiki-graph.tsindex 2ad0cdad..b3370835 100644--- a/src/lib/wiki-graph.ts+++ b/src/lib/wiki-graph.ts@@ -1,6 +1,7 @@import { readFile, listDirectory } from "@/commands/fs"import type { FileNode } from "@/types/wiki"import { buildRetrievalGraph, calculateRelevance } from "./graph-relevance"+import { normalizePath } from "@/lib/path-utils"export interface GraphNode {id: string@@ -63,7 +64,7 @@ function fileNameToId(fileName: string): string {export async function buildWikiGraph(projectPath: string,): Promise<{ nodes: GraphNode[]; edges: GraphEdge[] }> {- const wikiRoot = `${projectPath}/wiki`+ const wikiRoot = `${normalizePath(projectPath)}/wiki`let tree: FileNode[]try {@@ -141,7 +142,7 @@ export async function buildWikiGraph(try {const { useWikiStore } = await import("@/stores/wiki-store")const dv = useWikiStore.getState().dataVersion- retrievalGraph = await buildRetrievalGraph(projectPath, dv)+ retrievalGraph = await buildRetrievalGraph(normalizePath(projectPath), dv)} catch {// ignore — weights will default to 1}