Modern CLI tool for AI character card management - extract, repositorize, and rebuild character cards
Project description
Card Forge ๐จ
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.
๐ Key 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
๐ง Installation
# Install with uv (recommended)
uv add --dev card-forge
# Or with pip
pip install card-forge
๐ฏ Quick Start
# 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.png
๐๏ธ Architecture & Data Models
Card 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
Core Models
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.assets
Model 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
๐ Command Reference
Extract Command
card-forge extract card.png # Extract to character_name.json
card-forge extract card.png -o mychar.json # Custom output filename
Repository Command
card-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 configuration
Repository 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
Build Command
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 image
Validation & Analysis
card-forge validate character.png # Validate PNG
card-forge validate character.json # Validate JSON
card-forge info character.png # Show detailed information
Configuration
card-forge init-config # Generate config.yaml
card-forge init-config -o custom.yaml # Custom filename
๐ ๏ธ Development Workflow
1. Extract and Explore
card-forge extract my_card.png
card-forge info my_card.png
2. Convert to Repository
card-forge repo my_card.png
3. 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 png
๐ Common Use Cases
Version Control for Character Development
card-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 png
Collaborative Character Creation
card-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 png
Character Analysis and Debugging
card-forge info problematic_card.png
card-forge validate character.png
๐ฆ API Usage
Programmatic 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)
โ๏ธ Configuration System
Card Forge uses a flexible YAML-based configuration system for customizing how character data is organized into files and directories.
Field Types and Options
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
Template Variables
{idx}- Array index (auto-padded with zeros){value.name}- Access nested properties with dot notation{value.id}_{value.title}- Combine multiple properties
Configuration Examples
Custom Array Patterns:
alternate_greetings:
enabled: true
type: array
file_pattern: "greeting_{idx}.md"
value_type: string
Complex Object Arrays:
assets:
enabled: true
type: array
file_pattern: "{name}_{type}.yaml"
value_type: dict
Multilingual Content:
creator_notes_multilingual:
enabled: true
type: dict
file_pattern: "notes_{key}.md"
value_type: string
๐ฎ Compatibility
- โ SillyTavern: Full compatibility
- โ RisuAI: Full compatibility
- โ Character Card V3: Complete specification support
- โ Legacy formats: Backward compatible
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
๐ License
MIT License - see LICENSE file for details.
Card Forge - Making character card management simple, organized, and version-control friendly! ๐ญโจ
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file card_forge-0.2.0.tar.gz.
File metadata
- Download URL: card_forge-0.2.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18119ea99455c22a5a637ae01268d837b3b89668746edda1a91fbd93e8a6aac8
|
|
| MD5 |
972e41ee00d0d7be8a22c4ad9cc5e3a0
|
|
| BLAKE2b-256 |
b95b12755570924fbf2c4b05e82088164f88687449e3692f14140a15497fc56d
|
Provenance
The following attestation bundles were made for card_forge-0.2.0.tar.gz:
Publisher:
publish.yml on Nya-Foundation/card-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
card_forge-0.2.0.tar.gz -
Subject digest:
18119ea99455c22a5a637ae01268d837b3b89668746edda1a91fbd93e8a6aac8 - Sigstore transparency entry: 593052567
- Sigstore integration time:
-
Permalink:
Nya-Foundation/card-forge@c39b7cf8d56d484ac0930f13b28e7bb79993d1b4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nya-Foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c39b7cf8d56d484ac0930f13b28e7bb79993d1b4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file card_forge-0.2.0-py3-none-any.whl.
File metadata
- Download URL: card_forge-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5ee9be5af546ac33325d8159a5a95f212801c93c56b4e96bc70bf229f47d4f9
|
|
| MD5 |
002a6f569d8f8ceab30c809d5188fae2
|
|
| BLAKE2b-256 |
ec3c5eb09f18d91f9c017df1f179cbcd4b6105c8615814c53ca8a2eb3e78301d
|
Provenance
The following attestation bundles were made for card_forge-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Nya-Foundation/card-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
card_forge-0.2.0-py3-none-any.whl -
Subject digest:
c5ee9be5af546ac33325d8159a5a95f212801c93c56b4e96bc70bf229f47d4f9 - Sigstore transparency entry: 593052604
- Sigstore integration time:
-
Permalink:
Nya-Foundation/card-forge@c39b7cf8d56d484ac0930f13b28e7bb79993d1b4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nya-Foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c39b7cf8d56d484ac0930f13b28e7bb79993d1b4 -
Trigger Event:
push
-
Statement type: