Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/05-more/12-damo-solver-changelog/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "达摩院AgentOS更新日志",
"position": 10,
"link": {
"type": "doc",
"id": "more/damo-solver-changelog/index"
}
}
16 changes: 16 additions & 0 deletions docs/05-more/12-damo-solver-changelog/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "达摩院AgentOS更新日志"
description: "达摩院AgentOS版本更新历史记录"
keywords: [更新日志, 版本历史, changelog]
---

# 达摩院AgentOS更新日志

本页记录达摩院AgentOS各版本的重要变更。

## 版本索引

<!-- 版本行由发布流程插入到表格分隔行之后:分隔行必须与 DesireCore 更新日志章节保持一致。 -->

| 版本 | 日期 | 概要 |
|------|------|------|
1 change: 1 addition & 0 deletions docs/05-more/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ sidebar_position: 0
| [开源仓库](./09-open-source-repos.md) | 官方 GitHub 仓库一览 |
| [第三方软件与许可](./10-third-party-software.md) | 内置第三方组件及开源许可 |
| [更新日志](./11-changelog/index.md) | 版本更新历史记录 |
| [达摩院AgentOS更新日志](./12-damo-solver-changelog/index.md) | 达摩院AgentOS版本更新历史记录 |
4 changes: 4 additions & 0 deletions i18n/en/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,9 @@
"sidebar.more.category.更新日志": {
"message": "Changelog",
"description": "The label for category '更新日志' in sidebar 'more'"
},
"sidebar.more.category.达摩院AgentOS更新日志": {
"message": "达摩院AgentOS Changelog",
"description": "The label for category '达摩院AgentOS更新日志' in sidebar 'more'"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "达摩院AgentOS Changelog",
"position": 10,
"link": {
"type": "doc",
"id": "more/damo-solver-changelog/index"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "达摩院AgentOS Changelog"
description: "达摩院AgentOS version changelog"
keywords: [changelog, version history, release notes]
---

# 达摩院AgentOS Changelog

This page records important changes in each version of 达摩院AgentOS.

## Version Index

<!-- Version rows are inserted by the release workflow right after the table separator; keep the separator identical to the DesireCore changelog. -->

| Version | Date | Summary |
|---------|------|---------|
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Here you'll find quick reference materials and changelog for DesireCore.
| [Open Source Repositories](./09-open-source-repos.md) | Overview of official GitHub repositories |
| [Third-Party Software & Licenses](./10-third-party-software.md) | Bundled third-party components and open-source licenses |
| [Changelog](./11-changelog/index.md) | Version update history |
| [达摩院AgentOS Changelog](./12-damo-solver-changelog/index.md) | 达摩院AgentOS version update history |
38 changes: 38 additions & 0 deletions plugins/changelog-editions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"description": "更新日志章节配置:每个条目是一个产品发行版的独立更新日志。plugins/changelog-json-plugin.ts 按条目读取 zhSourceDir 下的 v<X.Y.Z>.md,构建时生成站点 /api/<outputFile>(客户端按发行版拉取);scripts/generate-changelog-cover.mjs <version> --edition <id> 按条目生成封面。DesireCore 发布流程只写 desirecore 章节;OEM 发布流程按 id 读取本文件定位章节目录,条目缺失时拒绝写入。新增发行版时追加条目并创建中英文两个章节目录(_category_.json 与 index.md,index.md 的表格分隔行与 desirecore 章节一致,发布流程据此插入版本行)。",
"fields": {
"id": "发行版更新日志 id(desirecore 仓库 editions/<id>/edition.json#distribution.changelogEdition)",
"zhSourceDir": "中文章节目录(相对仓库根):版本页面 v<X.Y.Z>.md 与 index.md 所在目录",
"enSourceDir": "英文章节目录(相对仓库根)",
"outputFile": "构建输出到站点 api/ 下的 JSON 文件名",
"urlPrefix": "版本页面路由前缀(Docusaurus 去掉目录数字前缀后的路径);JSON 中 url = 站点地址 + urlPrefix + /v<X.Y.Z>",
"coverImageDir": "封面图片输出目录(相对仓库根)",
"coverImageUrlPrefix": "版本页面中引用封面图片的路径前缀",
"coverBrandText": "封面左上角的品牌字样",
"coverWebsite": "封面右下角的网址;null 表示不显示"
},
"editions": [
{
"id": "desirecore",
"zhSourceDir": "docs/05-more/11-changelog",
"enSourceDir": "i18n/en/docusaurus-plugin-content-docs/current/05-more/11-changelog",
"outputFile": "changelog.json",
"urlPrefix": "/more/changelog",
"coverImageDir": "static/img/changelog",
"coverImageUrlPrefix": "/img/changelog",
"coverBrandText": "DESIRECORE",
"coverWebsite": "www.desirecore.cn"
},
{
"id": "damo-solver",
"zhSourceDir": "docs/05-more/12-damo-solver-changelog",
"enSourceDir": "i18n/en/docusaurus-plugin-content-docs/current/05-more/12-damo-solver-changelog",
"outputFile": "changelog-damo-solver.json",
"urlPrefix": "/more/damo-solver-changelog",
"coverImageDir": "static/img/changelog/damo-solver",
"coverImageUrlPrefix": "/img/changelog/damo-solver",
"coverBrandText": "达摩院AgentOS",
"coverWebsite": null
}
]
}
84 changes: 64 additions & 20 deletions plugins/changelog-json-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* Docusaurus 插件:构建时生成 changelog.json
* Docusaurus 插件:构建时生成更新日志 JSON
*
* 读取 docs/05-more/11-changelog/v*.md,解析 frontmatter 和 markdown sections,
* 输出结构化 JSON 到 static/api/changelog.json(开发+构建均可用)。
* 按 plugins/changelog-editions.json 的每个发行版条目读取 <zhSourceDir>/v*.md,解析 frontmatter 和 markdown sections,
* 输出结构化 JSON 到 static/api/<outputFile>(开发+构建均可用)。
* desirecore 条目的源目录、输出名与 url 前缀与改为配置之前相同(api/changelog.json);OEM 发行版条目输出 api/changelog-<id>.json。
*/

import type { LoadContext, Plugin } from '@docusaurus/types'
Expand Down Expand Up @@ -32,6 +33,14 @@ interface ChangelogJson {
versions: ChangelogVersion[]
}

/** plugins/changelog-editions.json 中插件使用的条目字段(完整字段说明见该文件) */
interface ChangelogEditionConfig {
id: string
zhSourceDir: string
outputFile: string
urlPrefix: string
}

/** section heading 到 type 的映射 */
const SECTION_MAP: Record<string, ChangelogSection['type']> = {
'新功能': 'feature',
Expand All @@ -44,7 +53,7 @@ const SITE_URL = 'https://docs.desirecore.com'
/**
* 从 markdown 文件内容中解析版本信息
*/
function parseChangelogMd(content: string, fileName: string): ChangelogVersion | null {
function parseChangelogMd(content: string, fileName: string, urlPrefix: string): ChangelogVersion | null {
// 提取版本号(从文件名 v10.0.16.md → 10.0.16)
const versionMatch = fileName.match(/^v(\d+\.\d+\.\d+)\.md$/)
if (!versionMatch) return null
Expand Down Expand Up @@ -91,7 +100,7 @@ function parseChangelogMd(content: string, fileName: string): ChangelogVersion |
version,
date,
sections: nonEmptySections,
url: `${SITE_URL}/more/changelog/v${version}`,
url: `${SITE_URL}${urlPrefix}/v${version}`,
}
if (coverImage) result.coverImage = coverImage
return result
Expand All @@ -100,13 +109,16 @@ function parseChangelogMd(content: string, fileName: string): ChangelogVersion |
/**
* 生成 changelog.json 内容
*/
function generateChangelogJson(changelogDir: string): ChangelogJson {
const files = fs.readdirSync(changelogDir).filter((f) => /^v\d+\.\d+\.\d+\.md$/.test(f))
function generateChangelogJson(changelogDir: string, urlPrefix: string): ChangelogJson {
// 章节目录尚不存在时输出空列表:客户端拿到「没有版本」而不是 404
const files = fs.existsSync(changelogDir)
? fs.readdirSync(changelogDir).filter((f) => /^v\d+\.\d+\.\d+\.md$/.test(f))
: []

const versions: ChangelogVersion[] = []
for (const file of files) {
const content = fs.readFileSync(path.join(changelogDir, file), 'utf-8')
const parsed = parseChangelogMd(content, file)
const parsed = parseChangelogMd(content, file, urlPrefix)
if (parsed) {
versions.push(parsed)
}
Expand All @@ -128,34 +140,66 @@ function generateChangelogJson(changelogDir: string): ChangelogJson {
}

/**
* 将 changelog.json 写入目标目录
* 将更新日志 JSON 写入目标目录的 api/<outputFile>
*/
function writeChangelogJson(targetDir: string, data: ChangelogJson): void {
function writeChangelogJson(targetDir: string, outputFile: string, data: ChangelogJson): void {
const apiDir = path.join(targetDir, 'api')
fs.mkdirSync(apiDir, { recursive: true })
fs.writeFileSync(path.join(apiDir, 'changelog.json'), JSON.stringify(data, null, 2), 'utf-8')
fs.writeFileSync(path.join(apiDir, outputFile), JSON.stringify(data, null, 2), 'utf-8')
}

/**
* 读取并校验 plugins/changelog-editions.json;配置错误直接让构建失败
*/
function loadChangelogEditions(siteDir: string): ChangelogEditionConfig[] {
const configPath = path.join(siteDir, 'plugins', 'changelog-editions.json')
const raw = JSON.parse(fs.readFileSync(configPath, 'utf-8')) as { editions?: unknown }
if (!Array.isArray(raw.editions) || raw.editions.length === 0) {
throw new Error(`[changelog-json-plugin] ${configPath} 缺少 editions`)
}
const outputFiles = new Set<string>()
return raw.editions.map((entry, index) => {
const edition = entry as Partial<ChangelogEditionConfig>
for (const field of ['id', 'zhSourceDir', 'outputFile', 'urlPrefix'] as const) {
if (typeof edition[field] !== 'string' || edition[field] === '') {
throw new Error(`[changelog-json-plugin] editions[${index}].${field} 必须是非空字符串`)
}
}
const { outputFile, urlPrefix } = edition as ChangelogEditionConfig
if (!/^[a-z0-9-]+\.json$/.test(outputFile) || !urlPrefix.startsWith('/') || outputFiles.has(outputFile)) {
throw new Error(`[changelog-json-plugin] editions[${index}] 的 outputFile(小写 .json 文件名、不得重复)或 urlPrefix(以 / 开头)非法`)
}
outputFiles.add(outputFile)
return edition as ChangelogEditionConfig
})
}

export default function changelogJsonPlugin(context: LoadContext): Plugin {
const changelogDir = path.join(context.siteDir, 'docs', '05-more', '11-changelog')
const editions = loadChangelogEditions(context.siteDir)

/** 为每个发行版生成并写入 JSON */
function generateAll(targetDir: string, label: string): Record<string, ChangelogJson> {
const results: Record<string, ChangelogJson> = {}
for (const edition of editions) {
const data = generateChangelogJson(path.join(context.siteDir, edition.zhSourceDir), edition.urlPrefix)
writeChangelogJson(targetDir, edition.outputFile, data)
console.log(`[changelog-json-plugin] 已生成 ${label}/api/${edition.outputFile}(${data.versions.length} 个版本)`)
results[edition.id] = data
}
return results
}

return {
name: 'changelog-json-plugin',

// 开发模式:在 static/ 中生成,Docusaurus 会自动 serve
async loadContent() {
const data = generateChangelogJson(changelogDir)
const staticDir = path.join(context.siteDir, 'static')
writeChangelogJson(staticDir, data)
console.log(`[changelog-json-plugin] 已生成 static/api/changelog.json(${data.versions.length} 个版本)`)
return data
return generateAll(path.join(context.siteDir, 'static'), 'static')
},

// 构建模式:复制到 build 输出目录
async postBuild({ outDir }) {
const data = generateChangelogJson(changelogDir)
writeChangelogJson(outDir, data)
console.log(`[changelog-json-plugin] 已生成 build/api/changelog.json(${data.versions.length} 个版本)`)
generateAll(outDir, 'build')
},
}
}
Loading
Loading