|
| 1 | +# Agents Guide |
| 2 | + |
| 3 | +This file provides guidance to coding agents when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This is an auto-moderator application that monitors task deadlines in a Notion database and sends reminders to Discord. It fetches tasks with deadlines within 3 days that are not marked as completed, formats them with assignee mentions, and sends notifications via Discord webhook. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +- **Start the application**: `bun run start` |
| 12 | +- **Type checking**: `bun run ci` or `bunx tsc` |
| 13 | +- **Linting and formatting**: `biome check --write` (configured for 120 character line width, 2-space indentation) |
| 14 | + |
| 15 | +## Project Structure |
| 16 | + |
| 17 | +The codebase is organized into 4 focused TypeScript modules: |
| 18 | + |
| 19 | +- **`src/main.ts`**: Main application logic that orchestrates task fetching, formatting, and notification sending |
| 20 | +- **`src/validator.ts`**: Valibot schemas for validating Notion API responses and type definitions |
| 21 | +- **`src/io.ts`**: I/O utilities for environment variables, retry logic, Discord webhooks, and Notion API queries |
| 22 | +- **`src/data.ts`**: Static mapping between Notion user names and Discord user IDs for @mentions |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +The application follows a functional architecture with clear separation: |
| 27 | + |
| 28 | +1. **Data Layer**: Notion API integration with type-safe schema validation using Valibot |
| 29 | +2. **Business Logic**: Task filtering (3-day deadline window), formatting with Discord mentions |
| 30 | +3. **I/O Layer**: Discord webhook notifications with retry mechanism |
| 31 | + |
| 32 | +## Environment Variables |
| 33 | + |
| 34 | +Required environment variables: |
| 35 | +- `NOTION_API_KEY`: Notion integration token |
| 36 | +- `DISCORD_WEBHOOK_URL`: Discord webhook URL for notifications |
| 37 | + |
| 38 | +## Git Hooks |
| 39 | + |
| 40 | +Lefthook is configured for pre-commit hooks: |
| 41 | +- Biome formatting and linting with auto-fix |
| 42 | +- TypeScript type checking |
| 43 | + |
| 44 | +Run `lefthook install` to set up hooks. |
| 45 | + |
| 46 | +## Technology Stack |
| 47 | + |
| 48 | +- **Runtime**: Bun |
| 49 | +- **Language**: TypeScript with strict mode |
| 50 | +- **Validation**: Valibot for runtime type safety |
| 51 | +- **APIs**: Notion API v2022-06-28, Discord webhooks |
| 52 | +- **Tooling**: Biome for linting/formatting, Lefthook for git hooks |
0 commit comments