@jiangzhx/adcli 0.1.3 → 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.
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 入口。
@@ -138,6 +184,7 @@ token 优先级:
138
184
  ### `adcli oceanengine advertiser list`
139
185
 
140
186
  通过当前仓库内的巨量引擎 Node.js SDK 拉取授权广告主列表。
187
+ 默认输出 `advertiser_id` 和 `name` 两列;需要完整响应时加 `--json`。
141
188
 
142
189
  ```bash
143
190
  adcli oceanengine advertiser list --access-token <token>
@@ -194,11 +241,102 @@ adcli oceanengine promotion list --advertiser-id <advertiser_id> --filtering '{"
194
241
  - SDK: `PromotionListV30Api`
195
242
  - API: `GET /open_api/v3.0/promotion/list/`
196
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
+
197
335
  ## 采集命令
198
336
 
199
337
  ### `bun run discover:sources`
200
338
 
201
- 从 collection recipe 入口发现文档列表,生成 collection manifest
339
+ 从 collection recipe 入口发现文档列表,生成 collection manifest。一个 recipe 文件对应一个平台,多个发现来源放在顶层 `sources` 数组里。
202
340
 
203
341
  ```bash
204
342
  bun run discover:sources recipes/oceanengine-open-platform-docs.json
@@ -208,16 +346,51 @@ bun run discover:sources recipes/oceanengine-open-platform-docs.json
208
346
 
209
347
  - `recipes/{platform}-*.json`
210
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
+
211
384
  输出:
212
385
 
213
- - `data/sources/{platform}/_collections/{collection_id}/manifest.json`
386
+ - `data/sources/{platform}/_collections/manifest.json`
214
387
 
215
388
  ### `bun run ingest:collection`
216
389
 
217
390
  按 collection manifest 批量采集文档。
218
391
 
219
392
  ```bash
220
- 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
221
394
  ```
222
395
 
223
396
  支持参数:
@@ -251,6 +424,7 @@ bun run ingest:source recipes/some-single-source.json
251
424
  ### `bun run build:llms`
252
425
 
253
426
  把 `data/sources/` 编译成 `public/` 静态文档包。
427
+ 如果平台存在 `data/sources/{platform}/_collections/manifest.json`,全量构建只发布该 manifest 中的 source,并清理 `public/{platform}/docs/` 下不在当前 source 集合里的历史 Markdown。
254
428
 
255
429
  ```bash
256
430
  bun run build:llms all
@@ -266,6 +440,20 @@ bun run build:llms oceanengine
266
440
  - `public/{platform}/manifest.json`
267
441
  - `public/{platform}/docs/{doc_id}.md`
268
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
+
269
457
  ### `bun run build:search-index`
270
458
 
271
459
  只基于当前 `public/` 重新生成搜索索引。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiangzhx/adcli",
3
- "version": "0.1.3",
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",
@@ -32,29 +32,37 @@
32
32
  "discover:sources": "bun scripts/discover-sources.ts",
33
33
  "ingest:collection": "bun scripts/ingest-collection.ts",
34
34
  "ingest:source": "bun scripts/ingest-source.ts",
35
+ "ingest:url": "bun scripts/ingest-url.ts",
35
36
  "rebuild:source-blocks": "bun scripts/rebuild-source-blocks.ts",
36
37
  "build:llms": "bun scripts/build-llms.ts",
37
38
  "build:search-index": "bun scripts/build-search-index.ts",
38
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",
39
41
  "adcli": "bun src/cli.ts",
40
42
  "prepack": "bun run build:cli",
41
- "test": "bun test tests/**/*.test.ts",
43
+ "test": "bun test tests",
42
44
  "test:all": "bun run test && bun run sdk:test && bun run codegen:test",
43
45
  "typecheck": "tsc --noEmit",
44
46
  "typecheck:all": "bun run typecheck && bun run sdk:typecheck && bun run codegen:typecheck",
45
47
  "sdk:oceanengine:test": "bun run --cwd packages/oceanengine-ad-open-sdk test",
46
48
  "sdk:oceanengine:typecheck": "bun run --cwd packages/oceanengine-ad-open-sdk typecheck",
47
- "sdk:test": "bun run sdk:oceanengine:test",
48
- "sdk:typecheck": "bun run sdk:oceanengine: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",
49
53
  "codegen:oceanengine:generate": "bun run --cwd packages/codegen generate:oceanengine",
50
54
  "codegen:oceanengine:generate:go": "bun run --cwd packages/codegen generate:oceanengine:go",
51
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",
52
59
  "codegen:test": "bun run --cwd packages/codegen test",
53
60
  "codegen:typecheck": "bun run --cwd packages/codegen typecheck",
54
61
  "lint": "eslint"
55
62
  },
56
63
  "devDependencies": {
57
64
  "@eslint/js": "^9.39.4",
65
+ "@larksuite/cli": "^1.0.66",
58
66
  "@types/node": "^20",
59
67
  "crawlee": "^3.16.0",
60
68
  "eslint": "^9",
@@ -63,7 +71,8 @@
63
71
  "typescript-eslint": "^8.59.3"
64
72
  },
65
73
  "dependencies": {
66
- "@jiangzhx/oceanengine-ad-open-sdk": "1.1.87-port.3",
74
+ "@jiangzhx/oceanengine-ad-open-sdk": "1.1.88-port.1",
75
+ "@jiangzhx/tencent-ads-marketing-api-sdk": "1.7.85-port.1",
67
76
  "env-paths": "^4.0.0",
68
77
  "minisearch": "^7.2.0"
69
78
  }