# The daily run

This is what the scheduled task does every day. No one is watching, so do not ask questions. If something fails, do as much as you can and say clearly what failed.

Before you start, read `my-briefing.md`, `my-sources.md` and `my-pronunciations.json`. If `my-briefing.md` does not exist, stop and say that setup has not been done yet (`prompts/setup.md`).

0. Check that you can reach the news: download one feed from `my-sources.md` with `curl`. If every feed is blocked, the network setting of this environment is probably limited (see `README.md`). Do not fill the show with whatever old stories a search returns. Stop and say what to change.
1. Work out today's date in the timezone in `my-briefing.md`. Use it as `YYYY-MM-DD` below.
   If today's script is already in `episodes/`, do not write a new one unless you were asked to. Record the audio if it is missing, then report.
2. Follow `prompts/1-select.md`.
3. Follow `prompts/2-analyze.md`.
4. Follow `prompts/3-script.md`.
5. Follow `prompts/4-fact-check.md`. It is a separate pass and it is required: do not record or publish until `episodes/YYYY-MM-DD.checks.md` exists and every problem in it is fixed.
6. Save the final script to `episodes/YYYY-MM-DD.txt`.
7. Save `episodes/YYYY-MM-DD.md` with the episode title, then the stories by section, each with one line on why it matters and its source links.
8. If `my-briefing.md` says audio is on, first look through the script for names and words that a voice reading that language would say wrong (foreign people, places, companies and outlets). Add each one to `my-pronunciations.json`, spelled the way it sounds in the briefing language, and commit that file with the episode. Then record it (long scripts take a while, so allow plenty of time or run it in the background):

       python3 -m pip install -r voice/requirements.txt
       python3 voice/speak.py episodes/YYYY-MM-DD.txt episodes/YYYY-MM-DD.mp3 --voice VOICE --pronunciations my-pronunciations.json

   Replace VOICE with the voice in `my-briefing.md`.
9. Commit `episodes/YYYY-MM-DD.txt`, `episodes/YYYY-MM-DD.md` and `episodes/YYYY-MM-DD.checks.md` and push them to the main branch with `git push origin HEAD:main`. This is allowed and expected. Do not commit the `voice/models` folder.
10. If you recorded audio, send it on its own branch. The MP3 is ignored on the main branch on purpose, so add it with `-f`:

        git checkout -b claude/audio-YYYY-MM-DD
        git add -f episodes/YYYY-MM-DD.mp3
        git commit -m "Audio for YYYY-MM-DD"
        git push origin claude/audio-YYYY-MM-DD

    A GitHub Action turns it into a Release named `ep-YYYY-MM-DD` and then deletes the branch.
11. Send the person the MP3. Look for a tool that sends files to the user (it may be called `SendUserFile`, and you may have to search your tools and load it first). If there is none, say so in the report. If you have a tool for push notifications, tell them the episode is ready.
12. End with a short report: stories per section, length in minutes, anything that failed, and any source that returned nothing.

If recording fails, still commit and push the script and the story list.
