Skip to content

quacstech/ai-digest-cli

Repository files navigation

AI Digest CLI

A Python command-line tool that reads your Gmail newsletters, scrapes configured tech news pages, and generates a personalised AI digest as a Hugo-compatible Markdown article — filtered to your interests using Claude via LangChain.

python digest.py

content/digest/digest-2026-04-19.md ready for Hugo.


How it works

  1. Gmail — searches your inbox for configured newsletter senders (last N days)
  2. Web scraper — fetches configured URLs and extracts article text
  3. LangChain + Claude — scores and summarises stories against your interest profile
  4. Hugo renderer — writes a dated Markdown article with front matter, ready to drop into your Hugo content folder

Setup

1. Clone the repo

git clone https://github.com/yourname/ai-digest-cli
cd ai-digest-cli

2. Python environment

python3 -m venv venv
source venv/bin/activate       # Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Google Cloud — Gmail credentials

You need a credentials.json file from Google Cloud. Do this once:

  1. Go to console.cloud.google.com
  2. Create a new project (e.g. ai-digest)
  3. Go to APIs & Services → Library → search Gmail API → Enable
  4. Go to APIs & Services → OAuth consent screen (or Google Auth Platform)
    • Click Get started → fill in app name + email → Audience: External
    • Under Audience, add your newsletter Gmail address as a test user
  5. Go to APIs & Services → Credentials → Create Credentials → OAuth client ID
    • Application type: Desktop app
    • Download the JSON → rename it credentials.json → place in this folder

4. Config file

cp config.example.yaml config.yaml

Edit config.yaml:

  • Add your Anthropic API key (get one at console.anthropic.com)
  • Add your newsletter sender addresses
  • Add web sources to scrape
  • Customise your interest categories

5. First run

python digest.py

On first run, a browser window opens for Gmail sign-in — sign in with your newsletter Gmail account. A token.json is saved locally. Every subsequent run is fully silent.


Usage

# Default (uses config.yaml, last 7 days)
python digest.py

# Override days
python digest.py --days 14

# Override output directory
python digest.py --output ~/Documents/digests/

# Skip Gmail (web only)
python digest.py --no-gmail

# Skip web scraping (Gmail only)
python digest.py --no-web

# Use a different config file
python digest.py --config myconfig.yaml

Project structure

ai-digest-cli/
├── digest.py              ← Entry point — run this
├── config.yaml            ← Your config (gitignored)
├── config.example.yaml    ← Template to copy
├── gmail_reader.py        ← Gmail OAuth + thread fetching
├── web_scraper.py         ← BeautifulSoup URL scraper
├── digest_chain.py        ← LangChain + Claude pipeline
├── credentials.json       ← Google OAuth credentials (gitignored)
├── token.json             ← Saved Gmail session (gitignored)
├── requirements.txt
└── README.md

Security

  • credentials.json and token.json are gitignored — never committed
  • config.yaml (contains your API key) is gitignored
  • The app only requests gmail.readonly scope — it cannot send email or modify anything
  • Your Anthropic API key is only sent to api.anthropic.com

Requirements


License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages