@character-foundry/character-foundry 0.1.7 → 0.1.8-dev.1765911858

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.
Files changed (50) hide show
  1. package/README.md +81 -32
  2. package/dist/app-framework.cjs +1 -1
  3. package/dist/app-framework.cjs.map +1 -1
  4. package/dist/app-framework.js +1 -1
  5. package/dist/app-framework.js.map +1 -1
  6. package/dist/charx.cjs.map +1 -1
  7. package/dist/charx.js.map +1 -1
  8. package/dist/core.cjs +1 -1
  9. package/dist/core.cjs.map +1 -1
  10. package/dist/core.d.cts +1 -1
  11. package/dist/core.d.ts +1 -1
  12. package/dist/core.js +1 -1
  13. package/dist/core.js.map +1 -1
  14. package/dist/exporter.cjs +3 -3
  15. package/dist/exporter.cjs.map +1 -1
  16. package/dist/exporter.js +3 -3
  17. package/dist/exporter.js.map +1 -1
  18. package/dist/federation.cjs +6 -6
  19. package/dist/federation.cjs.map +1 -1
  20. package/dist/federation.js +6 -6
  21. package/dist/federation.js.map +1 -1
  22. package/dist/index.cjs +7 -7
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.js +7 -7
  25. package/dist/index.js.map +1 -1
  26. package/dist/loader.cjs +4 -4
  27. package/dist/loader.cjs.map +1 -1
  28. package/dist/loader.js +4 -4
  29. package/dist/loader.js.map +1 -1
  30. package/dist/lorebook.cjs +5 -5
  31. package/dist/lorebook.cjs.map +1 -1
  32. package/dist/lorebook.js +5 -5
  33. package/dist/lorebook.js.map +1 -1
  34. package/dist/media.cjs.map +1 -1
  35. package/dist/media.js.map +1 -1
  36. package/dist/normalizer.cjs.map +1 -1
  37. package/dist/normalizer.js.map +1 -1
  38. package/dist/png.cjs +1 -1
  39. package/dist/png.cjs.map +1 -1
  40. package/dist/png.js +1 -1
  41. package/dist/png.js.map +1 -1
  42. package/dist/schemas.cjs.map +1 -1
  43. package/dist/schemas.js.map +1 -1
  44. package/dist/tokenizers.cjs.map +1 -1
  45. package/dist/tokenizers.js.map +1 -1
  46. package/dist/voxta.cjs +1 -1
  47. package/dist/voxta.cjs.map +1 -1
  48. package/dist/voxta.js +1 -1
  49. package/dist/voxta.js.map +1 -1
  50. package/package.json +6 -6
package/README.md CHANGED
@@ -1,69 +1,118 @@
1
1
  # @character-foundry/character-foundry
2
2
 
3
- Universal TypeScript library for reading, writing, and converting AI character card formats.
3
+ [![npm version](https://img.shields.io/npm/v/@character-foundry/character-foundry.svg)](https://www.npmjs.com/package/@character-foundry/character-foundry)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@character-foundry/character-foundry.svg)](https://www.npmjs.com/package/@character-foundry/character-foundry)
4
5
 
5
- **This is the meta package** - it installs all Character Foundry packages.
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, exportCard } from '@character-foundry/character-foundry';
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
- ## Included Packages
32
+ ## Supported Formats
27
33
 
28
- | Package | Description |
29
- |---------|-------------|
30
- | `core` | Binary utilities, ZIP, base64, security |
31
- | `schemas` | CCv2, CCv3, Voxta types + Zod validation |
32
- | `png` | PNG chunk handling, metadata embedding |
33
- | `charx` | CharX format, JPEG+ZIP hybrids |
34
- | `voxta` | Multi-character packages, scenarios |
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
- // Import specific packages
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 { CCv3DataSchema } from '@character-foundry/character-foundry/schemas';
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
- ## Supported Formats
65
+ ## Available Subpaths
54
66
 
55
- | Format | Read | Write |
56
- |--------|------|-------|
57
- | PNG (TavernCard v2/v3) | | |
58
- | CharX (Risu) | | |
59
- | Voxta (.voxpkg) | | |
60
- | Raw JSON | | |
61
- | Standalone Lorebooks | | |
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
- - [Full documentation](../../docs/)
66
- - [GitHub repository](https://github.com/character-foundry/character-foundry)
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
 
@@ -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 hasError = Boolean(error);
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);