# Restart Prompt You are continuing the `mailcat` project in `/Users/hanswienen/Documents/Development/Vibes/mailcat`. ## Current Goal The real `hans` mailbox has been completely reordered, and Roundcube/Managesieve filters have been uploaded for ongoing incoming-mail sorting. The Python live sorter and web route-management interface are no longer needed. The repository is intentionally reduced to the minimum tooling needed to: 1. Repeat folder creation and historical reordering if needed. 2. Keep/generate the Roundcube Sieve policy. 3. Continue unsubscribe work. 4. Run the daily report. Do not run mailbox-affecting scripts yourself unless the user explicitly authorizes it. The user prefers to run those scripts personally. ## Collaboration Rules - Follow the git workflow from `AGENTS.md`. - Before making file, code, or configuration changes, present a plan and wait for explicit approval. - Work on branch `codex` unless the user says otherwise. - Before every commit, rewrite this file from scratch as the current reconstruction prompt. - Commit after each user-prompted code change using the required three-section commit message format. - Keep runtime logs/state files unless the user explicitly says to delete them. - Do not commit credentials. ## Kept Files Core configuration and IMAP helpers: - `config.py` - `imap_utils.py` - `config.json` is local-only and ignored; it contains account credentials. Routing/reorder policy: - `mail_routes.py` - `domain_routes.json` - `mailinglist_routes.json` - `maak_mappen.py` - `verplaats_bestaand.py` Roundcube/Sieve: - `mailcat_roundcube.sieve` - `roundcube.txt` is local-only user export/test evidence and should not be treated as production policy. Unsubscribe: - `unsubscribe.py` - `decisions.json` - `unsubscribe_log.json` is runtime state and should not be committed unless the user explicitly asks. Daily report: - `dagelijks_overzicht.py` - `tests/test_dagelijks_overzicht.py` Logs/state kept: - `backup_log.json` - `verplaats_log.json` - `verplaats_log_voor_aiwijzigingen.json` - `verplaats_bestaand.log` - `unsubscribe_log.json` ## Current Behavior Roundcube/Sieve: - `mailcat_roundcube.sieve` is the generated Roundcube/Managesieve Sieve file for the current routing setup. - `invoice_dynamic_quarter.sieve` is a standalone Roundcube/Managesieve Sieve file containing only the dynamic invoice-quarter rule. It uses the message `Date` header to set `jaar`, regex month tests to set `kwartaal`, then files into `INBOX.Financieel.Facturen.${jaar}.${kwartaal}`. - It uses `INBOX.`-prefixed mailbox names because the user's Roundcube export used `fileinto :copy "INBOX.Notes";`. - It includes `Afmelden.*` routes and uses `fileinto` without `:copy`, so matching incoming messages are sorted instead of duplicated. - Rules have Roundcube-compatible `# rule:[...]` names. - Financial rules are first; the invoice rule remains one dynamic quarter rule, then remaining financial rules and all other rules are alphabetically ordered by rule name. - Duplicate destination names are disambiguated with `/ Mailing-list` or `/ Domain` suffixes. Daily report: - `dagelijks_overzicht.py` builds an HTML digest for a selected date, defaulting to yesterday. - It supports `--account` and `--mail-to`. - It searches sorted folders, excluding inbox/system/archive/technical folders. - It sends an HTML email via SMTP. - Report rows fetch `Message-ID` and render the subject as an Apple Mail `message://` link when a `Message-ID` is present. - Apple Mail links are macOS-oriented and depend on Apple Mail having the message synced/indexed locally. - Report HTML escapes folder labels, senders, subjects, and link attributes. Historical reorder: - `verplaats_bestaand.py` defaults to dry-run. Real moves require `--uitvoeren` and interactive `JA`. - Account selection is explicit with `--account `, for example `--account hans`. - `--audit` is available in dry-run mode. - It logs to `verplaats_log.json`. Unsubscribe: - `unsubscribe.py` reads `decisions.json`. - It processes entries with `keuze == "a"` and a `List-Unsubscribe` value. - It logs progress to `unsubscribe_log.json`. - It may perform HTTP unsubscribe requests or send mailto unsubscribe messages via SMTP, so the user should run it personally. ## NAS Daily Report For the current NAS setup, only the daily report needs scheduling. A simple cron entry is enough: ```cron 0 6 * * * cd /share/homes/mailcat/mailcat && /opt/bin/python3 dagelijks_overzicht.py --account hans --mail-to hans@australius.nl >> /share/homes/mailcat/mailcat/daily_report.out 2>&1 ``` Use the NAS-specific crontab mechanism if QNAP overwrites normal crontabs after reboot. ## Verification Commands Latest local verification should include: ```sh python3 -m py_compile config.py imap_utils.py mail_routes.py maak_mappen.py verplaats_bestaand.py dagelijks_overzicht.py unsubscribe.py python3 -m unittest discover -s tests sievec -c /tmp/mailcat-sieve-test/dovecot.conf mailcat_roundcube.sieve /tmp/mailcat_roundcube.svbin git diff --check ``` If `/tmp/mailcat-sieve-test/dovecot.conf` does not exist, recreate it for Dovecot 2.4.0: ```sh mkdir -p /tmp/mailcat-sieve-test printf 'dovecot_config_version = 2.4.0\ndovecot_storage_version = 2.4.0\nssl = no\n' > /tmp/mailcat-sieve-test/dovecot.conf ``` ## Next Expected Work Likely next steps: 1. Finish unsubscribe work, with the user running `unsubscribe.py`. 2. Deploy the reduced project to the NAS if desired. 3. Schedule `dagelijks_overzicht.py` daily at 06:00 on the NAS.