diff options
Diffstat (limited to 'AGENTS.md')
| -rw-r--r-- | AGENTS.md | 70 |
1 files changed, 42 insertions, 28 deletions
| @@ -1,33 +1,47 @@ | |||
| 1 | # Agent Instructions for Senator Sperma | 1 | # senator-sperma-rust — Agent Guide |
| 2 | 2 | ||
| 3 | ## Required Setup | 3 | ## Project Map |
| 4 | - Requires **Python 3.14** | ||
| 5 | - System dependencies: `ffmpeg`, `zbar` library (installed system-wide) | ||
| 6 | - Bot token in `.env` file (copy from `.env.example`) | ||
| 7 | 4 | ||
| 8 | ## Commands | 5 | ``` |
| 9 | - Run bot: `.venv/bin/python main.py` | 6 | src/ |
| 10 | - Type check: `.venv/bin/basedpyright` | 7 | ├── main.rs — Entry: init tracing, dotenvy, build Config/Data, start poise+serenity |
| 11 | - Test: `.venv/bin/pytest` | 8 | ├── config.rs — Config struct (env-driven), pub const TEMP_PATH |
| 9 | ├── error.rs — Unified Error enum + From impls, pub type Result<T> | ||
| 10 | ├── commands/ | ||
| 11 | │ ├── mod.rs — all_commands() aggregates every submodule | ||
| 12 | │ ├── ai.rs — /senator (OpenRouter chat + optional TTS) | ||
| 13 | │ ├── cron.rs — /cron group (6 subcommands) | ||
| 14 | │ ├── math.rs — /math (qalc subprocess) | ||
| 15 | │ ├── music.rs — /play (🟡 stub), /stop, /join, /loop_toggle | ||
| 16 | │ ├── qr.rs — /qr encode + decode | ||
| 17 | │ ├── trigger.rs — /trigger group (6 subcommands) | ||
| 18 | │ ├── tts.rs — /tts (Google TTS → file/vc), /log_volume | ||
| 19 | │ ├── utilities.rs — compress🟡, convert🟡, upload, search, download, say | ||
| 20 | │ └── web.rs — /web (DuckDuckGo scrape) | ||
| 21 | ├── copyparty/mod.rs — CopypartyClient (search, upload) | ||
| 22 | ├── database/mod.rs — DbPool, 21 query fns, 6 tables, migration | ||
| 23 | ├── events/mod.rs — handle_ready, handle_voice_state_update, handle_message | ||
| 24 | ├── openrouter/mod.rs — OpenRouterClient (chat, chat_with_history) | ||
| 25 | ├── tasks/mod.rs — cron_scheduler_loop (30s polling, stub exec bodies) | ||
| 26 | └── voice/mod.rs — VoiceManager (connect, disconnect, get_call), mp3_to_input | ||
| 27 | ``` | ||
| 12 | 28 | ||
| 13 | ## Architecture | 29 | ## Key Conventions |
| 14 | - Slash commands defined as cogs in `cogs/*.py` | ||
| 15 | - Discord API uses `discord.ApplicationContext` | ||
| 16 | - Music auto-complete queries copyparty server (`COPYPARTY_URL` config) | ||
| 17 | 30 | ||
| 18 | ## Environment | 31 | - **Framework**: poise 0.6 + serenity 0.12 + songbird 0.6 |
| 19 | - Copyparty URL for read-only access is COPYPARTY_URL | 32 | - **DB**: sqlx 0.9 async SQLite (pool stored in `Data.db_pool`) |
| 20 | - Copyparty URL for write-only access is COPYPARTY_URL_UPLOAD | 33 | - **Errors**: `crate::error::Error` enum with `?` propagation; use `Error::Custom(string)` for ad-hoc |
| 21 | - Above should be accessed using COPYPARTY_PASSWORD as a cookie | 34 | - **Shared state**: `Data` struct in `main.rs` — passed as poise `user_data` |
| 22 | - Channel for vclogs and alike is STATUS_CHANNEL_ID | 35 | - **Commands**: each submodule exports `pub fn commands() -> Vec<poise::Command<Data, Error>>` |
| 23 | - Trigger word for assistant is ASSISTANT_KEYWORD | 36 | - **Temp path**: always use `crate::config::TEMP_PATH` (resolves to `/tmp/senator_sperma`) |
| 24 | 37 | ||
| 25 | ## Testing | 38 | ## Stubs to Fill (see COMPARISON.md) |
| 26 | - Tests in `tests/cogs/test_*.py` | 39 | - `commands/music.rs` — `/play` is placeholder |
| 27 | - Uses pytest-asyncio with `asyncio_default_fixture_loop_scope = function` | 40 | - `commands/utilities.rs` — `/compress`, `/convert`, `/download` upload part |
| 28 | - `conftest.py` provides fixtures for mocking Discord objects | 41 | - `tasks/mod.rs` — cron execution bodies are `info!` only, no actual action |
| 29 | - **Slow integration tests** marked with `@pytest.mark.slow` | 42 | |
| 30 | - Test real-world feature usage with longer execution times | 43 | ## Database Tables |
| 31 | - Includes: voice session tracking, cron job execution, music playback lifecycle, downloader flow, trigger responses | 44 | `settings` (key/value), `voice_activity`, `cron_jobs`, `triggers`, `trigger_keywords`, `trigger_responses` |
| 32 | - Run only fast tests: `.venv/bin/pytest -m "not slow"` | 45 | |
| 33 | - Run only slow tests: `.venv/bin/pytest -m slow` | 46 | ## All Commands (26 total) |
| 47 | `/senator`, `/cron` (6), `/math`, `/play`, `/stop`, `/join`, `/loop_toggle`, `/qr` (2), `/trigger` (6), `/tts`, `/log_volume`, `/compress`, `/convert`, `/upload`, `/search`, `/download`, `/say`, `/web` | ||
