@mushi-mushi/web 1.28.0 → 1.29.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/test-utils.ts"],"names":[],"mappings":";;;;;;;AAuDA,eAAsB,UAAA,CAAW,IAAA,GAA0B,EAAC,EAA2B;AAErF,EAAU,OAAO,IAAA;AAqBnB;AAOO,SAAS,WAAW,QAAA,EAAsC;AAE/D,EAAU;AAEZ;AAGO,SAAS,gBAAgB,QAAA,EAAsC;AAEtE;AAOA,eAAsB,gBAAA,CAAiB,OAAA,GAAkC,EAAC,EAAoC;AAC5G,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,GAAA;AACvC,EAAA,MAAM,OAAA,GAAU,KAAK,GAAA,EAAI;AACzB,EAAA,IAAI,eAAA,GAAiD,IAAA;AAErD,EAAA,OAAO,IAAA,CAAK,GAAA,EAAI,GAAI,OAAA,GAAU,SAAA,EAAW;AAQvC,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAC,MAAM,UAAA,CAAW,CAAA,EAAG,GAAG,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,SAAA,CAAU,eAAe,CAAC,CAAA,CAAE,CAAA;AACxF;AAOA,eAAsB,wBAAA,CAAyB,OAAA,GAG3C,EAAC,EAAkB;AAErB,EAAU;AAgBZ;AAOA,eAAsB,iBAAA,CAAkB,OAAA,GAAkC,EAAC,EAAoB;AAE7F,EAAU,OAAO,CAAA;AAenB","file":"test-utils.cjs","sourcesContent":["/**\n * @mushi-mushi/web/test-utils\n *\n * Playwright / jsdom helpers for deterministic SDK tests. This module is\n * published as a separate entry-point so production bundles never pay the\n * cost — import it via `import { triggerBug, openReport } from\n * '@mushi-mushi/web/test-utils'`.\n *\n * Design goals:\n * 1. Zero production footprint. Nothing here is imported from `./mushi`,\n * `./widget`, or any runtime module. We reach for the live SDK via\n * `Mushi.getInstance()` so the test process sees exactly what the app\n * bootstrapped — no duplicate SDK singletons, no double-init races.\n * 2. Safe in a test harness even when Mushi is disabled. Every helper\n * no-ops when `Mushi.getInstance()` returns `null`, so Playwright\n * specs that conditionally wire Mushi (e.g. cloud vs local targets)\n * don't have to branch.\n * 3. Flat surface. Tests want 3 verbs: \"open the widget\", \"submit a\n * report programmatically\", \"wait until the SDK confirms the POST\n * landed\". Anything beyond that belongs in the app under test.\n */\n\nimport { Mushi } from './mushi';\nimport type {\n MushiDiagnosticsResult,\n MushiReportCategory,\n MushiSDKInstance,\n} from '@mushi-mushi/core';\n\n/** Options accepted by `triggerBug`. Mirrors the core report contract but\n * keeps every field optional so a Playwright test can say\n * `triggerBug({ description: 'button dead' })` without a category. */\nexport interface TriggerBugOptions {\n /** Short free-text description of the issue. Defaults to a marker\n * string so tests that forget to pass a description still produce a\n * distinguishable report in the admin console. */\n description?: string;\n /** Severity-free category tag. */\n category?: MushiReportCategory;\n /** Arbitrary metadata the test wants to round-trip. Merged on top of\n * whatever `setMetadata` has already stored. */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Submit a report bypassing the widget UI. Returns the server-assigned\n * `reportId` when the POST lands, or `null` if Mushi isn't initialised in\n * this test context (or the submit failed — the SDK swallows network\n * errors silently by design).\n *\n * Use this from Playwright `page.evaluate(...)` calls to round-trip a\n * report into the backend without needing to drive the widget's DOM. It's\n * the fastest way to assert \"a bug report made it from the browser into\n * reports/ in Supabase\".\n */\nexport async function triggerBug(opts: TriggerBugOptions = {}): Promise<string | null> {\n const sdk = Mushi.getInstance();\n if (!sdk) return null;\n\n const description = opts.description\n ?? `[test-utils] triggerBug marker ${new Date().toISOString()}`;\n\n if (opts.metadata) {\n for (const [k, v] of Object.entries(opts.metadata)) {\n try { sdk.setMetadata(k, v); } catch { /* ignore */ }\n }\n }\n\n // `captureEvent` is the documented programmatic-submit API since 0.3.0\n // — it bypasses the widget, resolves with the server-assigned report\n // id, and participates in the same offline queue / pre-filter pipeline\n // as a widget submission.\n return await sdk.captureEvent({\n description,\n source: 'test-utils',\n ...(opts.category ? { category: opts.category } : {}),\n ...(opts.metadata ? { metadata: opts.metadata } : {}),\n });\n}\n\n/**\n * Programmatically open the Mushi widget without submitting anything. Use\n * for interaction tests that want to assert \"the widget is mounted and\n * reachable\" or to drive a user-like flow via Playwright selectors.\n */\nexport function openReport(category?: MushiReportCategory): void {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n sdk.report(category ? { category } : undefined);\n}\n\n/** Alias with language that reads better in Playwright smoke tests. */\nexport function openMushiWidget(category?: MushiReportCategory): void {\n openReport(category);\n}\n\n/**\n * Wait until the live SDK instance exists and reports a mounted widget.\n * Throws with the diagnostics payload so CI failures point at CSP / Shadow DOM\n * / capture setup instead of a generic timeout.\n */\nexport async function expectMushiReady(options: { timeoutMs?: number } = {}): Promise<MushiDiagnosticsResult> {\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n let lastDiagnostics: MushiDiagnosticsResult | null = null;\n\n while (Date.now() - started < timeoutMs) {\n const sdk = Mushi.getInstance();\n if (sdk) {\n lastDiagnostics = await sdk.diagnose();\n if (lastDiagnostics.widgetMounted && lastDiagnostics.shadowDomAvailable) {\n return lastDiagnostics;\n }\n }\n await new Promise((r) => setTimeout(r, 100));\n }\n\n throw new Error(`[mushi:test-utils] SDK not ready: ${JSON.stringify(lastDiagnostics)}`);\n}\n\n/**\n * Run an optional action and fail if the SDK fires an api_cascade proactive\n * prompt during the observation window. This catches the exact glot.it class\n * of bug where Mushi reports on its own runtime-config/report endpoints.\n */\nexport async function expectNoMushiSelfCascade(options: {\n timeoutMs?: number;\n action?: () => void | Promise<void>;\n} = {}): Promise<void> {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n const timeoutMs = options.timeoutMs ?? 1_000;\n let cascade: unknown = null;\n const unsubscribe = sdk.on('proactive:triggered', (event) => {\n const payload = event.data as { type?: string } | undefined;\n if (payload?.type === 'api_cascade') cascade = event.data ?? true;\n });\n try {\n await options.action?.();\n await new Promise((r) => setTimeout(r, timeoutMs));\n } finally {\n unsubscribe();\n }\n if (cascade) {\n throw new Error(`[mushi:test-utils] unexpected api_cascade from SDK self-noise: ${JSON.stringify(cascade)}`);\n }\n}\n\n/**\n * Wait until the offline queue drains — useful after `triggerBug` in tests\n * that submit while offline then assert the report eventually syncs.\n * Resolves with the number of queued items remaining (0 = fully drained).\n */\nexport async function waitForQueueDrain(options: { timeoutMs?: number } = {}): Promise<number> {\n const sdk = Mushi.getInstance();\n if (!sdk) return 0;\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n // The SDK instance doesn't publicly expose the queue, but `getQueueSize`\n // has been in the contract since 0.2.x. We tolerate its absence so\n // upgrading doesn't break tests that only need triggerBug/openReport.\n const getQueueSize = (sdk as MushiSDKInstance & { getQueueSize?: () => number }).getQueueSize;\n if (typeof getQueueSize !== 'function') return 0;\n\n while (Date.now() - started < timeoutMs) {\n const remaining = getQueueSize.call(sdk);\n if (remaining === 0) return 0;\n await new Promise((r) => setTimeout(r, 100));\n }\n return getQueueSize.call(sdk);\n}\n"]}
1
+ {"version":3,"sources":["../src/test-utils.ts"],"names":[],"mappings":";;;;;;;AAyDA,eAAsB,UAAA,CAAW,IAAA,GAA0B,EAAC,EAA2B;AAErF,EAAU,OAAO,IAAA;AAqBnB;AAOO,SAAS,WAAW,QAAA,EAAsC;AAE/D,EAAU;AAEZ;AAGO,SAAS,gBAAgB,QAAA,EAAsC;AAEtE;AAOA,eAAsB,gBAAA,CAAiB,OAAA,GAAkC,EAAC,EAAoC;AAC5G,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,GAAA;AACvC,EAAA,MAAM,OAAA,GAAU,KAAK,GAAA,EAAI;AACzB,EAAA,IAAI,eAAA,GAAiD,IAAA;AAErD,EAAA,OAAO,IAAA,CAAK,GAAA,EAAI,GAAI,OAAA,GAAU,SAAA,EAAW;AAQvC,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAC,MAAM,UAAA,CAAW,CAAA,EAAG,GAAG,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,SAAA,CAAU,eAAe,CAAC,CAAA,CAAE,CAAA;AACxF;AAOA,eAAsB,wBAAA,CAAyB,OAAA,GAG3C,EAAC,EAAkB;AAErB,EAAU;AAgBZ;AAOA,eAAsB,iBAAA,CAAkB,OAAA,GAAkC,EAAC,EAAoB;AAE7F,EAAU,OAAO,CAAA;AAenB","file":"test-utils.cjs","sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2024–2026 Kenji Sakuramoto (kensaurus) — Mushi Mushi\n/**\n * @mushi-mushi/web/test-utils\n *\n * Playwright / jsdom helpers for deterministic SDK tests. This module is\n * published as a separate entry-point so production bundles never pay the\n * cost — import it via `import { triggerBug, openReport } from\n * '@mushi-mushi/web/test-utils'`.\n *\n * Design goals:\n * 1. Zero production footprint. Nothing here is imported from `./mushi`,\n * `./widget`, or any runtime module. We reach for the live SDK via\n * `Mushi.getInstance()` so the test process sees exactly what the app\n * bootstrapped — no duplicate SDK singletons, no double-init races.\n * 2. Safe in a test harness even when Mushi is disabled. Every helper\n * no-ops when `Mushi.getInstance()` returns `null`, so Playwright\n * specs that conditionally wire Mushi (e.g. cloud vs local targets)\n * don't have to branch.\n * 3. Flat surface. Tests want 3 verbs: \"open the widget\", \"submit a\n * report programmatically\", \"wait until the SDK confirms the POST\n * landed\". Anything beyond that belongs in the app under test.\n */\n\nimport { Mushi } from './mushi';\nimport type {\n MushiDiagnosticsResult,\n MushiReportCategory,\n MushiSDKInstance,\n} from '@mushi-mushi/core';\n\n/** Options accepted by `triggerBug`. Mirrors the core report contract but\n * keeps every field optional so a Playwright test can say\n * `triggerBug({ description: 'button dead' })` without a category. */\nexport interface TriggerBugOptions {\n /** Short free-text description of the issue. Defaults to a marker\n * string so tests that forget to pass a description still produce a\n * distinguishable report in the admin console. */\n description?: string;\n /** Severity-free category tag. */\n category?: MushiReportCategory;\n /** Arbitrary metadata the test wants to round-trip. Merged on top of\n * whatever `setMetadata` has already stored. */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Submit a report bypassing the widget UI. Returns the server-assigned\n * `reportId` when the POST lands, or `null` if Mushi isn't initialised in\n * this test context (or the submit failed — the SDK swallows network\n * errors silently by design).\n *\n * Use this from Playwright `page.evaluate(...)` calls to round-trip a\n * report into the backend without needing to drive the widget's DOM. It's\n * the fastest way to assert \"a bug report made it from the browser into\n * reports/ in Supabase\".\n */\nexport async function triggerBug(opts: TriggerBugOptions = {}): Promise<string | null> {\n const sdk = Mushi.getInstance();\n if (!sdk) return null;\n\n const description = opts.description\n ?? `[test-utils] triggerBug marker ${new Date().toISOString()}`;\n\n if (opts.metadata) {\n for (const [k, v] of Object.entries(opts.metadata)) {\n try { sdk.setMetadata(k, v); } catch { /* ignore */ }\n }\n }\n\n // `captureEvent` is the documented programmatic-submit API since 0.3.0\n // — it bypasses the widget, resolves with the server-assigned report\n // id, and participates in the same offline queue / pre-filter pipeline\n // as a widget submission.\n return await sdk.captureEvent({\n description,\n source: 'test-utils',\n ...(opts.category ? { category: opts.category } : {}),\n ...(opts.metadata ? { metadata: opts.metadata } : {}),\n });\n}\n\n/**\n * Programmatically open the Mushi widget without submitting anything. Use\n * for interaction tests that want to assert \"the widget is mounted and\n * reachable\" or to drive a user-like flow via Playwright selectors.\n */\nexport function openReport(category?: MushiReportCategory): void {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n sdk.report(category ? { category } : undefined);\n}\n\n/** Alias with language that reads better in Playwright smoke tests. */\nexport function openMushiWidget(category?: MushiReportCategory): void {\n openReport(category);\n}\n\n/**\n * Wait until the live SDK instance exists and reports a mounted widget.\n * Throws with the diagnostics payload so CI failures point at CSP / Shadow DOM\n * / capture setup instead of a generic timeout.\n */\nexport async function expectMushiReady(options: { timeoutMs?: number } = {}): Promise<MushiDiagnosticsResult> {\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n let lastDiagnostics: MushiDiagnosticsResult | null = null;\n\n while (Date.now() - started < timeoutMs) {\n const sdk = Mushi.getInstance();\n if (sdk) {\n lastDiagnostics = await sdk.diagnose();\n if (lastDiagnostics.widgetMounted && lastDiagnostics.shadowDomAvailable) {\n return lastDiagnostics;\n }\n }\n await new Promise((r) => setTimeout(r, 100));\n }\n\n throw new Error(`[mushi:test-utils] SDK not ready: ${JSON.stringify(lastDiagnostics)}`);\n}\n\n/**\n * Run an optional action and fail if the SDK fires an api_cascade proactive\n * prompt during the observation window. This catches the exact glot.it class\n * of bug where Mushi reports on its own runtime-config/report endpoints.\n */\nexport async function expectNoMushiSelfCascade(options: {\n timeoutMs?: number;\n action?: () => void | Promise<void>;\n} = {}): Promise<void> {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n const timeoutMs = options.timeoutMs ?? 1_000;\n let cascade: unknown = null;\n const unsubscribe = sdk.on('proactive:triggered', (event) => {\n const payload = event.data as { type?: string } | undefined;\n if (payload?.type === 'api_cascade') cascade = event.data ?? true;\n });\n try {\n await options.action?.();\n await new Promise((r) => setTimeout(r, timeoutMs));\n } finally {\n unsubscribe();\n }\n if (cascade) {\n throw new Error(`[mushi:test-utils] unexpected api_cascade from SDK self-noise: ${JSON.stringify(cascade)}`);\n }\n}\n\n/**\n * Wait until the offline queue drains — useful after `triggerBug` in tests\n * that submit while offline then assert the report eventually syncs.\n * Resolves with the number of queued items remaining (0 = fully drained).\n */\nexport async function waitForQueueDrain(options: { timeoutMs?: number } = {}): Promise<number> {\n const sdk = Mushi.getInstance();\n if (!sdk) return 0;\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n // The SDK instance doesn't publicly expose the queue, but `getQueueSize`\n // has been in the contract since 0.2.x. We tolerate its absence so\n // upgrading doesn't break tests that only need triggerBug/openReport.\n const getQueueSize = (sdk as MushiSDKInstance & { getQueueSize?: () => number }).getQueueSize;\n if (typeof getQueueSize !== 'function') return 0;\n\n while (Date.now() - started < timeoutMs) {\n const remaining = getQueueSize.call(sdk);\n if (remaining === 0) return 0;\n await new Promise((r) => setTimeout(r, 100));\n }\n return getQueueSize.call(sdk);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/test-utils.ts"],"names":[],"mappings":";;;;;AAuDA,eAAsB,UAAA,CAAW,IAAA,GAA0B,EAAC,EAA2B;AAErF,EAAU,OAAO,IAAA;AAqBnB;AAOO,SAAS,WAAW,QAAA,EAAsC;AAE/D,EAAU;AAEZ;AAGO,SAAS,gBAAgB,QAAA,EAAsC;AAEtE;AAOA,eAAsB,gBAAA,CAAiB,OAAA,GAAkC,EAAC,EAAoC;AAC5G,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,GAAA;AACvC,EAAA,MAAM,OAAA,GAAU,KAAK,GAAA,EAAI;AACzB,EAAA,IAAI,eAAA,GAAiD,IAAA;AAErD,EAAA,OAAO,IAAA,CAAK,GAAA,EAAI,GAAI,OAAA,GAAU,SAAA,EAAW;AAQvC,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAC,MAAM,UAAA,CAAW,CAAA,EAAG,GAAG,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,SAAA,CAAU,eAAe,CAAC,CAAA,CAAE,CAAA;AACxF;AAOA,eAAsB,wBAAA,CAAyB,OAAA,GAG3C,EAAC,EAAkB;AAErB,EAAU;AAgBZ;AAOA,eAAsB,iBAAA,CAAkB,OAAA,GAAkC,EAAC,EAAoB;AAE7F,EAAU,OAAO,CAAA;AAenB","file":"test-utils.js","sourcesContent":["/**\n * @mushi-mushi/web/test-utils\n *\n * Playwright / jsdom helpers for deterministic SDK tests. This module is\n * published as a separate entry-point so production bundles never pay the\n * cost — import it via `import { triggerBug, openReport } from\n * '@mushi-mushi/web/test-utils'`.\n *\n * Design goals:\n * 1. Zero production footprint. Nothing here is imported from `./mushi`,\n * `./widget`, or any runtime module. We reach for the live SDK via\n * `Mushi.getInstance()` so the test process sees exactly what the app\n * bootstrapped — no duplicate SDK singletons, no double-init races.\n * 2. Safe in a test harness even when Mushi is disabled. Every helper\n * no-ops when `Mushi.getInstance()` returns `null`, so Playwright\n * specs that conditionally wire Mushi (e.g. cloud vs local targets)\n * don't have to branch.\n * 3. Flat surface. Tests want 3 verbs: \"open the widget\", \"submit a\n * report programmatically\", \"wait until the SDK confirms the POST\n * landed\". Anything beyond that belongs in the app under test.\n */\n\nimport { Mushi } from './mushi';\nimport type {\n MushiDiagnosticsResult,\n MushiReportCategory,\n MushiSDKInstance,\n} from '@mushi-mushi/core';\n\n/** Options accepted by `triggerBug`. Mirrors the core report contract but\n * keeps every field optional so a Playwright test can say\n * `triggerBug({ description: 'button dead' })` without a category. */\nexport interface TriggerBugOptions {\n /** Short free-text description of the issue. Defaults to a marker\n * string so tests that forget to pass a description still produce a\n * distinguishable report in the admin console. */\n description?: string;\n /** Severity-free category tag. */\n category?: MushiReportCategory;\n /** Arbitrary metadata the test wants to round-trip. Merged on top of\n * whatever `setMetadata` has already stored. */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Submit a report bypassing the widget UI. Returns the server-assigned\n * `reportId` when the POST lands, or `null` if Mushi isn't initialised in\n * this test context (or the submit failed — the SDK swallows network\n * errors silently by design).\n *\n * Use this from Playwright `page.evaluate(...)` calls to round-trip a\n * report into the backend without needing to drive the widget's DOM. It's\n * the fastest way to assert \"a bug report made it from the browser into\n * reports/ in Supabase\".\n */\nexport async function triggerBug(opts: TriggerBugOptions = {}): Promise<string | null> {\n const sdk = Mushi.getInstance();\n if (!sdk) return null;\n\n const description = opts.description\n ?? `[test-utils] triggerBug marker ${new Date().toISOString()}`;\n\n if (opts.metadata) {\n for (const [k, v] of Object.entries(opts.metadata)) {\n try { sdk.setMetadata(k, v); } catch { /* ignore */ }\n }\n }\n\n // `captureEvent` is the documented programmatic-submit API since 0.3.0\n // — it bypasses the widget, resolves with the server-assigned report\n // id, and participates in the same offline queue / pre-filter pipeline\n // as a widget submission.\n return await sdk.captureEvent({\n description,\n source: 'test-utils',\n ...(opts.category ? { category: opts.category } : {}),\n ...(opts.metadata ? { metadata: opts.metadata } : {}),\n });\n}\n\n/**\n * Programmatically open the Mushi widget without submitting anything. Use\n * for interaction tests that want to assert \"the widget is mounted and\n * reachable\" or to drive a user-like flow via Playwright selectors.\n */\nexport function openReport(category?: MushiReportCategory): void {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n sdk.report(category ? { category } : undefined);\n}\n\n/** Alias with language that reads better in Playwright smoke tests. */\nexport function openMushiWidget(category?: MushiReportCategory): void {\n openReport(category);\n}\n\n/**\n * Wait until the live SDK instance exists and reports a mounted widget.\n * Throws with the diagnostics payload so CI failures point at CSP / Shadow DOM\n * / capture setup instead of a generic timeout.\n */\nexport async function expectMushiReady(options: { timeoutMs?: number } = {}): Promise<MushiDiagnosticsResult> {\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n let lastDiagnostics: MushiDiagnosticsResult | null = null;\n\n while (Date.now() - started < timeoutMs) {\n const sdk = Mushi.getInstance();\n if (sdk) {\n lastDiagnostics = await sdk.diagnose();\n if (lastDiagnostics.widgetMounted && lastDiagnostics.shadowDomAvailable) {\n return lastDiagnostics;\n }\n }\n await new Promise((r) => setTimeout(r, 100));\n }\n\n throw new Error(`[mushi:test-utils] SDK not ready: ${JSON.stringify(lastDiagnostics)}`);\n}\n\n/**\n * Run an optional action and fail if the SDK fires an api_cascade proactive\n * prompt during the observation window. This catches the exact glot.it class\n * of bug where Mushi reports on its own runtime-config/report endpoints.\n */\nexport async function expectNoMushiSelfCascade(options: {\n timeoutMs?: number;\n action?: () => void | Promise<void>;\n} = {}): Promise<void> {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n const timeoutMs = options.timeoutMs ?? 1_000;\n let cascade: unknown = null;\n const unsubscribe = sdk.on('proactive:triggered', (event) => {\n const payload = event.data as { type?: string } | undefined;\n if (payload?.type === 'api_cascade') cascade = event.data ?? true;\n });\n try {\n await options.action?.();\n await new Promise((r) => setTimeout(r, timeoutMs));\n } finally {\n unsubscribe();\n }\n if (cascade) {\n throw new Error(`[mushi:test-utils] unexpected api_cascade from SDK self-noise: ${JSON.stringify(cascade)}`);\n }\n}\n\n/**\n * Wait until the offline queue drains — useful after `triggerBug` in tests\n * that submit while offline then assert the report eventually syncs.\n * Resolves with the number of queued items remaining (0 = fully drained).\n */\nexport async function waitForQueueDrain(options: { timeoutMs?: number } = {}): Promise<number> {\n const sdk = Mushi.getInstance();\n if (!sdk) return 0;\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n // The SDK instance doesn't publicly expose the queue, but `getQueueSize`\n // has been in the contract since 0.2.x. We tolerate its absence so\n // upgrading doesn't break tests that only need triggerBug/openReport.\n const getQueueSize = (sdk as MushiSDKInstance & { getQueueSize?: () => number }).getQueueSize;\n if (typeof getQueueSize !== 'function') return 0;\n\n while (Date.now() - started < timeoutMs) {\n const remaining = getQueueSize.call(sdk);\n if (remaining === 0) return 0;\n await new Promise((r) => setTimeout(r, 100));\n }\n return getQueueSize.call(sdk);\n}\n"]}
1
+ {"version":3,"sources":["../src/test-utils.ts"],"names":[],"mappings":";;;;;AAyDA,eAAsB,UAAA,CAAW,IAAA,GAA0B,EAAC,EAA2B;AAErF,EAAU,OAAO,IAAA;AAqBnB;AAOO,SAAS,WAAW,QAAA,EAAsC;AAE/D,EAAU;AAEZ;AAGO,SAAS,gBAAgB,QAAA,EAAsC;AAEtE;AAOA,eAAsB,gBAAA,CAAiB,OAAA,GAAkC,EAAC,EAAoC;AAC5G,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,GAAA;AACvC,EAAA,MAAM,OAAA,GAAU,KAAK,GAAA,EAAI;AACzB,EAAA,IAAI,eAAA,GAAiD,IAAA;AAErD,EAAA,OAAO,IAAA,CAAK,GAAA,EAAI,GAAI,OAAA,GAAU,SAAA,EAAW;AAQvC,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAC,MAAM,UAAA,CAAW,CAAA,EAAG,GAAG,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,SAAA,CAAU,eAAe,CAAC,CAAA,CAAE,CAAA;AACxF;AAOA,eAAsB,wBAAA,CAAyB,OAAA,GAG3C,EAAC,EAAkB;AAErB,EAAU;AAgBZ;AAOA,eAAsB,iBAAA,CAAkB,OAAA,GAAkC,EAAC,EAAoB;AAE7F,EAAU,OAAO,CAAA;AAenB","file":"test-utils.js","sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2024–2026 Kenji Sakuramoto (kensaurus) — Mushi Mushi\n/**\n * @mushi-mushi/web/test-utils\n *\n * Playwright / jsdom helpers for deterministic SDK tests. This module is\n * published as a separate entry-point so production bundles never pay the\n * cost — import it via `import { triggerBug, openReport } from\n * '@mushi-mushi/web/test-utils'`.\n *\n * Design goals:\n * 1. Zero production footprint. Nothing here is imported from `./mushi`,\n * `./widget`, or any runtime module. We reach for the live SDK via\n * `Mushi.getInstance()` so the test process sees exactly what the app\n * bootstrapped — no duplicate SDK singletons, no double-init races.\n * 2. Safe in a test harness even when Mushi is disabled. Every helper\n * no-ops when `Mushi.getInstance()` returns `null`, so Playwright\n * specs that conditionally wire Mushi (e.g. cloud vs local targets)\n * don't have to branch.\n * 3. Flat surface. Tests want 3 verbs: \"open the widget\", \"submit a\n * report programmatically\", \"wait until the SDK confirms the POST\n * landed\". Anything beyond that belongs in the app under test.\n */\n\nimport { Mushi } from './mushi';\nimport type {\n MushiDiagnosticsResult,\n MushiReportCategory,\n MushiSDKInstance,\n} from '@mushi-mushi/core';\n\n/** Options accepted by `triggerBug`. Mirrors the core report contract but\n * keeps every field optional so a Playwright test can say\n * `triggerBug({ description: 'button dead' })` without a category. */\nexport interface TriggerBugOptions {\n /** Short free-text description of the issue. Defaults to a marker\n * string so tests that forget to pass a description still produce a\n * distinguishable report in the admin console. */\n description?: string;\n /** Severity-free category tag. */\n category?: MushiReportCategory;\n /** Arbitrary metadata the test wants to round-trip. Merged on top of\n * whatever `setMetadata` has already stored. */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Submit a report bypassing the widget UI. Returns the server-assigned\n * `reportId` when the POST lands, or `null` if Mushi isn't initialised in\n * this test context (or the submit failed — the SDK swallows network\n * errors silently by design).\n *\n * Use this from Playwright `page.evaluate(...)` calls to round-trip a\n * report into the backend without needing to drive the widget's DOM. It's\n * the fastest way to assert \"a bug report made it from the browser into\n * reports/ in Supabase\".\n */\nexport async function triggerBug(opts: TriggerBugOptions = {}): Promise<string | null> {\n const sdk = Mushi.getInstance();\n if (!sdk) return null;\n\n const description = opts.description\n ?? `[test-utils] triggerBug marker ${new Date().toISOString()}`;\n\n if (opts.metadata) {\n for (const [k, v] of Object.entries(opts.metadata)) {\n try { sdk.setMetadata(k, v); } catch { /* ignore */ }\n }\n }\n\n // `captureEvent` is the documented programmatic-submit API since 0.3.0\n // — it bypasses the widget, resolves with the server-assigned report\n // id, and participates in the same offline queue / pre-filter pipeline\n // as a widget submission.\n return await sdk.captureEvent({\n description,\n source: 'test-utils',\n ...(opts.category ? { category: opts.category } : {}),\n ...(opts.metadata ? { metadata: opts.metadata } : {}),\n });\n}\n\n/**\n * Programmatically open the Mushi widget without submitting anything. Use\n * for interaction tests that want to assert \"the widget is mounted and\n * reachable\" or to drive a user-like flow via Playwright selectors.\n */\nexport function openReport(category?: MushiReportCategory): void {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n sdk.report(category ? { category } : undefined);\n}\n\n/** Alias with language that reads better in Playwright smoke tests. */\nexport function openMushiWidget(category?: MushiReportCategory): void {\n openReport(category);\n}\n\n/**\n * Wait until the live SDK instance exists and reports a mounted widget.\n * Throws with the diagnostics payload so CI failures point at CSP / Shadow DOM\n * / capture setup instead of a generic timeout.\n */\nexport async function expectMushiReady(options: { timeoutMs?: number } = {}): Promise<MushiDiagnosticsResult> {\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n let lastDiagnostics: MushiDiagnosticsResult | null = null;\n\n while (Date.now() - started < timeoutMs) {\n const sdk = Mushi.getInstance();\n if (sdk) {\n lastDiagnostics = await sdk.diagnose();\n if (lastDiagnostics.widgetMounted && lastDiagnostics.shadowDomAvailable) {\n return lastDiagnostics;\n }\n }\n await new Promise((r) => setTimeout(r, 100));\n }\n\n throw new Error(`[mushi:test-utils] SDK not ready: ${JSON.stringify(lastDiagnostics)}`);\n}\n\n/**\n * Run an optional action and fail if the SDK fires an api_cascade proactive\n * prompt during the observation window. This catches the exact glot.it class\n * of bug where Mushi reports on its own runtime-config/report endpoints.\n */\nexport async function expectNoMushiSelfCascade(options: {\n timeoutMs?: number;\n action?: () => void | Promise<void>;\n} = {}): Promise<void> {\n const sdk = Mushi.getInstance();\n if (!sdk) return;\n const timeoutMs = options.timeoutMs ?? 1_000;\n let cascade: unknown = null;\n const unsubscribe = sdk.on('proactive:triggered', (event) => {\n const payload = event.data as { type?: string } | undefined;\n if (payload?.type === 'api_cascade') cascade = event.data ?? true;\n });\n try {\n await options.action?.();\n await new Promise((r) => setTimeout(r, timeoutMs));\n } finally {\n unsubscribe();\n }\n if (cascade) {\n throw new Error(`[mushi:test-utils] unexpected api_cascade from SDK self-noise: ${JSON.stringify(cascade)}`);\n }\n}\n\n/**\n * Wait until the offline queue drains — useful after `triggerBug` in tests\n * that submit while offline then assert the report eventually syncs.\n * Resolves with the number of queued items remaining (0 = fully drained).\n */\nexport async function waitForQueueDrain(options: { timeoutMs?: number } = {}): Promise<number> {\n const sdk = Mushi.getInstance();\n if (!sdk) return 0;\n const timeoutMs = options.timeoutMs ?? 5_000;\n const started = Date.now();\n // The SDK instance doesn't publicly expose the queue, but `getQueueSize`\n // has been in the contract since 0.2.x. We tolerate its absence so\n // upgrading doesn't break tests that only need triggerBug/openReport.\n const getQueueSize = (sdk as MushiSDKInstance & { getQueueSize?: () => number }).getQueueSize;\n if (typeof getQueueSize !== 'function') return 0;\n\n while (Date.now() - started < timeoutMs) {\n const remaining = getQueueSize.call(sdk);\n if (remaining === 0) return 0;\n await new Promise((r) => setTimeout(r, 100));\n }\n return getQueueSize.call(sdk);\n}\n"]}
package/package.json CHANGED
@@ -1,46 +1,86 @@
1
1
  {
2
2
  "name": "@mushi-mushi/web",
3
- "version": "1.28.0",
4
- "description": "Mushi Mushi browser SDK — embeddable bug reporting widget with Shadow DOM isolation",
3
+ "version": "1.29.0",
4
+ "description": "Bug report and user feedback widget for the web. The bug mediator for AI-built apps: plain-English diagnosis + a ready fix, in your editor.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
+ "unpkg": "./dist/mushi.loader.global.js",
11
+ "jsdelivr": "./dist/mushi.loader.global.js",
10
12
  "exports": {
11
13
  ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
14
- "require": "./dist/index.cjs"
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.cts",
20
+ "default": "./dist/index.cjs"
21
+ }
15
22
  },
