mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-16 13:25:51 +00:00
以 README 为单一事实来源,重构整个 docs/ 目录。 最终结构(3 大组、15 篇文档): - 开始: installation / quickstart / model-providers - 核心功能: pipes-and-lan、acp、channels、chrome-control、computer-use、 voice-mode、web-browser-tool、auto-dream、remote-control-self-hosting、 langfuse-monitoring - 内部机制: growthbook-adapter、sentry-setup 主要变更: - 删除 56 个 README 未提及的文档(architecture 全部 / guides 全部 / features 中未在 README 出现的 20 篇 / internals 中的 5 篇) - 合并 6 组重复文档(pipes-and-lan、chrome-control、acp、computer-use、 auto-dream、coordinator-mode 简化为入口) - features 子组从 5 → 4,ui/ 合并入 tools/ - 所有保留文档加上人性化 frontmatter(title/description/keywords) - docs.json navigation 简化为 3 大组,redirects 重新过滤为 7 条合并跳转 - 新增 docs.md 工作大纲与验证脚本(verify-docs / check-docs-orphans / dump-docs-outline) 总计 130 文件改动,从约 35000 行精简到约 2000 行。 Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* 反向校验:找出 docs/ 下所有 .md/.mdx 文件,但 docs.json 导航没引用的。
|
|
* 用法: node scripts/check-docs-orphans.mjs
|
|
*/
|
|
import { readFileSync, readdirSync, statSync, existsSync } from 'node:fs'
|
|
import { resolve, dirname, relative, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const ROOT = resolve(__dirname, '..')
|
|
const DOCS = resolve(ROOT, 'docs')
|
|
|
|
const docsJson = JSON.parse(readFileSync(resolve(ROOT, 'docs.json'), 'utf8'))
|
|
|
|
const referenced = new Set()
|
|
const walk = pages => {
|
|
if (!Array.isArray(pages)) return
|
|
for (const p of pages) {
|
|
if (typeof p === 'string') {
|
|
referenced.add(p.replace(/^docs\//, ''))
|
|
} else if (p && Array.isArray(p.pages)) {
|
|
walk(p.pages)
|
|
}
|
|
}
|
|
}
|
|
for (const g of docsJson?.navigation?.groups ?? []) walk(g.pages)
|
|
|
|
const collectMd = dir => {
|
|
const out = []
|
|
for (const name of readdirSync(dir)) {
|
|
if (name === 'logo' || name === 'images') continue
|
|
const full = join(dir, name)
|
|
const rel = relative(DOCS, full).replace(/\\/g, '/')
|
|
if (statSync(full).isDirectory()) {
|
|
out.push(...collectMd(full))
|
|
} else if (name.endsWith('.md') || name.endsWith('.mdx')) {
|
|
out.push(rel.replace(/\.(md|mdx)$/, ''))
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
const all = collectMd(DOCS)
|
|
const orphans = all.filter(p => !referenced.has(p))
|
|
|
|
if (orphans.length === 0) {
|
|
console.log(`✅ All ${all.length} docs files are referenced in navigation.`)
|
|
process.exit(0)
|
|
} else {
|
|
console.warn(`⚠️ ${orphans.length} orphan doc(s) not in navigation:`)
|
|
for (const o of orphans) console.warn(' - docs/' + o)
|
|
process.exit(0) // 不失败,只是提示
|
|
}
|