Skip to main content

Modern CLI tool for AI character card management - extract, repositorize, and rebuild character cards

Project description

Card Forge ๐Ÿ”จ

ไธญๆ–‡็‰ˆREADME | English README

Modern CLI tool for AI character card management - Extract, repositorize, and rebuild character cards with ease!

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                                                               โ•‘
โ•‘   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•‘
โ•‘  โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—    โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ•‘
โ•‘  โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ•‘
โ•‘  โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘    โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ•‘
โ•‘  โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•    โ–ˆโ–ˆโ•‘     โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•‘
โ•‘   โ•šโ•โ•โ•โ•โ•โ•โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•     โ•šโ•โ•      โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•  โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•‘
โ•‘                                                                               โ•‘
โ•‘                    ๐Ÿ”จ AI Character Card Management Tool ๐Ÿ”จ                    โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿš€ Features

  • ๐Ÿ“ค Extract: Get character data from PNG files to JSON
  • ๐Ÿ“ Repositorize: Convert cards to version-control friendly file structures
  • ๐Ÿ”จ Rebuild: Reconstruct cards from repositories
  • โœ… Validate: Check card integrity and specification compliance
  • ๐Ÿ“Š Analyze: Get detailed character card information
  • ๐ŸŽจ Modern CLI: Beautiful interface with helpful commands

๐Ÿ”ง Installation

# Install with uv (recommended)
uv add 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

# Generate default configuration file
card-forge init-config

# Show version information
card-forge --version

๐Ÿ“‹ Commands

extract - Extract card data to JSON

card-forge extract card.png                     # Extract to character_name.json
card-forge extract card.png -o mychar.json      # Custom output filename

repo - Convert to repository structure

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

Creates a clean, organized directory 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
    โ”‚   โ””โ”€โ”€ 0012.md
    โ”œโ”€โ”€ group_only_greetings/   # Group chat greetings
    โ”‚   โ””โ”€โ”€ 0011.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 - Rebuild from repository

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

validate - Check card integrity

card-forge validate character.png               # Validate PNG
card-forge validate character.json              # Validate JSON

info - Detailed character analysis

card-forge info character.png                   # Show detailed information

init-config - Generate configuration file

card-forge init-config                          # Generate config.yaml
card-forge init-config -o custom.yaml           # Custom filename

Example output:

๐ŸŽญ CHARACTER: Alice Wonderland
================================================================================
๐Ÿ‘ค Creator: CardMaker
๐Ÿท๏ธ  Tags: fantasy, adventure, curious
๐Ÿ“ Version: 1.0
๐Ÿ”ง Spec: chara_card_v3 v3.0

๐Ÿ“‹ CONTENT OVERVIEW:
  โ€ข Description: 1,250 characters
  โ€ข Personality: 890 characters
  โ€ข Scenario: 1,100 characters
  โ€ข Alternate greetings: 3
  โ€ข Group-only greetings: 1

๐Ÿ“š LOREBOOK:
  โ€ข Name: Wonderland Guide
  โ€ข Entries: 12

๐Ÿ› ๏ธ Development Workflow

1. Extract and Explore

# Extract a character card to see its structure
card-forge extract my_card.png
card-forge info my_card.png

2. Convert to Repository

# Create editable file structure
card-forge repo my_card.png

3. Edit Files

Edit the individual files in your favorite editor:

  • Modify description.md for character description
  • Update personality.md for personality traits
  • Add alternate greetings in alternate_greetings/
  • Edit lorebook entries in character_book/entries/

4. Rebuild and Test

# Rebuild to verify changes
card-forge build my_character/
card-forge validate my_character_rebuilt.json

# Create final PNG
card-forge build my_character/ -f png

๐Ÿ”„ Use Cases

Version Control for Character Development

# Initial setup
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"

# Rebuild for distribution
card-forge build . -f png

Collaborative Character Creation

# Split work among team members
card-forge repo base_character.png

# Person A works on personality.md
# Person B works on lorebook entries
# Person C works on greetings

# Merge changes and rebuild
card-forge build character/ -f png

Character Analysis and Debugging

# Quick analysis
card-forge info problematic_card.png

# Deep validation
card-forge validate character.png
card-forge extract character.png
card-forge repo character.json
card-forge build character/

๐ŸŽฎ Compatibility

  • โœ… SillyTavern: Full compatibility
  • โœ… RisuAI: Full compatibility
  • โœ… Character Card V3: Complete specification support
  • โœ… Legacy formats: Backward compatible

๐Ÿ“ฆ API Usage

For programmatic use:

from forge.helper import extract_card_data, repositorize, rebuild_card

