# Event Alerter Cron Job Prompt

This is the prompt for the recurring cron job that fires every 5 minutes and
detects macro-book calendar events that ended in the last 50-70 minutes.
For each, it generates a brief expert analysis, sends a Telegram message
to the user, and writes a post-event review file in `03-research/event/`.

## When this job runs

Every 5 minutes via `cronjob`. The job is self-contained — no memory of
previous runs. State is persisted in `07-calendar/alerted.log` (one
event ID per line, ISO-timestamp + ID).

## What to do

1. **Detect new events.** Run:
   ```
   cd ~/Obsidian-Macro && python3 scripts/event_alerter.py --include-reaction
   ```
   This returns JSON. If `alerts` is empty, exit immediately — do not
   send any message, do not write any file. The job is done.

2. **For each event in the alerts array:**
   - Note the `id`, `summary`, `dtstart_utc` (event time in UTC),
     `tier`, `source_url`, and pre-fetched `reaction` data (price moves
     in the 1h window).
   - Fetch the **actual print** of the event. For Tier 1 events, use
     `web_extract` or `curl` against the `source_url` if it points to a
     press release / statement / data page. Common sources:
     - federalreserve.gov (FOMC statements)
     - bls.gov/news.release (CPI, NFP, PCE, retail)
     - ecb.europa.eu (ECB rate decisions)
     - snb.ch (SNB)
     - boj.or.jp (BoJ)
     - stats.gov.cn (China NBS)
   - If you can't get a precise actual, write "actual: pending" and
     continue with the analysis based on the market reaction alone.
   - Fetch consensus / prior if available from the same source or
     secondary sources.

3. **Compose a brief, expert, direct analysis.** Keep it under 250 words
   for the Telegram message. Structure:
   - **Headline (1 line):** what happened
   - **Actual vs consensus (1 line):** direction + magnitude
   - **Market reaction (1-2 lines):** which tickers moved, how much,
     in what direction
   - **What this means (2-3 sentences):** regime implication, what the
     market is now pricing
   - **What to watch next (1 sentence):** the next catalyst

   Direct, peer-level tone. No fluff. No AI tells. No "passionate", no
   "synergy", no "dynamic". State numbers, not feelings.

4. **Send to Telegram.** Use the `send_message` tool with target
   `telegram` (the home channel). One message per event. The message
   should be plain text, no markdown (Telegram renders it as-is).
   Include the event ID at the end for cross-reference: `[event: <id>]`

5. **Write post-event review file.** Path:
   `~/Obsidian-Macro/03-research/event/<id>-review.md`
   Use the template at `03-research/event/_template.md`. Fill in the
   actual print, market reaction (from the JSON), and the expert take.
   The user's assessment checklist at the bottom of the template is
   for the user to fill in — leave it unchecked.

6. **Mark events as alerted.** Run:
   ```
   cd ~/Obsidian-Macro && python3 scripts/event_alerter.py --mark
   ```
   This appends the event IDs to `07-calendar/alerted.log` so the
   next cron tick doesn't re-alert.

## Tools to use

- `terminal` — run the detector scripts
- `web_extract` or `web_search` — fetch actual prints from source URLs
- `send_message` — Telegram
- `read_file` / `write_file` — review file I/O
- `patch` — fill in the review template

## Important constraints

- **No LLM tells.** Direct prose, numbers, no preamble.
- **No events = no message.** Don't send a "no events today" Telegram.
- **One Telegram message per event.** Don't bundle.
- **Idempotent.** If the detector returns an empty list, do nothing.
- **Quiet on failure.** If web fetch fails, write "actual: pending" and
  continue. Don't send an error Telegram.
- **No fabrication.** If you can't verify a number, mark it "pending".
  Never invent a consensus or actual.

## How to start this cron job

```
hermes cronjob create \
  --name "macro-book-event-alerter" \
  --schedule "*/5 * * * *" \
  --prompt "$(cat ~/Obsidian-Macro/scripts/prompts/event_alerter.txt)" \
  --enabled-toolsets "terminal,file,web,send_message" \
  --deliver "local"  # don't deliver anything to Telegram; the analysis itself sends
```

The `--deliver local` is important: we don't want the LLM's prose to be
delivered as a separate message. The agent's job is to call `send_message`
explicitly per event; the cron delivery channel is just for the watchdog's
own status (errors, etc.) which should be silent.
