README.md
# Trend Research (AgentRove native agent)
`agentrove.trend-research` 0.1.4 · MIT · Node.js >= 20 · no npm dependencies
Published by AgentRove (provisional, configurable name). Package identifiers keep the agentrove prefix for compatibility.
Finds which words and two-word phrases are showing up more often in feeds you choose, by comparing a
current time window with a baseline window. Every reported term lists the URLs of the items that
mention it, so you can check the evidence yourself.
Sources: RSS 2.0, RSS 1.0 (RDF) and Atom feeds (pasted as XML or fetched over https from hosts you
list), plus the public Hacker News search API. It does **not** scrape HTML pages: if a URL returns an
HTML page, it is rejected.
## Tools
| Tool | Side effects | What it does |
| --- | --- | --- |
| `parse_feeds` | none | Parses feed XML you supply into `source_list` items (`url`, `title`, `published_at`, `excerpt`, `source_name`). |
| `fetch_feeds` | external_read | Downloads feeds over https, **only** from the exact hostnames in `allowed_hosts`. Redirects are followed manually (max 3) and every hop is re-checked; each connection goes only to an address checked at connect time (no private, loopback or link-local addresses, IPv6 forms included). HTML responses, oversized bodies and DTD entity declarations are refused. |
| `fetch_hn` | external_read | Searches Hacker News stories by date through `hn.algolia.com` and returns them as `source_list` items. `hn_points` and `hn_comments` are copied from the API response, never estimated. |
| `analyze_trends` | none | Tokenises titles (and excerpts), removes English stopwords, builds bigrams that never cross punctuation or stopwords, counts how many items in each window mention each term, applies `min_count`, and computes a smoothed, volume-normalised change ratio. Returns a `trend_report`. |
### How the numbers are computed
- `count`: number of distinct items (deduplicated by URL) in the current window mentioning the term.
- `baseline_count`: the same in the baseline window.
- `change = ((count + 1) / (current_items + 1)) / ((baseline_count + 1) / (baseline_items + 1))`.
Above 1 means a larger share of items mention the term now.
- `status`: `new` (absent from baseline), `rising` (change >= 1.5), `steady`, `falling` (<= 0.67).
By default only `new` and `rising` terms are reported; pass `"direction": "all"` for everything.
- A single word is dropped when it only appears inside a reported phrase with the same count.
- Regular plurals are counted with their singular ("server" and "servers", "library" and
"libraries" are one term). The term shows the wording most items used and `variants` lists the
other spellings. Pass `"merge_plurals": false` to count them separately.
These counts describe the feeds you supplied. They are not a measure of overall popularity.
## Usage (Node CLI)
```sh
node bin/cli.js --help
# Fetch two feeds (hosts must be listed explicitly)
node bin/cli.js fetch_feeds --json '{"urls":["https://blog.example.com/feed.xml"],"allowed_hosts":["blog.example.com"]}' > items.json
# Hacker News stories mentioning "vector database" in a date range
node bin/cli.js fetch_hn --json '{"query":"vector database","from":"2026-03-01T00:00:00Z","to":"2026-03-15T00:00:00Z","max_hits":200}'
# Trend report: build an input file with the items and two windows, then run
node bin/cli.js analyze_trends --input trends-input.json
```
`trends-input.json` example:
```json
{
"items": [{ "url": "https://blog.example.com/a", "title": "Vector database benchmarks", "published_at": "2026-03-10T12:00:00Z" }],
"baseline": { "start": "2026-03-01T00:00:00Z", "end": "2026-03-08T00:00:00Z" },
"current": { "start": "2026-03-08T00:00:00Z", "end": "2026-03-15T00:00:00Z" },
"min_count": 3
}
```
Without `baseline`/`current`, the current window is the last `window_days` (default 7) before now
and the baseline is the window of the same length just before it.
On Windows PowerShell, prefer `--input file.json` over `--json`.
## Use as an MCP server
```sh
claude mcp add trend-research -- node /absolute/path/to/trend-research/bin/mcp.js
```
Generic MCP client config:
```json
{ "mcpServers": { "trend-research": { "command": "node", "args": ["/absolute/path/to/trend-research/bin/mcp.js"] } } }
```
`claude-code/SKILL.md` is a Claude Code skill that drives the CLI.
## Testing status
Tested with Node.js (Vitest: `tests/trend-research.test.ts` with fixture feeds and an injected fake
`fetch`, and `tests/netguard.test.ts` for the IPv6 address checks and connect-time pinning with fake
resolvers; no real network). This version (0.1.4) has **not yet been verified inside Claude Code** or
any other MCP client by AgentRove.
## Limitations
- English stopwords and Unicode-aware tokenisation only. Apart from regular plurals there is no
stemming or lemmatisation, so "deploy" and "deployment" are separate terms, and irregular
plurals ("indices") are not merged.
- Hostnames must be ASCII (use punycode for internationalised domains).
- Feeds that declare XML entities in a DTD are rejected. Encodings other than UTF-8 are decoded as
UTF-8.
- `fetch_hn` returns at most one page (up to 1,000 hits) per call.
- Respect each feed's and API's terms and rate limits. Feeds are meant for syndication, but some
publishers restrict reuse of their content.