@posthog/wizard 2.28.1 → 2.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.
Files changed (60) hide show
  1. package/dist/{add-mcp-server-to-clients-pXmZQkpk.js → add-mcp-server-to-clients-B6Pj4IKt.js} +4 -4
  2. package/dist/{add-mcp-server-to-clients-pXmZQkpk.js.map → add-mcp-server-to-clients-B6Pj4IKt.js.map} +1 -1
  3. package/dist/{agent-interface-Bw1w0ePT.js → agent-interface-CVW8H9eF.js} +8 -7
  4. package/dist/{agent-interface-Bw1w0ePT.js.map → agent-interface-CVW8H9eF.js.map} +1 -1
  5. package/dist/{agent-runner-djkxwCd9.js → agent-runner-VzTpPaVT.js} +18 -9
  6. package/dist/agent-runner-VzTpPaVT.js.map +1 -0
  7. package/dist/{analytics-AnN3M677.js → analytics-DvDjbNmK.js} +2 -2
  8. package/dist/{analytics-AnN3M677.js.map → analytics-DvDjbNmK.js.map} +1 -1
  9. package/dist/{api-CeVi1ZfZ.js → api-DfpSG5xU.js} +3 -3
  10. package/dist/{api-CeVi1ZfZ.js.map → api-DfpSG5xU.js.map} +1 -1
  11. package/dist/bin.js +399 -224
  12. package/dist/bin.js.map +1 -1
  13. package/dist/{ci-install-DPnE1HL3.js → ci-install-Bzfo3nON.js} +4 -4
  14. package/dist/{ci-install-DPnE1HL3.js.map → ci-install-Bzfo3nON.js.map} +1 -1
  15. package/dist/{debug-i9wAxF8s.js → debug-CMZ7kqW1.js} +17 -3
  16. package/dist/debug-CMZ7kqW1.js.map +1 -0
  17. package/dist/{debug-CyadC-pR.js → debug-HQ0NrBA2.js} +1 -1
  18. package/dist/{environment-CxkKJEfj.js → environment-cVP7bGnh.js} +3 -3
  19. package/dist/{environment-CxkKJEfj.js.map → environment-cVP7bGnh.js.map} +1 -1
  20. package/dist/{file-utils-D8H35Gk0.js → file-utils-D1632P4x.js} +2 -2
  21. package/dist/{file-utils-D8H35Gk0.js.map → file-utils-D1632P4x.js.map} +1 -1
  22. package/dist/{interactive-DwLH5ADP.js → interactive-DCIL3NcQ.js} +2 -2
  23. package/dist/{interactive-DwLH5ADP.js.map → interactive-DCIL3NcQ.js.map} +1 -1
  24. package/dist/{mcp-prompt-streaming-Cxy0XPv4.js → mcp-prompt-streaming-BRoVSf3N.js} +5 -5
  25. package/dist/mcp-prompt-streaming-BRoVSf3N.js.map +1 -0
  26. package/dist/{non-interactive-LHbUCRuo.js → non-interactive-u4VG76Vi.js} +2 -2
  27. package/dist/{non-interactive-LHbUCRuo.js.map → non-interactive-u4VG76Vi.js.map} +1 -1
  28. package/dist/{package-manager-BabzIzcR.js → package-manager-0M_uIOP0.js} +2 -2
  29. package/dist/{package-manager-BabzIzcR.js.map → package-manager-0M_uIOP0.js.map} +1 -1
  30. package/dist/{playground-BphF8gEy.js → playground-B6wgUvH-.js} +5 -5
  31. package/dist/{playground-BphF8gEy.js.map → playground-B6wgUvH-.js.map} +1 -1
  32. package/dist/{posthog-integration-vJHebMhn.js → posthog-integration-C_9G_kTS.js} +201 -12
  33. package/dist/posthog-integration-C_9G_kTS.js.map +1 -0
  34. package/dist/{provisioning-BYJOD26-.js → provisioning-CgCxuoe6.js} +3 -3
  35. package/dist/{provisioning-BYJOD26-.js.map → provisioning-CgCxuoe6.js.map} +1 -1
  36. package/dist/{registry-BGXvbfI-.js → registry-BgsYtCkS.js} +4 -4
  37. package/dist/{registry-BGXvbfI-.js.map → registry-BgsYtCkS.js.map} +1 -1
  38. package/dist/{setup-utils-DGnWKE9t.js → setup-utils-DF6EKEeA.js} +8 -8
  39. package/dist/{setup-utils-DGnWKE9t.js.map → setup-utils-DF6EKEeA.js.map} +1 -1
  40. package/dist/{start-tui-DetsuXHe.js → start-tui-Deaj99It.js} +306 -223
  41. package/dist/start-tui-Deaj99It.js.map +1 -0
  42. package/dist/{steps-DgYfPftk.js → steps-AF3ulYYe.js} +7 -7
  43. package/dist/{steps-DgYfPftk.js.map → steps-AF3ulYYe.js.map} +1 -1
  44. package/dist/{telemetry-WZu-ePKr.js → telemetry-DPVvKu5X.js} +3 -3
  45. package/dist/{telemetry-WZu-ePKr.js.map → telemetry-DPVvKu5X.js.map} +1 -1
  46. package/dist/{terminal-CfJ-haHU.js → terminal-BVKeWPb3.js} +13 -10
  47. package/dist/terminal-BVKeWPb3.js.map +1 -0
  48. package/dist/{urls-yVHBHA-b.js → urls-Bur7Zb7A.js} +2 -2
  49. package/dist/{urls-yVHBHA-b.js.map → urls-Bur7Zb7A.js.map} +1 -1
  50. package/dist/{wizard-abort-Ba5HDRGB.js → wizard-abort-D0UMhCP5.js} +3 -3
  51. package/dist/{wizard-abort-Ba5HDRGB.js.map → wizard-abort-D0UMhCP5.js.map} +1 -1
  52. package/dist/{wizard-abort-ChmzV0wB.js → wizard-abort-D3vY7K9a.js} +1 -1
  53. package/dist/wizard-ui-WZ48rUgr.js.map +1 -1
  54. package/package.json +1 -1
  55. package/dist/agent-runner-djkxwCd9.js.map +0 -1
  56. package/dist/debug-i9wAxF8s.js.map +0 -1
  57. package/dist/mcp-prompt-streaming-Cxy0XPv4.js.map +0 -1
  58. package/dist/posthog-integration-vJHebMhn.js.map +0 -1
  59. package/dist/start-tui-DetsuXHe.js.map +0 -1
  60. package/dist/terminal-CfJ-haHU.js.map +0 -1