16
23
  "./test-utils": {
17
- "types": "./dist/test-utils.d.ts",
18
- "import": "./dist/test-utils.js",
19
- "require": "./dist/test-utils.cjs"
24
+ "import": {
25
+ "types": "./dist/test-utils.d.ts",
26
+ "default": "./dist/test-utils.js"
27
+ },
28
+ "require": {
29
+ "types": "./dist/test-utils.d.cts",
30
+ "default": "./dist/test-utils.cjs"
31
+ }
20
32
  },
21
33
  "./i18n": {
22
- "types": "./dist/i18n/index.d.ts",
23
- "import": "./dist/i18n/index.js",
24
- "require": "./dist/i18n/index.cjs"
34
+ "import": {
35
+ "types": "./dist/i18n/index.d.ts",
36
+ "default": "./dist/i18n/index.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/i18n/index.d.cts",
40
+ "default": "./dist/i18n/index.cjs"
41
+ }
25
42
  },
26
43
  "./otel": {
27
- "types": "./dist/otel.d.ts",
28
- "import": "./dist/otel.js",
29
- "require": "./dist/otel.cjs"
44
+ "import": {
45
+ "types": "./dist/otel.d.ts",
46
+ "default": "./dist/otel.js"
47
+ },
48
+ "require": {
49
+ "types": "./dist/otel.d.cts",
50
+ "default": "./dist/otel.cjs"
51
+ }
30
52
  },
