website: generate the API reference from source (cordis + all 15 harness services)
scripts/gen-website-api.ts renders website/zh-CN/api/{cordis,harness}/* and the
api-sidebar.json fragment the VitePress config imports, so pages and navigation
can never drift from the code: signatures, @param/@returns prose, dispatch
modes, and GitHub source links are extracted, never transcribed, and the
generator hard-errors on any rendered member missing docs. verify-website-api
(doc-sync + run-gates) is the freshness gate.
Replaces the hand-written zh api pages (7 pages covering 7 of 15 services,
with phantom APIs: Context.current/Context.events, agent/post-step, tool/call,
compact/*, llm/pre-request none of which exist) with generated English
references: 5 cordis pages, 15 per-service pages, and a 35-event catalog
grouped by scope. The hand-written hub api/index.md stays and now indexes the
full surface; zh for these pages arrives with the unified translation flow.
This commit is contained in:
90
website/.vitepress/config/api-sidebar.json
Normal file
90
website/.vitepress/config/api-sidebar.json
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"cordis": [
|
||||
{
|
||||
"text": "Context",
|
||||
"link": "/zh-CN/api/cordis/context"
|
||||
},
|
||||
{
|
||||
"text": "Events",
|
||||
"link": "/zh-CN/api/cordis/events"
|
||||
},
|
||||
{
|
||||
"text": "Fiber",
|
||||
"link": "/zh-CN/api/cordis/fiber"
|
||||
},
|
||||
{
|
||||
"text": "Registry",
|
||||
"link": "/zh-CN/api/cordis/registry"
|
||||
},
|
||||
{
|
||||
"text": "Service",
|
||||
"link": "/zh-CN/api/cordis/service"
|
||||
}
|
||||
],
|
||||
"harness": [
|
||||
{
|
||||
"text": "ctx.agentLoop",
|
||||
"link": "/zh-CN/api/harness/agent-loop"
|
||||
},
|
||||
{
|
||||
"text": "ctx.agents",
|
||||
"link": "/zh-CN/api/harness/agents"
|
||||
},
|
||||
{
|
||||
"text": "ctx.bash",
|
||||
"link": "/zh-CN/api/harness/bash"
|
||||
},
|
||||
{
|
||||
"text": "ctx.codeRuntime",
|
||||
"link": "/zh-CN/api/harness/code-runtime"
|
||||
},
|
||||
{
|
||||
"text": "ctx.compact",
|
||||
"link": "/zh-CN/api/harness/compact"
|
||||
},
|
||||
{
|
||||
"text": "ctx.fs",
|
||||
"link": "/zh-CN/api/harness/fs"
|
||||
},
|
||||
{
|
||||
"text": "ctx.llm",
|
||||
"link": "/zh-CN/api/harness/llm"
|
||||
},
|
||||
{
|
||||
"text": "ctx.sessionPersistence",
|
||||
"link": "/zh-CN/api/harness/session-persistence"
|
||||
},
|
||||
{
|
||||
"text": "ctx.sessions",
|
||||
"link": "/zh-CN/api/harness/sessions"
|
||||
},
|
||||
{
|
||||
"text": "ctx.subagents",
|
||||
"link": "/zh-CN/api/harness/subagents"
|
||||
},
|
||||
{
|
||||
"text": "ctx.systemPrompt",
|
||||
"link": "/zh-CN/api/harness/system-prompt"
|
||||
},
|
||||
{
|
||||
"text": "ctx.tools",
|
||||
"link": "/zh-CN/api/harness/tools"
|
||||
},
|
||||
{
|
||||
"text": "ctx.userInteraction",
|
||||
"link": "/zh-CN/api/harness/user-interaction"
|
||||
},
|
||||
{
|
||||
"text": "ctx.web",
|
||||
"link": "/zh-CN/api/harness/web"
|
||||
},
|
||||
{
|
||||
"text": "ctx.workflows",
|
||||
"link": "/zh-CN/api/harness/workflows"
|
||||
},
|
||||
{
|
||||
"text": "Events",
|
||||
"link": "/zh-CN/api/harness/events"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
|
||||
import apiSidebarData from './api-sidebar.json'
|
||||
|
||||
const guideSidebar: DefaultTheme.SidebarItem[] = [
|
||||
{
|
||||
@@ -37,29 +38,20 @@ const developSidebar: DefaultTheme.SidebarItem[] = [
|
||||
},
|
||||
]
|
||||
|
||||
// The API section sidebar is GENERATED (scripts/gen-website-api.ts writes
|
||||
// api-sidebar.json alongside the pages), so navigation can never drift from
|
||||
// the generated page set. Only the hand-written hub link lives here.
|
||||
const apiSidebar: DefaultTheme.SidebarItem[] = [
|
||||
{
|
||||
text: '框架 API',
|
||||
items: [
|
||||
{ text: '总览', link: '/zh-CN/api/' },
|
||||
{ text: 'Context', link: '/zh-CN/api/cordis/context' },
|
||||
{ text: 'Events', link: '/zh-CN/api/cordis/events' },
|
||||
{ text: 'Fiber', link: '/zh-CN/api/cordis/fiber' },
|
||||
{ text: 'Registry', link: '/zh-CN/api/cordis/registry' },
|
||||
{ text: 'Service', link: '/zh-CN/api/cordis/service' },
|
||||
...apiSidebarData.cordis,
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Harness API',
|
||||
items: [
|
||||
{ text: 'Tools (dsh-tools)', link: '/zh-CN/api/harness/tools' },
|
||||
{ text: 'LLM (dsh-llm)', link: '/zh-CN/api/harness/llm' },
|
||||
{ text: 'Session (dsh-session)', link: '/zh-CN/api/harness/session' },
|
||||
{ text: 'Agent (dsh-agent)', link: '/zh-CN/api/harness/agent' },
|
||||
{ text: 'Bash (dsh-bash)', link: '/zh-CN/api/harness/bash' },
|
||||
{ text: 'Filesystem (dsh-fs)', link: '/zh-CN/api/harness/fs' },
|
||||
{ text: 'Subagent (dsh-subagent)', link: '/zh-CN/api/harness/subagent' },
|
||||
],
|
||||
items: apiSidebarData.harness,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user