@@ -1,22 +1,22 @@
1
- import { A as OAUTH_PORTS, L as POSTHOG_ORG_AI_SETTINGS_URL, P as POSTHOG_DOCS_URL, R as POSTHOG_PRIVACY_URL, U as REMOTE_SKILLS_BASE_URL, V as POSTHOG_TERMS_URL, Y as WIZARD_TOOLS_MENU_FLAG_KEY, _ as SIGNUP_WIZARD_READINESS_CONFIG, d as relativeToInstallDir, j as OAUTH_TIMEOUT_MS, k as Integration, l as WIZARD_LOG_FILE, m as setUI, s as logToFile, y as getBlockingServiceKeys } from "./debug-i9wAxF8s.js";
2
- import { t as analytics } from "./analytics-AnN3M677.js";
3
- import { o as extractOAuthCode, t as getOrAskForProjectData } from "./setup-utils-DGnWKE9t.js";
4
- import { a as getUiHostFromHost } from "./urls-yVHBHA-b.js";
5
- import { t as ApiError } from "./api-CeVi1ZfZ.js";
1
+ import { B as POSTHOG_PRIVACY_URL, G as REMOTE_SKILLS_BASE_URL, I as POSTHOG_DOCS_URL, M as OAUTH_PORTS, N as OAUTH_TIMEOUT_MS, U as POSTHOG_TERMS_URL, Z as WIZARD_TOOLS_MENU_FLAG_KEY, _ as SIGNUP_WIZARD_READINESS_CONFIG, d as relativeToInstallDir, j as Integration, l as WIZARD_LOG_FILE, m as setUI, s as logToFile, y as getBlockingServiceKeys, z as POSTHOG_ORG_AI_SETTINGS_URL } from "./debug-CMZ7kqW1.js";
2
+ import { t as analytics } from "./analytics-DvDjbNmK.js";
3
+ import { o as extractOAuthCode, t as getOrAskForProjectData } from "./setup-utils-DF6EKEeA.js";
4
+ import { a as getUiHostFromHost } from "./urls-Bur7Zb7A.js";
5
+ import { t as ApiError } from "./api-DfpSG5xU.js";
6
6
  import { t as ADDITIONAL_FEATURE_LABELS } from "./wizard-session-G3VWD6hv.js";
7
- import { i as wizardAbort } from "./wizard-abort-Ba5HDRGB.js";
8
- import { C as AUDIT_SEVERITY_STYLE, T as getAuditChecks, b as AUDIT_CHECKS_FILE, h as fetchSkillMenu, m as downloadSkill, w as coerceAuditChecks, x as AUDIT_CHECKS_KEY } from "./agent-interface-Bw1w0ePT.js";
9
- import { f as Colors, p as Icons, t as EVENT_PLAN_FILE } from "./posthog-integration-vJHebMhn.js";
10
- import { _ as getContentBlocks, d as getProgramConfig, f as DISPLAY_NAME, g as getDetectedWarehouseSources, h as fetchHealthIssues, n as useKeyBindings, p as SOURCE_MAPS_CONTEXT_KEYS, t as PickerMenu, u as Program, v as POSTHOG_SDKS, y as STRIPE_SDKS } from "./bin.js";
11
- import { A as ConfirmationInput, C as TabContainer, D as LinkText, E as LogViewer, F as SplitView, L as WizardStore, M as useStdoutDimensions, N as ProgressList, O as extractUrls, P as LoadingBox, S as HNViewer, T as EventPlanViewer, _ as ServiceHealthList, a as useSkillEntry, b as LearnCard, c as AUDIT_AREA_SLIDES, d as McpSuggestedPromptsScreen, g as SEVERITY_ORDER, h as SEVERITY_LABEL, i as SkillSourceInfo, k as ModalOverlay, l as VisualBox, m as IssueTable, n as releaseTerminal, o as OutroScreen, p as McpScreen, r as AiOptInRequiredScreen, s as SlackConnectScreen, t as enterDarkTerminal, u as AuditChecksViewer, v as VisualizerTab, w as ScreenContainer, y as TipsCard } from "./terminal-CfJ-haHU.js";
7
+ import { i as wizardAbort } from "./wizard-abort-D0UMhCP5.js";
8
+ import { C as AUDIT_SEVERITY_STYLE, T as getAuditChecks, b as AUDIT_CHECKS_FILE, h as fetchSkillMenu, m as downloadSkill, w as coerceAuditChecks, x as AUDIT_CHECKS_KEY } from "./agent-interface-CVW8H9eF.js";
9
+ import { f as Colors, h as detectProjectsWithAgent, p as Icons, t as EVENT_PLAN_FILE } from "./posthog-integration-C_9G_kTS.js";
10
+ import { _ as getDetectedWarehouseSources, b as STRIPE_SDKS, d as getProgramConfig, f as AUTOMATABLE_VARIANTS, g as fetchHealthIssues, m as SOURCE_MAPS_CONTEXT_KEYS, n as useKeyBindings, p as DISPLAY_NAME, t as PickerMenu, u as Program, v as getContentBlocks, y as POSTHOG_SDKS } from "./bin.js";
11
+ import { A as ConfirmationInput, C as TabContainer, D as LinkText, E as LogViewer, F as SplitView, L as WizardStore, M as useStdoutDimensions, N as ProgressList, O as extractUrls, P as LoadingBox, S as HNViewer, T as EventPlanViewer, _ as ServiceHealthList, a as useSkillEntry, b as LearnCard, c as AUDIT_AREA_SLIDES, d as McpSuggestedPromptsScreen, g as SEVERITY_ORDER, h as SEVERITY_LABEL, i as SkillSourceInfo, k as ModalOverlay, l as VisualBox, m as IssueTable, n as releaseTerminal, o as OutroScreen, p as McpScreen, r as AiOptInRequiredScreen, s as SlackConnectScreen, t as enterDarkTerminal, u as AuditChecksViewer, v as VisualizerTab, w as ScreenContainer, y as TipsCard } from "./terminal-BVKeWPb3.js";
12
12
  import { t as ALL_FEATURE_VALUES } from "./defaults-BNWIWzjc.js";
