card-forge 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nya Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,312 @@
1
+ Metadata-Version: 2.4
2
+ Name: card-forge
3
+ Version: 0.0.1
4
+ Summary: Modern CLI tool for AI character card management - extract, repositorize, and rebuild character cards
5
+ Author-email: "Nya Foundation Team (k3scat)" <k3scat@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Nya-Foundation/card-forge
8
+ Project-URL: Bug Tracker, https://github.com/Nya-Foundation/card-forge/issues
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.13
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: pillow>=11.3.0
20
+ Requires-Dist: pydantic>=2.11.9
21
+ Requires-Dist: pyyaml>=6.0.3
22
+ Dynamic: license-file
23
+
24
+ # Card Forge 🔨
25
+
26
+ > **[中文版README](README_zh.md) | [English README](README.md)**
27
+
28
+ **Modern CLI tool for AI character card management** - Extract, repositorize, and rebuild character cards with ease!
29
+
30
+ ```
31
+ ╔═══════════════════════════════════════════════════════════════════════════════╗
32
+ ║ ║
33
+ ║ ██████╗ █████╗ ██████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗║
34
+ ║ ██╔════╝██╔══██╗██╔══██╗██╔══██╗ ██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝║
35
+ ║ ██║ ███████║██████╔╝██║ ██║ █████╗ ██║ ██║██████╔╝██║ ███╗█████╗ ║
36
+ ║ ██║ ██╔══██║██╔══██╗██║ ██║ ██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝ ║
37
+ ║ ╚██████╗██║ ██║██║ ██║██████╔╝ ██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗║
38
+ ║ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝║
39
+ ║ ║
40
+ ║ 🔨 AI Character Card Management Tool 🔨 ║
41
+ ║ ║
42
+ ╚═══════════════════════════════════════════════════════════════════════════════╝
43
+ ```
44
+
45
+ ## 🚀 Features
46
+
47
+ - **📤 Extract**: Get character data from PNG files to JSON
48
+ - **📁 Repositorize**: Convert cards to version-control friendly file structures
49
+ - **🔨 Rebuild**: Reconstruct cards from repositories
50
+ - **✅ Validate**: Check card integrity and specification compliance
51
+ - **📊 Analyze**: Get detailed character card information
52
+ - **🎨 Modern CLI**: Beautiful interface with helpful commands
53
+
54
+ ## 🔧 Installation
55
+
56
+ ```bash
57
+ # Install with uv (recommended)
58
+ uv add card-forge
59
+
60
+ # Or with pip
61
+ pip install card-forge
62
+ ```
63
+
64
+ ## 🎯 Quick Start
65
+
66
+ ```bash
67
+ # Extract character data from a PNG file
68
+ card-forge extract character.png
69
+
70
+ # Convert a character card to a repository structure
71
+ card-forge repo character.png
72
+
73
+ # Rebuild a character card from repository
74
+ card-forge build my_character/
75
+
76
+ # Validate a character card
77
+ card-forge validate character.png
78
+
79
+ # Get detailed information about a character
80
+ card-forge info character.png
81
+
82
+ # Generate default configuration file
83
+ card-forge init-config
84
+
85
+ # Show version information
86
+ card-forge --version
87
+ ```
88
+
89
+ ## 📋 Commands
90
+
91
+ ### `extract` - Extract card data to JSON
92
+
93
+ ```bash
94
+ card-forge extract card.png # Extract to character_name.json
95
+ card-forge extract card.png -o mychar.json # Custom output filename
96
+ ```
97
+
98
+ ### `repo` - Convert to repository structure
99
+
100
+ ```bash
101
+ card-forge repo card.png # From PNG file
102
+ card-forge repo character.json # From JSON file
103
+ card-forge repo card.png -c custom_config.yaml # Custom configuration
104
+ ```
105
+
106
+ Creates a clean, organized directory structure:
107
+ ```
108
+ character_name/
109
+ ├── _metadata.yaml # Card metadata (spec, version)
110
+ └── data/
111
+ ├── _metadata.yaml # Remaining character data
112
+ ├── description.md # Character description
113
+ ├── personality.md # Personality traits
114
+ ├── scenario.md # Scenario description
115
+ ├── system_prompt.md # System instructions
116
+ ├── first_message.md # First message
117
+ ├── example_messages.md # Example dialogue
118
+ ├── creator_notes.md # Creator notes
119
+ ├── alternate_greetings/ # Alternative greetings
120
+ │ ├── 1.txt
121
+ │ └── 2.txt
122
+ ├── group_only_greetings/ # Group chat greetings
123
+ │ └── 1.txt
124
+ ├── creator_notes_multilingual/ # Multi-language notes
125
+ │ ├── en.md
126
+ │ └── es.md
127
+ ├── assets/ # Character assets
128
+ │ ├── main_icon.yaml
129
+ │ └── background_image.yaml
130
+ ├── extensions/ # Extensions and scripts
131
+ │ ├── _metadata.yaml
132
+ │ ├── TavernHelper_scripts/
133
+ │ │ └── script_name.yaml
134
+ │ └── regex_scripts/
135
+ │ └── script_name.yaml
136
+ └── character_book/ # Lorebook entries
137
+ ├── _metadata.yaml
138
+ └── entries/
139
+ ├── 1-location.yaml
140
+ └── 2-character.yaml
141
+ ```
142
+
143
+ ### `build` - Rebuild from repository
144
+
145
+ ```bash
146
+ card-forge build my_character/ # Rebuild to JSON
147
+ card-forge build my_character/ -f png # Rebuild to PNG
148
+ card-forge build my_character/ -o rebuilt # Custom output name
149
+ card-forge build my_character/ -f png -b base.png # Custom base image
150
+ ```
151
+
152
+ ### `validate` - Check card integrity
153
+
154
+ ```bash
155
+ card-forge validate character.png # Validate PNG
156
+ card-forge validate character.json # Validate JSON
157
+ ```
158
+
159
+ ### `info` - Detailed character analysis
160
+
161
+ ```bash
162
+ card-forge info character.png # Show detailed information
163
+ ```
164
+
165
+ ### `init-config` - Generate configuration file
166
+
167
+ ```bash
168
+ card-forge init-config # Generate config.yaml
169
+ card-forge init-config -o custom.yaml # Custom filename
170
+ ```
171
+
172
+ Example output:
173
+ ```
174
+ 🎭 CHARACTER: Alice Wonderland
175
+ ================================================================================
176
+ 👤 Creator: CardMaker
177
+ 🏷️ Tags: fantasy, adventure, curious
178
+ 📝 Version: 1.0
179
+ 🔧 Spec: chara_card_v3 v3.0
180
+
181
+ 📋 CONTENT OVERVIEW:
182
+ • Description: 1,250 characters
183
+ • Personality: 890 characters
184
+ • Scenario: 1,100 characters
185
+ • Alternate greetings: 3
186
+ • Group-only greetings: 1
187
+
188
+ 📚 LOREBOOK:
189
+ • Name: Wonderland Guide
190
+ • Entries: 12
191
+ ```
192
+
193
+ ## 🛠️ Development Workflow
194
+
195
+ ### 1. Extract and Explore
196
+ ```bash
197
+ # Extract a character card to see its structure
198
+ card-forge extract my_card.png
199
+ card-forge info my_card.png
200
+ ```
201
+
202
+ ### 2. Convert to Repository
203
+ ```bash
204
+ # Create editable file structure
205
+ card-forge repo my_card.png
206
+ ```
207
+
208
+ ### 3. Edit Files
209
+ Edit the individual files in your favorite editor:
210
+ - Modify `description.md` for character description
211
+ - Update `personality.md` for personality traits
212
+ - Add alternate greetings in `alternate_greetings/`
213
+ - Edit lorebook entries in `character_book/entries/`
214
+
215
+ ### 4. Rebuild and Test
216
+ ```bash
217
+ # Rebuild to verify changes
218
+ card-forge build my_character/
219
+ card-forge validate my_character_rebuilt.json
220
+
221
+ # Create final PNG
222
+ card-forge build my_character/ -f png
223
+ ```
224
+
225
+ ## 🔄 Use Cases
226
+
227
+ ### Version Control for Character Development
228
+ ```bash
229
+ # Initial setup
230
+ card-forge repo character.png
231
+ git init character_name
232
+ cd character_name
233
+ git add .
234
+ git commit -m "Initial character import"
235
+
236
+ # Make changes to files...
237
+ git commit -am "Updated personality traits"
238
+
239
+ # Rebuild for distribution
240
+ card-forge build . -f png
241
+ ```
242
+
243
+ ### Collaborative Character Creation
244
+ ```bash
245
+ # Split work among team members
246
+ card-forge repo base_character.png
247
+
248
+ # Person A works on personality.md
249
+ # Person B works on lorebook entries
250
+ # Person C works on greetings
251
+
252
+ # Merge changes and rebuild
253
+ card-forge build character/ -f png
254
+ ```
255
+
256
+ ### Character Analysis and Debugging
257
+ ```bash
258
+ # Quick analysis
259
+ card-forge info problematic_card.png
260
+
261
+ # Deep validation
262
+ card-forge validate character.png
263
+ card-forge extract character.png
264
+ card-forge repo character.json
265
+ card-forge build character/
266
+ ```
267
+
268
+ ## 🎮 Compatibility
269
+
270
+ - ✅ **SillyTavern**: Full compatibility
271
+ - ✅ **RisuAI**: Full compatibility
272
+ - ✅ **Character Card V3**: Complete specification support
273
+ - ✅ **Legacy formats**: Backward compatible
274
+
275
+ ## 📦 API Usage
276
+
277
+ For programmatic use:
278
+
279
+ ```python
280
+ from forge.helper import extract_card_data, repositorize, rebuild_card
281
+
282
+ # Extract character card from PNG
283
+ card = extract_card_data("character.png")
284
+
285
+ # Convert to repository structure
286
+ repo_path = repositorize(card)
287
+
288
+ # Edit files in the repository...
289
+
290
+ # Rebuild the card
291
+ rebuilt_card = rebuild_card(repo_path)
292
+ ```
293
+
294
+ ## ⚙️ Configuration
295
+
296
+ 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.
297
+
298
+ ## 🤝 Contributing
299
+
300
+ 1. Fork the repository
301
+ 2. Create a feature branch
302
+ 3. Make your changes
303
+ 4. Add tests for new functionality
304
+ 5. Submit a pull request
305
+
306
+ ## 📄 License
307
+
308
+ MIT License - see LICENSE file for details.
309
+
310
+ ---
311
+
312
+ **Card Forge** - Making character card management simple, organized, and version-control friendly! 🎭✨
@@ -0,0 +1,289 @@
1
+ # Card Forge 🔨
2
+
3
+ > **[中文版README](README_zh.md) | [English README](README.md)**
4
+
5
+ **Modern CLI tool for AI character card management** - Extract, repositorize, and rebuild character cards with ease!
6
+
7
+ ```
8
+ ╔═══════════════════════════════════════════════════════════════════════════════╗
9
+ ║ ║
10
+ ║ ██████╗ █████╗ ██████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗║
11
+ ║ ██╔════╝██╔══██╗██╔══██╗██╔══██╗ ██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝║
12
+ ║ ██║ ███████║██████╔╝██║ ██║ █████╗ ██║ ██║██████╔╝██║ ███╗█████╗ ║
13
+ ║ ██║ ██╔══██║██╔══██╗██║ ██║ ██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝ ║
14
+ ║ ╚██████╗██║ ██║██║ ██║██████╔╝ ██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗║
15
+ ║ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝║
16
+ ║ ║
17
+ ║ 🔨 AI Character Card Management Tool 🔨 ║
18
+ ║ ║
19
+ ╚═══════════════════════════════════════════════════════════════════════════════╝
20
+ ```
21
+
22
+ ## 🚀 Features
23
+
24
+ - **📤 Extract**: Get character data from PNG files to JSON
25
+ - **📁 Repositorize**: Convert cards to version-control friendly file structures
26
+ - **🔨 Rebuild**: Reconstruct cards from repositories
27
+ - **✅ Validate**: Check card integrity and specification compliance
28
+ - **📊 Analyze**: Get detailed character card information
29
+ - **🎨 Modern CLI**: Beautiful interface with helpful commands
30
+
31
+ ## 🔧 Installation
32
+
33
+ ```bash
34
+ # Install with uv (recommended)
35
+ uv add card-forge
36
+
37
+ # Or with pip
38
+ pip install card-forge
39
+ ```
40
+
41
+ ## 🎯 Quick Start
42
+
43
+ ```bash
44
+ # Extract character data from a PNG file
45
+ card-forge extract character.png
46
+
47
+ # Convert a character card to a repository structure
48
+ card-forge repo character.png
49
+
50
+ # Rebuild a character card from repository
51
+ card-forge build my_character/
52
+
53
+ # Validate a character card
54
+ card-forge validate character.png
55
+
56
+ # Get detailed information about a character
57
+ card-forge info character.png
58
+
59
+ # Generate default configuration file
60
+ card-forge init-config
61
+
62
+ # Show version information
63
+ card-forge --version
64
+ ```
65
+
66
+ ## 📋 Commands
67
+
68
+ ### `extract` - Extract card data to JSON
69
+
70
+ ```bash
71
+ card-forge extract card.png # Extract to character_name.json
72
+ card-forge extract card.png -o mychar.json # Custom output filename
73
+ ```
74
+
75
+ ### `repo` - Convert to repository structure
76
+
77
+ ```bash
78
+ card-forge repo card.png # From PNG file
79
+ card-forge repo character.json # From JSON file
80
+ card-forge repo card.png -c custom_config.yaml # Custom configuration
81
+ ```
82
+
83
+ Creates a clean, organized directory structure:
84
+ ```
85
+ character_name/
86
+ ├── _metadata.yaml # Card metadata (spec, version)
87
+ └── data/
88
+ ├── _metadata.yaml # Remaining character data
89
+ ├── description.md # Character description
90
+ ├── personality.md # Personality traits
91
+ ├── scenario.md # Scenario description
92
+ ├── system_prompt.md # System instructions
93
+ ├── first_message.md # First message
94
+ ├── example_messages.md # Example dialogue
95
+ ├── creator_notes.md # Creator notes
96
+ ├── alternate_greetings/ # Alternative greetings
97
+ │ ├── 1.txt
98
+ │ └── 2.txt
99
+ ├── group_only_greetings/ # Group chat greetings
100
+ │ └── 1.txt
101
+ ├── creator_notes_multilingual/ # Multi-language notes
102
+ │ ├── en.md
103
+ │ └── es.md
104
+ ├── assets/ # Character assets
105
+ │ ├── main_icon.yaml
106
+ │ └── background_image.yaml
107
+ ├── extensions/ # Extensions and scripts
108
+ │ ├── _metadata.yaml
109
+ │ ├── TavernHelper_scripts/
110
+ │ │ └── script_name.yaml
111
+ │ └── regex_scripts/
112
+ │ └── script_name.yaml
113
+ └── character_book/ # Lorebook entries
114
+ ├── _metadata.yaml
115
+ └── entries/
116
+ ├── 1-location.yaml
117
+ └── 2-character.yaml
118
+ ```
119
+
120
+ ### `build` - Rebuild from repository
121
+
122
+ ```bash
123
+ card-forge build my_character/ # Rebuild to JSON
124
+ card-forge build my_character/ -f png # Rebuild to PNG
125
+ card-forge build my_character/ -o rebuilt # Custom output name
126
+ card-forge build my_character/ -f png -b base.png # Custom base image
127
+ ```
128
+
129
+ ### `validate` - Check card integrity
130
+
131
+ ```bash
132
+ card-forge validate character.png # Validate PNG
133
+ card-forge validate character.json # Validate JSON
134
+ ```
135
+
136
+ ### `info` - Detailed character analysis
137
+
138
+ ```bash
139
+ card-forge info character.png # Show detailed information
140
+ ```
141
+
142
+ ### `init-config` - Generate configuration file
143
+
144
+ ```bash
145
+ card-forge init-config # Generate config.yaml
146
+ card-forge init-config -o custom.yaml # Custom filename
147
+ ```
148
+
149
+ Example output:
150
+ ```
151
+ 🎭 CHARACTER: Alice Wonderland
152
+ ================================================================================
153
+ 👤 Creator: CardMaker
154
+ 🏷️ Tags: fantasy, adventure, curious
155
+ 📝 Version: 1.0
156
+ 🔧 Spec: chara_card_v3 v3.0
157
+
158
+ 📋 CONTENT OVERVIEW:
159
+ • Description: 1,250 characters
160
+ • Personality: 890 characters
161
+ • Scenario: 1,100 characters
162
+ • Alternate greetings: 3
163
+ • Group-only greetings: 1
164
+
165
+ 📚 LOREBOOK:
166
+ • Name: Wonderland Guide
167
+ • Entries: 12
168
+ ```
169
+
170
+ ## 🛠️ Development Workflow
171
+
172
+ ### 1. Extract and Explore
173
+ ```bash
174
+ # Extract a character card to see its structure
175
+ card-forge extract my_card.png
176
+ card-forge info my_card.png
177
+ ```
178
+
179
+ ### 2. Convert to Repository
180
+ ```bash
181
+ # Create editable file structure
182
+ card-forge repo my_card.png
183
+ ```
184
+
185
+ ### 3. Edit Files
186
+ Edit the individual files in your favorite editor:
187
+ - Modify `description.md` for character description
188
+ - Update `personality.md` for personality traits
189
+ - Add alternate greetings in `alternate_greetings/`
190
+ - Edit lorebook entries in `character_book/entries/`
191
+
192
+ ### 4. Rebuild and Test
193
+ ```bash
194
+ # Rebuild to verify changes
195
+ card-forge build my_character/
196
+ card-forge validate my_character_rebuilt.json
197
+
198
+ # Create final PNG
199
+ card-forge build my_character/ -f png
200
+ ```
201
+
202
+ ## 🔄 Use Cases
203
+
204
+ ### Version Control for Character Development
205
+ ```bash
206
+ # Initial setup
207
+ card-forge repo character.png
208
+ git init character_name
209
+ cd character_name
210
+ git add .
211
+ git commit -m "Initial character import"
212
+
213
+ # Make changes to files...
214
+ git commit -am "Updated personality traits"
215
+
216
+ # Rebuild for distribution
217
+ card-forge build . -f png
218
+ ```
219
+
220
+ ### Collaborative Character Creation
221
+ ```bash
222
+ # Split work among team members
223
+ card-forge repo base_character.png
224
+
225
+ # Person A works on personality.md
226
+ # Person B works on lorebook entries
227
+ # Person C works on greetings
228
+
229
+ # Merge changes and rebuild
230
+ card-forge build character/ -f png
231
+ ```
232
+
233
+ ### Character Analysis and Debugging
234
+ ```bash
235
+ # Quick analysis
236
+ card-forge info problematic_card.png
237
+
238
+ # Deep validation
239
+ card-forge validate character.png
240
+ card-forge extract character.png
241
+ card-forge repo character.json
242
+ card-forge build character/
243
+ ```
244
+
245
+ ## 🎮 Compatibility
246
+
247
+ - ✅ **SillyTavern**: Full compatibility
248
+ - ✅ **RisuAI**: Full compatibility
249
+ - ✅ **Character Card V3**: Complete specification support
250
+ - ✅ **Legacy formats**: Backward compatible
251
+
252
+ ## 📦 API Usage
253
+
254
+ For programmatic use:
255
+
256
+ ```python
257
+ from forge.helper import extract_card_data, repositorize, rebuild_card
258
+
259
+ # Extract character card from PNG
260
+ card = extract_card_data("character.png")
261
+
262
+ # Convert to repository structure
263
+ repo_path = repositorize(card)
264
+
265
+ # Edit files in the repository...
266
+
267
+ # Rebuild the card
268
+ rebuilt_card = rebuild_card(repo_path)
269
+ ```
270
+
271
+ ## ⚙️ Configuration
272
+
273
+ 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.
274
+
275
+ ## 🤝 Contributing
276
+
277
+ 1. Fork the repository
278
+ 2. Create a feature branch
279
+ 3. Make your changes
280
+ 4. Add tests for new functionality
281
+ 5. Submit a pull request
282
+
283
+ ## 📄 License
284
+
285
+ MIT License - see LICENSE file for details.
286
+
287
+ ---
288
+
289
+ **Card Forge** - Making character card management simple, organized, and version-control friendly! 🎭✨