@youdao/baoku-cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/package.json +32 -0
- package/scripts/run.js +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# baoku-cli
|
|
2
|
+
|
|
3
|
+
有道宝库命令行工具 -- 知识库管理、内容生成(PPT/播客/脑图/信息图/文档翻译)、知识库问答。主要面向 AI Agent 调用,也可人工使用。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @youdao/baoku-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
或从源码编译:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
make build
|
|
15
|
+
sudo cp baoku /usr/local/bin/
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 快速开始
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 授权(浏览器登录)
|
|
22
|
+
baoku config init
|
|
23
|
+
|
|
24
|
+
# 一步生成 PPT
|
|
25
|
+
baoku generate ppt --file report.pdf
|
|
26
|
+
|
|
27
|
+
# 知识库问答
|
|
28
|
+
baoku chat --project-id <id> --message "核心观点是什么?"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 命令一览
|
|
32
|
+
|
|
33
|
+
| 命令 | 说明 |
|
|
34
|
+
|------|------|
|
|
35
|
+
| `baoku config init` | 浏览器授权,或 `--api-key` 手动配置 |
|
|
36
|
+
| `baoku config show` | 查看当前配置 |
|
|
37
|
+
| `baoku project create/list/get` | 知识库管理 |
|
|
38
|
+
| `baoku source add/list/status/delete` | 来源管理(文件/URL/文本) |
|
|
39
|
+
| `baoku generate ppt/podcast/mindmap/infographic/doctran` | 内容生成 |
|
|
40
|
+
| `baoku generate options` | 查看可用生成选项(模板、音色等) |
|
|
41
|
+
| `baoku task status` | 查询生成任务状态 |
|
|
42
|
+
| `baoku chat` | 知识库问答 |
|
|
43
|
+
|
|
44
|
+
输出格式:`--format json`(默认,Agent 友好)或 `--format pretty`(人类友好)。
|
|
45
|
+
|
|
46
|
+
## 开发
|
|
47
|
+
|
|
48
|
+
**依赖**: Go 1.22+
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
make build # 编译
|
|
52
|
+
make test # 单元测试
|
|
53
|
+
make integration-test # 集成测试
|
|
54
|
+
make test-all # 全部测试
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 项目结构
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
cmd/ Cobra 命令(每个命令一个文件)
|
|
61
|
+
internal/
|
|
62
|
+
client/ HTTP 客户端(认证注入、重试、错误分类)
|
|
63
|
+
config/ 配置管理(环境变量 → 密钥链 → 配置文件)
|
|
64
|
+
output/ JSON Envelope 输出、结构化错误、Pretty 格式
|
|
65
|
+
scripts/ npm 分发与发布脚本
|
|
66
|
+
skills/ Agent Skill 文档
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 测试
|
|
70
|
+
|
|
71
|
+
集成测试使用 `httptest.Server` 模拟 Baoku API,通过 `RunContext` 注入 fake 依赖(stdout/stderr、sleep、clock、API client)。所有测试命令必须带 `-timeout 30s`,防止轮询循环挂起。
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# 跑单个测试
|
|
75
|
+
go test ./cmd -run TestIntegration_source_add -v -timeout 30s
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 发布
|
|
79
|
+
|
|
80
|
+
### 1. 打 tag
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git tag v0.1.0
|
|
84
|
+
git push origin v0.1.0
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 2. 构建跨平台二进制
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 需要安装 goreleaser: brew install goreleaser/tap/goreleaser
|
|
91
|
+
./scripts/release.sh
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
产物在 `dist/` 目录,支持 darwin/linux/windows x amd64/arm64。
|
|
95
|
+
|
|
96
|
+
### 3. 发布到 npm
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
./scripts/publish.sh
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
自动完成:GoReleaser 编译 → 分平台 npm 包打包 → 发布 `@youdao/baoku-cli` 及 6 个平台包。
|
|
103
|
+
|
|
104
|
+
### 测试构建(不发布)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
./scripts/publish.sh --snapshot
|
|
108
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@youdao/baoku-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Youdao Baoku CLI - knowledge base management and content generation",
|
|
5
|
+
"bin": {
|
|
6
|
+
"baoku": "scripts/run.js"
|
|
7
|
+
},
|
|
8
|
+
"os": [
|
|
9
|
+
"darwin",
|
|
10
|
+
"linux",
|
|
11
|
+
"win32"
|
|
12
|
+
],
|
|
13
|
+
"cpu": [
|
|
14
|
+
"x64",
|
|
15
|
+
"arm64"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=16"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"files": [
|
|
22
|
+
"scripts/run.js"
|
|
23
|
+
],
|
|
24
|
+
"optionalDependencies": {
|
|
25
|
+
"@youdao/baoku-cli-darwin-arm64": "0.0.1",
|
|
26
|
+
"@youdao/baoku-cli-darwin-x64": "0.0.1",
|
|
27
|
+
"@youdao/baoku-cli-linux-arm64": "0.0.1",
|
|
28
|
+
"@youdao/baoku-cli-linux-x64": "0.0.1",
|
|
29
|
+
"@youdao/baoku-cli-win32-arm64": "0.0.1",
|
|
30
|
+
"@youdao/baoku-cli-win32-x64": "0.0.1"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/scripts/run.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execFileSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const PLATFORMS = {
|
|
6
|
+
"darwin-arm64": { pkg: "@youdao/baoku-cli-darwin-arm64", bin: "baoku" },
|
|
7
|
+
"darwin-x64": { pkg: "@youdao/baoku-cli-darwin-x64", bin: "baoku" },
|
|
8
|
+
"linux-arm64": { pkg: "@youdao/baoku-cli-linux-arm64", bin: "baoku" },
|
|
9
|
+
"linux-x64": { pkg: "@youdao/baoku-cli-linux-x64", bin: "baoku" },
|
|
10
|
+
"win32-arm64": { pkg: "@youdao/baoku-cli-win32-arm64", bin: "baoku.exe" },
|
|
11
|
+
"win32-x64": { pkg: "@youdao/baoku-cli-win32-x64", bin: "baoku.exe" },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
15
|
+
const platform = PLATFORMS[platformKey];
|
|
16
|
+
|
|
17
|
+
if (!platform) {
|
|
18
|
+
console.error(`Unsupported platform: ${platformKey}`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let binPath;
|
|
23
|
+
try {
|
|
24
|
+
const pkgDir = path.dirname(require.resolve(`${platform.pkg}/package.json`));
|
|
25
|
+
binPath = path.join(pkgDir, "bin", platform.bin);
|
|
26
|
+
} catch {
|
|
27
|
+
console.error(
|
|
28
|
+
`Platform package ${platform.pkg} is not installed.\n` +
|
|
29
|
+
`Try reinstalling: npm install @youdao/baoku-cli`
|
|
30
|
+
);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
36
|
+
} catch (e) {
|
|
37
|
+
if (e.code === "ENOENT") {
|
|
38
|
+
console.error("baoku binary not found. Try reinstalling: npm install @youdao/baoku-cli");
|
|
39
|
+
}
|
|
40
|
+
process.exit(e.status || 1);
|
|
41
|
+
}
|