@commentkit/comment-kit 0.7.7 → 1.0.0-beta.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 (109) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +108 -762
  3. package/SECURITY.md +19 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  6. package/dist/npm/chunks/client-D1vrh_5G.js +590 -0
  7. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  8. package/dist/npm/chunks/html2canvas-_mjSRP3G.js +4011 -0
  9. package/dist/npm/chunks/mount-Ce1MZrcm.js +2485 -0
  10. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-DRKlokR8.js} +224 -222
  11. package/dist/npm/chunks/realtime-5SvAvTUU.js +23 -0
  12. package/dist/npm/chunks/rolldown-runtime-VHNaYcLd.js +13 -0
  13. package/dist/npm/chunks/src-DJjfvVsa.js +330 -0
  14. package/dist/npm/element.js +24 -0
  15. package/dist/npm/headless.js +3 -0
  16. package/dist/npm/index.js +3 -0
  17. package/dist/npm/react.js +17 -0
  18. package/dist/npm/svelte.js +8 -0
  19. package/dist/npm/types/adapters/react.d.ts +9 -0
  20. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  21. package/dist/npm/types/adapters/vue.d.ts +46 -0
  22. package/dist/npm/types/anchor/index.d.ts +49 -0
  23. package/dist/npm/types/core/api.d.ts +29 -0
  24. package/dist/npm/types/core/auth.d.ts +48 -0
  25. package/dist/npm/types/core/client.d.ts +100 -0
  26. package/dist/npm/types/core/store.d.ts +7 -0
  27. package/dist/npm/types/core/types.d.ts +278 -0
  28. package/dist/npm/types/element.d.ts +10 -0
  29. package/dist/npm/types/headless.d.ts +7 -0
  30. package/dist/npm/types/index.d.ts +30 -0
  31. package/dist/npm/vue.js +32 -0
  32. package/package.json +65 -173
  33. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  34. package/dist/angular.es.js +0 -321
  35. package/dist/comment-kit.es.js +0 -218
  36. package/dist/demo.es.js +0 -483
  37. package/dist/headless.es.js +0 -4
  38. package/dist/preact.es.js +0 -117
  39. package/dist/qwik.es.js +0 -1
  40. package/dist/qwik.qwik.mjs +0 -114
  41. package/dist/react.es.js +0 -98
  42. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  43. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  44. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  45. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  46. package/dist/shared/bridge-CJoGYngu.js +0 -177
  47. package/dist/shared/button-D4GHW6oZ.js +0 -474
  48. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  49. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  50. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  51. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  52. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  53. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  54. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  55. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  56. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  57. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  58. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  59. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  60. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  61. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  62. package/dist/shared/dist-D9A5k-N4.js +0 -617
  63. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  64. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  65. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  66. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  67. package/dist/shared/icons-nzMOLzrm.js +0 -266
  68. package/dist/shared/input-UPtAj0M6.js +0 -111
  69. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  70. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  71. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  72. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  73. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  74. package/dist/shared/separator-UhJb0Row.js +0 -3955
  75. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  76. package/dist/shared/styles-CnYsLS2f.js +0 -2
  77. package/dist/shared/text-B4HHZNaa.js +0 -23
  78. package/dist/shared/token-session-D92MYbNu.js +0 -25
  79. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  80. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  81. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  82. package/dist/shared/validation-3wbbbuX0.js +0 -70
  83. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  84. package/dist/solid.es.js +0 -98
  85. package/dist/svelte.es.js +0 -130
  86. package/dist/types/adapters/bridge.d.ts +0 -122
  87. package/dist/types/angular/index.d.ts +0 -145
  88. package/dist/types/core/agent-context.d.ts +0 -17
  89. package/dist/types/core/api-client.d.ts +0 -155
  90. package/dist/types/core/comment-kit-core.d.ts +0 -254
  91. package/dist/types/core/local-demo.d.ts +0 -60
  92. package/dist/types/core/types.d.ts +0 -770
  93. package/dist/types/core/websocket-manager.d.ts +0 -125
  94. package/dist/types/core/write-access.d.ts +0 -11
  95. package/dist/types/demo.d.ts +0 -17
  96. package/dist/types/headless.d.ts +0 -8
  97. package/dist/types/index.d.ts +0 -87
  98. package/dist/types/preact/index.d.ts +0 -25
  99. package/dist/types/qwik/index.d.ts +0 -73
  100. package/dist/types/react/client.d.ts +0 -31
  101. package/dist/types/react/index.d.ts +0 -4
  102. package/dist/types/solid/index.d.ts +0 -37
  103. package/dist/types/svelte/index.d.ts +0 -55
  104. package/dist/types/utils/dom.d.ts +0 -59
  105. package/dist/types/utils/event-emitter.d.ts +0 -11
  106. package/dist/types/vue/index.d.ts +0 -87
  107. package/dist/vue.es.js +0 -148
  108. package/docs/api-reference.md +0 -405
  109. package/docs/local-demo.md +0 -60
package/README.md CHANGED
@@ -1,847 +1,193 @@
1
1
  # CommentKit
2
2
 
