Files
ai_academy/website-docs/.vitepress/config.mts
T
runny 9058149576
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
refactor: 项目更名 WeKnora → Academy
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
2026-11-13 20:52:51 +08:00

222 lines
7.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { readFileSync, readdirSync } from 'node:fs'
import { createRequire } from 'node:module'
import { resolve } from 'node:path'
import { defineConfig, type DefaultTheme } from 'vitepress'
import { withMermaid } from 'vitepress-plugin-mermaid'
import './theme-config.d.ts'
import { repoVersionLabel } from './version'
import { readScreenshotSizes } from './screenshot-sizes.mjs'
const root = resolve(import.meta.dirname, '..')
const require = createRequire(import.meta.url)
/** 当前安装能解析到该模块时返回 true。缺失的包不能写进 optimizeDeps.include。 */
function installedDep(id: string): boolean {
try {
require.resolve(id)
return true
} catch {
return false
}
}
const sections: { dir: string; label: string; newestFirst?: boolean }[] = [
{ dir: '01-getting-started', label: '快速开始' },
{ dir: '02-architecture', label: '架构' },
{ dir: '03-features', label: '功能模块' },
{ dir: '04-api', label: 'API 参考' },
{ dir: '05-clients', label: '客户端' },
{ dir: '06-development', label: '开发指南' },
// 每个版本一页(v0.8.2.md),最新版本排在最前
{ dir: '07-releases', label: '版本发布', newestFirst: true },
]
/** 侧边栏条目文字:取正文一级标题,去掉冗余前后缀 */
function itemText(dir: string, file: string): string {
const raw = readFileSync(resolve(root, dir, file), 'utf-8')
const heading = raw.match(/^#\s+(.+)$/m)?.[1] ?? file.replace(/\.md$/, '')
return heading
.replace(/^API 参考[::]\s*/, '')
.replace(/\s*[((][^(())]*[))]\s*/g, ' ')
.replace(/\s{2,}/g, ' ')
.trim()
}
/** 版本号按数字比较,v0.10.0 排在 v0.9.0 之后 */
function compareVersions(a: string, b: string): number {
const parts = (f: string) => f.replace(/^v|\.md$/g, '').split('.').map(Number)
const [x, y] = [parts(a), parts(b)]
for (let i = 0; i < Math.max(x.length, y.length); i++) {
if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) - (y[i] ?? 0)
}
return 0
}
function itemsOf(dir: string, newestFirst = false): DefaultTheme.SidebarItem[] {
const files = readdirSync(resolve(root, dir)).filter((f) => f.endsWith('.md'))
return (newestFirst ? files.sort(compareVersions).reverse() : files.sort())
.map((f) => ({
text: itemText(dir, f),
link: `/${dir}/${f.replace(/\.md$/, '')}`,
}))
}
const sidebar: DefaultTheme.SidebarItem[] = sections.map((s) => ({
text: s.label,
collapsed: false,
items: itemsOf(s.dir, s.newestFirst),
}))
/** 本地搜索默认按空白分词,中文整段会被当作一个词,这里退化为字粒度切分 */
function tokenize(text: string): string[] {
const tokens: string[] = []
for (const part of text.split(/[\s\n\r#%*,=/:;?[\]{}()&+\-!'"$·、,。:;?!()【】《》…—]+/)) {
if (!part) continue
if (/[\u4e00-\u9fa5]/.test(part)) {
tokens.push(part, ...part.split(''))
} else {
tokens.push(part)
}
}
return tokens
}
const repo = 'https://github.com/Tencent/WeKnora'
export default withMermaid(
defineConfig({
title: 'Academy',
titleTemplate: ':title · Academy 文档',
description: 'Academy(维娜拉)官方文档:部署、配置、功能说明、API 参考与二次开发',
lang: 'zh-CN',
base: '/docs/',
cleanUrls: true,
appearance: { storageKey: 'vitepress-theme-appearance' },
lastUpdated: true,
srcExclude: ['README.md', 'MIGRATION.md', 'homepage/**', 'shared/**', 'scripts/**', 'deploy/**', 'static-site/**', 'releases/**'],
metaChunk: true,
transformPageData(pageData) {
// The shared masthead replaces the default documentation navbar.
pageData.frontmatter.navbar = false
},
head: [
['link', { rel: 'icon', href: '/docs/favicon.ico', type: 'image/x-icon' }],
['meta', { name: 'theme-color', content: '#101f38' }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:title', content: 'Academy 文档' }],
[
'meta',
{
property: 'og:description',
content: '把 PDF、Word、网页与飞书 / Notion / 语雀的资料收进知识库,做成答案带出处的问答系统',
},
],
],
markdown: {
theme: { light: 'github-light', dark: 'github-dark' },
lineNumbers: false,
toc: { level: [2, 3] },
config(md) {
// 表格外面包一层滚动容器。默认主题把 <table> 本身设成 display:block 来做
// 横向滚动,副作用是表格按内容收缩——列少的表比正文列窄一截,页面里宽窄不一。
// 把滚动交给包裹层后,表格可以恢复 display:table + width:100%,统一撑满正文列。
md.renderer.rules.table_open = () => '<div class="wk-table">\n<table>\n'
md.renderer.rules.table_close = () => '</table>\n</div>\n'
},
},
themeConfig: {
logoLink: { link: '/', target: '_self' },
siteTitle: 'Academy',
nav: [],
academyVersion: repoVersionLabel,
academyScreenshotSizes: readScreenshotSizes(resolve(root, 'public/screenshots')),
sidebar,
socialLinks: [{ icon: 'github', link: repo }],
outline: { level: [2, 3], label: '本页目录' },
docFooter: { prev: '上一篇', next: '下一篇' },
returnToTopLabel: '回到顶部',
sidebarMenuLabel: '目录',
darkModeSwitchLabel: '外观',
lightModeSwitchTitle: '切换到浅色',
darkModeSwitchTitle: '切换到深色',
lastUpdated: {
text: '最后更新',
formatOptions: { dateStyle: 'medium', timeStyle: undefined },
},
editLink: {
pattern: `${repo}/edit/main/website-docs/:path`,
text: '在 GitHub 上编辑此页',
},
search: {
provider: 'local',
options: {
translations: {
button: { buttonText: '搜索文档', buttonAriaLabel: '搜索文档' },
modal: {
displayDetails: '展开详情',
resetButtonTitle: '清除',
backButtonTitle: '返回',
noResultsText: '没有找到结果',
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
},
},
},
miniSearch: {
options: { tokenize },
searchOptions: {
fuzzy: 0.2,
prefix: true,
boost: { title: 4, text: 2, titles: 1 },
},
},
},
},
footer: {
message: `基于 Academy ${repoVersionLabel} 源码整理 · MIT License`,
copyright: '© Tencent Academy',
},
},
// mermaid >= 11.17 会动态 import UMD 包 fastdom。Vite 启动时扫不到这次导入,
// 浏览器直接加载原始 fastdom.js,报 does not provide an export named 'default'
//(vitepress-plugin-mermaid#98)。只在能解析到这两个包时才预构建:lockfile 里的
// mermaid 11.16.0 没有 fastdom,无条件 include 会报 Failed to resolve dependency。
vite: {
optimizeDeps: {
include: ['fastdom', 'fastdom/extensions/fastdom-promised.js'].filter(installedDep),
},
},
mermaid: {
theme: 'base',
fontFamily:
'"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, sans-serif',
themeVariables: {
primaryColor: '#eef1f6',
primaryTextColor: '#101f38',
primaryBorderColor: '#9aa8bd',
lineColor: '#7d8ba1',
secondaryColor: '#faf7ef',
tertiaryColor: '#f6f7f9',
fontSize: '14px',
},
},
}),
)