@jiangzhx/adcli 0.1.2 → 0.1.4

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.
Files changed (4) hide show
  1. package/README.md +144 -36
  2. package/dist/cli.js +4661 -1231
  3. package/docs/commands.md +271 -4
  4. package/package.json +26 -2
package/docs/commands.md CHANGED
@@ -75,7 +75,7 @@ ADCLI_SEARCH_INDEX=https://example.com/search-index.json adcli doc search "广
75
75
 
76
76
  - 平台 ID。
77
77
  - 文档标题。
78
- - `public/` 下的 Markdown 路径。
78
+ - 线上 Markdown URL 和 `public/` 下的 Markdown 路径。
79
79
  - 原始官方文档 URL。
80
80
  - 搜索分数。
81
81
 
@@ -83,6 +83,52 @@ ADCLI_SEARCH_INDEX=https://example.com/search-index.json adcli doc search "广
83
83
 
84
84
  查询词中包含平台别名时会提升对应平台的排序权重,例如 `广点通`、`腾讯广告` 会提升 `tencent_ads` 文档,但不会硬过滤其他平台。需要明确限制平台时,使用 `--platform tencent_ads`。
85
85
 
86
+ ## 维护者采集命令
87
+
88
+ ### `bun run ingest:url`
89
+
90
+ 采集导航树未收录但可直达的单个官方文档页面,例如巨量开放平台里不出现在左侧树、但 URL 可直接打开的文档。
91
+
92
+ ```bash
93
+ bun run ingest:url https://open.oceanengine.com/labels/7/docs/1865873315616282
94
+ bun run ingest:url https://open.oceanengine.com/labels/7/docs/1865873315616282 --platform oceanengine
95
+ ```
96
+
97
+ 当前支持:
98
+
99
+ - `oceanengine`: `https://open.oceanengine.com/labels/<label_id>/docs/<doc_id>`
100
+
101
+ 命令会自动从 URL 识别平台和 `doc_id`,写入 `data/sources/{platform}/...`,并从页面内容解析标题。`--title` 不受支持;如果标题或正文无法从页面解析出来,应视为采集质量问题。
102
+
103
+ 采集完成后,命令会提示下一步:
104
+
105
+ ```bash
106
+ bun run build:llms --url https://open.oceanengine.com/labels/7/docs/1865873315616282
107
+ ```
108
+
109
+ 需要发布到 `public/` 文档包、`llms-full.txt` 和 `search-index.json` 时再执行这一步。
110
+
111
+ ### `bun run build:llms --url`
112
+
113
+ 只发布单个已采集 URL 对应的 Markdown 文档,并更新依赖它的汇总产物。
114
+
115
+ ```bash
116
+ bun run build:llms --url https://open.oceanengine.com/labels/7/docs/1865873315616282
117
+ bun run build:llms --url https://open.oceanengine.com/labels/7/docs/1865873315616282 --platform oceanengine
118
+ ```
119
+
120
+ 当前支持:
121
+
122
+ - `oceanengine`: `https://open.oceanengine.com/labels/<label_id>/docs/<doc_id>`
123
+
124
+ 命令要求对应源数据已经存在于 `data/sources/{platform}/...`,通常先执行 `bun run ingest:url <url>`。它只重写目标文档 Markdown 文件,同时更新:
125
+
126
+ - `public/{platform}/index.md`
127
+ - `public/{platform}/manifest.json`
128
+ - `public/llms.txt`
129
+ - `public/llms-full.txt`
130
+ - `public/search-index.json`
131
+
86
132
  ### `adcli llms`
87
133
 
88
134
  输出给 AI / Agent 使用的 docs pack 入口。
@@ -115,11 +161,182 @@ adcli prompt
115
161
  adcli llms prompt
