@tvbs-ai/news-rd 0.2.0 → 0.3.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 +25 -4
- package/dist/cli.js +61 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ TVBS News Rundown AI CLI — query rundowns, news candidates, Google Trends, and
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install -g @tvbs-ai/news-rd
|
|
9
|
-
# or
|
|
9
|
+
# or run directly
|
|
10
10
|
npx @tvbs-ai/news-rd --help
|
|
11
11
|
```
|
|
12
12
|
|
|
@@ -25,6 +25,7 @@ news-rd <group> <command> [args] [options]
|
|
|
25
25
|
| `news` | 候選新聞與趨勢關鍵字 |
|
|
26
26
|
| `prompt` | Prompt 模板、變數與編譯 |
|
|
27
27
|
| `token` | JWT Token 管理 |
|
|
28
|
+
| `completion` | Shell auto-completion |
|
|
28
29
|
|
|
29
30
|
### Examples
|
|
30
31
|
|
|
@@ -55,7 +56,8 @@ news-rd prompt compile 2026-03-10 0600
|
|
|
55
56
|
| `--base-url URL` | API base URL | `https://news-rundown.tvbs.ai` |
|
|
56
57
|
| `--token TOKEN` | JWT token (or `RD_TOKEN` env) | — |
|
|
57
58
|
| `--json` | Raw JSON output | — |
|
|
58
|
-
| `--
|
|
59
|
+
| `--version, -v` | Show version | — |
|
|
60
|
+
| `--help, -h` | Show help | — |
|
|
59
61
|
|
|
60
62
|
### Environment Variables
|
|
61
63
|
|
|
@@ -64,14 +66,33 @@ news-rd prompt compile 2026-03-10 0600
|
|
|
64
66
|
| `RD_BASE_URL` | API base URL |
|
|
65
67
|
| `RD_TOKEN` | JWT authentication token |
|
|
66
68
|
|
|
69
|
+
### Shell Completion
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Bash
|
|
73
|
+
news-rd completion bash >> ~/.bashrc && source ~/.bashrc
|
|
74
|
+
|
|
75
|
+
# Zsh
|
|
76
|
+
news-rd completion zsh >> ~/.zshrc && source ~/.zshrc
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Update
|
|
80
|
+
|
|
81
|
+
The CLI automatically checks for new versions and shows a hint after command output. To update:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install -g @tvbs-ai/news-rd@latest
|
|
85
|
+
```
|
|
86
|
+
|
|
67
87
|
## Requirements
|
|
68
88
|
|
|
69
89
|
- Node.js >= 18 (uses built-in fetch)
|
|
70
90
|
- A running TVBS News Rundown AI server
|
|
71
91
|
|
|
72
|
-
##
|
|
92
|
+
## Documentation
|
|
73
93
|
|
|
74
|
-
|
|
94
|
+
- [使用教學](../../docs/cli-guide.md) — 完整的操作教學(中文)
|
|
95
|
+
- [發佈指南](../../docs/cli-publishing.md) — 版本更新與 npm 發佈流程
|
|
75
96
|
|
|
76
97
|
## License
|
|
77
98
|
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
var CLI_VERSION = "0.
|
|
4
|
+
var CLI_VERSION = "0.3.0";
|
|
5
5
|
var rawArgs = process.argv.slice(2);
|
|
6
6
|
function parseArgs() {
|
|
7
7
|
const options = {
|
|
@@ -35,6 +35,12 @@ function parseArgs() {
|
|
|
35
35
|
options.limit = rawArgs[++i];
|
|
36
36
|
break;
|
|
37
37
|
case "--version":
|
|
38
|
+
if (!group) {
|
|
39
|
+
console.log(`@tvbs-ai/news-rd v${CLI_VERSION}`);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
options.version = rawArgs[++i];
|
|
43
|
+
break;
|
|
38
44
|
case "-v":
|
|
39
45
|
console.log(`@tvbs-ai/news-rd v${CLI_VERSION}`);
|
|
40
46
|
process.exit(0);
|
|
@@ -337,14 +343,24 @@ async function handleRundown(command, positional, options) {
|
|
|
337
343
|
`);
|
|
338
344
|
printTable(items.map((item, i) => {
|
|
339
345
|
const newsItem = item.news_item;
|
|
346
|
+
const scoring = newsItem?.scoring || {};
|
|
347
|
+
const bonus = scoring.rundown_bonus || {};
|
|
340
348
|
return {
|
|
341
349
|
"#": item.sequence ?? i + 1,
|
|
342
350
|
type: item.item_type,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
351
|
+
slug: newsItem?.slug ?? "-",
|
|
352
|
+
category: newsItem?.category ?? "-",
|
|
353
|
+
content_type: newsItem?.content_type ?? "-",
|
|
354
|
+
final: newsItem ? scoring.rundown_final_score?.toFixed?.(1) ?? "-" : "-",
|
|
355
|
+
summary: newsItem ? scoring.summary_score?.toFixed?.(1) ?? "-" : "-",
|
|
356
|
+
visual: newsItem ? scoring.visual_score?.toFixed?.(1) ?? "-" : "-",
|
|
357
|
+
trends: newsItem ? bonus.google_trends_score ?? 0 : "-",
|
|
358
|
+
excl: newsItem ? bonus.exclusivity_score ?? 0 : "-",
|
|
359
|
+
radar: newsItem ? bonus.trending_keywords_score ?? 0 : "-",
|
|
360
|
+
topic: newsItem ? bonus.featured_topic_score ?? 0 : "-",
|
|
361
|
+
title: newsItem ? String(newsItem.title ?? "").substring(0, 40) : item.placeholder?.caption ?? "-"
|
|
346
362
|
};
|
|
347
|
-
}), ["#", "type", "
|
|
363
|
+
}), ["#", "type", "slug", "category", "content_type", "final", "summary", "visual", "trends", "excl", "radar", "topic", "title"]);
|
|
348
364
|
return;
|
|
349
365
|
}
|
|
350
366
|
case "history": {
|
|
@@ -385,13 +401,23 @@ async function handleNews(command, positional, options) {
|
|
|
385
401
|
}
|
|
386
402
|
console.log(`Statistics: total=${data.statistics.total}, with_slug=${data.statistics.with_slug}, without_slug=${data.statistics.without_slug}
|
|
387
403
|
`);
|
|
388
|
-
printTable(data.candidates.map((c) =>
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
404
|
+
printTable(data.candidates.map((c) => {
|
|
405
|
+
const bonus = c.bonus_scoring || {};
|
|
406
|
+
return {
|
|
407
|
+
slug: c.slug || "-",
|
|
408
|
+
category: c.category,
|
|
409
|
+
content_type: c.content_type || "-",
|
|
410
|
+
publish_time: c.publish_time ? String(c.publish_time).substring(0, 16) : "-",
|
|
411
|
+
final: c.final_score?.toFixed(1),
|
|
412
|
+
summary: c.summary_score?.toFixed(1) ?? "-",
|
|
413
|
+
visual: c.visual_score?.toFixed(1) ?? "-",
|
|
414
|
+
trends: bonus.google_trends_score ?? 0,
|
|
415
|
+
excl: bonus.exclusivity_score ?? 0,
|
|
416
|
+
radar: bonus.trending_keywords_score ?? 0,
|
|
417
|
+
topic: bonus.featured_topic_score ?? 0,
|
|
418
|
+
title: String(c.title).substring(0, 40)
|
|
419
|
+
};
|
|
420
|
+
}), ["slug", "category", "content_type", "publish_time", "final", "summary", "visual", "trends", "excl", "radar", "topic", "title"]);
|
|
395
421
|
return;
|
|
396
422
|
}
|
|
397
423
|
case "trends": {
|
|
@@ -650,12 +676,34 @@ _news_rd() {
|
|
|
650
676
|
|
|
651
677
|
_news_rd "$@"`;
|
|
652
678
|
}
|
|
679
|
+
async function checkForUpdates() {
|
|
680
|
+
try {
|
|
681
|
+
const controller = new AbortController();
|
|
682
|
+
const timeout = setTimeout(() => controller.abort(), 3e3);
|
|
683
|
+
const res = await fetch(
|
|
684
|
+
"https://registry.npmjs.org/@tvbs-ai/news-rd/latest",
|
|
685
|
+
{ signal: controller.signal }
|
|
686
|
+
);
|
|
687
|
+
clearTimeout(timeout);
|
|
688
|
+
if (!res.ok) return;
|
|
689
|
+
const data = await res.json();
|
|
690
|
+
const latest = data.version;
|
|
691
|
+
if (latest && latest !== CLI_VERSION) {
|
|
692
|
+
console.error(`
|
|
693
|
+
\u65B0\u7248\u672C\u53EF\u7528: v${latest} (\u76EE\u524D v${CLI_VERSION})`);
|
|
694
|
+
console.error(` \u66F4\u65B0\u6307\u4EE4: npm install -g @tvbs-ai/news-rd@latest
|
|
695
|
+
`);
|
|
696
|
+
}
|
|
697
|
+
} catch {
|
|
698
|
+
}
|
|
699
|
+
}
|
|
653
700
|
async function main() {
|
|
654
701
|
const { group, command, positional, options } = parseArgs();
|
|
655
702
|
if (!group) {
|
|
656
703
|
showHelp();
|
|
657
704
|
process.exit(0);
|
|
658
705
|
}
|
|
706
|
+
const updateCheck = checkForUpdates();
|
|
659
707
|
try {
|
|
660
708
|
switch (group) {
|
|
661
709
|
case "config":
|
|
@@ -685,5 +733,6 @@ async function main() {
|
|
|
685
733
|
console.error(error instanceof Error ? error.message : String(error));
|
|
686
734
|
process.exit(1);
|
|
687
735
|
}
|
|
736
|
+
await updateCheck;
|
|
688
737
|
}
|
|
689
738
|
main();
|