腾讯新闻内容订阅
通过 tencent-news-cli 获取腾讯新闻内容。
核心原则:基础设施(安装、更新、Key 配置)交给脚本处理;智能体只负责选择子命令和参数——始终先读
help,不要硬编码。
平台约定
| 平台 | 脚本运行方式 | 示例 |
|------|------------|------|
| macOS / Linux | sh scripts/<name>.sh | sh scripts/cli-state.sh |
| Windows | bun scripts/<name>.ts | bun scripts/cli-state.ts |
Windows 需先确保
bun可用。若不可用:powershell -c "irm bun.sh/install.ps1 | iex",安装后重启终端确认bun --version。
以下所有脚本调用均以 macOS / Linux 为例,Windows 将 .sh 替换为 .ts,sh 替换为 bun。
CLI 命令本身不要依赖 cli-state 返回的模板字符串,直接根据 platform.cliPath 组装:
| 平台 | CLI 命令模板 |
|------|-------------|
| macOS / Linux | "<cliPath>" <subcommand> [args] |
| Windows PowerShell | & "<cliPath>" <subcommand> [args] |
Phase 1:环境就绪
环境已就绪时直接跳到 Phase 2。
1. 状态检查
sh scripts/cli-state.sh
解析返回的 JSON,关注以下字段:
| 字段 | 含义 |
|------|------|
| platform.cliPath | CLI 完整路径,后续所有命令使用此路径 |
| platform.cliSource | global(用户已全局安装)/ local(技能目录下载)/ none(未找到) |
| cliExists | CLI 是否存在 |
| update.needUpdate | 当前版本是否需要更新 |
| update.error | version 检查失败时的错误信息 |
| apiKey.present | API Key 是否已配置 |
| apiKey.status | configured / missing / error |
| apiKey.error | apikey-get 执行异常或输出异常时的错误信息 |
2. 安装 CLI(`cliExists` 为 `false` 时)
cliSource为global时跳过此步。
sh scripts/install-cli.sh