@character-foundry/character-foundry 0.1.6 → 0.1.8-dev.1765911776
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.
- package/README.md +81 -32
- package/dist/app-framework.cjs +1 -1
- package/dist/app-framework.cjs.map +1 -1
- package/dist/app-framework.js +1 -1
- package/dist/app-framework.js.map +1 -1
- package/dist/charx.cjs.map +1 -1
- package/dist/charx.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/exporter.cjs +3 -3
- package/dist/exporter.cjs.map +1 -1
- package/dist/exporter.js +3 -3
- package/dist/exporter.js.map +1 -1
- package/dist/federation.cjs +6 -6
- package/dist/federation.cjs.map +1 -1
- package/dist/federation.js +6 -6
- package/dist/federation.js.map +1 -1
- package/dist/image-utils.cjs +249 -0
- package/dist/image-utils.cjs.map +1 -0
- package/dist/image-utils.d.cts +136 -0
- package/dist/image-utils.d.ts +136 -0
- package/dist/image-utils.js +226 -0
- package/dist/image-utils.js.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +4 -4
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.js +4 -4
- package/dist/loader.js.map +1 -1
- package/dist/lorebook.cjs +5 -5
- package/dist/lorebook.cjs.map +1 -1
- package/dist/lorebook.js +5 -5
- package/dist/lorebook.js.map +1 -1
- package/dist/media.cjs.map +1 -1
- package/dist/media.js.map +1 -1
- package/dist/normalizer.cjs.map +1 -1
- package/dist/normalizer.js.map +1 -1
- package/dist/png.cjs +1 -1
- package/dist/png.cjs.map +1 -1
- package/dist/png.js +1 -1
- package/dist/png.js.map +1 -1
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.js.map +1 -1
- package/dist/tokenizers.cjs.map +1 -1
- package/dist/tokenizers.js.map +1 -1
- package/dist/voxta.cjs +1 -1
- package/dist/voxta.cjs.map +1 -1
- package/dist/voxta.js +1 -1
- package/dist/voxta.js.map +1 -1
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -1,69 +1,118 @@
|
|
|
1
1
|
# @character-foundry/character-foundry
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@character-foundry/character-foundry)
|
|
4
|
+
[](https://www.npmjs.com/package/@character-foundry/character-foundry)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Universal TypeScript library for reading, writing, and converting AI character card formats.
|
|
6
7
|
|
|
7
8
|
## Installation
|
|
8
9
|
|
|
9
10
|
```bash
|
|
11
|
+
# Stable release
|
|
10
12
|
npm install @character-foundry/character-foundry
|
|
13
|
+
|
|
14
|
+
# Development release (latest features, may be unstable)
|
|
15
|
+
npm install @character-foundry/character-foundry@dev
|
|
11
16
|
```
|
|
12
17
|
|
|
13
18
|
## Quick Start
|
|
14
19
|
|
|
15
20
|
```typescript
|
|
16
|
-
import { parseCard
|
|
21
|
+
import { parseCard } from '@character-foundry/character-foundry/loader';
|
|
22
|
+
import { exportCard } from '@character-foundry/character-foundry/exporter';
|
|
17
23
|
|
|
18
24
|
// Load any format (PNG, CharX, Voxta, JSON)
|
|
19
25
|
const { card, assets, format } = parseCard(buffer);
|
|
20
26
|
console.log(card.data.name);
|
|
21
27
|
|
|
22
28
|
// Export to different format
|
|
23
|
-
const pngBuffer = exportCard(card, assets, 'png');
|
|
29
|
+
const pngBuffer = exportCard(card, assets, { format: 'png' });
|
|
24
30
|
```
|
|
25
31
|
|
|
26
|
-
##
|
|
32
|
+
## Supported Formats
|
|
27
33
|
|
|
28
|
-
|
|
|
29
|
-
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
| `lorebook` | Lorebook parsing and conversion |
|
|
36
|
-
| `loader` | Universal parseCard() with format detection |
|
|
37
|
-
| `exporter` | Universal exportCard() with loss detection |
|
|
38
|
-
| `normalizer` | V2 ↔ V3 conversion |
|
|
39
|
-
| `tokenizers` | GPT-4/LLaMA token counting |
|
|
40
|
-
| `media` | Image format detection, thumbnails |
|
|
41
|
-
| `federation` | ActivityPub federation (experimental) |
|
|
42
|
-
| `app-framework` | Schema-driven UI with AutoForm |
|
|
34
|
+
| Format | Read | Write |
|
|
35
|
+
|--------|------|-------|
|
|
36
|
+
| PNG (TavernCard v2/v3) | ✅ | ✅ |
|
|
37
|
+
| CharX (Risu) | ✅ | ✅ |
|
|
38
|
+
| Voxta (.voxpkg) | ✅ | ✅ |
|
|
39
|
+
| Raw JSON | ✅ | ✅ |
|
|
40
|
+
| Standalone Lorebooks | ✅ | ✅ |
|
|
43
41
|
|
|
44
42
|
## Subpath Imports
|
|
45
43
|
|
|
44
|
+
All functionality is available via subpath exports:
|
|
45
|
+
|
|
46
46
|
```typescript
|
|
47
|
-
//
|
|
47
|
+
// Core functionality
|
|
48
48
|
import { parseCard } from '@character-foundry/character-foundry/loader';
|
|
49
|
+
import { exportCard, checkExportLoss } from '@character-foundry/character-foundry/exporter';
|
|
50
|
+
|
|
51
|
+
// Schemas and validation
|
|
52
|
+
import { CCv3DataSchema, isV3Card, parseV3Card } from '@character-foundry/character-foundry/schemas';
|
|
53
|
+
|
|
54
|
+
// Format-specific
|
|
55
|
+
import { readVoxta, mergeCharacterEdits } from '@character-foundry/character-foundry/voxta';
|
|
56
|
+
import { readCharX, writeCharX } from '@character-foundry/character-foundry/charx';
|
|
57
|
+
import { readPng, writePng } from '@character-foundry/character-foundry/png';
|
|
58
|
+
|
|
59
|
+
// Utilities
|
|
49
60
|
import { countTokens } from '@character-foundry/character-foundry/tokenizers';
|
|
50
|
-
import {
|
|
61
|
+
import { ccv2ToCCv3, ccv3ToCCv2Wrapped } from '@character-foundry/character-foundry/normalizer';
|
|
62
|
+
import { parseLorebook, serializeLorebook } from '@character-foundry/character-foundry/lorebook';
|
|
51
63
|
```
|
|
52
64
|
|
|
53
|
-
##
|
|
65
|
+
## Available Subpaths
|
|
54
66
|
|
|
55
|
-
|
|
|
56
|
-
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
| Voxta
|
|
60
|
-
|
|
|
61
|
-
|
|
|
67
|
+
| Subpath | Description |
|
|
68
|
+
|---------|-------------|
|
|
69
|
+
| `/loader` | Universal parseCard() with format detection |
|
|
70
|
+
| `/exporter` | Universal exportCard() with loss detection |
|
|
71
|
+
| `/schemas` | CCv2, CCv3, Voxta types + Zod validation |
|
|
72
|
+
| `/core` | Binary utilities, ZIP, base64, security |
|
|
73
|
+
| `/png` | PNG chunk handling, metadata embedding |
|
|
74
|
+
| `/charx` | CharX format, JPEG+ZIP hybrids |
|
|
75
|
+
| `/voxta` | Multi-character packages, scenarios |
|
|
76
|
+
| `/lorebook` | Lorebook parsing and conversion |
|
|
77
|
+
| `/normalizer` | V2 ↔ V3 conversion |
|
|
78
|
+
| `/tokenizers` | GPT-4/LLaMA token counting |
|
|
79
|
+
| `/media` | Image format detection, thumbnails |
|
|
80
|
+
| `/image-utils` | Image URL extraction, SSRF protection |
|
|
81
|
+
| `/federation` | ActivityPub federation (experimental) |
|
|
82
|
+
| `/app-framework` | Schema-driven UI with AutoForm |
|
|
83
|
+
|
|
84
|
+
## Runtime Validation
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { CCv3DataSchema, isV3Card, safeParse } from '@character-foundry/character-foundry/schemas';
|
|
88
|
+
|
|
89
|
+
// Type guard
|
|
90
|
+
if (isV3Card(data)) {
|
|
91
|
+
console.log(data.data.name);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Safe parse with error details
|
|
95
|
+
const result = safeParse(CCv3DataSchema, data);
|
|
96
|
+
if (!result.success) {
|
|
97
|
+
console.error(`${result.error} at ${result.field}`);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## CLI Tool
|
|
102
|
+
|
|
103
|
+
For command-line usage, install the CLI package:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm install -g @character-foundry/cli
|
|
107
|
+
cf detect card.png
|
|
108
|
+
cf info card.png
|
|
109
|
+
cf export card.png --to charx
|
|
110
|
+
```
|
|
62
111
|
|
|
63
112
|
## Documentation
|
|
64
113
|
|
|
65
|
-
- [
|
|
66
|
-
- [
|
|
114
|
+
- [GitHub Repository](https://github.com/character-foundry/character-foundry)
|
|
115
|
+
- [Changelog](https://github.com/character-foundry/character-foundry/blob/master/CHANGELOG.md)
|
|
67
116
|
|
|
68
117
|
## License
|
|
69
118
|
|
package/dist/app-framework.cjs
CHANGED
|
@@ -1190,7 +1190,7 @@ function FileUpload({
|
|
|
1190
1190
|
const id = `field-${name}`;
|
|
1191
1191
|
const errorId = `${id}-error`;
|
|
1192
1192
|
const helperId = `${id}-helper`;
|
|
1193
|
-
const
|
|
1193
|
+
const _hasError = Boolean(error);
|
|
1194
1194
|
const hasHelper = Boolean(hint?.helperText);
|
|
1195
1195
|
const inputRef = (0, import_react6.useRef)(null);
|
|
1196
1196
|
const [isDragging, setIsDragging] = (0, import_react6.useState)(false);
|