@cometchat/skills 4.2.1 → 4.4.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.
Files changed (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -12
  3. package/bin/install.js +59 -4
  4. package/package.json +14 -1
  5. package/skills/cometchat/SKILL.md +460 -77
  6. package/skills/cometchat/references/asking-questions.md +48 -0
  7. package/skills/cometchat-a11y/SKILL.md +3 -2
  8. package/skills/cometchat-android-v5/SKILL.md +2 -1
  9. package/skills/cometchat-android-v5-calls/SKILL.md +36 -22
  10. package/skills/cometchat-android-v5-calls/references/README.md +1 -1
  11. package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +7 -5
  12. package/skills/cometchat-android-v5-calls/references/audio-controls.md +4 -4
  13. package/skills/cometchat-android-v5-calls/references/call-layouts.md +33 -25
  14. package/skills/cometchat-android-v5-calls/references/call-session.md +2 -2
  15. package/skills/cometchat-android-v5-calls/references/custom-ui.md +5 -5
  16. package/skills/cometchat-android-v5-calls/references/event-listeners.md +2 -2
  17. package/skills/cometchat-android-v5-calls/references/idle-timeout.md +20 -14
  18. package/skills/cometchat-android-v5-calls/references/in-call-chat.md +1 -1
  19. package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +43 -27
  20. package/skills/cometchat-android-v5-calls/references/participant-management.md +3 -3
  21. package/skills/cometchat-android-v5-calls/references/raise-hand.md +25 -19
  22. package/skills/cometchat-android-v5-calls/references/recording.md +2 -2
  23. package/skills/cometchat-android-v5-calls/references/ringing-integration.md +1 -1
  24. package/skills/cometchat-android-v5-calls/references/screen-sharing.md +5 -9
  25. package/skills/cometchat-android-v5-calls/references/session-settings.md +3 -3
  26. package/skills/cometchat-android-v5-calls/references/setup.md +1 -1
  27. package/skills/cometchat-android-v5-calls/references/share-invite.md +9 -4
  28. package/skills/cometchat-android-v5-calls/references/video-controls.md +4 -4
  29. package/skills/cometchat-android-v5-calls/references/voip-calling.md +2 -2
  30. package/skills/cometchat-android-v5-components/SKILL.md +4 -3
  31. package/skills/cometchat-android-v5-core/SKILL.md +20 -2
  32. package/skills/cometchat-android-v5-customization/SKILL.md +171 -7
  33. package/skills/cometchat-android-v5-extensions/SKILL.md +7 -4
  34. package/skills/cometchat-android-v5-features/SKILL.md +5 -4
  35. package/skills/cometchat-android-v5-placement/SKILL.md +2 -1
  36. package/skills/cometchat-android-v5-production/SKILL.md +2 -1
  37. package/skills/cometchat-android-v5-push/SKILL.md +2 -3
  38. package/skills/cometchat-android-v5-testing/SKILL.md +2 -1
  39. package/skills/cometchat-android-v5-theming/SKILL.md +2 -1
  40. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +3 -2
  41. package/skills/cometchat-android-v6/SKILL.md +2 -1
  42. package/skills/cometchat-android-v6-builder-settings/SKILL.md +11 -7
  43. package/skills/cometchat-android-v6-calls/SKILL.md +79 -18
  44. package/skills/cometchat-android-v6-calls/references/advanced-features.md +87 -0
  45. package/skills/cometchat-android-v6-calls/references/call-layouts.md +24 -15
  46. package/skills/cometchat-android-v6-calls/references/call-session.md +2 -2
  47. package/skills/cometchat-android-v6-calls/references/device-management.md +17 -16
  48. package/skills/cometchat-android-v6-calls/references/idle-timeout.md +7 -4
  49. package/skills/cometchat-android-v6-calls/references/in-call-chat.md +13 -8
  50. package/skills/cometchat-android-v6-calls/references/raise-hand.md +6 -4
  51. package/skills/cometchat-android-v6-compose-components/SKILL.md +52 -29
  52. package/skills/cometchat-android-v6-compose-customization/SKILL.md +156 -1
  53. package/skills/cometchat-android-v6-compose-placement/SKILL.md +129 -40
  54. package/skills/cometchat-android-v6-compose-theming/SKILL.md +27 -1
  55. package/skills/cometchat-android-v6-core/SKILL.md +389 -9
  56. package/skills/cometchat-android-v6-events/SKILL.md +4 -1
  57. package/skills/cometchat-android-v6-extensions/SKILL.md +2 -1
  58. package/skills/cometchat-android-v6-features/SKILL.md +26 -2
  59. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +31 -1
  60. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +172 -1
  61. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +20 -5
  62. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +36 -5
  63. package/skills/cometchat-android-v6-migration/SKILL.md +44 -42
  64. package/skills/cometchat-android-v6-production/SKILL.md +6 -3
  65. package/skills/cometchat-android-v6-push/SKILL.md +43 -2
  66. package/skills/cometchat-android-v6-testing/SKILL.md +11 -8
  67. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +26 -5
  68. package/skills/cometchat-angular-calls/SKILL.md +256 -389
  69. package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +3 -2
  70. package/skills/cometchat-angular-calls/references/call-layouts.md +29 -12
  71. package/skills/cometchat-angular-calls/references/call-session.md +2 -2
  72. package/skills/cometchat-angular-calls/references/custom-ui.md +18 -10
  73. package/skills/cometchat-angular-calls/references/device-management.md +53 -34
  74. package/skills/cometchat-angular-calls/references/group-calls.md +45 -24
  75. package/skills/cometchat-angular-calls/references/idle-timeout.md +31 -15
  76. package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +7 -6
  77. package/skills/cometchat-angular-calls/references/raise-hand.md +9 -4
  78. package/skills/cometchat-angular-calls/references/recording-screen-share.md +32 -39
  79. package/skills/cometchat-angular-calls/references/ringing-integration.md +3 -1
  80. package/skills/cometchat-angular-calls/references/share-invite.md +11 -5
  81. package/skills/cometchat-angular-calls/references/virtual-background.md +29 -0
  82. package/skills/cometchat-angular-components/SKILL.md +149 -620
  83. package/skills/cometchat-angular-core/SKILL.md +235 -293
  84. package/skills/cometchat-angular-customization/SKILL.md +415 -223
  85. package/skills/cometchat-angular-features/SKILL.md +216 -334
  86. package/skills/cometchat-angular-patterns/SKILL.md +168 -359
  87. package/skills/cometchat-angular-placement/SKILL.md +189 -560
  88. package/skills/cometchat-angular-production/SKILL.md +241 -92
  89. package/skills/cometchat-angular-push/SKILL.md +280 -294
  90. package/skills/cometchat-angular-testing/SKILL.md +430 -158
  91. package/skills/cometchat-angular-theming/SKILL.md +190 -265
  92. package/skills/cometchat-angular-troubleshooting/SKILL.md +192 -157
  93. package/skills/cometchat-astro-patterns/SKILL.md +22 -1
  94. package/skills/cometchat-calls/SKILL.md +25 -19
  95. package/skills/cometchat-calls/references/use-case-broadcast.md +15 -10
  96. package/skills/cometchat-calls/references/use-case-marketplace.md +2 -3
  97. package/skills/cometchat-calls/references/use-case-support.md +3 -4
  98. package/skills/cometchat-calls/references/use-case-team.md +23 -12
  99. package/skills/cometchat-calls/references/use-case-telehealth.md +3 -4
  100. package/skills/cometchat-components/SKILL.md +163 -25
  101. package/skills/cometchat-core/SKILL.md +412 -13
  102. package/skills/cometchat-customization/SKILL.md +50 -25
  103. package/skills/cometchat-features/SKILL.md +313 -34
  104. package/skills/cometchat-flutter-v5/SKILL.md +10 -4
  105. package/skills/cometchat-flutter-v5-calls/SKILL.md +188 -158
  106. package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +48 -24
  107. package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +20 -15
  108. package/skills/cometchat-flutter-v5-calls/references/call-session.md +100 -145
  109. package/skills/cometchat-flutter-v5-calls/references/device-management.md +12 -8
  110. package/skills/cometchat-flutter-v5-calls/references/group-calls.md +30 -36
  111. package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +15 -13
  112. package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +12 -9
  113. package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +115 -65
  114. package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +41 -30
  115. package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +17 -14
  116. package/skills/cometchat-flutter-v5-calls/references/share-invite.md +8 -2
  117. package/skills/cometchat-flutter-v5-conversations/SKILL.md +2 -1
  118. package/skills/cometchat-flutter-v5-core/SKILL.md +20 -2
  119. package/skills/cometchat-flutter-v5-customization/SKILL.md +136 -5
  120. package/skills/cometchat-flutter-v5-events/SKILL.md +2 -1
  121. package/skills/cometchat-flutter-v5-messages/SKILL.md +2 -1
  122. package/skills/cometchat-flutter-v5-production/SKILL.md +15 -6
  123. package/skills/cometchat-flutter-v5-push/SKILL.md +2 -1
  124. package/skills/cometchat-flutter-v5-testing/SKILL.md +17 -6
  125. package/skills/cometchat-flutter-v5-theming/SKILL.md +2 -1
  126. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +7 -6
  127. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +3 -2
  128. package/skills/cometchat-flutter-v6/SKILL.md +17 -16
  129. package/skills/cometchat-flutter-v6-calls/SKILL.md +78 -63
  130. package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +8 -6
  131. package/skills/cometchat-flutter-v6-calls/references/advanced-features.md +89 -0
  132. package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +15 -12
  133. package/skills/cometchat-flutter-v6-calls/references/call-session.md +2 -2
  134. package/skills/cometchat-flutter-v6-calls/references/device-management.md +9 -3
  135. package/skills/cometchat-flutter-v6-calls/references/group-calls.md +10 -10
  136. package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +15 -7
  137. package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +6 -3
  138. package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +23 -16
  139. package/skills/cometchat-flutter-v6-components/SKILL.md +32 -11
  140. package/skills/cometchat-flutter-v6-conversations/SKILL.md +39 -11
  141. package/skills/cometchat-flutter-v6-core/SKILL.md +348 -10
  142. package/skills/cometchat-flutter-v6-customization/SKILL.md +97 -25
  143. package/skills/cometchat-flutter-v6-events/SKILL.md +3 -2
  144. package/skills/cometchat-flutter-v6-features/SKILL.md +15 -6
  145. package/skills/cometchat-flutter-v6-messages/SKILL.md +111 -60
  146. package/skills/cometchat-flutter-v6-migration/SKILL.md +18 -25
  147. package/skills/cometchat-flutter-v6-placement/SKILL.md +79 -50
  148. package/skills/cometchat-flutter-v6-production/SKILL.md +13 -12
  149. package/skills/cometchat-flutter-v6-push/SKILL.md +43 -21
  150. package/skills/cometchat-flutter-v6-testing/SKILL.md +6 -6
  151. package/skills/cometchat-flutter-v6-theming/SKILL.md +38 -5
  152. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +182 -17
  153. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +12 -4
  154. package/skills/cometchat-i18n/SKILL.md +139 -78
  155. package/skills/cometchat-ios/SKILL.md +4 -2
  156. package/skills/cometchat-ios-calls/SKILL.md +225 -95
  157. package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +11 -9
  158. package/skills/cometchat-ios-calls/references/audio-modes-and-controls.md +45 -0
  159. package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +6 -7
  160. package/skills/cometchat-ios-calls/references/call-layouts.md +31 -91
  161. package/skills/cometchat-ios-calls/references/call-session.md +51 -54
  162. package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +33 -29
  163. package/skills/cometchat-ios-calls/references/custom-ui.md +38 -38
  164. package/skills/cometchat-ios-calls/references/group-calls.md +33 -70
  165. package/skills/cometchat-ios-calls/references/idle-timeout.md +24 -25
  166. package/skills/cometchat-ios-calls/references/in-call-chat.md +19 -23
  167. package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +128 -70
  168. package/skills/cometchat-ios-calls/references/picture-in-picture.md +20 -20
  169. package/skills/cometchat-ios-calls/references/raise-hand.md +14 -227
  170. package/skills/cometchat-ios-calls/references/recording-screen-share.md +35 -122
  171. package/skills/cometchat-ios-calls/references/ringing-integration.md +17 -16
  172. package/skills/cometchat-ios-calls/references/share-invite.md +8 -12
  173. package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +4 -4
  174. package/skills/cometchat-ios-components/SKILL.md +200 -12
  175. package/skills/cometchat-ios-core/SKILL.md +281 -11
  176. package/skills/cometchat-ios-customization/SKILL.md +276 -110
  177. package/skills/cometchat-ios-features/SKILL.md +64 -36
  178. package/skills/cometchat-ios-placement/SKILL.md +15 -12
  179. package/skills/cometchat-ios-production/SKILL.md +12 -4
  180. package/skills/cometchat-ios-push/SKILL.md +53 -19
  181. package/skills/cometchat-ios-testing/SKILL.md +14 -9
  182. package/skills/cometchat-ios-theming/SKILL.md +39 -3
  183. package/skills/cometchat-ios-troubleshooting/SKILL.md +41 -21
  184. package/skills/cometchat-native-bare-patterns/SKILL.md +56 -18
  185. package/skills/cometchat-native-calls/SKILL.md +89 -19
  186. package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +2 -2
  187. package/skills/cometchat-native-calls/references/call-layouts.md +15 -14
  188. package/skills/cometchat-native-calls/references/call-session.md +2 -2
  189. package/skills/cometchat-native-calls/references/custom-ui.md +12 -8
  190. package/skills/cometchat-native-calls/references/device-management.md +53 -30
  191. package/skills/cometchat-native-calls/references/group-calls.md +35 -30
  192. package/skills/cometchat-native-calls/references/idle-timeout.md +6 -6
  193. package/skills/cometchat-native-calls/references/in-call-chat.md +10 -8
  194. package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +2 -2
  195. package/skills/cometchat-native-calls/references/raise-hand.md +15 -13
  196. package/skills/cometchat-native-calls/references/recording-screen-share.md +49 -170
  197. package/skills/cometchat-native-calls/references/share-invite.md +7 -5
  198. package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +4 -2
  199. package/skills/cometchat-native-components/SKILL.md +91 -57
  200. package/skills/cometchat-native-core/SKILL.md +281 -9
  201. package/skills/cometchat-native-customization/SKILL.md +150 -28
  202. package/skills/cometchat-native-expo-patterns/SKILL.md +77 -27
  203. package/skills/cometchat-native-features/SKILL.md +79 -49
  204. package/skills/cometchat-native-placement/SKILL.md +19 -10
  205. package/skills/cometchat-native-production/SKILL.md +9 -3
  206. package/skills/cometchat-native-push/SKILL.md +2 -1
  207. package/skills/cometchat-native-testing/SKILL.md +1 -2
  208. package/skills/cometchat-native-theming/SKILL.md +54 -29
  209. package/skills/cometchat-native-troubleshooting/SKILL.md +71 -3
  210. package/skills/cometchat-nextjs-patterns/SKILL.md +48 -6
  211. package/skills/cometchat-placement/SKILL.md +42 -3
  212. package/skills/cometchat-production/SKILL.md +12 -5
  213. package/skills/cometchat-react-calls/SKILL.md +220 -10
  214. package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +4 -3
  215. package/skills/cometchat-react-calls/references/call-layouts.md +5 -6
  216. package/skills/cometchat-react-calls/references/call-session.md +1 -1
  217. package/skills/cometchat-react-calls/references/custom-ui.md +61 -15
  218. package/skills/cometchat-react-calls/references/device-management.md +55 -51
  219. package/skills/cometchat-react-calls/references/group-calls.md +18 -23
  220. package/skills/cometchat-react-calls/references/idle-timeout.md +25 -12
  221. package/skills/cometchat-react-calls/references/in-call-chat.md +7 -7
  222. package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +9 -11
  223. package/skills/cometchat-react-calls/references/raise-hand.md +14 -14
  224. package/skills/cometchat-react-calls/references/recording-screen-share.md +39 -38
  225. package/skills/cometchat-react-calls/references/ringing-integration.md +2 -2
  226. package/skills/cometchat-react-calls/references/share-invite.md +4 -5
  227. package/skills/cometchat-react-calls/references/testing-calls-on-web.md +20 -2
  228. package/skills/cometchat-react-calls/references/virtual-background.md +32 -0
  229. package/skills/cometchat-react-patterns/SKILL.md +57 -4
  230. package/skills/cometchat-react-push/SKILL.md +258 -72
  231. package/skills/cometchat-react-router-patterns/SKILL.md +43 -4
  232. package/skills/cometchat-react-testing/SKILL.md +14 -5
  233. package/skills/cometchat-theming/SKILL.md +181 -18
  234. package/skills/cometchat-troubleshooting/SKILL.md +40 -20
@@ -3,26 +3,125 @@ name: cometchat-core
3
3
  description: "Shared rules for CometChat React UI Kit v6. Always loaded alongside framework + placement skills. Read this first."
4
4
  license: "MIT"
5
5
  compatibility: "Node.js >=18; React >=18; @cometchat/chat-uikit-react ^6; @cometchat/chat-sdk-javascript ^4"
6
- allowed-tools: "shell, file-read, file-search, file-list"
7
6
  metadata:
8
7
  author: "CometChat"
9
8
  version: "3.0.0"
10
9
  tags: "chat cometchat react core rules initialization patterns"
11
10
  ---
12
11
 
12
+ > **Ground truth:** the installed `@cometchat/chat-uikit-react@^6` + `@cometchat/chat-sdk-javascript@^4` package types (`node_modules/@cometchat/chat-uikit-react`) + `docs/ui-kit/react`. **Official docs:** https://www.cometchat.com/docs/ui-kit/react/overview · **Docs MCP:** `claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp` (or fetch the URL directly on agents without MCP). Verify any non-obvious symbol against the installed package types before relying on it.
13
+
13
14
  ## Purpose
14
15
 
15
16
  This is the foundational skill for every CometChat React UI Kit v6 integration. It teaches Claude HOW CometChat works -- initialization, login, CSS, environment variables, SSR safety, and the provider pattern -- so Claude can write project-appropriate code instead of relying on templates.
16
17
 
17
18
  **Read this skill first, before any framework or placement skill.**
18
19
 
20
+ ## When to use
21
+
22
+ - Any React-family integration: Vite + React, Next.js (App or Pages Router), React Router v6/v7, Astro with React islands.
23
+ - BEFORE loading any framework-specific patterns skill (`cometchat-react-patterns`, `cometchat-nextjs-patterns`, etc.) — those layer on top of this.
24
+ - When the user is asking about CometChat init, login, env vars, CSS, provider pattern, SSR safety, or production auth.
25
+
26
+ ## When NOT to use
27
+
28
+ - **React Native** (Expo or bare) — load `cometchat-native-core` instead. The wrappers, env-var prefixes, and lifecycle are different.
29
+ - **Angular** — load `cometchat-angular-core`. Uses `APP_INITIALIZER` + `CUSTOM_ELEMENTS_SCHEMA` + `environment.ts`, not React's provider chain.
30
+ - **Native Android (V5 or V6)** — load `cometchat-android-v5-core` or `cometchat-android-v6-core`. Kotlin init, `local.properties` credentials.
31
+ - **Native iOS (V5)** — load `cometchat-ios-core`. Swift init, CocoaPods/SPM.
32
+ - **Flutter (V5 or V6)** — load `cometchat-flutter-v5-core` or `cometchat-flutter-v6-core`. Dart init via `pubspec.yaml`.
33
+ - **Backend-only token-mint server work** — load `cometchat-production` for the REST-API token recipes; this skill is client-side.
34
+
35
+ ## Common Rationalizations — and why they're wrong
36
+
37
+ A two-column anti-skip defense. Every excuse below has been used by agents (or could plausibly be) to skip rules in this skill. The rebuttal cites the validated incident.
38
+
39
+ | Excuse the agent might invent | Reality |
40
+ |---|---|
41
+ | "StrictMode double-invocation is a dev-only quirk, so I can skip the in-flight login promise pattern (§2)" | The same race fires anywhere a parent component re-mounts (React Router v6 nested routes, Suspense boundary retries, error-boundary resets). Skipping yields the canonical `"Please wait until the previous login request ends"` error on production refreshes too. |
42
+ | "This is a quick prototype, I'll hardcode `cometchat-uid-1` instead of asking the user" | Two testers shipped apps where the default UID was a Bot in their dashboard (ENG-35717). Auth-key login refuses bot users by design; the error `Auth token creation not allowed for this bot <uid>` is opaque. **Always ask via the dispatcher's Step 3d.1 prompt.** |
43
+ | "I'll use `setError(String(e))` for now and pretty-print later" | `String(e)` on a CometChatException renders `[object Object]` — testers wasted 10-minute debugging sessions on this (ENG-35719). Always emit the §6 `formatCometChatError` helper from `cometchat/errors.ts`. "Later" never comes. |
44
+ | "The env file looks right, I don't need to run `config show --json`" | Two testers shipped code with empty `VITE_COMETCHAT_APP_ID` because the dispatcher moved on without confirming (ENG-35718). The pre-flight is 1 second; the cost of skipping is a customer-facing init failure. |
45
+ | "I know React, I can skip reading the framework-specific patterns skill" | The framework patterns carry version-pinned traps that aren't in training data: the Next.js 15+ rule `dynamic(ssr:false)` must live in a Client Component (verified by runtime smoke 2026-06-02), the Vite Visual Builder `tsconfig` patches (resolveJsonModule, jsx: react-jsx, verbatimModuleSyntax: false), the React Router v7 `appDirectory` constraint. Skipping = customer-visible build failure. |
46
+ | "I'll add the telemetry hook later; the basic provider works without it" | The telemetry prop is opt-in by design (no-op if not passed) — but the four lifecycle events (init_started / init_finished / login_started / login_finished + their _failed variants) are how customers wire analytics into onboarding funnels without monkey-patching. Skipping ENG-35715 wiring means the customer has to refactor their provider post-launch. |
47
+
48
+ ## Red flags — signs you're misapplying this skill
49
+
50
+ - The agent emitted `setError(String(e))` anywhere in code — should be `setError(formatCometChatError(e))` per §6 (ENG-35719).
51
+ - The agent's plan (Step 3f) doesn't include `cometchat/errors.ts` as a created file.
52
+ - The agent emitted bare `CometChatUIKit.login(uid)` without the in-flight-promise guard (`ensureLoggedIn`) — guaranteed StrictMode race in dev.
53
+ - A `<style>` or CSS rule targets internal class names like `.cometchat-conversation-list-item` (anti-pattern §8.3) instead of the `--cometchat-*` CSS variables.
54
+ - The agent picked `cometchat-uid-1` without asking the user (ENG-35717 — the bot-flag failure mode).
55
+ - The agent's env file uses the wrong framework prefix (e.g., `VITE_*` in a Next.js project, or `EXPO_PUBLIC_*` in a Vite project).
56
+ - The provider doesn't gate `{children}` on `isReady` — chat components mount before init completes and throw `CometChat is not initialized` errors.
57
+
58
+ ## Verification — before declaring this skill applied
59
+
60
+ Run through this checklist before saying "done" for any task that touched cometchat-core territory:
61
+
62
+ - [ ] `grep -nE "setError\(String\(" src/` returns ZERO matches (ENG-35719 — must use `formatCometChatError`).
63
+ - [ ] `src/cometchat/errors.ts` exists and exports `formatCometChatError` + `logCometChatError`.
64
+ - [ ] The provider has an `ensureLoggedIn`-style in-flight guard (no bare `CometChatUIKit.login` calls).
65
+ - [ ] `tsc --noEmit` passes against the project's existing `tsconfig`.
66
+ - [ ] Env vars use the **detected framework's prefix** (`VITE_*` / `NEXT_PUBLIC_*` / `PUBLIC_*` / `EXPO_PUBLIC_*`), and `.env` (or `.env.local` for Next.js) is in `.gitignore`.
67
+ - [ ] CSS imports happen once at the entry / root (per framework section in §3).
68
+ - [ ] If the user is on Next.js: the page that owns CometChat components has `"use client"` (App Router) or is dynamic-imported with `ssr: false` (App Router only inside another Client Component, per the Next.js 15+ rule verified 2026-06-02).
69
+ - [ ] The user confirmed the dev-mode UID via the dispatcher's Step 3d.1 prompt — NOT silently picked.
70
+
19
71
  ---
20
72
 
21
73
  ## 1. Initialization
22
74
 
23
75
  CometChat must be initialized exactly once before any UI component renders. Initialization is asynchronous and must complete fully before mounting any `CometChat*` component.
24
76
 
25
- ### The UIKitSettingsBuilder
77
+ ### File-based init with `cometchat-settings.json` (recommended)
78
+
79
+ > **Version requirement (ENG-35866 — Skills Telemetry).** `CometChatUIKit.initFromSettings(settings)` reads a `cometchat-settings.json` object and lets the SDK self-report `integrationSource = "ai-agent"` to `/user_sessions`. It ships GA in **`@cometchat/chat-uikit-react >= 6.5.2`** + **`@cometchat/chat-sdk-javascript >= 4.1.11`** (npm `latest`). On an older UI Kit the method does not exist — use the **`UIKitSettingsBuilder` fallback** below.
80
+
81
+ **Step 1 — create `cometchat-settings.json` at the project root.** Fill `appId` / `region` / `credentials.authKey` from the CLI `provision setup` output; leave everything else at the defaults below. This is the single source of credentials — no second copy to keep in sync.
82
+
83
+ ```json
84
+ {
85
+ "appId": "APP_ID_HERE",
86
+ "region": "us",
87
+ "credentials": {
88
+ "authKey": "AUTH_KEY_HERE"
89
+ },
90
+ "chatSDK": {
91
+ "presenceSubscription": {
92
+ "type": "ALL_USERS",
93
+ "roles": []
94
+ },
95
+ "autoEstablishSocketConnection": true,
96
+ "adminHost": null,
97
+ "clientHost": null
98
+ },
99
+ "callsSDK": {
100
+ "host": null,
101
+ "adminHost": null,
102
+ "clientHost": null,
103
+ "callsHost": null
104
+ },
105
+ "uiKit": {
106
+ "subscribePresenceForAllUsers": true
107
+ }
108
+ }
109
+ ```
110
+
111
+ **Step 2 — init by importing the JSON as a build-time module.** Vite, CRA, Next.js, and Astro all have `resolveJsonModule` on by default, so the import is type-safe with no extra config:
112
+
113
+ ```typescript
114
+ // initFromSettings ships GA in @cometchat/chat-uikit-react >= 6.5.2 (ENG-35866)
115
+ import { CometChatUIKit } from "@cometchat/chat-uikit-react";
116
+ import cometchatSettings from "./cometchat-settings.json"; // adjust path to the file's location
117
+
118
+ await CometChatUIKit.initFromSettings(cometchatSettings);
119
+ ```
120
+
121
+ - **Do NOT gitignore `cometchat-settings.json`.** The dev-mode `authKey` it holds is no more exposed than a `VITE_COMETCHAT_AUTH_KEY=…` env value (both ship in the built bundle); production integrations migrate to server-minted auth tokens regardless.
122
+ - The same module-flag / `useEffect` / entry-point placement rules in the rest of this section apply unchanged — just swap `CometChatUIKit.init(settings)` for `CometChatUIKit.initFromSettings(cometchatSettings)`.
123
+
124
+ ### The UIKitSettingsBuilder (fallback — UI Kit before file-based init)
26
125
 
27
126
  ```typescript
28
127
  import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react";
@@ -46,6 +145,16 @@ async function initCometChat(): Promise<void> {
46
145
  if (initialized) return;
47
146
  initialized = true;
48
147
 
148
+ // Fail loud if env vars didn't load. Empty credentials otherwise surface
149
+ // much later as a cryptic `ERROR_API_KEY_NOT_FOUND` / failed init that's hard
150
+ // to trace back to a missing/mis-prefixed .env. (audit P0-5)
151
+ if (!APP_ID || !REGION || !AUTH_KEY) {
152
+ throw new Error(
153
+ "CometChat credentials are empty — check .env and the framework's env prefix " +
154
+ "(VITE_ / NEXT_PUBLIC_ / PUBLIC_), and restart the dev server after editing .env.",
155
+ );
156
+ }
157
+
49
158
  const settings = new UIKitSettingsBuilder()
50
159
  .setAppId(APP_ID)
51
160
  .setRegion(REGION)
@@ -116,7 +225,13 @@ async function ensureLoggedIn(
116
225
  authToken?: string,
117
226
  ): Promise<void> {
118
227
  const existing = await CometChatUIKit.getLoggedinUser();
119
- if (existing) return; // sequential case already logged in
228
+ // Same user already logged in → nothing to do (sequential case).
229
+ if (existing && existing.getUid?.() === uid) return;
230
+ // A DIFFERENT user is logged in (account switch, or logout → login-as-other).
231
+ // Log out first: otherwise the SDK keeps the old session and login() silently
232
+ // no-ops, so the app shows the previous account. (Switching accounts requires
233
+ // an explicit logout — login() is a no-op against an existing session.)
234
+ if (existing) await CometChatUIKit.logout();
120
235
  if (loginInFlight) { // concurrent case — reuse pending promise
121
236
  await loginInFlight;
122
237
  return;
@@ -386,12 +501,23 @@ async function ensureLoggedIn(
386
501
  }
387
502
  }
388
503
 
504
+ // ENG-35715 telemetry hook — opt-in callback for init/login lifecycle.
505
+ // Fires at six phases. If `telemetry` prop is not passed, all calls are no-ops.
506
+ export type CometChatTelemetryEvent =
507
+ | { phase: "init_started"; appId: string; region: string }
508
+ | { phase: "init_finished"; durationMs: number }
509
+ | { phase: "init_failed"; error: unknown }
510
+ | { phase: "login_started"; uid: string; mode: "authKey" | "authToken" }
511
+ | { phase: "login_finished"; durationMs: number }
512
+ | { phase: "login_failed"; error: unknown };
513
+
389
514
  interface CometChatProviderProps {
390
515
  appId: string;
391
516
  region: string;
392
517
  authKey?: string;
393
518
  authToken?: string;
394
519
  uid?: string;
520
+ telemetry?: (event: CometChatTelemetryEvent) => void; // ← opt-in lifecycle hook
395
521
  children: React.ReactNode;
396
522
  }
397
523
 
@@ -401,6 +527,7 @@ export function CometChatProvider({
401
527
  authKey,
402
528
  authToken,
403
529
  uid = "cometchat-uid-1",
530
+ telemetry,
404
531
  children,
405
532
  }: CometChatProviderProps) {
406
533
  const [isReady, setIsReady] = useState(false);
@@ -408,9 +535,11 @@ export function CometChatProvider({
408
535
 
409
536
  useEffect(() => {
410
537
  async function setup() {
538
+ const initStart = performance.now();
411
539
  try {
412
540
  if (!initialized) {
413
541
  initialized = true;
542
+ telemetry?.({ phase: "init_started", appId, region });
414
543
  const builder = new UIKitSettingsBuilder()
415
544
  .setAppId(appId)
416
545
  .setRegion(region)
@@ -422,18 +551,25 @@ export function CometChatProvider({
422
551
 
423
552
  const settings = builder.build();
424
553
  await CometChatUIKit.init(settings);
554
+ telemetry?.({ phase: "init_finished", durationMs: performance.now() - initStart });
425
555
  }
426
556
 
557
+ const loginStart = performance.now();
558
+ telemetry?.({ phase: "login_started", uid, mode: authToken ? "authToken" : "authKey" });
427
559
  await ensureLoggedIn(uid, authToken);
560
+ telemetry?.({ phase: "login_finished", durationMs: performance.now() - loginStart });
428
561
 
429
562
  setIsReady(true);
430
563
  } catch (e) {
431
- setError(String(e));
564
+ // If init never completed, this is an init_failed; otherwise login_failed.
565
+ const phase = isReady ? "login_failed" : "init_failed";
566
+ telemetry?.({ phase, error: e } as CometChatTelemetryEvent);
567
+ setError(formatCometChatError(e));
432
568
  }
433
569
  }
434
570
 
435
571
  setup();
436
- }, [appId, region, authKey, authToken, uid]);
572
+ }, [appId, region, authKey, authToken, uid, telemetry]);
437
573
 
438
574
  if (error) {
439
575
  return (
@@ -463,6 +599,16 @@ export function CometChatProvider({
463
599
  appId={import.meta.env.VITE_COMETCHAT_APP_ID}
464
600
  region={import.meta.env.VITE_COMETCHAT_REGION}
465
601
  authKey={import.meta.env.VITE_COMETCHAT_AUTH_KEY}
602
+ // Optional — wire your analytics on each lifecycle event (ENG-35715):
603
+ telemetry={(event) => {
604
+ if (event.phase === "init_finished" || event.phase === "login_finished") {
605
+ analytics.track(`cometchat.${event.phase}`, { ms: event.durationMs });
606
+ } else if (event.phase === "init_failed" || event.phase === "login_failed") {
607
+ analytics.trackError(`cometchat.${event.phase}`, { error: String(event.error) });
608
+ } else {
609
+ analytics.track(`cometchat.${event.phase}`, event);
610
+ }
611
+ }}
466
612
  >
467
613
  <ChatPage />
468
614
  </CometChatProvider>
@@ -470,6 +616,83 @@ export function CometChatProvider({
470
616
 
471
617
  The provider pattern keeps init/login logic in one place. Chat components inside `<CometChatProvider>` are guaranteed to render only after init and login succeed.
472
618
 
619
+ ### Pretty-print errors — DO NOT `String(error)` (ENG-35719)
620
+
621
+ `CometChat.CometChatException` objects look like `{ code: "ERROR_API_KEY_NOT_FOUND", message: "Auth Key cannot be empty", details: ..., source: ... }` (in some kit versions the fields are `errorCode` / `errorDescription`). Calling `String(e)` on them yields `"[object Object]"` — the integrator then has to open devtools, copy the error to the console, and `JSON.stringify` it by hand just to read the message. Testers consistently flag this as the most frustrating moment of the first-run integration.
622
+
623
+ **Emit this helper in `cometchat/errors.ts` and reuse it from the provider, login screen, and any feature module that catches a kit error:**
624
+
625
+ ```typescript
626
+ // cometchat/errors.ts
627
+ export function formatCometChatError(e: unknown): string {
628
+ if (e == null) return "Unknown CometChat error.";
629
+ const err = e as Record<string, unknown>;
630
+ const code =
631
+ (err.code as string | undefined) ??
632
+ (err.errorCode as string | undefined);
633
+ const message =
634
+ (err.message as string | undefined) ??
635
+ (err.errorDescription as string | undefined);
636
+ if (code && message) return `[CometChat ${code}] ${message}`;
637
+ if (message) return `[CometChat] ${message}`;
638
+ try {
639
+ return `[CometChat] ${JSON.stringify(e)}`;
640
+ } catch {
641
+ return `[CometChat] ${String(e)}`;
642
+ }
643
+ }
644
+
645
+ const KNOWN_DOC_HINTS: Record<string, string> = {
646
+ ERROR_API_KEY_NOT_FOUND:
647
+ "Auth Key is missing or invalid. Check your env vars (VITE_COMETCHAT_AUTH_KEY / EXPO_PUBLIC_COMETCHAT_AUTH_KEY) and confirm the key in Dashboard → App → Credentials.",
648
+ ERR_UID_NOT_FOUND:
649
+ "The UID you're logging in with doesn't exist in this CometChat app. Create the user in Dashboard → Users, or pick one of the pre-seeded test UIDs (cometchat-uid-1 .. cometchat-uid-5).",
650
+ ERR_AUTH_TOKEN_NOT_FOUND:
651
+ "Auth token is empty or expired. Re-mint it from your backend via the CometChat REST API.",
652
+ AUTH_ERR_BOT:
653
+ "This UID is flagged as a Bot in the dashboard — auth-key login is refused for bot users by design. Toggle Bot OFF in Dashboard → Users, or pick a non-bot UID.",
654
+ };
655
+
656
+ export function logCometChatError(e: unknown): void {
657
+ const formatted = formatCometChatError(e);
658
+ console.error(formatted, e);
659
+ const code = (e as { code?: string; errorCode?: string })?.code ??
660
+ (e as { code?: string; errorCode?: string })?.errorCode;
661
+ if (code && KNOWN_DOC_HINTS[code]) {
662
+ console.warn(`[CometChat hint] ${KNOWN_DOC_HINTS[code]}`);
663
+ }
664
+ }
665
+ ```
666
+
667
+ Then in the provider:
668
+
669
+ ```typescript
670
+ } catch (e) {
671
+ logCometChatError(e);
672
+ setError(formatCometChatError(e));
673
+ }
674
+ ```
675
+
676
+ And in the error renderer:
677
+
678
+ ```tsx
679
+ if (error) {
680
+ return (
681
+ <div role="alert" style={{ color: "#b91c1c", padding: 16, fontFamily: "ui-monospace, monospace", whiteSpace: "pre-wrap" }}>
682
+ <strong>CometChat failed to initialize.</strong>
683
+ <div style={{ marginTop: 8 }}>{error}</div>
684
+ <div style={{ marginTop: 8, fontSize: 12, opacity: 0.7 }}>
685
+ See the browser console for the full error object and any [CometChat hint] line above it.
686
+ </div>
687
+ </div>
688
+ );
689
+ }
690
+ ```
691
+
692
+ This three-part recipe — `formatCometChatError` for the visible message, `logCometChatError` for the console (with a docs hint for known codes), and a multi-line render that points at the console — turns "ERR_API_KEY_NOT_FOUND" from a 10-minute debugging session into a 10-second fix.
693
+
694
+ > ⚠️ **Replace `setError(String(e))` everywhere.** The two earlier examples in this skill (§1 init-in-useEffect, §6 provider's setup() catch) use `setError(String(e))` for compactness — when you scaffold the real integration, emit `formatCometChatError(e)` instead and import it from `cometchat/errors.ts`. The same applies to RN (`cometchat-native-core`), Angular (`cometchat-angular-core`), and the native cores — the helper is platform-agnostic, just adapt the file extension.
695
+
473
696
  ---
474
697
 
475
698
  ## 7. RTL, i18n, and accessibility
@@ -496,23 +719,27 @@ CometChatLocalize.init({
496
719
  });
497
720
  ```
498
721
 
499
- For a dynamic language switcher, call `CometChatLocalize.setLocale(newLang)` when the user picks a language. The UI Kit re-renders with the new strings.
722
+ For a dynamic language switcher, call `CometChatLocalize.setCurrentLanguage(newLang)` when the user picks a language (NOT `setLocale` — that method doesn't exist in v6). The UI Kit re-renders with the new strings.
500
723
 
501
- **To override a string:** the `resources` option accepts custom translations merged over the defaults. Useful for brand-specific terms:
724
+ **To override a string:** there's no nested `resources: { en: {...} }` option. Use either `translationsForLanguage` at init (a FLAT key→value map for the chosen `language`), or the standalone `CometChatLocalize.addTranslation({...})`:
502
725
 
503
726
  ```typescript
727
+ // (a) at init — flat map for the active language
504
728
  CometChatLocalize.init({
505
729
  language: "en",
506
- resources: {
507
- en: {
508
- "type a message": "Write your message…",
509
- "start a conversation": "Say hi 👋",
510
- },
730
+ translationsForLanguage: {
731
+ "type a message": "Write your message…",
732
+ "start a conversation": "Say hi 👋",
511
733
  },
512
734
  });
735
+
736
+ // (b) anytime after init
737
+ CometChatLocalize.addTranslation({
738
+ "type a message": "Write your message…",
739
+ });
513
740
  ```
514
741
 
515
- **Full translation key list** lives in `node_modules/@cometchat/chat-uikit-react/dist/resources/` or the docs MCP. Don't invent keys — unknown keys fall through to the default.
742
+ **Full translation key list** lives under `node_modules/@cometchat/chat-uikit-react/dist/types/resources/` (types) or the docs MCP. Don't invent keys — unknown keys fall through to the default.
516
743
 
517
744
  ### Accessibility
518
745
 
@@ -629,6 +856,11 @@ Install with your project's package manager:
629
856
  npm install @cometchat/chat-uikit-react @cometchat/chat-sdk-javascript
630
857
  ```
631
858
 
859
+ > 💡 **Cost transparency (ENG-35722) — disclose proactively when integrating into a new project:** the kit adds roughly **2.8 MB of JS** (~860 KB gzipped), **~860 KB of CSS**, and **~1.5 MB of Roboto TTF fonts** (9 weights bundled). If the customer's app already loads custom fonts, the Roboto bundle is redundant; override via the `--cometchat-font-family` CSS variable to skip preloading the kit fonts (the TTFs still ship but the browser doesn't download them unless they're actually used). For SaaS founders evaluating CometChat vs self-build, also mention:
860
+ > - **Pricing:** https://www.cometchat.com/pricing (free tier covers small dev/test use)
861
+ > - **Data extraction / migration:** REST API endpoints `GET /v3/users`, `GET /v3/groups`, `GET /v3/messages?conversationId=` can export everything; no proprietary lock-in
862
+ > - **Demo without account:** for `intent: "evaluating"` users, point at the hosted demo at https://app.cometchat.com/login (sign-up gives a free app immediately; ENG-35722 demo-without-account hosted-demo is a vendor follow-up)
863
+
632
864
  ### SDK types you will use
633
865
 
634
866
  ```typescript
@@ -645,3 +877,170 @@ CometChat.TextMessage // A text message specifically
645
877
  CometChat.getUser(uid: string): Promise<CometChat.User>
646
878
  CometChat.getGroup(guid: string): Promise<CometChat.Group>
647
879
  ```
880
+
881
+ ## 11. Visual Builder integration
882
+
883
+ When the dispatcher's Step 3.1 sets `customize=visual`, skills runs **`cometchat builder export --platform react`** — a single CLI command that mirrors the dashboard's Export-button workflow. It downloads the canonical static template ZIP from `preview.cometchat.com/downloads/cometchat-builder-react.zip`, fetches the per-builder settings JSON via `GET /vcb/builders/{id}`, unzips the template, **splices** the fetched JSON (+ missing-field defaults) into `CometChatSettings.ts`, and writes the result to `--output` (default: `src/CometChat/`).
884
+
885
+ **How `CometChatSettings.ts` is patched (splice, not full-file overwrite):** the canonical file declares both `export interface CometChatSettingsInterface { ... }` and `export const CometChatSettings: CometChatSettingsInterface = { ... }`. The CLI rewrites **only the `export const CometChatSettings = {...}` object literal** with the per-builder JSON, **preserving the `export interface CometChatSettingsInterface`** above it (the const is typed against that interface — destroying it breaks the build). The sentinel comment (`SKILLS-AUTO-GENERATED — do not edit by hand. Last sync: <ISO>`) is **prepended to the spliced file**. Do not describe this as a full-file replace.
886
+
887
+ The `src/CometChat/` directory contains `CometChatApp.tsx`, the repo's own `CometChatProvider`-style context, `CometChatHome` with tabs (Chats / Calls / Users / Groups), theme hooks (`useThemeStyles`, `useSystemColorScheme`), login listener wiring, and 13 supporting components. Skills does NOT hand-roll these — the copied directory is the integration. Two valid render entry points exist: the canonical CRA app's own `src/App.tsx` composes `CometChatHome` + `CometChatLogin` directly (gated on a login listener), while the Next.js entry renders the higher-level `<CometChatApp />` wrapper. Both are fine — `<CometChatApp />` is the simplest, but don't assume it's the only canonical shape.
888
+
889
+ This is the same pattern iOS (verbatim `MessagesVC.swift`), Android v6 (verbatim `BuilderSettingsHelper.kt`), and Flutter v6 (verbatim `chat_builder/` package) use. React just happens to copy a directory of TSX files instead of a single class.
890
+
891
+ ### 11.1 Run `cometchat builder export`
892
+
893
+ After Step 3.1.v step 4 (customer says "Done" + skills caches the builderId in `.cometchat/builder.json`), run:
894
+
895
+ ```bash
896
+ cometchat builder export --platform react --json
897
+ ```
898
+
899
+ This produces the full per-builder integration in one shot:
900
+
901
+ | What | Where |
902
+ |---|---|
903
+ | Downloads static template ZIP | `https://preview.cometchat.com/downloads/cometchat-builder-react.zip` |
904
+ | Fetches per-builder settings | `GET /vcb/builders/{builderId}` via the same `Bearer` token used elsewhere |
905
+ | Applies F3 + F10 missing-field defaults | `chatFeatures.inAppSounds` + `chatFeatures.deeperUserEngagement.mentionAll` |
906
+ | Unzips template into temp dir | `/tmp/cometchat-builder-export-XXXX/extracted/` |
907
+ | Splices `CometChatSettings.ts` | Rewrites only the `export const CometChatSettings = {...}` literal with the per-builder JSON; preserves `export interface CometChatSettingsInterface`; prepends the sentinel comment ("SKILLS-AUTO-GENERATED — do not edit by hand. Last sync: <ISO>") |
908
+ | Copies to `--output` | Default `src/CometChat/` |
909
+ | Reports JSON | `{ status: "exported", builderId, appId, platform, output, settings_file, builder_name }` |
910
+
911
+ **For Next.js App Router**, pass `--output src/app/CometChat`. For React Router v7 framework mode, pass `--output app/CometChat`. The CLI's F25 case-collision pre-check warns if a lowercase `src/cometchat/` exists with In-code-shape files (init.ts / CometChatProvider.tsx).
912
+
913
+ **For resync** (Step 7 iteration menu → Re-sync visual builder), re-run the SAME command with `--force`. This re-downloads the latest canonical template + re-fetches the latest settings + replaces the `--output` directory entirely. Customer hand-edits inside the `CometChat/` directory are lost — matches the "SKILLS-AUTO-GENERATED" contract on the sentinel.
914
+
915
+ ### 11.2 Files patched (after export)
916
+
917
+ The `builder export` command writes the canonical files. Skills then patches the customer's existing project to wire it in:
918
+
919
+ | Path | Patch |
920
+ |---|---|
921
+ | `package.json` | (1) `npm install @cometchat/chat-uikit-react@6.4.3 @cometchat/calls-sdk-javascript@4.2.5` — **pinned versions from the canonical repo's README**. Older/newer versions of `chat-uikit-react` may drift from the exported `src/CometChat/` directory's expected API surface. (2) **REQUIRED for Vite — add the `cometChatCustomConfig` block to `package.json`.** The canonical `package.json` carries a top-level `cometChatCustomConfig` block, and the copied context (`CometChat/context/CometChatContext.tsx:~216`) reads `pkg?.default?.cometChatCustomConfig.name`. ⚠ This **IS build-breaking on Vite**: the Builder tsconfig requires `resolveJsonModule: true` (next row), so `tsc -b` (the project-references build `npm run build` runs) **statically types `package.json`** → `TS2339: Property 'cometChatCustomConfig' does not exist` when absent. (`tsc --noEmit` passes and HIDES this — use `tsc -b`/`npm run build` for the build proof. Verified 2026-06-14 on a real export build.) Add: `"cometChatCustomConfig": { "name": "<your-app-name>", "version": "<your-app-version>", "production": true }`. |
922
+ | Entry file — `src/main.tsx` (Vite) / `src/index.tsx` (CRA) / new client component (Next.js) / route file (React Router) / `.astro` page (Astro) | Init UI Kit + render `<CometChatProvider><App /></CometChatProvider>`. Pattern below — varies by framework. |
923
+ | `tsconfig.app.json` (Vite 7+) or `tsconfig.json` (CRA / older Vite) | **Imports resolve on Vite as-is** — the current `builder export` writes `src/CometChat/` with **relative imports** (`../utils/utils`, `../context/CometChatContext`), NOT the bare `CometChat/…`-rooted imports older CRA exports used. So you do **NOT** need `vite-tsconfig-paths` / `baseUrl` (verified 2026-06-14: zero `from "CometChat/…"` in a fresh export; resolves on Vite out of the box). *(Historical: pre-2026 CRA exports used `baseUrl:"./src"` bare imports that needed `vite-tsconfig-paths`; the current template ships relative.)*<br><br>You DO still need these stricter-than-CRA tsconfig flags — Vite 7+ template defaults will otherwise fail the build with `TS6133` / `TS1484`:<br>• `"resolveJsonModule": true` — required (`utils/utils.ts` imports a JSON locale)<br>• `"jsx": "react-jsx"` — required<br>• `"verbatimModuleSyntax": false` — Vite 7+ default is `true`; canonical code uses mixed value + type imports without the `type` modifier<br>• `"noUnusedLocals": false` — Vite 7+ default is `true`; canonical code has many unused-by-default destructured listener args (e.g. `({ groupOwner, kickedUser, ... })`)<br>• `"noUnusedParameters": false` — same rationale<br>• `"erasableSyntaxOnly": false` — Vite 7+ template flag; canonical code uses const enums / namespace patterns<br>• `"allowJs": true` — canonical app's tsconfig sets this; some kit internals may rely on JS fallthrough<br>Validated 2026-05-21 against `create-vite@8` + canonical `uikit-builder-app` (CRA) + `@cometchat/chat-uikit-react@6.4.3`. |
924
+ | `.env` (framework-prefixed) | Already written by Step 2c provision. Skip if present; warn if missing. |
925
+
926
+ The `builder export` command handles the JSON patching + sentinel comment automatically. Skills only needs to patch the four files above (package.json, entry file, tsconfig, .env).
927
+
928
+ ### 11.3 Entry-file init pattern (Vite + React)
929
+
930
+ ```tsx
931
+ // src/main.tsx
932
+ import { createRoot } from "react-dom/client";
933
+ import "./index.css";
934
+ import App from "./App.tsx";
935
+ import {
936
+ UIKitSettingsBuilder,
937
+ CometChatUIKit,
938
+ } from "@cometchat/chat-uikit-react";
939
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
940
+ import { setupLocalization } from "./CometChat/utils/utils.ts";
941
+ import { CometChatProvider } from "./CometChat/context/CometChatContext.tsx";
942
+
943
+ export const COMETCHAT_CONSTANTS = {
944
+ APP_ID: import.meta.env.VITE_COMETCHAT_APP_ID!,
945
+ REGION: import.meta.env.VITE_COMETCHAT_REGION!,
946
+ AUTH_KEY: import.meta.env.VITE_COMETCHAT_AUTH_KEY!,
947
+ };
948
+
949
+ const uiKitSettings = new UIKitSettingsBuilder()
950
+ .setAppId(COMETCHAT_CONSTANTS.APP_ID)
951
+ .setRegion(COMETCHAT_CONSTANTS.REGION)
952
+ .setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
953
+ .subscribePresenceForAllUsers()
954
+ .build();
955
+
956
+ CometChatUIKit.init(uiKitSettings)?.then(() => {
957
+ setupLocalization();
958
+ createRoot(document.getElementById("root")!).render(
959
+ <CometChatProvider>
960
+ <App />
961
+ </CometChatProvider>
962
+ );
963
+ });
964
+ ```
965
+
966
+ Then in `src/App.tsx`:
967
+
968
+ ```tsx
969
+ import CometChatApp from "./CometChat/CometChatApp";
970
+
971
+ export default function App() {
972
+ return (
973
+ // CometChatApp requires an explicit width and height to render. Adjust as needed
974
+ // for your Step 3c placement (full route, drawer, modal, embedded panel).
975
+ <div style={{ width: "100vw", height: "100dvh" }}>
976
+ <CometChatApp />
977
+ </div>
978
+ );
979
+ }
980
+ ```
981
+
982
+ **Critical:**
983
+
984
+ - `CometChatProvider` is the **repo's own context** from `./CometChat/context/CometChatContext`, NOT the kit's `CometChatUIKit` export. It manages the builder's `styleFeatures` / `chatFeatures` state and is required for `CometChatHome`, `useThemeStyles`, and the customization toggles to work.
985
+ - `setupLocalization()` from `./CometChat/utils/utils` is required before render — it wires the builder's i18n catalog into the kit. Skipping it leaves UI strings empty.
986
+ - `CometChatUIKit.init(...)` returns a Promise — render only AFTER it resolves. Rendering before init resolves causes `CometChatHome` to throw on first listener attach.
987
+ - Login is handled by `CometChatApp` itself (the canonical component uses `CometChat.addLoginListener` + `CometChatUIKit.getLoggedinUser`). For dev mode, the customer's `App.tsx` should call `CometChatUIKit.login("cometchat-uid-1")` after init resolves but BEFORE rendering — see §2's login order. The canonical app shows a `LoginPlaceholder` until a user is present.
988
+
989
+ ### 11.4 Per-framework variants
990
+
991
+ | Framework | Where to put `CometChat/` | Entry-file pattern | SSR notes |
992
+ |---|---|---|---|
993
+ | **Vite + React** | `src/CometChat/` | `src/main.tsx` (above) | N/A |
994
+ | **Create React App** | `src/CometChat/` | `src/index.tsx` — same as Vite but use `ReactDOM.createRoot` from `react-dom/client` | N/A |
995
+ | **Next.js App Router** | `src/app/CometChat/` | Create `src/app/CometChatNoSSR/CometChatNoSSR.tsx` (client component) that does init + login + renders `<CometChatProvider><CometChatApp /></CometChatProvider>`. Then create `src/app/CometChatAppWrapper.tsx` with `"use client"` + `dynamic(() => import("../app/CometChatNoSSR/CometChatNoSSR"), { ssr: false })`. Import the wrapper in `src/app/page.tsx`. | The canonical `src/CometChat/` uses `window` / `document` / WebSocket APIs at module scope. `{ ssr: false }` on the wrapper is **non-negotiable** — direct import from a server component causes hydration errors. Use `process.env.NEXT_PUBLIC_COMETCHAT_*` instead of `import.meta.env.*`. |
996
+ | **Next.js Pages Router** | `src/CometChat/` | `pages/chat.tsx` — `const CometChatApp = dynamic(() => import("../src/CometChat/CometChatApp"), { ssr: false });` Init in `pages/_app.tsx` inside `useEffect`. | Same SSR rationale as App Router. |
997
+ | **React Router v7** | `app/CometChat/` (framework mode) or `src/CometChat/` (data mode) | Framework mode: use a `.client.tsx` suffix or `<ClientOnly>` from `remix-utils/client-only`. Data mode: same as Vite. | Framework mode SSRs by default — `.client.tsx` suffix OR `<ClientOnly>` is the only safe pattern. |
998
+ | **Astro** | `src/CometChat/` | `<CometChatApp client:only="react" />` inside an `.astro` page. Init runs in a sibling `.tsx` component that mounts before `CometChatApp`. | `client:only="react"` — never `client:load` (Astro will still SSR the import resolution and crash). |
999
+
1000
+ ### 11.5 Calls + builder
1001
+
1002
+ If `CometChatSettings.callFeatures` has any `true` value (`oneOnOneVoiceCalling`, `oneOnOneVideoCalling`, `groupVideoConference`, `groupVoiceConference`):
1003
+
1004
+ 1. The canonical `src/CometChat/` already wires `CometChatIncomingCall` inside `CometChatHome` — no extra mount required.
1005
+ 2. Skills patches `package.json` to add `@cometchat/calls-sdk-javascript@4.2.5` (already in the canonical install command above) and the Cloudsmith-hosted `@cometchat/calls-lib-webrtc` per `cometchat-react-calls`.
1006
+ 3. Calls SDK init runs alongside UI Kit init — pattern in `cometchat-react-calls § 2`.
1007
+
1008
+ Invoke `cometchat-react-calls` after this section with `{ mode: "additive" }` so it adds Calls SDK init + lib-webrtc without duplicating the kit-level wiring already present in the copied `src/CometChat/`.
1009
+
1010
+ ### 11.6 Resync flow
1011
+
1012
+ The "Re-sync visual builder" iteration menu option (see `cometchat/SKILL.md § Step 7`) is a **one-command re-run**:
1013
+
1014
+ ```bash
1015
+ cometchat builder export --platform react --force
1016
+ ```
1017
+
1018
+ The `--force` flag is mandatory: it explicitly authorizes replacing the existing `src/CometChat/` directory. Without it, the CLI bails with *"--output directory \`src/CometChat\` already exists. Pass --force to replace it (full re-download per the resync flow), or pick a different --output path."*
1019
+
1020
+ This matches the product contract for step 7 of the UI Kit Builder workflow:
1021
+
1022
+ 1. Re-download the canonical static template ZIP (in case vendor has shipped fixes)
1023
+ 2. Re-fetch the customer's current settings JSON (in case they tweaked in browser)
1024
+ 3. Apply the F3 + F10 missing-field defaults
1025
+ 4. Replace the `src/CometChat/` directory entirely
1026
+
1027
+ **Customer hand-edits inside `src/CometChat/` are lost on resync.** This is intentional — the SKILLS-AUTO-GENERATED sentinel comment prepended to `CometChatSettings.ts` documents the "do not edit by hand" contract. (Note the export itself is a splice — only the `export const CometChatSettings = {...}` literal is rewritten and `export interface CometChatSettingsInterface` is preserved — but on `--force` resync the whole `src/CometChat/` directory is re-downloaded and replaced, so any in-folder hand-edits are discarded regardless.)
1028
+
1029
+ If a customer needs to override beyond what the Visual Builder exposes, the supported escape hatches are:
1030
+ - Edit the entry file (e.g., `src/main.tsx`) — outside `src/CometChat/`, never touched by resync
1031
+ - Edit `src/App.tsx` to wrap `<CometChatApp />` with additional providers / styling
1032
+ - Use `cometchat apply-feature <id>` for extension toggles (server-side, survives resync)
1033
+ - For one-off CSS overrides, edit `src/index.css` or equivalent — also outside `src/CometChat/`
1034
+
1035
+ > **Builder feature toggles vs. dashboard extensions — two independent layers.** The Visual Builder's `chatFeatures` toggles (baked into `CometChatSettings.ts`) only control whether a feature's **UI** is shown. Extension- and AI-backed features (polls, message translation, collaborative document/whiteboard, stickers, smart replies, conversation starter/summary) need their **server-side capability** enabled separately — the dashboard extensions store, which `cometchat apply-feature <id>` writes and the builder export **never touches**. So: (a) `apply-feature`'d extensions always survive `builder export --force`; (b) turning a feature ON in the builder shows its UI but it fails at runtime until the matching extension is enabled — that's why `builder export` reports a `dashboardSetupNeeded` list (the dispatcher runs `apply-feature` for each). The two flows are complementary: the builder draws the UI, `apply-feature` turns on the capability behind it.
1036
+
1037
+ The `cometchat-core` §11.7 "Override hook pattern" documents the recommended places to override without touching the canonical.
1038
+
1039
+ `verify --builder` runs after resync to confirm the new export is structurally sound.
1040
+
1041
+ ### 11.7 What this section does NOT emit
1042
+
1043
+ The canonical `src/CometChat/` honors every Builder setting it supports — theme colors, typography, dark/light, sidebar toggle, layout tabs, `chatFeatures.*`, `callFeatures.*`, `agent.*` (per the repo's `CometChatHome` + `styleConfig.ts`). The only setting that isn't auto-applied is `noCode.docked` (the floating-widget shape) — that's a runtime DOM injection that requires the customer to mount `<CometChatApp />` inside a docked overlay container. Surface this in the post-emit summary:
1044
+
1045
+ > Builder settings honored: theme, typography, layout/tabs, sidebar, chat features (mentions/reactions/threads/media/etc.), call features, agent UI.
1046
+ > Builder settings deferred: `noCode.docked` floating-widget mode — requires manual mount inside a positioned overlay; see `cometchat-placement § Floating widget`.