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: language detection + case-insensitive wikilinks + entity/source lang skip
nash_suffeaf86a5b38
diff --git a/src/lib/detect-language.ts b/src/lib/detect-language.tsindex 36909b02..26ba7d83 100644--- a/src/lib/detect-language.ts+++ b/src/lib/detect-language.ts@@ -16,6 +16,15 @@ export function detectLanguage(text: string): string {}}+ // Special case: Japanese uses BOTH Hiragana/Katakana and Kanji. Pure+ // Chinese uses ONLY Kanji. If we see any Japanese script characters at+ // all alongside Kanji, the language is Japanese, regardless of which+ // count dominates. (Kanji-heavy Japanese text would otherwise be+ // misclassified as Chinese.)+ if ((counts.Japanese ?? 0) > 0 && (counts.Chinese ?? 0) > 0) {+ return "Japanese"+ }+// If non-Latin scripts detected, return the dominant onelet maxScript = ""let maxCount = 0diff --git a/src/lib/ingest.ts b/src/lib/ingest.tsindex ba9cd8c0..17f60a93 100644--- a/src/lib/ingest.ts+++ b/src/lib/ingest.ts@@ -280,13 +280,25 @@ async function writeFileBlocks(projectPath: string, text: string): Promise<strinif (!relativePath) continue// Language guard: reject individual FILE blocks whose body contradicts- // the user-set target language. Log entries are short / structural so- // skip the check for them.+ // the user-set target language. Skip:+ // - log.md (structural, short)+ // - /sources/ and /entities/ pages: these legitimately cite cross-+ // language proper nouns (a German philosophy source summary naturally+ // quotes Russian philosophers) which confuses naive script-based+ // detection. Keep the check for /concepts/ pages, which should be+ // authoritative content in the target language.+ const isLog =+ relativePath.endsWith("/log.md") || relativePath === "wiki/log.md"+ const isEntityOrSource =+ relativePath.startsWith("wiki/entities/") ||+ relativePath.includes("/entities/") ||+ relativePath.startsWith("wiki/sources/") ||+ relativePath.includes("/sources/")if (targetLang &&targetLang !== "auto" &&- !relativePath.endsWith("/log.md") &&- relativePath !== "wiki/log.md" &&+ !isLog &&+ !isEntityOrSource &&!contentMatchesTargetLanguage(content, targetLang)) {console.warn(diff --git a/src/lib/lint.ts b/src/lib/lint.tsindex d443663f..b20117d4 100644--- a/src/lib/lint.ts+++ b/src/lib/lint.ts@@ -43,7 +43,12 @@ function relativeToSlug(relativePath: string): string {return relativePath.replace(/\.md$/, "")}-/** Build a slug → absolute path map from wiki files */+/**+ * Build a slug → absolute path map from wiki files. Keys are lowercased+ * so [[Transformer]] matches transformer.md — wikilink matching should+ * be case-insensitive (matching typical wiki conventions). Callers must+ * also lowercase their lookup keys.+ */function buildSlugMap(wikiFiles: FileNode[],wikiRoot: string,@@ -52,9 +57,9 @@ function buildSlugMap(for (const f of wikiFiles) {// e.g. /path/to/project/wiki/entities/foo.md → entities/fooconst rel = getRelativePath(f.path, wikiRoot).replace(/\.md$/, "")- map.set(rel, f.path)+ map.set(rel.toLowerCase(), f.path)// also index by basename without extension- map.set(f.name.replace(/\.md$/, ""), f.path)+ map.set(f.name.replace(/\.md$/, "").toLowerCase(), f.path)}return map}@@ -93,13 +98,15 @@ export async function runStructuralLint(projectPath: string): Promise<LintResult}}- // Build inbound link count+ // Build inbound link count. Lookups are case-insensitive — [[Transformer]]+ // should match transformer.md (slug "transformer").const inboundCounts = new Map<string, number>()for (const p of pages) {for (const link of p.outlinks) {- const target = slugMap.has(link)- ? relativeToSlug(getRelativePath(slugMap.get(link)!, wikiRoot))- : link+ const lookup = link.toLowerCase()+ const target = slugMap.has(lookup)+ ? relativeToSlug(getRelativePath(slugMap.get(lookup)!, wikiRoot)).toLowerCase()+ : lookupinboundCounts.set(target, (inboundCounts.get(target) ?? 0) + 1)}}@@ -109,8 +116,8 @@ export async function runStructuralLint(projectPath: string): Promise<LintResultfor (const p of pages) {const shortName = getRelativePath(p.path, wikiRoot)- // Orphan: no inbound links- const inbound = inboundCounts.get(p.slug) ?? 0+ // Orphan: no inbound links (lowercased slug for case-insensitive match)+ const inbound = inboundCounts.get(p.slug.toLowerCase()) ?? 0if (inbound === 0) {results.push({type: "orphan",@@ -130,9 +137,11 @@ export async function runStructuralLint(projectPath: string): Promise<LintResult})}- // Broken links+ // Broken links — case-insensitive matching.for (const link of p.outlinks) {- const exists = slugMap.has(link) || slugMap.has(getFileName(link).replace(/\.md$/, ""))+ const lookup = link.toLowerCase()+ const basename = getFileName(link).replace(/\.md$/, "").toLowerCase()+ const exists = slugMap.has(lookup) || slugMap.has(basename)if (!exists) {results.push({type: "broken-link",