2025-12-12 23:20:42 -03:00
# botserver Development Prompt Guide
2025-12-04 12:28:05 -03:00
**Version:** 6.1.0
2025-12-12 23:20:42 -03:00
**Purpose:** Consolidated LLM context for botserver development
2025-12-04 12:28:05 -03:00
---
2025-12-21 23:40:43 -03:00
## ZERO TOLERANCE POLICY
**This project has the strictest code quality requirements possible:**
```toml
[lints.clippy]
all = "warn"
pedantic = "warn"
nursery = "warn"
cargo = "warn"
unwrap_used = "warn"
expect_used = "warn"
panic = "warn"
todo = "warn"
```
2025-12-19 19:59:15 -03:00
2025-12-21 23:40:43 -03:00
**EVERY SINGLE WARNING MUST BE FIXED. NO EXCEPTIONS.**
2025-12-19 19:59:15 -03:00
2025-12-21 23:40:43 -03:00
---
2025-12-19 19:59:15 -03:00
2025-12-21 23:40:43 -03:00
## ABSOLUTE PROHIBITIONS
2025-12-19 19:59:15 -03:00
2025-12-21 23:40:43 -03:00
```
❌ NEVER use #![allow()] or #[allow()] in source code to silence warnings
2025-12-26 08:59:25 -03:00
❌ NEVER use _ prefix for unused variables - USE the variable (add logging)
2025-12-21 23:40:43 -03:00
❌ NEVER use .unwrap() - use ? or proper error handling
❌ NEVER use .expect() - use ? or proper error handling
❌ NEVER use panic!() or unreachable!() - handle all cases
❌ NEVER use todo!() or unimplemented!() - write real code
❌ NEVER leave unused imports - DELETE them
2025-12-26 08:59:25 -03:00
❌ NEVER leave dead code - USE IT (add logging, make public, add fallback methods)
❌ NEVER delete unused struct fields - USE them in logging or make them public
2025-12-21 23:40:43 -03:00
❌ NEVER use approximate constants (3.14159) - use std::f64::consts::PI
❌ NEVER silence clippy in code - FIX THE CODE or configure in Cargo.toml
❌ NEVER use CDN links - all assets must be local
2025-12-23 15:52:35 -03:00
❌ NEVER run cargo check or cargo clippy - USE ONLY the diagnostics tool
❌ NEVER add comments - code must be self-documenting via types and naming
❌ NEVER add file header comments (//! or /*!) - no module docs
❌ NEVER add function doc comments (///) - types are the documentation
❌ NEVER add ASCII art or banners in code
❌ NEVER add TODO/FIXME/HACK comments - fix it or delete it
2025-12-21 23:40:43 -03:00
```
2025-12-19 19:59:15 -03:00
---
2025-12-21 23:40:43 -03:00
## CARGO.TOML LINT EXCEPTIONS
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
When a clippy lint has **technical false positives** that cannot be fixed in code,
disable it in `Cargo.toml` with a comment explaining why:
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
```toml
[lints.clippy]
# Disabled: has false positives for functions with mut self, heap types (Vec, String)
missing_const_for_fn = "allow"
# Disabled: Tauri commands require owned types (Window) that cannot be passed by reference
needless_pass_by_value = "allow"
# Disabled: transitive dependencies we cannot control
multiple_crate_versions = "allow"
```
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
**Approved exceptions:**
- `missing_const_for_fn` - false positives for `mut self` , heap types
- `needless_pass_by_value` - Tauri/framework requirements
- `multiple_crate_versions` - transitive dependencies
- `future_not_send` - when async traits require non-Send futures
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
---
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
## MANDATORY CODE PATTERNS
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
### Error Handling - Use `?` Operator
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
let value = something.unwrap();
let value = something.expect("msg");
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
let value = something?;
let value = something.ok_or_else(|| Error::NotFound)?;
```
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
2025-12-21 23:40:43 -03:00
### Option Handling - Use Combinators
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
if let Some(x) = opt {
x
} else {
default
}
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
opt.unwrap_or(default)
opt.unwrap_or_else(|| compute_default())
opt.map_or(default, |x| transform(x))
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
```
2025-12-21 23:40:43 -03:00
### Match Arms - Must Be Different
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG - identical arms
match x {
A => do_thing(),
B => do_thing(),
C => other(),
}
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT - combine identical arms
match x {
A | B => do_thing(),
C => other(),
}
```
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
### Self Usage in Impl Blocks
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
impl MyStruct {
fn new() -> MyStruct { MyStruct { } }
}
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
impl MyStruct {
fn new() -> Self { Self { } }
}
```
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
### Format Strings - Inline Variables
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
format!("Hello {}", name)
log::info!("Processing {}", id);
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
format!("Hello {name}")
log::info!("Processing {id}");
```
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
### Display vs ToString
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
impl ToString for MyType {
fn to_string(& self) -> String { }
}
// ✅ CORRECT
impl std::fmt::Display for MyType {
fn fmt(& self, f: & mut std::fmt::Formatter< '_>) -> std::fmt::Result { }
}
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
```
2025-12-21 23:40:43 -03:00
### Derive Eq with PartialEq
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
#[derive(PartialEq)]
struct MyStruct { }
2025-12-04 18:15:09 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
#[derive(PartialEq, Eq)]
struct MyStruct { }
```
### Must Use Attributes
2025-12-04 18:15:09 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG - pure function without #[must_use]
pub fn calculate() -> i32 { }
2025-12-04 12:28:05 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
#[must_use]
pub fn calculate() -> i32 { }
```
2025-12-04 12:28:05 -03:00
2025-12-23 15:52:35 -03:00
### Zero Comments Policy
```rust
// ❌ WRONG - any comments
/// Returns the user's full name
fn get_full_name(& self) -> String { }
// Validate input before processing
fn process(data: & str) { }
//! This module handles user authentication
// ✅ CORRECT - self-documenting code, no comments
fn full_name(& self) -> String { }
fn process_validated_input(data: & str) { }
```
**Why zero comments:**
- Rust's type system documents intent (Result, Option, traits)
- Comments become stale when code changes
- LLMs can infer intent from well-structured code
- Good naming > comments
- Types are the documentation
2025-12-21 23:40:43 -03:00
### Const Functions
2025-12-04 12:28:05 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG - could be const but isn't
pub fn default_value() -> i32 { 42 }
2025-12-04 12:28:05 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
pub const fn default_value() -> i32 { 42 }
2025-12-04 12:28:05 -03:00
```
2025-12-21 23:40:43 -03:00
### Pass by Reference
2025-12-04 12:28:05 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG - needless pass by value
fn process(data: String) { println!("{data}"); }
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
fn process(data: & str) { println!("{data}"); }
```
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
### Clone Only When Needed
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG - redundant clone
let x = value.clone();
use_value(&x);
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
// ✅ CORRECT
use_value(&value);
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
```
2025-12-21 23:40:43 -03:00
### Mathematical Constants
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG
let pi = 3.14159;
let e = 2.71828;
// ✅ CORRECT
use std::f64::consts::{PI, E};
let pi = PI;
let e = E;
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
```
2025-12-21 23:40:43 -03:00
### Async Functions
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
2025-12-21 23:40:43 -03:00
```rust
// ❌ WRONG - async without await
async fn process() { sync_operation(); }
// ✅ CORRECT - remove async if no await needed
fn process() { sync_operation(); }
```
feat(auth): Add OAuth login for Google, Discord, Reddit, Twitter, Microsoft, Facebook
- Create core/oauth module with OAuthProvider enum and shared types
- Implement providers.rs with auth URLs, token exchange, user info endpoints
- Add routes for /auth/oauth/providers, /auth/oauth/{provider}, and callbacks
- Update login.html with OAuth button grid and dynamic provider loading
- Add OAuth config settings to config.csv with setup documentation and links
- Uses HTMX for login form, minimal JS for OAuth provider visibility
2025-12-04 22:53:40 -03:00
---
2025-12-21 23:40:43 -03:00
## Build Rules
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
```bash
# Development - ALWAYS debug build
cargo build
cargo check
# NEVER use release unless deploying
# cargo build --release # NO!
```
---
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
## Version Management
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
**Version is 6.1.0 - NEVER CHANGE without explicit approval**
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
---
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
## Database Standards
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
**TABLES AND INDEXES ONLY:**
2025-12-04 13:55:19 -03:00
2025-12-21 23:40:43 -03:00
```
✅ CREATE TABLE IF NOT EXISTS
✅ CREATE INDEX IF NOT EXISTS
✅ Inline constraints
❌ CREATE VIEW
❌ CREATE TRIGGER
❌ CREATE FUNCTION
❌ Stored Procedures
```
**JSON Columns:** Use TEXT with `_json` suffix, not JSONB
2025-12-04 13:55:19 -03:00
---
2025-12-04 12:28:05 -03:00
## Code Generation Rules
```
- KISS, NO TALK, SECURED ENTERPRISE GRADE THREAD SAFE CODE ONLY
2025-12-21 23:40:43 -03:00
- Use rustc 1.90.0+
- No placeholders, no explanations, no comments
2025-12-04 12:28:05 -03:00
- All code must be complete, professional, production-ready
- REMOVE ALL COMMENTS FROM GENERATED CODE
- Always include full updated code files - never partial
- Only return files that have actual changes
2025-12-21 23:40:43 -03:00
- Return 0 warnings - FIX ALL CLIPPY WARNINGS
- NO DEAD CODE - implement real functionality
2025-12-04 13:55:19 -03:00
```
2025-12-21 23:40:43 -03:00
---
## Documentation Rules
2025-12-04 13:55:19 -03:00
```
2025-12-21 23:40:43 -03:00
- Rust code examples ONLY in docs/reference/architecture.md
2025-12-04 13:55:19 -03:00
- All other docs: BASIC, bash, JSON, SQL, YAML only
- Keep only README.md and PROMPT.md at project root level
```
2025-12-21 23:40:43 -03:00
---
## Frontend Rules
2025-12-04 13:55:19 -03:00
```
- Use HTMX to minimize JavaScript - delegate logic to Rust server
- NO external CDN - all JS/CSS must be local in vendor/ folders
- Server-side rendering with Askama templates returning HTML
- Endpoints return HTML fragments, not JSON (for HTMX)
2025-12-04 12:28:05 -03:00
```
---
2025-12-21 23:40:43 -03:00
## Rust Patterns
2025-12-04 12:28:05 -03:00
```rust
2025-12-21 23:40:43 -03:00
// Random number generation
let mut rng = rand::rng();
2025-12-04 12:28:05 -03:00
2025-12-21 23:40:43 -03:00
// Database - ONLY diesel, never sqlx
2025-12-04 12:28:05 -03:00
use diesel::prelude::*;
2025-12-21 23:40:43 -03:00
// Config from AppConfig - no hardcoded values
let url = config.drive.endpoint.clone();
2025-12-04 12:28:05 -03:00
2025-12-21 23:40:43 -03:00
// Logging - all-in-one-line, unique messages, inline vars
info!("Processing request id={id} user={user_id}");
2025-12-04 12:28:05 -03:00
```
---
2025-12-21 23:40:43 -03:00
## Dependencies
2025-12-04 12:28:05 -03:00
```
2025-12-21 23:40:43 -03:00
- Use diesel - remove any sqlx references
- After adding to Cargo.toml: cargo audit must show 0 vulnerabilities
- If audit fails, find alternative library
- Minimize redundancy - check existing libs before adding
2025-12-04 12:28:05 -03:00
```
---
2025-12-21 23:40:43 -03:00
## Key Files
2025-12-04 12:28:05 -03:00
```
2025-12-21 23:40:43 -03:00
src/main.rs # Entry point
src/lib.rs # Module exports
src/basic/ # BASIC language keywords
src/core/ # Core functionality
src/shared/state.rs # AppState definition
src/shared/utils.rs # Utility functions
src/shared/models.rs # Database models
2025-12-04 12:28:05 -03:00
```
---
## Dependencies (Key Libraries)
| Library | Version | Purpose |
|---------|---------|---------|
| axum | 0.7.5 | Web framework |
2025-12-21 23:40:43 -03:00
| diesel | 2.1 | PostgreSQL ORM |
2025-12-04 12:28:05 -03:00
| tokio | 1.41 | Async runtime |
| rhai | git | BASIC scripting |
| reqwest | 0.12 | HTTP client |
| serde | 1.0 | Serialization |
2025-12-04 13:55:19 -03:00
| askama | 0.12 | HTML Templates |
2025-12-04 12:28:05 -03:00
---
2025-12-26 08:59:25 -03:00
## Efficient Warning Fix Strategy
**IDE DIAGNOSTICS ARE THE SOURCE OF TRUTH** - Never run `cargo clippy` manually.
When fixing clippy warnings in files:
1. **TRUST DIAGNOSTICS** - Use `diagnostics()` tool, not cargo commands
2. **READ FULL FILE** - Use `read_file` with line ranges to get complete file content
3. **FIX ALL WARNINGS** - Apply all fixes in memory before writing
4. **OVERWRITE FILE** - Use `edit_file` with `mode: "overwrite"` to replace entire file
5. **BATCH FILES** - Get diagnostics for multiple files, fix in parallel
6. **RE-CHECK** - Call `diagnostics(path)` after edits to verify fixes
This is FASTER than incremental edits. Never make single-warning fixes.
```
// Workflow:
1. diagnostics() - get project overview (files with warning counts)
2. diagnostics(path) - get specific warnings with line numbers
3. read_file(path, start, end) - read full file in chunks
4. edit_file(path, mode="overwrite") - write fixed version
5. diagnostics(path) - verify warnings are fixed
6. Repeat for next file
```
**IMPORTANT:** Diagnostics may be stale after edits. Re-read the file or call diagnostics again to refresh.
---
## Current Warning Status (Session 10)
### Completed Files (0 warnings):
- `main.rs` - Fixed unused imports, io_other_error, redundant field names
- `score_lead.rs` - Fixed redundant clones, map_or→is_some_and, manual_clamp
- `auto_task.rs` - Fixed derive Eq, use_self in impl blocks
- `hear_talk.rs` - Renamed from_str→parse_type, removed redundant clones
### High-Priority Files Remaining:
| File | Warnings | Main Issues |
|------|----------|-------------|
| `crm/attendance.rs` | 27 | manual_let_else, redundant_clone, comparison_chain |
| `attendance/llm_assist.rs` | 25 | trim_split_whitespace, format_push_string, match_same_arms |
| `core/bootstrap/mod.rs` | 24 | unused_self, if_not_else, unnecessary_debug_formatting |
| `drive/vectordb.rs` | 24 | dead_code, significant_drop_tightening, unused_async |
| `http_operations.rs` | 22 | TBD |
| `add_bot.rs` | 22 | TBD |
| `api_tool_generator.rs` | 22 | TBD |
| `document_processor.rs` | 22 | TBD |
| `llm/observability.rs` | 21 | TBD |
| `mcp_client.rs` | 21 | TBD |
| `llm/local.rs` | 21 | TBD |
| `console/mod.rs` | 20 | TBD |
### Common Fix Patterns for Remaining Files:
- `manual_let_else` : `let x = match opt { Some(v) => v, None => return }` → `let Some(x) = opt else { return }`
- `redundant_clone` : Remove `.clone()` on last usage of variable
- `format_push_string` : `s.push_str(&format!(...))` → `use std::fmt::Write; let _ = write!(s, ...)`
- `unnecessary_debug_formatting` : `{:?}` on PathBuf → `{path.display()}`
- `if_not_else` : `if !x { a } else { b }` → `if x { b } else { a }`
- `match_same_arms` : Combine identical arms with `|`
- `or_fun_call` : `.unwrap_or(fn())` → `.unwrap_or_else(fn)`
- `unused_self` : Convert to associated function with `Self::method()` calls
- `significant_drop_tightening` : Wrap lock in block `{ let guard = lock.await; use(guard); }`
---
2025-12-04 12:28:05 -03:00
## Remember
2025-12-21 23:40:43 -03:00
- **ZERO WARNINGS** - Every clippy warning must be fixed
2025-12-23 15:52:35 -03:00
- **ZERO COMMENTS** - No comments, no doc comments, no file headers, no ASCII art
2025-12-21 23:40:43 -03:00
- **NO ALLOW IN CODE** - Never use #[allow()] in source files
- **CARGO.TOML EXCEPTIONS OK** - Disable lints with false positives in Cargo.toml with comment
- **NO DEAD CODE** - Delete unused code, never prefix with _
- **NO UNWRAP/EXPECT** - Use ? operator or proper error handling
- **NO APPROXIMATE CONSTANTS** - Use std::f64::consts
- **INLINE FORMAT ARGS** - format!("{name}") not format!("{}", name)
- **USE SELF** - In impl blocks, use Self not the type name
- **DERIVE EQ** - Always derive Eq with PartialEq
- **DISPLAY NOT TOSTRING** - Implement Display, not ToString
- **USE DIAGNOSTICS** - Use IDE diagnostics tool, never call cargo clippy directly
- **PASS BY REF** - Don't clone unnecessarily
- **CONST FN** - Make functions const when possible
- **MUST USE** - Add #[must_use] to pure functions
2025-12-04 13:55:19 -03:00
- **diesel**: No sqlx references
2025-12-04 12:28:05 -03:00
- **Sessions**: Always retrieve by ID when present
- **Config**: Never hardcode values, use AppConfig
- **Bootstrap**: Never suggest manual installation
2025-12-21 23:40:43 -03:00
- **Version**: Always 6.1.0 - do not change
- **Migrations**: TABLES AND INDEXES ONLY
- **JSON**: Use TEXT columns with `_json` suffix
- **Session Continuation**: When running out of context, create detailed summary: (1) what was done, (2) what remains, (3) specific files and line numbers, (4) exact next steps.
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
---
## Monitor Keywords (ON EMAIL, ON CHANGE)
2025-12-21 23:40:43 -03:00
### ON EMAIL
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
```basic
ON EMAIL "support@company .com"
email = GET LAST "email_received_events"
2025-12-21 23:40:43 -03:00
TALK "New email from " + email.from_address
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
END ON
```
2025-12-21 23:40:43 -03:00
### ON CHANGE
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
```basic
2025-12-21 23:40:43 -03:00
ON CHANGE "gdrive://myaccount/folder"
files = GET LAST "folder_change_events"
FOR EACH file IN files
TALK "File changed: " + file.name
NEXT
feat: add ON EMAIL and ON CHANGE keywords for event-driven monitoring
- Add ON EMAIL keyword with FROM/SUBJECT filters
- Add ON CHANGE keyword with account:// syntax (gdrive, onedrive, dropbox, local)
- Add TriggerKind::EmailReceived (5) and FolderChange (6)
- Add migration 6.1.3_bot_hierarchy_monitors with:
- email_monitors, folder_monitors tables
- email_received_events, folder_change_events tables
- user_organizations table
- Bot hierarchy: parent_bot_id, enabled_tabs_json, inherit_parent_config
- Add 26 unit tests (12 on_email, 12 on_change, 2 trigger_kind)
- Update PROMPT.md with weekly maintenance checklist
- Zero warnings, zero errors
2025-12-18 16:17:58 -03:00
END ON
```
2025-12-21 23:40:43 -03:00
**TriggerKind Enum:**
- Scheduled = 0
- TableUpdate = 1
- TableInsert = 2
- TableDelete = 3
- Webhook = 4
- EmailReceived = 5
- FolderChange = 6