@jiangzhx/adcli 0.1.0

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.
Binary file
@@ -0,0 +1,209 @@
1
+ # 命令功能清单
2
+
3
+ 当前项目使用 Bun + TypeScript。命令分为两层:
4
+
5
+ - `adcli ...`:面向使用者的 CLI。
6
+ - `bun run ...`:面向项目维护、采集、构建和校验的工程命令。
7
+
8
+ ## 对外 CLI
9
+
10
+ ### `adcli doc search`
11
+
12
+ 搜索已经发布到线上 docs pack 的广告平台文档。全局安装后直接使用:
13
+
14
+ ```bash
15
+ adcli doc search "广告消耗"
16
+ ```
17
+
18
+ 项目内开发时也可以用:
19
+
20
+ ```bash
21
+ bun run adcli doc search "广告消耗"
22
+ ```
23
+
24
+ 支持参数:
25
+
26
+ ```bash
27
+ bun run adcli doc search "广告消耗" --limit 5
28
+ bun run adcli doc search "广告消耗" --json
29
+ bun run adcli doc search "广告消耗" --index public/search-index.json
30
+ bun run adcli doc search "广告消耗" --platform tencent_ads
31
+ ```
32
+
33
+ 全局 CLI 默认读取:
34
+
35
+ ```text
36
+ https://adcli.jiangzhx.com/search-index.json
37
+ ```
38
+
39
+ 也可以用环境变量覆盖:
40
+
41
+ ```bash
42
+ ADCLI_SEARCH_INDEX=https://example.com/search-index.json adcli doc search "广告消耗"
43
+ ```
44
+
45
+ 当前返回:
46
+
47
+ - 平台 ID。
48
+ - 文档标题。
49
+ - `public/` 下的 Markdown 路径。
50
+ - 原始官方文档 URL。
51
+ - 搜索分数。
52
+
53
+ 当前搜索依赖 `public/search-index.json`,不重新采集原始站点。
54
+
55
+ 查询词中包含平台别名时会提升对应平台的排序权重,例如 `广点通`、`腾讯广告` 会提升 `tencent_ads` 文档,但不会硬过滤其他平台。需要明确限制平台时,使用 `--platform tencent_ads`。
56
+
57
+ ## 采集命令
58
+
59
+ ### `bun run discover:sources`
60
+
61
+ 从 collection recipe 入口发现文档列表,生成 collection manifest。
62
+
63
+ ```bash
64
+ bun run discover:sources recipes/oceanengine-open-platform-docs.json
65
+ ```
66
+
67
+ 输入:
68
+
69
+ - `recipes/{platform}-*.json`
70
+
71
+ 输出:
72
+
73
+ - `data/sources/{platform}/_collections/{collection_id}/manifest.json`
74
+
75
+ ### `bun run ingest:collection`
76
+
77
+ 按 collection manifest 批量采集文档。
78
+
79
+ ```bash
80
+ bun run ingest:collection data/sources/oceanengine/_collections/oceanengine_open_platform_docs/manifest.json
81
+ ```
82
+
83
+ 支持参数:
84
+
85
+ ```bash
86
+ --limit N
87
+ --concurrency N
88
+ --source-id ID
89
+ --changed-only
90
+ ```
91
+
92
+ 输出:
93
+
94
+ - `data/sources/{platform}/{source_id}/source.json`
95
+ - `data/sources/{platform}/{source_id}/raw.html`
96
+ - `data/sources/{platform}/{source_id}/cleaned.md`
97
+ - `data/sources/{platform}/{source_id}/blocks.json`
98
+
99
+ ### `bun run ingest:source`
100
+
101
+ 采集单篇 source recipe。
102
+
103
+ ```bash
104
+ bun run ingest:source recipes/some-single-source.json
105
+ ```
106
+
107
+ 适合调试单个页面,不是当前批量采集主路径。
108
+
109
+ ## 构建命令
110
+
111
+ ### `bun run build:llms`
112
+
113
+ 把 `data/sources/` 编译成 `public/` 静态文档包。
114
+
115
+ ```bash
116
+ bun run build:llms all
117
+ bun run build:llms oceanengine
118
+ ```
119
+
120
+ 输出:
121
+
122
+ - `public/llms.txt`
123
+ - `public/llms-full.txt`
124
+ - `public/search-index.json`
125
+ - `public/{platform}/index.md`
126
+ - `public/{platform}/manifest.json`
127
+ - `public/{platform}/docs/{doc_id}.md`
128
+
129
+ ### `bun run build:search-index`
130
+
131
+ 只基于当前 `public/` 重新生成搜索索引。
132
+
133
+ ```bash
134
+ bun run build:search-index
135
+ ```
136
+
137
+ 输出:
138
+
139
+ - `public/search-index.json`
140
+
141
+ 适合只调整搜索逻辑或搜索索引结构后使用。
142
+
143
+ ### `bun run rebuild:source-blocks`
144
+
145
+ 基于已有 `raw.html` 重建 source blocks。
146
+
147
+ ```bash
148
+ bun run rebuild:source-blocks oceanengine
149
+ ```
150
+
151
+ 适合调整 HTML block 抽取逻辑后,避免重新访问远程站点。
152
+
153
+ ## 校验命令
154
+
155
+ ### `bun run build`
156
+
157
+ 校验当前 `public/` 是否是完整可发布产物。
158
+
159
+ ```bash
160
+ bun run build
161
+ ```
162
+
163
+ 当前检查:
164
+
165
+ - `public/llms.txt` 存在。
166
+ - `public/llms-full.txt` 存在。
167
+ - `public/search-index.json` 存在。
168
+ - 每个平台 manifest 被 root index 覆盖。
169
+ - manifest 中每篇文档的 Markdown 文件存在。
170
+ - 搜索索引覆盖 manifest 中每篇文档。
171
+
172
+ ### `bun run test`
173
+
174
+ 运行测试。
175
+
176
+ ```bash
177
+ bun run test
178
+ ```
179
+
180
+ ### `bun run typecheck`
181
+
182
+ 运行 TypeScript 类型检查。
183
+
184
+ ```bash
185
+ bun run typecheck
186
+ ```
187
+
188
+ ### `bun run lint`
189
+
190
+ 运行 ESLint。
191
+
192
+ ```bash
193
+ bun run lint
194
+ ```
195
+
196
+ ## 当前边界
197
+
198
+ `adcli` CLI 当前只支持 `doc search`。采集、构建和校验还停留在 `bun run ...` 工程命令层。
199
+
200
+ 后续如果要把项目产品化成完整 CLI,可以逐步把这些能力收进 `adcli`:
201
+
202
+ - `adcli doc show <doc-path-or-id>`
203
+ - `adcli doc build llms [platform|all]`
204
+ - `adcli doc build search-index`
205
+ - `adcli source discover <recipe>`
206
+ - `adcli source ingest <manifest-or-recipe>`
207
+ - `adcli build llms [platform|all]`
208
+ - `adcli build search-index`
209
+ - `adcli verify`
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@jiangzhx/adcli",
3
+ "version": "0.1.0",
4
+ "description": "CLI for searching hosted advertising platform API docs.",
5
+ "type": "module",
6
+ "packageManager": "bun@1.3.10",
7
+ "homepage": "https://github.com/jiangzhx/adcli#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jiangzhx/adcli.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/jiangzhx/adcli/issues"
14
+ },
15
+ "bin": {
16
+ "adcli": "dist/cli.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "docs/commands.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "scripts": {
27
+ "build": "bun run verify:public",
28
+ "build:cli": "bun scripts/build-cli.ts",
29
+ "discover:sources": "bun scripts/discover-sources.ts",
30
+ "ingest:collection": "bun scripts/ingest-collection.ts",
31
+ "ingest:source": "bun scripts/ingest-source.ts",
32
+ "rebuild:source-blocks": "bun scripts/rebuild-source-blocks.ts",
33
+ "build:llms": "bun scripts/build-llms.ts",
34
+ "build:search-index": "bun scripts/build-search-index.ts",
35
+ "verify:public": "bun scripts/verify-public.ts",
36
+ "adcli": "bun src/cli.ts",
37
+ "prepack": "bun run build:cli",
38
+ "test": "bun test tests/**/*.test.ts",
39
+ "typecheck": "tsc --noEmit",
40
+ "lint": "eslint"
41
+ },
42
+ "devDependencies": {
43
+ "@eslint/js": "^9.39.4",
44
+ "@types/node": "^20",
45
+ "crawlee": "^3.16.0",
46
+ "eslint": "^9",
47
+ "playwright": "^1.60.0",
48
+ "typescript": "^5",
49
+ "typescript-eslint": "^8.59.3"
50
+ },
51
+ "dependencies": {
52
+ "minisearch": "^7.2.0"
53
+ }
54
+ }