@codejoy/terminal-pet
Version:
A virtual pet that lives in your terminal and grows with your coding activity
275 lines (200 loc) ⢠7.4 kB
Markdown
# š¾ Terminal Pet
A virtual pet that lives in your terminal and grows with your coding activity! Your pet gets stronger, happier, and more experienced with every git commit you make.



## ⨠Features
- š± **Multiple Pet Types**: Choose from cats, dogs, or dragons
- š **Real-time Stats**: Health, happiness, hunger, and energy tracking
- šÆ **Git Integration**: Your pet grows stronger with every commit
- š **Achievement System**: Unlock achievements for coding milestones
- šØ **Beautiful ASCII Art**: Colorful pet visualizations with mood indicators
- š¾ **Persistent State**: Your pet remembers everything between sessions
- š **Automatic Git Hooks**: Optional automatic feeding on commits
- š **Coding Analytics**: Track your programming patterns and streaks
## š Installation
### Global Installation (Recommended)
```bash
npm install -g terminal-pet
```
### Local Installation
```bash
npm install terminal-pet
```
## š® Quick Start
1. **Adopt your first pet:**
```bash
pet adopt
```
2. **Check on your pet:**
```bash
pet status
```
3. **Take care of your pet:**
```bash
pet feed # When hungry
pet play # When bored
pet sleep # When tired
```
4. **Start coding!** Your pet will automatically get stronger with every git commit! š
## š Commands
| Command | Description |
|---------|-------------|
| `pet` | Show your pet's current status |
| `pet adopt` | Adopt a new pet (replaces current pet) |
| `pet status` | View detailed pet status |
| `pet feed` | Feed your hungry pet |
| `pet play` | Play with your pet (requires energy) |
| `pet sleep` | Let your pet rest and recover |
| `pet stats` | View achievements and coding statistics |
| `pet help` | Show help information |
| `pet git-setup` | Set up automatic git hooks |
| `pet git-remove` | Remove git hooks |
## š¾ Pet Types
### š± Cat
- **Personality**: Independent but loving
- **Special**: Extra happiness from successful commits
- **ASCII Art**: Classic cat expressions
### š¶ Dog
- **Personality**: Loyal and energetic
- **Special**: Bonus energy recovery
- **ASCII Art**: Adorable dog animations
### š Dragon
- **Personality**: Powerful and mystical
- **Special**: Higher experience gains
- **ASCII Art**: Majestic dragon poses
## š Pet Stats Explained
### Core Stats
- **ā¤ļø Health** (0-100): Overall wellbeing. Decreases if hungry or unhappy for too long
- **š Happiness** (0-100): Mood level. Increases with play and commits, decreases over time
- **š Hunger** (0-100): How hungry your pet is. Increases over time, feed to decrease
- **ā” Energy** (0-100): Activity level. Decreases with play, recovers with sleep
### Progression
- **Level**: Increases with experience points from commits
- **Experience**: Gained from git commits and good coding practices
- **Age**: How many days since adoption
- **Streak**: Consecutive days with commits
## š Achievement System
Unlock achievements by reaching coding milestones:
- š **First Commit**: Make your first commit with your pet
- šÆ **Century Club**: Reach 100 total commits
- š„ **Week Warrior**: Maintain a 7-day commit streak
- š **Month Master**: Maintain a 30-day commit streak
- š **Double Digits**: Reach level 10
- šļø **Half Century**: Reach level 50
- š **Well Fed**: Keep hunger at 0
- š **Pure Joy**: Achieve 100% happiness
## šÆ Git Integration
Terminal Pet integrates with your git workflow to reward good coding practices:
### Commit Rewards
- **Base XP**: 10 points per commit
- **Streak Bonus**: Up to 20 extra points for consecutive days
- **Message Quality**: Bonus points for descriptive commit messages
- **Commit Type Bonuses**:
- Bug fixes: +5 XP
- New features: +8 XP
- Refactoring: +6 XP
### Automatic Git Hooks
Set up automatic feeding with git hooks:
```bash
pet git-setup
```
This creates a post-commit hook that automatically rewards your pet after each commit!
## šØ Pet Moods
Your pet's mood changes based on their stats:
- š **Happy**: Good overall stats
- 𤩠**Ecstatic**: Excellent health and happiness
- š¢ **Sad**: Low happiness
- š½ļø **Hungry**: High hunger level
- š“ **Tired**: Low energy
- š¤ **Sick**: Low health
- š **Dead**: Health reached 0 (adopt a new pet!)
## š§ Advanced Usage
### Programmatic Usage
```javascript
const { Pet, PetDisplay, GitIntegration } = require('terminal-pet');
// Create a new pet
const pet = new Pet('MyPet', 'cat');
// Simulate a commit
pet.onCommit('feat: add awesome feature');
// Display the pet
console.log(PetDisplay.displayPet(pet));
// Save state
pet.save();
```
### Custom Git Integration
```javascript
const { GitIntegration } = require('terminal-pet');
const git = new GitIntegration();
// Get commit statistics
const stats = await git.analyzeCommitActivity();
console.log('Recent commits:', stats.totalCommits);
// Check if in git repository
const isRepo = await git.isGitRepository();
```
## š ļø Development
### Setup
```bash
git clone https://github.com/yourusername/terminal-pet.git
cd terminal-pet
npm install
```
### Testing
```bash
# Link for local testing
npm link
# Test commands
pet adopt
pet status
```
### Project Structure
```
terminal-pet/
āāā bin/
ā āāā cli.js # CLI interface
āāā lib/
ā āāā Pet.js # Core pet logic
ā āāā PetDisplay.js # ASCII art and display
ā āāā GitIntegration.js # Git workflow integration
āāā package.json
āāā index.js # Main module exports
āāā README.md
```
## š¤ Contributing
Contributions are welcome! Here are some ideas:
- šØ New pet types and ASCII art
- š Additional achievements
- š More detailed analytics
- š® Mini-games and interactions
- š Localization support
### Development Guidelines
1. Fork the repository
2. Create a feature branch
3. Add tests for new features
4. Ensure all tests pass
5. Submit a pull request
## š License
MIT License - see [LICENSE](LICENSE) file for details.
## š Acknowledgments
- Inspired by the classic Tamagotchi virtual pets
- Built with love for the developer community
- ASCII art inspired by various terminal art collections
## š Troubleshooting
### Common Issues
**Pet not responding to commits:**
- Ensure you're in a git repository
- Set up git hooks with `pet git-setup`
- Check that the pet is alive with `pet status`
**Pet died:**
- Adopt a new pet with `pet adopt`
- Remember to feed and play with your pet regularly!
**Commands not found:**
- Ensure global installation: `npm install -g terminal-pet`
- Check PATH includes npm global binaries
### Support
- š [Report bugs](https://github.com/yourusername/terminal-pet/issues)
- š” [Request features](https://github.com/yourusername/terminal-pet/issues)
- š¬ [Join discussions](https://github.com/yourusername/terminal-pet/discussions)
---
**Made with ā¤ļø for developers who love their code (and virtual pets)!**
*Remember: A well-fed pet is a happy pet! Keep coding and keep your terminal buddy healthy! š¾*