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
Release 0.4.9
nash_su76e5a8084ea9
diff --git a/package-lock.json b/package-lock.jsonindex 56371405..ea1935cf 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "llm-wiki",- "version": "0.4.8",+ "version": "0.4.9","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "llm-wiki",- "version": "0.4.8",+ "version": "0.4.9","dependencies": {"@base-ui/react": "^1.3.0","@fontsource-variable/geist": "^5.2.8",diff --git a/package.json b/package.jsonindex db6d630f..348203f4 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "llm-wiki","private": true,- "version": "0.4.8",+ "version": "0.4.9","type": "module","scripts": {"dev": "vite",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 070a82a7..30ffe511 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -4469,7 +4469,7 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"[[package]]name = "llm-wiki"-version = "0.4.8"+version = "0.4.9"dependencies = ["arrow-array","arrow-schema",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 4b55257e..23003433 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "llm-wiki"-version = "0.4.8"+version = "0.4.9"description = "LLM Wiki - A personal knowledge base for LLM concepts"authors = []edition = "2021"diff --git a/src-tauri/build.rs b/src-tauri/build.rsindex d860e1e6..47007fbf 100644--- a/src-tauri/build.rs+++ b/src-tauri/build.rs@@ -1,3 +1,6 @@fn main() {- tauri_build::build()+ let windows = tauri_build::WindowsAttributes::new()+ .app_manifest(include_str!("windows-app-manifest.xml"));+ let attrs = tauri_build::Attributes::new().windows_attributes(windows);+ tauri_build::try_build(attrs).expect("failed to run tauri build script");}diff --git a/src-tauri/src/commands/file_sync.rs b/src-tauri/src/commands/file_sync.rsindex ab662ba5..42fc46b5 100644--- a/src-tauri/src/commands/file_sync.rs+++ b/src-tauri/src/commands/file_sync.rs@@ -161,15 +161,22 @@ pub fn start_project_file_watcher(let tx_for_watcher = tx.clone();let root_for_overflow = root.clone();+ let root_for_error = root.clone();let mut watcher = RecommendedWatcher::new(move |res: notify::Result<Event>| {- if let Ok(event) = res {- for path in event.paths {- if tx_for_watcher.try_send(path).is_err() {- let _ = tx_for_watcher.try_send(root_for_overflow.clone());- break;+ match res {+ Ok(event) => {+ for path in event.paths {+ if tx_for_watcher.try_send(path).is_err() {+ let _ = tx_for_watcher.try_send(root_for_overflow.clone());+ break;+ }}}+ Err(err) => {+ eprintln!("[file-sync] watcher error; scheduling rescan: {err}");+ let _ = tx_for_watcher.try_send(root_for_error.clone());+ }}},Config::default(),@@ -727,6 +734,7 @@ fn normalize_rel_path(path: &Path) -> Option<String> {for component in path.components() {match component {Component::Normal(s) => parts.push(s.to_string_lossy().to_string()),+ Component::CurDir => {}_ => return None,}}@@ -759,7 +767,11 @@ fn should_watch_rel(rel: &str) -> bool {return false;}let name = lower.rsplit('/').next().unwrap_or(&lower);- if name.starts_with("~$") || (name.starts_with(".~lock.") && name.ends_with('#')) {+ if name == "thumbs.db"+ || name == "desktop.ini"+ || name.starts_with("~$")+ || (name.starts_with(".~lock.") && name.ends_with('#'))+ {return false;}rel == "purpose.md"@@ -846,7 +858,31 @@ fn write_json<T: Serialize>(path: PathBuf, value: &T) -> Result<(), String> {}let text =serde_json::to_string_pretty(value).map_err(|e| format!("JSON encode failed: {e}"))?;- fs::write(&path, text).map_err(|e| format!("Failed to write '{}': {e}", path.display()))+ let file_name = path+ .file_name()+ .map(|name| name.to_string_lossy().to_string())+ .unwrap_or_else(|| "file-sync.json".to_string());+ let tmp_path = path.with_file_name(format!(+ ".{file_name}.{}.tmp",+ chrono::Utc::now().timestamp_nanos_opt().unwrap_or_else(now_ms)+ ));+ fs::write(&tmp_path, text)+ .map_err(|e| format!("Failed to write '{}': {e}", tmp_path.display()))?;+ #[cfg(windows)]+ {+ if path.exists() {+ fs::remove_file(&path)+ .map_err(|e| format!("Failed to replace '{}': {e}", path.display()))?;+ }+ }+ fs::rename(&tmp_path, &path).map_err(|e| {+ let _ = fs::remove_file(&tmp_path);+ format!(+ "Failed to move '{}' to '{}': {e}",+ tmp_path.display(),+ path.display()+ )+ })}fn stable_path_hash(path: &str) -> String {@@ -913,7 +949,7 @@ fn path_key(path: &Path) -> String {}fn normalize_path_key(path: &Path) -> String {- path.to_string_lossy().replace('\\', "/")+ normalize_key(&path.to_string_lossy().replace('\\', "/"))}fn is_app_write_ignored(path: &Path) -> bool {@@ -1099,11 +1135,22 @@ mod tests {assert!(!should_watch_rel(".llm-wiki/file-change-queue.json"));assert!(!should_watch_rel("raw/sources/~$Document.docx"));assert!(!should_watch_rel("raw/sources/.~lock.Document.odt#"));+ assert!(!should_watch_rel("raw/sources/Thumbs.db"));+ assert!(!should_watch_rel("raw/sources/desktop.ini"));assert!(!should_watch_rel("raw/sources/download.crdownload"));assert!(!should_watch_rel(".vscode/settings.json"));assert!(!should_watch_rel("wiki/media/image.png"));}+ #[test]+ fn normalize_rel_path_tolerates_current_dir_segments() {+ let path = Path::new("raw").join(".").join("sources").join("doc.md");+ assert_eq!(+ normalize_rel_path(&path),+ Some("raw/sources/doc.md".to_string())+ );+ }+#[test]fn queue_lock_recovers_after_poison() {let root = temp_root("poison");@@ -1157,6 +1204,15 @@ mod tests {let _ = fs::remove_dir_all(root);}+ #[test]+ #[cfg(windows)]+ fn windows_path_key_is_case_insensitive() {+ assert_eq!(+ normalize_path_key(Path::new(r"C:\Proj\raw\sources\File.md")),+ normalize_path_key(Path::new(r"c:\proj\RAW\sources\file.md"))+ );+ }+#[test]fn process_queue_updates_snapshot_and_removes_done_tasks() {let root = temp_root("process-e2e");diff --git a/src-tauri/src/commands/fs.rs b/src-tauri/src/commands/fs.rsindex c45300ec..e8b32e22 100644--- a/src-tauri/src/commands/fs.rs+++ b/src-tauri/src/commands/fs.rs@@ -1,6 +1,8 @@use std::fs;use std::io::Read as IoRead;use std::path::Path;+use std::thread;+use std::time::Duration;use calamine::{Reader, open_workbook_auto, Data};@@ -1083,10 +1085,10 @@ pub async fn delete_file(path: String) -> Result<(), String> {let p = Path::new(&path);file_sync::mark_app_write_path(p);if p.is_dir() {- fs::remove_dir_all(&path)+ remove_path_with_retry(&path, true).map_err(|e| format!("Failed to delete directory '{}': {}", path, e))?;} else {- fs::remove_file(&path)+ remove_path_with_retry(&path, false).map_err(|e| format!("Failed to delete file '{}': {}", path, e))?;}file_sync::mark_app_write_path(p);@@ -1097,6 +1099,39 @@ pub async fn delete_file(path: String) -> Result<(), String> {.map_err(|e| format!("delete_file blocking task join error: {e}"))?}+fn remove_path_with_retry(path: &str, is_dir: bool) -> Result<(), std::io::Error> {+ let mut last_err: Option<std::io::Error> = None;+ for attempt in 0..4 {+ let result = if is_dir {+ fs::remove_dir_all(path)+ } else {+ fs::remove_file(path)+ };+ match result {+ Ok(()) => return Ok(()),+ Err(err) if attempt < 3 && is_windows_transient_delete_error(&err) => {+ last_err = Some(err);+ thread::sleep(Duration::from_millis(250 * (1_u64 << attempt)));+ }+ Err(err) => return Err(err),+ }+ }+ Err(last_err.unwrap_or_else(|| std::io::Error::other("delete failed")))+}++fn is_windows_transient_delete_error(err: &std::io::Error) -> bool {+ #[cfg(windows)]+ {+ matches!(err.raw_os_error(), Some(32 | 33))+ || err.kind() == std::io::ErrorKind::PermissionDenied+ }+ #[cfg(not(windows))]+ {+ let _ = err;+ false+ }+}+/// Find wiki pages that reference a given source file name./// Scans all .md files under wiki/ for the source filename in frontmatter or content.#[tauri::command]diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 1ba36055..d4163847 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://schema.tauri.app/config/2","productName": "LLM Wiki",- "version": "0.4.8",+ "version": "0.4.9","identifier": "com.llmwiki.app","build": {"beforeDevCommand": "npm run dev",diff --git a/src-tauri/windows-app-manifest.xml b/src-tauri/windows-app-manifest.xmlnew file mode 100644index 00000000..61df80ac--- /dev/null+++ b/src-tauri/windows-app-manifest.xml@@ -0,0 +1,19 @@+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">+ <dependency>+ <dependentAssembly>+ <assemblyIdentity+ type="win32"+ name="Microsoft.Windows.Common-Controls"+ version="6.0.0.0"+ processorArchitecture="*"+ publicKeyToken="6595b64144ccf1df"+ language="*"+ />+ </dependentAssembly>+ </dependency>+ <application xmlns="urn:schemas-microsoft-com:asm.v3">+ <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">+ <ws2:longPathAware>true</ws2:longPathAware>+ </windowsSettings>+ </application>+</assembly>diff --git a/src/lib/changelog.ts b/src/lib/changelog.tsindex c57b2b38..a1be1762 100644--- a/src/lib/changelog.ts+++ b/src/lib/changelog.ts@@ -25,6 +25,14 @@ export interface ChangelogEntry {}export const CHANGELOG: ChangelogEntry[] = [+ {+ version: "0.4.9",+ date: "2026-05-11",+ highlights: {+ en: ["Fixed Windows compatibility issues around file paths, source sync, and file deletion."],+ zh: ["修复 Windows 下文件路径、原始资料同步和文件删除相关的兼容性问题。"],+ },+ },{version: "0.4.8",date: "2026-05-11",diff --git a/src/lib/ingest-parse.test.ts b/src/lib/ingest-parse.test.tsindex d632acdb..060c4cb6 100644--- a/src/lib/ingest-parse.test.ts+++ b/src/lib/ingest-parse.test.ts@@ -378,6 +378,31 @@ describe("isSafeIngestPath — what the validator accepts and rejects", () => {expect(isSafeIngestPath("wiki/concepts/foo\nbar.md")).toBe(false)expect(isSafeIngestPath("wiki/\x07alarm.md")).toBe(false)})++ it("rejects Windows-invalid characters in generated filenames", () => {+ expect(isSafeIngestPath("wiki/concepts/Article: Why It Matters.md")).toBe(false)+ expect(isSafeIngestPath('wiki/concepts/quoted"name.md')).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/a|b.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/a?b.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/a*b.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/a<b>.md")).toBe(false)+ })++ it("rejects Windows reserved device names even with extensions", () => {+ expect(isSafeIngestPath("wiki/concepts/con.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/NUL.pdf.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/com1.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/LPT9.notes.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/auxiliary.md")).toBe(true)+ })++ it("rejects segments ending in a space or dot for Windows compatibility", () => {+ expect(isSafeIngestPath("wiki/concepts/topic .md")).toBe(true)+ expect(isSafeIngestPath("wiki/concepts/topic.")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/topic ")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/folder./topic.md")).toBe(false)+ expect(isSafeIngestPath("wiki/concepts/folder /topic.md")).toBe(false)+ })})describe("parseFileBlocks — path-traversal guard end-to-end", () => {diff --git a/src/lib/ingest.ts b/src/lib/ingest.tsindex 279b3f26..bd79354d 100644--- a/src/lib/ingest.ts+++ b/src/lib/ingest.ts@@ -96,6 +96,8 @@ const CLOSER_LINE = /^---\s*END\s+FILE\s*---\s*$/i* - paths not starting with `wiki/`* - absolute paths (`/etc/passwd`, `C:/Windows/...`)* - any `..` segment+ * - Windows-invalid filename characters / reserved device names+ * - segments ending in space or `.`* - NUL or control characters* - empty / whitespace-only paths*@@ -111,11 +113,32 @@ export function isSafeIngestPath(p: string): boolean {// Normalize backslashes so a Windows-style payload doesn't sneak past.const normalized = p.replace(/\\/g, "/")// No `..` segments, regardless of position.- if (normalized.split("/").some((seg) => seg === "..")) return false+ const segments = normalized.split("/")+ if (segments.some((seg) => seg === "..")) return false+ if (segments.some((seg) => !isWindowsSafePathSegment(seg))) return false// Must live under wiki/ — the only tree the ingest pipeline writes to.if (!normalized.startsWith("wiki/")) return falsereturn true}++function isWindowsSafePathSegment(segment: string): boolean {+ if (segment.length === 0) return false+ if (/[<>:"|?*]/.test(segment)) return false+ if (/[ .]$/.test(segment)) return false+ const stem = segment.split(".")[0]?.toUpperCase()+ if (!stem) return false+ if (+ stem === "CON" ||+ stem === "PRN" ||+ stem === "AUX" ||+ stem === "NUL" ||+ /^COM[1-9]$/.test(stem) ||+ /^LPT[1-9]$/.test(stem)+ ) {+ return false+ }+ return true+}// Fence delimiters per CommonMark (triple+ backticks or tildes). Leading// indentation ≤ 3 spaces is still a fence; 4+ spaces is an indented code// block and doesn't use fence markers.@@ -229,7 +252,7 @@ export function parseFileBlocks(text: string): ParseFileBlocksResult {if (!isSafeIngestPath(path)) {// Path-traversal guard. Drops blocks whose path tries to escape// wiki/ — see isSafeIngestPath for the threat model.- const msg = `FILE block with unsafe path "${path}" rejected (must be under wiki/, no .., no absolute paths).`+ const msg = `FILE block with unsafe path "${path}" rejected (must be under wiki/, no .., no absolute paths, and Windows-safe file names).`console.warn(`[ingest] ${msg}`)warnings.push(msg)continue