116
162
  ```
117
163
 
164
+ ### `adcli oceanengine auth`
165
+
166
+ 保存巨量引擎 access token。保存后,巨量引擎相关命令可以不再重复传 `--access-token`。
167
+
168
+ ```bash
169
+ adcli oceanengine auth <token>
170
+ ```
171
+
172
+ token 会按 CLI 缓存处理,保存到 AdCLI 缓存目录下的 `oceanengine.json`。macOS 默认路径:
173
+
174
+ ```text
175
+ ~/Library/Caches/adcli/oceanengine.json
176
+ ```
177
+
178
+ token 优先级:
179
+
180
+ 1. `--access-token`
181
+ 2. `OCEANENGINE_ACCESS_TOKEN`
182
+ 3. `adcli oceanengine auth <token>` 保存的本地 token
183
+
184
+ ### `adcli oceanengine advertiser list`
185
+
186
+ 通过当前仓库内的巨量引擎 Node.js SDK 拉取授权广告主列表。
187
+ 默认输出 `advertiser_id` 和 `name` 两列;需要完整响应时加 `--json`。
188
+
189
+ ```bash
190
+ adcli oceanengine advertiser list --access-token <token>
191
+ adcli oceanengine advertiser list --json
192
+ ```
193
+
194
+ 也可以用环境变量提供 token,或先通过 `adcli oceanengine auth <token>` 保存 token:
195
+
196
+ ```bash
197
+ OCEANENGINE_ACCESS_TOKEN=<token> adcli oceanengine advertiser list --json
198
+ ```
199
+
200
+ 对应 SDK/API:
201
+
202
+ - SDK: `Oauth2AdvertiserGetApi`
203
+ - API: `GET /open_api/oauth2/advertiser/get/`
204
+
205
+ ### `adcli oceanengine project list`
206
+
207
+ 通过当前仓库内的巨量引擎 Node.js SDK 拉取广告主下的项目列表,对应巨量引擎 OpenAPI 的 `project/list`。
208
+
209
+ ```bash
210
+ adcli oceanengine project list --advertiser-id <advertiser_id> --access-token <token>
211
+ adcli oceanengine project list --advertiser-id <advertiser_id> --page 1 --page-size 20
212
+ adcli oceanengine project list --advertiser-id <advertiser_id> --json
213
+ adcli oceanengine project list --advertiser-id <advertiser_id> --filtering '{"status":"PROJECT_STATUS_ALL"}'
214
+ adcli oceanengine project list --advertiser-id <advertiser_id> --filtering '{"status_first":"PROJECT_STATUS_ENABLE"}'
215
+ ```
216
+
217
+ 默认输出只包含 `project_id` 和 `name` 两列;使用 `--json` 打印完整原始响应。
218
+ 巨量接口默认不返回已删除项目;需要和 fujian 同步口径一致时,使用 `--filtering '{"status":"PROJECT_STATUS_ALL"}'` 拉取包含已删除项目的全量列表。
219
+
220
+ 对应 SDK/API:
221
+
222
+ - SDK: `ProjectListV30Api`
223
+ - API: `GET /open_api/v3.0/project/list/`
224
+
225
+ ### `adcli oceanengine promotion list`
226
+
227
+ 通过当前仓库内的巨量引擎 Node.js SDK 拉取广告主下的广告列表,对应巨量引擎 OpenAPI 的 `promotion/list`。
228
+
229
+ ```bash
230
+ adcli oceanengine promotion list --advertiser-id <advertiser_id> --access-token <token>
231
+ adcli oceanengine promotion list --advertiser-id <advertiser_id> --project-id <project_id>
232
+ adcli oceanengine promotion list --advertiser-id <advertiser_id> --project-id <project_id> --json
233
+ adcli oceanengine promotion list --advertiser-id <advertiser_id> --fields promotion_id,name,status_first
234
+ adcli oceanengine promotion list --advertiser-id <advertiser_id> --filtering '{"status_first":"PROMOTION_STATUS_ENABLE"}'
235
+ ```
236
+
237
+ 默认输出只包含 `promotion_id` 和 `name` 两列;使用 `--json` 打印完整原始响应。
238
+
239
+ 对应 SDK/API:
240
+
241
+ - SDK: `PromotionListV30Api`
242
+ - API: `GET /open_api/v3.0/promotion/list/`
243
+
244
+ ### `adcli tencent-ads auth`
245
+
246
+ 保存腾讯广告 access token。保存后,腾讯广告相关命令可以不再重复传 `--access-token`。
247
+
248
+ ```bash
249
+ adcli tencent-ads auth <token>
250
+ ```
251
+
252
+ token 会按 CLI 缓存处理,保存到 AdCLI 缓存目录下的 `tencent-ads.json`。macOS 默认路径:
253
+
254
+ ```text
255
+ ~/Library/Caches/adcli/tencent-ads.json
256
+ ```
257
+
258
+ token 优先级:
259
+
260
+ 1. `--access-token`
261
+ 2. `TENCENT_ADS_ACCESS_TOKEN`
262
+ 3. `adcli tencent-ads auth <token>` 保存的本地 token
263
+
264
+ ### `adcli tencent-ads advertiser list`
265
+
266
+ 通过当前仓库内的腾讯广告 Node.js SDK 拉取 BM/管家账号下的账号列表。
267
+ 默认输出 `account_id` 和 `name` 两列;需要完整响应时加 `--json`。
268
+
269
+ ```bash
270
+ adcli tencent-ads advertiser list --access-token <token>
271
+ adcli tencent-ads advertiser list --json
272
+ adcli tencent-ads advertiser list --fields account_id,corporation_name,is_bid,is_mp,is_adx,comment_list
273
+ ```
274
+
275
+ 这个命令对齐 fujian 的广告主同步逻辑,默认调用 `organization_account_relation/get`,不是 `advertiser/get`。
276
+
277
+ 对应 SDK/API:
278
+
279
+ - SDK: `api/v3.OrganizationAccountRelationApi`
280
+ - API: `GET /organization_account_relation/get`
281
+
282
+ ### `adcli tencent-ads advertiser get`
283
+
284
+ 通过当前仓库内的腾讯广告 Node.js SDK 拉取单个账号详情,对应腾讯广告 OpenAPI 的 `advertiser/get`。
285
+
286
+ ```bash
287
+ adcli tencent-ads advertiser get --account-id <account_id> --access-token <token>
288
+ adcli tencent-ads advertiser get --account-id <account_id> --json
289
+ adcli tencent-ads advertiser get --account-id <account_id> --fields account_id,account_name
290
+ ```
291
+
292
+ 对应 SDK/API:
293
+
294
+ - SDK: `api/v3.AdvertiserApi`
295
+ - API: `GET /advertiser/get`
296
+
297
+ ### `adcli tencent-ads adgroup list`
298
+
299
+ 通过当前仓库内的腾讯广告 Node.js SDK 拉取账号下的营销单元列表,对应腾讯广告 v3 API 的 `adgroups/get`。
300
+
301
+ ```bash
302
+ adcli tencent-ads adgroup list --account-id <account_id> --access-token <token>
303
+ adcli tencent-ads adgroup list --account-id <account_id> --page 1 --page-size 20
304
+ adcli tencent-ads adgroup list --account-id <account_id> --json
305
+ adcli tencent-ads adgroup list --account-id <account_id> --fields adgroup_id,adgroup_name
306
+ adcli tencent-ads adgroup list --account-id <account_id> --filtering '{"configured_status":"AD_STATUS_NORMAL"}'
307
+ ```
308
+
309
+ `--advertiser-id` 可作为 `--account-id` 的别名。默认输出只包含 `adgroup_id` 和 `name` 两列;使用 `--json` 打印完整原始响应。资源过滤统一传 `--filtering` JSON。
310
+
311
+ 对应 SDK/API:
312
+
313
+ - SDK: `api/v3.AdgroupsApi`
314
+ - API: `GET /v3.0/adgroups/get`
315
+
316
+ ### `adcli tencent-ads dynamic-creative list`
317
+
318
+ 通过当前仓库内的腾讯广告 Node.js SDK 拉取账号下的创意列表,对应腾讯广告 v3 API 的 `dynamic_creatives/get`。
319
+
320
+ ```bash
321
+ adcli tencent-ads dynamic-creative list --account-id <account_id> --access-token <token>
322
+ adcli tencent-ads dynamic-creative list --account-id <account_id> --page 1 --page-size 20
323
+ adcli tencent-ads dynamic-creative list --account-id <account_id> --json
324
+ adcli tencent-ads dynamic-creative list --account-id <account_id> --fields dynamic_creative_id,dynamic_creative_name
325
+ adcli tencent-ads dynamic-creative list --account-id <account_id> --filtering '{"adgroup_id":"<adgroup_id>"}'
326
+ ```
327
+
328
+ `--advertiser-id` 可作为 `--account-id` 的别名。默认输出只包含 `dynamic_creative_id` 和 `name` 两列;使用 `--json` 打印完整原始响应。资源过滤统一传 `--filtering` JSON。
329
+
330
+ 对应 SDK/API:
331
+
332
+ - SDK: `api/v3.DynamicCreativesApi`
333
+ - API: `GET /v3.0/dynamic_creatives/get`
334
+
118
335
  ## 采集命令
119
336
 
120
337
  ### `bun run discover:sources`
121
338
 
122
- 从 collection recipe 入口发现文档列表,生成 collection manifest
339
+ 从 collection recipe 入口发现文档列表,生成 collection manifest。一个 recipe 文件对应一个平台,多个发现来源放在顶层 `sources` 数组里。
123
340
 
124
341
  ```bash
