update claude.md
Browse files
CLAUDE.md
CHANGED
@@ -4,7 +4,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
4 |
|
5 |
## Project Overview
|
6 |
|
7 |
-
This is a Svelte 5 + TypeScript + Vite single-page application. It uses the latest Svelte 5 with runes syntax (`$state()`, `$derived()`, etc.).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
## Essential Commands
|
10 |
|
@@ -23,6 +30,12 @@ npm run build
|
|
23 |
|
24 |
# Preview production build
|
25 |
npm run preview
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
```
|
27 |
|
28 |
## Architecture
|
@@ -33,18 +46,79 @@ npm run preview
|
|
33 |
- Reusable components go in `src/lib/`
|
34 |
- Uses Svelte 5 runes syntax (not Svelte 4 syntax)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
### Key Patterns
|
37 |
1. **State Management**: Use `$state()` rune for reactive state
|
38 |
2. **TypeScript**: All components should use `<script lang="ts">`
|
39 |
3. **Imports**: Use ES module imports, components are default exports
|
40 |
4. **Styling**: Component styles are scoped by default, global styles in `src/app.css`
|
|
|
41 |
|
42 |
### Build Configuration
|
43 |
- Vite handles bundling with `vite.config.ts`
|
44 |
- TypeScript config uses project references (tsconfig.json + tsconfig.app.json)
|
45 |
- Production builds go to `dist/` directory
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
## Important Notes
|
48 |
- This is NOT SvelteKit - no routing, SSR, or API routes
|
49 |
- HMR preserves component state (can be toggled in vite.config.ts)
|
50 |
-
- All paths in imports should be relative or use `$lib` alias for src/lib
|
|
|
|
4 |
|
5 |
## Project Overview
|
6 |
|
7 |
+
This is a Svelte 5 + TypeScript + Vite single-page application for a Pokémon-style creature collection game called "Pictuary". It uses the latest Svelte 5 with runes syntax (`$state()`, `$derived()`, etc.).
|
8 |
+
|
9 |
+
### Main Features
|
10 |
+
- **Monster Generation**: Upload images → AI generates unique creatures ("Piclets") with stats and abilities
|
11 |
+
- **Battle System**: Turn-based combat between player and AI opponents
|
12 |
+
- **Collection Management**: Roster of captured Piclets with detailed stats and move sets
|
13 |
+
- **Creature Cards**: Trading card-style interface with type-based designs
|
14 |
+
- **Image Processing**: AI-powered image captioning and creature concept generation
|
15 |
|
16 |
## Essential Commands
|
17 |
|
|
|
30 |
|
31 |
# Preview production build
|
32 |
npm run preview
|
33 |
+
|
34 |
+
# Run tests
|
35 |
+
npm test
|
36 |
+
|
37 |
+
# Run tests with UI
|
38 |
+
npm run test:ui
|
39 |
```
|
40 |
|
41 |
## Architecture
|
|
|
46 |
- Reusable components go in `src/lib/`
|
47 |
- Uses Svelte 5 runes syntax (not Svelte 4 syntax)
|
48 |
|
49 |
+
### Key Components
|
50 |
+
- **Pages**: `Scanner.svelte` (main), `Pictuary.svelte` (collection), `Battle.svelte` (combat)
|
51 |
+
- **Monster Generation**: `MonsterGenerator.svelte`, `MonsterResult.svelte` (redesigned with PicletCard preview)
|
52 |
+
- **Battle System**: `BattleField.svelte`, `ActionButtons.svelte`, turn-based combat logic
|
53 |
+
- **Piclet Management**: `PicletCard.svelte`, `PicletDetail.svelte`, `AddToRosterDialog.svelte`
|
54 |
+
- **Database**: IndexedDB with `schema.ts` defining PicletInstance, BattleMove, Monster types
|
55 |
+
|
56 |
### Key Patterns
|
57 |
1. **State Management**: Use `$state()` rune for reactive state
|
58 |
2. **TypeScript**: All components should use `<script lang="ts">`
|
59 |
3. **Imports**: Use ES module imports, components are default exports
|
60 |
4. **Styling**: Component styles are scoped by default, global styles in `src/app.css`
|
61 |
+
5. **Database**: IndexedDB operations in `src/lib/db/` with async functions for CRUD operations
|
62 |
|
63 |
### Build Configuration
|
64 |
- Vite handles bundling with `vite.config.ts`
|
65 |
- TypeScript config uses project references (tsconfig.json + tsconfig.app.json)
|
66 |
- Production builds go to `dist/` directory
|
67 |
|
68 |
+
## External Dependencies
|
69 |
+
|
70 |
+
### Gradio Client Integration
|
71 |
+
This project uses Gradio Client for connecting to Hugging Face Spaces. **Important**: Use the CDN-based approach, not npm packages.
|
72 |
+
|
73 |
+
**Setup in App.svelte:**
|
74 |
+
```javascript
|
75 |
+
// CDN imports are loaded dynamically
|
76 |
+
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
|
77 |
+
window.gradioClient = { Client };
|
78 |
+
```
|
79 |
+
|
80 |
+
**Usage in other files:**
|
81 |
+
```typescript
|
82 |
+
// Access via window.gradioClient (types are declared in vite-env.d.ts)
|
83 |
+
const client = await window.gradioClient.Client.connect("space-name");
|
84 |
+
```
|
85 |
+
|
86 |
+
**Current Gradio Connections:**
|
87 |
+
- **Flux Image Generation**: `Fraser/flux`
|
88 |
+
- **Joy Caption**: `fancyfeast/joy-caption-pre-alpha`
|
89 |
+
- **Zephyr-7B Text Generation**: `Fraser/zephyr-7b` (fallback)
|
90 |
+
- **Qwen3 Text Generation**: `Qwen/Qwen3-Demo` (primary)
|
91 |
+
|
92 |
+
**Build Notes:**
|
93 |
+
- DO NOT install Gradio Client via npm (`npm install @gradio/client`) - it causes build failures
|
94 |
+
- The CDN approach ensures compatibility with Vite bundling
|
95 |
+
- All Gradio connections should use the established pattern from App.svelte
|
96 |
+
|
97 |
+
### Text Generation Architecture
|
98 |
+
The project uses a smart fallback system:
|
99 |
+
1. **Primary**: Qwen3 via proper Gradio Client connection to `/add_message` endpoint
|
100 |
+
2. **Fallback**: Zephyr-7B for when Qwen3 is unavailable
|
101 |
+
3. **Manager**: `textGenerationManager` handles automatic switching with connection testing
|
102 |
+
|
103 |
+
## Troubleshooting
|
104 |
+
|
105 |
+
### Common Build Issues
|
106 |
+
- **Gradio Client build failures**: Ensure you're NOT using `npm install @gradio/client`. Use CDN imports only.
|
107 |
+
- **Type errors**: Run `npm run check` to identify TypeScript issues before building
|
108 |
+
- **Missing dependencies**: Run `npm install` if packages are missing
|
109 |
+
|
110 |
+
### Monster Generation Issues
|
111 |
+
- **Name extraction problems**: Check `MonsterGenerator.svelte` line 322 - regex should extract content after `# Monster Name`
|
112 |
+
- **Qwen3 connection failures**: System automatically falls back to Zephyr-7B if Qwen3 is unavailable
|
113 |
+
- **Image processing errors**: Verify Flux and Joy Caption clients are properly connected
|
114 |
+
|
115 |
+
### Performance
|
116 |
+
- **Large image files**: Consider image compression before upload
|
117 |
+
- **Slow generation**: Qwen3 may take 10-30 seconds for complex monster concepts
|
118 |
+
- **Battle lag**: IndexedDB operations are async - ensure proper await usage
|
119 |
+
|
120 |
## Important Notes
|
121 |
- This is NOT SvelteKit - no routing, SSR, or API routes
|
122 |
- HMR preserves component state (can be toggled in vite.config.ts)
|
123 |
+
- All paths in imports should be relative or use `$lib` alias for src/lib
|
124 |
+
- IndexedDB is used for local storage - data persists between sessions
|