mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
feat(news): rank this company's news first and label each item
MSN's feed for a stock is often mostly general market news: of 10 items, ADRO, BREN and CUAN had none about the company, BBRI one, yet they were presented as the company's news. Fetch at least 50 items, label each `relevance: company` (tagged by MSN with the stock's instrument id, or naming the ticker or the company) or `market`, and return company items first, newest first, trimmed to --limit. Company names come from the quote's short and display names, best effort: MSN tags Telkom articles with its NYSE ADR, not TLKM, so names catch what tags miss. Classification stays a pure function in parse_news. Output change, intentional: news JSON gains `relevance`, the table an ABOUT column (goldens regenerated), and the get_company tool description explains the field (tools.json and the website tools page regenerated). News cache keys change so entries without the field are not reused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
parent
537b01901f
commit
1796e58105
13 changed files with 254 additions and 38 deletions
|
|
@ -837,10 +837,11 @@ pub fn print_news(items: &[NewsItem]) -> Result<(), IdxError> {
|
|||
let mut table = Table::new();
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.set_header(vec!["TITLE", "PROVIDER", "DATE", "URL"]);
|
||||
.set_header(vec!["TITLE", "ABOUT", "PROVIDER", "DATE", "URL"]);
|
||||
for item in items {
|
||||
table.add_row(vec![
|
||||
Cell::new(&item.title),
|
||||
Cell::new(item.relevance.as_str()),
|
||||
Cell::new(&item.provider),
|
||||
Cell::new(&item.published_at),
|
||||
Cell::new(truncate_url(&item.url)),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
exit: 0
|
||||
--- stdout
|
||||
[{"id":"news-1","symbol":"BBCA.JK","title":"BCA reports steady growth","url":"https://example.com/news/bca-growth","description":"BCA delivered steady quarterly growth across lending and deposits.","provider":"Contoso News","published_at":"2026-03-20T10:00:00Z","read_time_min":3}]
|
||||
[{"id":"news-1","symbol":"BBCA.JK","title":"BCA reports steady growth","url":"https://example.com/news/bca-growth","description":"BCA delivered steady quarterly growth across lending and deposits.","provider":"Contoso News","published_at":"2026-03-20T10:00:00Z","read_time_min":3,"relevance":"market"}]
|
||||
--- stderr
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
exit: 0
|
||||
--- stdout
|
||||
┌───────────────────────────┬──────────────┬──────────────────────┬─────────────────────────────────────┐
|
||||
│ TITLE ┆ PROVIDER ┆ DATE ┆ URL │
|
||||
╞═══════════════════════════╪══════════════╪══════════════════════╪═════════════════════════════════════╡
|
||||
│ BCA reports steady growth ┆ Contoso News ┆ 2026-03-20T10:00:00Z ┆ https://example.com/news/bca-growth │
|
||||
└───────────────────────────┴──────────────┴──────────────────────┴─────────────────────────────────────┘
|
||||
┌───────────────────────────┬────────┬──────────────┬──────────────────────┬─────────────────────────────────────┐
|
||||
│ TITLE ┆ ABOUT ┆ PROVIDER ┆ DATE ┆ URL │
|
||||
╞═══════════════════════════╪════════╪══════════════╪══════════════════════╪═════════════════════════════════════╡
|
||||
│ BCA reports steady growth ┆ market ┆ Contoso News ┆ 2026-03-20T10:00:00Z ┆ https://example.com/news/bca-growth │
|
||||
└───────────────────────────┴────────┴──────────────┴──────────────────────┴─────────────────────────────────────┘
|
||||
--- stderr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue