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: v0.6.6
nash_su98786f69684b
diff --git a/package-lock.json b/package-lock.jsonindex f06d6a5f..a5a51a75 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "llm-wiki",- "version": "0.6.5",+ "version": "0.6.6","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "llm-wiki",- "version": "0.6.5",+ "version": "0.6.6","dependencies": {"@base-ui/react": "^1.3.0","@fontsource-variable/geist": "^5.2.8",diff --git a/package.json b/package.jsonindex 2dc6c039..25be587a 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "llm-wiki","private": true,- "version": "0.6.5",+ "version": "0.6.6","type": "module","scripts": {"dev": "vite",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 1209ecd4..6ac7123b 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -4561,7 +4561,7 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"[[package]]name = "llm-wiki"-version = "0.6.5"+version = "0.6.6"dependencies = ["arrow-array","arrow-schema",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 56f15295..76fe2326 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "llm-wiki"-version = "0.6.5"+version = "0.6.6"description = "LLM Wiki - A personal knowledge base for LLM concepts"authors = []edition = "2021"diff --git a/src-tauri/src/agent/tools.rs b/src-tauri/src/agent/tools.rsindex 47bd7117..67be466d 100644--- a/src-tauri/src/agent/tools.rs+++ b/src-tauri/src/agent/tools.rs@@ -1179,7 +1179,7 @@ pub async fn run_web_search(if provider.is_empty() || provider == "none" {return Err("Web search provider is not configured.".to_string());}- let max_results = top_k.clamp(1, 20);+ let max_results = web_search_result_limit(&provider, top_k);let client = reqwest::Client::builder().timeout(std::time::Duration::from_secs(WEB_SEARCH_TIMEOUT_SECS)).build()@@ -1190,6 +1190,7 @@ pub async fn run_web_search("tavily" => tavily_search(&client, query, &config, max_results).await?,"ollama" => ollama_search(&client, query, &config, max_results).await?,"brave" => brave_search(&client, query, &config, max_results).await?,+ "bocha" => bocha_search(&client, query, &config, max_results).await?,"serpapi" => serpapi_search(&client, query, &config, max_results).await?,other => {return Err(format!(@@ -1200,6 +1201,13 @@ pub async fn run_web_search(Ok(web_items_to_references(raw, max_results))}+fn web_search_result_limit(provider: &str, requested: usize) -> usize {+ // Bocha documents a 1-50 range. Existing providers retain the historical+ // 20-result ceiling so adding Bocha cannot increase their request cost.+ let provider_max = if provider == "bocha" { 50 } else { 20 };+ requested.clamp(1, provider_max)+}+pub async fn run_anytxt_search(query: &str,config: Option<AnyTxtConfig>,@@ -1802,6 +1810,58 @@ async fn brave_search(.await}+async fn bocha_search(+ client: &reqwest::Client,+ query: &str,+ config: &WebSearchConfig,+ max_results: usize,+) -> Result<Vec<WebSearchItem>, String> {+ let key = required_api_key(config, "Bocha")?;+ let response = client+ .post("https://api.bocha.cn/v1/web-search")+ .header("Accept", "application/json")+ .bearer_auth(key)+ .json(&json!({+ "query": query,+ "freshness": "noLimit",+ "summary": true,+ "count": max_results.clamp(1, 50)+ }))+ .send()+ .await+ .map_err(|err| format!("Network error reaching Bocha Search: {err}"))?;+ parse_web_json_response(response, "Bocha Search", parse_bocha_results).await+}++fn parse_bocha_results(value: Value) -> Vec<WebSearchItem> {+ value+ .get("data")+ .and_then(|data| data.get("webPages"))+ .and_then(|pages| pages.get("value"))+ .and_then(Value::as_array)+ .into_iter()+ .flatten()+ .map(|item| WebSearchItem {+ title: item+ .get("name")+ .and_then(Value::as_str)+ .unwrap_or("Untitled")+ .to_string(),+ url: item+ .get("url")+ .and_then(Value::as_str)+ .unwrap_or("")+ .to_string(),+ snippet: item+ .get("summary")+ .and_then(Value::as_str)+ .or_else(|| item.get("snippet").and_then(Value::as_str))+ .unwrap_or("")+ .to_string(),+ })+ .collect()+}+async fn serpapi_search(client: &reqwest::Client,query: &str,@@ -1873,6 +1933,17 @@ async fn parse_web_json_response(}fn provider_payload_error(provider: &str, value: &Value) -> Option<String> {+ if provider == "Bocha Search" {+ let code = value.get("code").and_then(Value::as_i64);+ if code != Some(200) {+ let message = value+ .get("msg")+ .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)));+ }+ }if provider == "Brave Search" && value.get("web").is_none() {let message = value.get("message").and_then(Value::as_str)?;return Some(format!("{provider} search failed: {message}"));@@ -3453,6 +3524,55 @@ mod tests {);}+ #[test]+ fn bocha_payload_error_requires_success_code() {+ let failure = json!({ "code": 401, "msg": "invalid api key" });+ assert_eq!(+ provider_payload_error("Bocha Search", &failure),+ Some("Bocha Search failed (code 401): invalid api key".to_string())+ );+ assert_eq!(+ provider_payload_error("Bocha Search", &json!({ "code": 200, "data": {} })),+ None+ );+ }++ #[test]+ fn bocha_results_prefer_summary_and_fall_back_to_snippet() {+ let items = parse_bocha_results(json!({+ "code": 200,+ "data": {+ "webPages": {+ "value": [+ {+ "name": "Summary result",+ "url": "https://example.com/summary",+ "snippet": "short",+ "summary": "long summary"+ },+ {+ "name": "Snippet result",+ "url": "https://example.com/snippet",+ "summary": null,+ "snippet": "fallback snippet"+ }+ ]+ }+ }+ }));+ assert_eq!(items.len(), 2);+ assert_eq!(items[0].title, "Summary result");+ assert_eq!(items[0].snippet, "long summary");+ assert_eq!(items[1].snippet, "fallback snippet");+ }++ #[test]+ fn bocha_accepts_fifty_results_without_changing_other_provider_limits() {+ assert_eq!(web_search_result_limit("bocha", 100), 50);+ assert_eq!(web_search_result_limit("tavily", 100), 20);+ assert_eq!(web_search_result_limit("bocha", 0), 1);+ }+#[test]fn non_brave_message_does_not_mask_valid_provider_payloads() {let value = json!({ "message": "FYI" });diff --git a/src-tauri/src/clip_server.rs b/src-tauri/src/clip_server.rsindex bb6c5493..973a641e 100644--- a/src-tauri/src/clip_server.rs+++ b/src-tauri/src/clip_server.rs@@ -22,7 +22,7 @@ const RESTART_DELAY_SECS: u64 = 5;const fn next_restart_count(current: u32) -> Option<u32> {let next = current.saturating_add(1);- if next >= MAX_RESTART_RETRIES {+ if next > MAX_RESTART_RETRIES {None} else {Some(next)@@ -368,7 +368,7 @@ mod lan_auth_tests {#[test]fn restart_counter_stops_at_the_configured_limit() {let mut count = 0;- for expected in 1..MAX_RESTART_RETRIES {+ for expected in 1..=MAX_RESTART_RETRIES {count = next_restart_count(count).unwrap();assert_eq!(count, expected);}diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 35637d58..232da948 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.6.5",+ "version": "0.6.6","identifier": "com.llmwiki.app","build": {"beforeDevCommand": "npm run dev",diff --git a/src/components/settings/sections/web-search-section.tsx b/src/components/settings/sections/web-search-section.tsxindex d3be2c2a..b4284b5c 100644--- a/src/components/settings/sections/web-search-section.tsx+++ b/src/components/settings/sections/web-search-section.tsx@@ -62,6 +62,13 @@ const SEARCH_PROVIDERS = [keyPlaceholder: "Enter your Brave Search API subscription token",configKind: "key",},+ {+ id: "bocha",+ label: "Bocha Search",+ hint: "Chinese and global web search via Bocha AI",+ keyPlaceholder: "Enter your Bocha API key (open.bocha.cn)",+ configKind: "key",+ },] as constexport function WebSearchSection() {@@ -406,6 +413,11 @@ export function WebSearchSection() {{t("settings.sections.webSearch.ollamaHint")}</p>)}+ {provider.id === "bocha" && (+ <p className="text-xs text-muted-foreground">+ {t("settings.sections.webSearch.bochaHint")}+ </p>+ )}</div>)}diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex d0b052f9..994c8a17 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -667,6 +667,7 @@"savedBadge": "Saved","instanceUrl": "Instance URL","ollamaHint": "Uses the official Ollama Web Search API (`https://ollama.com/api/web_search`). An Ollama API key is required.",+ "bochaHint": "Uses the official Bocha Web Search API. Create and manage API keys at open.bocha.cn.","firecrawlHint": "Leave API key blank for anonymous search, or add a Firecrawl API key for authenticated quota. Base URL supports compatible self-hosted endpoints.","searxngJsonHint": "The instance must allow JSON search responses (`format=json`).","searchCategories": "Search categories",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex c9a6e4b7..fefbd11e 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -667,6 +667,7 @@"savedBadge": "已保存","instanceUrl": "实例 URL","ollamaHint": "使用官方 Ollama Web Search API(`https://ollama.com/api/web_search`),需要填写 Ollama API Key。",+ "bochaHint": "使用博查官方网页搜索 API。可前往 open.bocha.cn 创建和管理 API Key。","firecrawlHint": "API Key 留空时使用匿名搜索;填写 Firecrawl API Key 后使用认证额度。Base URL 也可指向兼容的自托管端点。","searxngJsonHint": "实例必须允许 JSON 搜索响应(`format=json`)。","searchCategories": "搜索分类",diff --git a/src/lib/changelog.ts b/src/lib/changelog.tsindex 5c228303..40a8a644 100644--- a/src/lib/changelog.ts+++ b/src/lib/changelog.ts@@ -25,6 +25,24 @@ export interface ChangelogEntry {}export const CHANGELOG: ChangelogEntry[] = [+ {+ version: "0.6.6",+ date: "2026-07-27",+ highlights: {+ en: [+ "Added Bocha Web Search as an external search provider for Agent, Deep Research, API, and MCP workflows.",+ "Added targeted recovery for truncated Ingest output so missing Wiki files can be regenerated automatically.",+ "Improved cross-platform PDF preview support.",+ "Improved Windows scheduled imports, nested paths, drive-letter and UNC path handling, Clip Server recovery, and overall stability.",+ ],+ zh: [+ "新增博查网页搜索 Provider,可用于 Agent、Deep Research、API 和 MCP 工作流。",+ "新增 Ingest 截断定向恢复,可自动重新生成缺失的 Wiki 文件。",+ "完善 PDF 跨平台预览支持。",+ "优化 Windows 计划导入、嵌套目录、盘符和 UNC 路径处理,并改进 Clip Server 恢复与整体稳定性。",+ ],+ },+ },{version: "0.6.5",date: "2026-07-20",diff --git a/src/lib/ingest-parse.test.ts b/src/lib/ingest-parse.test.tsindex 3c81ad6c..60cd0627 100644--- a/src/lib/ingest-parse.test.ts+++ b/src/lib/ingest-parse.test.ts@@ -30,6 +30,7 @@ import {canonicalizeSourcesField,isAppManagedAggregatePath,updateBoundedRecentIndexSection,+ filterTruncatedFileRepairOutput,} from "./ingest"// ── Happy paths ─────────────────────────────────────────────────────@@ -190,6 +191,34 @@ describe("parseFileBlocks — H2: truncated streams (surface, don't hide)", () =})})+describe("filterTruncatedFileRepairOutput", () => {+ it("keeps one requested block and drops duplicate and unrequested blocks", () => {+ const requested = "wiki/concepts/recovered.md"+ const result = filterTruncatedFileRepairOutput([+ `---FILE: ${requested}---`,+ "# First complete repair",+ "---END FILE---",+ `---FILE: ${requested}---`,+ "# Duplicate repair",+ "---END FILE---",+ "---FILE: wiki/concepts/unrequested.md---",+ "# Unrequested",+ "---END FILE---",+ ].join("\n"), [requested])++ expect(result.paths).toEqual([requested])+ expect(result.text).toContain("# First complete repair")+ expect(result.text).not.toContain("# Duplicate repair")+ expect(result.text).not.toContain("# Unrequested")+ expect(result.warnings).toEqual(+ expect.arrayContaining([+ expect.stringMatching(/duplicate FILE block/),+ expect.stringMatching(/unrequested FILE block/),+ ]),+ )+ })+})+// ── H3: Marker whitespace / case variants ──────────────────────────describe("parseFileBlocks — H3: tolerant marker matching", () => {diff --git a/src/lib/ingest.ts b/src/lib/ingest.tsindex 80225962..2e3af438 100644--- a/src/lib/ingest.ts+++ b/src/lib/ingest.ts@@ -1125,8 +1125,10 @@ async function autoIngestImpl(const writtenPaths = writeResult.writtenPathsconst writeWarnings = writeResult.warningsconst hardFailures = writeResult.hardFailures- let unrecoveredTruncatedPaths = writeResult.truncatedPaths.filter((path) =>- !writtenPaths.some((writtenPath) => normalizePath(writtenPath) === normalizePath(path))+ let unrecoveredTruncatedPaths = uniqueNormalizedPaths(+ writeResult.truncatedPaths.filter((path) =>+ !writtenPaths.some((writtenPath) => normalizePath(writtenPath) === normalizePath(path))+ ),)if (unrecoveredTruncatedPaths.length > 0 && !signal?.aborted) {@@ -1170,7 +1172,10 @@ async function autoIngestImpl({temperature: 0.1,reasoning: { mode: "off" },- max_tokens: computeIngestReviewMaxTokens(llmConfig.maxContextSize),+ // A repair must regenerate the complete FILE body. Reusing the+ // smaller review budget can immediately truncate the same long page+ // that exhausted the original response.+ max_tokens: computeIngestGenerationMaxTokens(llmConfig.maxContextSize),},)throwIfIngestAborted(signal, activityId)@@ -1191,9 +1196,15 @@ async function autoIngestImpl(activityId,onFileWritten,)- const recoveredPaths = repairResult.writtenPaths.length === filteredRepair.paths.length- ? filteredRepair.paths- : []+ // Match successful writes against the paths requested from the model,+ // not the final on-disk paths. writeFileBlocks may legitimately rewrite+ // a title-derived filename for the selected output language.+ const completedInputPathKeys = new Set(+ repairResult.completedInputPaths.map(normalizePath),+ )+ const recoveredPaths = filteredRepair.paths.filter((path) =>+ completedInputPathKeys.has(normalizePath(path)),+ )for (const path of repairResult.writtenPaths) {if (!writtenPaths.some((writtenPath) => normalizePath(writtenPath) === normalizePath(path))) {writtenPaths.push(path)@@ -1207,8 +1218,9 @@ async function autoIngestImpl(}writeWarnings.push(...repairResult.warnings)hardFailures.push(...repairResult.hardFailures)+ const recoveredPathKeys = new Set(recoveredPaths.map(normalizePath))unrecoveredTruncatedPaths = unrecoveredTruncatedPaths.filter((path) =>- !recoveredPaths.includes(path)+ !recoveredPathKeys.has(normalizePath(path)))}} catch (err) {@@ -1782,10 +1794,20 @@ async function writeFileBlocks(signal?: AbortSignal,activityId?: string,onFileWritten?: (relativePath: string) => void,-): Promise<{ writtenPaths: string[]; warnings: string[]; hardFailures: string[]; truncatedPaths: string[] }> {+): Promise<{+ writtenPaths: string[]+ completedInputPaths: string[]+ warnings: string[]+ hardFailures: string[]+ truncatedPaths: string[]+}> {const { blocks, warnings: parseWarnings, truncatedPaths } = parseFileBlocks(text)const warnings = [...parseWarnings]const writtenPaths: string[] = []+ // Keep the model-requested path separate from the final path. Path+ // canonicalization may rename the file after parsing, but callers that+ // repair a specific FILE block still need to know that request succeeded.+ const completedInputPaths: string[] = []// "Hard failures" = blocks we INTENDED to write but the FS rejected// (disk full, permission, OS-level errors). Distinct from soft drops// (language mismatch, parse warnings, path-traversal rejections):@@ -1936,6 +1958,7 @@ async function writeFileBlocks(await writeFile(fullPath, toWrite)}writtenPaths.push(relativePath)+ completedInputPaths.push(rawRelativePath)onFileWritten?.(relativePath)} catch (err) {const msg = `Failed to write "${relativePath}": ${err instanceof Error ? err.message : String(err)}`@@ -1945,7 +1968,13 @@ async function writeFileBlocks(}}- return { writtenPaths, warnings, hardFailures, truncatedPaths }+ return {+ writtenPaths,+ completedInputPaths,+ warnings,+ hardFailures,+ truncatedPaths,+ }}function isOwnedOnlyBySource(content: string, sourceIdentity: string): boolean {@@ -2360,19 +2389,39 @@ function buildTruncatedFileRepairPrompt(].filter(Boolean).join("\n")}-function filterTruncatedFileRepairOutput(+export function filterTruncatedFileRepairOutput(text: string,allowedPaths: readonly string[],): { text: string; paths: string[]; warnings: string[] } {const allowed = new Set(allowedPaths.map(normalizePath))const { blocks, warnings } = parseFileBlocks(text)- const kept = blocks.filter((block) => allowed.has(normalizePath(block.path)))- const dropped = blocks.filter((block) => !allowed.has(normalizePath(block.path)))+ const seen = new Set<string>()+ const kept: ParsedFileBlock[] = []+ const dropped: ParsedFileBlock[] = []+ const duplicates: ParsedFileBlock[] = []+ for (const block of blocks) {+ const pathKey = normalizePath(block.path)+ if (!allowed.has(pathKey)) {+ dropped.push(block)+ continue+ }+ if (seen.has(pathKey)) {+ duplicates.push(block)+ continue+ }+ seen.add(pathKey)+ kept.push(block)+ }if (dropped.length > 0) {warnings.push(`Dropped ${dropped.length} unrequested FILE block(s) from truncated repair output: ${dropped.map((block) => block.path).join(", ")}`,)}+ if (duplicates.length > 0) {+ warnings.push(+ `Dropped ${duplicates.length} duplicate FILE block(s) from truncated repair output: ${duplicates.map((block) => block.path).join(", ")}`,+ )+ }return {text: kept.map((block) => `---FILE: ${block.path}---\n${block.content.trimEnd()}\n---END FILE---`)@@ -2382,6 +2431,16 @@ function filterTruncatedFileRepairOutput(}}+function uniqueNormalizedPaths(paths: readonly string[]): string[] {+ const seen = new Set<string>()+ return paths.filter((path) => {+ const key = normalizePath(path)+ if (seen.has(key)) return false+ seen.add(key)+ return true+ })+}+function getStore() {return useChatStore.getState()}diff --git a/src/lib/web-search.test.ts b/src/lib/web-search.test.tsindex af3047fc..be624f97 100644--- a/src/lib/web-search.test.ts+++ b/src/lib/web-search.test.ts@@ -63,7 +63,9 @@ describe("webSearch", () => {await expect(webSearch("x", { provider: "none", apiKey: "" }, 5)).rejects.toThrow("Web search not configured")await expect(webSearch("x", { provider: "serpapi", apiKey: "" }, 5))- .rejects.toThrow("Add a Tavily, SerpApi, or Brave Search API key")+ .rejects.toThrow("Add an API key for the selected search provider")+ await expect(webSearch("x", { provider: "bocha", apiKey: "" }, 5))+ .rejects.toThrow("Add an API key for the selected search provider")await expect(webSearch("x", { provider: "searxng", apiKey: "" }, 5)).rejects.toThrow("Add a SearXNG instance URL")await expect(webSearch("x", { provider: "ollama", apiKey: "" }, 5))@@ -71,6 +73,27 @@ describe("webSearch", () => {expect(invokeMock).not.toHaveBeenCalled()})+ it("resolves and forwards a stored Bocha provider key", async () => {+ invokeMock.mockResolvedValueOnce([])++ await webSearch("阿里巴巴 ESG 报告", {+ provider: "bocha",+ apiKey: "",+ providerConfigs: {+ bocha: { apiKey: "bocha-key" },+ },+ }, 12)++ expect(invokeMock).toHaveBeenCalledWith("web_search", {+ query: "阿里巴巴 ESG 报告",+ maxResults: 12,+ config: expect.objectContaining({+ provider: "bocha",+ apiKey: "bocha-key",+ }),+ })+ })+it("treats key-free providers as configured", () => {expect(hasConfiguredSearchProvider({ provider: "searxng", apiKey: "", searXngUrl: "http://localhost:8080" })).toBe(true)expect(hasConfiguredSearchProvider({ provider: "firecrawl", apiKey: "" })).toBe(true)diff --git a/src/lib/web-search.ts b/src/lib/web-search.tsindex 5f029dde..7ae76ab7 100644--- a/src/lib/web-search.ts+++ b/src/lib/web-search.ts@@ -137,10 +137,15 @@ export async function webSearch(throw new Error("Web search not configured. Select a search provider in Settings.")}if (- (resolved.provider === "tavily" || resolved.provider === "serpapi" || resolved.provider === "brave") &&+ (+ resolved.provider === "tavily" ||+ resolved.provider === "serpapi" ||+ resolved.provider === "brave" ||+ resolved.provider === "bocha"+ ) &&!resolved.apiKey) {- throw new Error("Web search not configured. Add a Tavily, SerpApi, or Brave Search API key in Settings, or select a key-free provider such as Firecrawl or SearXNG.")+ throw new Error("Web search not configured. Add an API key for the selected search provider in Settings, or select a key-free provider such as Firecrawl or SearXNG.")}if (resolved.provider === "searxng" && !resolved.searXngUrl?.trim()) {throw new Error("Web search not configured. Add a SearXNG instance URL in Settings.")diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.tsindex 29da074d..58c71863 100644--- a/src/stores/wiki-store.ts+++ b/src/stores/wiki-store.ts@@ -57,6 +57,7 @@ export type SearchProvider =| "searxng"| "ollama"| "brave"+ | "bocha"| "firecrawl"| "none"export type DeepResearchSource = "web" | "anytxt" | "both"