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: harden archive exports and clean Rust warnings
nash_su47373c51ac27
diff --git a/src-tauri/src/agent/tools.rs b/src-tauri/src/agent/tools.rsindex 67be466d..caeb367f 100644--- a/src-tauri/src/agent/tools.rs+++ b/src-tauri/src/agent/tools.rs@@ -646,6 +646,7 @@ fn tool_top_k(input: &Value) -> usize {.clamp(1, 10)}+#[cfg(test)]pub fn write_wiki_page_with_options(project_path: &str,rel_path: &str,@@ -1941,7 +1942,10 @@ fn provider_payload_error(provider: &str, value: &Value) -> Option<String> {.and_then(Value::as_str).filter(|message| !message.trim().is_empty()).unwrap_or("unknown API error");- return Some(format!("{provider} failed (code {}): {message}", code.unwrap_or(0)));+ return Some(format!(+ "{provider} failed (code {}): {message}",+ code.unwrap_or(0)+ ));}}if provider == "Brave Search" && value.get("web").is_none() {diff --git a/src-tauri/src/commands/claude_cli.rs b/src-tauri/src/commands/claude_cli.rsindex f11d8d61..cc43a93a 100644--- a/src-tauri/src/commands/claude_cli.rs+++ b/src-tauri/src/commands/claude_cli.rs@@ -161,8 +161,6 @@ async fn find_claude_command() -> Result<PathBuf, String> {fn suppress_windows_console(_cmd: &mut Command) {#[cfg(windows)]{- use std::os::windows::process::CommandExt;-const CREATE_NO_WINDOW: u32 = 0x08000000;_cmd.creation_flags(CREATE_NO_WINDOW);}diff --git a/src-tauri/src/commands/cli_resolver.rs b/src-tauri/src/commands/cli_resolver.rsindex 725316e1..2175a811 100644--- a/src-tauri/src/commands/cli_resolver.rs+++ b/src-tauri/src/commands/cli_resolver.rs@@ -1,10 +1,14 @@use std::collections::HashMap;use std::path::PathBuf;+#[cfg(not(windows))]use std::process::{Command, Stdio};use std::sync::{Mutex, OnceLock};+#[cfg(not(windows))]use std::time::Duration;+#[cfg(not(windows))]const LOGIN_SHELL_PATH_TIMEOUT: Duration = Duration::from_secs(3);+#[cfg(not(windows))]const PATH_MARKER: char = '\x1e';static RESOLVED_COMMANDS: OnceLock<Mutex<HashMap<String, PathBuf>>> = OnceLock::new();diff --git a/src-tauri/src/commands/codex_cli.rs b/src-tauri/src/commands/codex_cli.rsindex 2d6dcfa7..41d647b1 100644--- a/src-tauri/src/commands/codex_cli.rs+++ b/src-tauri/src/commands/codex_cli.rs@@ -62,8 +62,6 @@ async fn find_codex_command() -> Result<PathBuf, String> {fn suppress_windows_console(_cmd: &mut Command) {#[cfg(windows)]{- use std::os::windows::process::CommandExt;-const CREATE_NO_WINDOW: u32 = 0x08000000;_cmd.creation_flags(CREATE_NO_WINDOW);}diff --git a/src-tauri/src/commands/fs.rs b/src-tauri/src/commands/fs.rsindex e7f3727a..f6ac8bc6 100644--- a/src-tauri/src/commands/fs.rs+++ b/src-tauri/src/commands/fs.rs@@ -664,10 +664,12 @@ fn extract_docx_with_library(path: &str) -> Result<String, String> {docx_rs::DocumentChild::Table(table) => {let mut rows: Vec<Vec<String>> = Vec::new();for row in &table.rows {- if let docx_rs::TableChild::TableRow(tr) = row {+ {+ let docx_rs::TableChild::TableRow(tr) = row;let mut cells: Vec<String> = Vec::new();for cell in &tr.cells {- if let docx_rs::TableRowChild::TableCell(tc) = cell {+ {+ let docx_rs::TableRowChild::TableCell(tc) = cell;let mut cell_text = String::new();for child in &tc.children {if let docx_rs::TableCellContent::Paragraph(para) = child {@@ -748,8 +750,6 @@ fn extract_docx_markdown(archive: &mut zip::ZipArchive<fs::File>) -> Result<Strilet chars: Vec<char> = xml.chars().collect();let len = chars.len();- // Track current paragraph state- let mut in_paragraph = false;let mut paragraph_text = String::new();let mut is_heading = false;let mut heading_level: u8 = 1;@@ -765,7 +765,6 @@ fn extract_docx_markdown(archive: &mut zip::ZipArchive<fs::File>) -> Result<Striwhile i < len {if chars[i] == '<' {// Read tag name- let tag_start = i;i += 1;let is_closing = i < len && chars[i] == '/';if is_closing {@@ -791,7 +790,6 @@ fn extract_docx_markdown(archive: &mut zip::ZipArchive<fs::File>) -> Result<Strimatch tag_name.as_str() {// Paragraph start"w:p" if !is_closing => {- in_paragraph = true;paragraph_text.clear();is_heading = false;in_list_item = false;@@ -812,7 +810,6 @@ fn extract_docx_markdown(archive: &mut zip::ZipArchive<fs::File>) -> Result<Striresult.push_str("\n\n");}}- in_paragraph = false;paragraph_text.clear();}// Heading style detectiondiff --git a/src-tauri/src/commands/project_maintenance.rs b/src-tauri/src/commands/project_maintenance.rsindex f5848f28..cb892f66 100644--- a/src-tauri/src/commands/project_maintenance.rs+++ b/src-tauri/src/commands/project_maintenance.rs@@ -93,6 +93,30 @@ mod tests {let _ = fs::remove_dir_all(root);let _ = fs::remove_dir_all(sibling);}++ #[test]+ fn export_uses_the_resolved_destination_path() {+ let source = temp("export-resolved-source");+ let destination_dir = temp("export-resolved-target");+ fs::create_dir_all(source.join("wiki")).unwrap();+ fs::create_dir_all(&destination_dir).unwrap();+ fs::write(source.join("wiki/index.md"), "# Index").unwrap();++ let destination = destination_dir+ .join("..")+ .join(destination_dir.file_name().unwrap())+ .join("archive.zip");+ let resolved = destination_dir.canonicalize().unwrap().join("archive.zip");+ export_project_archive_inner(+ source.to_string_lossy().into_owned(),+ destination.to_string_lossy().into_owned(),+ )+ .unwrap();++ assert!(resolved.is_file());+ let _ = fs::remove_dir_all(source);+ let _ = fs::remove_dir_all(destination_dir);+ }}#[tauri::command]@@ -135,8 +159,10 @@ fn export_project_archive_inner(project_path: String, destination: String) -> Relet root = PathBuf::from(&project_path).canonicalize().map_err(|e| e.to_string())?;- let output = PathBuf::from(destination);- resolve_export_destination(&root, &output)?;+ // Use the same canonical destination that passed containment validation.+ // Reusing the unresolved input would separate the checked path from the+ // path opened for writing and retain avoidable traversal/TOCTOU surface.+ let output = resolve_export_destination(&root, &PathBuf::from(destination))?;let file = File::create(&output).map_err(|e| e.to_string())?;let mut zip = zip::ZipWriter::new(file);let options = SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated);diff --git a/src-tauri/src/proxy.rs b/src-tauri/src/proxy.rsindex 25f7019d..fb3c0d81 100644--- a/src-tauri/src/proxy.rs+++ b/src-tauri/src/proxy.rs@@ -404,7 +404,7 @@ mod tests {}#[test]- fn parses_camelcase_bypassLocal_field() {+ fn parses_camelcase_bypass_local_field() {// Frontend writes `bypassLocal` (camelCase). We must accept// that exact spelling — verify the serde rename works.let json = r#"{"enabled": true, "url": "http://x:1", "bypassLocal": false}"#;@@ -415,7 +415,7 @@ mod tests {}#[test]- fn missing_proxyConfig_returns_none() {+ fn missing_proxy_config_returns_none() {let dir = tempdir_for_test();let path = dir.join("missing.json");assert!(read_proxy_config_from_store(&path).is_none());