# Getting started

How a run works, the two ways to install Herald (the Docker image or from source) and the commands
you use day to day. Once it runs, pick your [categories](configuration.md#categories), an
[AI provider](providers.md), the [channels](channels.md) that receive the briefing and a
[schedule](scheduling.md). To have a coding agent do all of it for you, see
[Install with an agent](install-with-an-agent.md).

## How it works

Herald reads a few hundred sources: news sites, newsletters, and official data from BCB, IBGE,
CVM, SEC, the Fed and others. It discards most of it without spending a token, merges the same
story told by many outlets, asks a cheap model to score what is left, and has a strong model
write short, factual entries in both languages. Sources are attached by code, never invented by
the model. A typical full run with API keys costs well under US$ 1. The topics range over tech,
AI, fintech, payments, crypto, markets, economy, politics, regulation and sports, plus science,
health, climate and energy, culture and startups.

Herald is a **job, not a server**. Each run collects the last N hours of news, builds the
briefing, delivers it to the channels you enabled, records what was published and exits. You
run it once a day with a scheduler (cron, systemd, Docker, GitHub Actions).

A run with no AI over a few hundred sources (one region plus a few topics, about 7,000 items)
takes about 4 minutes on 2 vCPUs and needs about 0.8 GB of memory at its peak; an AI provider
adds the time of its calls. Most of the time goes into embedding each item once with the local
model (about 40 items a second on 2 vCPUs), so a run grows with the items your categories bring
in. The log shows each stage with its counts and duration, and a long stage shows its progress
at least every 30 seconds. If a run takes several times longer and the `embeddings: loading`
line shows more threads than the machine has CPUs (a limit Herald can't see, as on some LXC VPSes
or with Docker inside a container), set `embeddings.threads` to the CPU count
([Configuration](configuration.md#configuration-reference)). On a 1 GB machine, add swap, or set `embeddings.provider` to `none`:
ranking by keywords alone takes under a minute and about 200 MB, but is less precise.

```
06:00  scheduler starts `herald`
       fetch ~1,240 sources → normalize → drop already published → pre-filter (no LLM)
       → cluster → score (cheap model) → select (thresholds, caps, diversity)
       → write (strong model, pt-BR + en in one call) → render Markdown
       → deliver (every enabled channel: Telegram, WhatsApp, email, Slack, ...)
       → record history → exit
```

Every briefing is also saved to `data/briefings/<date>.pt-BR.md` and `.en.md`, and every run
writes a report to `data/reports/`:

```
Herald run 20261130T090002-1a2b3c  window=24h  status=ok  (America/Sao_Paulo)
funnel  fetched 4,112 → normalized 4,020 → unseen 3,870 → prefiltered 392 → clusters 268 → scored 268 → selected 30 → enriched 30
sources 3 skipped · 21 empty · 4 error · 262 ok
ai      scoring    claude-haiku-5-5        12 calls    71,204 in (48,000 cached) / 11,890 out  $0.0127
ai      enrichment claude-opus-5-5         30 calls   118,330 in (0 cached) / 24,770 out  $0.9687
total   $0.9814
```

(Illustrative numbers. Costs come from the `ai.pricing` table in your config.)

Design details: [`docs/architecture.md`](architecture.md) · Source status:
[`docs/sources-report.md`](sources-report.md) · Privacy/LGPD:
[`docs/privacy.md`](privacy.md) · Brand: [`docs/brand`](brand/README.md)

## Run the Docker image

Tagged releases publish a ready image, `ghcr.io/felipebossolani/herald`. Herald is in beta:
`:beta` is the newest beta release, and every version also has its own tag, such as
`:0.3.9-beta` (`:latest` arrives with the first stable release). Nothing to install but Docker:

```bash
mkdir -p herald/data && cd herald
docker run --rm --entrypoint cat ghcr.io/felipebossolani/herald:beta /app/config.example.json > config.json
docker run --rm --entrypoint cat ghcr.io/felipebossolani/herald:beta /app/.env.example > .env
alias herald='docker run --rm -it --user "$(id -u):$(id -g)" -v "$PWD/config.json:/app/config.json" -v "$PWD/.env:/app/.env" -v "$PWD/data:/app/data" ghcr.io/felipebossolani/herald:beta'

herald init        # pick the AI provider and categories; then put the provider's key in .env
herald --dry-run   # builds today's briefing in data/briefings/, sends nothing
herald             # real run: delivers to the enabled channels and records history
```

- `config.json` and `.env` must exist before Docker mounts them (otherwise Docker creates
  directories in their place), which is what the two `cat` lines are for. They are mounted
  read-write, so `herald init`, `herald categories` and `herald config` can save your choices.
- Mount the config at `/app/config.json`. Relative paths in it, such as `profiles.dir` and
  `sources.catalog`, start at the config file's folder, so a config mounted elsewhere does not
  find the shipped categories (`herald init` then names the folder it looked in).
- `--user "$(id -u):$(id -g)"` runs the container as you, so it can save `config.json` and
  `data/` stays yours. The image runs as any uid; without `--user` it runs as uid 1000, and when
  that user can't write a mounted file, `herald init`, `herald categories` and `herald config`
  stop with an error naming the file.
- History, briefings, run reports and the embedding model live in `data/`.
- The image works with API-key providers only; `claude-code` and `codex` need the host, where
  the CLI is signed in (see [providers](providers.md#using-a-claude-or-chatgpt-subscription-claude-code-codex)).

To build the image yourself, use `docker compose` from a clone (see [Scheduling](scheduling.md)).

## Install from source

Requires Python 3.12+ and [uv](https://docs.astral.sh/uv/).

```bash
git clone https://github.com/felipebossolani/herald && cd herald
uv sync --extra embed            # 'embed' adds local multilingual embeddings (fastembed)

uv run herald init               # onboarding: creates config.json and .env, asks provider + categories
# fill in the provider's key in .env, if it needs one (see docs/providers.md)

uv run herald --dry-run          # writes data/briefings/<date>.*.md, sends nothing, records nothing
uv run herald                    # real run: delivers to enabled channels and records history
```

`herald init` asks two questions:
- which AI provider to use, saved as `HERALD_AI_PROVIDER` in `.env`;
- which categories to follow, saved as `profiles.enabled` in `config.json`.

For scripts, pass both as flags: `herald init --provider anthropic --categories br eu-politics sports`.
The providers and their keys are in [AI providers](providers.md).

The briefing languages, the channels and the time zone are one command each:

```bash
herald config set languages en pt-BR         # written in both; the first is the primary
herald config set channels telegram slack    # these channels on, every other one off
herald config set timezone Europe/Lisbon     # an IANA name; it sets the briefing's date
```

Every channel gets all the languages ([Output languages](configuration.md#output-languages)),
and a channel's keys go in `.env` ([Channels](channels.md)).

**Zero-cost smoke test**, with no keys at all: `HERALD_AI_PROVIDER=none uv run herald --dry-run`.
Pre-filter relevance becomes the score and entries use the feed text.

## Day to day

```
herald [--config config.json] [--data-dir DIR] [--log-level INFO] run [--hours 24] [--profile ID ...] [--dry-run]
herald run --at 06:10 [--days 1-5]                           # from an hourly cron: runs only at that local time
herald init [--provider NAME] [--categories ID ...]          # onboarding
herald categories list|set|add|remove [ID ...]               # the categories you follow
herald config set languages|channels|timezone VALUE ...      # briefing languages, channels on, time zone
herald config set provider none                              # the AI provider (HERALD_AI_PROVIDER in .env)
herald --hours 6                                             # catch up on the last 6 hours
herald --version                                             # the installed version
herald history "Copom" [--days 30] [--profile br-economy]   # search past briefings, any language
herald runs [--json]                                         # recent runs: start, duration, status, dry runs marked
herald sources add URL [URL...] [--yes] [--file F]           # find the feed, AI fills the entry, confirm
herald sources validate [--only ID,ID] [--status unchecked]  # re-check feeds, update status + report
herald sources report                                        # regenerate docs/sources-report.md
herald sources health [--runs 14] [--apply]                  # flaky vs dead sources; --apply marks dead
herald subscribers add|confirm|unsubscribe|list|export|delete|prune [EMAIL|TOKEN|telegram:CHAT_ID]
herald bot telegram                                          # Telegram bot for subscribers (long polling)
herald notify preview [--channel TYPE] [--date YYYY-MM-DD] [--lang L] [--sample] [--alert]  # what each channel would send, offline
herald notify send [--channel TYPE] [--date YYYY-MM-DD] [--lang L] [--sample] [--alert]     # send it for real (release checks)
herald dev sink [--port 8787] [--secret S | --standard-webhooks-secret S | --token T] [--out DIR]  # local webhook receiver
```

Stories already published are not repeated on later days. `herald --hours 12` is shorthand for
`herald run --hours 12`.
