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: resolve sources inside raw/sources dotfolders
Dongmin, Yubc384852e364
diff --git a/src/lib/project-file-tree-refresh.test.ts b/src/lib/project-file-tree-refresh.test.tsindex f5e2b076..b7dbd466 100644--- a/src/lib/project-file-tree-refresh.test.ts+++ b/src/lib/project-file-tree-refresh.test.ts@@ -78,11 +78,48 @@ describe("refreshProjectFileTree", () => {expect(mocks.listDirectory).toHaveBeenNthCalledWith(1, project.path, { maxDepth: 2 })expect(mocks.listDirectory).toHaveBeenNthCalledWith(2, project.path, undefined)+ expect(mocks.listDirectory).toHaveBeenNthCalledWith(3, `${project.path}/raw/sources`, {+ includeHidden: true,+ })expect(useWikiStore.getState().fileTree).toEqual(shallowTree)expect(useWikiStore.getState().projectPathIndex.byPath.has("/tmp/project/wiki/entities/alpha.md")).toBe(true)expect(useWikiStore.getState().dataVersion).toBe(1)})+ it("includes raw/sources dotfolders in the resolver index via a hidden scan", async () => {+ const rawSourcesHiddenTree: FileNode[] = [+ {+ name: ".claude",+ path: "/tmp/project/raw/sources/.claude",+ is_dir: true,+ children: [+ {+ name: "memory.md",+ path: "/tmp/project/raw/sources/.claude/memory.md",+ is_dir: false,+ },+ ],+ },+ ]+ mocks.listDirectory.mockImplementation(+ async (path: string, options?: { maxDepth?: number; includeHidden?: boolean }) => {+ if (options?.maxDepth === 2) return shallowTree+ if (path === "/tmp/project/raw/sources") return rawSourcesHiddenTree+ return fullTree+ },+ )++ await refreshProjectFileTree(project.path, {+ projectId: project.id,+ bumpDataVersion: true,+ })+ await flushMicrotasks()++ const index = useWikiStore.getState().projectPathIndex+ expect(index.byPath.has("/tmp/project/wiki/entities/alpha.md")).toBe(true)+ expect(index.byPath.has("/tmp/project/raw/sources/.claude/memory.md")).toBe(true)+ })+it("does not write stale results after the active project changes", async () => {mocks.listDirectory.mockImplementation(async (_path: string, options?: { maxDepth?: number }) =>options?.maxDepth === 2 ? shallowTree : fullTree@@ -123,9 +160,11 @@ describe("refreshProjectFileTree", () => {await flushMicrotasks()expect(mocks.listDirectory).toHaveBeenNthCalledWith(1, project.path, { maxDepth: 2 })- expect(mocks.listDirectory).toHaveBeenNthCalledWith(2, project.path, undefined)- expect(mocks.listDirectory).toHaveBeenNthCalledWith(3, project.path, undefined)- expect(mocks.listDirectory).toHaveBeenNthCalledWith(4, project.path, undefined)+ // The full project scan retries three times before giving up.+ const fullScanCalls = mocks.listDirectory.mock.calls.filter(+ ([path, options]) => path === project.path && options === undefined,+ )+ expect(fullScanCalls).toHaveLength(3)expect(useWikiStore.getState().fileTree).toEqual(shallowTree)expect(useWikiStore.getState().projectPathIndex.byPath.has("/tmp/project/wiki/entities/alpha.md")).toBe(true)} finally {diff --git a/src/lib/project-file-tree-refresh.ts b/src/lib/project-file-tree-refresh.tsindex 0f42b8fd..9e4da313 100644--- a/src/lib/project-file-tree-refresh.ts+++ b/src/lib/project-file-tree-refresh.ts@@ -78,10 +78,27 @@ export async function refreshProjectFileTree(if (refreshPathIndex) {if (!isStillCurrentProject(currentProjectId, normalizedProjectPath)) return- listDirectoryWithRetry(normalizedProjectPath, undefined, 3)- .then((fullTree) => {+ // The full project scan hides dot-prefixed entries (`.git`,+ // `.llm-wiki`, …), which is correct for most of the tree. But+ // `raw/sources` may hold user-added dotfolders (`.claude`,+ // `.codex`) whose files back real `sources:` references. Scan+ // that subtree with `includeHidden` and merge it in so those+ // sources resolve instead of rendering as "not found". The+ // raw/sources scan is best-effort — a project without sources+ // must still get a full index.+ Promise.all([+ listDirectoryWithRetry(normalizedProjectPath, undefined, 3),+ listDirectoryWithRetry(+ `${normalizedProjectPath}/raw/sources`,+ { includeHidden: true },+ 3,+ ).catch(() => [] as FileNode[]),+ ])+ .then(([fullTree, rawSourcesTree]) => {if (!isStillCurrentProject(currentProjectId, normalizedProjectPath)) return- useWikiStore.getState().setProjectPathIndexFromTree(fullTree)+ useWikiStore+ .getState()+ .setProjectPathIndexFromTree([...fullTree, ...rawSourcesTree])}).catch((err) => {console.error("Failed to refresh project path index:", err)diff --git a/src/lib/wiki-page-resolver.test.ts b/src/lib/wiki-page-resolver.test.tsindex e42531db..9ac07388 100644--- a/src/lib/wiki-page-resolver.test.ts+++ b/src/lib/wiki-page-resolver.test.ts@@ -64,6 +64,27 @@ const STRAY_CHILDREN_INDEX = buildProjectPathIndexFromTree([},])+describe("buildProjectPathIndexFromTree", () => {+ it("indexes each path once when overlapping trees are merged", () => {+ // The full project scan and a hidden raw/sources rescan share the+ // visible source files; merging them must not create duplicate+ // filesByName entries, while still surfacing hidden-only files.+ const rawSourcesRescan: FileNode[] = [+ dir(`${SOURCES}`, [+ file(`${SOURCES}/report.pdf`), // duplicate of the full scan+ dir(`${SOURCES}/.claude`, [file(`${SOURCES}/.claude/memory.md`)]),+ ]),+ ]+ const merged = buildProjectPathIndexFromTree([...TREE, ...rawSourcesRescan])++ expect(merged.filesByName.get("report.pdf")).toHaveLength(1)+ expect(merged.byPath.has(`${SOURCES}/.claude/memory.md`)).toBe(true)+ expect(findInTreeByName(merged, "memory.md", `${SOURCES}/`)).toBe(+ `${SOURCES}/.claude/memory.md`,+ )+ })+})+describe("unwrapWikilink", () => {it("unwraps a bare [[target]]", () => {expect(unwrapWikilink("[[nh3-n]]")).toEqual({ slug: "nh3-n", label: "nh3-n" })@@ -264,4 +285,24 @@ describe("resolveSourceName", () => {`${WIKI}/sources/paper.md`,)})++ it("resolves a source that lives inside a raw/sources dotfolder", () => {+ // Real frontmatter shape: sources: [".claude/projects/.../MEMORY.md"].+ // These only resolve once the hidden raw/sources rescan puts the+ // dotfolder file into the index.+ const dotIndex = buildProjectPathIndexFromTree([+ dir(`${PP}/raw`, [+ dir(`${SOURCES}`, [+ dir(`${SOURCES}/.claude`, [+ dir(`${SOURCES}/.claude/projects`, [+ file(`${SOURCES}/.claude/projects/MEMORY.md`),+ ]),+ ]),+ ]),+ ]),+ ])+ expect(resolveSourceName(dotIndex, ".claude/projects/MEMORY.md", SOURCES)).toBe(+ `${SOURCES}/.claude/projects/MEMORY.md`,+ )+ })})diff --git a/src/lib/wiki-page-resolver.ts b/src/lib/wiki-page-resolver.tsindex d11a7082..5d7a73eb 100644--- a/src/lib/wiki-page-resolver.ts+++ b/src/lib/wiki-page-resolver.ts@@ -20,15 +20,21 @@ export function buildProjectPathIndexFromTree(tree: FileNode[]): ProjectPathIndefunction walk(nodes: FileNode[]) {for (const node of nodes) {- const entry: ProjectPathIndexEntry = {- name: node.name,- path: node.path,- }- byPath.set(node.path, entry)- if (!node.is_dir) {- const bucket = filesByName.get(node.name)- if (bucket) bucket.push(entry)- else filesByName.set(node.name, [entry])+ // Callers may pass overlapping trees (e.g. the full project+ // scan plus a hidden `raw/sources` rescan share the visible+ // source files). Index each path once so `filesByName` buckets+ // don't accumulate duplicate entries.+ if (!byPath.has(node.path)) {+ const entry: ProjectPathIndexEntry = {+ name: node.name,+ path: node.path,+ }+ byPath.set(node.path, entry)+ if (!node.is_dir) {+ const bucket = filesByName.get(node.name)+ if (bucket) bucket.push(entry)+ else filesByName.set(node.name, [entry])+ }}if (node.is_dir && node.children) walk(node.children)}