13
- import { a as getSupportedClients, c as removeMCPServer, i as getInstalledClients, o as getSupportedPluginClients, s as installPlugins, u as isPluginCapable } from "./add-mcp-server-to-clients-pXmZQkpk.js";
13
+ import { a as getSupportedClients, c as removeMCPServer, i as getInstalledClients, o as getSupportedPluginClients, s as installPlugins, u as isPluginCapable } from "./add-mcp-server-to-clients-B6Pj4IKt.js";
14
14
  import * as fs$1 from "fs";
15
15
  import path from "path";
16
16
  import { join as join$1 } from "node:path";
17
17
  import { spawn, spawnSync } from "node:child_process";
18
18
  import { Box, Text, render, useInput } from "ink";
19
- import { Fragment, createElement, useEffect, useMemo, useState, useSyncExternalStore } from "react";
19
+ import { Fragment, createElement, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
20
20
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
21
21
  import { access, readdir, rm } from "node:fs/promises";
22
22
  import { Spinner, TextInput } from "@inkjs/ui";
@@ -70,6 +70,12 @@ var InkUI = class {
70
70
  waitForAiOptIn() {
71
71
  return this.store.getGate("ai-opt-in");
72
72
  }
73
+ waitForGate(stepId) {
74
+ return this.store.getGate(stepId);
75
+ }
76
+ getFrameworkContext(key) {
77
+ return this.store.session.frameworkContext[key];
78
+ }
73
79
  setDetectedFramework(label) {
74
80
  this.store.setDetectedFramework(label);
75
81
  }
@@ -1065,7 +1071,7 @@ const FrameworkPicker = ({ store, onComplete }) => {
1065
1071
  })),
