Add fetch_evening_tasks.py script and shared notion_helpers module

Refactors weekly-template's Notion client setup into a shared helper
(with .env/dotenv support and full pagination), and adds a dedicated
evening-prep script so both commands can fall back to script-based
fetching instead of the MCP search/fetch pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
aj.siegel
2026-09-21 23:05:57 -04:00
parent 339f9b1034
commit 20d8c1aedc
8 changed files with 229 additions and 59 deletions

View File

@@ -1,4 +1,4 @@
# Weekly Planning Scripts
# Daily/Weekly Planning Scripts
## Setup
@@ -24,30 +24,38 @@ For each database (Projects, Tasks Tracker, Reading List):
2. Click "..." menu → "Connections"
3. Add your "Weekly Planning Script" integration
### 4. Set environment variable
### 4. Set your Notion token
Add to your `~/.zshrc` or `~/.bash_profile`:
Create a `.env` file in the project root:
```bash
export NOTION_TOKEN="secret_your_token_here"
NOTION_TOKEN="secret_your_token_here"
```
Then reload: `source ~/.zshrc`
(`.env` is gitignored, and the script loads it automatically via `python-dotenv`.)
## Usage
Run the script to fetch weekly planning data:
### `fetch_weekly_data.py`
```bash
python3 scripts/fetch_weekly_data.py
```
Or add it to your PATH and run directly:
```bash
./scripts/fetch_weekly_data.py
```
This outputs JSON with:
- Projects marked "Focus this week"
- Active, non-personal projects (candidates for the weekly focus selection)
- Tasks due within the next 7 days
- Reading list articles (To Read or In Progress)
The weekly-template skill automatically calls this script to generate your weekly note, reducing AI inference costs.
The `/weekly-template` command calls this script to generate your weekly note, reducing AI inference costs. If the script fails, the command falls back to the Notion MCP search/fetch pattern.
### `fetch_evening_tasks.py`
```bash
python3 scripts/fetch_evening_tasks.py
```
This outputs JSON with:
- All open tasks (not Done, not Blocked) — paginated, so it stays complete as the tracker grows
- Every task currently marked `Top Task = true` (any status), for unmarking stale ones
The `/evening-prep` command calls this script to build the day's Suggested Tasks and manage the `Top Task` checkbox, with the same MCP fallback if the script fails.
Both scripts share Notion client setup, database IDs, and pagination logic in `notion_helpers.py`.