From 101138716f431a95d836de765f1387940958e033 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 10 Oct 2025 20:07:44 +0200 Subject: [PATCH] Hallucinate hella cursor rules --- .cursor/rules/code-quality.mdc | 31 ++++++++++++++++++++++++++ .cursor/rules/database-abstraction.mdc | 23 +++++++++++++++++++ .cursor/rules/esi-sso-interface.mdc | 31 ++++++++++++++++++++++++++ .cursor/rules/go-eve-pi-project.mdc | 27 ++++++++++++++++++++++ .cursor/rules/go-logging.mdc | 24 ++++++++++++++++++++ 5 files changed, 136 insertions(+) create mode 100644 .cursor/rules/code-quality.mdc create mode 100644 .cursor/rules/database-abstraction.mdc create mode 100644 .cursor/rules/esi-sso-interface.mdc create mode 100644 .cursor/rules/go-eve-pi-project.mdc create mode 100644 .cursor/rules/go-logging.mdc diff --git a/.cursor/rules/code-quality.mdc b/.cursor/rules/code-quality.mdc new file mode 100644 index 0000000..027b1a1 --- /dev/null +++ b/.cursor/rules/code-quality.mdc @@ -0,0 +1,31 @@ +--- +globs: *.go +description: Code quality and consistency standards +--- + +# Code Quality Standards + +## General Principles +- Keep functions focused and single-purpose +- Use descriptive variable and function names +- Add comprehensive logging for debugging +- Handle errors gracefully with proper context + +## Specific Rules +- Never use `fmt.Printf` or `fmt.Println` - always use the logger +- Avoid redundant log lines right next to each other +- Use `logger.Warning()` not `logger.Warn()` +- Include character names and operation context in log messages +- Use high-level database methods, not raw GORM calls + +## Code Organization +- Keep SSO logic in [esi_sso.go](mdc:esi_sso.go) +- Keep database abstraction in [db.go](mdc:db.go) +- Main application logic in [main.go](mdc:main.go) +- Use interfaces for database operations to enable testing + +## Error Handling +- Always log errors with sufficient context +- Don't swallow errors silently +- Provide meaningful error messages to users +- Handle network timeouts and API failures gracefully \ No newline at end of file diff --git a/.cursor/rules/database-abstraction.mdc b/.cursor/rules/database-abstraction.mdc new file mode 100644 index 0000000..851cb4c --- /dev/null +++ b/.cursor/rules/database-abstraction.mdc @@ -0,0 +1,23 @@ +--- +globs: *.go +description: Database abstraction layer conventions +--- + +# Database Abstraction Standards + +## High-Level Interface +The [db.go](mdc:db.go) file provides a high-level database interface. Always use these methods instead of raw GORM calls: + +- `GetTokenForCharacter(characterName string) (*Token, error)` +- `SaveTokenForCharacter(token *Token) error` +- `AutoMigrate(dst ...interface{}) error` + +## Never Use Raw GORM +- Don't call `s.db.DB().Where(...)` directly +- Don't call `s.db.DB().Save(...)` directly +- Always use the abstracted methods in the DB interface + +## Database Operations +- All database operations should be logged with appropriate context +- Include character names in log messages for database operations +- Handle errors gracefully and log them with context \ No newline at end of file diff --git a/.cursor/rules/esi-sso-interface.mdc b/.cursor/rules/esi-sso-interface.mdc new file mode 100644 index 0000000..f1c5131 --- /dev/null +++ b/.cursor/rules/esi-sso-interface.mdc @@ -0,0 +1,31 @@ +--- +globs: esi_sso.go +description: EVE SSO interface and implementation standards +--- + +# EVE SSO Interface Standards + +## Core Interface +The SSO system provides a simple interface: +```go +token, err := sso.GetToken(ctx, "CharacterName") +``` + +## Key Principles +- Use character NAMES, not IDs (nobody knows character IDs) +- Handle all SSO complexity behind the scenes +- Automatic token refresh when expired +- Automatic re-authentication when refresh fails +- Store tokens in database for persistence + +## Implementation Details +- [esi_sso.go](mdc:esi_sso.go) contains the SSO implementation +- Uses PKCE for secure OAuth2 flow +- Implements proper callback handling with HTTP server +- Includes comprehensive logging for debugging +- Handles token exchange and refresh automatically + +## Error Handling +- Always log errors with context (character name, operation) +- Provide clear error messages for authentication failures +- Handle network timeouts and API errors gracefully \ No newline at end of file diff --git a/.cursor/rules/go-eve-pi-project.mdc b/.cursor/rules/go-eve-pi-project.mdc new file mode 100644 index 0000000..6acb04d --- /dev/null +++ b/.cursor/rules/go-eve-pi-project.mdc @@ -0,0 +1,27 @@ +--- +alwaysApply: true +description: Go EVE PI project structure and conventions +--- + +# Go EVE PI Project Structure + +This is a Go project for EVE Online PI (Planetary Interaction) management with SSO authentication. + +## Key Files +- [main.go](mdc:main.go) - Main entry point, loads configuration from .env file +- [esi_sso.go](mdc:esi_sso.go) - EVE SSO authentication implementation +- [db.go](mdc:db.go) - Database abstraction layer with high-level methods + +## Project Conventions +- Uses `logger "git.site.quack-lab.dev/dave/cylogger"` for all logging +- Database operations use high-level methods like `GetTokenForCharacter()` and `SaveTokenForCharacter()` +- SSO interface: `GetToken(ctx, characterName)` returns access token for character +- Configuration loaded from .env file (ESI_CLIENT_ID, ESI_REDIRECT_URI, ESI_SCOPES, DB_PATH) + +## Logging Standards +- Use `logger.Info()` for important business events +- Use `logger.Debug()` for detailed debugging information +- Use `logger.Warning()` for warning conditions +- Use `logger.Error()` for error conditions +- Never use `fmt.Printf` - always use the logger +- Avoid redundant log lines right next to each other \ No newline at end of file diff --git a/.cursor/rules/go-logging.mdc b/.cursor/rules/go-logging.mdc new file mode 100644 index 0000000..32f2db8 --- /dev/null +++ b/.cursor/rules/go-logging.mdc @@ -0,0 +1,24 @@ +--- +globs: *.go +description: Go logging standards and conventions +--- + +# Go Logging Standards + +## Always Use cylogger +- Import: `logger "git.site.quack-lab.dev/dave/cylogger"` +- Never use `fmt.Printf`, `fmt.Println`, or standard `log` package +- All output must go through the logger system + +## Logging Levels +- `logger.Debug()` - Detailed debugging info, internal state +- `logger.Info()` - Important business events, user-facing messages +- `logger.Warning()` - Warning conditions (not `logger.Warn()`) +- `logger.Error()` - Error conditions, failures + +## Best Practices +- Include context in log messages (character names, operation details) +- Use structured logging with format strings: `logger.Info("Operation completed for %s", name)` +- Avoid redundant log lines right next to each other +- Log at appropriate levels - don't spam with unnecessary debug logs +- Always log errors with context about what operation failed \ No newline at end of file