@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.
@@ -0,0 +1,9 @@
1
+ import {
2
+ createTaskSummaryCommand,
3
+ handleTaskSummary
4
+ } from "./chunk-6XCY6MPX.js";
5
+ export {
6
+ createTaskSummaryCommand,
7
+ handleTaskSummary
8
+ };
9
+ //# sourceMappingURL=summary-G3W57YYB.js.map
@@ -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! ๐Ÿš€