Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
refactor: Update wiki link syntax and rendering in WikiBrowser component
wizardchen5d5073c96bc9
diff --git a/frontend/src/views/knowledge/wiki/WikiBrowser.vue b/frontend/src/views/knowledge/wiki/WikiBrowser.vueindex 8d57ddc1b..ce15cea32 100644--- a/frontend/src/views/knowledge/wiki/WikiBrowser.vue+++ b/frontend/src/views/knowledge/wiki/WikiBrowser.vue@@ -288,8 +288,12 @@ const graphDrawerContent = computed(() => {function renderMarkdown(content: string): string {let html = content- html = html.replace(/\[\[([^\]]+)\]\]/g, (_, slug) =>- `<a href="#" class="wiki-content-link" data-slug="${slug}">[[${slug}]]</a>`)+ html = html.replace(/\[\[([^\]]+)\]\]/g, (_, inner: string) => {+ const pipeIdx = inner.indexOf('|')+ const slug = pipeIdx > 0 ? inner.substring(0, pipeIdx).trim() : inner.trim()+ const display = pipeIdx > 0 ? inner.substring(pipeIdx + 1).trim() : slugDisplayName(slug)+ return `<a href="#" class="wiki-content-link" data-slug="${slug}">${display}</a>`+ })html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>')html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>')html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>')@@ -1290,13 +1294,9 @@ onMounted(() => {:deep(.wiki-content-link) {color: var(--td-brand-color);text-decoration: none;- font-family: monospace;- font-size: 13px;- padding: 1px 4px;- background: rgba(7, 192, 95, 0.06);- border-radius: 3px;+ border-bottom: 1px dashed var(--td-brand-color);cursor: pointer;- &:hover { background: rgba(7, 192, 95, 0.12); }+ &:hover { border-bottom-style: solid; }}}diff --git a/internal/agent/prompts_wiki.go b/internal/agent/prompts_wiki.goindex 080910ca6..f42d30672 100644--- a/internal/agent/prompts_wiki.go+++ b/internal/agent/prompts_wiki.go@@ -25,7 +25,7 @@ const WikiSummaryPrompt = `You are a wiki editor. Given the following document c2. After the SUMMARY line, write a comprehensive summary of the document in Markdown format.3. Include the key facts, arguments, and conclusions.4. Use proper heading hierarchy (## for sections, ### for subsections).-5. **Wiki-link rule**: The available_wiki_pages list above maps slugs to display names (e.g. "[[entity/zhong-guo]] = 中国"). Whenever you mention a name that matches a listed entry, you MUST write it as [[slug]] (e.g. [[entity/zhong-guo]]), NOT as bold (**name**) or plain text. Use the EXACT slugs provided — do NOT invent new slugs.+5. **Wiki-link rule**: The available_wiki_pages list above maps slugs to display names (format: "[[slug]] = display name"). Whenever you mention a name that matches a listed entry, you MUST write it as [[slug|display name]] (e.g. [[entity/zhong-guo|中国]]), NOT as bold (**name**) or bare [[slug]]. Use the EXACT slugs provided — do NOT invent new slugs.6. At the end, include a "## Key Takeaways" section with bullet points.7. Write in {{.Language}}.8. Keep the summary concise but thorough (500-1500 words depending on document length).@@ -124,7 +124,7 @@ const WikiPageUpdatePrompt = `You are a wiki editor tasked with updating an exis3. Preserve all existing information that is still valid.4. If the new information contradicts existing content, prefer the newer information and silently replace the old claim.5. Add new facts, details, and context from the new document.-6. Preserve any existing [[wiki-link]] references in the content. Do NOT invent new wiki-link slugs.+6. Preserve any existing [[slug|name]] wiki-link references in the content. Do NOT invent new wiki-link slugs.7. Maintain the existing page structure and formatting style.8. Add a source reference to the new document at the bottom.9. Write in {{.Language}}.@@ -161,7 +161,7 @@ const WikiPageRetractPrompt = `You are a wiki editor. A source document has been4. If a fact is also supported by the remaining source documents, KEEP it.5. If you are unsure whether a fact came from the deleted document, keep it as-is — do NOT add any review notes or annotations.6. Update or remove the "Source: {{.DeletedDocTitle}}" reference line if present.-7. Keep [[wiki-link]] references ONLY if the slug appears in the <valid_wiki_links> list above. Remove any [[wiki-link]] whose slug is NOT in that list.+7. Keep [[slug|name]] wiki-link references ONLY if the slug appears in the <valid_wiki_links> list above. Remove any [[slug|name]] whose slug is NOT in that list.8. Maintain the existing page structure, formatting style, and language.9. If after removing the deleted document's contributions the page becomes nearly empty, output just: "SUMMARY: (empty page)\n# [Title]\n\n*This page's primary source document was removed.*"10. Write in {{.Language}}.@@ -247,7 +247,7 @@ Use wiki_write_page to persist valuable knowledge artifacts. Write a page when:#### Page Content Guidelines- Write in Markdown with proper heading hierarchy-- Use [[entity/slug]] and [[concept/slug]] syntax to link to other wiki pages+- Use [[slug|display name]] syntax to link to other wiki pages (e.g. [[entity/acme-corp|Acme Corp]])- Include a one-line summary in the first paragraph (used for index listings)- Cite source documents when possible- Keep pages focused: one topic/entity/concept per pagediff --git a/internal/application/service/wiki_ingest.go b/internal/application/service/wiki_ingest.goindex 4c62ee1b3..8e8f6cab1 100644--- a/internal/application/service/wiki_ingest.go+++ b/internal/application/service/wiki_ingest.go@@ -746,19 +746,15 @@ func (s *wikiIngestService) injectCrossLinks(ctx context.Context, kbID string, achanged := falsefor _, ref := range allRefs {- // Don't self-linkif ref.slug == p.Slug {continue}- // Skip if already linked with this slug- if strings.Contains(content, "[["+ref.slug+"]]") {+ // Skip if already linked with this slug (either [[slug]] or [[slug|...]])+ if strings.Contains(content, "[["+ref.slug+"|") || strings.Contains(content, "[["+ref.slug+"]]") {continue}- // Replace title mentions with [[slug]] link- // Only replace if the title appears as a standalone term (not inside an existing link)if strings.Contains(content, ref.title) {- // Replace first occurrence only (avoid over-linking)- content = replaceFirstOutsideLinks(content, ref.title, ref.title+" [["+ref.slug+"]]")+ content = replaceFirstOutsideLinks(content, ref.title, "[["+ref.slug+"|"+ref.title+"]]")changed = true}}diff --git a/internal/application/service/wiki_page.go b/internal/application/service/wiki_page.goindex 1816b2a53..3edf11068 100644--- a/internal/application/service/wiki_page.go+++ b/internal/application/service/wiki_page.go@@ -352,9 +352,9 @@ func (s *wikiPageService) parseOutLinks(content string) types.StringArray {for _, match := range matches {if len(match) > 1 {slug := strings.TrimSpace(match[1])- // Handle [[Title|slug]] format+ // Handle [[slug|display name]] format — slug is the first partif parts := strings.SplitN(slug, "|", 2); len(parts) == 2 {- slug = strings.TrimSpace(parts[1])+ slug = strings.TrimSpace(parts[0])}slug = normalizeSlug(slug)if slug != "" && !seen[slug] {diff --git a/internal/application/service/wiki_page_test.go b/internal/application/service/wiki_page_test.goindex b79509c35..3ba03366a 100644--- a/internal/application/service/wiki_page_test.go+++ b/internal/application/service/wiki_page_test.go@@ -30,10 +30,15 @@ func TestParseOutLinks(t *testing.T) {want: []string{"entity/acme-corp"},},{- name: "pipe syntax: title|slug",- content: "See [[Acme Corp|entity/acme-corp]] for details.",+ name: "pipe syntax: slug|display name",+ content: "See [[entity/acme-corp|Acme Corp]] for details.",want: []string{"entity/acme-corp"},},+ {+ name: "mixed: pipe and bare links",+ content: "See [[entity/acme-corp|Acme Corp]] and [[concept/rag]] here.",+ want: []string{"entity/acme-corp", "concept/rag"},+ },{name: "no links",content: "Just plain text without any links.",