1066
1072
  onSelect: (value) => {
1067
1073
  const integration = Array.isArray(value) ? value[0] : value;
1068
- import("./registry-BGXvbfI-.js").then((n) => n.n).then(({ FRAMEWORK_REGISTRY }) => {
1074
+ import("./registry-BgsYtCkS.js").then((n) => n.n).then(({ FRAMEWORK_REGISTRY }) => {
1069
1075
  const config = FRAMEWORK_REGISTRY[integration];
1070
1076
  store.setFrameworkConfig(integration, config);
1071
1077
  store.setDetectedFramework(config.metadata.name);
@@ -1409,7 +1415,7 @@ const RevenueIntroScreen = ({ store }) => {
1409
1415
  }), /* @__PURE__ */ jsx(Box, {
1410
1416
  marginTop: 1,
1411
1417
  flexDirection: "column",
1412
- children: /* @__PURE__ */ jsx(DetectErrorBody$3, { error: detectError })
1418
+ children: /* @__PURE__ */ jsx(DetectErrorBody$2, { error: detectError })
1413
1419
  })]
1414
1420
  }), /* @__PURE__ */ jsx(PickerMenu, {
1415
1421
  options: [{
@@ -1453,7 +1459,7 @@ const RevenueIntroScreen = ({ store }) => {
1453
1459
  }
1454
1460
  });
1455
1461
  };
1456
- const DetectErrorBody$3 = ({ error }) => {
1462
+ const DetectErrorBody$2 = ({ error }) => {
1457
1463
  switch (error.kind) {
1458
1464
  case "bad-directory": {
1459
1465
  const reasonText = {
@@ -1654,7 +1660,7 @@ const WarehouseIntroScreen = ({ store }) => {
1654
1660
  }), /* @__PURE__ */ jsx(Box, {
1655
1661
  marginTop: 1,
1656
1662
  flexDirection: "column",
1657
- children: /* @__PURE__ */ jsx(DetectErrorBody$2, { error: detectError })
1663
+ children: /* @__PURE__ */ jsx(DetectErrorBody$1, { error: detectError })
1658
1664
  })]
1659
1665
  }), /* @__PURE__ */ jsx(PickerMenu, {
1660
1666
  options: [{
@@ -1697,7 +1703,7 @@ const WarehouseIntroScreen = ({ store }) => {
1697
1703
  }
1698
1704
  });
1699
1705
  };
1700
- const DetectErrorBody$2 = ({ error }) => {
1706
+ const DetectErrorBody$1 = ({ error }) => {
1701
1707
  switch (error.kind) {
1702
1708
  case "bad-directory": {
1703
1709
  const reasonText = {
@@ -1768,27 +1774,14 @@ const MigrationIntroScreen = ({ store }) => {
1768
1774
  /**
1769
1775
  * SourceMapsIntroScreen — Welcome screen for the source-maps upload flow.
1770
1776
  *
1771
- * Reads detection results from frameworkContext (written by
1772
- * detectSourceMapsPrerequisites). On success: shows the detected platform.
1773
- * On failure: shows the structured error with an Exit prompt.
1777
+ * Static intro: detection now runs after login (on the source-maps-detect
1778
+ * screen), so this screen no longer shows a detected platform. Continue takes
1779
+ * the user straight to authentication.
1774
1780
  */
1775
1781
  const SourceMapsIntroScreen = ({ store }) => {
1776
1782
  useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
1777
1783
  const [view, setView] = useState("default");
1778
1784
  const { session } = store;
1779
- const detectError = session.frameworkContext[SOURCE_MAPS_CONTEXT_KEYS.detectError];
1780
- const variant = session.frameworkContext[SOURCE_MAPS_CONTEXT_KEYS.skillVariant];
1781
- const displayName = session.frameworkContext[SOURCE_MAPS_CONTEXT_KEYS.displayName];
1782
- const packagePaths = session.frameworkContext[SOURCE_MAPS_CONTEXT_KEYS.packagePaths] ?? [];
1783
- const detectionRows = [];
1784
- if (displayName) detectionRows.push({
1785
- label: "Platform",
1786
- value: displayName
1787
- });
1788
- if (variant) detectionRows.push({
1789
- label: "Skill",
1790
- value: `error-tracking-upload-source-maps-${variant}`
1791
- });
1792
1785
  const body = view === "more-info" ? /* @__PURE__ */ jsxs(Box, {
1793
1786
  flexDirection: "column",
1794
1787
  width: 56,
@@ -1822,9 +1815,9 @@ const SourceMapsIntroScreen = ({ store }) => {
1822
1815
  marginTop: 1,
1823
1816
  paddingLeft: 4,
1824
1817
  children: [
1825
- /* @__PURE__ */ jsxs(Text, { children: ["•", " Ask for a personal API key to authorize uploads"] }),
1818
+ /* @__PURE__ */ jsxs(Text, { children: ["•", " Detect the framework(s) in your repo"] }),
1819
+ /* @__PURE__ */ jsxs(Text, { children: ["•", " Download the relevant docs for your stack"] }),
1826
1820
  /* @__PURE__ */ jsxs(Text, { children: ["•", " Wire map generation + upload into your build"] }),
1827
- /* @__PURE__ */ jsxs(Text, { children: ["•", " Write the upload credentials to your .env"] }),
1828
1821
  /* @__PURE__ */ jsxs(Text, { children: ["•", " Wire CI for deploys and offer a local test run"] })
1829
1822
  ]
1830
1823
  }),
@@ -1836,53 +1829,14 @@ const SourceMapsIntroScreen = ({ store }) => {
1836
1829
  })
1837
1830
  })
1838
1831
  ]
1839
- }) : view === "privacy" ? /* @__PURE__ */ jsx(PrivacyPanel, {}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Box, {
1832
+ }) : view === "privacy" ? /* @__PURE__ */ jsx(PrivacyPanel, {}) : /* @__PURE__ */ jsxs(Box, {
1840
1833
  flexDirection: "column",
1841
- alignItems: "center",
1842
- children: [/* @__PURE__ */ jsx(Text, { children: "Upload source maps for accurate error stack traces." }), /* @__PURE__ */ jsx(Box, {
1843
- flexDirection: "column",
1834
+ width: 60,
1835
+ children: [/* @__PURE__ */ jsx(Text, { children: "The Wizard will run an agent to detect your project's framework(s), download the relevant docs, and implement source-map uploads for you." }), /* @__PURE__ */ jsx(Box, {
1844
1836
  marginTop: 1,
1845
- children: /* @__PURE__ */ jsx(Text, { children: "The agent will wire it into your build." })
1837
+ children: /* @__PURE__ */ jsx(Text, { children: "Ready?" })
1846
1838
  })]
1847
- }), packagePaths.length > 1 && /* @__PURE__ */ jsxs(Box, {
1848
- flexDirection: "column",
1849
- marginTop: 1,
1850
- children: [/* @__PURE__ */ jsxs(Text, {
1851
- dimColor: true,
1852
- children: [
1853
- "Found ",
1854
- packagePaths.length,
1855
- " package.json files:"
1856
- ]
1857
- }), packagePaths.map((p) => /* @__PURE__ */ jsxs(Text, {
1858
- dimColor: true,
1859
- children: [
1860
- " ",
1861
- "•",
1862
- " ",
1863
- p
1864
- ]
1865
- }, p))]
1866
- })] });
1867
- const errorView = detectError ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Box, {
1868
- flexDirection: "column",
1869
- marginBottom: 1,
1870
- children: [/* @__PURE__ */ jsxs(Text, {
1871
- color: "red",
1872
- bold: true,
1873
- children: ["✘", " Cannot set up source map upload"]
1874
- }), /* @__PURE__ */ jsx(Box, {
1875
- marginTop: 1,
1876
- flexDirection: "column",
1877
- children: /* @__PURE__ */ jsx(DetectErrorBody$1, { error: detectError })
1878
- })]
1879
- }), /* @__PURE__ */ jsx(PickerMenu, {
1880
- options: [{
1881
- label: "Exit",
1882
- value: "exit"
1883
- }],
1884
- onSelect: () => process.exit(1)
1885
- })] }) : void 0;
1839
+ });
1886
1840
  const menuOptions = view === "more-info" ? [{
1887
1841
  label: "Back",
1888
1842
  value: "back"
@@ -1913,8 +1867,6 @@ const SourceMapsIntroScreen = ({ store }) => {
1913
1867
  showSubtitle: view === "default",
1914
1868
  body,
1915
1869
  showDetection: view === "default",
1916
- detectionRows,
1917
- errorView,
1918
1870
  programLabel: session.programLabel,
1919
1871
  skillId: session.skillId,
1920
1872
  menuOptions,
@@ -1927,165 +1879,294 @@ const SourceMapsIntroScreen = ({ store }) => {
1927
1879
  }
1928
1880
  });
1929
1881
  };
