Tools
Clawpet
Claw Pet is an innovative virtual pet plugin for OpenClaw that transforms your development environment into a more engaging and delightful workspace. Inspired by the success of Claude Code's Buddy feature.
README
<div align="center">
<img src="assets/logo.png" alt="ClawPet Logo" width="400">
# ClawPet โ Virtual Companion for OpenClaw



**Hatch and raise your own ASCII pet with unique traits, personality, and abilities. Your companion grows stronger as you use OpenClaw, creating a living bond between you and your AI assistant.**
</div>
## Features
- ๐ฅ **Deterministic Generation**: Your companion is uniquely generated from your API key using seeded PRNG
- ๐จ **Unique Traits**: Each pet has randomly generated species, personality, stats, rarity, and appearance
- โจ **Shiny Variants**: Rare shiny pets with special visual effects (1% chance)
- ๐ **RPG-Style Stats**: STR, DEX, CON, INT, WIS, CHA affect combat performance
- โ๏ธ **Combat System**: Battle other companions with D20-based attack/defense rolls
- ๐ **Leveling System**: Your pet grows stronger as you use OpenClaw (based on token usage)
- ๐ **HP/MP System**: Health and mana regenerate over time
- ๐ **Save Integrity**: HMAC-SHA256 cryptographic protection prevents tampering
## Installation
ClawPet is included in the OpenClaw extensions directory. To enable it:
```bash
# Navigate to OpenClaw workspace
cd ~/.openclaw/workspace
# The extension is already in extensions/clawpet
# OpenClaw will auto-load it on next restart
```
## Quick Start
### 1. Hatch Your Companion
```bash
/hatch
```
Your first companion will be created! Each machine/API key can only hatch one companion to ensure uniqueness.
### 2. Check Your Pet
```bash
/pet
```
View your companion's current stats, level, HP/MP, combat abilities, and appearance.
### 3. Battle (Optional)
```bash
/attack self # Test combat against yourself
/attack <machine-id> # Battle another companion
```
Combat uses D20 rolls + stat bonuses. Critical hits (nat 20) deal double damage!
## AI Integration
ClawPet provides three tools that the AI can invoke automatically:
- **clawpet_hatch**: When user says "hatch", "ๅญตๅ", or wants to create a pet
- **clawpet_pet**: When user says "pet", "ๅฎ ็ฉ", or wants to check their companion
- **clawpet_attack**: When user wants to battle or engage in combat
The AI will detect these commands in natural language and execute them for you.
## How It Works
### Deterministic Generation
Your companion's traits (species, stats, rarity, appearance) are generated using a seeded PRNG based on your API key. This means:
- Same API key = same companion bones (species, stats, base traits)
- Portable across machines with the same API key
- Impossible to "reroll" for better stats
### Soul & Bones Architecture
- **Bones** (deterministic): Species, stats, rarity, appearance - generated from API key
- **Soul** (dynamic): Name, personality, level, HP/MP, tokens used - stored in save files
This design ensures your companion's core identity is permanent while allowing growth over time.
### Leveling & Growth
Your companion levels up as you use OpenClaw:
- Tokens used are tracked via the `llm_output` event
- Every 10,000 tokens = 1 level
- Stats increase automatically with level
- Max HP/MP scale with CON and INT stats
### Save Files
Save files are stored in `~/.openclaw/workspace/.clawpet/<machine-id>.json` with:
- Version field for future compatibility
- HMAC-SHA256 integrity checking using API key + internal salt
- Simple checksum as decoy protection
- Timestamp validation to prevent time manipulation
- Reasonableness checks to detect impossible token counts
### Combat System
Combat follows D&D-inspired mechanics:
- **Attack Roll**: d20 + DEX bonus + level
- **Defense Roll**: d20 + (WIS+DEX)/2 bonus + level
- **Damage**: Base damage (STR + level) ร critical multiplier ยฑ variance
- **Critical Hit**: Nat 20 = 2ร damage
- **Critical Miss**: Nat 1 = automatic miss
- **Cooldown**: 30 seconds between attacks to prevent spam
HP regenerates 5% per minute, MP regenerates 10% per minute.
## File Structure
```
clawpet/
โโโ index.ts # Plugin entry point
โโโ package.json # NPM package metadata
โโโ openclaw.plugin.json # OpenClaw plugin config
โโโ README.md # This file
โโโ src/
โโโ types.ts # Type definitions
โโโ storage.ts # Save file handling with HMAC
โโโ machine-id.ts # Machine ID from API key
โโโ openclaw-config.ts # Read OpenClaw config
โโโ prng.ts # Seeded random number generator
โโโ companion.ts # Companion generation & merging
โโโ sprites.ts # ASCII art rendering
โโโ combat.ts # Combat system
โโโ utils.ts # Utility functions
โโโ commands/
โโโ hatch.ts # /hatch command
โโโ pet.ts # /pet command
โโโ attack.ts # /attack command
```
## Development
```bash
# Build TypeScript
npm run build
# Watch mode for development
npm run dev
```
## Configuration
ClawPet has no user-configurable settings. All behavior is deterministic based on:
- Your API key (for companion generation)
- Token usage (for leveling)
- Save file state (for HP/MP/level)
## FAQ
**Q: Can I have multiple companions?**
A: No, each machine/API key can only hatch one companion. This ensures uniqueness and prevents "rerolling."
**Q: What if I change my API key?**
A: Your companion's bones (species, stats) will change because they're derived from the API key. The save file will be separate.
**Q: Can I edit my save file to cheat?**
A: No, save files have HMAC-SHA256 integrity checking. Tampering will cause the save to be rejected.
**Q: How do I reset my companion?**
A: Delete the save file at `~/.openclaw/workspace/.clawpet/<machine-id>.json` and run `/hatch` again. Note: you'll get the same bones (species/stats) because they're deterministic.
**Q: Why can't I change my companion's name?**
A: Name and personality are part of the companion's soul and can only be set at hatching. This prevents identity confusion.
## License
MIT License - see LICENSE file for details.
## Credits
Created for OpenClaw by the ClawPet team. Inspired by Tamagotchi, Pokรฉmon, and D&D mechanics.
๐พ Happy adventuring with your companion!
tools
Comments
Sign in to leave a comment