Skip to content
mhingstonPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Newsweave

Newsweave turns a list of RSS/Atom feeds into one curated daily email. It fetches the feeds itself hourly, expands configured digest feeds into child links, fetches content through Fabric-supported extractors, summarises items with one text model request, groups related coverage, selects at most 50 stories with no more than 5 stories from one feed, and sends the result through Resend.

State lives in a local SQLite database (DATABASE_PATH, default ./data/newsweave.db). Feeds are fetched directly over HTTP; there are no external services to run.

Fabric is installed separately and should be kept current with the official installer. The verified host version is currently 1.4.467.

Commands

newsweave feeds import  Load feeds.json (FEEDS_FILE) into the feeds table
newsweave feeds add-local-rss --id 9001 --title "..." --path /abs/feed.xml
newsweave feeds list    Show configured feeds
newsweave ingest [--feed-limit N]  Fetch enabled feeds and queue new items
newsweave process      Fetch and summarise pending items
newsweave publish      Curate and send the daily email
newsweave engagement   Poll Resend for digest-level opens and clicks
newsweave retention    Delete items, entries and digests older than the retention window, then VACUUM
newsweave doctor       Check configuration and integrations
newsweave candidates   Report likely digest/fan-out feeds for review
newsweave metrics      Show item and latest-digest counts
newsweave downvote URL  Mark an item as not interested for future editions

Initial configuration

Copy .env.example to .env and set the credentials. Then import the feed list once:

npm run build
node dist/cli.js feeds import          # reads FEEDS_FILE (default ./feeds.json)
node dist/cli.js feeds add-local-rss --id 9001 --title "Resend Newsletters" \
  --path /opt/resend-newsletters/data/feed.xml
DATABASE_PATH=./data/newsweave.db
FEEDS_FILE=./feeds.json
FEED_FETCH_TIMEOUT_MS=20000
PROCESS_MAX_ITEMS_PER_RUN=10
AI_BASE_URL=https://api.openai.com/v1
AI_API_KEY=...
AI_MODEL=...
RESEND_API_KEY=...
EMAIL_FROM=Newsweave <[email protected]>
EMAIL_TO=[email protected]
TIMEZONE=Europe/London
PUBLICATION_TIME=06:00
RETENTION_DAYS=7
FABRIC_BIN=fabric
FANOUT_FEED_IDS=1,230,228,179

feeds.json is the feed list (106 feeds). Feed IDs are stable, so the FANOUT_* settings still apply. The Resend newsletter feed (ID 9001) is added separately with feeds add-local-rss. ACM Queue (251) is disabled because its URL returns HTTP 404; re-running feeds import does not change that flag.

FANOUT_FEED_IDS and FANOUT_FEED_TITLES are comma-separated. Feed titles are matched case-insensitively. Configure a feed as fan-out only after checking the candidate report; ordinary feed entries remain first-class items.

Mixed feeds — digests some days, essays or announcements on others — can be listed in FANOUT_CANDIDATE_FEED_IDS / FANOUT_CANDIDATE_FEED_TITLES instead. Every entry from a candidate feed is tested individually and only becomes fan-out when it carries at least FANOUT_MIN_LINKS outbound article links (default 5) spanning at least FANOUT_MIN_DOMAINS distinct domains (default 3); everything else stays an ordinary item. Feeds on neither list are never expanded, so link-heavy but non-digest blogs remain safe.

Curation

process only summarises items whose source entry was published today (in TIMEZONE), and handles at most PROCESS_MAX_ITEMS_PER_RUN items per run (default 10). This caps paid AI calls while the backlog is worked off. Older pending items stay pending and are never summarised.

Newsweave processes every eligible item, then groups related coverage before selecting what appears in the email. Selection is ranked by the story-group score, capped at 50 story groups per edition, and capped at 5 selected groups per feed. Items reviewed but suppressed are recorded as excluded from that digest and remain available for the 7-day retention period.

The ranking policy and safe adjustment points are documented in docs/curation-policy.md.

An optional typed decision layer can be enabled with DECISION_MODEL_ENABLED=true. It uses @mhingston5/jev-cli, so provider selection remains independent of Newsweave: TypeSafe, OpenRouter, Vercel, Cloudflare, or any compatible /v1/systemone service can be selected through the normal JEV_* / provider credential environment variables.

When enabled, the decision layer re-ranks the text model's story groups using explicit editorial judgments and, by default, performs a final semantic same-event check. If two groups from different sources are judged to describe the same specific event above DECISION_MODEL_DUPLICATE_THRESHOLD, the lower ranked group is merged into the higher ranked group so its source links are preserved rather than emitted as a duplicate story. The semantic dedupe guard only compares groups with distinct source provenance; same-publisher follow-up coverage is left separate.

Decision calls fail open: ranking keeps the existing score and dedupe keeps groups separate when the decision service is unavailable. A run-level budget (default 60 seconds) and a circuit breaker after two consecutive failures stop provider outages from multiplying per-call timeouts across the whole edition.

Engagement polling is supported without webhooks: Newsweave stores each Resend email ID and the engagement command polls Resend's Email Metrics API for digest-level opens and clicks. These metrics are observational for now; transactional-email metrics do not provide per-story link breakdowns for these sends.

To exclude a specific item from future editions, use its title URL:

npm start -- downvote https://example.com/story

Downvotes affect future editions only; they do not rewrite emails already sent. Simon Willison blog posts titled Release: ... are automatically downvoted before processing and publication, excluding them from future editions.

YouTube Shorts are excluded at ingestion and processing time. Standard YouTube videos remain supported through Fabric/yt-dlp extraction. Videos with missing placeholder titles, bot-check pages, or metadata-only responses are also excluded rather than summarised.

Scheduling

Use cron or systemd timers to run newsweave ingest and newsweave process hourly, newsweave publish at 06:00 Europe/London, and newsweave retention daily. Each command takes a named lock in the locks table (stale after one hour), so missed or overlapping invocations are safe to retry.

ingest sends conditional requests (ETag / Last-Modified); unchanged feeds return 304. Per-feed failures are recorded in feeds.last_error and do not stop the run. Entries published before the RETENTION_DAYS cutoff are skipped (counted as stale), so retention does not re-import what it just deleted. Entries without a publish date are kept. Local files (absolute paths or file:// URLs) are read from disk.

For a dry run of publish, set NEWSWEAVE_DRY_RUN=/path/to/out.html: the digest is rendered to that file and nothing is sent through Resend. See scripts/cron.example for a starting point; schedules are not installed automatically.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages