@commentkit/comment-kit 2.0.0 → 2.0.1

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 (72) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +109 -13
  3. package/SECURITY.md +2 -2
  4. package/dist/node/cli/doctor.js +84 -20
  5. package/dist/node/cli/init.js +349 -35
  6. package/dist/node/cli/main.js +35 -17
  7. package/dist/node/cli/mcp.js +187 -6
  8. package/dist/node/shared/dashboard-places.js +33 -0
  9. package/dist/npm/chunks/{AgentSend-DxRJIYiz.js → AgentSend-DOy3jhyF.js} +16 -16
  10. package/dist/npm/chunks/{Checklist-CnlfeSbc.js → Checklist-CW_SwMpS.js} +70 -70
  11. package/dist/npm/chunks/{Composer-B1bBVszY.js → Composer-Bveq5QrK.js} +276 -274
  12. package/dist/npm/chunks/{Guest-vvNPz8h-.js → Guest-7hcN765o.js} +58 -55
  13. package/dist/npm/chunks/{MarkupEditor-VCOXh9d2.js → MarkupEditor-6bJGpWGO.js} +46 -39
  14. package/dist/npm/chunks/Panel-ChPUB68C.js +1211 -0
  15. package/dist/npm/chunks/{Settings-BGoZS2iV.js → Settings-CB5eEKnf.js} +77 -77
  16. package/dist/npm/chunks/{Shortcuts-B2OMvczr.js → Shortcuts-eAyjJ89P.js} +4 -4
  17. package/dist/npm/chunks/{StyleEditor-CJ_d8Huf.js → StyleEditor-CZTdAA5c.js} +10 -10
  18. package/dist/npm/chunks/{StylePanel-yQzHHlY7.js → StylePanel-B4pHQUL9.js} +61 -61
  19. package/dist/npm/chunks/{TaskFields-fmy6_HtK.js → TaskFields-C8BX0Sgg.js} +55 -55
  20. package/dist/npm/chunks/ThreadCard-B1EsX3PR.js +1160 -0
  21. package/dist/npm/chunks/Viewer-DY6zb90M.js +114 -0
  22. package/dist/npm/chunks/{agent-C1OQzBAm.js → agent-MTQHr9ei.js} +1 -1
  23. package/dist/npm/chunks/{ar-CAJ3XT8e.js → ar-L5cQ-NPe.js} +2 -0
  24. package/dist/npm/chunks/{card-bits-CAnzrqx3.js → card-bits-CTdrkYn8.js} +16 -16
  25. package/dist/npm/chunks/{client-kNAo2TTG.js → client-7eVxvg5j.js} +7 -7
  26. package/dist/npm/chunks/{confetti-CkBdSu19.js → confetti-BIs5s14P.js} +1 -1
  27. package/dist/npm/chunks/{context-B8UAzve0.js → context-Cf6khm7A.js} +1 -1
  28. package/dist/npm/chunks/{de-Dl18G48t.js → de-D0C-v6tP.js} +2 -0
  29. package/dist/npm/chunks/{dialog-GO04oC3D.js → dialog-DvdIkCW0.js} +1 -1
  30. package/dist/npm/chunks/{dpop-U48QIQd7.js → dpop-0A76OPa9.js} +1 -1
  31. package/dist/npm/chunks/{es-Dxk79lS9.js → es-Bw4Dj9tN.js} +2 -0
  32. package/dist/npm/chunks/{extension-CKFpPWmi.js → extension-DFVOvciD.js} +1 -1
  33. package/dist/npm/chunks/{extension-E81hWyiT.js → extension-SmoH5AA4.js} +2 -2
  34. package/dist/npm/chunks/{files-DyD5BZgp.js → files-4lV9YQIX.js} +2 -2
  35. package/dist/npm/chunks/{fr-8BebGKYD.js → fr-TkuQaIAa.js} +2 -0
  36. package/dist/npm/chunks/{hi-BIN6Yy_p.js → hi-DXSH2U8d.js} +2 -0
  37. package/dist/npm/chunks/{i18n-DOBt8e9U.js → i18n-aVSu9TcJ.js} +56 -47
  38. package/dist/npm/chunks/{identify-CN-3xzqL.js → identify-BGYh2dVo.js} +4 -4
  39. package/dist/npm/chunks/{it-Cr6EwpPQ.js → it-CiWA_bch.js} +2 -0
  40. package/dist/npm/chunks/{ja-Iy3s5aur.js → ja-C-QmR3yz.js} +2 -0
  41. package/dist/npm/chunks/{late-words-B2bmZceJ.js → late-words-80_VWt8S.js} +3 -1
  42. package/dist/npm/chunks/{live-CelVeZfP.js → live-BExWHzQ7.js} +1 -1
  43. package/dist/npm/chunks/{nl-B84WHqqe.js → nl-CEmZRqjX.js} +2 -0
  44. package/dist/npm/chunks/{page-key-DepmJzC1.js → page-key-HSY3Lze5.js} +1 -1
  45. package/dist/npm/chunks/{pick-yTyqtxN0.js → pick-B3sR7jtS.js} +1 -1
  46. package/dist/npm/chunks/{pkce-ChKGSW_4.js → pkce-CfZhiNBi.js} +1 -1
  47. package/dist/npm/chunks/{pt-BR-DOkdlfoe.js → pt-BR-b-a8sxO8.js} +2 -0
  48. package/dist/npm/chunks/{report-CrIqQZDI.js → report-DaVuoRYS.js} +1 -1
  49. package/dist/npm/chunks/show-BoN8AC-F.js +97 -0
  50. package/dist/npm/chunks/{signin-Dd1rb2BP.js → signin-BOWr_WCo.js} +3 -3
  51. package/dist/npm/chunks/{source-pXVve2Cx.js → source-mk3rGBBQ.js} +1 -1
  52. package/dist/npm/chunks/{src-BTMy4Gyc.js → src-C8rZFyL_.js} +77 -70
  53. package/dist/npm/chunks/start-CV4j78_q.js +1894 -0
  54. package/dist/npm/chunks/{states-sfTbjZz8.js → states-b9Bv3Ci7.js} +1 -1
  55. package/dist/npm/chunks/{upload-MgPYqPyE.js → upload-B2mkgMeJ.js} +1 -1
  56. package/dist/npm/chunks/uploads-8AxyRq7g.js +1147 -0
  57. package/dist/npm/chunks/{wrap-Bl0gbnFa.js → wrap-DW6EFbVQ.js} +1 -1
  58. package/dist/npm/chunks/{zh-CN-Z5fQCb7G.js → zh-CN-JTscW8u8.js} +2 -0
  59. package/dist/npm/element.js +1 -1
  60. package/dist/npm/headless.js +2 -2
  61. package/dist/npm/index.js +2 -2
  62. package/dist/npm/react.js +1 -1
  63. package/dist/npm/svelte.js +1 -1
  64. package/dist/npm/types/core/types.d.ts +2 -2
  65. package/dist/npm/vue.js +1 -1
  66. package/package.json +3 -1
  67. package/dist/npm/chunks/Panel-F37vIL1K.js +0 -1206
  68. package/dist/npm/chunks/ThreadCard-D51slKST.js +0 -1113
  69. package/dist/npm/chunks/Viewer-BOBadqmC.js +0 -111
  70. package/dist/npm/chunks/show-BgVC8gWY.js +0 -97
  71. package/dist/npm/chunks/start-DtVlpt7p.js +0 -1878
  72. package/dist/npm/chunks/uploads-D49mywwz.js +0 -1146