1930
- const SOURCE_MAP_DOCS = "https://posthog.com/docs/error-tracking/upload-source-maps";
1931
- const ERROR_TRACKING_INSTALL_DOCS = "https://posthog.com/docs/error-tracking/installation";
1932
- const WIZARD_ISSUES_URL = "https://github.com/PostHog/wizard/issues";
1882
+ //#endregion
1883
+ //#region src/lib/programs/error-tracking-upload-source-maps/detect-agentic.ts
1933
1884
  /**
1934
- * Platforms PostHog Error Tracking supports with published source-map / symbol
1935
- * upload docs, but that the wizard can't automate yet. The user (or their own
1936
- * coding agent) can follow these docs to wire it up by hand. Anything not in
1937
- * this map falls through to the generic "not supported yet" message — we don't
1938
- * hardcode the full supported-platform list (it lives in the docs and changes
1939
- * server-side), we just point there.
1885
+ * Source-maps adapter over the generic agentic detector
1886
+ * (`@lib/detection/agentic`). The detector itself is product-knowledge-free;
1887
+ * this file supplies the source-maps targets (the automatable skill variants),
1888
+ * maps the result back to variants, and classifies each project as
1889
+ * instrumentable or not. The screen renders the result and the run step
1890
+ * instruments the chosen project.
1940
1891
  */
