@cometchat/skills 3.0.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.
@@ -0,0 +1,514 @@
1
+ ---
2
+ name: cometchat-features
3
+ description: Add features (calls, reactions, polls, file sharing, presence, etc.) to an already-integrated CometChat project. Routes to the right sub-flow based on feature type — default features (already enabled), dashboard-toggle features (extensions + AI), package-install features (calls), or component-swap features (rich text).
4
+ license: "MIT"
5
+ compatibility: "Node.js >=18; @cometchat/chat-uikit-react ^6; integration must already be applied"
6
+ allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
7
+ metadata:
8
+ author: "CometChat"
9
+ version: "3.0.0"
10
+ tags: "cometchat features extensions calls reactions polls ai-features"
11
+ ---
12
+
13
+ > **Companion skills:** `cometchat-core` covers initialization and the
14
+ > provider pattern; `cometchat-customization` is the next step when a
15
+ > feature is enabled but needs visual customization;
16
+ > `cometchat-troubleshooting` handles post-feature-enable failures.
17
+
18
+ ## Purpose
19
+
20
+ This skill teaches Claude how CometChat features are structured and
21
+ what work is actually required to enable each one. Most features require
22
+ **zero code** — they are either already built into the UI Kit, enabled
23
+ via a dashboard toggle, or activated by a single npm install.
24
+ Understanding which type a feature is prevents unnecessary work.
25
+
26
+ ---
27
+
28
+ ## 1. Use this skill when
29
+
30
+ The user wants to add a specific feature to an already-integrated CometChat
31
+ project. Trigger phrases:
32
+
33
+ - `/cometchat features`
34
+ - `/cometchat features <name>` (e.g. `/cometchat features reactions`)
35
+ - `/cometchat <feature>` (e.g. `/cometchat polls`, `/cometchat calls`)
36
+ - "add reactions to my chat"
37
+ - "add video calling"
38
+ - "enable polls"
39
+ - "add file sharing"
40
+ - "enable smart replies"
41
+ - "add typing indicators"
42
+
43
+ ## 2. Preconditions
44
+
45
+ The user must have an existing integration:
46
+
47
+ ```bash
48
+ npx @cometchat/skills-cli info --json
49
+ ```
50
+
51
+ If `integrated` is `false`, **stop** and tell the user to run `/cometchat`
52
+ first to create the integration.
53
+
54
+ ## 3. Why features fall into each type
55
+
56
+ CometChat features split into 4 types based on their architecture:
57
+
58
+ - **Type 1 — Default (compiled-in):** These are shipped inside the UI
59
+ Kit component bundle unconditionally. CometChat builds reactions,
60
+ typing indicators, mentions, etc. into `CometChatMessageList` and
61
+ `CometChatMessageComposer` at compile time. The feature is always
62
+ present; the only question is whether the prop that surfaces it is
63
+ enabled. No code or dashboard changes needed.
64
+
65
+ - **Type 2 — Dashboard-toggle (backend extensions):** These are
66
+ backend services hosted by CometChat's infrastructure. The UI Kit
67
+ polls which extensions are enabled via the app's init response. When
68
+ you flip the dashboard toggle, the backend returns a different
69
+ feature flag, and the UI Kit renders the corresponding UI
70
+ automatically. No client code change is needed — the rendering logic
71
+ is already in the UI Kit, just gated on the flag.
72
+
73
+ - **Type 3 — Package-install (separate SDK):** Voice/video calling
74
+ requires a separate WebRTC SDK (`@cometchat/calls-sdk-javascript`)
75
+ because it links against browser media APIs that would bloat every
76
+ integration if bundled unconditionally. Once installed, the UI Kit
77
+ detects it via dynamic import and enables the call UI.
78
+
79
+ - **Type 4 — Component-swap (variant component):** Some features
80
+ require a different component variant because the base component has
81
+ a hard-coded behavior that can't be toggled via props. The CLI does
82
+ a safe word-boundary replace of the component name in your owned
83
+ files. If CometChat adds new variant components in future SDK
84
+ releases, they will follow this same pattern.
85
+
86
+ ---
87
+
88
+ ## 4. The feature catalog
89
+
90
+ ### Type 1 — Default features (~14, already enabled in UI Kit)
91
+
92
+ These are already part of the components your integration uses. The skill's
93
+ job is to **tell the user they're already there** and point at the relevant
94
+ component:
95
+
96
+ - Instant Messaging
97
+ - Media Sharing (file/image/audio/video)
98
+ - Read Receipts
99
+ - Mark as Unread
100
+ - Typing Indicator
101
+ - User Presence (online/offline)
102
+ - Reactions
103
+ - Mentions (incl. @all)
104
+ - Threaded Conversations
105
+ - Quoted Replies
106
+ - Group Chat
107
+ - Report Message
108
+ - Conversation/Advanced Search
109
+
110
+ For these: query the docs MCP for the feature's component/usage docs, show
111
+ the user where it is in their integration. **No code changes needed.**
112
+
113
+ ### Type 2 — Dashboard-toggle features (~40+, no code needed)
114
+
115
+ These require flipping a toggle in the [CometChat Dashboard](https://app.cometchat.com).
116
+ Once enabled, the UI Kit auto-integrates them. **No code changes needed.**
117
+
118
+ > **Note:** The dashboard features page also shows the Type 1 features
119
+ > (Instant Messaging, Reactions, Mentions, etc.) as always-on toggles
120
+ > at the top. Those are already enabled — no action needed. The
121
+ > features below are the ones that actually require toggling on.
122
+
123
+ > **Note:** Conversation and Advanced Search has its own toggle on the
124
+ > Features page. It is on by default but can be disabled. If a user
125
+ > reports that search is missing, check this toggle.
126
+
127
+ **Extensions — User Experience:**
128
+ Avatar, Bitly, Link Preview, Message Shortcuts, Pin Message, Rich
129
+ Media Preview, Save Message, Thumbnail Generation, TinyURL, Voice
130
+ Transcription
131
+
132
+ **Extensions — User Engagement:**
133
+ Broadcast, Giphy, Gfycat, Message Translation, Polls, Reminders,
134
+ Stickers, Stipop, Tenor
135
+
136
+ **Extensions — Collaboration:**
137
+ Collaborative Document, Collaborative Whiteboard
138
+
139
+ **Extensions — Security:**
140
+ Disappearing Messages, E2E Encryption (Enterprise plan only)
141
+
142
+ **Extensions — Moderation** (on the separate Extensions page, not Features):
143
+ Data Masking, Image Moderation, Profanity Filter, Sentiment Analysis,
144
+ XSS Filter, Human Moderation, Report User, Slow Mode,
145
+ Virus/Malware Scanner
146
+
147
+ **Extensions — Notifications** (on the separate Extensions page):
148
+ Email Notification, Push Notification, SMS Notification
149
+
150
+ **Extensions — Customer Support:**
151
+ Chatwoot, Intercom
152
+
153
+ **Smart Chat Features (AI):**
154
+ Conversation Starter, Smart Replies, Conversation Summary
155
+ (AI features are fetched dynamically from the API — the exact list
156
+ depends on your plan and backend configuration.)
157
+
158
+ **Exact dashboard path (give this to the user verbatim):**
159
+
160
+ > **For most features (User Experience, User Engagement, Collaboration, Security, AI):**
161
+ > 1. Open https://app.cometchat.com
162
+ > 2. Select your app
163
+ > 3. In the left sidebar: **Chat & Messaging** → **Features**
164
+ > 4. Find the feature and flip its **Status** toggle to ON
165
+ > 5. Some extensions have a settings icon — click it if the feature
166
+ > needs configuration (e.g. API keys for Giphy)
167
+ > 6. Changes take effect immediately — refresh the chat in the browser
168
+ >
169
+ > **For Moderation and Notification extensions:**
170
+ > These are NOT on the Features page. Navigate to:
171
+ > **Left sidebar → Extensions** (the separate Extensions page)
172
+ > Find the extension and enable it there.
173
+
174
+ After enabling, run `cometchat verify` to ensure the existing
175
+ integration still passes. No code changes are needed — the UI Kit
176
+ picks up enabled features automatically.
177
+
178
+ ### Type 3 — Package-install features (4, calls)
179
+
180
+ These require installing `@cometchat/calls-sdk-javascript`. Once installed,
181
+ the UI Kit auto-detects it and surfaces the call UI in CometChatMessageHeader,
182
+ CometChatConversations, etc.
183
+
184
+ - Call Buttons (in message headers)
185
+ - Incoming Call notifications
186
+ - Outgoing Call interface
187
+ - Call Logs (call history)
188
+
189
+ For these, the user opting in IS consent — run the install directly:
190
+
191
+ ```bash
192
+ npm install @cometchat/calls-sdk-javascript
193
+ npx @cometchat/skills-cli verify --json
194
+ ```
195
+
196
+ The UI Kit's `initiateAfterLogin()` auto-calls `enableCalling()` after the
197
+ package is installed. No manual wiring needed for default call buttons in
198
+ CometChatMessageHeader. Restart the dev server.
199
+
200
+ ### Type 4 — Component-swap features (drop-in variant)
201
+
202
+ Some features require swapping one component for a variant that has
203
+ different default behavior. The CLI handles the swap automatically —
204
+ it walks `state.files_owned`, performs a word-boundary regex replace,
205
+ updates `state.json` checksums, and records the applied feature so
206
+ re-runs are no-ops. Idempotent.
207
+
208
+ Currently available:
209
+
210
+ - `rich-text-formatting` — swaps `CometChatMessageComposer` →
211
+ `CometChatCompactMessageComposer` (the compact variant enables rich
212
+ text formatting by default; the regular composer has
213
+ `enableRichTextEditor=false` baked in)
214
+
215
+ ```bash
216
+ npx @cometchat/skills-cli apply-feature rich-text-formatting
217
+ ```
218
+
219
+ Do NOT hand-edit the swap. The CLI is the source of truth. If future
220
+ SDK releases add new variant components, they will follow this same
221
+ `apply-feature <id>` pattern.
222
+
223
+ ---
224
+
225
+ ## 4b. Deep patterns for three most-requested features
226
+
227
+ For calls, AI smart replies, and presence, the catalog above only says "install a package" or "toggle in dashboard." Here are the concrete compositional patterns so common requests don't require a docs MCP round-trip.
228
+
229
+ ### Calls (audio + video)
230
+
231
+ After `npm install @cometchat/calls-sdk-javascript`, call buttons auto-appear in `CometChatMessageHeader` and the call UI renders in place. **No manual wiring needed** for basic 1:1 audio/video calls.
232
+
233
+ For custom integration — e.g. putting a "Start video call" button outside the message header, or handling an incoming call notification in a custom way — use `CometChatCallButtons` + `CometChatIncomingCall` + `CometChatOngoingCall`:
234
+
235
+ ```tsx
236
+ import { useState, useEffect } from "react";
237
+ import {
238
+ CometChatCallButtons,
239
+ CometChatIncomingCall,
240
+ CometChatOngoingCall,
241
+ } from "@cometchat/chat-uikit-react";
242
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
243
+
244
+ export function CustomCallUI({ targetUser }: { targetUser: CometChat.User }) {
245
+ const [ongoingCall, setOngoingCall] = useState<CometChat.Call>();
246
+
247
+ useEffect(() => {
248
+ // Listen for call state changes
249
+ const listenerId = "custom-call-listener";
250
+ CometChat.addCallListener(
251
+ listenerId,
252
+ new CometChat.CallListener({
253
+ onOutgoingCallAccepted: (call: CometChat.Call) => setOngoingCall(call),
254
+ onIncomingCallCancelled: () => setOngoingCall(undefined),
255
+ onCallEnded: () => setOngoingCall(undefined),
256
+ }),
257
+ );
258
+ return () => CometChat.removeCallListener(listenerId);
259
+ }, []);
260
+
261
+ return (
262
+ <>
263
+ <CometChatCallButtons user={targetUser} />
264
+ <CometChatIncomingCall />
265
+ {ongoingCall && <CometChatOngoingCall call={ongoingCall} />}
266
+ </>
267
+ );
268
+ }
269
+ ```
270
+
271
+ **Common gotchas:**
272
+ - Calls require a logged-in CometChat user on *both* sides. Test from two browsers (or incognito) logged in as different UIDs.
273
+ - `CometChatIncomingCall` must be mounted globally (e.g. in your provider or layout) so incoming calls ring on every page.
274
+ - Group calls use `CometChat.Group` instead of `CometChat.User` on `CometChatCallButtons`.
275
+
276
+ ### AI smart replies
277
+
278
+ Smart replies is a dashboard-toggle feature (Type 2). After enabling it in the dashboard (Extensions → Smart Replies → Toggle on), **no code changes are required** — the `CometChatMessageComposer` automatically renders suggested replies as chips above the input when there's a recent incoming message.
279
+
280
+ For a custom UI — e.g. showing smart replies inline instead of above the composer, or only for certain conversation types — you read the extension data from the incoming message and render your own chips:
281
+
282
+ ```tsx
283
+ function SmartReplyChips({ message }: { message: CometChat.BaseMessage }) {
284
+ const metadata = message.getMetadata() as Record<string, unknown> | undefined;
285
+ const extensions = (metadata?.["@injected"] as Record<string, unknown>)?.["extensions"] as
286
+ | Record<string, unknown>
287
+ | undefined;
288
+ const smartReply = extensions?.["smart-reply"] as { reply_positive?: string; reply_neutral?: string; reply_negative?: string } | undefined;
289
+
290
+ if (!smartReply) return null;
291
+
292
+ const replies = [smartReply.reply_positive, smartReply.reply_neutral, smartReply.reply_negative].filter(Boolean) as string[];
293
+ return (
294
+ <div style={{ display: "flex", gap: 8, padding: 8 }}>
295
+ {replies.map((r) => (
296
+ <button key={r} onClick={() => sendTextMessage(r)}>{r}</button>
297
+ ))}
298
+ </div>
299
+ );
300
+ }
301
+ ```
302
+
303
+ Smart replies are server-generated and attached to messages via the `@injected.extensions.smart-reply` metadata path — the AI feature runs on CometChat's backend, not in your code.
304
+
305
+ ### Presence (online / offline status)
306
+
307
+ Presence is a **default feature** (Type 1) — online status indicators appear automatically on user avatars in `CometChatConversations`, `CometChatUsers`, and `CometChatGroupMembers`. Nothing to install, nothing to enable.
308
+
309
+ For custom UI that needs to know a specific user's online state — e.g. a "Sold by Aria Chen · online now" label on a product page — subscribe to user events:
310
+
311
+ ```tsx
312
+ import { useEffect, useState } from "react";
313
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
314
+
315
+ export function useUserPresence(uid: string): "online" | "offline" | "unknown" {
316
+ const [status, setStatus] = useState<"online" | "offline" | "unknown">("unknown");
317
+
318
+ useEffect(() => {
319
+ // 1. Fetch initial state
320
+ CometChat.getUser(uid).then((u) => {
321
+ setStatus(u.getStatus() === "online" ? "online" : "offline");
322
+ });
323
+
324
+ // 2. Subscribe to live changes
325
+ const listenerId = `presence-${uid}`;
326
+ CometChat.addUserListener(
327
+ listenerId,
328
+ new CometChat.UserListener({
329
+ onUserOnline: (user: CometChat.User) => {
330
+ if (user.getUid() === uid) setStatus("online");
331
+ },
332
+ onUserOffline: (user: CometChat.User) => {
333
+ if (user.getUid() === uid) setStatus("offline");
334
+ },
335
+ }),
336
+ );
337
+ return () => CometChat.removeUserListener(listenerId);
338
+ }, [uid]);
339
+
340
+ return status;
341
+ }
342
+ ```
343
+
344
+ **Common gotchas:**
345
+ - Presence events only fire for users the current user has interacted with (conversation exists, in same group, etc.). For arbitrary UIDs with no prior interaction, you may need to call `CometChat.getUser(uid)` periodically instead.
346
+ - `getStatus()` returns `"online"` or `"offline"` — also check `getLastActiveAt()` for a "last seen X ago" timestamp.
347
+ - "Last seen" is disabled by default on free-tier apps. Enable it in the dashboard (Settings → Chat → Last Seen).
348
+
349
+ ---
350
+
351
+ ## 5. Docs MCP contract
352
+
353
+ The CometChat docs MCP at `cometchat-docs` is a **hard requirement** for
354
+ this skill. It's the canonical source for:
355
+
356
+ - Per-feature SDK reference (props, callbacks, builders, events)
357
+ - Per-feature configuration details beyond the dashboard path above
358
+ - Feature compatibility notes (which features need backend setup,
359
+ which auto-wire, which require explicit `setExtensions([...])`)
360
+
361
+ **Hard rules:**
362
+
363
+ 1. **Always query the docs MCP first** before answering any feature
364
+ question that's not in our local catalog (`cometchat features info`).
365
+ 2. **If the docs MCP is not installed**, STOP. Tell the user:
366
+ "I need the CometChat docs MCP to walk you through this feature.
367
+ Install it with `claude mcp add --transport http cometchat-docs
368
+ https://www.cometchat.com/docs/mcp` and re-run."
369
+ 3. **Use the dashboard path from this skill** (Chat & Messaging →
370
+ Features) for all toggle features. Query the docs MCP for
371
+ per-feature configuration details beyond the basic toggle.
372
+ 4. **Canonical reference URLs** (use as starting points if the agent
373
+ doesn't have an MCP query handy):
374
+ - Extensions: https://www.cometchat.com/docs/ui-kit/react/extensions
375
+ - AI features: https://www.cometchat.com/docs/ui-kit/react/ai-features
376
+ - Calls: https://www.cometchat.com/docs/ui-kit/react/call-features
377
+ - Core features: https://www.cometchat.com/docs/ui-kit/react/core-features
378
+
379
+ ---
380
+
381
+ ## 6. Steps
382
+
383
+ ### Step 1 — Read state
384
+
385
+ ```bash
386
+ npx @cometchat/skills-cli info --json
387
+ ```
388
+
389
+ If not integrated, stop. Otherwise note the framework + experience so you
390
+ can find the right files.
391
+
392
+ ### Step 2 — Determine feature
393
+
394
+ If the user named a feature, use it. Otherwise list the categories above
395
+ and ask which feature they want.
396
+
397
+ ### Step 3 — Classify the feature
398
+
399
+ Match the feature name against the 4 types in section 4. If you don't know
400
+ the type, query the docs MCP first.
401
+
402
+ ### Step 4 — Execute the right sub-flow
403
+
404
+ - **Default:** show the user it's already there. Point at the component.
405
+ Use `npx @cometchat/skills-cli features info <id>` to surface
406
+ the walkthrough verbatim.
407
+ - **CRITICAL — if the user explicitly wants a UI element to surface
408
+ the default feature** (e.g. "implement conversation search",
409
+ "add a search bar", "show typing indicators in the header",
410
+ "expose mentions in the composer"), **do NOT add a new component
411
+ yet**. Most default features are exposed via PROPS on the
412
+ components your integration already mounts:
413
+ - "search bar" → `showSearchBar` on `CometChatConversations`
414
+ (and `onSearchBarClicked` to swap in `<CometChatSearch>` for
415
+ advanced dual-scope search if the user wants that)
416
+ - "filter conversations / messages" → `conversationsRequestBuilder`
417
+ / `messagesRequestBuilder`
418
+ - "custom empty / error / loading state" → `emptyStateView`,
419
+ `errorStateView`, `loadingStateView`
420
+ - "custom message bubble" → `templates` prop on
421
+ `CometChatMessageList` (NOT a custom bubble component)
422
+ - "hide / disable a sub-feature" → `disable*` boolean props
423
+ - "click handler" → `onItemClick`, `onMessageClick`,
424
+ `onSearchBarClicked`, `onBack`
425
+ - "custom subtitle / status / timestamp" → `subtitleView`,
426
+ `statusView`, `timestampView`
427
+ Process before any code change:
428
+ 1. Read the files in `.cometchat/state.json` `files_owned` and
429
+ grep for the `<CometChat[A-Z]` JSX components actually in use:
430
+ ```bash
431
+ grep -hoE '<CometChat[A-Z][a-zA-Z]*' \
432
+ $(jq -r '.files_owned[]' .cometchat/state.json 2>/dev/null) \
433
+ 2>/dev/null | sort -u
434
+ ```
435
+ 2. Query the docs MCP for `"<ComponentName> props"` for each one.
436
+ 3. If a prop matches the user's intent, **add the prop and stop**.
437
+ No new components, no custom CSS, no new files.
438
+ 4. Only if no prop matches, route to the `cometchat-customization`
439
+ skill for the full four-tier discovery.
440
+ - **Dashboard-toggle:** prefer the CLI — it flips the toggle via the
441
+ same API the dashboard UI uses, so the user doesn't leave the
442
+ terminal:
443
+ ```bash
444
+ npx @cometchat/skills-cli features enable <id> --json
445
+ # to turn it off:
446
+ npx @cometchat/skills-cli features disable <id> --json
447
+ ```
448
+ The CLI reads the app id from `.cometchat/config.json` and the
449
+ bearer token from the OS keychain (requires a prior
450
+ `cometchat auth login`). Response shape:
451
+ - `"status": "enabled"` / `"disabled"` → done. Tell the user to
452
+ hard-refresh (Cmd+Shift+R) the browser tab running their dev
453
+ server.
454
+ - `"status": "no-op"` → already in the desired state.
455
+ - `"status": "not-logged-in"` → run `cometchat auth login` first.
456
+ - `"status": "no-app"` → run `/cometchat` or
457
+ `cometchat provision setup` first so `.cometchat/config.json`
458
+ has the app id.
459
+ - `"status": "error"` → surface `next_steps` verbatim. Includes
460
+ the dashboard URL as a manual fallback.
461
+
462
+ **Only fall back to the dashboard walkthrough** (app.cometchat.com
463
+ → Chat & Messaging → Features → flip Status toggle) if the CLI
464
+ returns `error` or isn't available. Run
465
+ `cometchat features info <id>` for per-feature configuration
466
+ details (Giphy API keys, translation languages, etc.) beyond the
467
+ basic toggle.
468
+
469
+ **Note:** if the feature has `auto_wired_in_uikit: false` in the
470
+ catalog (most non-default extensions), the toggle alone isn't
471
+ enough — you also need to register the extension via
472
+ `UIKitSettingsBuilder.setExtensions([...])` before `init`. The
473
+ CLI's success output flags this; query the docs MCP for the exact
474
+ builder syntax.
475
+ - **Package-install (calls):** run `npm install @cometchat/calls-sdk-javascript`
476
+ directly. The user opted in, that IS consent.
477
+ - **Component-swap:** run `npx @cometchat/skills-cli apply-feature <id>`.
478
+ The CLI handles the swap deterministically. Do NOT hand-edit.
479
+
480
+ ### Step 5 — Verify
481
+
482
+ ```bash
483
+ npx @cometchat/skills-cli verify --json
484
+ ```
485
+
486
+ Surface any failed checks verbatim. If anything looks off after enabling
487
+ a feature (drift, unexpected build error, env warning), run
488
+ `cometchat doctor` for combined drift + env + AST diagnostics with
489
+ per-issue fix instructions, or route to the `cometchat-troubleshooting`
490
+ skill for deeper triage.
491
+
492
+ ## Hard rules
493
+
494
+ - Never modify a project without an existing CometChat integration.
495
+ - Always query the docs MCP for SDK reference (do not invent function names).
496
+ - For component-swap features, always use `cometchat apply-feature <id>` —
497
+ the CLI is the source of truth, never hand-edit.
498
+ - For package-install features (calls), the user opting in IS consent —
499
+ run `npm install <package>` directly.
500
+ - For dashboard-toggle features, walk the user through the dashboard
501
+ activation steps from `cometchat features info <id>` — the dashboard
502
+ flip is something only the human can do.
503
+ - For dashboard-toggle features, always give the canonical path:
504
+ **app.cometchat.com → select app → Chat & Messaging → Features →
505
+ toggle ON.** Query the docs MCP for per-feature config details
506
+ (e.g. Giphy API key, Translation language settings).
507
+ - Always use `npx @cometchat/skills-cli`.
508
+
509
+ ## Sources
510
+
511
+ - [Core features](https://www.cometchat.com/docs/ui-kit/react/core-features)
512
+ - [Extensions](https://www.cometchat.com/docs/ui-kit/react/extensions)
513
+ - [AI features](https://www.cometchat.com/docs/ui-kit/react/ai-features)
514
+ - [Call features](https://www.cometchat.com/docs/ui-kit/react/call-features)