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
import type { FileNode } from "@/types/wiki"
export interface ReplaceNodeChildrenResult {
nodes: FileNode[]
matched: boolean
}
export function replaceNodeChildren(
nodes: FileNode[],
path: string,
children: FileNode[],
): ReplaceNodeChildrenResult {
let matched = false
const next = nodes.map((node) => {
if (node.path === path) {
matched = true
return { ...node, children }
}
if (node.children) {
const result = replaceNodeChildren(node.children, path, children)
if (result.matched) {
matched = true
return { ...node, children: result.nodes }
}
}
return node
})
return { nodes: matched ? next : nodes, matched }
}