125
342
  bun run discover:sources recipes/oceanengine-open-platform-docs.json
@@ -129,16 +346,51 @@ bun run discover:sources recipes/oceanengine-open-platform-docs.json
129
346
 
130
347
  - `recipes/{platform}-*.json`
131
348
 
349
+ 配置示例:
350
+
351
+ ```json
352
+ {
353
+ "platform": "oceanengine",
354
+ "sources": [
355
+ {
356
+ "url": "https://open.oceanengine.com/labels/7/docs/1839621283557572",
357
+ "discover": {
358
+ "mode": "playwright",
359
+ "link_patterns": ["/labels/7/docs/"],
360
+ "wait_for": "body",
361
+ "max_items": "all"
362
+ }
363
+ },
364
+ {
365
+ "url": "https://bytedance.larkoffice.com/docx/BH6zdu3j2o9hiGxr4oucedjFnGb",
366
+ "discover": {
367
+ "link_patterns": ["https://open.oceanengine.com/labels/7/docs/"],
368
+ "max_items": "all"
369
+ }
370
+ }
371
+ ]
372
+ }
373
+ ```
374
+
375
+ 飞书/Lark 文档 URL 会自动按 `lark_doc` 来源处理,只把飞书文档作为 URL 来源;实际采集正文时仍采集 `link_patterns` 匹配到的官方文档地址。
376
+
377
+ `lark_doc` 来源依赖 `lark-cli` 读取飞书文档内容。项目已把 `@larksuite/cli` 放在 devDependencies,`bun install` 后会安装本地 `lark-cli`。首次使用前需要完成飞书配置和授权:
378
+
379
+ ```bash
380
+ bunx lark-cli config init --new
381
+ bunx lark-cli auth login --recommend
382
+ ```
383
+
132
384
  输出:
