@youdao/baoku-cli
v0.0.3
Published
Youdao Baoku CLI - knowledge base management and content generation
Readme
baoku-cli
有道宝库命令行工具 -- 知识库管理、内容生成(PPT/播客/脑图/信息图/文档翻译)、知识库问答。主要面向 AI Agent 调用,也可人工使用。
安装
npm install -g @youdao/baoku-cli或从源码编译:
make build
sudo cp baoku /usr/local/bin/快速开始
# 授权(浏览器登录)
baoku config init
# 一步生成 PPT
baoku generate ppt --file report.pdf
# 知识库问答
baoku chat --project-id <id> --message "核心观点是什么?"命令一览
| 命令 | 说明 |
|------|------|
| baoku config init | 浏览器授权,或 --api-key 手动配置 |
| baoku config show | 查看当前配置 |
| baoku project create/list/get | 知识库管理 |
| baoku source add/list/status/delete | 来源管理(文件/URL/文本) |
| baoku generate ppt/podcast/mindmap/infographic/doctran | 内容生成 |
| baoku generate options | 查看可用生成选项(模板、音色等) |
| baoku task status | 查询生成任务状态 |
| baoku chat | 知识库问答 |
输出格式:--format json(默认,Agent 友好)或 --format pretty(人类友好)。
详细文档:https://baoku.youdao.com/developer/#/docs/getting-started
开发
依赖: Go 1.22+
make build # 编译
make test # 单元测试
make integration-test # 集成测试
make test-all # 全部测试项目结构
cmd/ Cobra 命令(每个命令一个文件)
internal/
client/ HTTP 客户端(认证注入、重试、错误分类)
config/ 配置管理(环境变量 → 密钥链 → 配置文件)
output/ JSON Envelope 输出、结构化错误、Pretty 格式
scripts/ npm 分发与发布脚本
skills/ Agent Skill 文档测试
集成测试使用 httptest.Server 模拟 Baoku API,通过 RunContext 注入 fake 依赖(stdout/stderr、sleep、clock、API client)。所有测试命令必须带 -timeout 30s,防止轮询循环挂起。
# 跑单个测试
go test ./cmd -run TestIntegration_source_add -v -timeout 30s发布
1. 打 tag
git tag v0.1.0
git push origin v0.1.02. 构建跨平台二进制
# 需要安装 goreleaser: brew install goreleaser/tap/goreleaser
./scripts/release.sh产物在 dist/ 目录,支持 darwin/linux/windows x amd64/arm64。
3. 发布到 npm
./scripts/publish.sh自动完成:GoReleaser 编译 → 分平台 npm 包打包 → 发布 @youdao/baoku-cli 及 6 个平台包。
测试构建(不发布)
./scripts/publish.sh --snapshot