#!/usr/bin/env bash # daily-brief-collector.sh # No-agent data collector: fetches free public data for the daily brief. # Injected as cron context via the script= parameter. # Zero API keys needed — all sources are free/public. # # Pattern: no-agent polling script → context injection → agent curates set -euo pipefail echo "# Daily Brief Data — $(date -I 2>/dev/null || date +%Y-%m-%d)" echo "" # --- 1. Weather --- echo "## 🌤 Weather — Placerville, CA" if WEATHER=$(curl -sf "wttr.in/Placerville,CA?format=%C+%t+%w+%h&u" 2>/dev/null); then echo "Current: $WEATHER" else echo "Weather: (unavailable)" fi echo "" # --- 2. Hacker News Top Stories --- echo "## 📰 Hacker News — Top Stories" TOP_IDS=$(curl -sf "https://hacker-news.firebaseio.com/v0/topstories.json" 2>/dev/null | python3 -c " import sys, json ids = json.load(sys.stdin)[:8] for i in ids: print(i) " 2>/dev/null) if [ -n "$TOP_IDS" ]; then echo "$TOP_IDS" | while read -r ID; do ITEM=$(curl -sf "https://hacker-news.firebaseio.com/v0/item/$ID.json" 2>/dev/null) [ -n "$ITEM" ] && echo "$ITEM" | python3 -c " import sys, json d = json.load(sys.stdin) title = d.get('title', '?') url = d.get('url', 'https://news.ycombinator.com/item?id=' + str(d.get('id', ''))) score = d.get('score', 0) print(f\"- [{title}]({url}) (⬆{score})\") " 2>/dev/null || true done else echo "HN: (unavailable)" fi echo "" # --- 3. GitHub Trending (24h) --- echo "## 💻 GitHub — Trending Repos (24h)" YESTERDAY=$(date -d '2 days ago' +%Y-%m-%d 2>/dev/null || date -v-2d +%Y-%m-%d 2>/dev/null || echo "2026-06-18") curl -sf "https://api.github.com/search/repositories?q=created:>$YESTERDAY&sort=stars&order=desc&per_page=5" 2>/dev/null | python3 -c " import sys, json data = json.load(sys.stdin) items = data.get('items', []) if not items: print('No repos found in last 24h') else: for r in items: name = r['full_name'] desc = (r['description'] or 'No description')[:100] stars = r['stargazers_count'] url = r['html_url'] lang = r.get('language') or '?' print(f\"- [{name}]({url}) — {desc} ({lang}, ⭐{stars})\") " 2>/dev/null || echo "GitHub: (unavailable)" echo "" echo "---" echo "Use the data above to generate a concise daily brief (max 8 bullets). Format all links as clickable Telegram markdown. No intro or closing text."