add-velt 0.1.0

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 ADDED
@@ -0,0 +1,503 @@
1
+ # add-velt
2
+
3
+ CLI tool to add Velt real-time collaboration to your Next.js application.
4
+
5
+ ## Features
6
+
7
+ - **Smart Project Analysis**: Automatically detects your project structure and package manager
8
+ - **Workspace Support**: Detects pnpm/yarn workspaces by checking parent directories
9
+ - **Feature Flags**: Choose specific features (comments, notifications, CRDT types)
10
+ - **Auto-Wiring**: Automatically configures VeltProvider and VeltCollaboration in your app layout
11
+ - **Strict Scoping**: Only installs dependencies and scaffolds files for selected features
12
+ - **Zero Config**: Works out of the box with App Router and Pages Router
13
+ - **Latest Versions**: Always installs the latest package versions (no stale pinned versions)
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npx add-velt
19
+ ```
20
+
21
+ Or install globally:
22
+
23
+ ```bash
24
+ npm install -g add-velt
25
+ add-velt
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Core only (minimal setup)
32
+ npx add-velt
33
+
34
+ # Add comments feature
35
+ npx add-velt --comments
36
+
37
+ # Add notifications feature
38
+ npx add-velt --notifications
39
+
40
+ # Add CRDT for ReactFlow canvas
41
+ npx add-velt --reactflow-crdt
42
+
43
+ # Add all features with Tiptap CRDT
44
+ npx add-velt --all --tiptap-crdt
45
+ ```
46
+
47
+ ## Command Reference
48
+
49
+ ```bash
50
+ npx add-velt [options]
51
+ ```
52
+
53
+ ### Feature Flags
54
+
55
+ | Flag | Description |
56
+ |------|-------------|
57
+ | `--comments` | Add comments (VeltComments, VeltCommentsSidebar, VeltCursor) |
58
+ | `--notifications` | Add notifications (VeltNotificationsTool, VeltCursor) |
59
+
60
+ ### CRDT Type Flags (choose one)
61
+
62
+ | Flag | Description | Documentation |
63
+ |------|-------------|---------------|
64
+ | `--reactflow-crdt` | Add ReactFlow CRDT (canvas collaboration) | [ReactFlow CRDT Docs](https://docs.velt.dev/realtime-collaboration/crdt/setup/reactflow) |
65
+ | `--tiptap-crdt` | Add Tiptap CRDT (rich text editor) | [Tiptap CRDT Docs](https://docs.velt.dev/realtime-collaboration/crdt/setup/tiptap) |
66
+ | `--codemirror-crdt` | Add CodeMirror CRDT (code editor) | [CodeMirror CRDT Docs](https://docs.velt.dev/realtime-collaboration/crdt/setup/codemirror) |
67
+
68
+ ### Combined Flag
69
+
70
+ | Flag | Description |
71
+ |------|-------------|
72
+ | `--all` | Enable comments + notifications + CRDT (requires a CRDT type flag) |
73
+
74
+ ### Installation Flags
75
+
76
+ | Flag | Description |
77
+ |------|-------------|
78
+ | `--force`, `-f` | Force overwrite existing files |
79
+ | `--legacy-peer-deps` | Use legacy peer deps (npm only) |
80
+ | `--help`, `-h` | Show help message |
81
+
82
+ ---
83
+
84
+ ## Feature Documentation
85
+
86
+ ### Comments
87
+
88
+ **What it does**: Enables inline commenting on any element in your app. Users can click to add comments, reply to threads, and view all comments in a sidebar.
89
+
90
+ **Documentation**: [Comments Overview](https://docs.velt.dev/async-collaboration/comments/overview)
91
+
92
+ **Flags**: `--comments` or included with `--all`
93
+
94
+ **Components generated**:
95
+ - `VeltCollaboration.tsx` - Renders VeltComments, VeltCommentsSidebar, and VeltCursor
96
+ - `VeltTools.tsx` - Renders VeltPresence and VeltSidebarButton
97
+
98
+ **Code injected**:
99
+ ```tsx
100
+ // In VeltCollaboration.tsx
101
+ <VeltComments
102
+ popoverMode={true}
103
+ shadowDom={false}
104
+ textMode={false}
105
+ commentPinHighlighter={false}
106
+ dialogOnHover={false}
107
+ />
108
+ <VeltCommentsSidebar groupConfig={{ enable: false }} />
109
+ <VeltCursor />
110
+ ```
111
+
112
+ **UI Customization files**:
113
+ - `VeltCommentBubbleWf.tsx` - Custom comment bubble wireframe
114
+ - `VeltCommentToolWf.tsx` - Custom comment tool wireframe
115
+ - `styles.css` - Custom styling
116
+
117
+ ---
118
+
119
+ ### Notifications
120
+
121
+ **What it does**: Adds a notification system that alerts users to comments, mentions, and other collaboration events.
122
+
123
+ **Documentation**: [Notifications Setup](https://docs.velt.dev/async-collaboration/notifications/setup)
124
+
125
+ **Flags**: `--notifications` or included with `--all`
126
+
127
+ **Components generated**:
128
+ - `VeltCollaboration.tsx` - Renders VeltCursor
129
+ - `VeltTools.tsx` - Renders VeltPresence and VeltNotificationsTool
130
+
131
+ **Code injected**:
132
+ ```tsx
133
+ // In VeltTools.tsx
134
+ <VeltNotificationsTool
135
+ settings={true}
136
+ shadowDom={false}
137
+ tabConfig={{
138
+ forYou: { name: "For You", enable: true },
139
+ documents: { name: "Documents", enable: true },
140
+ all: { name: "All", enable: true },
141
+ }}
142
+ />
143
+ ```
144
+
145
+ **UI Customization files**:
146
+ - `VeltNotificationsToolWf.tsx` - Custom notifications wireframe
147
+ - `styles.css` - Custom styling
148
+
149
+ ---
150
+
151
+ ### Presence
152
+
153
+ **What it does**: Shows which users are currently online/active in the document. Displays user avatars and status indicators.
154
+
155
+ **Documentation**: [Presence Setup](https://docs.velt.dev/realtime-collaboration/presence/setup)
156
+
157
+ **Flags**: Automatically included with `--comments`, `--notifications`, or any CRDT flag
158
+
159
+ **Component generated**:
160
+ - `VeltTools.tsx` - Contains VeltPresence
161
+
162
+ **Code injected**:
163
+ ```tsx
164
+ // In VeltTools.tsx
165
+ <VeltPresence />
166
+ ```
167
+
168
+ **Placement**: Render `<VeltTools />` in your toolbar or header area to display the presence indicators.
169
+
170
+ ---
171
+
172
+ ### Cursors
173
+
174
+ **What it does**: Shows live cursor positions of other users in real-time. Users can see where others are pointing/working.
175
+
176
+ **Documentation**: [Cursors Setup](https://docs.velt.dev/realtime-collaboration/cursors/setup)
177
+
178
+ **Flags**: Automatically included with `--comments`, `--notifications`, or any CRDT flag
179
+
180
+ **Component generated**:
181
+ - `VeltCollaboration.tsx` - Contains VeltCursor
182
+
183
+ **Code injected**:
184
+ ```tsx
185
+ // In VeltCollaboration.tsx
186
+ <VeltCursor />
187
+ ```
188
+
189
+ **Placement**: The `<VeltCursor />` component is rendered inside `<VeltCollaboration />` which is auto-wired into your app layout. Cursors appear automatically across your app.
190
+
191
+ ---
192
+
193
+ ## Examples
194
+
195
+ ```bash
196
+ # Core only (minimal setup)
197
+ npx add-velt
198
+
199
+ # Comments only (includes Presence + Cursors)
200
+ npx add-velt --comments
201
+
202
+ # Notifications only (includes Presence + Cursors)
203
+ npx add-velt --notifications
204
+
205
+ # ReactFlow CRDT only (includes Presence + Cursors)
206
+ npx add-velt --reactflow-crdt
207
+
208
+ # Tiptap CRDT only (includes Presence + Cursors)
209
+ npx add-velt --tiptap-crdt
210
+
211
+ # CodeMirror CRDT only (includes Presence + Cursors)
212
+ npx add-velt --codemirror-crdt
213
+
214
+ # Comments + Notifications (includes Presence + Cursors)
215
+ npx add-velt --comments --notifications
216
+
217
+ # Comments + Tiptap CRDT (includes Presence + Cursors)
218
+ npx add-velt --comments --tiptap-crdt
219
+
220
+ # All features with ReactFlow
221
+ npx add-velt --all --reactflow-crdt
222
+
223
+ # All features with Tiptap
224
+ npx add-velt --all --tiptap-crdt
225
+
226
+ # All features with CodeMirror
227
+ npx add-velt --all --codemirror-crdt
228
+
229
+ # Force overwrite existing files
230
+ npx add-velt --all --reactflow-crdt --force
231
+ ```
232
+
233
+ ## Dependencies Installed
234
+
235
+ All dependencies are installed at their **latest versions** (no pinned/stale versions).
236
+
237
+ ### Baseline (always)
238
+
239
+ | Package | Type |
240
+ |---------|------|
241
+ | `@veltdev/react` | Production |
242
+ | `@veltdev/types` | Development |
243
+
244
+ ### ReactFlow CRDT (`--reactflow-crdt`)
245
+
246
+ | Package | Type |
247
+ |---------|------|
248
+ | `@veltdev/reactflow-crdt` | Production |
249
+ | `yjs` | Production |
250
+
251
+ ### Tiptap CRDT (`--tiptap-crdt`)
252
+
253
+ | Package | Type |
254
+ |---------|------|
255
+ | `@veltdev/tiptap-crdt` | Production |
256
+ | `@veltdev/tiptap-crdt-react` | Production |
257
+ | `@veltdev/tiptap-velt-comments` | Production |
258
+ | `yjs` | Production |
259
+ | `y-prosemirror` | Production |
260
+
261
+ ### CodeMirror CRDT (`--codemirror-crdt`)
262
+
263
+ | Package | Type |
264
+ |---------|------|
265
+ | `@veltdev/codemirror-crdt` | Production |
266
+ | `@veltdev/codemirror-crdt-react` | Production |
267
+ | `yjs` | Production |
268
+ | `y-codemirror.next` | Production |
269
+
270
+ ## Files Generated
271
+
272
+ ### Core (always created)
273
+
274
+ ```
275
+ components/velt/
276
+ ├── VeltCollaboration.tsx # Main collaboration wrapper (includes VeltCursor)
277
+ ├── VeltInitializeDocument.tsx # Document initialization
278
+ └── VeltInitializeUser.tsx # User authentication hook
279
+ ```
280
+
281
+ ### With `--comments`
282
+
283
+ ```
284
+ components/velt/
285
+ ├── VeltTools.tsx # Toolbar (VeltPresence, VeltSidebarButton)
286
+ └── ui-customization/
287
+ ├── VeltCustomization.tsx # Dark mode + wireframe wrapper
288
+ ├── VeltCommentBubbleWf.tsx # Comment bubble wireframe
289
+ ├── VeltCommentToolWf.tsx # Comment tool wireframe
290
+ └── styles.css # Custom styles
291
+ ```
292
+
293
+ ### With `--notifications`
294
+
295
+ ```
296
+ components/velt/
297
+ ├── VeltTools.tsx # Toolbar (VeltPresence, VeltNotificationsTool)
298
+ └── ui-customization/
299
+ ├── VeltCustomization.tsx # Dark mode + wireframe wrapper
300
+ ├── VeltNotificationsToolWf.tsx # Notifications wireframe
301
+ └── styles.css # Custom styles
302
+ ```
303
+
304
+ ### With `--comments --notifications`
305
+
306
+ ```
307
+ components/velt/
308
+ ├── VeltTools.tsx # Full toolbar
309
+ └── ui-customization/
310
+ ├── VeltCustomization.tsx
311
+ ├── VeltCommentBubbleWf.tsx
312
+ ├── VeltCommentToolWf.tsx
313
+ ├── VeltNotificationsToolWf.tsx
314
+ ├── VeltSidebarButtonWf.tsx
315
+ └── styles.css
316
+ ```
317
+
318
+ ### With CRDT flags or `--all`
319
+
320
+ ```
321
+ components/velt/
322
+ ├── VeltTools.tsx # Full toolbar (+ VeltHuddleTool for ReactFlow)
323
+ └── ui-customization/
324
+ ├── VeltCustomization.tsx
325
+ ├── VeltCommentBubbleWf.tsx
326
+ ├── VeltCommentToolWf.tsx
327
+ ├── VeltNotificationsToolWf.tsx
328
+ ├── VeltSidebarButtonWf.tsx
329
+ └── styles.css
330
+ ```
331
+
332
+ ## Auto-Wiring
333
+
334
+ The CLI automatically modifies your app layout to include VeltProvider and VeltCollaboration:
335
+
336
+ **App Router** (`app/layout.tsx`):
337
+ - Adds imports for VeltProvider, useVeltAuthProvider, and VeltCollaboration
338
+ - Creates a `VeltClientWrapper` component
339
+ - Wraps `{children}` with the wrapper inside `<body>`
340
+
341
+ **Pages Router** (`pages/_app.tsx`):
342
+ - Adds the same imports
343
+ - Wraps `<Component {...pageProps} />` with VeltClientWrapper
344
+
345
+ The auto-wiring is **idempotent** - running the CLI again won't duplicate the wiring.
346
+
347
+ ## Strict Scoping Rules
348
+
349
+ The CLI enforces strict scoping to avoid installing unnecessary dependencies or files:
350
+
351
+ - **`--comments` only**: No notifications wireframes included
352
+ - **`--notifications` only**: No comment wireframes included
353
+ - **CRDT types**: Only ONE can be selected at a time
354
+ - **`--all`**: REQUIRES a CRDT type flag
355
+
356
+ ## Setup After Installation
357
+
358
+ ### 1. Get Your API Key
359
+
360
+ Get your API key from [Velt Console](https://console.velt.dev).
361
+
362
+ ### 2. Configure API Key
363
+
364
+ After running the CLI, update your API key in the auto-wired layout:
365
+
366
+ ```tsx
367
+ // In app/layout.tsx (auto-generated VeltClientWrapper)
368
+ <VeltProvider apiKey={process.env.NEXT_PUBLIC_VELT_API_KEY || 'YOUR_API_KEY'} authProvider={authProvider}>
369
+ ```
370
+
371
+ Or set `NEXT_PUBLIC_VELT_API_KEY` in your `.env.local` file.
372
+
373
+ ### 3. Configure Document ID
374
+
375
+ Update `components/velt/VeltInitializeDocument.tsx` with your document ID source:
376
+
377
+ ```tsx
378
+ // Replace with your document ID logic
379
+ const documentId = 'your-document-id';
380
+ const documentName = 'your-document-name';
381
+ ```
382
+
383
+ ### 4. Configure User Authentication
384
+
385
+ Update `components/velt/VeltInitializeUser.tsx` with your user context:
386
+
387
+ ```tsx
388
+ // Replace with your user retrieval logic
389
+ const user = {
390
+ userId: 'user-id',
391
+ organizationId: 'organization-id',
392
+ email: 'user@example.com',
393
+ };
394
+ ```
395
+
396
+ ### 5. Add VeltTools (if using features)
397
+
398
+ ```tsx
399
+ import VeltTools from '@/components/velt/VeltTools';
400
+
401
+ export default function MyPage() {
402
+ return (
403
+ <>
404
+ <div className="toolbar">
405
+ <VeltTools />
406
+ </div>
407
+ {/* Your page content */}
408
+ </>
409
+ );
410
+ }
411
+ ```
412
+
413
+ ### 6. CRDT-Specific Setup
414
+
415
+ For CRDT integrations, see the relevant documentation:
416
+ - **ReactFlow**: https://docs.velt.dev/realtime-collaboration/crdt/setup/reactflow
417
+ - **Tiptap**: https://docs.velt.dev/realtime-collaboration/crdt/setup/tiptap
418
+ - **CodeMirror**: https://docs.velt.dev/realtime-collaboration/crdt/setup/codemirror
419
+
420
+ ## Troubleshooting
421
+
422
+ ### Dependency Conflicts
423
+
424
+ ```bash
425
+ npx add-velt --force
426
+ # or
427
+ npx add-velt --legacy-peer-deps
428
+ ```
429
+
430
+ ### Existing Files
431
+
432
+ Use `--force` to overwrite:
433
+
434
+ ```bash
435
+ npx add-velt --comments --force
436
+ ```
437
+
438
+ ### Multiple CRDT Types Error
439
+
440
+ Only one CRDT type can be selected:
441
+
442
+ ```bash
443
+ # Wrong - will error
444
+ npx add-velt --reactflow-crdt --tiptap-crdt
445
+
446
+ # Correct
447
+ npx add-velt --reactflow-crdt
448
+ ```
449
+
450
+ ### --all Without CRDT Type Error
451
+
452
+ The `--all` flag requires a CRDT type:
453
+
454
+ ```bash
455
+ # Wrong - will error
456
+ npx add-velt --all
457
+
458
+ # Correct
459
+ npx add-velt --all --reactflow-crdt
460
+ ```
461
+
462
+ ### Auto-Wiring Failed
463
+
464
+ If no layout file was found, manually wrap your app:
465
+
466
+ ```tsx
467
+ // app/layout.tsx
468
+ import { VeltProvider } from '@veltdev/react';
469
+ import { useVeltAuthProvider } from '@/components/velt/VeltInitializeUser';
470
+ import { VeltCollaboration } from '@/components/velt/VeltCollaboration';
471
+
472
+ function VeltClientWrapper({ children }: { children: React.ReactNode }) {
473
+ const { authProvider } = useVeltAuthProvider();
474
+ return (
475
+ <VeltProvider apiKey="YOUR_API_KEY" authProvider={authProvider}>
476
+ <VeltCollaboration />
477
+ {children}
478
+ </VeltProvider>
479
+ );
480
+ }
481
+
482
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
483
+ return (
484
+ <html lang="en">
485
+ <body>
486
+ <VeltClientWrapper>{children}</VeltClientWrapper>
487
+ </body>
488
+ </html>
489
+ );
490
+ }
491
+ ```
492
+
493
+ ## Version Compatibility
494
+
495
+ - **Next.js**: 13.4.0+
496
+ - **React**: 18.2.0+
497
+ - **TypeScript**: 5.0.0+
498
+ - **Node.js**: 18+
499
+
500
+ ## Support
501
+
502
+ - [Velt Documentation](https://docs.velt.dev)
503
+ - [Velt Console](https://console.velt.dev)
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" width="100%" height="100%" overflow="visible" style="display: block;" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="tabler-icon-bell">
3
+ <path id="Vector" d="M7.29441 13.7726V14.5828C7.29441 15.2274 7.55049 15.8456 8.00631 16.3015C8.46212 16.7573 9.08035 17.0133 9.72497 17.0133C10.3696 17.0133 10.9878 16.7573 11.4436 16.3015C11.8994 15.8456 12.1555 15.2274 12.1555 14.5828V13.7726M8.1046 4.05038C8.1046 3.62064 8.27532 3.20849 8.57919 2.90461C8.88307 2.60073 9.29522 2.43001 9.72497 2.43001C10.1547 2.43001 10.5669 2.60073 10.8707 2.90461C11.1746 3.20849 11.3453 3.62064 11.3453 4.05038C12.2758 4.49034 13.0689 5.17519 13.6398 6.03153C14.2107 6.88787 14.5378 7.88343 14.5861 8.9115V11.3421C14.6471 11.8457 14.8254 12.3281 15.1069 12.7503C15.3883 13.1724 15.7649 13.5226 16.2065 13.7726H3.24349C3.68499 13.5226 4.06162 13.1724 4.34306 12.7503C4.6245 12.3281 4.80289 11.8457 4.86386 11.3421V8.9115C4.91211 7.88343 5.23922 6.88787 5.81011 6.03153C6.38101 5.17519 7.17418 4.49034 8.1046 4.05038Z" stroke="var(--stroke-0, white)" stroke-width="1.21528" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg preserveAspectRatio="none" width="100%" height="100%" overflow="visible" style="display: block;" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path id="Vector 291" d="M1 8.31818L3.09957 2.28192C3.36653 1.5144 4.09009 1 4.9027 1H8H11.0973C11.9099 1 12.6335 1.5144 12.9004 2.28192L15 8.31818M1 8.31818H3.07287C3.57919 8.31818 4.06477 8.51932 4.4228 8.87734L5.84993 10.3045C6.20795 10.6625 6.69354 10.8636 7.19986 10.8636H8H8.80014C9.30646 10.8636 9.79204 10.6625 10.1501 10.3045L11.5772 8.87734C11.9352 8.51932 12.4208 8.31818 12.9271 8.31818H15M1 8.31818V11.6638C1 12.1701 1.20114 12.6557 1.55916 13.0137L1.71357 13.1681C2.07159 13.5261 2.55718 13.7273 3.0635 13.7273H8H12.9365C13.4428 13.7273 13.9284 13.5261 14.2864 13.1681L14.4408 13.0137C14.7989 12.6557 15 12.1701 15 11.6638V8.31818" stroke="var(--stroke-0, white)" stroke-width="1.25"/>
3
+ </svg>