3
- **Figma-style comments, drawing, and feedback for any website.**
4
- Drop-in SDK for React, Vue, Svelte, Angular, Solid.js, Qwik, Preact, and vanilla JavaScript.
5
-
6
- [npm version](https://www.npmjs.com/package/@commentkit/comment-kit)
7
- [downloads](https://www.npmjs.com/package/@commentkit/comment-kit)
8
- [license](./LICENSE)
9
- [docs](https://commentkit.dev/developers)
10
-
11
- ---
12
-
13
- ## Features
14
-
15
- | Feature | Description |
16
- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
17
- | **Pin Comments** | Click anywhere on a page to leave a comment pin |
18
- | **Element Comments** | Select a real DOM element, comment on it, and keep it marked until resolved |
19
- | **Text Highlighting** | Select text to annotate with contextual feedback |
20
- | **Drawing Tools** | Freehand draw, shapes, and arrows overlaid on the page |
21
- | **Screenshots** | Capture annotated screenshots with one click |
22
- | **Real-Time Collaboration** | See live cursors, presence indicators, and instant updates |
23
- | **Offline Support** | Mutations queue automatically and retry when back online |
24
- | **OTP Authentication** | Passwordless email authentication with authenticator/recovery-code support |
25
- | **Member Invite Links** | Invite members by email — they verify via OTP to join |
26
- | **Task Workflows** | Assign, prioritize, resolve, and track comments as tasks |
27
- | **@Mentions** | Tag team members with autocomplete from your project roster |
28
- | **Reactions** | Emoji reactions on comments and replies |
29
- | **Deep Linking** | Link directly to any comment via URL hash |
30
- | **Agent Handoff** | Copy unresolved comments + element source + screenshot to Claude Desktop, Cursor, Codex, Continue, Zed AI, or any clipboard-aware agent |
31
- | **Source-Resolved Output** | When the `element-source` peer is installed, agent context includes `file:line:col` and the component stack for each element |
32
- | **Dev Grab** | One-click capture: any element on your localhost site → clipboard with Markdown + `image/png` screenshot for direct paste into your agent |
33
- | **Dev Export Panel** | On localhost, bulk-select stakeholder comments from production/staging and copy them as one bundled agent payload |
34
- | **Multi-Select** | Shift+click or drag a marquee to grab multiple elements at once |
35
- | **Context Menu** | Right-click any element while in select mode: grab, comment, copy selector, copy XPath, inspect |
36
- | **Hold-to-Activate** | Configure select mode to be active only while a modifier key is held (`Alt`, `Meta`, `Control`, `Shift`) |
37
- | **Animation Freeze** | While selecting, all host-page CSS animations, transitions, and Web Animations API tweens pause |
38
- | **Touch Mode** | Long-press opens the context menu on touch devices |
39
- | **MCP Companion** | Separate `comment-kit-mcp` package for authenticated, read-only agent access to feedback |
40
- | **Keyboard Shortcuts** | Full keyboard navigation and tool shortcuts |
41
- | **Shadow DOM Isolation** | UI is fully isolated from your app's styles |
42
- | **Environment Scoping** | New comments are tagged to production, staging, preview, or dev |
43
- | **Auto-Configuration** | SDK auto-detects projectId, WebSocket config, and invite tokens |
44
-
45
- ---
46
-
47
- ## Quick Start
48
-
49
- ### 1. Install
50
-
51
- For an app that already has matching React and ReactDOM 18+ versions:
3
+ Figma-style comments for any website.
52
4
 
53
- ```bash
54
- npm install @commentkit/comment-kit
55
- ```
5
+ Your clients click the part of the page they mean and write what should change. CommentKit pins the comment to that exact spot, attaches a screenshot of what they saw, and records the page, browser and screen size. You see the feedback on your live site, your staging and preview links, and on `localhost` — and you can hand it straight to your AI coding agent.
56
6
 
57
- For vanilla, Vue, Svelte, Angular, Solid, Qwik, or Preact apps using the built-in widget:
58
-
59
- ```bash
60
- npm install @commentkit/comment-kit react react-dom
61
- ```
62
-
63
- Every adapter renders the same React widget. React and ReactDOM are optional in package metadata so a headless installation can omit them; **all built-in UI integrations still need both**. Keep existing compatible React versions rather than upgrading them just to install CommentKit. Your adapter's framework is also a peer dependency.
64
-
65
- The package is ESM-only; use `import`, not CommonJS `require()`. For default screenshots and image captures, also install `html2canvas`, or supply a custom `screenshotProvider`:
66
-
67
- ```bash
68
- npm install html2canvas
69
- ```
7
+ - **One install, every stack.** A script tag works on any website (WordPress, Webflow, Shopify, plain HTML). npm users get `init()` plus tiny React, Vue and Svelte helpers. Nothing else to install: no React required on your side.
8
+ - **Built for people who have never used a feedback tool.** Clients open a review link, click, type, confirm their email once. No account, no password.
9
+ - **Built for developers.** Feedback per branch and environment, element selectors and source locations, console errors, a dashboard with list and board views, email notifications, and an MCP server for Claude Code, Cursor and other agents.
70
10
 
71
- ### 2. Get Your API Key
11
+ ## Install
72
12
 
73
- 1. Sign up at [commentkit.dev](https://commentkit.dev)
74
- 2. Create an organization
75
- 3. Create a project inside the organization
76
- 4. Add the website domains that may use this project to its **allowed domains**
77
- 5. Copy the **API key** from the project dashboard
13
+ ### Any website
78
14
 
79
- Each project gets its own browser-facing API key. The SDK reads the project ID, WebSocket configuration and features from the API automatically. An empty origin allowlist denies browser requests by default. The project key identifies the project; a verified user session is still required to read private context and mutate feedback. Never embed user Bearer tokens or server credentials in your application source.
15
+ Paste before `</body>`:
80
16
 
81
- ### 3. Add to Your App
82
-
83
- On localhost the toolbar is visible. On production, staging and preview sites, press **Cmd/Ctrl + Shift + K** to open sign-in, then verify your email with OTP. Mount one instance for the app and clean it up when its host unmounts.
84
-
85
- **Next.js (App Router)**
86
-
87
- Import the client entry directly from your layout. The published React entry retains its `"use client"` boundary, and browser UI mounting happens after hydration. A `next/dynamic` wrapper with `ssr: false` is no longer required.
88
-
89
- ```tsx
90
- // app/layout.tsx
91
- import { CommentKit } from "@commentkit/comment-kit/react";
92
-
93
- export default function RootLayout({ children }: { children: React.ReactNode }) {
94
- return (
95
- <html lang="en">
96
- <body>
97
- {children}
98
- <CommentKit apiKey="your-api-key" />
99
- </body>
100
- </html>
101
- );
102
- }
17
+ ```html
18
+ <script src="https://commentkit.dev/cdn/v1/loader.js" data-project="pk_live_your_key" defer></script>
103
19
  ```
104
20
 
105
- **Next.js (Pages Router)**
21
+ ### npm
106
22
 
107
- ```tsx
108
- // pages/_app.tsx
109
- import { CommentKit } from "@commentkit/comment-kit/react";
110
- import type { AppProps } from "next/app";
111
-
112
- export default function App({ Component, pageProps }: AppProps) {
113
- return (
114
- // Works with any CSS setup — Tailwind, CSS Modules, styled-components.
115
- // CommentKit UI is fully isolated inside Shadow DOM.
116
- <CommentKit
117
- apiKey="your-api-key"
118
- // onReady={() => console.log("CommentKit loaded")}
119
- // onError={(err) => console.error(err)}
120
- >
121
- <Component {...pageProps} />
122
- </CommentKit>
123
- );
124
- }
23
+ ```bash
24
+ npm install @commentkit/comment-kit
125
25
  ```
126
26
 
127
- **Remix**
128
-
129
- ```tsx
130
- // app/root.tsx
131
- import { CommentKit } from "@commentkit/comment-kit/react";
27
+ ```ts
28
+ import { init } from "@commentkit/comment-kit";
132
29
 
133
- export default function App() {
134
- return (
135
- <html lang="en">
136
- <head>
137
- <Meta />
138
- <Links />
139
- </head>
140
- <body>
141
- <Outlet />
142
- {/* Same as Next.js — sits outside your providers, fully self-contained */}
143
- <CommentKit apiKey="your-api-key" />
144
- <Scripts />
145
- </body>
146
- </html>
147
- );
148
- }
30
+ init({ project: "pk_live_your_key" });
149
31
  ```
150
32
 
151
- **React (Vite / CRA)**
33
+ ### React / Next.js
152
34
 
153
35
  ```tsx
154
- // main.tsx or App.tsx
155
36
  import { CommentKit } from "@commentkit/comment-kit/react";
156
37
 
157
- export default function App() {
158
- return (
159
- // Drop-in: renders a floating toolbar with comment, draw,
160
- // highlight, and screenshot tools. Tooltips built-in.
161
- // Theme follows .dark/.light class or system preference.
162
- <CommentKit apiKey="your-api-key">{/* Your app content */}</CommentKit>
163
- );
164
- }
38
+ // Root layout, next to {children}. Works in Next.js server layouts.
39
+ <CommentKit project="pk_live_your_key" branch={process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF} />
165
40
  ```
166
41
 
167
- **Vue 3**
168
-
169
- ```vue
170
- <script setup>
171
- import { useCommentKit } from "@commentkit/comment-kit/vue";
172
-
173
- // Reactive refs — auto-update when state changes.
174
- // Theme auto-detects. Tooltips built into the toolbar.
175
- const { isAuthenticated, comments, toggleOverlay } = useCommentKit({
176
- apiKey: "your-api-key",
177
- // ui: { theme: "dark", position: "bottom-left" },
178
- });
179
- </script>
180
- ```
181
-
182
- Or register as a plugin:
42
+ ### Vue / Nuxt
183
43
 
184
44
  ```ts
185
- // main.ts — registers the <CommentKit> component
186
45
  import { CommentKitPlugin } from "@commentkit/comment-kit/vue";
187
46
 
188
- app.use(CommentKitPlugin);
189
- ```
190
-
191
- Then mount `<CommentKit api-key="your-api-key" />` once in your root template.
192
-
193
- **Nuxt 3 / Nuxt 4**
194
-
195
- For a client-only Nuxt integration, use a component whose filename ends in `.client.vue`. Its setup registers the hook, and Nuxt handles client mounting.
196
-
197
- ```vue
198
- <!-- components/CommentKitClient.client.vue -->
199
- <script setup lang="ts">
200
- import { useCommentKit } from "@commentkit/comment-kit/vue";
201
-
202
- // Register lifecycle hooks during setup; the .client.vue boundary handles SSR.
203
- useCommentKit({ apiKey: "your-api-key" });
204
- </script>
205
-
206
- <template><div /></template>
47
+ app.use(CommentKitPlugin, { project: "pk_live_your_key" });
207
48
  ```
208
49
 
209
- ```vue
210
- <!-- app.vue -->
211
- <template>
212
- <div>
213
- <NuxtPage />
214
- <CommentKitClient />
215
- </div>
216
- </template>
217
- ```
218
-
219
- **Svelte**
50
+ ### Svelte / SvelteKit
220
51
 
221
52
  ```svelte
222
53
  <script>
223
- import { useCommentKit } from "@commentkit/comment-kit/svelte";
224
-
225
- // Svelte stores — use $store syntax for reactivity.
226
- // Theme auto-detects. Tooltips built into the toolbar.
227
- const { comments, isAuthenticated, toggleOverlay } = useCommentKit({
228
- apiKey: "your-api-key",
229
- // ui: { theme: "dark" },
230
- });
54
+ import { commentkit } from "@commentkit/comment-kit/svelte";
231
55
  </script>
232
56
 
233
- <button on:click={toggleOverlay}>Toggle Comments</button>
234
- <p>Comments: {$comments.length}</p>
235
- ```
236
-
237
- **SvelteKit**
238
-
239
- For an explicit client-only SvelteKit integration, create the store after a dynamic import and return synchronous teardown from `onMount`. `useCommentKit` registers Svelte lifecycle hooks, so call it during component initialization rather than after an `await`.
240
-
241
- ```svelte
242
- <!-- src/routes/+layout.svelte -->
243
- <script lang="ts">
244
- import { onMount } from "svelte";
245
- import type { SvelteCommentKitStore } from "@commentkit/comment-kit/svelte";
246
-
247
- onMount(() => {
248
- let disposed = false;
249
- let store: SvelteCommentKitStore | undefined;
250
-
251
- void import("@commentkit/comment-kit/svelte")
252
- .then(({ createCommentKitStore }) => {
253
- if (!disposed) store = createCommentKitStore({ apiKey: "your-api-key" });
254
- })
255
- .catch((error) => console.error("CommentKit could not load", error));
256
-
257
- return () => {
258
- disposed = true;
259
- store?.destroy();
260
- };
261
- });
262
- </script>
263
-
264
- <slot />
265
- ```
266
-
267
- **Angular**
268
-
269
- ```typescript
270
- // app.config.ts
271
- import { provideCommentKit } from "@commentkit/comment-kit/angular";
272
-
273
- export const appConfig = {
274
- providers: [
275
- // Registers CommentKitService with DI.
276
- // Theme auto-detects. All UI isolated in Shadow DOM.
277
- provideCommentKit({
278
- apiKey: "your-api-key",
279
- // ui: { theme: "dark", position: "bottom-left" },
280
- }),
281
- ],
282
- };
283
- ```
284
-
285
- ```typescript
286
- // app.component.ts
287
- import { Component, inject } from "@angular/core";
288
- import { CommentKitService } from "@commentkit/comment-kit/angular";
289
-
290
- @Component({ selector: "app-root", standalone: true, template: "<main>Your app</main>" })
291
- export class AppComponent {
292
- private readonly commentKit = inject(CommentKitService);
293
-
294
- // RxJS observables — auto-emit on state changes
295
- comments$ = this.commentKit.comments$;
296
- }
297
- ```
298
-
299
- **Solid.js / SolidStart**
300
-
301
- ```tsx
302
- import { useCommentKit } from "@commentkit/comment-kit/solid";
303
-
304
- function App() {
305
- // Solid signals — auto-track dependencies, fine-grained reactivity.
306
- // Full UI mounts in Shadow DOM automatically.
307
- const { comments, isAuthenticated, toggleOverlay } = useCommentKit({
308
- apiKey: "your-api-key",
309
- });
310
-
311
- return <p>Comments: {comments().length}</p>;
312
- }
313
- ```
314
-
315
- **Qwik / QwikCity**
316
-
317
- ```tsx
318
- import { component$ } from "@builder.io/qwik";
319
- import { useCommentKit } from "@commentkit/comment-kit/qwik";
320
-
321
- export default component$(() => {
322
- // The hook uses useVisibleTask$ to mount only on the client.
323
- // The Shadow DOM widget still requires React and ReactDOM.
324
- const { core, isReady } = useCommentKit({
325
- apiKey: "your-api-key",
326
- });
327
-
328
- return (
329
- <button disabled={!isReady.value} onClick$={() => core.value?.toggleOverlay()}>
330
- Toggle comments
331
- </button>
332
- );
333
- });
334
- ```
335
-
336
- Call the hook inside `component$`. In Qwik event handlers, access methods through the destructured `core` signal as above; do not capture plain bridge callbacks across an `onClick$` boundary. `useCommentKit$` remains a deprecated compatibility alias.
337
-
338
- Use Qwik's optimizer and its supported Vite version to build the host app. Qwik 1.20.2 has an upstream declaration error that requires `skipLibCheck: true`; CommentKit's consumer API expressions are still checked. Client-only function options such as `screenshotProvider` cannot survive server serialization; Qwik callbacks that must resume should use `onReady$` and `onError$`.
339
-
340
- **Preact**
341
-
342
- ```tsx
343
- import { useCommentKit } from "@commentkit/comment-kit/preact";
344
-
345
- function App() {
346
- // Preact hooks — lightweight React alternative.
347
- // Full UI mounts in Shadow DOM via React and ReactDOM (UI peers).
348
- const { state, core } = useCommentKit({
349
- apiKey: "your-api-key",
350
- });
351
-
352
- return <p>Comments: {state?.comments.length ?? 0}</p>;
353
- }
354
- ```
355
-
356
- **Astro**
357
-
358
- Astro needs the React integration installed (`npx astro add react`). Wrap the import in a tiny React component so `client:only="react"` keeps CommentKit out of the server bundle.
359
-
360
- ```tsx
361
- // src/components/CommentKitClient.tsx
362
- import { useEffect, useState } from "react";
363
-
364
- export default function CommentKitClient({ apiKey }: { apiKey: string }) {
365
- const [Cmp, setCmp] = useState<React.ComponentType<{ apiKey: string }> | null>(null);
366
- useEffect(() => {
367
- import("@commentkit/comment-kit/react").then((m) => setCmp(() => m.CommentKit));
368
- }, []);
369
- return Cmp ? <Cmp apiKey={apiKey} /> : null;
370
- }
57
+ <svelte:body use:commentkit={{ project: "pk_live_your_key" }} />
371
58
  ```
372
59
 
373
- ```astro
374
- ---
375
- // src/layouts/Layout.astro
376
- import CommentKitClient from "../components/CommentKitClient";
377
- ---
378
- <html lang="en">
379
- <body>
380
- <slot />
381
- <CommentKitClient client:only="react" apiKey="your-api-key" />
382
- </body>
383
- </html>
384
- ```
60
+ ### Anything else
385
61
 
386
- Or use vanilla JS in any `.astro` page:
62
+ Angular, Solid, Astro, Qwik, Remix, or a custom setup: call `init()` once in the browser. If you prefer markup, import the custom element once in your bundle and place the tag anywhere:
387
63
 
388
- ```html
389
- <script>
390
- import { CommentKit } from "@commentkit/comment-kit";
391
- new CommentKit({ apiKey: "your-api-key" });
392
- </script>
64
+ ```ts
65
+ import "@commentkit/comment-kit/element";
393
66
  ```
394
67
 
395
- **Vanilla JavaScript with a bundler**
396
-
397
- The following package import is resolved by a bundler such as Vite. A standalone HTML page needs a browser-ready bundle or an import map for the SDK and its peers; browsers do not resolve bare npm package names by themselves.
398
-
399
68
  ```html
400
- <!-- In a bundler-managed HTML entry, CommentKit mounts its widget on demand.
401
- Theme follows .dark class on <html> or system preference.
402
- Tooltips, dialogs, and panels are built-in. -->
403
- <script type="module">
404
- import { CommentKit } from "@commentkit/comment-kit";
405
-
406
- const ck = new CommentKit({
407
- apiKey: "your-api-key",
408
- // ui: { theme: "dark", position: "bottom-left" },
409
- });
410
- </script>
69
+ <comment-kit project="pk_live_your_key" branch="main"></comment-kit>
411
70
  ```
412
71
 
413
- ---
72
+ Find your key in the dashboard under **Project → Setup** (or run `npx @commentkit/cli init`), and add every website address there (live, staging, preview, e.g. `https://*.vercel.app`). Localhost always works for your team.
414
73
 
415
- ## Headless and Demo Entries
74
+ ## How it behaves
416
75
 
417
- Use the engine without the built-in widget or React dependencies:
76
+ | Where | Who sees the widget |
77
+ | --- | --- |
78
+ | `localhost`, `*.localhost`, `*.test` | Always visible, for your team |
79
+ | Live, staging and preview sites | Hidden from visitors. Shown when someone opens a review link (`?ck=…`), an email link, presses **Cmd/Ctrl + Shift + K**, or is already signed in on that device |
418
80
 
419
- ```ts
420
- import { CommentKitCore } from "@commentkit/comment-kit/headless";
81
+ People leave feedback with one tool:
421
82
 
422
- const core = new CommentKitCore({ apiKey: "your-api-key" });
423
- const unsubscribe = core.on("state:changed", (state) => {
424
- // Render state in your own interface.
425
- console.log(state.comments);
426
- });
83
+ - **Click** an element to comment on it.
84
+ - **Drag** to mark an area.
85
+ - **Select text first** to comment on exactly that text.
427
86
 
428
- // When your integration unmounts:
429
- // unsubscribe();
430
- // core.destroy();
431
- ```
87
+ A screenshot of the visible page is attached automatically with the pin drawn on it. Reviewers can draw on it (arrow, box, pen, blur to hide private details, text). Passwords, card fields, one-time codes and anything marked `data-commentkit-redact` are never captured.
432
88
 
433
- The headless entry exports the engine, API types, and helpers without widget mounting or `window.CommentKit` registration. Browser features such as element selection and screenshots still require a DOM.
89
+ Sign-in opens a small CommentKit window (or continues in the same tab inside in-app browsers like WhatsApp and Instagram). Credentials never touch your page.
434
90
 
435
- For a website's opt-in product sandbox, load the dedicated demo entry on demand:
91
+ ## Options
436
92
 
437
93
  ```ts
438
- // Inside your "Try the demo" click handler:
439
- const { createCommentKitDemo } = await import("@commentkit/comment-kit/demo");
440
- const demo = await createCommentKitDemo({ storageKey: "website-demo" });
441
- // demo.reset() starts a fresh sandbox; demo.destroy() removes it.
94
+ init({
95
+ project: "pk_live_…", // required
96
+ branch: "feature/checkout", // filter feedback per branch
97
+ commit: "a1b2c3d",
98
+ deploymentUrl: "https://pr-12.example.vercel.app",
99
+ hideOnProduction: true, // default; false shows the launcher to everyone
100
+ theme: "auto", // "light" | "dark" — default from the dashboard
101
+ position: "bottom-right",
102
+ redact: [".customer-email"], // extra selectors never captured
103
+ locale: "en",
104
+ auth: "auto", // "popup" | "redirect"
105
+ });
442
106
  ```
443
107
 
444
- The real widget uses a private browser store with a fixed 24-hour lifetime and a memory fallback when storage is unavailable. No project key, OTP, production API writes, uploads, or realtime connection is created. The demo UI needs React and ReactDOM. Its complete lifecycle and limits are in the included [private-demo guide](./docs/local-demo.md). The old root `createCommentKitDemo` export remains as a deprecated lazy compatibility wrapper.
445
-
446
- ## Member Invite Links
447
-
448
- Invite external collaborators by email — they verify via OTP before they can comment:
449
-
450
- 1. **Dashboard:** Enter the member's email and create an invite link
451
- 2. **Share:** Send the link (e.g. `https://yoursite.com?ck_invite=token`) to the member
452
- 3. **Verify:** When they visit, the SDK detects the invite token and prompts for their email
453
- 4. **OTP:** If the email matches the invite, an OTP is sent for verification
454
- 5. **Collaborate:** After verification, they're a full member and can comment
455
-
456
- The SDK auto-detects `?ck_invite=` from the URL — no code changes needed.
457
-
458
- ---
459
-
460
- ## Works With
461
-
462
- Every framework and meta-framework gets the full CommentKit UI — identical toolbar, sidebar, login, and comments panel rendered in Shadow DOM.
463
-
464
- **React family** — `@commentkit/comment-kit/react`
465
-
466
- | Framework / Tool | Notes |
467
- | ----------------------- | --------------------------------------------------------------------- |
468
- | React | Vite, CRA, esbuild, Rollup, Parcel, plain webpack — same import |
469
- | Next.js (App Router) | `<CommentKit>` is `"use client"` — works inside a server `layout.tsx` |
470
- | Next.js (Pages Router) | Mount once in `_app.tsx` |
471
- | Remix / React Router v7 | Mount in `root.tsx` |
472
- | Gatsby | Mount in `gatsby-browser.js` or any page |
473
- | RedwoodJS | Mount in `App.tsx` |
474
- | TanStack Start | Mount in `app/client.tsx` |
475
- | Vinxi | Same as TanStack Start |
476
- | Million.js | React-compatible; same import |
477
- | Blitz.js | Next.js underneath; same as Next |
478
- | Modern.js | React-based; same import |
479
- | Refine | React-based; mount alongside `<Refine>` |
480
- | Docusaurus | Drop into `swizzled` `Root` component |
481
- | Nextra | Drop into `theme.config.tsx` layout |
482
- | Laravel Inertia (React) | Mount in `app.tsx` |
483
-
484
- **Vue family** — `@commentkit/comment-kit/vue`
485
-
486
- | Framework / Tool | Notes |
487
- | --------------------- | ------------------------------------------------------------------ |
488
- | Vue 3 | Vite, CLI, esbuild, Rollup — same import |
489
- | Nuxt 3 / Nuxt 4 | Client-only — wrap in `<ClientOnly>` or check `import.meta.client` |
490
- | Quasar | Mount in `boot/commentkit.ts` |
491
- | VitePress / VuePress | Mount in `.vitepress/theme/index.ts` |
492
- | Vike-Vue | Mount in `_default.page.client.ts` |
493
- | Laravel Inertia (Vue) | Mount in `app.ts` |
494
-
495
- **Svelte family** — `@commentkit/comment-kit/svelte`
496
-
497
- | Framework / Tool | Notes |
498
- | ------------------------ | --------------------------------------------------------------------- |
499
- | Svelte 5 | Vite, esbuild — same import |
500
- | SvelteKit | Create the store in `onMount` and destroy it on cleanup (see snippet) |
501
- | Laravel Inertia (Svelte) | Mount in `app.ts` |
502
-
503
- **Angular family** — `@commentkit/comment-kit/angular`
504
-
505
- | Framework / Tool | Notes |
506
- | ------------------------ | -------------------------------------------------- |
507
- | Angular 17+ (standalone) | `provideCommentKit({ apiKey })` in `app.config.ts` |
508
- | Analog | Angular-based meta-framework; same provider |
509
- | Angular Universal | Provider is browser-only-safe (SSR-aware) |
510
-
511
- **Solid family** — `@commentkit/comment-kit/solid`
512
-
513
- | Framework / Tool | Notes |
514
- | ---------------- | ------------------------------------ |
515
- | Solid.js | Vite, esbuild — same import |
516
- | SolidStart | Use inside a `<ClientOnly>` boundary |
517
- | Vike-Solid | Same as SolidStart |
518
-
519
- **Qwik family** — `@commentkit/comment-kit/qwik`
520
-
521
- | Framework / Tool | Notes |
522
- | ---------------- | ----------------------------------------------------------------------- |
523
- | Qwik | Call `useCommentKit` inside `component$`; the hook owns client mounting |
524
- | QwikCity | Same; use in the root component or a shared layout |
525
-
526
- **Preact family** — `@commentkit/comment-kit/preact`
527
-
528
- | Framework / Tool | Notes |
529
- | ---------------- | ------------------------------ |
530
- | Preact | Vite, esbuild — same import |
531
- | Fresh (Deno) | Use in an `islands/` component |
532
-
533
- **Multi-framework / unified** — `@commentkit/comment-kit/react`, `@commentkit/comment-kit/vue`, `@commentkit/comment-kit/svelte`, `@commentkit/comment-kit/preact`, or `@commentkit/comment-kit/solid` depending on island
108
+ Most behaviour is set in the dashboard and applies instantly without a deploy: pausing feedback on all sites, theme, position, accent colour, privacy selectors, and console/network capture.
534
109
 
535
- | Framework / Tool | Notes |
536
- | ---------------------- | ------------------------------------------------------- |
537
- | Astro | Use any adapter under `client:only` matching the island |
538
- | Vike (multi-framework) | Pick adapter matching your selected framework |
110
+ ### Script-tag attributes
539
111
 
540
- **Vanilla / Web Components / HTML-first** — `@commentkit/comment-kit`
112
+ `data-project`, `data-branch`, `data-commit`, `data-auth`, `data-hide-on-production="false"`.
541
113
 
542
- | Framework / Tool | Notes |
543
- | -------------------------- | --------------------------------------------------------------------- |
544
- | Plain HTML (no framework) | Browser-ready bundle or import map, then `new CommentKit({ apiKey })` |
545
- | Web Components / Lit | Mount in `connectedCallback` of a host component |
546
- | Stencil | Mount in `componentDidLoad` |
547
- | Marko (eBay) | Mount in client init |
548
- | Alpine.js / Petite-Vue | `<script>` tag at end of `<body>` |
549
- | htmx | Same as plain HTML |
550
- | Stimulus / Hotwire (Rails) | Mount in a Stimulus controller's `connect()` |
551
- | Phoenix LiveView | Mount in a `hook.mounted()` |
552
- | Laravel Livewire | Mount in Livewire hook |
553
- | Laravel Filament | Drop the `<script>` into a custom page layout |
554
- | Mitosis | Mount in the compiled framework's init |
555
-
556
- **WebView / hybrid shells** — `@commentkit/comment-kit` (vanilla), works the same as a normal page
557
-
558
- | Shell | Notes |
559
- | ----------------- | ---------------------------------------------- |
560
- | Electron | Renderer process — like a normal Chromium page |
561
- | Tauri | Like a normal WebView |
562
- | Capacitor (Ionic) | Use inside the WebView; `html2canvas` works |
563
- | Cordova | Same as Capacitor |
564
- | Neutralinojs | Same |
565
-
566
- **Not supported** — these runtimes have no DOM, and CommentKit's UI is a Shadow DOM widget. Hosting it elsewhere is not on the roadmap.
567
-
568
- | Runtime | Why |
569
- | ------------------------ | ---------------------------------------------- |
570
- | React Native / Expo | No DOM; needs a separate native commenting SDK |
571
- | NativeScript | No DOM |
572
- | Ink (terminal UIs) | No DOM |
573
- | Server-only (Hono, etc.) | Server framework, not a client target |
574
-
575
- ---
576
-
577
- ## Keyboard Shortcuts
578
-
579
- | Shortcut | Action |
580
- | -------------------- | --------------------------------------------------------------------------------------------- |
581
- | Cmd/Ctrl + Shift + K | Toggle overlay |
582
- | C | Comment (pin) mode |
583
- | E | Element selector mode |
584
- | D | Drawing mode |
585
- | H | Highlight mode |
586
- | S | Screenshot mode |
587
- | Cmd/Ctrl + C | While in select mode: grab the hovered (or selected) element to the clipboard with screenshot |
588
- | Shift + click | While in select mode: add an element to the multi-select bucket |
589
- | Right-click | While in select mode: open context menu (grab, comment, copy selector, copy XPath, inspect) |
590
- | Long-press (touch) | While in select mode: open context menu on touch devices |
591
- | ? | Show shortcuts overlay |
592
- | Esc | Close / deselect / exit mode |
114
+ ## API
593
115
 
594
- > Tool shortcuts require authentication and a visible overlay or active tool, with no input focused. Cmd/Ctrl + Shift + K also opens sign-in before authentication. Cmd/Ctrl + C respects active text selections — system copy still wins when text is highlighted.
595
-
596
- ---
597
-
598
- ## Peer Dependencies
599
-
600
- | Package | Required | Min Version |
601
- | ----------------------------------- | ----------------------------------------------------------------------------- | ----------- |
602
- | `react` + `react-dom` | Built-in UI, including vanilla and non-React adapters | `>=18.0.0` |
603
- | `vue` | Only for Vue apps | `>=3.0.0` |
604
- | `svelte` | Only for Svelte apps | `>=4.0.0` |
605
- | `@angular/core` + `@angular/common` | Only for Angular apps | `>=17.0.0` |
606
- | `rxjs` | Only for Angular apps | `>=7.0.0` |
607
- | `solid-js` | Only for Solid.js apps | `>=1.0.0` |
608
- | `@builder.io/qwik` | Only for Qwik apps | `>=1.0.0` |
609
- | `preact` | Only for Preact apps | `>=10.0.0` |
610
- | `html2canvas` | For default screenshots; not needed with a custom `screenshotProvider` | `>=1.4.0` |
611
- | `pusher-js` | Bundled — no install needed (inlined into the SDK for real-time) | — |
612
- | `element-source` | Optional — enables file:line + component stack in agent context and dev grabs | `>=0.0.5` |
613
-
614
- **Migration note:** React and ReactDOM are now optional npm peers, so npm will not install them automatically for a new headless-only consumer. UI consumers must declare compatible versions of both explicitly. Headless imports from `@commentkit/comment-kit/headless` do not require either. The minimum UI peer version remains React 18; using a non-React adapter does not remove this UI runtime requirement.
615
-
616
- ## Agent Handoff
617
-
618
- CommentKit was designed for the loop where stakeholders leave feedback on a live site and developers feed that feedback — plus the elements behind it — straight into Claude Desktop, Cursor, Codex, Continue, Zed AI, or any clipboard-aware coding agent.
619
-
620
- There are three integration paths.
621
-
622
- ### 1. Element selector (toolbar)
623
-
624
- The toolbar's **Element** tool (`E`) lets anyone — stakeholder or developer — click a page element, write a short comment, and save. CommentKit persists a viewport position plus `position.element` and `position.xpath`. Anchored comments render a persistent outline that re-resolves on scroll, resize, and DOM mutations.
625
-
626
- ### 2. Dev grab (developer, local)
627
-
628
- In the same Element-tool composer, a **Grab for agent** button copies the selected element directly to the clipboard — no backend save. ⌘C / Ctrl+C on the hovered element does the same. The clipboard payload includes:
629
-
630
- - A Markdown summary with tag name, component name (when resolved), source file location (`file:line:col`), component stack, a bounded and redacted structural HTML snapshot, and the page URL.
631
- - An `image/png` clipboard MIME carrying the rendered element screenshot. Agents that accept image pastes (Claude Desktop, Cursor, Codex) drop both the text and the image in one paste.
116
+ `init()` returns an instance:
632
117
 
633
118
  ```ts
634
- const result = await commentKit.grabElement(document.querySelector("#checkout-btn")!);
635
- // result.markdown — Markdown payload now on the clipboard
636
- // result.screenshotDataUrl — base64 PNG, also attached to the clipboard
637
- // result.element.source — { filePath, lineNumber, columnNumber, componentName } when resolved
638
- ```
119
+ const kit = init({ project: "pk_live_…" });
639
120
 
640
- For multiple elements, hold Shift while clicking (or drag a marquee) and call:
641
-
642
- ```ts
643
- const bundle = await commentKit.grabElements([el1, el2, el3]);
644
- // bundle.markdown — single bundled payload, each entry with its own screenshot inlined as a data URL
121
+ kit.show(); // same as Cmd/Ctrl + Shift + K
122
+ kit.hide();
123
+ await kit.signIn(); // call from a click
124
+ await kit.signOut();
125
+ kit.session(); // { person, role, project, capabilities } | null
126
+ kit.on("thread:created", ({ thread }) => {});
127
+ kit.destroy(); // removes every trace from the page
645
128
  ```
646
129
 
647
- Source resolution kicks in when the optional `element-source` peer dep is installed. Without it, the output falls back to `selector` + `xpath`.
130
+ Events: `ready`, `session:change`, `thread:created`, `thread:updated`, `message:created`, `error`.
648
131
 
649
- ### 3. Bulk export of stakeholder comments (developer, local)
132
+ `@commentkit/comment-kit/headless` exports `CommentKitClient`, `createAnchor` and `resolveAnchor` for custom interfaces and browser extensions.
650
133
 
651
- The toolbar's **Dev export** button (visible only on localhost) opens a side panel listing loaded open stakeholder comments from production / staging / preview. Load additional pages in the comments panel before exporting a larger selection. Select N comments, click **Copy N for agent**, and the clipboard receives one bundled Markdown payload — each comment's content, replies, author, page URL, the stakeholder's screenshot, the element's resolved source location (looked up against the developer's local build), and the selector / XPath fallback.
134
+ ## AI agents
652
135
 
653
- ```ts
654
- await commentKit.copyAgentContext({
655
- includeResolved: false,
656
- currentPageOnly: true,
657
- });
136
+ The easiest way: add `https://commentkit.dev/mcp` as a remote MCP server in Claude, Cursor or VS Code and sign in. You choose the project and what the agent may do.
658
137
 
659
- const prompt = await commentKit.formatAgentContextAsync({ includeResolved: false });
138
+ ```sh
139
+ claude mcp add --transport http commentkit https://commentkit.dev/mcp
660
140
  ```
661
141
 
662
- ### MCP server
663
-
664
- The separate `comment-kit-mcp` companion implements `list_comments`, `get_comment`, and `search_comments` for MCP clients. It is installed independently from this browser SDK and requires a numeric project ID and dedicated 30-day read-only agent token from Project → Installation; public project keys and SDK login tokens are not accepted. See its [package guide](https://www.npmjs.com/package/comment-kit-mcp) for installation and local stdio configuration.
665
-
666
- Contributors with access to the private repository can follow the [MCP development guide](https://github.com/commentkit/comment-kit/blob/main/mcp/README.md). Clipboard-based agent handoff works directly from the SDK and does not require this companion.
667
-
668
- ---
142
+ Or run the server on your computer: create an agent token in **Project → Developers**, then add it to your agent:
669
143
 
670
- ## Configuration
671
-
672
- Most apps only need `apiKey`. Everything else is auto-configured.
673
-
674
- ```typescript
144
+ ```json
675
145
  {
676
- apiKey: "your-api-key", // required — from dashboard
677
- branch: "main", // optional — tag new feedback and filter this branch
678
- enabled: true, // optional — set false to disable completely
679
- screenshotProvider: async (el) => {...}, // optional — replaces html2canvas
680
- ui: {
681
- theme: "auto", // "light" | "dark" | "auto"
682
- position: "bottom-right", // "bottom-right" | "bottom-left" | "top-right" | "top-left"
683
- activation: {
684
- mode: "toggle", // "toggle" (default) | "hold"
685
- key: "Alt", // "Alt" | "Meta" | "Control" | "Shift" — used by hold mode
686
- },
687
- },
688
- realtime: { // optional — collaboration tuning
689
- cursors: true, // live peer cursors (default true; set false on high-concurrency projects)
690
- presence: true, // online-users list (default true)
691
- maxRenderedCursors: 24, // cap on distinct remote cursors rendered at once
692
- },
146
+ "mcpServers": {
147
+ "commentkit": {
148
+ "command": "npx",
149
+ "args": ["-y", "comment-kit-mcp"],
150
+ "env": { "COMMENT_KIT_PROJECT_ID": "123", "COMMENT_KIT_ACCESS_TOKEN": "…" }
151
+ }
152
+ }
693
153
  }
694
154
  ```
695
155
 
696
- ### Project context and branches
697
-
698
- After authentication, the SDK retrieves the actual team members, roles, storage usage and saved branches from the backend. The panel's **All** tab spans project pages; **Page** filters loaded threads to the current path. Use **Load more comments** to retrieve additional records. Shared links retrieve their target even when it is not in the first page.
699
-
700
- `core.setBranch("preview")` filters that branch and tags new comments. `core.setBranch(null)` shows all branches. `core.reloadProjectContext()` refreshes members and usage. These APIs require the backend upgrade described below; old untagged records stay visible under All branches. `core.reloadComments()` refreshes the first page of the active branch, while `loadMoreComments()` appends the next page.
701
-
702
- The production composer uploads files before saving, reuses completed uploads when a save is retried, and sends description, checklist, assignee, mention and device context with the record. Reply quotes and reactions persist on the corresponding message. `ReplyOptions`, `ReplyTarget`, `CommentCreateOptions`, `CommentDeviceInfo` and `ProjectContext` are available from the headless entry.
703
-
704
- ### Realtime at scale
705
-
706
- Live cursors are the one realtime feature whose cost grows with the number of
707
- simultaneous viewers — each client can receive up to _(online peers × ~30fps)_
708
- cursor events. The SDK bounds rendered cursor state and updates with three
709
- inbound limits (per-peer ~30fps throttle, a distinct-cursor cap, and a global
710
- per-second emit budget), and the online-users roster is capped at 500. For very
711
- high-concurrency projects where cursor sharing isn't worth the bandwidth, set
712
- `realtime.cursors: false` (stops outbound cursor whispers and drops inbound
713
- cursor events) and/or `realtime.presence: false`. Comment/reply/reaction
714
- broadcasts are unaffected by these knobs.
715
-
716
- To disable in production:
717
-
718
- ```tsx
719
- <CommentKit apiKey="your-api-key" enabled={process.env.NODE_ENV !== "production"} />
720
- ```
721
-
722
- ---
723
-
724
- ## Privacy & Security
725
-
726
- CommentKit is designed for production integration, but it runs with your page's JavaScript privileges. No embedded SDK can guarantee immunity from compromise. Review the [production host hardening guidance](./SECURITY.md#hardening-guidance-for-hosts), pin the reviewed package version, and verify your site's integration before enabling it for customers.
727
-
728
- | Concern | How CommentKit handles it |
729
- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
730
- | **No telemetry** | The SDK sends no analytics or tracking events. Submitted feedback includes its author, page, content, attachments and optional browser/OS/viewport context. |
731
- | **Network requests** | API calls use `api.commentkit.dev` by default or your configured `baseUrl`; realtime connects to the host returned by project configuration. Displayed attachments and avatars load their supplied URLs. Google Fonts is contacted only when you opt in via `ui.loadRemoteFonts: true`. |
732
- | **No install scripts** | This package declares no `preinstall`, `install` or `postinstall` hooks. Build and publication checks are separate maintainer scripts. |
733
- | **No dynamic code execution** | Zero `eval()`, `new Function()`, `innerHTML`, or `document.write`. |
734
- | **Shadow DOM isolation** | Widget styles are scoped inside Shadow DOM. Annotation, element capture and screenshots intentionally inspect the host page to attach feedback; host permissions and browser restrictions still apply. |
735
- | **Source maps disabled** | No `.map` files ship. No `sourceMappingURL` in built files. |
736
- | **OTP authentication** | All commenters verify via email OTP; accounts with two-factor authentication also confirm an authenticator or recovery code before a session is issued. No passwords stored. |
737
- | **Session persistence** | Sanctum Bearer token is kept in **sessionStorage** (tab-scoped) so in-tab refresh keeps auth and the offline queue can drain. Closing the tab clears the session; logout / auth-expiry also clear the offline queue. Prefer Bearer over `X-User-Email` (spoofable). |
738
- | **Origin allowlist** | Browser requests must match the project's `allowed_domains` (wildcards like `*.example.com` supported). Empty allowlists deny browser traffic unless the backend enables `COMMENTKIT_ALLOW_EMPTY_ALLOWED_DOMAINS`. Server/MCP clients may omit `Origin`. |
739
- | **Stored data** | Authenticated comments store author identity, feedback and submitted context. The SDK uses tab-scoped session storage and a bounded local retry queue; the private demo uses a separate expiring browser store. |
740
-
741
- The retry queue uses project-scoped `localStorage` and binds each mutation to its authenticated user. It can outlive a tab; replay requires the same user to sign in again. Logout and expired sessions clear it. Browser storage is best-effort, and raw file uploads are not persisted for offline replay. Observe offline events to distinguish queued feedback from feedback saved on the server.
742
-
743
- API requests send explicit SDK authentication headers, omit ambient host cookies and referrers, and reject redirects. Self-hosted integrations must configure the final HTTPS API endpoint directly. Browser project keys are public identifiers; never ship an admin token or a shared authenticated session in your website. All access decisions must remain on the backend.
744
-
745
- ### Backend API contract (SDK ↔ backend-v2)
746
-
747
- - Base path is `/api` (not `/api/v1`). Default host: `https://api.commentkit.dev/api`.
748
- - Auth: `X-API-Key` on every route; user identity via `Authorization: Bearer` (Sanctum ability `sdk`). Prefer Bearer over `X-User-Email` (only honored when `COMMENTKIT_ALLOW_EMAIL_AUTH=true`).
749
- - Attachments: upload drafts to `POST .../files`, then pass `attachment_ids` on comment/reply create or update. Direct uploads may target an authorized `comment_id` or `reply_id`. Unlinked drafts do not appear on comments.
750
- - MCP comment reads may use API key only when `COMMENTKIT_MACHINE_READ_ENABLED` is on; mutations still need Bearer.
751
- - Realtime: bind `comment_completed` separately from `comment_updated`.
752
-
753
- ### Backend upgrade order
754
-
755
- This release adds server-backed widget context, reply quotes/reactions, metadata and lifecycle timestamps. Customers using CommentKit’s hosted service only install the SDK after CommentKit has deployed its matching API. The following sequence is for operators of the backend-v2 deployment:
756
-
757
- 1. Prepare a database backup and the matching backend release. Apply its additive migrations with the backend release’s `php artisan migrate --force` command before routing traffic to new server code. Required migrations are `2026_10_16_105715_add_widget_context_to_comments_and_replies` and `2026_10_16_114945_add_status_timestamps_to_comments_table`.
758
- 2. Deploy that API, configure the project’s allowed domains, and verify OTP delivery, authenticated `/api/projects/{slug}/context`, comment/reply retrieval, attachments and realtime. Existing clients remain supported; historical lifecycle dates stay null.
759
- 3. Install the candidate SDK in staging. Verify create/reply/edit/reaction/resolve/reopen and reload against that deployed API with a dedicated test project. The private local demo does not exercise the API or migrations.
760
- 4. Release the website integration, then publish the new npm version only after the deployment checks and release approval. If the client must be rolled back, keep the additive schema in place; do not drop columns containing newly stored feedback.
761
-
762
- An older API’s missing context route is tolerated during a rolling upgrade, but that fallback does not provide the new persistent workflows. Do not treat a working local demo as proof that the production backend is ready.
763
-
764
- ### Screenshot redaction
765
-
766
- Built-in screenshots exclude password, hidden, payment-autocomplete and one-time-code fields. They also omit iframes; redaction of individual elements inside embedded documents is not supported. Mark other sensitive regions with `data-commentkit-redact`; the marker also excludes their content from element grabs and DOM context exports, including when an ancestor is selected. DOM exports omit form values and editable content, including directly selected descendants of those containers, as well as script/template/embedded-document contents, arbitrary data attributes, event handlers, and URL attributes while retaining structural context.
767
-
768
- A custom `screenshotProvider` is responsible for masking private descendants in its image. These controls do not detect secrets in ordinary text, page URLs, titles, selected text, or files users attach. Keep CommentKit off sensitive routes until their capture and data-sharing behavior has been reviewed.
156
+ Agents can list, search and read feedback and dashboard tasks (including the screenshot, by id or `CK-12`). With the permissions you choose, they can reply, link the commit and mark a task **ready for review**; by default a person approves each of these first (Agent requests). The reviewer then checks and resolves it. Agents never resolve, assign or delete. See [`mcp/README.md`](mcp/README.md).
769
157
 
770
- ### Backend identity contract
158
+ ## Terminal and build tools
771
159
 
772
- Your realtime channel-auth endpoint must derive user identity from the authenticated session token and ignore any client-supplied `user_id` / `user_name` / `user_email` parameters. Client-supplied identity is spoofable by anyone who can run JavaScript on the page — never trust it for presence, authorship, or channel authorization.
160
+ - [`@commentkit/cli`](cli/README.md): `commentkit login` (a short code confirmed in the browser), `init` (adds the key, the build plugin and `.gitignore` entry), `pull` (open feedback to `.commentkit/feedback.md` for any agent), `open CK-12`, and tokens for CI.
161
+ - [`@commentkit/build`](build/README.md): Vite, Next.js, webpack and Astro plugins that tag elements with their source file and line in development, and record the branch and commit. On localhost the widget then shows this branch's feedback first, with "All branches" one click away.
773
162
 
774
- ### Host-page XSS
163
+ ## Privacy and security
775
164
 
776
- The widget runs in the host page's JavaScript context. Shadow DOM isolates **styles**, not JS — an XSS vulnerability on the host page can access the widget's session, and a compromised trusted dependency can affect its host. Use a reviewed, pinned release, a strict script CSP, and SRI where applicable to external scripts. Test CSP compatibility in staging: the widget uses inline style elements and attributes, so a nonce-only style policy is not currently a verified integration. Never enable `unsafe-eval` or weaken script policy to fix widget styling.
165
+ - The project key (`pk_…`) only identifies a project. Everything is authorised on the server: the widget only works on the websites you list, sessions are bound to that website, and reviewers only see projects they were invited to.
166
+ - The widget runs in a Shadow DOM, adds one element to your page, needs no `unsafe-eval`, and removes itself completely on `destroy()`.
167
+ - Feedback text is rendered as plain text with safe links only. Agent output marks feedback as untrusted.
168
+ - See [SECURITY.md](SECURITY.md) for hardening guidance and how to report a vulnerability.
777
169
 
778
- ### Reporting vulnerabilities
170
+ ## Size
779
171
 
780
- See [SECURITY.md](./SECURITY.md) for how to report security issues and our supported-versions policy.
172
+ | Loaded | Gzip |
173
+ | --- | --- |
174
+ | Script-tag loader (every page) | ~0.6 KB |
175
+ | Widget when activated (incl. Preact) | ~31 KB |
176
+ | Screenshot engine (only while commenting) | ~51 KB |
177
+ | Realtime (signed-in people only) | ~21 KB |
781
178
 
782
- ---
179
+ ## Development
783
180
 
784
- ## Bundle Size
785
-
786
- The shared ESM build stores common engine, UI, and styles once across all framework adapters. A small activation shell loads first; the full widget and its styles load when a visible surface is requested. Drawing, screenshot selection/annotation, element grabs, developer export, and the image lightbox load when used. Access rules, restored sessions, invites, and explicit tool requests still determine when the UI appears.
787
-
788
- Measured from the current development build on 2026-10-16; KB below means 1,000 bytes:
789
-
790
- | Measurement | Before | Current |
791
- | ----------------------------------------------------- | -------: | -------: |
792
- | React initial SDK code, gzip | 262.8 KB | 42.2 KB |
793
- | React through first widget open, cumulative gzip | — | 306.3 KB |
794
- | React with every reachable optional chunk, gzip | 289.3 KB | 368.1 KB |
795
- | Compressed npm archive, all adapters and declarations | 2.33 MB | 432.9 KB |
796
-
797
- These are different measurements. Browser estimates sum each SDK chunk compressed with gzip level 9 and exclude React, ReactDOM, framework peers, `html2canvas`, and `element-source`. First-open size includes the initial code; it is not an additional 306.3 KB. The npm archive includes every adapter and is not a browser download. Host bundling, caching, and enabled realtime features affect actual requests. Archive size is approximate and changes with included documentation.
798
-
799
- The initial React load is smaller because work is deferred; the complete optional feature set has not been removed. All 46 retained primitive families remain available; the main product screens now use their audited compositions. Contributors with repository access can read the [full port audit](https://github.com/commentkit/comment-kit/blob/main/docs/ui-full-port-audit.md) and [performance baseline](https://github.com/commentkit/comment-kit/blob/main/docs/package-performance-audit.md) for verification, limitations and reproduction commands. `npm run build` enforces the package and load-stage size budgets.
800
-
801
- ---
802
-
803
- ## Tech Stack
804
-
805
- | Layer | Technology |
806
- | ------------- | --------------------------------------------------------------------------- |
807
- | Language | TypeScript (strict mode) |
808
- | UI Framework | React 18+ peers; developed with React 19 and Base UI 1.9 primitives |
809
- | CSS Isolation | Shadow DOM with scoped CSS custom properties |
810
- | Real-Time | Pusher.js / Laravel Reverb (WebSocket) |
811
- | Bundler | Vite+ (Rolldown) |
812
- | Testing | Vitest 5 with standard V8 coverage + Playwright browser and consumer checks |
813
- | Linting | OXC (oxlint) |
814
- | Formatting | OXC (oxfmt) |
815
-
816
- ---
817
-
818
- ## Browser Support
819
-
820
- Use current evergreen Chrome, Edge, Firefox or Safari. The UI requires Shadow DOM, Pointer Events and modern CSS color functions (`oklch` and `color-mix`). The browser test matrix targets current Playwright Chromium, Firefox and WebKit engines; older browser versions are not validated.
821
-
822
- The published package declares **Node.js >=18**. Developing or building this repository requires **Node.js 24.15+** for the current Vite+, TypeScript, and framework toolchain. That development requirement does not raise the React 18 UI peer minimum.
823
-
824
- ---
825
-
826
- ## Advanced Usage
827
-
828
- For custom integrations, events, selective subscriptions, and TypeScript types, see the [API Reference](./docs/api-reference.md).
829
-
830
- The repository is private. Contributors with access can run `npm run dev` and open `/design-system` to inspect all 46 internal primitive families in light/dark mode and RTL. The [development catalog guide](https://github.com/commentkit/comment-kit/blob/main/dev/README.md) explains its 111 examples and browser checks; the [primitive audit](https://github.com/commentkit/comment-kit/blob/main/docs/ui-primitive-parity-audit.md) records comparisons with the React reference. Open `/design-system/product` for the assembled panel, thread, composer, filters and settings with local fixture data and a simulated failed-save option. The [product audit](https://github.com/commentkit/comment-kit/blob/main/docs/ui-product-port-audit.md) records source comparisons and supported behavior. The gallery and its local fonts are development assets, excluded from the published package.
181
+ ```bash
182
+ npm ci
183
+ npm run typecheck
184
+ npm test # unit tests (Vitest)
185
+ npm run build # npm + CDN bundles, public types, size budgets
186
+ npm run test:e2e # Playwright: Chromium, Firefox, WebKit
187
+ ```
831
188
 
832
- ---
189
+ The architecture and roadmap live in [ARCHITECTURE-BLUEPRINT.md](ARCHITECTURE-BLUEPRINT.md) and [TASKS.md](TASKS.md).
833
190
 
834
191
  ## License
835
192
 
836
- CommentKit is proprietary software. See [LICENSE](./LICENSE) for details.
837
-
838
- ---
839
-
840
- ## Links
841
-
842
- - [Developer guide](https://commentkit.dev/developers)
843
- - [Sign in](https://commentkit.dev/auth/otp)
844
- - [Changelog](./CHANGELOG.md)
845
- - [GitHub (private contributor repository)](https://github.com/commentkit/comment-kit)
846
- - [npm](https://www.npmjs.com/package/@commentkit/comment-kit)
847
- - [Twitter / X](https://x.com/commentkit)
193
+ Proprietary. See [LICENSE](LICENSE).