133
385
 
134
- - `data/sources/{platform}/_collections/{collection_id}/manifest.json`
386
+ - `data/sources/{platform}/_collections/manifest.json`
135
387
 
136
388
  ### `bun run ingest:collection`
137
389
 
138
390
  按 collection manifest 批量采集文档。
139
391
 
140
392
  ```bash
141
- bun run ingest:collection data/sources/oceanengine/_collections/oceanengine_open_platform_docs/manifest.json
393
+ bun run ingest:collection data/sources/oceanengine/_collections/manifest.json
142
394
  ```
143
395
 
144
396
  支持参数:
@@ -172,6 +424,7 @@ bun run ingest:source recipes/some-single-source.json
172
424
  ### `bun run build:llms`
173
425
 
174
426
  把 `data/sources/` 编译成 `public/` 静态文档包。
427
+ 如果平台存在 `data/sources/{platform}/_collections/manifest.json`,全量构建只发布该 manifest 中的 source,并清理 `public/{platform}/docs/` 下不在当前 source 集合里的历史 Markdown。
175
428
 
176
429
  ```bash
177
430
  bun run build:llms all
@@ -187,6 +440,20 @@ bun run build:llms oceanengine
187
440
  - `public/{platform}/manifest.json`
188
441
  - `public/{platform}/docs/{doc_id}.md`
189
442
 
443
+ ### `bun run deploy:cloudflare`
444
+
445
+ 校验 `public/` 后发布到 Cloudflare Pages 的 `adcli` 项目。
446
+
447
+ ```bash
448
+ CLOUDFLARE_API_TOKEN=<token> bun run deploy:cloudflare
449
+ ```
450
+
451
+ 实际执行:
452
+
453
+ ```bash
454
+ bun run verify:public && bunx wrangler pages deploy public --project-name adcli --branch main
455
+ ```
456
+
190
457
  ### `bun run build:search-index`
191
458
 
192
459
  只基于当前 `public/` 重新生成搜索索引。
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@jiangzhx/adcli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for searching hosted advertising platform API docs.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.10",
7
+ "workspaces": [
8
+ "packages/*"
9
+ ],
7
10
  "homepage": "https://github.com/jiangzhx/adcli#readme",
8
11
  "repository": {
9
12
  "type": "git",
@@ -29,18 +32,37 @@
29
32
  "discover:sources": "bun scripts/discover-sources.ts",
30
33
  "ingest:collection": "bun scripts/ingest-collection.ts",
31
34
  "ingest:source": "bun scripts/ingest-source.ts",
35
+ "ingest:url": "bun scripts/ingest-url.ts",
32
36
  "rebuild:source-blocks": "bun scripts/rebuild-source-blocks.ts",
33
37
  "build:llms": "bun scripts/build-llms.ts",
34
38
  "build:search-index": "bun scripts/build-search-index.ts",
35
39
  "verify:public": "bun scripts/verify-public.ts",
40
+ "deploy:cloudflare": "bun run verify:public && bunx wrangler pages deploy public --project-name adcli --branch main",
36
41
  "adcli": "bun src/cli.ts",
37
42
  "prepack": "bun run build:cli",
38
- "test": "bun test tests/**/*.test.ts",
43
+ "test": "bun test tests",
44
+ "test:all": "bun run test && bun run sdk:test && bun run codegen:test",
39
45
  "typecheck": "tsc --noEmit",
46
+ "typecheck:all": "bun run typecheck && bun run sdk:typecheck && bun run codegen:typecheck",
47
+ "sdk:oceanengine:test": "bun run --cwd packages/oceanengine-ad-open-sdk test",
48
+ "sdk:oceanengine:typecheck": "bun run --cwd packages/oceanengine-ad-open-sdk typecheck",
49
+ "sdk:tencent-ads:test": "bun run --cwd packages/tencent-ads-marketing-api-sdk test",
50
+ "sdk:tencent-ads:typecheck": "bun run --cwd packages/tencent-ads-marketing-api-sdk typecheck",
51
+ "sdk:test": "bun run sdk:oceanengine:test && bun run sdk:tencent-ads:test",
52
+ "sdk:typecheck": "bun run sdk:oceanengine:typecheck && bun run sdk:tencent-ads:typecheck",
53
+ "codegen:oceanengine:generate": "bun run --cwd packages/codegen generate:oceanengine",
54
+ "codegen:oceanengine:generate:go": "bun run --cwd packages/codegen generate:oceanengine:go",
55
+ "codegen:oceanengine:test": "bun run --cwd packages/codegen test:oceanengine",
56
+ "codegen:tencent-ads:generate": "bun run --cwd packages/codegen generate:tencent-ads",
57
+ "codegen:tencent-ads:generate:go": "bun run --cwd packages/codegen generate:tencent-ads:go",
58
+ "codegen:tencent-ads:test": "bun run --cwd packages/codegen test:tencent-ads",
59
+ "codegen:test": "bun run --cwd packages/codegen test",
60
+ "codegen:typecheck": "bun run --cwd packages/codegen typecheck",
40
61
  "lint": "eslint"
41
62
  },
42
63
  "devDependencies": {
43
64
  "@eslint/js": "^9.39.4",
65
+ "@larksuite/cli": "^1.0.66",
44
66
  "@types/node": "^20",
45
67
  "crawlee": "^3.16.0",
46
68
  "eslint": "^9",
@@ -49,6 +71,8 @@
49
71
  "typescript-eslint": "^8.59.3"
50
72
  },
51
73
  "dependencies": {
74
+ "@jiangzhx/oceanengine-ad-open-sdk": "1.1.88-port.1",
75
+ "@jiangzhx/tencent-ads-marketing-api-sdk": "1.7.85-port.1",
52
76
  "env-paths": "^4.0.0",
53
77
  "minisearch": "^7.2.0"
54
78
  }