# Extract character card from PNG
card = extract_card_data("character.png")

# Convert to repository structure  
repo_path = repositorize(card)

# Edit files in the repository...

# Rebuild the card
rebuilt_card = rebuild_card(repo_path)

โš™๏ธ Configuration

The tool uses config.yaml for customization. The default configuration works great for most use cases, but you can customize field handling, file patterns, and repository structure as needed.

๐Ÿ› ๏ธ Customizing Repositorization Behavior

Card Forge uses a flexible configuration system that lets you control exactly how character data gets organized into files and directories. Here's how to customize it:

Field Types and Options

Each field in your character card can be configured with different types and behaviors:

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

Card Forge supports powerful template variables for dynamic file naming:

Basic Variables:

  • {idx} - Array index (auto-padded with zeros)
  • {key} - Dictionary key name

Dot Notation (for complex data):

  • {value.name} - Access nested properties
  • {value.id}_{value.title} - Combine multiple properties

Configuration Examples

1. Custom Array Patterns

# Default: alternate_greetings/001.md, 002.md, 003.md
alternate_greetings:
  enabled: true
  type: array
  file_pattern: "greeting_{idx}.md"
  value_type: string

# Result: alternate_greetings/greeting_001.md, greeting_002.md

2. Complex Object Arrays

# For arrays of objects like assets or scripts
assets:
  enabled: true
  type: array
  file_pattern: "{name}_{type}.yaml"  # Uses object properties
  value_type: dict

# Result: assets/portrait_icon.yaml, background_image.yaml

3. Multilingual Content

# Dictionary with language codes as keys
creator_notes_multilingual:
  enabled: true
  type: dict
  file_pattern: "notes_{key}.md"  # key = language code
  value_type: string

# Result: creator_notes_multilingual/notes_en.md, notes_es.md

4. Nested Field Configuration

extensions:
  enabled: true
  type: nested
  fields:
    regex_scripts:
      enabled: true
      type: array
      file_pattern: "{idx}_{scriptName}.yaml"  # Uses script's name property
      value_type: dict

5. Disabling Fields

# Keep some fields in metadata instead of separate files
tags:
  enabled: false  # Will remain in _metadata.yaml
  type: array
  value_type: string

source:
  enabled: false  # Keep URLs in metadata for easier management
  type: array
  value_type: string

Custom Configuration Workflow

  1. Generate default config:

    card-forge init-config -o my_config.yaml
    
  2. Customize field handling:

    # Example: Change how greetings are organized
    alternate_greetings:
      enabled: true
      type: array
      file_pattern: "alt_greeting_{idx}.txt"
      value_type: string
    
  3. Use custom config:

    card-forge repo character.png -c my_config.yaml
    card-forge build character/ -c my_config.yaml
    

Advanced Examples

Organize scripts by functionality:

extensions:
  enabled: true
  type: nested
  fields:
    regex_scripts:
      enabled: true
      type: array
      file_pattern: "{idx}_{scriptName}_{id}.yaml"
      value_type: dict

Lorebook entries with meaningful names:

character_book:
  enabled: true
  type: nested
  fields:
    entries:
      enabled: true
      type: array
      file_pattern: "{id}_{comment}.yaml"  # Uses entry ID and comment
      value_type: dict

Custom string field organization:

# Group all text content in a 'content' subdirectory
description:
  enabled: true
  type: string
  filename: "content/character_description.md"

personality:
  enabled: true
  type: string
  filename: "content/personality_traits.md"

The configuration system is designed to be intuitive yet powerful - you can keep the defaults for quick workflows, or customize everything for complex projects with specific organization needs.

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. 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

card_forge-0.1.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

card_forge-0.1.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file card_forge-0.1.1.tar.gz.

File metadata

  • Download URL: card_forge-0.1.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for card_forge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 322982958d68531baf469d2f2835705a3523f2656f30cf3de230c67aad72a09b
MD5 f52c175dd539df9c7c6a726c5c3aab21
BLAKE2b-256 76376903ad984939c1e8921349f0ad63b29a6b42dd045681aa46d35dedb0da4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for card_forge-0.1.1.tar.gz:

Publisher: publish.yml on Nya-Foundation/card-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file card_forge-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: card_forge-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for card_forge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed3c905688c9ed4b7dd02c6ee5b8c0259016ae03b817202f4f5a1f9e1c4821f
MD5 6af269448bf0af601eed09b9970f5654
BLAKE2b-256 94ee94003eb57cedc2e09928ce49e5e5c12bb526c72193d222061b05957176c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for card_forge-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Nya-Foundation/card-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page