Via tencent-news-cli to get Tencent News content.
Core Principle: Infrastructure (installation, updates, Key configuration) is handled by scripts; the agent is only responsible for choosing subcommands and parameters — always read
helpfirst, do not hardcode.
Platform Conventions
| Platform | Script Execution Method | Example |
|---|---|---|
| macOS / Linux | sh scripts/<name>.sh |
sh scripts/cli-state.sh |
| Windows | bun scripts/<name>.ts |
bun scripts/cli-state.ts |
On Windows, first ensure
bunis available. If unavailable:powershell -c "irm bun.sh/install.ps1 | iex", after installation restart the terminal and confirmbun --version。
All script invocations below use macOS / Linux as examples; on Windows replace .sh with .ts,sh replace bun。
The CLI command itself should not depend on cli-state the returned template string; directly assemble according to platform.cliPath :
| Platform | CLI Command Template |
|---|---|
| macOS / Linux | "<cliPath>" <subcommand> [args] |
| Windows PowerShell | & "<cliPath>" <subcommand> [args] |
Phase 1: Environment Ready
When the environment is ready, skip directly to Phase 2.
1. Status Check
sh scripts/cli-state.sh
Parse the returned JSON, focusing on the following fields:
| Field | Meaning |
|---|---|
platform.cliPath |
Full CLI path; all subsequent commands use this path |
platform.cliSource |
global(user has installed globally) / local(downloaded in skill directory) / none(not found) |
cliExists |
Whether the CLI exists |
update.needUpdate |
Whether the current version needs an update |
update.error |
version Error message when the check fails |
apiKey.present |
Whether the API Key is configured |
apiKey.status |
configured / missing / error |
apiKey.error |
apikey-get Error message when execution is abnormal or output is abnormal |
2. Install CLI (cliExists is false )
cliSourceWhenglobal, skip this step.
sh scripts/install-cli.sh
If script installation fails, guide the user to install manually — see references/installation-guide.md。
3. Update CLI (update.needUpdate is true, or when the CLI prompts that the version is too old)
"<cliPath>" update
Windows PowerShell uses & "<cliPath>" update。
Always use platform.cliPath to assemble commands. If update.error is not empty, first display the error and let the user handle it.
If the update command fails, or the error message indicates that the current CLI does not support update(such as unknown command、not found、not recognized), immediately switch to running the installation script to overwrite:
sh scripts/install-cli.sh --force
Windows:
bun scripts/install-cli.ts --force
Parse the JSON returned by the installation script, and switch subsequent commands to the newly returned platform.cliPath. Only when overwrite installation also fails should you guide the user to refer to references/update-guide.md for manual handling.
4. Configure API Key (apiKey.status is not configured )
missing→ guide the user to open API Key acquisition page to obtain it themselves,do not runopen/xdg-open/startand other commands to automatically open the browsererror→ displayapiKey.error, let the user handle it first (permissions, network, CLI abnormality), then retry after handling
Set Key (command prefix uses platform.cliPath, KEY is a bare value without quotes):
"<cliPath>" apikey-set KEY
Windows PowerShell respectively uses & "<cliPath>" apikey-set KEY、& "<cliPath>" apikey-get、& "<cliPath>" apikey-clear。
Verify:"<cliPath>" apikey-get
Clear (only when the user explicitly requests it):"<cliPath>" apikey-clear
See references/env-setup-guide.md。
Phase 2: Fetch News
The CLI is updated frequently, and subcommands and arguments may change between versions.Always rely on the current
helpoutput; do not assume or memorize any subcommands.
-
Execute
helpUseplatform.cliPathto construct commands yourself: on macOS / Linux use"<cliPath>" help, on Windows PowerShell use& "<cliPath>" help。 -
Understand the intent, map to subcommands
- Single request(e.g., "show trending") → map to one subcommand
- Compound request(e.g., "show trending, finance, and military news") → break down into multiple intents, map each separately, and invoke them in sequence
- Report an issue(e.g., "report an error, the news quality is poor") → use the
feedbacksubcommand; the content must include the problem symptoms and context - If
helpcontains no matching subcommand, truthfully inform the user that it is not currently supported
-
Execute and output—present the results in the format below
Output Format
Single-type request
1. **标题文字**
来源:媒体名称
时间:发布时间
摘要内容……
[查看原文](https://…)
2. **标题文字**
来源:媒体名称
时间:发布时间
摘要内容……
[查看原文](https://…)
**来源:腾讯新闻**
Multi-type request
Group by type, with each group headed by a second-level heading indicating the category:
## 热点新闻
1. **标题文字**
...
2. **标题文字**
...
## 财经新闻
1. **标题文字**
...
2. **标题文字**
...
**来源:腾讯新闻**
General Rules
- Title:
序号. **标题**, numbering starts from 1; for multiple types, each group is numbered independently - Source:
来源:followed by the author or media name returned by the CLI; omit if this field is absent - Time:
时间:followed by the publication time returned by the CLI; omit if this field is absent - Summary: immediately below the source; omit if there is no summary field
- Original link: if there is a link, output
[查看原文](URL); if not, do not output it - Other valuable fields (publication time, tags, etc.) may be added below the source
- Separate multiple news items with a blank line
**来源:腾讯新闻**appears once at the end of all content- If a certain type fails to be fetched, explain the reason under that group and continue outputting the remaining groups
CLI Execution Failure Handling
After a CLI command fails, stop immediately; never obtain news via WebSearch or any other means as a substitute.
- If the CLI returns a non-zero exit code, times out, or the output contains permission/security errors, do not retry and do not switch methods.
- Guide the user based on the error message:
- macOS Gatekeeper(
cannot be opened、not verified) → System Settings → Privacy & Security → "Open Anyway" - Enterprise security software(
connection refused, firewall interception) → click "Trust"/"Allow" in the security prompt - Insufficient permissions(
permission denied)→chmod +x <cliPath> - Other → show the full error and ask the user to handle it
- macOS Gatekeeper(
- Retry only after the user confirms the action is complete. Even if it fails multiple times, you may only inform them that it cannot be fetched and explain why;neverfall back to other information sources.
References
- Manual installation guide for users:
references/installation-guide.md - Manual update guide for users:
references/update-guide.md - API Key acquisition and manual configuration:
references/env-setup-guide.md