1941
- const NATIVE_PLATFORM_DOCS = {
1942
- ios: {
1943
- label: "iOS",
1944
- url: "https://posthog.com/docs/error-tracking/upload-source-maps/ios"
1945
- },
1946
- android: {
1947
- label: "Android",
1948
- url: "https://posthog.com/docs/error-tracking/upload-mappings/android"
1949
- },
1950
- "react-native": {
1951
- label: "React Native",
1952
- url: "https://posthog.com/docs/error-tracking/upload-source-maps/react-native"
1953
- },
1954
- flutter: {
1955
- label: "Flutter",
1956
- url: "https://posthog.com/docs/error-tracking/upload-source-maps/flutter"
1957
- }
1892
+ /**
1893
+ * Variant precedence for the agentic picker (most specific first). The detector
1894
+ * keeps the EARLIEST matching target, so this ordering is what makes a React app
1895
+ * built with Vite resolve to `vite` (bundler-plugin upload) instead of the
1896
+ * generic `react` posthog-cli path. Mirrors `pickJsVariant` in detect.ts:
1897
+ * opinionated frameworks → bundlers → bare React → Node → generic web.
1898
+ */
1899
+ const VARIANT_PRECEDENCE = [
1900
+ "nextjs",
1901
+ "nuxt",
1902
+ "angular",
1903
+ "vite",
1904
+ "webpack",
1905
+ "rollup",
1906
+ "react",
1907
+ "node",
1908
+ "web"
1909
+ ];
1910
+ const precedenceRank = (v) => {
1911
+ const i = VARIANT_PRECEDENCE.indexOf(v);
1912
+ return i === -1 ? Number.MAX_SAFE_INTEGER : i;
1958
1913
  };
1959
- const DetectErrorBody$1 = ({ error }) => {
1960
- switch (error.kind) {
1961
- case "bad-directory": {
1962
- const reasonText = {
1963
- missing: "does not exist",
1964
- "not-dir": "is not a directory",
1965
- unreadable: "could not be accessed"
1966
- }[error.reason];
1967
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Text, { children: [
1968
- "This path ",
1969
- reasonText,
1970
- ":"
1971
- ] }), /* @__PURE__ */ jsxs(Text, {
1972
- dimColor: true,
1973
- children: [" ", error.path]
1974
- })] });
1975
- }
1976
- case "no-project-files": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1977
- /* @__PURE__ */ jsx(Text, { children: "No recognizable project files were found." }),
1914
+ /**
1915
+ * Source-maps targets: the variants the wizard can automate, by id → name,
1916
+ * ordered by VARIANT_PRECEDENCE so the detector's "earliest match wins"
1917
+ * tie-break selects the most specific variant. Derived from AUTOMATABLE_VARIANTS
1918
+ * so a newly-automatable variant is never silently dropped (unranked ones sort
1919
+ * last). Exported for testing.
1920
+ */
1921
+ const SOURCE_MAPS_TARGETS = [...AUTOMATABLE_VARIANTS].sort((a, b) => precedenceRank(a) - precedenceRank(b)).map((v) => ({
1922
+ id: v,
1923
+ name: DISPLAY_NAME[v]
1924
+ }));
1925
+ function classify(variant, hasPostHog) {
1926
+ if (variant == null) return {
1927
+ instrumentable: false,
1928
+ reason: "Source-map upload isn't supported for this stack yet"
1929
+ };
1930
+ if (!hasPostHog) return {
1931
+ instrumentable: false,
1932
+ reason: "No PostHog SDK installed yet run `npx @posthog/wizard` first"
1933
+ };
1934
+ return { instrumentable: true };
1935
+ }
1936
+ /** Map a generic detection report into source-maps projects. */
1937
+ function toSourceMapsReport(report) {
1938
+ return {
1939
+ repoType: report.repoType,
1940
+ projects: report.projects.map((p) => {
1941
+ const variant = p.targetId ?? null;
1942
+ return {
1943
+ path: p.path,
1944
+ framework: p.framework,
1945
+ variant,
1946
+ hasPostHog: p.hasPostHog,
1947
+ ...classify(variant, p.hasPostHog)
1948
+ };
1949
+ })
1950
+ };
1951
+ }
1952
+ /** Run the Haiku detector over the repo and classify projects for source maps. */
1953
+ async function detectSourceMapsProjects(session, onEvent) {
1954
+ return toSourceMapsReport(await detectProjectsWithAgent(session, {
1955
+ targets: SOURCE_MAPS_TARGETS,
1956
+ purpose: "set up PostHog Error Tracking source-map upload",
1957
+ onEvent
1958
+ }));
1959
+ }
1960
+ //#endregion
1961
+ //#region src/ui/tui/screens/SourceMapsDetectScreen.tsx
1962
+ /**
1963
+ * SourceMapsDetectScreen — runs the Haiku detection agent over the repo, shows
1964
+ * streaming progress, then renders a structured map of which projects can have
1965
+ * source-map upload wired up and which cannot. The user picks one project; the
1966
+ * choice is written to frameworkContext and the run step instruments it.
1967
+ *
1968
+ * Runs after auth — the detection agent needs credentials.
1969
+ */
1970
+ const EXIT = "__exit";
1971
+ const MAX_ACTIVITY_LINES = 8;
1972
+ function projectLabel(p) {
1973
+ const name = p.variant ? DISPLAY_NAME[p.variant] : p.framework;
1974
+ const where = p.path === "." ? "repo root" : p.path;
1975
+ return `${name} ${Icons.bullet} ${where}`;
1976
+ }
1977
+ const SourceMapsDetectScreen = ({ store }) => {
1978
+ useSyncExternalStore((cb) => store.subscribe(cb), () => store.getSnapshot());
1979
+ const { credentials } = store.session;
1980
+ const accessToken = credentials?.accessToken;
1981
+ const [state, setState] = useState({ kind: "loading" });
1982
+ const [activity, setActivity] = useState([]);
1983
+ const started = useRef(false);
1984
+ useEffect(() => {
1985
+ if (!accessToken || started.current) return;
1986
+ started.current = true;
1987
+ let cancelled = false;
1988
+ (async () => {
1989
+ try {
1990
+ const report = await detectSourceMapsProjects(store.session, (line) => {
1991
+ if (!cancelled) setActivity((prev) => [...prev, line].slice(-MAX_ACTIVITY_LINES));
1992
+ });
1993
+ if (!cancelled) setState({
1994
+ kind: "ready",
1995
+ report
1996
+ });
1997
+ } catch (err) {
1998
+ if (!cancelled) setState({
1999
+ kind: "error",
2000
+ message: err instanceof Error ? err.message : String(err)
2001
+ });
2002
+ }
2003
+ })();
2004
+ return () => {
2005
+ cancelled = true;
2006
+ };
2007
+ }, [accessToken, store]);
2008
+ if (!credentials) return /* @__PURE__ */ jsx(LoadingBox, { message: "Waiting for authentication..." });
2009
+ if (state.kind === "loading") return /* @__PURE__ */ jsxs(Box, {
2010
+ flexDirection: "column",
2011
+ children: [
1978
2012
  /* @__PURE__ */ jsx(Text, {
1979
- dimColor: true,
1980
- children: "Source map upload needs a package.json, Xcode project, Gradle build, or Flutter pubspec.yaml."
2013
+ bold: true,
2014
+ color: Colors.accent,
2015
+ children: "Detecting your project..."
1981
2016
  }),
1982
- /* @__PURE__ */ jsx(Text, {
1983
- dimColor: true,
1984
- children: "Run this command from your project root."
2017
+ /* @__PURE__ */ jsx(Box, {
2018
+ marginY: 1,
2019
+ children: /* @__PURE__ */ jsx(LoadingBox, { message: "Scanning the repo for frameworks and PostHog SDKs..." })
1985
2020
  }),
1986
- /* @__PURE__ */ jsxs(Box, {
1987
- marginTop: 1,
2021
+ /* @__PURE__ */ jsx(Box, {
1988
2022
  flexDirection: "column",
1989
- children: [/* @__PURE__ */ jsx(Text, {
2023
+ children: activity.length === 0 ? /* @__PURE__ */ jsxs(Text, {
1990
2024
  dimColor: true,
1991
- children: "How source map upload works:"
1992
- }), /* @__PURE__ */ jsxs(Text, {
1993
- dimColor: true,
1994
- children: [" ", SOURCE_MAP_DOCS]
1995
- })]
2025
+ children: [" ", "Starting up the detection agent…"]
2026
+ }) : activity.map((line, i) => /* @__PURE__ */ jsxs(Text, {
2027
+ dimColor: i < activity.length - 1,
2028
+ color: i === activity.length - 1 ? Colors.primary : void 0,
2029
+ children: [
2030
+ " ",
2031
+ Icons.triangleSmallRight,
2032
+ " ",
2033
+ line
2034
+ ]
2035
+ }, `${i}-${line}`))
1996
2036
  })
1997
- ] });
1998
- case "unsupported-platform": {
1999
- const native = NATIVE_PLATFORM_DOCS[error.detected];
2000
- if (native) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Text, { children: [
2001
- "The wizard can't set up source map upload for ",
2002
- native.label,
2003
- " yet."
2004
- ] }), /* @__PURE__ */ jsxs(Box, {
2005
- marginTop: 1,
2037
+ ]
2038
+ });
2039
+ if (state.kind === "error") return /* @__PURE__ */ jsxs(Box, {
2040
+ flexDirection: "column",
2041
+ children: [/* @__PURE__ */ jsxs(Box, {
2042
+ flexDirection: "column",
2043
+ marginY: 1,
2044
+ children: [/* @__PURE__ */ jsxs(Text, {
2045
+ color: Colors.error,
2046
+ bold: true,
2047
+ children: [Icons.squareFilled, " Detection failed"]
2048
+ }), /* @__PURE__ */ jsx(Text, {
2049
+ dimColor: true,
2050
+ children: state.message
2051
+ })]
2052
+ }), /* @__PURE__ */ jsx(PickerMenu, {
2053
+ options: [{
2054
+ label: "Exit",
2055
+ value: EXIT
2056
+ }],
2057
+ onSelect: () => process.exit(1)
2058
+ })]
2059
+ });
2060
+ const { report } = state;
2061
+ const instrumentable = report.projects.filter((p) => p.instrumentable);
2062
+ const blocked = report.projects.filter((p) => !p.instrumentable);
2063
+ if (instrumentable.length === 0) return /* @__PURE__ */ jsxs(Box, {
2064
+ flexDirection: "column",
2065
+ children: [
2066
+ /* @__PURE__ */ jsxs(Box, {
2006
2067
  flexDirection: "column",
2068
+ marginBottom: 1,
2007
2069
  children: [/* @__PURE__ */ jsxs(Text, {
2070
+ color: Colors.error,
2071
+ bold: true,
2072
+ children: [Icons.squareFilled, " Nothing to instrument yet"]
2073
+ }), /* @__PURE__ */ jsxs(Text, {
2008
2074
  dimColor: true,
2009
2075
  children: [
2010
- "PostHog Error Tracking does support ",
2011
- native.label,
2012
- ". You can set it up yourself by following the docs below — or hand them to your own coding agent to do it for you:"
2076
+ "None of the ",
2077
+ report.projects.length,
2078
+ " projects found can have source-map upload set up."
2013
2079
  ]
2014
- }), /* @__PURE__ */ jsx(Box, {
2015
- marginTop: 1,
2016
- children: /* @__PURE__ */ jsx(Text, {
2017
- dimColor: true,
2018
- children: native.url
2019
- })
2020
2080
  })]
2021
- })] });
2022
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, { children: "Source map upload isn't supported for this stack yet." }), /* @__PURE__ */ jsxs(Box, {
2023
- marginTop: 1,
2024
- flexDirection: "column",
2025
- children: [
2026
- /* @__PURE__ */ jsx(Text, {
2027
- dimColor: true,
2028
- children: "Check which platforms PostHog Error Tracking supports:"
2029
- }),
2030
- /* @__PURE__ */ jsx(Box, {
2031
- marginTop: 1,
2032
- children: /* @__PURE__ */ jsx(Text, {
2033
- dimColor: true,
2034
- children: ERROR_TRACKING_INSTALL_DOCS
2035
- })
2036
- }),
2037
- /* @__PURE__ */ jsx(Box, {
2038
- marginTop: 1,
2039
- children: /* @__PURE__ */ jsxs(Text, {
2040
- dimColor: true,
2041
- children: [
2042
- "If yours isn't listed and you'd like it added, open an issue at",
2043
- " ",
2044
- WIZARD_ISSUES_URL,
2045
- " with details about your build setup."
2046
- ]
2047
- })
2048
- })
2049
- ]
2050
- })] });
2051
- }
2052
- case "no-posthog-sdk": {
2053
- const platformLabel = DISPLAY_NAME[error.platform] ?? error.platform;
2054
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Text, { children: [
2055
- "Detected ",
2056
- platformLabel,
2057
- " but no PostHog SDK is installed."
2058
- ] }), /* @__PURE__ */ jsxs(Box, {
2081
+ }),
2082
+ /* @__PURE__ */ jsx(BlockedSummary, { blocked }),
2083
+ /* @__PURE__ */ jsx(Box, {
2059
2084
  marginTop: 1,
2085
+ children: /* @__PURE__ */ jsx(PickerMenu, {
2086
+ options: [{
2087
+ label: "Exit",
2088
+ value: EXIT
2089
+ }],
2090
+ onSelect: () => process.exit(0)
2091
+ })
2092
+ })
2093
+ ]
2094
+ });
2095
+ const options = [...instrumentable.map((p) => ({
2096
+ label: projectLabel(p),
2097
+ value: p.path
2098
+ })), {
2099
+ label: "Cancel",
2100
+ value: EXIT
2101
+ }];
2102
+ return /* @__PURE__ */ jsxs(Box, {
2103
+ flexDirection: "column",
2104
+ children: [
2105
+ /* @__PURE__ */ jsx(Box, {
2060
2106
  flexDirection: "column",
2061
- children: [/* @__PURE__ */ jsxs(Text, {
2062
- dimColor: true,
2107
+ marginBottom: 1,
2108
+ children: /* @__PURE__ */ jsxs(Text, {
2109
+ bold: true,
2110
+ color: Colors.accent,
2063
2111
  children: [
2064
- "Source map upload only resolves stack traces from errors the SDK reports. Run ",
2065
- /* @__PURE__ */ jsx(Text, {
2066
- bold: true,
2067
- children: "npx @posthog/wizard"
2068
- }),
2069
- " first to install the SDK, then run this command again."
2112
+ Icons.check,
2113
+ " Found",
2114
+ " ",
2115
+ report.repoType === "monorepo" ? "a monorepo" : "your project"
2070
2116
  ]
2071
- }), /* @__PURE__ */ jsxs(Box, {
2072
- marginTop: 1,
2073
- flexDirection: "column",
2074
- children: [/* @__PURE__ */ jsxs(Text, {
2075
- dimColor: true,
2076
- children: [
2077
- "Set up source map upload for ",
2078
- platformLabel,
2079
- ":"
2080
- ]
2081
- }), /* @__PURE__ */ jsxs(Text, {
2082
- dimColor: true,
2083
- children: [" ", SOURCE_MAP_DOCS]
2084
- })]
2085
- })]
2086
- })] });
2087
- }
2088
- }
2117
+ })
2118
+ }),
2119
+ /* @__PURE__ */ jsx(PickerMenu, {
2120
+ message: "Which project would you like to set up source map uploads for?",
2121
+ options,
2122
+ onSelect: (value) => {
2123
+ const path = Array.isArray(value) ? value[0] : value;
2124
+ if (path === EXIT) {
2125
+ process.exit(0);
2126
+ return;
2127
+ }
2128
+ const chosen = instrumentable.find((p) => p.path === path);
2129
+ if (!chosen || !chosen.variant) return;
2130
+ store.setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.selectedVariant, chosen.variant);
2131
+ store.setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.selectedDisplayName, DISPLAY_NAME[chosen.variant]);
2132
+ store.setFrameworkContext(SOURCE_MAPS_CONTEXT_KEYS.selectedPath, chosen.path);
2133
+ }
2134
+ }),
2135
+ /* @__PURE__ */ jsx(Box, {
2136
+ marginTop: 1,
2137
+ children: /* @__PURE__ */ jsx(BlockedSummary, { blocked })
2138
+ })
2139
+ ]
2140
+ });
2141
+ };
2142
+ /**
2143
+ * Collapses the non-instrumentable projects into a short count line (or two)
2144
+ * instead of listing every one — a monorepo can have dozens.
2145
+ */
2146
+ const BlockedSummary = ({ blocked }) => {
2147
+ const unsupported = blocked.filter((p) => p.variant == null).length;
2148
+ const missingSdk = blocked.length - unsupported;
2149
+ if (blocked.length === 0) return null;
2150
+ return /* @__PURE__ */ jsxs(Box, {
2151
+ flexDirection: "column",
2152
+ children: [unsupported > 0 && /* @__PURE__ */ jsxs(Text, {
2153
+ dimColor: true,
2154
+ children: [
2155
+ "(… ",
2156
+ unsupported,
2157
+ " other project",
2158
+ unsupported === 1 ? "" : "s",
2159
+ " not supported)"
2160
+ ]
2161
+ }), missingSdk > 0 && /* @__PURE__ */ jsxs(Text, {
2162
+ dimColor: true,
2163
+ children: [
2164
+ "(… ",
2165
+ missingSdk,
2166
+ " supported but missing the PostHog SDK — install it first with `npx @posthog/wizard`)"
2167
+ ]
2168
+ })]
2169
+ });
2089
2170
  };