31
53
  "./headless": {
32
- "types": "./dist/headless.d.ts",
33
- "import": "./dist/headless.js",
34
- "require": "./dist/headless.cjs"
54
+ "import": {
55
+ "types": "./dist/headless.d.ts",
56
+ "default": "./dist/headless.js"
57
+ },
58
+ "require": {
59
+ "types": "./dist/headless.d.cts",
60
+ "default": "./dist/headless.cjs"
61
+ }
62
+ }
63
+ },
64
+ "typesVersions": {
65
+ "*": {
66
+ "test-utils": [
67
+ "./dist/test-utils.d.ts"
68
+ ],
69
+ "i18n": [
70
+ "./dist/i18n/index.d.ts"
71
+ ],
72
+ "otel": [
73
+ "./dist/otel.d.ts"
74
+ ],
75
+ "headless": [
76
+ "./dist/headless.d.ts"
77
+ ]
35
78
  }
36
79
  },
37
80
  "files": [
38
81
  "dist",
39
82
  "README.md",
40
- "LICENSE",
41
- "CONTRIBUTING.md",
42
- "CODE_OF_CONDUCT.md",
43
- "SECURITY.md"
83
+ "LICENSE"
44
84
  ],
45
85
  "repository": {
46
86
  "type": "git",
@@ -53,6 +93,7 @@
53
93
  },