@@ -1,41 +1,58 @@
1
1
  // `npx @commentkit/comment-kit init`: find the framework, then add the key, the build plugin and the widget.
2
- import { existsSync, readFileSync } from "node:fs";
2
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
- import { dirname, join, resolve } from "node:path";
5
- function detect(dir) {
6
- let deps = {};
4
+ import { dirname, join, posix, resolve } from "node:path";
5
+ /** The Node versions the build plugins' source locations need (plugins/node-version.ts PLUGIN_NODE; a test keeps them equal). */
6
+ export const PLUGIN_NODE = "22.18 or 24.11";
7
+ export const PLUGIN_NODE_NOTE = `The build plugin's source locations need Node ${PLUGIN_NODE} or newer; on an older Node (a deploy server that builds, for example) it prints one warning and the build carries on without them.`;
8
+ function readJsonFile(file) {
7
9
  try {
8
- const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
9
- deps = { ...pkg.dependencies, ...pkg.devDependencies };
10
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
11
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
10
12
  }
11
13
  catch {
12
- // No package.json: a plain website.
14
+ return null;
13
15
  }
16
+ }
17
+ /** A Laravel app: `artisan` next to a composer.json that requires laravel/framework. */
18
+ export function isLaravel(dir) {
19
+ if (!existsSync(join(dir, "artisan")))
20
+ return false;
21
+ const composer = readJsonFile(join(dir, "composer.json"));
22
+ return Boolean(composer?.require?.["laravel/framework"] || composer?.["require-dev"]?.["laravel/framework"]);
23
+ }
24
+ function detect(dir) {
25
+ const pkg = readJsonFile(join(dir, "package.json"));
26
+ // No package.json: a plain website (or a Laravel app without a JavaScript build).
27
+ const deps = pkg ? { ...pkg.dependencies, ...pkg.devDependencies } : {};
14
28
  // React Router 7 (framework mode) and Remix build with Vite but render the page from app/root: not a plain Vite app.
15
29
  const reactRouter = deps["@react-router/dev"] || deps["@remix-run/dev"] || deps["@remix-run/react"];
16
- const framework = deps.next ? "next" : deps.astro ? "astro" : deps.nuxt ? "nuxt" : deps["@sveltejs/kit"] ? "sveltekit" : reactRouter ? "react-router" : deps.vite ? "vite" : "html";
30
+ // Laravel first: its apps also list vite, but keep their entries in resources/js and render pages from Blade.
31
+ const framework = isLaravel(dir) ? "laravel" : deps.next ? "next" : deps.astro ? "astro" : deps.nuxt ? "nuxt" : deps["@sveltejs/kit"] ? "sveltekit" : reactRouter ? "react-router" : deps.vite ? "vite" : "html";
17
32
  return { framework, packageManager: packageManagerFor(dir), deps };
18
33
  }
19
- const LOCKFILES = [["pnpm-lock.yaml", "pnpm"], ["pnpm-workspace.yaml", "pnpm"], ["yarn.lock", "yarn"], ["bun.lock", "bun"], ["bun.lockb", "bun"], ["package-lock.json", "npm"], ["npm-shrinkwrap.json", "npm"]];
34
+ /** Lockfiles decide first: a stray pnpm-workspace.yaml next to package-lock.json is not a pnpm project. */
35
+ const LOCKFILES = [["package-lock.json", "npm"], ["npm-shrinkwrap.json", "npm"], ["pnpm-lock.yaml", "pnpm"], ["yarn.lock", "yarn"], ["bun.lock", "bun"], ["bun.lockb", "bun"]];
36
+ /** Weaker hints, used only when a folder has neither a lockfile nor "packageManager". */
37
+ const HINTS = [["pnpm-workspace.yaml", "pnpm"], [".yarnrc.yml", "yarn"], ["bunfig.toml", "bun"]];
20
38
  /**
21
39
  * The package manager of the project, or of the workspace it belongs to: the nearest folder (this one or
22
- * a parent, up to the repository root or the home folder) that names one in package.json
23
- * ("packageManager": "pnpm@9…") or has its lockfile. npm when none does.
40
+ * a parent, up to the repository root or the home folder) that has a lockfile, names one in package.json
41
+ * ("packageManager": "pnpm@9…") or has another hint (pnpm-workspace.yaml). In each folder a lockfile wins;
42
+ * with lockfiles of two managers, "packageManager" breaks the tie. npm when nothing says.
24
43
  */
25
44
  export function packageManagerFor(dir, home = homedir()) {
26
45
  let current = resolve(dir);
27
46
  for (;;) {
28
- try {
29
- const declared = /^(npm|pnpm|yarn|bun)@/.exec(String(JSON.parse(readFileSync(join(current, "package.json"), "utf8")).packageManager ?? ""));
30
- if (declared)
31
- return declared[1];
32
- }
33
- catch {
34
- // No package.json here, or not JSON: look for a lockfile.
35
- }
36
- const lock = LOCKFILES.find(([file]) => existsSync(join(current, file)));
37
- if (lock)
38
- return lock[1];
47
+ const declared = /^(npm|pnpm|yarn|bun)@/.exec(String(readJsonFile(join(current, "package.json"))?.packageManager ?? ""))?.[1];
48
+ const locks = [...new Set(LOCKFILES.filter(([file]) => existsSync(join(current, file))).map(([, pm]) => pm))];
49
+ if (locks.length)
50
+ return declared && locks.includes(declared) ? declared : locks[0];
51
+ if (declared)
52
+ return declared;
53
+ const hint = HINTS.find(([file]) => existsSync(join(current, file)));
54
+ if (hint)
55
+ return hint[1];
39
56
  const parent = dirname(current);
40
57
  if (parent === current || current === resolve(home) || existsSync(join(current, ".git")))
41
58
  return "npm";
@@ -118,6 +135,10 @@ export function addToArray(source, key, call, importLine) {
118
135
  return null;
119
136
  const at = hits[0].index;
120
137
  const open = source.indexOf("[", at) + 1;
138
+ // A list written one item per line gets commentkit() on its own line, indented like the first item.
139
+ const lead = /^[ \t]*\r?\n[ \t]*(?=[^\s\]])/.exec(source.slice(open))?.[0];
140
+ if (lead)
141
+ return withImport(`${source.slice(0, open)}${lead}${call},${source.slice(open)}`, importLine);
121
142
  let out = `${source.slice(0, open)}${call}, ${source.slice(open).replace(/^\s*(?=\])/, "")}`;
122
143
  out = out.replace(new RegExp(`\\[${call.replace(/[()]/g, "\\$&")}, \\]`), `[${call}]`);
123
144
  return withImport(out, importLine);
@@ -147,6 +168,221 @@ function withImport(source, importLine) {
147
168
  }
148
169
  /** The widget is already set up in this file. */
149
170
  const HAS_WIDGET = /@commentkit\/comment-kit|commentkit\.dev\/cdn\/|loader\.js["'][^>]*data-project/;
171
+ /** The CDN script tag (any version folder), as a page or template writes it. */
172
+ const LOADER_TAG = /<script\b[^>]*\bsrc\s*=\s*["']?[^"'\s>]*\/cdn\/[^"'\s>/]+\/loader\.js[^>]*>/i;
173
+ const VITE_CONFIGS = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
174
+ const SCRIPT_FILE = /\.(?:[mc]?[jt]sx?)$/;
175
+ const LARAVEL_ENTRIES = ["resources/js/app.ts", "resources/js/app.tsx", "resources/js/app.js", "resources/js/app.jsx"];
176
+ /** The string literals between the bracket at `open` and the one that closes it. */
177
+ function literalsIn(source, mask, open) {
178
+ const close = source[open] === "[" || source[open] === "{" || source[open] === "(" ? closing(source, mask, open) : -1;
179
+ if (close < 0)
180
+ return [];
181
+ return [...source.slice(open, close).matchAll(/(["'`])((?:(?!\1)[^\\\n$])*)\1/g)].map((m) => m[2]);
182
+ }
183
+ /**
184
+ * Script entries a Vite config names: `input: "…"`, `input: [...]` or `input: { name: "…" }` (Rollup and
185
+ * laravel-vite-plugin), and laravel([...]) / laravel("…") shorthand. Stylesheets and other files are left out.
186
+ */
187
+ export function viteInputs(source) {
188
+ const mask = codeMask(source);
189
+ const found = [];
190
+ for (const m of source.matchAll(/\b(?:input\s*:|laravel\s*\()\s*/g)) {
191
+ if (!mask[m.index])
192
+ continue;
193
+ const at = m.index + m[0].length;
194
+ const c = source[at];
195
+ if (c === '"' || c === "'" || c === "`") {
196
+ const end = source.indexOf(c, at + 1);
197
+ if (end > at)
198
+ found.push(source.slice(at + 1, end));
199
+ }
200
+ else if (c === "[" || (c === "{" && m[0].startsWith("input"))) {
201
+ found.push(...literalsIn(source, mask, at));
202
+ }
203
+ }
204
+ return [...new Set(found.map((f) => f.replace(/^\.?\//, "")).filter((f) => SCRIPT_FILE.test(f) && !f.includes("..")))];
205
+ }
206
+ /** The script files a Vite config's `input` names that exist in `dir`. */
207
+ function viteConfigEntries(dir) {
208
+ const config = first(dir, VITE_CONFIGS);
209
+ if (!config)
210
+ return [];
211
+ return viteInputs(readFileSync(join(dir, config), "utf8")).filter((f) => existsSync(join(dir, f)));
212
+ }
213
+ /** Laravel's JavaScript entries: what vite.config's input names, then resources/js/app.{ts,tsx,js,jsx}. */
214
+ export function laravelEntries(dir) {
215
+ return [...new Set([...viteConfigEntries(dir), ...LARAVEL_ENTRIES.filter((f) => existsSync(join(dir, f)))])];
216
+ }
217
+ /** The import specifiers of a module (static imports, side-effect imports and import()). */
218
+ function importsOf(source) {
219
+ const mask = codeMask(source);
220
+ const found = [];
221
+ for (const m of source.matchAll(/\b(?:import|export)\s*(?:[\w*${}\s,]+?\s*from\s*)?(["'])([^"'\n]+)\1|\bimport\s*\(\s*(["'])([^"'\n]+)\3\s*\)/g)) {
222
+ if (mask[m.index])
223
+ found.push(m[2] ?? m[4]);
224
+ }
225
+ return found;
226
+ }
227
+ /** A relative or aliased import (`./x`, `@/x` and `~/x` meaning resources/js in Laravel) as a file in `dir`, or null. */
228
+ function resolveImport(dir, from, spec, laravel) {
229
+ let base;
230
+ if (spec.startsWith("./") || spec.startsWith("../"))
231
+ base = posix.join(posix.dirname(from), spec);
232
+ else if (laravel && /^[@~]\//.test(spec))
233
+ base = posix.join("resources/js", spec.slice(2));
234
+ else
235
+ return null;
236
+ if (base.startsWith(".."))
237
+ return null;
238
+ const candidates = [base, ...[".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts"].map((e) => base + e), ...["ts", "tsx", "js", "jsx"].map((e) => `${base}/index.${e}`)];
239
+ return candidates.find((f) => SCRIPT_FILE.test(f) && existsSync(join(dir, f)) && statSync(join(dir, f)).isFile()) ?? null;
240
+ }
241
+ const KEY_LITERAL = /\bpk_(?:live|test)_[a-z0-9]{20,40}\b/;
242
+ /** Is the widget set up in one of `entries`, or in a file one of them imports directly? */
243
+ export function widgetInEntries(dir, entries, laravel = false) {
244
+ const read = (file) => readFileSync(join(dir, file), "utf8");
245
+ const place = (file, text, via) => ({ file, ...(via ? { via } : {}), ...(KEY_LITERAL.test(text) ? { key: KEY_LITERAL.exec(text)[0] } : {}) });
246
+ for (const entry of entries) {
247
+ const text = read(entry);
248
+ if (HAS_WIDGET.test(text))
249
+ return place(entry, text);
250
+ }
251
+ for (const entry of entries) {
252
+ for (const spec of importsOf(read(entry))) {
253
+ const file = resolveImport(dir, entry, spec, laravel);
254
+ if (!file)
255
+ continue;
256
+ const text = read(file);
257
+ if (HAS_WIDGET.test(text))
258
+ return place(file, text, entry);
259
+ }
260
+ }
261
+ return null;
262
+ }
263
+ const MAX_TEMPLATES = 3000;
264
+ /** Blade templates under resources/views (at most 3000), as paths relative to `dir`. */
265
+ export function bladeFiles(dir) {
266
+ const out = [];
267
+ const walk = (rel) => {
268
+ let names;
269
+ try {
270
+ names = readdirSync(join(dir, rel)).sort();
271
+ }
272
+ catch {
273
+ return;
274
+ }
275
+ for (const name of names) {
276
+ if (out.length >= MAX_TEMPLATES)
277
+ return;
278
+ const path = `${rel}/${name}`;
279
+ let isDir = false;
280
+ try {
281
+ isDir = statSync(join(dir, path)).isDirectory();
282
+ }
283
+ catch {
284
+ continue;
285
+ }
286
+ if (isDir)
287
+ walk(path);
288
+ else if (name.endsWith(".blade.php"))
289
+ out.push(path);
290
+ }
291
+ };
292
+ walk("resources/views");
293
+ return out;
294
+ }
295
+ /** HTML pages served as they are from public/ (top level only). */
296
+ function publicHtml(dir) {
297
+ try {
298
+ return readdirSync(join(dir, "public")).filter((f) => f.endsWith(".html")).sort().map((f) => `public/${f}`);
299
+ }
300
+ catch {
301
+ return [];
302
+ }
303
+ }
304
+ /** Blade templates and public/*.html files that hold the CommentKit script tag. */
305
+ export function templatesWithTag(dir) {
306
+ const found = [];
307
+ for (const file of [...bladeFiles(dir), ...publicHtml(dir)]) {
308
+ const text = readFileSync(join(dir, file), "utf8");
309
+ const tag = LOADER_TAG.exec(text)?.[0];
310
+ if (!tag)
311
+ continue;
312
+ const key = /\bdata-project\s*=\s*["']?(pk_(?:live|test)_[a-z0-9]{20,40})\b/.exec(tag)?.[1] ?? /[?&]project=(pk_(?:live|test)_[a-z0-9]{20,40})\b/.exec(tag)?.[1];
313
+ found.push({ file, ...(key ? { key } : {}) });
314
+ }
315
+ return found;
316
+ }
317
+ /**
318
+ * Where the widget is set up, for the frameworks whose entry init can find more than one way: a Vite app's
319
+ * entry (index.html's module script or the config's `input`), a Laravel app's entries, a file one of them
320
+ * imports directly, or (Laravel) the script tag in a Blade layout or public/*.html. Null when none is found.
321
+ */
322
+ export function findWidget(dir, framework) {
323
+ if (framework === "laravel")
324
+ return widgetInEntries(dir, laravelEntries(dir), true) ?? templatesWithTag(dir)[0] ?? null;
325
+ if (framework === "vite")
326
+ return widgetInEntries(dir, viteEntries(dir));
327
+ return null;
328
+ }
329
+ /** A Vite app's entries: index.html's module script, the config's `input`, then src/main.* and src/index.*. */
330
+ function viteEntries(dir) {
331
+ const out = [];
332
+ if (existsSync(join(dir, "index.html"))) {
333
+ const src = /<script\b[^>]*\btype=["']module["'][^>]*\bsrc=["']\/?([^"'?#]+\.(?:[mc]?[jt]sx?))["']/i.exec(readFileSync(join(dir, "index.html"), "utf8"))?.[1];
334
+ if (src && !src.includes("..") && existsSync(join(dir, src)))
335
+ out.push(src);
336
+ }
337
+ out.push(...viteConfigEntries(dir));
338
+ out.push(...["src/main.ts", "src/main.tsx", "src/main.js", "src/main.jsx", "src/index.ts", "src/index.tsx", "src/index.js", "src/index.jsx"].filter((f) => existsSync(join(dir, f))));
339
+ return [...new Set(out)];
340
+ }
341
+ /** The quote character most of a file's imports use (Laravel's Prettier setup uses single quotes). */
342
+ function quoteOf(source) {
343
+ let single = (source.match(/\bfrom\s*'|\bimport\s*'/g) ?? []).length;
344
+ let double = (source.match(/\bfrom\s*"|\bimport\s*"/g) ?? []).length;
345
+ if (!single && !double) {
346
+ // No imports yet: the quotes the file's strings use.
347
+ single = (source.match(/'/g) ?? []).length;
348
+ double = (source.match(/"/g) ?? []).length;
349
+ }
350
+ return single > double ? "'" : '"';
351
+ }
352
+ /**
353
+ * Add CommentKit to a Laravel JavaScript entry: the import, then init() with the key as the default, so a
354
+ * server builds it without a new environment variable (VITE_COMMENTKIT_KEY still overrides it). `vite`
355
+ * false (Laravel Mix) has no import.meta.env, so the key is passed as it is.
356
+ */
357
+ export function laravelInit(source, key, vite = true) {
358
+ const q = quoteOf(source);
359
+ const mask = codeMask(source);
360
+ // A name `init` the file already has (its own function, another library's import) keeps its meaning.
361
+ const taken = [...source.matchAll(/\binit\b/g)].some((m) => mask[m.index]);
362
+ const name = taken ? "initCommentKit" : "init";
363
+ const semi = /;\s*$/m.test(source) || source.trim() === "" ? ";" : "";
364
+ const importLine = `import { ${taken ? "init as initCommentKit" : "init"} } from ${q}@commentkit/comment-kit${q}${semi}`;
365
+ const project = vite ? `import.meta.env.VITE_COMMENTKIT_KEY || ${q}${key}${q}` : `${q}${key}${q}`;
366
+ return `${withImport(source, importLine).replace(/\s*$/, "\n")}\n${name}({ project: ${project} })${semi}\n`;
367
+ }
368
+ /** `@vite(...)` directives in a template that list only stylesheets: those pages get no JavaScript entry. */
369
+ export function cssOnlyVite(text) {
370
+ const lists = [];
371
+ for (const m of text.matchAll(/@vite\s*\(([^)]*)\)/g)) {
372
+ const files = [...m[1].matchAll(/(["'])([^"'\n]+)\1/g)].map((f) => f[2]);
373
+ if (files.length && !files.some((f) => SCRIPT_FILE.test(f) || f.includes("{$")))
374
+ lists.push(files);
375
+ }
376
+ return lists;
377
+ }
378
+ /** Blade files that look like page layouts (they close </body>), mail, PDF and vendor templates left out. */
379
+ export function bladeLayouts(dir, files = bladeFiles(dir)) {
380
+ const skip = /\/(?:mail|emails?|pdfs?|vendor|notifications|errors)\//;
381
+ const layouts = files.filter((f) => !skip.test(f) && /<\/body>/i.test(readFileSync(join(dir, f), "utf8")));
382
+ const rank = (f) => (/\/layouts?\//.test(f) ? 0 : /\/(?:app|welcome)\.blade\.php$/.test(f) ? 1 : 2);
383
+ return layouts.sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
384
+ }
385
+ const loaderTag = (key) => `<script src="https://commentkit.dev/cdn/v1/loader.js" data-project="${key}" defer></script>`;
150
386
  /** Insert `markup` on its own line just before the last </body>, indented like the body's content. */
151
387
  function beforeBodyEnd(source, markup) {
152
388
  const at = source.lastIndexOf("</body>");
@@ -192,17 +428,25 @@ export function entryEdit(dir, framework, key, svelteMajor = 5) {
192
428
  });
193
429
  }
194
430
  case "vite": {
195
- let file = null;
196
- if (existsSync(join(dir, "index.html"))) {
197
- const src = /<script\b[^>]*\btype=["']module["'][^>]*\bsrc=["']\/?([^"'?#]+\.(?:[mc]?[jt]sx?))["']/i.exec(read("index.html"))?.[1];
198
- if (src && !src.includes("..") && existsSync(join(dir, src)))
199
- file = src;
200
- }
201
- file ??= first(dir, ["src/main.ts", "src/main.tsx", "src/main.js", "src/main.jsx", "src/index.ts", "src/index.tsx", "src/index.js", "src/index.jsx"]);
431
+ const entries = viteEntries(dir);
432
+ if (widgetInEntries(dir, entries))
433
+ return "done";
434
+ const file = entries[0];
202
435
  if (!file)
203
436
  return null;
204
437
  return edit(file, (s) => `${withImport(s, 'import { init } from "@commentkit/comment-kit";').replace(/\s*$/, "\n")}\ninit({ project: import.meta.env.VITE_COMMENTKIT_KEY });\n`);
205
438
  }
439
+ case "laravel": {
440
+ if (findWidget(dir, "laravel"))
441
+ return "done";
442
+ const entries = laravelEntries(dir);
443
+ // The app's main entry (loaded on every Inertia page and by most layouts), else the first script input.
444
+ const file = entries.find((f) => LARAVEL_ENTRIES.includes(f)) ?? entries[0];
445
+ if (!file)
446
+ return null;
447
+ const vite = Boolean(first(dir, VITE_CONFIGS)) || !existsSync(join(dir, "webpack.mix.js"));
448
+ return edit(file, (s) => laravelInit(s, key, vite));
449
+ }
206
450
  case "sveltekit": {
207
451
  const file = "src/routes/+layout.svelte";
208
452
  const use = "<svelte:body use:commentkit={{ project: import.meta.env.VITE_COMMENTKIT_KEY }} />";
@@ -293,13 +537,24 @@ export function wrapNextConfig(source) {
293
537
  }
294
538
  export function plan(dir, key) {
295
539
  const detected = detect(dir);
296
- return { ...basePlan(dir, key, detected), entry: entryEdit(dir, detected.framework, key, major(detected.deps.svelte) ?? 5) };
540
+ return { ...basePlan(dir, key, detected), entry: entryEdit(dir, detected.framework, key, major(detected.deps.svelte) ?? 5), widget: findWidget(dir, detected.framework) };
541
+ }
542
+ /** "resources/js/commentkit.ts, imported by resources/js/app.ts" */
543
+ export function describePlace(place) {
544
+ return place.via ? `${place.file}, imported by ${place.via}` : place.file;
297
545
  }
298
546
  const VITE_PLUGIN = 'import commentkit from "@commentkit/comment-kit/vite";\n // and in the config object: plugins: [commentkit(), ...your other plugins]';
547
+ /** vite-plus configs that build their plugin list in lazyPlugins(() => [...]): init does not edit inside the callback. */
548
+ const VITE_LAZY_PLUGIN = 'import commentkit from "@commentkit/comment-kit/vite";\n // and first in the list lazyPlugins returns: plugins: lazyPlugins(() => [commentkit(), ...your other plugins])';
549
+ /** What to add to a Vite config by hand, in the shape it has. */
550
+ export function vitePluginSnippet(source) {
551
+ return /\blazyPlugins\s*\(/.test(source) ? VITE_LAZY_PLUGIN : VITE_PLUGIN;
552
+ }
299
553
  function basePlan(dir, key, { framework, packageManager, deps }) {
300
554
  const add = packageManager === "npm" ? ["npm", "install"] : [packageManager, "add"];
301
555
  // One package: the widget and the build plugins (@commentkit/comment-kit/vite, /next, /astro).
302
- const install = framework === "html" ? [] : [[...add, "@commentkit/comment-kit"]];
556
+ // Nothing to install for a plain website, or when package.json already lists the package.
557
+ const install = framework === "html" || deps["@commentkit/comment-kit"] ? [] : [[...add, "@commentkit/comment-kit"]];
303
558
  const read = (file) => (file ? readFileSync(join(dir, file), "utf8") : "");
304
559
  switch (framework) {
305
560
  case "next": {
@@ -308,7 +563,7 @@ function basePlan(dir, key, { framework, packageManager, deps }) {
308
563
  framework, packageManager, label: "Next.js", envFile: ".env.local", envVar: "NEXT_PUBLIC_COMMENTKIT_KEY", configFile,
309
564
  configEdit: configFile ? wrapNextConfig(read(configFile)) : null,
310
565
  configSnippet: 'import { withCommentKit } from "@commentkit/comment-kit/next";\n // and wrap the default export: export default withCommentKit(nextConfig);',
311
- manual: configFile ? [] : ['Create next.config.mjs with: import { withCommentKit } from "@commentkit/comment-kit/next"; export default withCommentKit({});'],
566
+ notes: [], manual: configFile ? [] : ['Create next.config.mjs with: import { withCommentKit } from "@commentkit/comment-kit/next"; export default withCommentKit({});'],
312
567
  install,
313
568
  snippet: 'In app/layout.tsx:\n import { CommentKit } from "@commentkit/comment-kit/react";\n <CommentKit project={process.env.NEXT_PUBLIC_COMMENTKIT_KEY!} />',
314
569
  };
@@ -319,13 +574,14 @@ function basePlan(dir, key, { framework, packageManager, deps }) {
319
574
  framework, packageManager, label: "Astro", envFile: ".env", envVar: "PUBLIC_COMMENTKIT_KEY", configFile,
320
575
  configEdit: configFile ? addToArray(read(configFile), "integrations", "commentkit()", 'import commentkit from "@commentkit/comment-kit/astro";') : null,
321
576
  configSnippet: 'import commentkit from "@commentkit/comment-kit/astro";\n // and in defineConfig: integrations: [commentkit(), ...your other integrations]',
322
- manual: [], install,
577
+ manual: [], notes: [], install,
323
578
  snippet: 'In your base layout:\n <script>\n import { init } from "@commentkit/comment-kit";\n init({ project: import.meta.env.PUBLIC_COMMENTKIT_KEY });\n </script>',
324
579
  };
325
580
  }
326
581
  case "nuxt":
327
582
  return {
328
583
  framework, packageManager, label: "Nuxt", envFile: ".env", envVar: "NUXT_PUBLIC_COMMENTKIT_KEY", configFile: first(dir, ["nuxt.config.ts", "nuxt.config.js"]), configEdit: null, configSnippet: "",
584
+ notes: [],
329
585
  manual: [
330
586
  'In nuxt.config.ts add: import commentkit from "@commentkit/comment-kit/vite"; and vite: { plugins: [commentkit()] }',
331
587
  'In nuxt.config.ts also add: runtimeConfig: { public: { commentkitKey: "" } }',
@@ -345,19 +601,77 @@ function basePlan(dir, key, { framework, packageManager, deps }) {
345
601
  return {
346
602
  framework, packageManager, label: framework === "sveltekit" ? "SvelteKit" : framework === "react-router" ? (remix ? "Remix" : "React Router") : "Vite", envFile: ".env.local", envVar: "VITE_COMMENTKIT_KEY", configFile,
347
603
  configEdit: configFile ? addToArray(read(configFile), "plugins", "commentkit()", 'import commentkit from "@commentkit/comment-kit/vite";') : null,
348
- configSnippet: VITE_PLUGIN,
604
+ configSnippet: vitePluginSnippet(read(configFile)),
605
+ notes: [],
349
606
  manual: configFile || framework !== "react-router" ? [] : ['No vite.config found. If the app builds with Vite, add to its config: import commentkit from "@commentkit/comment-kit/vite"; and plugins: [commentkit(), ...]'],
350
607
  install,
351
608
  snippet: snippets[framework],
352
609
  };
353
610
  }
611
+ case "laravel":
612
+ return laravelPlan(dir, key, packageManager, deps, install);
354
613
  default:
355
614
  return {
356
- framework, packageManager, label: "a plain website", envFile: "", envVar: "", configFile: null, configEdit: null, configSnippet: "", manual: [], install: [],
615
+ framework, packageManager, label: "a plain website", envFile: "", envVar: "", configFile: null, configEdit: null, configSnippet: "", manual: [], notes: [], install: [],
357
616
  snippet: `Add before </body> on every page:\n <script src="https://commentkit.dev/cdn/v1/loader.js" data-project="${key}" defer></script>`,
358
617
  };
359
618
  }
360
619
  }
620
+ /** "Inertia React", "Livewire" or "Blade": what renders a Laravel app's pages. */
621
+ function laravelFlavour(dir, deps) {
622
+ if (deps["@inertiajs/react"])
623
+ return "Inertia React";
624
+ if (deps["@inertiajs/vue3"] || deps["@inertiajs/vue"])
625
+ return "Inertia Vue";
626
+ if (deps["@inertiajs/svelte"])
627
+ return "Inertia Svelte";
628
+ const composer = readJsonFile(join(dir, "composer.json"));
629
+ return composer?.require?.["livewire/livewire"] || composer?.require?.["livewire/flux"] ? "Livewire" : "Blade";
630
+ }
631
+ function laravelPlan(dir, key, packageManager, deps, install) {
632
+ const configFile = first(dir, VITE_CONFIGS);
633
+ const config = configFile ? readFileSync(join(dir, configFile), "utf8") : "";
634
+ const entries = laravelEntries(dir);
635
+ const entry = entries.find((f) => LARAVEL_ENTRIES.includes(f)) ?? entries[0] ?? null;
636
+ const templates = bladeFiles(dir);
637
+ const notes = [];
638
+ const manual = [];
639
+ const composer = readJsonFile(join(dir, "composer.json"));
640
+ const placed = findWidget(dir, "laravel");
641
+ if (entry && !placed) {
642
+ notes.push(`The key goes into ${entry} as the default value. Publishable keys are public by design, so it is safe to commit, and your server needs no new environment variable. To use another key in one place (pk_test_… on staging), set VITE_COMMENTKIT_KEY there before the build.`);
643
+ }
644
+ if (entry) {
645
+ // Layouts whose @vite(...) lists only stylesheets: their pages never load the entry, so the widget is not there.
646
+ for (const file of templates) {
647
+ for (const list of cssOnlyVite(readFileSync(join(dir, file), "utf8"))) {
648
+ const quoted = [...list, entry].map((f) => `'${f}'`).join(", ");
649
+ manual.push(`${file} loads only stylesheets with @vite, so its pages will not show the widget. To show it there, change that line to: @vite([${quoted}])`);
650
+ }
651
+ }
652
+ }
653
+ if (composer?.require?.["filament/filament"]) {
654
+ notes.push(`Filament admin panels do not load ${entry ?? "your app's JavaScript entry"}, so the widget does not show in them.`);
655
+ }
656
+ // No JavaScript entry at all: pages are plain Blade. init does not edit Blade; it prints the line and where it goes.
657
+ const layouts = bladeLayouts(dir, templates).slice(0, 5);
658
+ const where = layouts.length ? `\nLayouts that look like the place for it: ${layouts.join(", ")}` : "";
659
+ const snippet = entry
660
+ ? `In ${entry}:\n import { init } from "@commentkit/comment-kit";\n init({ project: import.meta.env.VITE_COMMENTKIT_KEY || "${key}" });`
661
+ : `Your pages load no JavaScript entry, so add the script tag before </body> in your layout (init does not edit Blade files):\n ${loaderTag(key)}${where}`;
662
+ return {
663
+ framework: "laravel", packageManager, label: `Laravel + ${laravelFlavour(dir, deps)}`,
664
+ // The key is written into the entry, not an env file: .env.local is git-ignored (a server that builds on deploy has none) and Laravel itself never reads it.
665
+ envFile: "", envVar: "VITE_COMMENTKIT_KEY",
666
+ configFile: entry ? configFile : null,
667
+ configEdit: entry && configFile ? addToArray(config, "plugins", "commentkit()", `import commentkit from ${quoteOf(config)}@commentkit/comment-kit/vite${quoteOf(config)};`) : null,
668
+ configSnippet: vitePluginSnippet(config),
669
+ manual, notes,
670
+ // Plain Blade pages use the script tag: nothing to install.
671
+ install: entry ? install : [],
672
+ snippet,
673
+ };
674
+ }
361
675
  /** Set KEY=value in an env file's text, replacing an existing line. */
362
676
  export function setEnv(text, name, value) {
363
677
  const line = `${name}=${value}`;
@@ -1,15 +1,16 @@
1
1
  // The `commentkit` command.
2
2
  import { spawn } from "node:child_process";
3
3
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
- import { dirname, join, resolve } from "node:path";
4
+ import { dirname, join, relative, resolve } from "node:path";
5
5
  import { createInterface } from "node:readline/promises";
6
6
  import { parseArgs } from "node:util";
7
7
  import { CliError, endpointFrom, pollDevice, Project, registerClient, SIGN_IN_AGAIN, startDevice } from "./api.js";
8
+ import { DASHBOARD } from "../shared/dashboard-places.js";
8
9
  import { forget, load, save } from "./credentials.js";
9
10
  import { doctor, render } from "./doctor.js";
10
11
  import { feedbackMarkdown } from "./format.js";
11
- import { ignoreFolder, plan, setEnv } from "./init.js";
12
- import { AGENTS, backup, configPath, DEFAULT_SCOPE, entry, mergeJson, mergeToml, NEXT_STEP, readIfExists, writeAtomic } from "./mcp.js";
12
+ import { describePlace, ignoreFolder, plan, PLUGIN_NODE_NOTE, setEnv } from "./init.js";
13
+ import { AGENTS, backup, configPath, DEFAULT_SCOPE, entry, gitPlace, mergeJson, mergeToml, NEXT_STEP, readIfExists, writeAtomic } from "./mcp.js";
13
14
  import { openUrl } from "./open.js";
14
15
  /** The publishable key format; a test keeps it equal to the pattern in contract/openapi-v1.yaml. */
15
16
  export const PUBLISHABLE_KEY = /^pk_(live|test)_[a-z0-9]{20,40}$/;
@@ -53,7 +54,7 @@ the project and what the CLI may do.
53
54
  logout: `Usage: npx @commentkit/comment-kit logout
54
55
 
55
56
  Forgets the sign-in on this computer. To end it on the server too, disconnect it in
56
- CommentKit under Settings > Sessions.`,
57
+ CommentKit, in Settings → Security, under Connected coding agents.`,
57
58
  status: `Usage: npx @commentkit/comment-kit status [--json]
58
59
 
59
60
  Which project you are signed in to, what the CLI may do, and whether agent changes wait
@@ -62,9 +63,10 @@ for a person's approval.
62
63
  --json Print JSON`,
63
64
  init: `Usage: npx @commentkit/comment-kit init [--yes] [--dry-run] [--install] [--key pk_…]
64
65
 
65
- Finds your framework (Next.js, Vite, SvelteKit, Astro, Nuxt or a plain website) and sets
66
- CommentKit up: the key in your env file, the build plugin in your config, .commentkit/ in
67
- .gitignore, and the widget in your layout or entry file. Asks before each change.
66
+ Finds your framework (Next.js, Vite, SvelteKit, Astro, Nuxt, Laravel or a plain website) and
67
+ sets CommentKit up: the key in your env file (Laravel: in the entry, as the default), the build
68
+ plugin in your config, .commentkit/ in .gitignore, and the widget in your layout or entry file.
69
+ Asks before each change.
68
70
 
69
71
  --yes, -y Make every change without asking
70
72
  --dry-run Show what would change, change nothing
@@ -105,8 +107,8 @@ Tokens for CI (COMMENTKIT_TOKEN), never with more permissions than your sign-in.
105
107
  mcp: `Usage: npx @commentkit/comment-kit mcp install <cursor|vscode|claude|codex> [--scope user|project] [--dry-run] [--yes]
106
108
 
107
109
  Adds the hosted CommentKit MCP server (https://commentkit.dev/mcp) to your coding agent's
108
- config file. Nothing else in the file changes, and it is backed up first. Your agent asks
109
- you to sign in the first time.
110
+ config file. Nothing else in the file changes (its indentation and last newline stay), and it
111
+ is backed up first. Your agent asks you to sign in the first time.
110
112
 
111
113
  cursor ~/.cursor/mcp.json (--scope project: .cursor/mcp.json)
112
114
  vscode .vscode/mcp.json (--scope user: your VS Code profile's mcp.json)
@@ -258,7 +260,7 @@ async function logout(out) {
258
260
  // CommentKit has no endpoint yet for a terminal sign-in to end itself, so this is local only.
259
261
  const had = await forget(endpointFrom());
260
262
  out.log(had
261
- ? "Signed out on this computer. The sign-in still works on the server until it expires (30 days unused); to end it now, disconnect it in CommentKit under Settings > Sessions."
263
+ ? `Signed out on this computer. The sign-in still works on the server until it expires (30 days unused); to end it now, disconnect it in CommentKit, in ${DASHBOARD.connectedAgents}.`
262
264
  : "You were not signed in.");
263
265
  return 0;
264
266
  }
@@ -308,7 +310,7 @@ async function init(args, out, cwd) {
308
310
  const info = await (await Project.connect()).request("");
309
311
  key = info.data.publishable_keys.live ?? info.data.publishable_keys.test ?? undefined;
310
312
  if (!key)
311
- throw new CliError("This project has no publishable key yet. Open Setup in CommentKit once, then try again.");
313
+ throw new CliError(`This website has no publishable key yet. In CommentKit, open ${DASHBOARD.install} and press Create the key, then try again.`);
312
314
  out.log(`Project: ${info.data.name}`);
313
315
  }
314
316
  if (!PUBLISHABLE_KEY.test(key))
@@ -321,7 +323,7 @@ async function init(args, out, cwd) {
321
323
  if (after === before)
322
324
  return;
323
325
  if (dryRun) {
324
- out.log(`Would ${before ? "change" : "create"} ${file}:\n${addedLines(before, after)}\n`);
326
+ out.log(`Would ${existsSync(join(cwd, file)) ? "change" : "create"} ${file}:\n${addedLines(before, after)}\n`);
325
327
  return;
326
328
  }
327
329
  if (await ask(question, yes)) {
@@ -332,17 +334,18 @@ async function init(args, out, cwd) {
332
334
  skipped++;
333
335
  };
334
336
  const readOr = (file) => (existsSync(join(cwd, file)) ? readFileSync(join(cwd, file), "utf8") : "");
335
- if (p.envVar) {
337
+ if (p.envVar && p.envFile) {
336
338
  const before = readOr(p.envFile);
337
339
  await change(p.envFile, before, setEnv(before, p.envVar, key), `Add ${p.envVar} to ${p.envFile}?`);
338
340
  }
339
341
  const ignoreBefore = readOr(".gitignore");
340
342
  await change(".gitignore", ignoreBefore, ignoreFolder(ignoreBefore), "Add .commentkit/ to .gitignore (pulled feedback stays on your computer)?");
343
+ const configBefore = p.configFile ? readOr(p.configFile) : "";
341
344
  if (p.configFile && p.configEdit) {
342
- await change(p.configFile, readOr(p.configFile), p.configEdit, `Add the CommentKit build plugin to ${p.configFile}?`);
345
+ await change(p.configFile, configBefore, p.configEdit, `Add the CommentKit build plugin to ${p.configFile}?`);
343
346
  }
344
347
  else if (p.configFile && !p.configEdit) {
345
- out.log(`Could not edit ${p.configFile} safely, so it was left as it is. Add the build plugin by hand:\n ${p.configSnippet}\n(more: https://commentkit.dev/docs/frameworks)`);
348
+ out.log(`Could not edit ${p.configFile} safely, so it was left as it is. Add the build plugin by hand:\n ${p.configSnippet}\n${PLUGIN_NODE_NOTE}\n(more: https://commentkit.dev/docs/frameworks)\n`);
346
349
  }
347
350
  if (p.entry && p.entry !== "done") {
348
351
  const { file, content, created } = p.entry;
@@ -350,6 +353,11 @@ async function init(args, out, cwd) {
350
353
  }
351
354
  for (const line of p.manual)
352
355
  out.log(`By hand: ${line}`);
356
+ for (const line of p.notes)
357
+ out.log(line);
358
+ // Laravel servers often build on deploy, with whatever Node they have.
359
+ if (p.framework === "laravel" && p.configFile && p.configEdit && p.configEdit !== configBefore)
360
+ out.log(PLUGIN_NODE_NOTE);
353
361
  if (p.install.length) {
354
362
  if (values.install && !dryRun) {
355
363
  for (const command of p.install) {
@@ -365,7 +373,7 @@ async function init(args, out, cwd) {
365
373
  }
366
374
  }
367
375
  if (p.entry === "done")
368
- out.log("\nThe widget is already in your app.");
376
+ out.log(`\nThe widget is already in your app${p.widget ? ` (${describePlace(p.widget)})` : ""}.`);
369
377
  else if (!p.entry)
370
378
  out.log(`\nLast step, show the widget. ${p.snippet}\n`);
371
379
  if (dryRun) {
@@ -410,8 +418,15 @@ async function mcp(args, out, cwd) {
410
418
  out.log(NEXT_STEP[target]);
411
419
  return 0;
412
420
  }
421
+ // A project file that git ignores stays on this computer: each developer adds it for themselves.
422
+ const ignored = scope === "project" ? gitPlace(file) : null;
423
+ const ignoredNote = ignored?.ignored
424
+ ? `Git ignores ${relative(cwd, file) || file}${ignored.rule ? ` (${ignored.rule})` : ""}, so this stays on this computer and is not shared through the repository: each developer who wants CommentKit in their agent runs npx @commentkit/comment-kit mcp install ${target} --scope project themselves.`
425
+ : null;
413
426
  if (values["dry-run"]) {
414
427
  out.log(`Would ${before === null ? "create" : merged.status === "replaced" ? "replace the commentkit entry in" : "add CommentKit to"} ${file}:\n${addedLines(before ?? "", merged.content)}`);
428
+ if (ignoredNote)
429
+ out.log(ignoredNote);
415
430
  out.log("\nRun it again without --dry-run to write it.");
416
431
  return 0;
417
432
  }
@@ -421,7 +436,10 @@ async function mcp(args, out, cwd) {
421
436
  }
422
437
  const copy = before !== null ? backup(file) : null;
423
438
  writeAtomic(file, merged.content);
424
- out.log(`${merged.status === "replaced" ? "Replaced" : "Added"} CommentKit (${url}) in ${file}.${copy ? ` Backup: ${copy}` : ""}`);
439
+ const away = copy && dirname(copy) !== dirname(file) ? " (kept outside the repository, so git does not pick it up)" : "";
440
+ out.log(`${merged.status === "replaced" ? "Replaced" : "Added"} CommentKit (${url}) in ${file}.${copy ? ` Backup: ${copy}${away}` : ""}`);
441
+ if (ignoredNote)
442
+ out.log(ignoredNote);
425
443
  out.log(NEXT_STEP[target]);
426
444
  return 0;
427
445
  }