# SillyBubble - Dynamic Chat Bubble Extension

## Extension Purpose
- Creates dynamic chat bubble images from AI-provided text
- Uses a tool function called by the AI to generate markdown image links
- Properly URL-encodes the text parameter in the image URL

## Build & Test Commands
- Extension Installation: Place in `extensions/` directory of SillyTavern
- No build process needed - extension is JavaScript-based
- Test in SillyTavern by verifying:
  - Tool registration with the AI
  - Proper URL encoding of parameters
  - Markdown image rendering in chat

## Code Style Guidelines

### Structure
- Extension name: "SillyBubble"
- Key files: `index.js` (tool registration), `manifest.json`, `style.css`

### Tool Implementation
- Register tool function `generateChatBubbleImage` for AI function calling
- Function should accept text input and return formatted markdown
- Use `encodeURIComponent()` for proper URL parameter encoding
- Return format: `![](image.php?q=encoded_text)`

### JavaScript Patterns
- Use async/await for asynchronous operations
- Rely on jQuery for DOM manipulation
- Import required functions from SillyTavern's extensions.js
- Register event handlers in jQuery ready function

### Extension Settings
- Store settings in `extension_settings[extensionName]`
- Allow configuration of image service URL
- Support style parameters (e.g., bubble style, colors)

## Server Configuration

### SSHFS Mount
- Remote server mounted at `/home/crystal/Projects/SillyBubble/mounts/calista`
- Mount command: `sshfs calista@calista.the.sexiest.cat:/var/www/calista.the.sexiest.cat/ /home/crystal/Projects/SillyBubble/mounts/calista`
- Verify connection: `ls -la /home/crystal/Projects/SillyBubble/mounts/calista`
- Common mount error: If "Transport endpoint is not connected", run `fusermount -u /home/crystal/Projects/SillyBubble/mounts/calista` and try mounting again

### Deploying to Web Server
- Copy files to mounted directory: `cp /home/crystal/Projects/SillyBubble/image.php /home/crystal/Projects/SillyBubble/mounts/calista/`
- Create fonts directory if needed: `mkdir -p /home/crystal/Projects/SillyBubble/mounts/calista/fonts`
- Web server URL: `http://calista.the.sexiest.cat/image.php`
- Required server dependencies: PHP with GD library (`php-gd` package)

### Testing the Image Generator
- Direct test: `http://calista.the.sexiest.cat/image.php?q=Test%20message`
- HTML interface: `http://calista.the.sexiest.cat/sillybubble.html`
- Configure SillyBubble extension to use `http://calista.the.sexiest.cat/image.php` as the image service URL