diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 01:33:33 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 01:33:33 +0100 |
| commit | 97a26ec4e64a98a24dad7969337d2569339db9a7 (patch) | |
| tree | ada17e2b1f50d053a6bfe4067296e06de848ac87 /AGENTS.md | |
| parent | config: harden the shared temp directory (diff) | |
| download | senator-sperma-97a26ec4e64a98a24dad7969337d2569339db9a7.tar.gz senator-sperma-97a26ec4e64a98a24dad7969337d2569339db9a7.zip | |
docs: sync with current behavior
Diffstat (limited to 'AGENTS.md')
| -rw-r--r-- | AGENTS.md | 49 |
1 files changed, 27 insertions, 22 deletions
| @@ -4,28 +4,33 @@ | |||
| 4 | 4 | ||
| 5 | ``` | 5 | ``` |
| 6 | src/ | 6 | src/ |
| 7 | ├── main.rs — Entry: init tracing, dotenvy, build Config/Data, start poise+serenity | 7 | ├── main.rs — Entry: tracing, dotenvy, temp dir, Config/Data, poise+serenity |
| 8 | ├── config.rs — Config struct (env-driven), pub const TEMP_PATH | 8 | ├── config.rs — Config struct (env-driven), temp dir init/access |
| 9 | ├── error.rs — Unified Error enum + From impls, pub type Result<T> | 9 | ├── error.rs — Unified Error enum + From impls, pub type Result<T> |
| 10 | ├── net.rs — public-IP check for user-supplied URLs (SSRF guard) | ||
| 10 | ├── music.rs — MusicState: per-guild queue, now/next/last, skip, auto-advance | 11 | ├── music.rs — MusicState: per-guild queue, now/next/last, skip, auto-advance |
| 12 | ├── recording/mod.rs — per-guild rolling PCM recorder for /record | ||
| 13 | ├── tts.rs — TtsState (piper-rs in-process, bounded DashMap cache, resampler, WAV encoder) | ||
| 11 | ├── commands/ | 14 | ├── commands/ |
| 12 | │ ├── mod.rs — all_commands() aggregates every submodule | 15 | │ ├── mod.rs — all_commands() aggregates every submodule |
| 13 | │ ├── ai.rs — /senator (OpenRouter chat + optional TTS) | 16 | │ ├── ai.rs — /senator (LLM chat + optional TTS) |
| 17 | │ ├── autocomplete.rs — Copyparty autocomplete + trigger_name | ||
| 14 | │ ├── cron.rs — /cron group (6 subcommands) | 18 | │ ├── cron.rs — /cron group (6 subcommands) |
| 15 | │ ├── math.rs — /math (qalc subprocess) | 19 | │ ├── leaderboard.rs — /leaderboard group (me/messages/active/afk/total) |
| 20 | │ ├── math.rs — /math (qalc subprocess, 5s timeout) | ||
| 16 | │ ├── music.rs — /music group (grajcuj, skip, queue, stop, join) + context menu | 21 | │ ├── music.rs — /music group (grajcuj, skip, queue, stop, join) + context menu |
| 17 | │ ├── qr.rs — /qr encode + decode | 22 | │ ├── qr.rs — /qr encode + decode (dimension/allocation limits) |
| 23 | │ ├── record.rs — /record (flush this guild's buffer to Copyparty) | ||
| 18 | │ ├── trigger.rs — /trigger group (6 subcommands) | 24 | │ ├── trigger.rs — /trigger group (6 subcommands) |
| 19 | │ ├── tts.rs — /tts (local Piper TTS → file/vc), /log_volume | 25 | │ ├── tts.rs — /tts (local Piper TTS → file/vc) |
| 20 | │ ├── utilities.rs — compress🟡, convert🟡, upload, search, download, say | 26 | │ ├── utilities.rs — compress, convert, upload, search, download, say |
| 21 | │ └── web.rs — /web (DuckDuckGo scrape) | 27 | │ └── web.rs — /web (DuckDuckGo scrape) |
| 22 | ├── copyparty/mod.rs — CopypartyClient (search, upload) | 28 | ├── copyparty/mod.rs — CopypartyClient (search, upload, credential-safe URLs) |
| 23 | ├── database/mod.rs — DbPool, 21 query fns, 6 tables, migration | 29 | ├── database/mod.rs — DbPool, migrations, query helpers (7 tables) |
| 24 | ├── events/mod.rs — handle_ready, handle_voice_state_update, handle_message | 30 | ├── events/mod.rs — handle_ready, voice-state, message (triggers + LLM) |
| 25 | ├── openrouter/mod.rs — OpenRouterClient (chat, chat_with_history) | 31 | ├── openrouter/mod.rs — OpenRouterClient (chat, chat_with_history, timeouts) |
| 26 | ├── tasks/mod.rs — cron_scheduler_loop (30s polling, stub exec bodies) | 32 | ├── tasks/mod.rs — cron_scheduler_loop (60s polling, real execution) |
| 27 | ├── tts.rs — TtsState (piper-rs in-process, DashMap cache, pre-gen, resampler, WAV encoder) | 33 | └── voice/mod.rs — VoiceManager (connect, disconnect, get_call), ffmpeg/symphonia inputs |
| 28 | └── voice/mod.rs — VoiceManager (connect, disconnect, get_call), mp3_to_input | ||
| 29 | ``` | 34 | ``` |
| 30 | 35 | ||
| 31 | ## Key Conventions | 36 | ## Key Conventions |
| @@ -35,18 +40,18 @@ src/ | |||
| 35 | - **Errors**: `crate::error::Error` enum with `?` propagation; use `Error::Custom(string)` for ad-hoc | 40 | - **Errors**: `crate::error::Error` enum with `?` propagation; use `Error::Custom(string)` for ad-hoc |
| 36 | - **Shared state**: `Data` struct in `main.rs` — passed as poise `user_data` | 41 | - **Shared state**: `Data` struct in `main.rs` — passed as poise `user_data` |
| 37 | - **Commands**: each submodule exports `pub fn commands() -> Vec<poise::Command<Data, Error>>` | 42 | - **Commands**: each submodule exports `pub fn commands() -> Vec<poise::Command<Data, Error>>` |
| 38 | - **Temp path**: always use `crate::config::TEMP_PATH` (resolves to `/tmp/senator_sperma`) | 43 | - **Permissions**: admin commands use `required_permissions`; recording/cron/trigger are `guild_only` and scoped by `guild_id` in the DB |
| 39 | - **TTS**: piper-rs in-process (no subprocess). `TtsState` in `Data` holds `OnceLock<Mutex<Piper>>` + `DashMap` cache. Synthesize via `data.tts.synthesize(text)`. Pre-generates 6 event phrases per user on first voice event. No Google TTS fallback. | 44 | - **Temp path**: always use `crate::config::temp_path()` (initialized with mode `0700`; never hardcode `/tmp/senator_sperma`) |
| 45 | - **Outbound URLs**: user-supplied `http(s)` URLs go through `crate::net::ensure_public_http_url` unless they belong to the configured Copyparty origin | ||
| 46 | - **TTS**: piper-rs in-process (no subprocess). `TtsState` holds `OnceLock<Arc<std::sync::Mutex<Piper>>>` + a bounded `DashMap` cache. Synthesize via `data.tts.synthesize(text)`; work runs on `spawn_blocking`. No external TTS fallback. | ||
| 47 | - **Recording**: opt-in (`RECORDING_ENABLED=false` by default), one buffer per guild. | ||
| 40 | 48 | ||
| 41 | ## Build | 49 | ## Build |
| 42 | - `build.rs` — compiles C stubs for espeak-rs-sys missing sonic/audio_object symbols | 50 | - `build.rs` — compiles C stubs for espeak-rs-sys missing sonic/audio_object symbols |
| 43 | 51 | ||
| 44 | ## Stubs to Fill (see COMPARISON.md) | ||
| 45 | - `commands/utilities.rs` — `/compress`, `/convert`, `/download` upload part | ||
| 46 | - `tasks/mod.rs` — cron execution bodies are `info!` only, no actual action | ||
| 47 | |||
| 48 | ## Database Tables | 52 | ## Database Tables |
| 49 | `settings` (key/value), `voice_activity`, `cron_jobs`, `triggers`, `trigger_keywords`, `trigger_responses` | 53 | `settings`, `voice_activity`, `user_stats`, `cron_jobs`, `triggers`, `trigger_keywords`, `trigger_responses` |
| 50 | 54 | ||
| 51 | ## Commands | 55 | ## Commands |
| 52 | `/senator`, `/cron` (6), `/math`, `/music` (5: grajcuj, skip, queue, stop, join), `/qr` (2), `/trigger` (6), `/tts`, `/log_volume`, `/compress`, `/convert`, `/upload`, `/search`, `/download`, `/say`, `/web`, `/record`, `/leaderboard` | 56 | `/senator`, `/cron` (6), `/leaderboard` (5), `/math`, `/music` (5: grajcuj, skip, queue, stop, join), `/qr` (2), `/trigger` (6), `/tts`, `/record`, `/compress`, `/convert`, `/upload`, `/search`, `/download`, `/say`, `/web`. |
| 57 | Context menus: "Odtwórz", "Wyślij załączniki", "kompresja", "Pobierz z linku". | ||
