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: preserve technical names in language prompts
nash_su69fe4314988e
diff --git a/src/components/chat/chat-panel.tsx b/src/components/chat/chat-panel.tsxindex e181ea75..bd7a74c1 100644--- a/src/components/chat/chat-panel.tsx+++ b/src/components/chat/chat-panel.tsx@@ -13,7 +13,7 @@ import { listDirectory, readFile, deleteFile } from "@/commands/fs"import { searchWiki } from "@/lib/search"import { buildRetrievalGraph, getRelatedNodes } from "@/lib/graph-relevance"import { normalizePath, getFileName, getRelativePath } from "@/lib/path-utils"-import { getOutputLanguage, buildLanguageReminder } from "@/lib/output-language"+import { buildLanguageDirective, buildLanguageReminder } from "@/lib/output-language"import { isGreeting } from "@/lib/greeting-detector"import { computeContextBudget } from "@/lib/context-budget"import { anyTxtSearchSmart, hasConfiguredAnyTxt } from "@/lib/anytxt-search"@@ -201,7 +201,6 @@ export function ChatPanel() {// minimal system prompt and let the model reply conversationally.const greetingOnly = isGreeting(text)if (project && greetingOnly) {- const outLang = getOutputLanguage(text)systemMessages.push({role: "system",content: [@@ -209,7 +208,7 @@ export function ChatPanel() {"The user sent a casual greeting — reply briefly and naturally, in one or two sentences.","Do NOT invent wiki content or pretend to have retrieved pages. Invite the user to ask a concrete question if they want information from the wiki.","",- `Respond in ${outLang}.`,+ buildLanguageReminder(text),].join("\n"),})// Skip retrieval; queryRefs stays empty so no "Sources" chip is shown.@@ -372,8 +371,6 @@ export function ChatPanel() {).join("\n")const externalContext = formatExternalSearchContext(externalSearchResults)- const outLang = getOutputLanguage(text)-systemMessages.push({role: "system",content: [@@ -404,13 +401,7 @@ export function ChatPanel() {"","---","",- `## ⚠️ MANDATORY OUTPUT LANGUAGE: ${outLang}`,- "",- `You MUST write your entire response in **${outLang}**.`,- `The wiki content above may be in a different language, but this is IRRELEVANT to your output language.`,- `Ignore the language of the wiki content. Write in ${outLang} only.`,- `Even proper nouns should use standard ${outLang} transliteration when appropriate.`,- `DO NOT use any other language. This overrides all other instructions.`,+ buildLanguageDirective(text),].filter(Boolean).join("\n"),})diff --git a/src/lib/ingest.prompt.test.ts b/src/lib/ingest.prompt.test.tsindex ab88ddc6..88d0351a 100644--- a/src/lib/ingest.prompt.test.ts+++ b/src/lib/ingest.prompt.test.ts@@ -80,6 +80,19 @@ describe("buildGenerationPrompt language directive", () => {expect(prompt).toContain("keep readable CJK characters in the filename")})+ it("preserves technical proper nouns instead of translating them into the output language", () => {+ useWikiStore.getState().setOutputLanguage("Chinese")+ const prompt = buildGenerationPrompt("", "", "", "source.pdf")++ expect(prompt).toContain("proper nouns and technical identifiers take precedence")+ expect(prompt).toContain("GPT-5")+ expect(prompt).toContain("Transformer")+ expect(prompt).toContain("standard original form")+ expect(prompt).toContain("Do not put raw URLs, citation strings, or full paper titles directly into file paths")+ expect(prompt).toContain("technical terms with no widely-used localized equivalent")+ expect(prompt).not.toContain("No exceptions — not even for page names")+ })+it("makes project schema routing authoritative over default entity and concept folders", () => {const prompt = buildGenerationPrompt("Use wiki/people/ for people. Use wiki/technologies/ for technical methods.",diff --git a/src/lib/ingest.ts b/src/lib/ingest.tsindex 4d704bc9..bb4c84df 100644--- a/src/lib/ingest.ts+++ b/src/lib/ingest.ts@@ -1841,7 +1841,7 @@ export function buildGenerationPrompt("- Use [[wikilink]] syntax in the BODY for cross-references between pages","- If you include images, use wiki-root-relative paths such as `media/source-slug/image.png`; never output absolute filesystem paths.","- Use kebab-case filenames",- "- Derive filenames from the page title in the mandatory output language. For Chinese/Japanese/Korean titles, keep readable CJK characters in the filename instead of translating the slug to English.",+ "- Derive filenames from the page title in the mandatory output language, but short proper nouns and technical identifiers take precedence: preserve names such as OpenAI, GPT-5, Transformer, CLIP, ImageNet, PyTorch, CUDA, GitHub, arXiv, React, LanceDB, AnyTXT, MinerU, model names, dataset names, tool names, and code identifiers in their standard original form. Do not put raw URLs, citation strings, or full paper titles directly into file paths; convert surrounding descriptive prose to a safe readable title. For Chinese/Japanese/Korean prose titles, keep readable CJK characters in the filename instead of translating the slug to English.","- Follow the analysis recommendations on what to emphasize","- If the analysis found connections to existing pages, add cross-references","",@@ -1904,7 +1904,7 @@ export function buildGenerationPrompt("4. DO NOT output markdown tables, bullet lists, or headings outside of FILE/REVIEW blocks.","5. DO NOT output any trailing commentary after the last `---END FILE---` or `---END REVIEW---`.","6. Between blocks, use only blank lines — no prose.",- "7. EVERY FILE block's content (titles, body, descriptions) MUST be in the mandatory output language specified below. No exceptions — not even for page names or section headings.",+ "7. FILE block prose (body, explanations, descriptions, section text) must use the mandatory output language specified below. Preserve proper nouns, acronyms, model names, dataset names, tool/library names, code identifiers, URLs, file names, citation strings, paper titles, and technical terms with no widely-used localized equivalent in their standard original form, including in page names and section headings.","","If you start with anything other than `---FILE:`, the entire response will be discarded.","",diff --git a/src/lib/output-language.test.ts b/src/lib/output-language.test.tsindex 51081d8b..79bd051b 100644--- a/src/lib/output-language.test.ts+++ b/src/lib/output-language.test.ts@@ -47,12 +47,20 @@ describe("buildLanguageDirective", () => {expect(directive).toContain("MANDATORY OUTPUT LANGUAGE: Chinese")})- it("names the language multiple times for emphasis", () => {+ it("keeps the target prose language prominent without requiring proper noun translation", () => {useWikiStore.getState().setOutputLanguage("Japanese")const directive = buildLanguageDirective()- // Should include 'Japanese' at least 4× (header + instructions)const count = (directive.match(/Japanese/g) || []).length- expect(count).toBeGreaterThanOrEqual(4)+ expect(count).toBeGreaterThanOrEqual(3)+ expect(directive).toContain("Write surrounding natural-language prose")+ expect(directive).toContain("prose titles and section headings")+ expect(directive).toContain("Preserve organization names")+ expect(directive).toContain("model names")+ expect(directive).toContain("paper titles")+ expect(directive).toContain("technical terms that have no widely-used localized equivalent")+ expect(directive).toContain("does not override the proper-noun and technical-identifier preservation rule")+ expect(directive).not.toMatch(/transliteration when appropriate/i)+ expect(directive).not.toContain("overrides all other instructions")})it("follows the explicit setting even when fallback text is in another language", () => {@@ -74,10 +82,11 @@ describe("buildLanguageDirective", () => {expect(directive).toContain("MANDATORY OUTPUT LANGUAGE: Persian (Farsi / فارسی)")})- it("explicitly overrides source content language", () => {+ it("uses the source as evidence without translating proper nouns", () => {useWikiStore.getState().setOutputLanguage("English")const directive = buildLanguageDirective()- expect(directive).toContain("IRRELEVANT to your output language")+ expect(directive).toContain("use it as evidence")+ expect(directive).toContain("proper nouns and technical identifiers")})})@@ -85,7 +94,9 @@ describe("buildLanguageReminder", () => {it("is a concise reminder, not a full directive", () => {useWikiStore.getState().setOutputLanguage("Chinese")const reminder = buildLanguageReminder()- expect(reminder).toMatch(/All output must be in Chinese/)+ expect(reminder).toMatch(/Write prose in Chinese/)+ expect(reminder).toContain("preserve names")+ expect(reminder).not.toContain("Do not use any other language")// Reminder should be ONE line, not a multi-line blockexpect(reminder.split("\n").length).toBe(1)})diff --git a/src/lib/output-language.ts b/src/lib/output-language.tsindex b2ee6c3d..588d4328 100644--- a/src/lib/output-language.ts+++ b/src/lib/output-language.ts@@ -25,11 +25,12 @@ export function buildLanguageDirective(fallbackText: string = ""): string {return [`## ⚠️ MANDATORY OUTPUT LANGUAGE: ${promptLang}`,"",- `You MUST write your entire response (including wiki page titles, content, descriptions, summaries, and any generated text) in **${promptLang}**.`,- `The source material or wiki content may be in a different language, but this is IRRELEVANT to your output language.`,- `Ignore the language of any source content. Generate everything in ${promptLang} only.`,- `Proper nouns should use standard ${promptLang} transliteration when appropriate.`,- `DO NOT use any other language. This overrides all other instructions.`,+ `Write surrounding natural-language prose in **${promptLang}**.`,+ `All generated prose, including prose titles and section headings, must be in ${promptLang}.`,+ `Do not translate, transliterate, or describe proper nouns and technical identifiers unless the source already uses a well-established localized form.`,+ `Preserve organization names, product names, model names, dataset names, tool/library names, acronyms, code identifiers, file names, URLs, paper titles, citation strings, and technical terms that have no widely-used localized equivalent in their standard original form.`,+ `The source material or wiki content may be in a different language; use it as evidence, but keep generated prose in ${promptLang}.`,+ `This language rule overrides weaker style instructions, but it does not override the proper-noun and technical-identifier preservation rule above.`,].join("\n")}@@ -38,5 +39,5 @@ export function buildLanguageDirective(fallbackText: string = ""): string {*/export function buildLanguageReminder(fallbackText: string = ""): string {const lang = getOutputLanguage(fallbackText)- return `REMINDER: All output must be in ${getLanguagePromptName(lang)}. Do not use any other language.`+ return `REMINDER: Write prose in ${getLanguagePromptName(lang)}; preserve names, acronyms, identifiers, URLs, file names, and paper titles in their standard original form.`}