54
94
  "keywords": [
55
95
  "mushi-mushi",
96
+ "bug-report-widget",
56
97
  "bug-translation",
57
98
  "vibe-coding",
58
99
  "ai-debugging",
@@ -72,7 +113,6 @@
72
113
  "svelte",
73
114
  "angular",
74
115
  "sentry-companion",
75
- "sentry-alternative",
76
116
  "ai-agent",
77
117
  "sdk"
78
118
  ],
@@ -85,7 +125,7 @@
85
125
  {
86
126
  "name": "Core SDK bundle (minified + gzipped)",
87
127
  "path": "dist/index.js",
88
- "limit": "89 KB",
128
+ "limit": "89.5 KB",
89
129
  "gzip": true
90
130
  },
91
131
  {
@@ -107,30 +147,32 @@
107
147
  }
108
148
  ],
109
149
  "dependencies": {
110
- "@mushi-mushi/core": "^1.28.0"
150
+ "@mushi-mushi/core": "^1.29.0"
111
151
  },
112
- "optionalDependencies": {
152
+ "peerDependencies": {
113
153
  "rrweb": "^2.0.1"
114
154
  },
155
+ "peerDependenciesMeta": {
156
+ "rrweb": {
157
+ "optional": true
158
+ }
159
+ },
115
160
  "devDependencies": {
116
161
  "@size-limit/file": "^12.1.0",
117
162
  "eslint": "^10.6.0",
118
163
  "jsdom": "^29.1.1",
164
+ "rrweb": "^2.0.1",
119
165
  "size-limit": "^12.1.0",
120
166
  "tsup": "^8.5.1",
121
167
  "typescript": "^6.0.3",
122
168
  "vitest": "^4.1.9",
169
+ "eslint-plugin-mushi-mushi": "0.3.4",
123
170
  "@mushi-mushi/tsconfig": "0.0.0",
124
- "eslint-plugin-mushi-mushi": "0.3.3",
125
171
  "@mushi-mushi/eslint-config": "0.0.0"
126
172
  },
127
- "author": "Kenji Sakuramoto (https://bsky.app/profile/mushimushi.dev)",
173
+ "author": "Kenji Sakuramoto <kensaurus@gmail.com> (https://github.com/kensaurus)",
128
174
  "engines": {
129
- "node": ">=20"
130
- },
131
- "funding": {
132
- "type": "github",
133
- "url": "https://github.com/sponsors/kensaurus"
175
+ "node": ">=20.19.0"
134
176
  },
135
177
  "scripts": {
136
178
  "build": "tsup",
@@ -1,51 +0,0 @@
1
- <!--
2
- AUTO-SYNCED from repo root by scripts/sync-community-files.mjs.
3
- Do not edit here — edit the canonical file at the repository root and
4
- re-run `node scripts/sync-community-files.mjs` (pre-commit hook does this
5
- automatically).
6
- -->
7
-
8
- # Contributor Covenant Code of Conduct
9
-
10
- ## Our Pledge
11
-
12
- We as members, contributors, and leaders pledge to make participation in our
13
- community a harassment-free experience for everyone, regardless of age, body
14
- size, visible or invisible disability, ethnicity, sex characteristics, gender
15
- identity and expression, level of experience, education, socio-economic status,
16
- nationality, personal appearance, race, caste, color, religion, or sexual
17
- identity and orientation.
18
-
19
- We pledge to act and interact in ways that contribute to an open, welcoming,
20
- diverse, inclusive, and healthy community.
21
-
22
- ## Our Standards
23
-
24
- Examples of behavior that contributes to a positive environment:
25
-
26
- - Using welcoming and inclusive language
27
- - Being respectful of differing viewpoints and experiences
28
- - Gracefully accepting constructive criticism
29
- - Focusing on what is best for the community
30
- - Showing empathy towards other community members
31
-
32
- Examples of unacceptable behavior:
33
-
34
- - The use of sexualized language or imagery, and sexual attention or advances of any kind
35
- - Trolling, insulting or derogatory comments, and personal or political attacks
36
- - Public or private harassment
37
- - Publishing others' private information without explicit permission
38
- - Other conduct which could reasonably be considered inappropriate in a professional setting
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
43
- reported to the project team at **kensaurus@gmail.com**.
44
-
45
- All complaints will be reviewed and investigated promptly and fairly.
46
-
47
- ## Attribution
48
-
49
- This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
50
- version 2.1, available at
51
- https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
package/CONTRIBUTING.md DELETED
@@ -1,226 +0,0 @@
1
- <!--
2
- AUTO-SYNCED from repo root by scripts/sync-community-files.mjs.
3
- Do not edit here — edit the canonical file at the repository root and
4
- re-run `node scripts/sync-community-files.mjs` (pre-commit hook does this
5
- automatically).
6
- -->
7
-
8
- # Contributing to Mushi Mushi
9
-
10
- Thanks for wanting to help. Here's everything you need to get started.
11
-
12
- ## Prerequisites
13
-
14
- - **Node.js >= 22** (see `.node-version`)
15
- - **pnpm >= 10** — install with `corepack enable`
16
-
17
- ## Setup
18
-
19
- ```bash
20
- git clone https://github.com/kensaurus/mushi-mushi.git
21
- cd mushi-mushi
22
- pnpm install
23
- pnpm build
24
- ```
25
-
26
- ## Development
27
-
28
- ```bash
29
- pnpm dev # Start all dev servers (admin on :6464)
30
- ```
31
-
32
- | Surface | URL |
33
- | --- | --- |
34
- | Admin console | http://localhost:6464 |
35
- | Docs site | http://localhost:3000 |
36
- | CLI console override | `MUSHI_CONSOLE_URL=http://localhost:6464` |
37
-
38
- ```bash
39
- pnpm test # Run Vitest across all packages
40
- pnpm typecheck # TypeScript checks
41
- pnpm lint # ESLint
42
- pnpm format # Prettier
43
- pnpm smoke:cli-setup # Playwright: onboarding ?setup=cli + success panel (skips headless if unsigned)
44
- ```
45
-
46
- Set `CLI_SETUP_SMOKE_STRICT=1` to fail the smoke script when Playwright is not signed in (CI gate).
47
-
48
- Ad-hoc screenshots captured during UI reviews can live temporarily at the repo
49
- root, but root-level `*.png` files are intentionally ignored. Canonical
50
- screenshots that should be versioned belong under `docs/screenshots/`.
51
-
52
- ### Working on a single package
53
-
54
- ```bash
55
- cd packages/core
56
- pnpm dev # Watch mode
57
- pnpm test # Tests for this package only
58
- ```
59
-
60
- ## Project Structure
61
-
62
- ```
63
- packages/
64
- core/ Types, API client, offline queue (MIT)
65
- web/ Browser SDK — widget, capture (MIT)
66
- react/ React bindings (MIT)
67
- vue/ Vue 3 plugin (MIT)
68
- svelte/ Svelte SDK (MIT)
69
- angular/ Angular SDK (MIT)
70
- react-native/ React Native SDK (MIT)
71
- cli/ CLI tool (MIT)
72
- mcp/ MCP server for coding agents (MIT)
73
- server/ Supabase Edge Functions (AGPLv3; ee/ is commercial)
74
- agents/ Agentic fix pipeline (AGPLv3)
75
- verify/ Fix verification (AGPLv3)
76
- apps/
77
- admin/ Admin dashboard (React + Tailwind)
78
- docs/ Documentation site (Nextra — apps/docs)
79
- testers/ Tester marketplace portal (Next.js)
80
- tooling/
81
- eslint-config/ Shared ESLint flat config
82
- tsconfig/ Shared TypeScript configs
83
- ```
84
-
85
- ## What we don't accept
86
-
87
- Knowing this upfront saves everyone time.
88
-
89
- - **Automated / bulk / AI-slop PRs** — any PR that was opened by a script, an LLM agent acting without meaningful human review, or as part of a parallel bounty-farming sweep is closed on sight. The commit history, branch name, or helper scripts included in the PR make this obvious.
90
- - **PRs that target the wrong base** — all PRs must branch from and target `master`. PRs targeting `main` or any other branch are closed (and will show an inflated diff that is not your work).
91
- - **One PR per issue, one issue per PR** — splitting or duplicating work just to collect acknowledgements isn't welcome.
92
- - **Good-first-issues without claiming first** — comment on the issue to claim it before starting. If two people open PRs for the same issue, the one that commented first is prioritised.
93
- - **Documentation-only PRs that merely duplicate existing content** — if the information already exists (e.g. in another file in this repo), adding a redundant copy adds noise without value.
94
-
95
- If a PR violates these policies it will be closed with a brief explanation. No hard feelings — a genuine contribution on the same issue is always welcome.
96
-
97
- ## Making Changes
98
-
99
- 1. Create a feature branch from `master`
100
- 2. Make your changes
101
- 3. Add tests for new functionality
102
- 4. Run `pnpm typecheck && pnpm lint && pnpm test` to verify
103
- 5. Create a changeset if your change affects published packages:
104
- ```bash
105
- pnpm changeset
106
- ```
107
- 6. Open a pull request
108
-
109
- ### Documentation (docs-as-code)
110
-
111
- If your PR changes **user-visible SDK or CLI behavior**, update docs in the **same PR**:
112
-
113
- | Surface | When to update |
114
- | --- | --- |
115
- | `packages/*/README.md` | npm-facing install/API/config changes for that package |
116
- | `apps/docs/content/**/*.mdx` | Long-form guides, quickstarts, admin console docs |
117
- | Root `README.md` | Marketing stats only when counts change — run `pnpm check:docs-stats` |
118
-
119
- Guardrails (run locally before pushing):
120
-
121
- ```bash
122
- pnpm check:docs-stats # root README stat badges + glance <sub> line
123
- pnpm check:sdk-version-matrix # apps/docs/content/sdks/index.mdx versions
124
- pnpm check:internal-doc-links # dead /foo links in MDX
125
- pnpm check:onboarding-drift # phantom MCP env vars / stale tool names / native install coords
126
- pnpm check:catalog-sync # MCP catalog ↔ admin counts ↔ prose "N tools"
127
- pnpm check:mcp-tools-doc # mcp-tools.generated.mdx stale check
128
- pnpm check:bundle-docs # @mushi-mushi/web size-limit vs README
129
- pnpm check:docs-drift # versions + public docs links
130
- pnpm gen:llms-txt # regenerate apps/docs/public/llms.txt after nav changes
131
- pnpm gen:mcp-tools-doc # regenerate sdks/mcp-tools.generated.mdx from catalog.ts
132
- ```
133
-
134
- **Same-PR rule:** if behavior, env vars, CLI commands, MCP tools, or install
135
- coordinates change, update the matching docs in this PR and run
136
- `pnpm check:docs-drift && pnpm check:onboarding-drift && pnpm check:catalog-sync`.
137
-
138
- README changes on npm packages only appear on [npmjs.com](https://www.npmjs.com) after the next **Changesets publish**.
139
-
140
- ## Changesets
141
-
142
- We use [Changesets](https://github.com/changesets/changesets) for versioning. If your PR modifies a published package (`core`, `web`, `react`, `vue`, `svelte`, `angular`, `react-native`, `cli`, `mcp`), add a changeset:
143
-
144
- ```bash
145
- pnpm changeset
146
- ```
147
-
148
- Select the affected packages, the semver bump type, and write a summary. The changeset file gets committed with your PR.
149
-
150
- ## Release flow
151
-
152
- Releases are fully automated once the version PR is merged. Maintainers don't run
153
- `npm publish` by hand for routine bumps. See **[`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md)**
154
- for the full production runbook (edge functions, admin SPA, docs site, migrations).
155
-
156
- 1. PRs land on `master` with one or more changeset files in `.changeset/`.
157
- Orphaned changesets (only ignored packages) fail `pnpm check:changeset-orphans`.
158
- 2. `release.yml` runs on every push to `master`. It opens (or updates) a
159
- **`chore: version packages`** PR on `changeset-release/master` that bumps
160
- affected `package.json` files, rolls up changelogs, and deletes consumed
161
- changesets.
162
- 3. **Wait for CI on the version PR.** If checks don't appear (bot-branch
163
- suppression), push an empty commit to `changeset-release/master`. If
164
- `check:sdk-version-matrix` fails, run `pnpm gen:sdk-version-matrix` on that
165
- branch and commit `apps/docs/content/sdks/index.mdx`.
166
- 4. Merge the version PR. The publish step uses **OIDC Trusted Publishers** +
167
- Sigstore provenance (with `NPM_TOKEN` only for brand-new package bootstrap).
168
- 5. **Manually dispatch Release** unless a run starts within ~2 minutes:
169
- **Actions → Release → Run workflow → `master`**. Squash-merges attributed to
170
- `github-actions[bot]` usually suppress the auto `push` trigger — manual
171
- dispatch is the normal path, not a fallback of last resort.
172
-
173
- ```bash
174
- gh workflow run release.yml --ref master
175
- ```
176
-
177
- ### Adding a brand-new publishable package
178
-
179
- Trusted Publisher bindings are configured **per package** on `npmjs.com` and require the package to already exist on the registry. New packages therefore need a one-time bootstrap before OIDC can take over.
180
-
181
- 1. Add the package under `packages/<name>/` with a real `version`, `files`, `publishConfig.access: "public"`, `LICENSE`, and the standard fields enforced by `pnpm check:publish-readiness`.
182
- 2. Build it locally: `pnpm install && pnpm -r build`.
183
- 3. Mint a short-lived granular access token at `https://www.npmjs.com/settings/<your-user>/tokens/granular-access-tokens/new` — **Bypass 2FA: ON**, **Read and write: All packages**, **Expiration: 7 days**.
184
- 4. Bootstrap-publish:
185
- ```bash
186
- NPM_TOKEN=npm_xxx pnpm bootstrap:new-package
187
- ```
188
- The script auto-detects which workspace packages are missing on npm and publishes them via `pnpm publish --no-provenance` (so `workspace:^` specifiers get rewritten to real semver in the tarball).
189
- 5. The script prints one URL per freshly-published package. Open each, click **GitHub Actions** under "Trusted Publisher", confirm the auto-filled fields (`<owner>` / `<repo>` / `release.yml`), and tap your security key.
190
- 6. Revoke the bootstrap token at `https://www.npmjs.com/settings/<your-user>/tokens`.
191
-
192
- From the next changeset bump onward, that package publishes through the normal `release.yml` flow with full OIDC provenance — same as the rest.
193
-
194
- ## Code Style
195
-
196
- - **TypeScript strict mode** — no `any` unless absolutely necessary
197
- - **Prettier** formats everything — run `pnpm format` before committing
198
- - **ESLint** catches bugs — `pnpm lint` must pass
199
- - **No default exports** in library packages — use named exports
200
- - **Dual ESM/CJS** builds via tsup for all SDK packages
201
-
202
- ## Commit Messages
203
-
204
- Use conventional commits:
205
-
206
- ```
207
- feat(core): add batch report submission
208
- fix(web): prevent widget from opening during screenshot
209
- docs(react): update provider usage example
210
- chore: bump dependencies
211
- ```
212
-
213
- ## Tests
214
-
215
- - **Framework:** Vitest
216
- - **Location:** Co-located with source (`src/foo.test.ts`)
217
- - **Coverage:** Required for `core`, `web`, `react` — encouraged for all packages
218
-
219
- ## License
220
-
221
- - SDK packages are MIT — your contributions will be MIT-licensed
222
- - Server/agents/verify are AGPLv3 — contributions to those packages fall under AGPLv3. A [commercial license](./COMMERCIAL-LICENSE.md) is available for hosted-SaaS use cases that cannot publish modifications. The `packages/server/ee/` directory is source-available but commercial (production use needs a license); contributions there are accepted under the same EE terms.
223
-
224
- ## Questions?
225
-
226
- Open an issue or start a discussion. We're happy to help.