Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

add Copy Markdown button and llms.txt support (#1688)

yufeng18e82eebf461
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index 872bd61ec..298981511 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -108,6 +108,90 @@ const zhNav: DefaultTheme.NavItem[] = [
{ text: navLabels.zh.changelog, link: '/zh/about/02-changelog', activeMatch: '/zh/about/' }
]
+function collectAllMdFiles(srcDir: string): { relativePath: string; absPath: string }[] {
+ const results: { relativePath: string; absPath: string }[] = []
+ const ignored = new Set(['node_modules', '.vitepress'])
+
+ function walk(dir: string) {
+ for (const entry of fs.readdirSync(dir)) {
+ if (ignored.has(entry)) continue
+ const abs = path.join(dir, entry)
+ const stat = fs.statSync(abs)
+ if (stat.isDirectory()) {
+ walk(abs)
+ } else if (entry.endsWith('.md') && entry !== 'index.md') {
+ results.push({ relativePath: path.relative(srcDir, abs), absPath: abs })
+ }
+ }
+ }
+
+ walk(srcDir)
+ return results.sort((a, b) => a.relativePath.localeCompare(b.relativePath))
+}
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+function buildLlmsTxt(siteConfig: any) {
+ const siteUrl = process.env.DOCS_SITE_URL || 'https://volcengine.github.io/OpenViking'
+ const base = (siteConfig.site.base || '/').replace(/\/$/, '')
+ const srcDir = siteConfig.srcDir
+ const outDir = siteConfig.outDir
+
+ const files = collectAllMdFiles(srcDir)
+
+ // Group by section prefix (e.g. en/getting-started, zh/concepts)
+ const sections = new Map<string, { title: string; url: string }[]>()
+ for (const { relativePath, absPath } of files) {
+ const parts = relativePath.replace(/\\/g, '/').split('/')
+ const section = parts.length >= 2 ? parts.slice(0, -1).join('/') : 'misc'
+ const content = fs.readFileSync(absPath, 'utf-8')
+ const heading = content.match(/^#\s+(.+)$/m)?.[1]?.trim() ?? path.basename(absPath, '.md')
+ const urlPath = `/${relativePath.replace(/\\/g, '/').replace(/\.md$/, '')}`
+ const url = `${siteUrl}${base}${urlPath}`
+ if (!sections.has(section)) sections.set(section, [])
+ sections.get(section)!.push({ title: heading, url })
+ }
+
+ const lines: string[] = [
+ '# OpenViking',
+ '',
+ '> Open-source context database for AI Agents. OpenViking unifies memory, resources, and skills management for AI Agents through a file system paradigm.',
+ '',
+ `- Source: https://github.com/${process.env.GITHUB_REPOSITORY || 'volcengine/OpenViking'}`,
+ '',
+ ]
+
+ for (const [section, pages] of sections) {
+ lines.push(`## ${section}`, '')
+ for (const { title, url } of pages) {
+ lines.push(`- [${title}](${url})`)
+ }
+ lines.push('')
+ }
+
+ fs.writeFileSync(path.join(outDir, 'llms.txt'), lines.join('\n'), 'utf-8')
+
+ // llms-full.txt: all content concatenated
+ const fullLines: string[] = [
+ '# OpenViking — Full Documentation',
+ '',
+ '> This file contains the complete documentation for LLM consumption.',
+ '',
+ ]
+ for (const { relativePath, absPath } of files) {
+ const content = fs.readFileSync(absPath, 'utf-8')
+ fullLines.push(`\n\n---\n<!-- source: ${relativePath} -->\n\n${content}`)
+ }
+ fs.writeFileSync(path.join(outDir, 'llms-full.txt'), fullLines.join('\n'), 'utf-8')
+
+ // Per-page llms.txt: /{page-path}/llms.txt returns the raw markdown of that page
+ for (const { relativePath, absPath } of files) {
+ const content = fs.readFileSync(absPath, 'utf-8')
+ const pageDir = path.join(outDir, relativePath.replace(/\.md$/, ''))
+ fs.mkdirSync(pageDir, { recursive: true })
+ fs.writeFileSync(path.join(pageDir, 'llms.txt'), content, 'utf-8')
+ }
+}
+
export default defineConfig({
base,
title: 'OpenViking',
@@ -120,8 +204,37 @@ export default defineConfig({
head: [
['link', { rel: 'icon', href: `${base}ov-logo.png` }]
],
+ transformPageData(pageData, { siteConfig }) {
+ const srcPath = path.join(siteConfig.srcDir, pageData.relativePath)
+ try {
+ pageData.frontmatter._rawMarkdown = fs.readFileSync(srcPath, 'utf-8')
+ } catch {
+ pageData.frontmatter._rawMarkdown = ''
+ }
+ },
+ buildEnd(siteConfig) {
+ buildLlmsTxt(siteConfig)
+ },
vite: {
- publicDir: 'images'
+ publicDir: 'images',
+ plugins: [
+ {
+ name: 'llms-txt-dev',
+ configureServer(server) {
+ server.middlewares.use((req, res, next) => {
+ if (!req.url?.endsWith('/llms.txt')) return next()
+ const stripped = req.url.replace(/\/llms\.txt$/, '')
+ const candidate = stripped ? path.join(docsRoot, stripped + '.md') : null
+ if (candidate && fs.existsSync(candidate)) {
+ res.setHeader('Content-Type', 'text/plain; charset=utf-8')
+ res.end(fs.readFileSync(candidate, 'utf-8'))
+ } else {
+ next()
+ }
+ })
+ }
+ }
+ ]
},
themeConfig: {
logo: '/ov-logo.png',
diff --git a/docs/.vitepress/theme/CopyMarkdownButton.vue b/docs/.vitepress/theme/CopyMarkdownButton.vue
new file mode 100644
index 000000000..d8b37faad
--- /dev/null
+++ b/docs/.vitepress/theme/CopyMarkdownButton.vue
@@ -0,0 +1,229 @@
+<script setup lang="ts">
+import { useData, withBase } from 'vitepress'
+import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
+
+const { frontmatter, page } = useData()
+
+const copied = ref(false)
+const open = ref(false)
+const wrapRef = ref<HTMLElement | null>(null)
+
+// Build absolute llms.txt URL for this page (browser-only)
+const llmsTxtUrl = computed(() => {
+ if (typeof window === 'undefined') return ''
+ const pagePath = page.value.relativePath.replace(/\.md$/, '')
+ return `${window.location.origin}${withBase(`/${pagePath}/llms.txt`)}`
+})
+
+const items = computed(() => {
+ const q = encodeURIComponent(`Read ${llmsTxtUrl.value}, I want to ask questions about it.`)
+ return [
+ {
+ label: 'Open in ChatGPT',
+ href: `https://chatgpt.com/?hints=search&q=${q}`,
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M22.28 9.28a5.76 5.76 0 0 0-.496-4.727 5.83 5.83 0 0 0-6.275-2.8A5.826 5.826 0 0 0 11.12 0a5.83 5.83 0 0 0-5.563 4.038 5.826 5.826 0 0 0-3.9 2.83 5.83 5.83 0 0 0 .717 6.834 5.76 5.76 0 0 0 .496 4.727 5.83 5.83 0 0 0 6.274 2.8A5.826 5.826 0 0 0 12.88 24a5.83 5.83 0 0 0 5.564-4.038 5.826 5.826 0 0 0 3.9-2.83 5.83 5.83 0 0 0-.717-6.834l-.347.152zm-9.4 13.173a4.32 4.32 0 0 1-2.774-1.006l.137-.078 4.608-2.66a.76.76 0 0 0 .383-.662v-6.497l1.948 1.124a.072.072 0 0 1 .038.054v5.38a4.334 4.334 0 0 1-4.34 4.345zm-9.327-3.984a4.32 4.32 0 0 1-.517-2.912l.137.082 4.609 2.661a.76.76 0 0 0 .765 0l5.628-3.25v2.249a.072.072 0 0 1-.029.06L9.4 19.897a4.334 4.334 0 0 1-5.847-1.43zm-1.214-10.05a4.32 4.32 0 0 1 2.256-1.903v5.47a.76.76 0 0 0 .384.661l5.628 3.25-1.948 1.124a.072.072 0 0 1-.068.006L4.09 14.54a4.334 4.334 0 0 1-1.751-6.121zm16.018 3.724-5.628-3.25 1.948-1.123a.072.072 0 0 1 .068-.007l4.515 2.607a4.334 4.334 0 0 1-.672 7.818v-5.47a.76.76 0 0 0-.231-.575zm1.938-2.924-.137-.083-4.608-2.66a.76.76 0 0 0-.766 0L9.156 9.73V7.482a.072.072 0 0 1 .029-.06l4.515-2.607a4.334 4.334 0 0 1 6.613 4.49zm-12.184 4.01-1.948-1.124a.072.072 0 0 1-.038-.054V6.693a4.334 4.334 0 0 1 7.106-3.328l-.137.078-4.608 2.661a.76.76 0 0 0-.383.661v.001zm1.058-2.283 2.505-1.446 2.505 1.446v2.889l-2.505 1.447-2.505-1.447z"/></svg>`
+ },
+ {
+ label: 'Open in Claude',
+ href: `https://claude.ai/new?q=${q}`,
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.031-2.339-.047-1.089-.04-.703-.087-.128-.048.065-.176.128-.128 1.49-.518 3.294-1.04 3.295-1.04.87-.295-.016-.12-.136-.073-2.657-.37-2.63-.406-1.842-.287-.872-.16-.528-.127-.448-.256-.096-.335.016-.176.103-.16.24-.128.336-.048.415.016 1.055.128 2.155.255 3.12.4 3.121.4.504.064.047-.127-.287-.368-1.449-2.02-1.21-1.73-.62-.894-.447-.687-.128-.256-.064-.336.064-.239.207-.12.304-.065.384.065.415.224.814.654 1.73 1.4 1.714 1.384.623.495.16-.048.048-.144.016-2.837.015-1.457.065-1.039.16-.737.23-.639.383-.415.384-.128.4.064.351.224.24.4.112.606v.7l-.112 1.01-.128 1.217-.144 2.035-.016.32.144.064 1.09-.735 1.97-1.297 1.75-1.12.894-.527.719-.383.655-.16.543.064.463.303.24.496.016.51-.16.43-.384.4-.783.543-1.34.926-1.004.703-.655.48.016.096.08.063 2.403-.16 1.426-.015 1.04.063 1.137.24.719.383.383.48.16.623-.127.575-.384.464-.64.32-.815.144h-.384l-.4-.016-1.009-.127-2.307-.384-1.972-.32-.415-.048-.064.063.208.32 1.25 1.924.927 1.49.399.735.095.655-.127.559-.383.4-.48.143-.624-.016-.607-.24-.622-.511-1.562-1.67-1.307-1.42-.432-.512-.16.016-.112.159-.016.384.064 2.006.08 1.955.016.9.016.56-.16.654-.32.527-.512.304-.608.048-.512-.16-.432-.367-.32-.608-.192-.847-.16-1.36-.048-1.782-.016-1.115v-.44l-.016-.064-.112-.016-.256.08-1.99.647-2.16.687-.944.287-.687.128-.624-.032-.463-.191-.288-.4-.08-.432.031-.367.208-.32.384-.272.576-.192.768-.16 2.032-.48.127-.064z"/></svg>`
+ },
+ ]
+})
+
+async function copyToClipboard() {
+ const md: string = frontmatter.value._rawMarkdown ?? ''
+ if (!md) return
+ await navigator.clipboard.writeText(md)
+ copied.value = true
+ setTimeout(() => { copied.value = false }, 2000)
+}
+
+async function handleCopy() {
+ await copyToClipboard()
+ open.value = false
+}
+
+function handleItem(href: string) {
+ window.open(href, '_blank', 'noopener')
+ open.value = false
+}
+
+function onOutsideClick(e: MouseEvent) {
+ if (wrapRef.value && !wrapRef.value.contains(e.target as Node)) {
+ open.value = false
+ }
+}
+
+onMounted(() => document.addEventListener('click', onOutsideClick))
+onBeforeUnmount(() => document.removeEventListener('click', onOutsideClick))
+
+const isDoc = computed(() => page.value.relativePath !== 'index.md')
+</script>
+
+<template>
+ <div v-if="isDoc" ref="wrapRef" class="copy-md-wrap">
+ <div class="copy-md-group" :class="{ open }">
+ <button class="copy-md-main" :class="{ copied }" @click="handleCopy">
+ <span class="copy-md-icon">
+ <svg v-if="!copied" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
+ </svg>
+ <svg v-else xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="20 6 9 17 4 12"/>
+ </svg>
+ </span>
+ {{ copied ? 'Copied!' : 'Copy markdown' }}
+ </button>
+ <button class="copy-md-chevron" :class="{ open }" @click.stop="open = !open" aria-label="More options">
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
+ <polyline v-if="open" points="18 15 12 9 6 15"/>
+ <polyline v-else points="6 9 12 15 18 9"/>
+ </svg>
+ </button>
+ </div>
+
+ <Transition name="dropdown">
+ <div v-if="open" class="copy-md-dropdown">
+ <button
+ v-for="item in items"
+ :key="item.label"
+ class="copy-md-dropdown-item"
+ @click="handleItem(item.href)"
+ >
+ <span class="copy-md-dropdown-icon" v-html="item.icon" />
+ <span>{{ item.label }}</span>
+ <svg class="copy-md-ext" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
+ <polyline points="15 3 21 3 21 9"/>
+ <line x1="10" y1="14" x2="21" y2="3"/>
+ </svg>
+ </button>
+ </div>
+ </Transition>
+ </div>
+</template>
+
+<style scoped>
+.copy-md-wrap {
+ display: flex;
+ justify-content: flex-end;
+ margin-bottom: 16px;
+ position: relative;
+}
+
+.copy-md-group {
+ display: inline-flex;
+ align-items: stretch;
+ border: 1px solid var(--vp-c-divider);
+ border-radius: 8px;
+ overflow: visible;
+ background: var(--vp-c-bg-soft);
+ transition: border-color 0.2s;
+}
+
+.copy-md-group:hover,
+.copy-md-group.open {
+ border-color: var(--vp-c-brand-1);
+}
+
+.copy-md-main {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 12px;
+ background: transparent;
+ border: none;
+ border-right: 1px solid var(--vp-c-divider);
+ color: var(--vp-c-text-2);
+ font-size: 13px;
+ font-family: var(--vp-font-family-base);
+ cursor: pointer;
+ transition: color 0.2s;
+ white-space: nowrap;
+}
+
+.copy-md-main:hover,
+.copy-md-main.copied {
+ color: var(--vp-c-brand-1);
+}
+
+.copy-md-icon {
+ display: flex;
+ align-items: center;
+}
+
+.copy-md-chevron {
+ display: inline-flex;
+ align-items: center;
+ padding: 6px 8px;
+ background: transparent;
+ border: none;
+ color: var(--vp-c-text-2);
+ cursor: pointer;
+ transition: color 0.2s;
+}
+
+.copy-md-chevron:hover {
+ color: var(--vp-c-brand-1);
+}
+
+.copy-md-dropdown {
+ position: absolute;
+ top: calc(100% + 6px);
+ right: 0;
+ min-width: 190px;
+ background: var(--vp-c-bg-elv);
+ border: 1px solid var(--vp-c-divider);
+ border-radius: 10px;
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
+ z-index: 100;
+ padding: 4px;
+}
+
+.copy-md-dropdown-item {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ width: 100%;
+ padding: 8px 12px;
+ background: transparent;
+ border: none;
+ border-radius: 7px;
+ color: var(--vp-c-text-1);
+ font-size: 13px;
+ font-family: var(--vp-font-family-base);
+ cursor: pointer;
+ text-align: left;
+ transition: background 0.15s;
+}
+
+.copy-md-dropdown-item:hover {
+ background: var(--vp-c-bg-soft);
+}
+
+.copy-md-dropdown-icon {
+ display: flex;
+ align-items: center;
+ color: var(--vp-c-text-2);
+ flex-shrink: 0;
+}
+
+.copy-md-ext {
+ margin-left: auto;
+ color: var(--vp-c-text-3, var(--vp-c-text-2));
+ opacity: 0.5;
+ flex-shrink: 0;
+}
+
+.dropdown-enter-active,
+.dropdown-leave-active {
+ transition: opacity 0.15s, transform 0.15s;
+}
+.dropdown-enter-from,
+.dropdown-leave-to {
+ opacity: 0;
+ transform: translateY(-4px);
+}
+</style>
diff --git a/docs/.vitepress/theme/LlmsTxtLink.vue b/docs/.vitepress/theme/LlmsTxtLink.vue
new file mode 100644
index 000000000..79b8fbe8c
--- /dev/null
+++ b/docs/.vitepress/theme/LlmsTxtLink.vue
@@ -0,0 +1,46 @@
+<script setup lang="ts">
+import { useData, withBase } from 'vitepress'
+import { computed } from 'vue'
+
+const { page } = useData()
+
+const llmsUrl = computed(() => {
+ const pagePath = page.value.relativePath.replace(/\.md$/, '')
+ return withBase(`/${pagePath}/llms.txt`)
+})
+
+const isDoc = computed(() => page.value.relativePath !== 'index.md')
+</script>
+
+<template>
+ <div v-if="isDoc" class="llms-link-wrap">
+ <a :href="llmsUrl" target="_blank" rel="noopener" class="llms-link">
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/>
+ <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/>
+ </svg>
+ llms.txt
+ </a>
+ </div>
+</template>
+
+<style scoped>
+.llms-link-wrap {
+ display: inline-flex;
+ margin-bottom: 8px;
+}
+
+.llms-link {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ color: var(--vp-c-text-2);
+ font-size: 13px;
+ text-decoration: none;
+ transition: color 0.2s;
+}
+
+.llms-link:hover {
+ color: var(--vp-c-brand-1);
+}
+</style>
diff --git a/docs/.vitepress/theme/custom.css b/docs/.vitepress/theme/custom.css
index ba31c4b08..2c3162c36 100644
--- a/docs/.vitepress/theme/custom.css
+++ b/docs/.vitepress/theme/custom.css
@@ -18,10 +18,10 @@
--vp-c-brand-2: #2dd4bf;
--vp-c-brand-3: #0f766e;
--vp-c-brand-soft: rgba(45, 212, 191, 0.18);
- --vp-c-bg: #101816;
- --vp-c-bg-alt: #0b1210;
- --vp-c-bg-elv: #16211e;
- --vp-c-bg-soft: #182622;
+ --vp-c-bg: #0f0f0f;
+ --vp-c-bg-alt: #080808;
+ --vp-c-bg-elv: #1a1a1a;
+ --vp-c-bg-soft: #1e1e1e;
--vp-c-text-1: #edf7f3;
--vp-c-text-2: #bbcac5;
}
diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts
index 42fe9a936..218f64445 100644
--- a/docs/.vitepress/theme/index.ts
+++ b/docs/.vitepress/theme/index.ts
@@ -1,4 +1,15 @@
+import { h } from 'vue'
import DefaultTheme from 'vitepress/theme'
+import CopyMarkdownButton from './CopyMarkdownButton.vue'
+import LlmsTxtLink from './LlmsTxtLink.vue'
import './custom.css'
-export default DefaultTheme
+export default {
+ extends: DefaultTheme,
+ Layout() {
+ return h(DefaultTheme.Layout, null, {
+ 'doc-before': () => h(CopyMarkdownButton),
+ 'doc-footer-before': () => h(LlmsTxtLink)
+ })
+ }
+}