Modern CLI tool for AI character card management - Extract, repositorize, and rebuild character cards with ease!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โโโโโโโ โโโโโโ โโโโโโโ โโโโโโโ โโโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโโโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โ โโโ โโโโโโโโโโโโโโโโโโโ โโโ โโโโโโ โโโ โโโโโโโโโโโโโโ โโโโโโโโโโ โ
โ โโโ โโโโโโโโโโโโโโโโโโโ โโโ โโโโโโ โโโ โโโโโโโโโโโโโโ โโโโโโโโโ โ
โ โโโโโโโโโโโ โโโโโโ โโโโโโโโโโโ โโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ
โ โโโโโโโโโโ โโโโโโ โโโโโโโโโโ โโโ โโโโโโโ โโโ โโโ โโโโโโโ โโโโโโโโโ
โ โ
โ ๐จ AI Character Card Management Tool ๐จ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ Compatibility Notice: This project is designed primarily for Character Card V3 Specification (CCV3) under https://github.com/kwaroran/character-card-spec-v3. Legacy versions are technically supported but not guaranteed to work correctly with all features.
- ๐ค Extract: Get character data from PNG files to JSON with full CCV3 support
- ๐ Repositorize: Convert cards to version-control friendly file structures
- ๐จ Rebuild: Reconstruct cards from repositories with data integrity validation
- โ Validate: Check card integrity and specification compliance using Pydantic models
- ๐ Analyze: Get detailed character card information and statistics
- โ๏ธ Configurable: Flexible YAML-based configuration for custom workflows
- ๐จ Modern CLI: Beautiful interface with helpful commands and clear feedback
# Install with uv (recommended)
uv add --dev card-forge
# Or with pip
pip install card-forge# Extract character data from a PNG file
card-forge extract character.png
# Convert a character card to a repository structure
card-forge repo character.png
# Rebuild a character card from repository
card-forge build my_character/
# Validate a character card
card-forge validate character.png
# Get detailed information about a character
card-forge info character.pngCard Forge is built on robust Pydantic v2 models that ensure data integrity and type safety throughout the entire workflow. Our models provide:
- Full CCV3 Compliance: Complete implementation of Character Card V3 specification
- Type Safety: All character data is validated using strongly-typed Pydantic models
- Data Integrity: Automatic validation during extraction, repositorization, and rebuilding
- Extensibility: Support for custom extensions and application-specific fields
from forge.models import CharacterCardV3, CharacterCardV3Data, Lorebook, LorebookEntry, Asset
# All character cards are represented as validated Pydantic models
card: CharacterCardV3 = extract_card_data("character.png")
# Access typed data with full IDE support and validation
character_name: str = card.data.name
lorebook: Optional[Lorebook] = card.data.character_book
assets: Optional[List[Asset]] = card.data.assetsModel Features:
- Automatic Validation: Invalid data is caught early with clear error messages
- Type Hints: Full IDE support with autocompletion and type checking
- Flexible Fields: Support for optional fields, defaults, and custom extensions
- JSON Serialization: Seamless conversion between Python objects and JSON
card-forge extract card.png # Extract to character_name.json
card-forge extract card.png -o mychar.json # Custom output filenamecard-forge repo card.png # From PNG file
card-forge repo character.json # From JSON file
card-forge repo card.png -c custom_config.yaml # Custom configurationRepository Structure:
character_name/
โโโ _metadata.yaml # Card metadata (spec, version)
โโโ data/
โโโ _metadata.yaml # Remaining character data
โโโ description.md # Character description
โโโ personality.md # Personality traits
โโโ scenario.md # Scenario description
โโโ system_prompt.md # System instructions
โโโ first_message.md # First message
โโโ example_messages.md # Example dialogue
โโโ creator_notes.md # Creator notes
โโโ alternate_greetings/ # Alternative greetings
โ โโโ 001.md
โ โโโ 002.md
โโโ group_only_greetings/ # Group chat greetings
โ โโโ 001.md
โโโ creator_notes_multilingual/ # Multi-language notes
โ โโโ en.md
โ โโโ es.md
โโโ assets/ # Character assets
โ โโโ main_icon.yaml
โ โโโ background_image.yaml
โโโ extensions/ # Extensions and scripts
โ โโโ _metadata.yaml
โ โโโ TavernHelper_scripts/
โ โ โโโ 001_script_name.yaml
โ โโโ regex_scripts/
โ โโโ 001_script_name.yaml
โโโ character_book/ # Lorebook entries
โโโ _metadata.yaml
โโโ entries/
โโโ 001_location.yaml
โโโ 002_character.yaml
card-forge build my_character/ # Rebuild to JSON
card-forge build my_character/ -f png # Rebuild to PNG
card-forge build my_character/ -o rebuilt # Custom output name
card-forge build my_character/ -f png -b base.png # Custom base imagecard-forge validate character.png # Validate PNG
card-forge validate character.json # Validate JSON
card-forge info character.png # Show detailed informationcard-forge init-config # Generate config.yaml
card-forge init-config -o custom.yaml # Custom filename1. Extract and Explore
card-forge extract my_card.png
card-forge info my_card.png2. Convert to Repository
card-forge repo my_card.png3. Edit Files - Edit individual files in your favorite editor
4. Rebuild and Test
card-forge build my_character/
card-forge validate my_character_rebuilt.json
card-forge build my_character/ -f pngcard-forge repo character.png
git init character_name && cd character_name
git add . && git commit -m "Initial character import"
# Make changes to files...
git commit -am "Updated personality traits"
card-forge build . -f pngcard-forge repo base_character.png
# Team members work on different files
# Person A: personality.md, Person B: lorebook entries, Person C: greetings
card-forge build character/ -f pngcard-forge info problematic_card.png
card-forge validate character.pngProgrammatic Access with Pydantic Models:
from forge.helper import extract_card_data, repositorize, rebuild_card
from forge.models import CharacterCardV3
# Extract character card with full type safety
card: CharacterCardV3 = extract_card_data("character.png")
# Access validated data
print(f"Character: {card.data.name}")
print(f"Creator: {card.data.creator}")
print(f"Lorebook entries: {len(card.data.character_book.entries) if card.data.character_book else 0}")
# Convert to repository structure
repo_path: str = repositorize(card)
# Edit files in the repository...
# Rebuild with validation
rebuilt_card: CharacterCardV3 = rebuild_card(repo_path)Card Forge uses a flexible YAML-based configuration system for customizing how character data is organized into files and directories.
repositorize:
fields:
field_name:
enabled: true/false # Whether to process this field
type: string|array|dict|nested # How to handle the data
filename: "custom.md" # For string types
file_pattern: "{template}" # For arrays and dicts
value_type: string|dict # Type of values in arrays/dicts{idx}- Array index (auto-padded with zeros){value.name}- Access nested properties with dot notation{value.id}_{value.title}- Combine multiple properties
Custom Array Patterns:
alternate_greetings:
enabled: true
type: array
file_pattern: "greeting_{idx}.md"
value_type: stringComplex Object Arrays:
assets:
enabled: true
type: array
file_pattern: "{name}_{type}.yaml"
value_type: dictMultilingual Content:
creator_notes_multilingual:
enabled: true
type: dict
file_pattern: "notes_{key}.md"
value_type: string- โ SillyTavern: Full compatibility
- โ RisuAI: Full compatibility
- โ Character Card V3: Complete specification support
- โ Legacy formats: Backward compatible
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
MIT License - see LICENSE file for details.
Card Forge - Making character card management simple, organized, and version-control friendly! ๐ญโจ