2090
2171
  //#endregion
2091
2172
  //#region src/ui/tui/screens/SourceMapsOutroScreen.tsx
@@ -4393,7 +4474,7 @@ function createMcpSuggestedPromptsServices(_store) {
4393
4474
  };
4394
4475
  }
4395
4476
  async function* runProductionPromptStreaming(args) {
4396
- const { runMcpPromptViaSdk } = await import("./mcp-prompt-streaming-Cxy0XPv4.js");
4477
+ const { runMcpPromptViaSdk } = await import("./mcp-prompt-streaming-BRoVSf3N.js");
4397
4478
  yield* runMcpPromptViaSdk(args);
4398
4479
  }
4399
4480
  //#endregion
@@ -4417,6 +4498,7 @@ function createScreens(store, services) {
4417
4498
  ["revenue-intro"]: /* @__PURE__ */ jsx(RevenueIntroScreen, { store }),
4418
4499
  ["warehouse-intro"]: /* @__PURE__ */ jsx(WarehouseIntroScreen, { store }),
4419
4500
  ["source-maps-intro"]: /* @__PURE__ */ jsx(SourceMapsIntroScreen, { store }),
4501
+ ["source-maps-detect"]: /* @__PURE__ */ jsx(SourceMapsDetectScreen, { store }),
4420
4502
  ["source-maps-outro"]: /* @__PURE__ */ jsx(SourceMapsOutroScreen, { store }),
4421
4503
  ["migration-intro"]: /* @__PURE__ */ jsx(MigrationIntroScreen, { store }),
4422
4504
  ["agent-skill-intro"]: /* @__PURE__ */ jsx(AgentSkillIntroScreen, { store }),
@@ -4500,6 +4582,7 @@ function startTUI(version, program = Program.PostHogIntegration) {
4500
4582
  store.version = version;
4501
4583
  setUI(new InkUI(store));
4502
4584
  const { unmount: inkUnmount, waitUntilExit } = render(createElement(App, { store }));
4585
+ analytics.setTag("program_id", program);
4503
4586
  analytics.wizardCapture("started", { program_id: program });
4504
4587
  store.runInitHooks();
4505
4588
  process.stdin.on("error", (err) => {
@@ -4528,4 +4611,4 @@ function startTUI(version, program = Program.PostHogIntegration) {
4528
4611
  //#endregion
4529
4612
  export { startTUI };
4530
4613
 
4531
- //# sourceMappingURL=start-tui-DetsuXHe.js.map
4614
+ //# sourceMappingURL=start-tui-Deaj99It.js.map