DocSync — Living Documentation for Your Codebase
DocSync generates documentation from your code and keeps it in sync automatically. It uses tree-sitter for multi-language AST parsing, lefthook for git hook integration, and difftastic for semantic change detection.
Commands
Free Tier (No license required)
docsync generate <file-or-directory>
Generate a one-shot README or API doc for a single file or directory.
How to execute:
CODEBLOCK0
What it does:
- 1. Parses the target file(s) with tree-sitter to extract symbols (functions, classes, exports, types, interfaces)
- Applies the appropriate template from INLINECODE1
- Generates a markdown documentation file alongside the source
Example usage scenarios:
- - "Generate docs for src/utils/auth.ts" → runs INLINECODE2
- "Document this whole directory" → runs INLINECODE3
- "Create a README for this project" → runs INLINECODE4
Pro Tier ($29/user/month — requires DOCSYNCLICENSEKEY)
docsync drift [directory]
Scan for documentation drift — find where code has changed but docs haven't been updated.
How to execute:
CODEBLOCK1
What it does:
- 1. Validates license key from config
- Parses all source files with tree-sitter
- Compares extracted symbols against existing documentation
- Reports: new undocumented symbols, changed signatures with stale docs, deleted symbols still in docs
- Outputs a drift report with severity levels (critical/warning/info)
docsync hooks install
Install git hooks that automatically check for doc drift on every commit.
How to execute:
CODEBLOCK2
What it does:
- 1. Validates Pro+ license
- Copies lefthook config to project root
- Installs lefthook pre-commit hook
- On every commit: analyzes staged files, blocks commit if critical drift detected, offers auto-regen
docsync hooks uninstall
Remove DocSync git hooks.
CODEBLOCK3
docsync auto-fix [directory]
Auto-regenerate stale documentation for files with detected drift.
CODEBLOCK4
Team Tier ($49/user/month — requires DOCSYNCLICENSEKEY with team tier)
docsync onboarding [directory]
Generate a comprehensive onboarding guide for new developers.
CODEBLOCK5
docsync architecture [directory]
Generate architecture documentation showing module relationships and data flow.
CODEBLOCK6
Supported Languages
DocSync uses tree-sitter grammars and supports:
- - JavaScript / TypeScript (including JSX/TSX)
- Python
- Rust
- Go
- Java
- C / C++
- Ruby
- PHP
- C#
- Swift
- Kotlin
Configuration
Users can configure DocSync in ~/.openclaw/openclaw.json:
CODEBLOCK7
Important Notes
- - Free tier works immediately with no configuration
- Pro/Team tiers require a license key from https://docsync.pages.dev
- All processing happens locally — no code is sent to external servers
- License validation is offline — no network calls needed
- Git hooks use lefthook which must be installed (see install metadata above)
- tree-sitter and difftastic are optional but recommended for best results; the skill falls back to regex-based parsing if unavailable
Error Handling
- - If tree-sitter is not installed, fall back to regex-based symbol extraction (less accurate but functional)
- If lefthook is not installed and user tries
hooks install, prompt to install it - If license key is invalid or expired, show clear message with link to https://docsync.pages.dev/renew
- If a language grammar is not available, skip that file with a warning
When to Use DocSync
The user might say things like:
- - "Generate docs for this file/project"
- "Are my docs up to date?"
- "Check for documentation drift"
- "Set up auto-docs on my commits"
- "Create an onboarding guide"
- "Document the architecture"
- "What's undocumented in this codebase?"
DocSync — 代码库的活文档
DocSync 从代码生成文档并自动保持同步。它使用 tree-sitter 进行多语言 AST 解析,lefthook 进行 git 钩子集成,以及 difftastic 进行语义变更检测。
命令
免费版(无需许可证)
docsync generate <文件或目录>
为单个文件或目录生成一次性 README 或 API 文档。
执行方式:
bash
bash /scripts/docsync.sh generate <目标>
功能说明:
- 1. 使用 tree-sitter 解析目标文件,提取符号(函数、类、导出项、类型、接口)
- 应用 /templates/ 中的相应模板
- 在源文件旁生成 markdown 格式的文档文件
使用场景示例:
- - 为 src/utils/auth.ts 生成文档 → 运行 docsync generate src/utils/auth.ts
- 为整个目录生成文档 → 运行 docsync generate src/api/
- 为该项目创建 README → 运行 docsync generate .
专业版(29美元/用户/月 — 需要 DOCSYNCLICENSEKEY)
docsync drift [目录]
扫描文档漂移 — 检测代码已变更但文档未更新的情况。
执行方式:
bash
bash /scripts/docsync.sh drift [目录]
功能说明:
- 1. 验证配置文件中的许可证密钥
- 使用 tree-sitter 解析所有源文件
- 将提取的符号与现有文档进行比较
- 报告:未记录的新符号、签名已变更但文档过时的内容、文档中仍存在的已删除符号
- 输出带有严重级别(严重/警告/信息)的漂移报告
docsync hooks install
安装 git 钩子,在每次提交时自动检查文档漂移。
执行方式:
bash
bash /scripts/docsync.sh hooks install
功能说明:
- 1. 验证专业版及以上许可证
- 将 lefthook 配置复制到项目根目录
- 安装 lefthook 预提交钩子
- 每次提交时:分析暂存文件,检测到严重漂移时阻止提交,提供自动重新生成选项
docsync hooks uninstall
移除 DocSync git 钩子。
bash
bash /scripts/docsync.sh hooks uninstall
docsync auto-fix [目录]
为检测到漂移的文件自动重新生成过时文档。
bash
bash /scripts/docsync.sh auto-fix [目录]
团队版(49美元/用户/月 — 需要团队版 DOCSYNCLICENSEKEY)
docsync onboarding [目录]
为新开发者生成全面的入职指南。
bash
bash /scripts/docsync.sh onboarding [目录]
docsync architecture [目录]
生成展示模块关系和数据流的架构文档。
bash
bash /scripts/docsync.sh architecture [目录]
支持的语言
DocSync 使用 tree-sitter 语法,支持:
- - JavaScript / TypeScript(包括 JSX/TSX)
- Python
- Rust
- Go
- Java
- C / C++
- Ruby
- PHP
- C#
- Swift
- Kotlin
配置
用户可以在 ~/.openclaw/openclaw.json 中配置 DocSync:
json
{
skills: {
entries: {
docsync: {
enabled: true,
apiKey: YOURLICENSEKEY_HERE,
config: {
outputDir: docs,
templateOverrides: {},
excludePatterns: [/node_modules/, /dist/, /.git/],
languages: [typescript, python, go],
driftThreshold: warning,
autoFix: false
}
}
}
}
}
重要说明
- - 免费版 无需配置即可立即使用
- 专业版/团队版 需要从 https://docsync.pages.dev 获取许可证密钥
- 所有处理均在本地完成 — 代码不会发送到外部服务器
- 许可证验证是离线的 — 无需网络调用
- Git 钩子使用 lefthook,需提前安装(参见上方安装元数据)
- tree-sitter 和 difftastic 为可选但推荐使用以获得最佳效果;若不可用,技能将回退到基于正则表达式的解析
错误处理
- - 如果未安装 tree-sitter,回退到基于正则表达式的符号提取(精度较低但功能可用)
- 如果未安装 lefthook 且用户尝试执行 hooks install,提示安装
- 如果许可证密钥无效或已过期,显示清晰消息并附带 https://docsync.pages.dev/renew 链接
- 如果某种语言的语法不可用,跳过该文件并发出警告
何时使用 DocSync
用户可能会说:
- - 为这个文件/项目生成文档
- 我的文档是最新的吗?
- 检查文档漂移
- 在提交时设置自动文档生成
- 创建入职指南
- 记录架构
- 这个代码库中哪些部分没有文档?