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: cross-platform compatibility audit — macOS, Windows, Linux
nash_su1ea5ebb2bc50
diff --git a/extension/popup.js b/extension/popup.jsindex 40d8ed78..4d824522 100644--- a/extension/popup.js+++ b/extension/popup.js@@ -49,7 +49,7 @@ async function loadProjects() {const res = await fetch(`${API_URL}/project`, { method: "GET" });const data = await res.json();if (data.ok && data.path) {- const name = data.path.split("/").pop() || data.path;+ const name = data.path.replace(/\\/g, "/").split("/").pop() || data.path;projectSelect.innerHTML = `<option value="${data.path}">${name}</option>`;}} catch {diff --git a/src-tauri/src/clip_server.rs b/src-tauri/src/clip_server.rsindex c18c930f..d2bab0c3 100644--- a/src-tauri/src/clip_server.rs+++ b/src-tauri/src/clip_server.rs@@ -237,10 +237,11 @@ fn handle_clip(body: &str) -> String {let slug: String = slug_raw.chars().take(50).collect();let base_name = format!("{}-{}", slug, date_compact);- let dir = format!("{}/raw/sources", project_path);+ // Use PathBuf for cross-platform path construction+ let dir_path = std::path::Path::new(&project_path).join("raw").join("sources");// Ensure directory exists- if let Err(e) = std::fs::create_dir_all(&dir) {+ if let Err(e) = std::fs::create_dir_all(&dir_path) {return format!(r#"{{"ok":false,"error":"Failed to create directory: {}"}}"#,e@@ -248,12 +249,13 @@ fn handle_clip(body: &str) -> String {}// Find unique filename- let mut file_path = format!("{}/{}.md", dir, base_name);+ let mut file_path = dir_path.join(format!("{}.md", base_name));let mut counter = 2u32;- while std::path::Path::new(&file_path).exists() {- file_path = format!("{}/{}-{}.md", dir, base_name, counter);+ while file_path.exists() {+ file_path = dir_path.join(format!("{}-{}.md", base_name, counter));counter += 1;}+ let file_path = file_path.to_string_lossy().to_string();// Build markdown content with web-clip originlet markdown = format!(@@ -273,7 +275,14 @@ fn handle_clip(body: &str) -> String {);}- let relative_path = file_path.replace(&format!("{}/", project_path), "");+ // Compute relative path using Path for cross-platform separator handling+ let relative_path = {+ let full = std::path::Path::new(&file_path);+ let base = std::path::Path::new(&project_path);+ full.strip_prefix(base)+ .map(|p| p.to_string_lossy().replace('\\', "/"))+ .unwrap_or_else(|_| file_path.replace('\\', "/"))+ };// Add to pending clips for frontend to pick up and auto-ingestif let Ok(mut pending) = PENDING_CLIPS.lock() {diff --git a/src-tauri/src/commands/fs.rs b/src-tauri/src/commands/fs.rsindex d536a5f7..9f40cf61 100644--- a/src-tauri/src/commands/fs.rs+++ b/src-tauri/src/commands/fs.rs@@ -759,10 +759,11 @@ pub fn find_related_wiki_pages(project_path: String, source_name: String) -> Resfn collect_related_pages(dir: &Path, source_name: &str, results: &mut Vec<String>) -> Result<(), String> {let entries = fs::read_dir(dir).map_err(|e| e.to_string())?;- // Get just the filename without path- let file_name = source_name- .rsplit('/')- .next()+ // Get just the filename without path — use Path for cross-platform separator handling+ let source_path = std::path::Path::new(source_name);+ let file_name = source_path+ .file_name()+ .and_then(|n| n.to_str()).unwrap_or(source_name);let file_name_lower = file_name.to_lowercase();@@ -797,7 +798,11 @@ fn collect_related_pages(dir: &Path, source_name: &str, results: &mut Vec<String|| content_lower.contains(&format!("'{}'", file_name_lower));// Match 2: source summary page (wiki/sources/{stem}.md)- let is_source_summary = path.to_string_lossy().contains("/sources/")+ // Use Path component iteration to avoid hardcoded separator assumptions+ let is_in_sources_dir = path+ .components()+ .any(|c| c.as_os_str() == "sources");+ let is_source_summary = is_in_sources_dir&& fname.to_lowercase().starts_with(&file_stem_lower);// Match 3: page was generated from this source (check frontmatter sources field)diff --git a/src/lib/lint.ts b/src/lib/lint.tsindex 87f4e152..845cadc6 100644--- a/src/lib/lint.ts+++ b/src/lib/lint.ts@@ -3,7 +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"+import { getFileName, getRelativePath, normalizePath } from "@/lib/path-utils"export interface LintResult {type: "orphan" | "broken-link" | "no-outlinks" | "semantic"@@ -50,7 +50,7 @@ function buildSlugMap(const map = new Map<string, string>()for (const f of wikiFiles) {// e.g. /path/to/project/wiki/entities/foo.md → entities/foo- const rel = f.path.replace(wikiRoot + "/", "").replace(/\.md$/, "")+ const rel = getRelativePath(f.path, wikiRoot).replace(/\.md$/, "")map.set(rel, f.path)// also index by basename without extensionmap.set(f.name.replace(/\.md$/, ""), f.path)@@ -84,7 +84,7 @@ export async function runStructuralLint(projectPath: string): Promise<LintResultfor (const f of contentFiles) {try {const content = await readFile(f.path)- const slug = relativeToSlug(f.path.replace(wikiRoot + "/", ""))+ const slug = relativeToSlug(getRelativePath(f.path, wikiRoot))const outlinks = extractWikilinks(content)pages.push({ path: f.path, slug, content, outlinks })} catch {@@ -97,7 +97,7 @@ export async function runStructuralLint(projectPath: string): Promise<LintResultfor (const p of pages) {for (const link of p.outlinks) {const target = slugMap.has(link)- ? relativeToSlug(slugMap.get(link)!.replace(wikiRoot + "/", ""))+ ? relativeToSlug(getRelativePath(slugMap.get(link)!, wikiRoot)): linkinboundCounts.set(target, (inboundCounts.get(target) ?? 0) + 1)}@@ -106,7 +106,7 @@ export async function runStructuralLint(projectPath: string): Promise<LintResultconst results: LintResult[] = []for (const p of pages) {- const shortName = p.path.replace(wikiRoot + "/", "")+ const shortName = getRelativePath(p.path, wikiRoot)// Orphan: no inbound linksconst inbound = inboundCounts.get(p.slug) ?? 0@@ -184,7 +184,7 @@ export async function runSemanticLint(try {const content = await readFile(f.path)const preview = content.slice(0, 500) + (content.length > 500 ? "..." : "")- const shortPath = f.path.replace(wikiRoot + "/", "")+ const shortPath = getRelativePath(f.path, wikiRoot)summaries.push(`### ${shortPath}\n${preview}`)} catch {// skip