@jvittechs/j 1.0.11
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 +25 -0
- package/dist/chunk-6XCY6MPX.js +400 -0
- package/dist/chunk-6XCY6MPX.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +16875 -0
- package/dist/cli.js.map +1 -0
- package/dist/summary-G3W57YYB.js +9 -0
- package/dist/summary-G3W57YYB.js.map +1 -0
- package/dist/web-chat/README.md +418 -0
- package/dist/web-chat/app.js +2012 -0
- package/dist/web-chat/index.html +325 -0
- package/dist/web-chat/style.css +2129 -0
- package/package.json +101 -0
- package/redmine.config.example.yaml +29 -0
- package/scripts/postinstall.js +75 -0
- package/scripts/redmine-sync-issue.sh +35 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
# Jai1 Web Chat
|
|
2
|
+
|
|
3
|
+
A modern, lightweight web-based chat interface for Jai1 AI with support for multiple LLM providers, real-time streaming, and rich markdown rendering including Mermaid diagrams.
|
|
4
|
+
|
|
5
|
+
## โจ Features
|
|
6
|
+
|
|
7
|
+
### Core Functionality
|
|
8
|
+
- ๐ค **Multi-Model Support** - Switch between Claude, GPT, and Gemini
|
|
9
|
+
- โก **Real-time Streaming** - Server-Sent Events for instant responses
|
|
10
|
+
- ๐พ **Local Storage** - Conversations persist in browser localStorage
|
|
11
|
+
- ๐งต **Thread Management** - Multiple conversations with history
|
|
12
|
+
- ๐จ **Beautiful UI** - Modern, dark-themed interface with ambient effects
|
|
13
|
+
- ๐ **Usage Stats** - Track model usage in real-time
|
|
14
|
+
|
|
15
|
+
### Rich Content Rendering
|
|
16
|
+
- ๐ **Markdown Support** - Full GitHub Flavored Markdown (GFM)
|
|
17
|
+
- ๐จ **Syntax Highlighting** - Code blocks with Prism.js
|
|
18
|
+
- ๐งโโ๏ธ **Mermaid Diagrams** - Flowcharts, sequences, classes, and more
|
|
19
|
+
- ๐ **Tables** - Fully formatted markdown tables
|
|
20
|
+
- ๐ **Smart Links** - Auto-open in new tabs with security
|
|
21
|
+
- ๐ฌ **Inline Code** - Styled code snippets
|
|
22
|
+
|
|
23
|
+
### Developer Experience
|
|
24
|
+
- ๐ **Zero Build Step** - Pure vanilla JavaScript
|
|
25
|
+
- ๐ฆ **CDN Based** - No npm install required
|
|
26
|
+
- ๐ง **Easy to Customize** - Clean, documented code
|
|
27
|
+
- ๐งช **Test Suite** - Comprehensive test files included
|
|
28
|
+
- ๐ **Well Documented** - Extensive markdown documentation
|
|
29
|
+
|
|
30
|
+
## ๐ Quick Start
|
|
31
|
+
|
|
32
|
+
### 1. Run the Server
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Start the Jai1 web chat server
|
|
36
|
+
jai1 chat --web
|
|
37
|
+
|
|
38
|
+
# Or specify a port
|
|
39
|
+
jai1 chat --web --port 3000
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Open in Browser
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
http://localhost:3000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Start Chatting!
|
|
49
|
+
|
|
50
|
+
- Type your message in the input field
|
|
51
|
+
- Press `Enter` to send (or `Shift+Enter` for new line)
|
|
52
|
+
- Watch the AI response stream in real-time
|
|
53
|
+
- Switch models using the dropdown
|
|
54
|
+
- Create new threads with `Cmd/Ctrl+N`
|
|
55
|
+
|
|
56
|
+
## ๐ Project Structure
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
web-chat/
|
|
60
|
+
โโโ index.html # Main application
|
|
61
|
+
โโโ app.js # Application logic
|
|
62
|
+
โโโ style.css # Styling and themes
|
|
63
|
+
โ
|
|
64
|
+
โโโ DOCUMENTATION:
|
|
65
|
+
โโโ README.md # This file
|
|
66
|
+
โโโ README-ZERO-MD.md # Zero-MD integration guide
|
|
67
|
+
โโโ MERMAID-SUPPORT.md # Mermaid diagrams guide
|
|
68
|
+
โโโ FIX-SUMMARY.md # Zero-MD fix history
|
|
69
|
+
โโโ TEST-FILES.md # Test files guide
|
|
70
|
+
โ
|
|
71
|
+
โโโ TEST FILES:
|
|
72
|
+
โโโ test-simple.html # Basic functionality test
|
|
73
|
+
โโโ test-zero-md.html # Full markdown test
|
|
74
|
+
โโโ test-mermaid-quick.html # Quick mermaid test
|
|
75
|
+
โโโ test-mermaid.html # Full mermaid test suite
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## ๐ ๏ธ Technology Stack
|
|
79
|
+
|
|
80
|
+
### Frontend
|
|
81
|
+
- **Vanilla JavaScript** - No frameworks, pure ES6+
|
|
82
|
+
- **Web Components** - Zero-MD for markdown rendering
|
|
83
|
+
- **CSS Variables** - Dynamic theming support
|
|
84
|
+
- **LocalStorage API** - Client-side persistence
|
|
85
|
+
|
|
86
|
+
### Libraries (CDN)
|
|
87
|
+
- **[Zero-MD](https://github.com/zerodevx/zero-md)** `v3` - Markdown renderer
|
|
88
|
+
- **[Zero-MD-Mermaid](https://github.com/stefanvanburen/zero-md-mermaid)** `v0.0.6` - Mermaid plugin
|
|
89
|
+
- **Inter Font** - Primary UI font
|
|
90
|
+
- **JetBrains Mono** - Code font
|
|
91
|
+
|
|
92
|
+
### Backend API
|
|
93
|
+
- **Node.js** - Server runtime
|
|
94
|
+
- **Express** - Web framework
|
|
95
|
+
- **SSE** - Server-Sent Events for streaming
|
|
96
|
+
- **Session-based Auth** - Secure token validation
|
|
97
|
+
|
|
98
|
+
## ๐ Key Files Explained
|
|
99
|
+
|
|
100
|
+
### `index.html`
|
|
101
|
+
Main HTML structure with:
|
|
102
|
+
- Zero-MD and Mermaid plugin imports
|
|
103
|
+
- Application layout (header, sidebars, chat area)
|
|
104
|
+
- Input controls and model selector
|
|
105
|
+
- Loading and error modals
|
|
106
|
+
|
|
107
|
+
### `app.js`
|
|
108
|
+
Core application logic:
|
|
109
|
+
- **Storage** - LocalStorage management with cleanup
|
|
110
|
+
- **API** - Server communication and streaming
|
|
111
|
+
- **Conversations** - Thread management
|
|
112
|
+
- **UI** - Rendering and user interactions
|
|
113
|
+
- **Event Handlers** - User input and actions
|
|
114
|
+
|
|
115
|
+
### `style.css`
|
|
116
|
+
Modern styling with:
|
|
117
|
+
- CSS variables for theming
|
|
118
|
+
- Glassmorphism effects
|
|
119
|
+
- Ambient background animations
|
|
120
|
+
- Responsive design
|
|
121
|
+
- Dark mode optimized
|
|
122
|
+
|
|
123
|
+
## ๐งช Testing
|
|
124
|
+
|
|
125
|
+
### Quick Tests
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# 1. Basic functionality (5 seconds)
|
|
129
|
+
open test-simple.html
|
|
130
|
+
|
|
131
|
+
# 2. Mermaid diagrams (10 seconds)
|
|
132
|
+
open test-mermaid-quick.html
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Full Test Suite
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# 1. Complete markdown features (15 seconds)
|
|
139
|
+
open test-zero-md.html
|
|
140
|
+
|
|
141
|
+
# 2. All mermaid diagram types (20 seconds)
|
|
142
|
+
open test-mermaid.html
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
See [TEST-FILES.md](TEST-FILES.md) for detailed testing guide.
|
|
146
|
+
|
|
147
|
+
## ๐จ Mermaid Diagram Support
|
|
148
|
+
|
|
149
|
+
The chat supports all Mermaid diagram types:
|
|
150
|
+
|
|
151
|
+
```markdown
|
|
152
|
+
# Example: System Flow
|
|
153
|
+
|
|
154
|
+
```mermaid
|
|
155
|
+
flowchart LR
|
|
156
|
+
A[User] --> B[Frontend]
|
|
157
|
+
B --> C[API]
|
|
158
|
+
C --> D[LLM]
|
|
159
|
+
D --> C
|
|
160
|
+
C --> B
|
|
161
|
+
B --> A
|
|
162
|
+
```
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Supported types:**
|
|
166
|
+
- Flowcharts
|
|
167
|
+
- Sequence diagrams
|
|
168
|
+
- Class diagrams
|
|
169
|
+
- State diagrams
|
|
170
|
+
- Gantt charts
|
|
171
|
+
- Pie charts
|
|
172
|
+
- Git graphs
|
|
173
|
+
- Entity relationship
|
|
174
|
+
- User journeys
|
|
175
|
+
|
|
176
|
+
See [MERMAID-SUPPORT.md](MERMAID-SUPPORT.md) for complete guide.
|
|
177
|
+
|
|
178
|
+
## ๐ง Configuration
|
|
179
|
+
|
|
180
|
+
### Session Token
|
|
181
|
+
|
|
182
|
+
The app uses session tokens for authentication:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Automatically passed via URL parameter
|
|
186
|
+
http://localhost:3000?token=your-session-token
|
|
187
|
+
|
|
188
|
+
# Or stored in localStorage
|
|
189
|
+
localStorage.setItem('jai1-session', JSON.stringify({
|
|
190
|
+
token: 'your-token',
|
|
191
|
+
storedAt: Date.now()
|
|
192
|
+
}));
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Storage Limits
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
// In app.js
|
|
199
|
+
const MAX_STORAGE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
200
|
+
const MAX_CONTEXT_TOKENS = 100000; // 100k tokens
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Models
|
|
204
|
+
|
|
205
|
+
Models are fetched from the API:
|
|
206
|
+
- `claude-3-5-sonnet-20241022`
|
|
207
|
+
- `gpt-4-turbo`
|
|
208
|
+
- `gemini-pro`
|
|
209
|
+
- And more...
|
|
210
|
+
|
|
211
|
+
## ๐ Documentation
|
|
212
|
+
|
|
213
|
+
### For Users
|
|
214
|
+
- `README.md` - This file (getting started)
|
|
215
|
+
- `TEST-FILES.md` - How to test the application
|
|
216
|
+
|
|
217
|
+
### For Developers
|
|
218
|
+
- `README-ZERO-MD.md` - Zero-MD integration details
|
|
219
|
+
- `MERMAID-SUPPORT.md` - Mermaid diagram guide
|
|
220
|
+
- `FIX-SUMMARY.md` - Bug fix history
|
|
221
|
+
|
|
222
|
+
### Code Comments
|
|
223
|
+
All JavaScript files are extensively commented for easy understanding.
|
|
224
|
+
|
|
225
|
+
## ๐ Troubleshooting
|
|
226
|
+
|
|
227
|
+
### Messages Not Displaying
|
|
228
|
+
|
|
229
|
+
**Problem**: Conversation messages appear blank.
|
|
230
|
+
|
|
231
|
+
**Solution**: Verify Zero-MD is loaded correctly in `index.html`:
|
|
232
|
+
|
|
233
|
+
```html
|
|
234
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/zero-md@3?register"></script>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
See [FIX-SUMMARY.md](FIX-SUMMARY.md) for details.
|
|
238
|
+
|
|
239
|
+
### Mermaid Diagrams Show as Code
|
|
240
|
+
|
|
241
|
+
**Problem**: Diagrams render as code blocks instead of visual diagrams.
|
|
242
|
+
|
|
243
|
+
**Solution**: Ensure mermaid plugin is loaded:
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@stefanvanburen/zero-md-mermaid@0.0.6"></script>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Test with `test-mermaid-quick.html` to verify.
|
|
250
|
+
|
|
251
|
+
### Session Expired Error
|
|
252
|
+
|
|
253
|
+
**Problem**: "Session expired" modal appears.
|
|
254
|
+
|
|
255
|
+
**Solution**: Run `jai1 chat --web` to generate a new session token.
|
|
256
|
+
|
|
257
|
+
### Storage Full Warning
|
|
258
|
+
|
|
259
|
+
**Problem**: Warning about storage limit.
|
|
260
|
+
|
|
261
|
+
**Solution**:
|
|
262
|
+
1. Delete old conversations
|
|
263
|
+
2. Clear browser localStorage
|
|
264
|
+
3. Increase `MAX_STORAGE_SIZE` in `app.js`
|
|
265
|
+
|
|
266
|
+
## ๐ฏ Best Practices
|
|
267
|
+
|
|
268
|
+
### For Chat Usage
|
|
269
|
+
1. **Use descriptive titles** - Edit conversation titles for easy reference
|
|
270
|
+
2. **Organize threads** - Create new conversations for different topics
|
|
271
|
+
3. **Monitor token usage** - Check the token counter to avoid limits
|
|
272
|
+
4. **Save important responses** - Use copy button to save content
|
|
273
|
+
|
|
274
|
+
### For Development
|
|
275
|
+
1. **Test before deploying** - Run all test files
|
|
276
|
+
2. **Validate mermaid syntax** - Use https://mermaid.live/
|
|
277
|
+
3. **Check browser console** - Monitor for errors
|
|
278
|
+
4. **Keep docs updated** - Document any changes
|
|
279
|
+
|
|
280
|
+
### For Content Creation
|
|
281
|
+
1. **Use markdown formatting** - Bold, italic, headers for readability
|
|
282
|
+
2. **Include code blocks** - With language tags for syntax highlighting
|
|
283
|
+
3. **Add diagrams** - Use mermaid for visual explanations
|
|
284
|
+
4. **Structure content** - Use headers and lists
|
|
285
|
+
|
|
286
|
+
## ๐ Performance
|
|
287
|
+
|
|
288
|
+
### Optimizations
|
|
289
|
+
- **Lazy loading** - Content loaded on demand
|
|
290
|
+
- **Shadow DOM** - Isolated rendering for zero-md
|
|
291
|
+
- **Event delegation** - Efficient event handling
|
|
292
|
+
- **Debounced updates** - Prevent unnecessary re-renders
|
|
293
|
+
- **Storage cleanup** - Automatic old conversation removal
|
|
294
|
+
|
|
295
|
+
### Metrics
|
|
296
|
+
- **Initial load**: < 2 seconds
|
|
297
|
+
- **Message render**: < 100ms
|
|
298
|
+
- **Mermaid diagrams**: 1-3 seconds
|
|
299
|
+
- **Storage size**: < 5MB (configurable)
|
|
300
|
+
|
|
301
|
+
## ๐ Security
|
|
302
|
+
|
|
303
|
+
### Implemented
|
|
304
|
+
- โ
Session-based authentication
|
|
305
|
+
- โ
CORS headers validation
|
|
306
|
+
- โ
XSS prevention (via zero-md)
|
|
307
|
+
- โ
Secure link handling (`rel="noopener"`)
|
|
308
|
+
- โ
Input sanitization
|
|
309
|
+
|
|
310
|
+
### Recommendations
|
|
311
|
+
- ๐ Use HTTPS in production
|
|
312
|
+
- ๐ Rotate session tokens regularly
|
|
313
|
+
- ๐ Validate all API responses
|
|
314
|
+
- ๐ Implement rate limiting
|
|
315
|
+
- ๐ Monitor for suspicious activity
|
|
316
|
+
|
|
317
|
+
## ๐ Browser Support
|
|
318
|
+
|
|
319
|
+
### Fully Supported
|
|
320
|
+
- โ
Chrome 67+
|
|
321
|
+
- โ
Firefox 63+
|
|
322
|
+
- โ
Safari 10.1+
|
|
323
|
+
- โ
Edge 79+
|
|
324
|
+
|
|
325
|
+
### Requirements
|
|
326
|
+
- ES6 modules support
|
|
327
|
+
- Web Components support
|
|
328
|
+
- LocalStorage API
|
|
329
|
+
- Server-Sent Events (SSE)
|
|
330
|
+
|
|
331
|
+
### Not Supported
|
|
332
|
+
- โ Internet Explorer 11
|
|
333
|
+
- โ Legacy browsers without ES6
|
|
334
|
+
|
|
335
|
+
## ๐ฆ CDN Dependencies
|
|
336
|
+
|
|
337
|
+
```html
|
|
338
|
+
<!-- Required: Zero-MD -->
|
|
339
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/zero-md@3?register"></script>
|
|
340
|
+
|
|
341
|
+
<!-- Fonts -->
|
|
342
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## ๐ค Contributing
|
|
346
|
+
|
|
347
|
+
### Making Changes
|
|
348
|
+
1. Test changes with test files
|
|
349
|
+
2. Update relevant documentation
|
|
350
|
+
3. Verify no console errors
|
|
351
|
+
4. Check responsive design
|
|
352
|
+
5. Run full test suite
|
|
353
|
+
|
|
354
|
+
### Adding Features
|
|
355
|
+
1. Document in appropriate .md file
|
|
356
|
+
2. Add tests if applicable
|
|
357
|
+
3. Update this README if needed
|
|
358
|
+
4. Follow existing code style
|
|
359
|
+
|
|
360
|
+
## ๐ License
|
|
361
|
+
|
|
362
|
+
ISC - Same as parent project
|
|
363
|
+
|
|
364
|
+
## ๐ Acknowledgments
|
|
365
|
+
|
|
366
|
+
- **Zero-MD** - Excellent markdown web component
|
|
367
|
+
- **Mermaid.js** - Beautiful diagram rendering
|
|
368
|
+
- **Inter & JetBrains Mono** - Clean, readable fonts
|
|
369
|
+
- **Prism.js** - Syntax highlighting (bundled with Zero-MD)
|
|
370
|
+
|
|
371
|
+
## ๐ Support
|
|
372
|
+
|
|
373
|
+
- **Documentation**: See .md files in this directory
|
|
374
|
+
- **Issues**: Check browser console for errors
|
|
375
|
+
- **Testing**: Run test files to verify setup
|
|
376
|
+
- **Examples**: Test files contain working examples
|
|
377
|
+
|
|
378
|
+
## ๐ Quick Links
|
|
379
|
+
|
|
380
|
+
- [Zero-MD Documentation](https://zerodevx.github.io/zero-md/)
|
|
381
|
+
- [Mermaid Documentation](https://mermaid.js.org/)
|
|
382
|
+
- [Mermaid Live Editor](https://mermaid.live/)
|
|
383
|
+
- [Test Files Guide](TEST-FILES.md)
|
|
384
|
+
- [Mermaid Support Guide](MERMAID-SUPPORT.md)
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
**Version**: 1.0.0
|
|
389
|
+
**Last Updated**: 2024-12-19
|
|
390
|
+
**Maintainer**: Jai1 Team
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## โก Quick Reference
|
|
395
|
+
|
|
396
|
+
### Keyboard Shortcuts
|
|
397
|
+
- `Enter` - Send message
|
|
398
|
+
- `Shift+Enter` - New line
|
|
399
|
+
- `Cmd/Ctrl+N` - New conversation
|
|
400
|
+
|
|
401
|
+
### API Endpoints
|
|
402
|
+
- `GET /api/session` - Get session info
|
|
403
|
+
- `GET /api/models` - List available models
|
|
404
|
+
- `POST /api/chat/stream` - Stream chat response
|
|
405
|
+
- `GET /api/stats` - Get usage statistics
|
|
406
|
+
|
|
407
|
+
### Storage Keys
|
|
408
|
+
- `jai1-session` - Session token
|
|
409
|
+
- `jai1-conversations` - Chat history
|
|
410
|
+
- `jai1-settings` - User preferences
|
|
411
|
+
|
|
412
|
+
### Test Files Priority
|
|
413
|
+
1. `test-simple.html` - Start here โก
|
|
414
|
+
2. `test-mermaid-quick.html` - Then this ๐งโโ๏ธ
|
|
415
|
+
3. `test-zero-md.html` - Full markdown ๐
|
|
416
|
+
4. `test-mermaid.html` - Full diagrams ๐จ
|
|
417
|
+
|
|
418
|
+
Ready to chat? Run `jai1 chat --web` and enjoy! ๐
|