@posthog/wizard 1.23.0 → 1.25.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.
- package/README.md +37 -0
- package/dist/bin.js +38 -7
- package/dist/bin.js.map +1 -1
- package/dist/src/__tests__/cli.test.js +91 -0
- package/dist/src/__tests__/cli.test.js.map +1 -1
- package/dist/src/astro/astro-wizard.js +1 -0
- package/dist/src/astro/astro-wizard.js.map +1 -1
- package/dist/src/lib/agent-interface.js +7 -8
- package/dist/src/lib/agent-interface.js.map +1 -1
- package/dist/src/lib/agent-runner.d.ts +1 -1
- package/dist/src/lib/agent-runner.js +5 -3
- package/dist/src/lib/agent-runner.js.map +1 -1
- package/dist/src/lib/config.d.ts +12 -1
- package/dist/src/lib/config.js +22 -0
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/constants.d.ts +5 -1
- package/dist/src/lib/constants.js +8 -1
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/framework-config.d.ts +8 -6
- package/dist/src/lib/framework-config.js +12 -0
- package/dist/src/lib/framework-config.js.map +1 -1
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +215 -0
- package/dist/src/lib/safe-tools.js.map +1 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js +0 -3
- package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -1
- package/dist/src/react/react-wizard.js +1 -0
- package/dist/src/react/react-wizard.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +2 -3
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-router/react-router-wizard-agent.d.ts +5 -0
- package/dist/src/react-router/react-router-wizard-agent.js +151 -0
- package/dist/src/react-router/react-router-wizard-agent.js.map +1 -0
- package/dist/src/react-router/utils.d.ts +19 -0
- package/dist/src/react-router/utils.js +276 -0
- package/dist/src/react-router/utils.js.map +1 -0
- package/dist/src/run.d.ts +2 -0
- package/dist/src/run.js +17 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +2 -1
- package/dist/src/steps/add-mcp-server-to-clients/index.js +6 -1
- package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
- package/dist/src/svelte/svelte-wizard.js +1 -0
- package/dist/src/svelte/svelte-wizard.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +6 -4
- package/dist/src/utils/clack-utils.js +51 -6
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +8 -0
- package/dist/src/utils/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":";;;;;AAiCA,wCAsNC;AArPD,sDAU8B;AAC9B,kDAA+C;AAC/C,2CAA4D;AAC5D,2DAAmC;AACnC,uDAK2B;AAC3B,wCAAsD;AACtD,kDAA0B;AAC1B,oCAGkB;AAElB;;;GAGG;AACI,KAAK,UAAU,cAAc,CAClC,MAAuB,EACvB,OAAsB;IAEtB,cAAc;IACd,IAAA,0BAAY,EAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;IAEvD,eAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iFAAiF,MAAM,CAAC,QAAQ,CAAC,IAAI,qGAAqG,CAC3M,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAe,EAAC,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAA,mBAAK,EAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,MAAM,IAAA,+BAAiB,GAAE,CAAC,CAAC;IACvE,MAAM,kBAAkB,GAAG,IAAA,+BAAiB,E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,OAAO,CAAC,gBAAgB;gBAC/C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;qBAC5B,OAAO,CAAC,aAAa;kBACxB,OAAO,CAAC,IAAI,GAAG,iBAAiB;;;;;;mJAO9C,MAAM,CAAC,QAAQ,CAAC,IAClB;;;;;;EAMA,8BAAY,CAAC,iBAAiB;;;;EAI9B,8BAAY,CAAC,sBAAsB;;CAEpC,CAAC;AACF,CAAC","sourcesContent":["import type { FrameworkConfig } from './framework-config';\nimport type { WizardOptions } from '../utils/types';\nimport {\n abort,\n askForAIConsent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n isUsingTypeScript,\n printWelcome,\n askForCloudRegion,\n} from '../utils/clack-utils';\nimport { analytics } from '../utils/analytics';\nimport { WIZARD_INTERACTION_EVENT_NAME } from './constants';\nimport clack from '../utils/clack';\nimport {\n initializeAgent,\n runAgent,\n AgentSignals,\n AgentErrorType,\n} from './agent-interface';\nimport { getCloudUrlFromRegion } from '../utils/urls';\nimport chalk from 'chalk';\nimport {\n addMCPServerToClientsStep,\n uploadEnvironmentVariablesStep,\n} from '../steps';\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using PostHog MCP integration.\n */\nexport async function runAgentWizard(\n config: FrameworkConfig,\n options: WizardOptions,\n): Promise<void> {\n // Setup phase\n printWelcome({ wizardName: config.ui.welcomeMessage });\n\n clack.log.info(\n `🧙 The wizard has chosen you to try the next-generation agent integration for ${config.metadata.name}.\\n\\nStand by for the good stuff, and let the robot minders know how it goes:\\n\\nwizard@posthog.com`,\n );\n\n const aiConsent = await askForAIConsent(options);\n if (!aiConsent) {\n await abort(config.metadata.abortMessage, 0);\n }\n\n const cloudRegion = options.cloudRegion ?? (await askForCloudRegion());\n const typeScriptDetected = isUsingTypeScript(options);\n\n await confirmContinueIfNoOrDirtyGitRepo(options);\n\n // Framework detection and version\n const packageJson = await getPackageDotJson(options);\n await ensurePackageIsInstalled(\n packageJson,\n config.detection.packageName,\n config.detection.packageDisplayName,\n );\n\n const frameworkVersion = config.detection.getVersion(packageJson);\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'started agent integration',\n integration: config.metadata.integration,\n });\n\n // Get PostHog credentials\n const { projectApiKey, host, accessToken } = await getOrAskForProjectData({\n ...options,\n cloudRegion,\n });\n\n // Gather framework-specific context (e.g., Next.js router, React Native platform)\n const frameworkContext = config.metadata.gatherContext\n ? await config.metadata.gatherContext(options)\n : {};\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n // Build integration prompt\n const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n projectApiKey,\n host,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n const spinner = clack.spinner();\n\n // Determine MCP URL: CLI flag > env var > production default\n const mcpUrl = options.localMcp\n ? 'http://localhost:8787/mcp'\n : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';\n\n const agent = initializeAgent(\n {\n workingDirectory: options.installDir,\n posthogMcpUrl: mcpUrl,\n posthogApiKey: accessToken,\n posthogApiHost: host,\n },\n options,\n );\n\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n options,\n spinner,\n {\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n spinnerMessage: config.ui.spinnerMessage,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n },\n );\n\n // Handle error cases detected in agent output\n if (agentResult.error === AgentErrorType.MCP_MISSING) {\n analytics.captureException(\n new Error('Agent could not access PostHog MCP server'),\n {\n integration: config.metadata.integration,\n error_type: AgentErrorType.MCP_MISSING,\n signal: AgentSignals.ERROR_MCP_MISSING,\n },\n );\n\n const errorMessage = `\n${chalk.red('❌ Could not access the PostHog MCP server')}\n\nThe wizard was unable to connect to the PostHog MCP server.\nThis could be due to a network issue or a configuration problem.\n\nPlease try again, or set up ${\n config.metadata.name\n } manually by following our documentation:\n${chalk.cyan(config.metadata.docsUrl)}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n if (agentResult.error === AgentErrorType.RESOURCE_MISSING) {\n analytics.captureException(\n new Error('Agent could not access setup resource'),\n {\n integration: config.metadata.integration,\n error_type: AgentErrorType.RESOURCE_MISSING,\n signal: AgentSignals.ERROR_RESOURCE_MISSING,\n },\n );\n\n const errorMessage = `\n${chalk.red('❌ Could not access the setup resource')}\n\nThe wizard could not access the setup resource. This may indicate a version mismatch or a temporary service issue.\n\nPlease try again, or set up ${\n config.metadata.name\n } manually by following our documentation:\n${chalk.cyan(config.metadata.docsUrl)}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n // Build environment variables from OAuth credentials\n const envVars = config.environment.getEnvVars(projectApiKey, host);\n\n // Upload environment variables to hosting providers (if configured)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n options,\n });\n }\n\n // Add MCP server to clients\n await addMCPServerToClientsStep({\n cloudRegion,\n integration: config.metadata.integration,\n });\n\n // Build outro message\n const continueUrl = options.signup\n ? `${getCloudUrlFromRegion(cloudRegion)}/products?source=wizard`\n : undefined;\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0\n ? `Added environment variables to .env file`\n : '',\n uploadedEnvVars.length > 0\n ? `Uploaded environment variables to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const nextSteps = [\n ...config.ui.getOutroNextSteps(frameworkContext),\n uploadedEnvVars.length === 0 && config.environment.uploadToHosting\n ? `Upload your Project API key to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const outroMessage = `\n${chalk.green('Successfully installed PostHog!')}\n\n${chalk.cyan('What the agent did:')}\n${changes.map((change) => `• ${change}`).join('\\n')}\n\n${chalk.yellow('Next steps:')}\n${nextSteps.map((step) => `• ${step}`).join('\\n')}\n\nLearn more: ${chalk.cyan(config.metadata.docsUrl)}\n${continueUrl ? `\\nContinue onboarding: ${chalk.cyan(continueUrl)}\\n` : ``}\n${chalk.dim(\n 'Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made.',\n)}\n\n${chalk.dim(`How did this work for you? Drop us a line: wizard@posthog.com`)}`;\n\n clack.outro(outroMessage);\n\n await analytics.shutdown('success');\n}\n\n/**\n * Build the integration prompt for the agent.\n * Uses shared base prompt with optional framework-specific addendum.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n projectApiKey: string;\n host: string;\n },\n frameworkContext: Record<string, any>,\n): string {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0\n ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n')\n : '';\n\n return `You have access to the PostHog MCP server which provides an integration resource to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}\n- PostHog API Key: ${context.projectApiKey}\n- PostHog Host: ${context.host}${additionalContext}\n\nInstructions:\n\n1. Call the PostHog MCP's resource for setup: posthog://workflows/basic-integration/begin\n2. Follow all instructions provided; do package installation as soon as possible.\n3. Set up environment variables for PostHog in a .env file with the API key and host provided above, using the appropriate naming convention for ${\n config.metadata.name\n }. Make sure to use these environment variables in the code files you create instead of hardcoding the API key and host.\n\nThe PostHog MCP will provide specific integration code and instructions. Please follow them carefully. Be sure to look for lockfiles to determine the appropriate package manager to use when installing PostHog. Do not manually edit the package.json file.\n\nBefore beginning, confirm that you can access the PostHog MCP. If the PostHog MCP is not accessible, emit the following string:\n\n${AgentSignals.ERROR_MCP_MISSING} Could not access the PostHog MCP.\n\nIf the PostHog MCP is accessible, attempt to access the setup resource. If the setup resource is not accessible, emit the following string:\n\n${AgentSignals.ERROR_RESOURCE_MISSING} Could not access the setup resource.\n\n`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":";;;;;AAqCA,wCA0NC;AA/PD,yDAI4B;AAE5B,sDAU8B;AAC9B,kDAA+C;AAC/C,2CAA4D;AAC5D,2DAAmC;AACnC,uDAK2B;AAC3B,wCAAsD;AACtD,kDAA0B;AAC1B,oCAGkB;AAElB;;;GAGG;AACI,KAAK,UAAU,cAAc,CAClC,MAAuB,EACvB,OAAsB;IAEtB,cAAc;IACd,IAAA,0BAAY,EAAC,EAAE,UAAU,EAAE,IAAA,oCAAiB,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtE,eAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iFAAiF,MAAM,CAAC,QAAQ,CAAC,IAAI,qGAAqG,CAC3M,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAe,EAAC,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAA,mBAAK,EACT,sGAAsG,MAAM,CAAC,QAAQ,CAAC,IAAI,sBAAsB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EACzK,CAAC,CACF,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,MAAM,IAAA,+BAAiB,GAAE,CAAC,CAAC;IACvE,MAAM,kBAAkB,GAAG,IAAA,+BAAiB,EAAC,OA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,IAAI,OAAO,CAAC,gBAAgB;gBAC/C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;qBAC5B,OAAO,CAAC,aAAa;kBACxB,OAAO,CAAC,IAAI,GAAG,iBAAiB;;;;;;mJAO9C,MAAM,CAAC,QAAQ,CAAC,IAClB;;;;;;EAMA,8BAAY,CAAC,iBAAiB;;;;EAI9B,8BAAY,CAAC,sBAAsB;;CAEpC,CAAC;AACF,CAAC","sourcesContent":["import {\n getWelcomeMessage,\n SPINNER_MESSAGE,\n type FrameworkConfig,\n} from './framework-config';\nimport type { WizardOptions } from '../utils/types';\nimport {\n abort,\n askForAIConsent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n isUsingTypeScript,\n printWelcome,\n askForCloudRegion,\n} from '../utils/clack-utils';\nimport { analytics } from '../utils/analytics';\nimport { WIZARD_INTERACTION_EVENT_NAME } from './constants';\nimport clack from '../utils/clack';\nimport {\n initializeAgent,\n runAgent,\n AgentSignals,\n AgentErrorType,\n} from './agent-interface';\nimport { getCloudUrlFromRegion } from '../utils/urls';\nimport chalk from 'chalk';\nimport {\n addMCPServerToClientsStep,\n uploadEnvironmentVariablesStep,\n} from '../steps';\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using PostHog MCP integration.\n */\nexport async function runAgentWizard(\n config: FrameworkConfig,\n options: WizardOptions,\n): Promise<void> {\n // Setup phase\n printWelcome({ wizardName: getWelcomeMessage(config.metadata.name) });\n\n clack.log.info(\n `🧙 The wizard has chosen you to try the next-generation agent integration for ${config.metadata.name}.\\n\\nStand by for the good stuff, and let the robot minders know how it goes:\\n\\nwizard@posthog.com`,\n );\n\n const aiConsent = await askForAIConsent(options);\n if (!aiConsent) {\n await abort(\n `This wizard uses an LLM agent to intelligently modify your project. Please view the docs to set up ${config.metadata.name} manually instead: ${config.metadata.docsUrl}`,\n 0,\n );\n }\n\n const cloudRegion = options.cloudRegion ?? (await askForCloudRegion());\n const typeScriptDetected = isUsingTypeScript(options);\n\n await confirmContinueIfNoOrDirtyGitRepo(options);\n\n // Framework detection and version\n const packageJson = await getPackageDotJson(options);\n await ensurePackageIsInstalled(\n packageJson,\n config.detection.packageName,\n config.detection.packageDisplayName,\n );\n\n const frameworkVersion = config.detection.getVersion(packageJson);\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'started agent integration',\n integration: config.metadata.integration,\n });\n\n // Get PostHog credentials\n const { projectApiKey, host, accessToken } = await getOrAskForProjectData({\n ...options,\n cloudRegion,\n });\n\n // Gather framework-specific context (e.g., Next.js router, React Native platform)\n const frameworkContext = config.metadata.gatherContext\n ? await config.metadata.gatherContext(options)\n : {};\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n // Build integration prompt\n const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n projectApiKey,\n host,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n const spinner = clack.spinner();\n\n // Determine MCP URL: CLI flag > env var > production default\n const mcpUrl = options.localMcp\n ? 'http://localhost:8787/mcp'\n : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';\n\n const agent = initializeAgent(\n {\n workingDirectory: options.installDir,\n posthogMcpUrl: mcpUrl,\n posthogApiKey: accessToken,\n posthogApiHost: host,\n },\n options,\n );\n\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n options,\n spinner,\n {\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n },\n );\n\n // Handle error cases detected in agent output\n if (agentResult.error === AgentErrorType.MCP_MISSING) {\n analytics.captureException(\n new Error('Agent could not access PostHog MCP server'),\n {\n integration: config.metadata.integration,\n error_type: AgentErrorType.MCP_MISSING,\n signal: AgentSignals.ERROR_MCP_MISSING,\n },\n );\n\n const errorMessage = `\n${chalk.red('❌ Could not access the PostHog MCP server')}\n\nThe wizard was unable to connect to the PostHog MCP server.\nThis could be due to a network issue or a configuration problem.\n\nPlease try again, or set up ${\n config.metadata.name\n } manually by following our documentation:\n${chalk.cyan(config.metadata.docsUrl)}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n if (agentResult.error === AgentErrorType.RESOURCE_MISSING) {\n analytics.captureException(\n new Error('Agent could not access setup resource'),\n {\n integration: config.metadata.integration,\n error_type: AgentErrorType.RESOURCE_MISSING,\n signal: AgentSignals.ERROR_RESOURCE_MISSING,\n },\n );\n\n const errorMessage = `\n${chalk.red('❌ Could not access the setup resource')}\n\nThe wizard could not access the setup resource. This may indicate a version mismatch or a temporary service issue.\n\nPlease try again, or set up ${\n config.metadata.name\n } manually by following our documentation:\n${chalk.cyan(config.metadata.docsUrl)}`;\n\n clack.outro(errorMessage);\n await analytics.shutdown('error');\n process.exit(1);\n }\n\n // Build environment variables from OAuth credentials\n const envVars = config.environment.getEnvVars(projectApiKey, host);\n\n // Upload environment variables to hosting providers (if configured)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n options,\n });\n }\n\n // Add MCP server to clients\n await addMCPServerToClientsStep({\n cloudRegion,\n integration: config.metadata.integration,\n ci: options.ci,\n });\n\n // Build outro message\n const continueUrl = options.signup\n ? `${getCloudUrlFromRegion(cloudRegion)}/products?source=wizard`\n : undefined;\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0\n ? `Added environment variables to .env file`\n : '',\n uploadedEnvVars.length > 0\n ? `Uploaded environment variables to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const nextSteps = [\n ...config.ui.getOutroNextSteps(frameworkContext),\n uploadedEnvVars.length === 0 && config.environment.uploadToHosting\n ? `Upload your Project API key to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const outroMessage = `\n${chalk.green('Successfully installed PostHog!')}\n\n${chalk.cyan('What the agent did:')}\n${changes.map((change) => `• ${change}`).join('\\n')}\n\n${chalk.yellow('Next steps:')}\n${nextSteps.map((step) => `• ${step}`).join('\\n')}\n\nLearn more: ${chalk.cyan(config.metadata.docsUrl)}\n${continueUrl ? `\\nContinue onboarding: ${chalk.cyan(continueUrl)}\\n` : ``}\n${chalk.dim(\n 'Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made.',\n)}\n\n${chalk.dim(`How did this work for you? Drop us a line: wizard@posthog.com`)}`;\n\n clack.outro(outroMessage);\n\n await analytics.shutdown('success');\n}\n\n/**\n * Build the integration prompt for the agent.\n * Uses shared base prompt with optional framework-specific addendum.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n projectApiKey: string;\n host: string;\n },\n frameworkContext: Record<string, any>,\n): string {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0\n ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n')\n : '';\n\n return `You have access to the PostHog MCP server which provides an integration resource to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}\n- PostHog API Key: ${context.projectApiKey}\n- PostHog Host: ${context.host}${additionalContext}\n\nInstructions:\n\n1. Call the PostHog MCP's resource for setup: posthog://workflows/basic-integration/begin\n2. Follow all instructions provided; do package installation as soon as possible.\n3. Set up environment variables for PostHog in a .env file with the API key and host provided above, using the appropriate naming convention for ${\n config.metadata.name\n }. Make sure to use these environment variables in the code files you create instead of hardcoding the API key and host.\n\nThe PostHog MCP will provide specific integration code and instructions. Please follow them carefully. Be sure to look for lockfiles to determine the appropriate package manager to use when installing PostHog. Do not manually edit the package.json file.\n\nBefore beginning, confirm that you can access the PostHog MCP. If the PostHog MCP is not accessible, emit the following string:\n\n${AgentSignals.ERROR_MCP_MISSING} Could not access the PostHog MCP.\n\nIf the PostHog MCP is accessible, attempt to access the setup resource. If the setup resource is not accessible, emit the following string:\n\n${AgentSignals.ERROR_RESOURCE_MISSING} Could not access the setup resource.\n\n`;\n}\n"]}
|
package/dist/src/lib/config.d.ts
CHANGED
|
@@ -56,5 +56,16 @@ export declare const INTEGRATION_CONFIG: {
|
|
|
56
56
|
readonly defaultChanges: "• Added PostHog component with initialization script\n• Created PostHogLayout for consistent analytics tracking";
|
|
57
57
|
readonly nextSteps: "• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app\n• Use posthog.isFeatureEnabled() for feature flags";
|
|
58
58
|
};
|
|
59
|
+
readonly "react-router": {
|
|
60
|
+
readonly name: "React Router";
|
|
61
|
+
readonly filterPatterns: ["**/*.{tsx,ts,jsx,js}"];
|
|
62
|
+
readonly ignorePatterns: ["node_modules", "dist", "build", "public", "static", "assets"];
|
|
63
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
|
|
64
|
+
readonly generateFilesRules: "";
|
|
65
|
+
readonly filterFilesRules: "";
|
|
66
|
+
readonly docsUrl: "https://posthog-git-react-post-hog.vercel.app/docs/libraries/react-router";
|
|
67
|
+
readonly defaultChanges: "• Installed posthog-js package\n• Added PostHogProvider to the root of the app\n• Integrated PostHog with React Router for pageview tracking";
|
|
68
|
+
readonly nextSteps: "• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app";
|
|
69
|
+
};
|
|
59
70
|
};
|
|
60
|
-
export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.astro, Integration.svelte, Integration.reactNative, Integration.react];
|
|
71
|
+
export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.astro, Integration.svelte, Integration.reactNative, Integration.reactRouter, Integration.react];
|
package/dist/src/lib/config.js
CHANGED
|
@@ -89,12 +89,34 @@ exports.INTEGRATION_CONFIG = {
|
|
|
89
89
|
defaultChanges: '• Added PostHog component with initialization script\n• Created PostHogLayout for consistent analytics tracking',
|
|
90
90
|
nextSteps: '• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app\n• Use posthog.isFeatureEnabled() for feature flags',
|
|
91
91
|
},
|
|
92
|
+
[constants_1.Integration.reactRouter]: {
|
|
93
|
+
name: 'React Router',
|
|
94
|
+
filterPatterns: ['**/*.{tsx,ts,jsx,js}'],
|
|
95
|
+
ignorePatterns: [
|
|
96
|
+
'node_modules',
|
|
97
|
+
'dist',
|
|
98
|
+
'build',
|
|
99
|
+
'public',
|
|
100
|
+
'static',
|
|
101
|
+
'assets',
|
|
102
|
+
],
|
|
103
|
+
detect: async (options) => {
|
|
104
|
+
const packageJson = await (0, clack_utils_1.getPackageDotJson)(options);
|
|
105
|
+
return (0, package_json_1.hasPackageInstalled)('react-router', packageJson);
|
|
106
|
+
},
|
|
107
|
+
generateFilesRules: '',
|
|
108
|
+
filterFilesRules: '',
|
|
109
|
+
docsUrl: 'https://posthog-git-react-post-hog.vercel.app/docs/libraries/react-router',
|
|
110
|
+
defaultChanges: '• Installed posthog-js package\n• Added PostHogProvider to the root of the app\n• Integrated PostHog with React Router for pageview tracking',
|
|
111
|
+
nextSteps: '• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app',
|
|
112
|
+
},
|
|
92
113
|
};
|
|
93
114
|
exports.INTEGRATION_ORDER = [
|
|
94
115
|
constants_1.Integration.nextjs,
|
|
95
116
|
constants_1.Integration.astro,
|
|
96
117
|
constants_1.Integration.svelte,
|
|
97
118
|
constants_1.Integration.reactNative,
|
|
119
|
+
constants_1.Integration.reactRouter,
|
|
98
120
|
constants_1.Integration.react,
|
|
99
121
|
];
|
|
100
122
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":";;;AAAA,sDAAyD;AACzD,wDAA4D;AAE5D,2CAA0C;AAc7B,QAAA,kBAAkB,GAAG;IAChC,CAAC,uBAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,CAAC,8BAA8B,CAAC;QAChD,cAAc,EAAE;YACd,cAAc;YACd,MAAM;YACN,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,cAAc;SACf;QACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAClD,CAAC;QACD,kBAAkB,EAAE,EAAE;QACtB,gBAAgB,EAAE,EAAE;QACpB,OAAO,EAAE,4CAA4C;QACrD,cAAc,EACZ,mOAAmO;QACrO,SAAS,EACP,0HAA0H;KAC7H;IACD,CAAC,uBAAW,CAAC,KAAK,CAAC,EAAE;QACnB,IAAI,EAAE,OAAO;QACb,cAAc,EAAE,CAAC,sBAAsB,CAAC;QACxC,cAAc,EAAE;YACd,cAAc;YACd,MAAM;YACN,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,QAAQ;SACT;QACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;QACD,kBAAkB,EAAE,EAAE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Ac,EAAE,CAAC,4BAA4B,CAAC;QAC9C,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACrE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;QACD,kBAAkB,EAAE,EAAE;QACtB,gBAAgB,EAAE,EAAE;QACpB,OAAO,EAAE,uCAAuC;QAChD,cAAc,EACZ,iHAAiH;QACnH,SAAS,EACP,8KAA8K;KACjL;CACwD,CAAC;AAE/C,QAAA,iBAAiB,GAAG;IAC/B,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,KAAK;IACjB,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,WAAW;IACvB,uBAAW,CAAC,KAAK;CACT,CAAC","sourcesContent":["import { getPackageDotJson } from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { Integration } from './constants';\n\ntype IntegrationConfig = {\n name: string;\n filterPatterns: string[];\n ignorePatterns: string[];\n detect: (options: Pick<WizardOptions, 'installDir'>) => Promise<boolean>;\n generateFilesRules: string;\n filterFilesRules: string;\n docsUrl: string;\n nextSteps: string;\n defaultChanges: string;\n};\n\nexport const INTEGRATION_CONFIG = {\n [Integration.nextjs]: {\n name: 'Next.js',\n filterPatterns: ['**/*.{tsx,ts,jsx,js,mjs,cjs}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'next-env.d.*',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('next', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/next-js',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Initialized PostHog and added pageview tracking\\n• Created a PostHogClient to use PostHog server-side\\n• Setup a reverse proxy to avoid ad blockers blocking analytics requests',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.react]: {\n name: 'React',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'assets',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app, to initialize PostHog and enable autocapture',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.svelte]: {\n name: 'Svelte',\n filterPatterns: ['**/*.{svelte,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('@sveltejs/kit', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/svelte',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Added PostHog initialization to your Svelte app\\n• Setup pageview & pageleave tracking\\n• Setup event auto - capture to capture events as users interact with your app\\n• Added a getPostHogClient() function to use PostHog server-side',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Use getPostHogClient() to start capturing events server - side',\n },\n [Integration.reactNative]: {\n name: 'React Native',\n filterPatterns: ['**/*.{ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react-native', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react-native',\n defaultChanges:\n '• Installed required packages\\n• Added PostHogProvider to the root of the app\\n• Enabled autocapture and session replay',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.astro]: {\n name: 'Astro',\n filterPatterns: ['**/*.{astro,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('astro', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/js',\n defaultChanges:\n '• Added PostHog component with initialization script\\n• Created PostHogLayout for consistent analytics tracking',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app\\n• Use posthog.isFeatureEnabled() for feature flags',\n },\n} as const satisfies Record<Integration, IntegrationConfig>;\n\nexport const INTEGRATION_ORDER = [\n Integration.nextjs,\n Integration.astro,\n Integration.svelte,\n Integration.reactNative,\n Integration.react,\n] as const;\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":";;;AAAA,sDAAyD;AACzD,wDAA4D;AAE5D,2CAA0C;AAc7B,QAAA,kBAAkB,GAAG;IAChC,CAAC,uBAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,CAAC,8BAA8B,CAAC;QAChD,cAAc,EAAE;YACd,cAAc;YACd,MAAM;YACN,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,cAAc;SACf;QACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAClD,CAAC;QACD,kBAAkB,EAAE,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,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAC1D,CAAC;QACD,kBAAkB,EAAE,EAAE;QACtB,gBAAgB,EAAE,EAAE;QACpB,OAAO,EACL,2EAA2E;QAC7E,cAAc,EACZ,8IAA8I;QAChJ,SAAS,EACP,0HAA0H;KAC7H;CACwD,CAAC;AAE/C,QAAA,iBAAiB,GAAG;IAC/B,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,KAAK;IACjB,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,WAAW;IACvB,uBAAW,CAAC,WAAW;IACvB,uBAAW,CAAC,KAAK;CACT,CAAC","sourcesContent":["import { getPackageDotJson } from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { Integration } from './constants';\n\ntype IntegrationConfig = {\n name: string;\n filterPatterns: string[];\n ignorePatterns: string[];\n detect: (options: Pick<WizardOptions, 'installDir'>) => Promise<boolean>;\n generateFilesRules: string;\n filterFilesRules: string;\n docsUrl: string;\n nextSteps: string;\n defaultChanges: string;\n};\n\nexport const INTEGRATION_CONFIG = {\n [Integration.nextjs]: {\n name: 'Next.js',\n filterPatterns: ['**/*.{tsx,ts,jsx,js,mjs,cjs}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'next-env.d.*',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('next', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/next-js',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Initialized PostHog and added pageview tracking\\n• Created a PostHogClient to use PostHog server-side\\n• Setup a reverse proxy to avoid ad blockers blocking analytics requests',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.react]: {\n name: 'React',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'assets',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app, to initialize PostHog and enable autocapture',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.svelte]: {\n name: 'Svelte',\n filterPatterns: ['**/*.{svelte,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('@sveltejs/kit', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/svelte',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Added PostHog initialization to your Svelte app\\n• Setup pageview & pageleave tracking\\n• Setup event auto - capture to capture events as users interact with your app\\n• Added a getPostHogClient() function to use PostHog server-side',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Use getPostHogClient() to start capturing events server - side',\n },\n [Integration.reactNative]: {\n name: 'React Native',\n filterPatterns: ['**/*.{ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react-native', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react-native',\n defaultChanges:\n '• Installed required packages\\n• Added PostHogProvider to the root of the app\\n• Enabled autocapture and session replay',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.astro]: {\n name: 'Astro',\n filterPatterns: ['**/*.{astro,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('astro', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/js',\n defaultChanges:\n '• Added PostHog component with initialization script\\n• Created PostHogLayout for consistent analytics tracking',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app\\n• Use posthog.isFeatureEnabled() for feature flags',\n },\n [Integration.reactRouter]: {\n name: 'React Router',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'assets',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react-router', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl:\n 'https://posthog-git-react-post-hog.vercel.app/docs/libraries/react-router',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app\\n• Integrated PostHog with React Router for pageview tracking',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n} as const satisfies Record<Integration, IntegrationConfig>;\n\nexport const INTEGRATION_ORDER = [\n Integration.nextjs,\n Integration.astro,\n Integration.svelte,\n Integration.reactNative,\n Integration.reactRouter,\n Integration.react,\n] as const;\n"]}
|
|
@@ -3,7 +3,11 @@ export declare enum Integration {
|
|
|
3
3
|
react = "react",
|
|
4
4
|
svelte = "svelte",
|
|
5
5
|
reactNative = "react-native",
|
|
6
|
-
astro = "astro"
|
|
6
|
+
astro = "astro",
|
|
7
|
+
reactRouter = "react-router"
|
|
8
|
+
}
|
|
9
|
+
export declare enum FeatureFlagDefinition {
|
|
10
|
+
ReactRouter = "wizard-react-router"
|
|
7
11
|
}
|
|
8
12
|
export declare function getIntegrationDescription(type: string): string;
|
|
9
13
|
type IntegrationChoice = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WIZARD_INTERACTION_EVENT_NAME = exports.OAUTH_PORT = exports.POSTHOG_DEV_CLIENT_ID = exports.POSTHOG_EU_CLIENT_ID = exports.POSTHOG_US_CLIENT_ID = exports.DUMMY_PROJECT_API_KEY = exports.ANALYTICS_TEAM_TAG = exports.ANALYTICS_HOST_URL = exports.ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = exports.DEFAULT_HOST_URL = exports.ISSUES_URL = exports.DEFAULT_URL = exports.DEBUG = exports.IS_DEV = exports.Integration = void 0;
|
|
3
|
+
exports.WIZARD_INTERACTION_EVENT_NAME = exports.OAUTH_PORT = exports.POSTHOG_DEV_CLIENT_ID = exports.POSTHOG_EU_CLIENT_ID = exports.POSTHOG_US_CLIENT_ID = exports.DUMMY_PROJECT_API_KEY = exports.ANALYTICS_TEAM_TAG = exports.ANALYTICS_HOST_URL = exports.ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = exports.DEFAULT_HOST_URL = exports.ISSUES_URL = exports.DEFAULT_URL = exports.DEBUG = exports.IS_DEV = exports.FeatureFlagDefinition = exports.Integration = void 0;
|
|
4
4
|
exports.getIntegrationDescription = getIntegrationDescription;
|
|
5
5
|
exports.getIntegrationChoices = getIntegrationChoices;
|
|
6
6
|
var Integration;
|
|
@@ -10,7 +10,12 @@ var Integration;
|
|
|
10
10
|
Integration["svelte"] = "svelte";
|
|
11
11
|
Integration["reactNative"] = "react-native";
|
|
12
12
|
Integration["astro"] = "astro";
|
|
13
|
+
Integration["reactRouter"] = "react-router";
|
|
13
14
|
})(Integration || (exports.Integration = Integration = {}));
|
|
15
|
+
var FeatureFlagDefinition;
|
|
16
|
+
(function (FeatureFlagDefinition) {
|
|
17
|
+
FeatureFlagDefinition["ReactRouter"] = "wizard-react-router";
|
|
18
|
+
})(FeatureFlagDefinition || (exports.FeatureFlagDefinition = FeatureFlagDefinition = {}));
|
|
14
19
|
function getIntegrationDescription(type) {
|
|
15
20
|
switch (type) {
|
|
16
21
|
case Integration.nextjs:
|
|
@@ -23,6 +28,8 @@ function getIntegrationDescription(type) {
|
|
|
23
28
|
return 'Svelte';
|
|
24
29
|
case Integration.astro:
|
|
25
30
|
return 'Astro';
|
|
31
|
+
case Integration.reactRouter:
|
|
32
|
+
return 'React Router';
|
|
26
33
|
default:
|
|
27
34
|
throw new Error(`Unknown integration ${type}`);
|
|
28
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAaA,8DAiBC;AAOD,sDAKC;AA1CD,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,gCAAiB,CAAA;IACjB,2CAA4B,CAAA;IAC5B,8BAAe,CAAA;IACf,2CAA4B,CAAA;AAC9B,CAAC,EAPW,WAAW,2BAAX,WAAW,QAOtB;AAED,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC/B,4DAAmC,CAAA;AACrC,CAAC,EAFW,qBAAqB,qCAArB,qBAAqB,QAEhC;AAED,SAAgB,yBAAyB,CAAC,IAAY;IACpD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW,CAAC,MAAM;YACrB,OAAO,SAAS,CAAC;QACnB,KAAK,WAAW,CAAC,KAAK;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,WAAW,CAAC,WAAW;YAC1B,OAAO,cAAc,CAAC;QACxB,KAAK,WAAW,CAAC,MAAM;YACrB,OAAO,QAAQ,CAAC;QAClB,KAAK,WAAW,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-native',\n astro = 'astro',\n reactRouter = 'react-router',\n}\n\nexport enum FeatureFlagDefinition {\n ReactRouter = 'wizard-react-router',\n}\n\nexport function getIntegrationDescription(type: string): string {\n switch (type) {\n case Integration.nextjs:\n return 'Next.js';\n case Integration.react:\n return 'React';\n case Integration.reactNative:\n return 'React Native';\n case Integration.svelte:\n return 'Svelte';\n case Integration.astro:\n return 'Astro';\n case Integration.reactRouter:\n return 'React Router';\n default:\n throw new Error(`Unknown integration ${type}`);\n }\n}\n\ntype IntegrationChoice = {\n name: string;\n value: string;\n};\n\nexport function getIntegrationChoices(): IntegrationChoice[] {\n return Object.keys(Integration).map((type: string) => ({\n name: getIntegrationDescription(type),\n value: type,\n }));\n}\n\nexport interface Args {\n debug: boolean;\n integration: Integration;\n}\n\nexport const IS_DEV = ['test', 'development'].includes(\n process.env.NODE_ENV ?? '',\n);\n\nexport const DEBUG = false;\n\nexport const DEFAULT_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.posthog.com';\nexport const ISSUES_URL = 'https://github.com/posthog/wizard/issues';\nexport const DEFAULT_HOST_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.i.posthog.com';\nexport const ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = 'sTMFPsFhdP1Ssg';\nexport const ANALYTICS_HOST_URL = 'https://internal-j.posthog.com';\nexport const ANALYTICS_TEAM_TAG = 'docs-and-wizard';\nexport const DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';\n\nexport const POSTHOG_US_CLIENT_ID = 'c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM';\nexport const POSTHOG_EU_CLIENT_ID = 'bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy';\nexport const POSTHOG_DEV_CLIENT_ID = 'DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ';\nexport const OAUTH_PORT = 8239;\n\nexport const WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction';\n"]}
|
|
@@ -22,8 +22,6 @@ export interface FrameworkMetadata {
|
|
|
22
22
|
integration: Integration;
|
|
23
23
|
/** URL to framework-specific PostHog docs */
|
|
24
24
|
docsUrl: string;
|
|
25
|
-
/** Message shown when user declines AI consent */
|
|
26
|
-
abortMessage: string;
|
|
27
25
|
/**
|
|
28
26
|
* Optional URL to docs for users with unsupported framework versions.
|
|
29
27
|
* If not provided, defaults to docsUrl.
|
|
@@ -85,10 +83,6 @@ export interface PromptConfig {
|
|
|
85
83
|
* UI messaging configuration
|
|
86
84
|
*/
|
|
87
85
|
export interface UIConfig {
|
|
88
|
-
/** Welcome message for wizard start */
|
|
89
|
-
welcomeMessage: string;
|
|
90
|
-
/** Spinner message while agent runs */
|
|
91
|
-
spinnerMessage: string;
|
|
92
86
|
/** Success message when agent completes */
|
|
93
87
|
successMessage: string;
|
|
94
88
|
/** Estimated time for agent to complete (in minutes) */
|
|
@@ -98,3 +92,11 @@ export interface UIConfig {
|
|
|
98
92
|
/** Generate "Next steps" bullets from context */
|
|
99
93
|
getOutroNextSteps: (context: any) => string[];
|
|
100
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Generate welcome message from framework name
|
|
97
|
+
*/
|
|
98
|
+
export declare function getWelcomeMessage(frameworkName: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Shared spinner message for all frameworks
|
|
101
|
+
*/
|
|
102
|
+
export declare const SPINNER_MESSAGE = "Writing your PostHog setup with events, error capture and more...";
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SPINNER_MESSAGE = void 0;
|
|
4
|
+
exports.getWelcomeMessage = getWelcomeMessage;
|
|
5
|
+
/**
|
|
6
|
+
* Generate welcome message from framework name
|
|
7
|
+
*/
|
|
8
|
+
function getWelcomeMessage(frameworkName) {
|
|
9
|
+
return `PostHog ${frameworkName} wizard (agent-powered)`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Shared spinner message for all frameworks
|
|
13
|
+
*/
|
|
14
|
+
exports.SPINNER_MESSAGE = 'Writing your PostHog setup with events, error capture and more...';
|
|
3
15
|
//# sourceMappingURL=framework-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-config.js","sourceRoot":"","sources":["../../../src/lib/framework-config.ts"],"names":[],"mappings":"","sourcesContent":["import type { Integration } from './constants';\nimport type { WizardOptions } from '../utils/types';\n\n/**\n * Configuration interface for framework-specific agent integrations.\n * Each framework exports a FrameworkConfig that the universal runner uses.\n */\nexport interface FrameworkConfig {\n metadata: FrameworkMetadata;\n detection: FrameworkDetection;\n environment: EnvironmentConfig;\n analytics: AnalyticsConfig;\n prompts: PromptConfig;\n ui: UIConfig;\n}\n\n/**\n * Basic framework information and documentation\n */\nexport interface FrameworkMetadata {\n /** Display name (e.g., \"Next.js\", \"React\") */\n name: string;\n\n /** Integration type from constants */\n integration: Integration;\n\n /** URL to framework-specific PostHog docs */\n docsUrl: string;\n\n
|
|
1
|
+
{"version":3,"file":"framework-config.js","sourceRoot":"","sources":["../../../src/lib/framework-config.ts"],"names":[],"mappings":";;;AAqHA,8CAEC;AALD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,aAAqB;IACrD,OAAO,WAAW,aAAa,yBAAyB,CAAC;AAC3D,CAAC;AAED;;GAEG;AACU,QAAA,eAAe,GAC1B,mEAAmE,CAAC","sourcesContent":["import type { Integration } from './constants';\nimport type { WizardOptions } from '../utils/types';\n\n/**\n * Configuration interface for framework-specific agent integrations.\n * Each framework exports a FrameworkConfig that the universal runner uses.\n */\nexport interface FrameworkConfig {\n metadata: FrameworkMetadata;\n detection: FrameworkDetection;\n environment: EnvironmentConfig;\n analytics: AnalyticsConfig;\n prompts: PromptConfig;\n ui: UIConfig;\n}\n\n/**\n * Basic framework information and documentation\n */\nexport interface FrameworkMetadata {\n /** Display name (e.g., \"Next.js\", \"React\") */\n name: string;\n\n /** Integration type from constants */\n integration: Integration;\n\n /** URL to framework-specific PostHog docs */\n docsUrl: string;\n\n /**\n * Optional URL to docs for users with unsupported framework versions.\n * If not provided, defaults to docsUrl.\n */\n unsupportedVersionDocsUrl?: string;\n\n /**\n * Optional function to gather framework-specific context before agent runs.\n * For Next.js: detects router type\n * For React Native: detects Expo vs bare\n */\n gatherContext?: (options: WizardOptions) => Promise<Record<string, any>>;\n}\n\n/**\n * Framework detection and version handling\n */\nexport interface FrameworkDetection {\n /** Package name to check in package.json (e.g., \"next\", \"react\") */\n packageName: string;\n\n /** Human-readable name for error messages (e.g., \"Next.js\") */\n packageDisplayName: string;\n\n /** Extract version from package.json */\n getVersion: (packageJson: any) => string | undefined;\n\n /** Optional: Convert version to analytics bucket (e.g., \"15.x\") */\n getVersionBucket?: (version: string) => string;\n}\n\n/**\n * Environment variable configuration\n */\nexport interface EnvironmentConfig {\n /** Whether to upload env vars to hosting providers post-agent */\n uploadToHosting: boolean;\n\n /**\n * Build the environment variables object for this framework.\n * Returns the exact variable names and values to upload to hosting providers.\n */\n getEnvVars: (apiKey: string, host: string) => Record<string, string>;\n}\n\n/**\n * Analytics configuration\n */\nexport interface AnalyticsConfig {\n /** Generate tags from context (e.g., { 'nextjs-version': '15.x', 'router': 'app' }) */\n getTags: (context: any) => Record<string, any>;\n\n /** Optional: Additional event properties */\n getEventProperties?: (context: any) => Record<string, any>;\n}\n\n/**\n * Prompt configuration\n */\nexport interface PromptConfig {\n /**\n * Optional: Additional context lines to append to base prompt\n * For Next.js: \"- Router: app\"\n * For React Native: \"- Platform: Expo\"\n */\n getAdditionalContextLines?: (context: any) => string[];\n}\n\n/**\n * UI messaging configuration\n */\nexport interface UIConfig {\n /** Success message when agent completes */\n successMessage: string;\n\n /** Estimated time for agent to complete (in minutes) */\n estimatedDurationMinutes: number;\n\n /** Generate \"What the agent did\" bullets from context */\n getOutroChanges: (context: any) => string[];\n\n /** Generate \"Next steps\" bullets from context */\n getOutroNextSteps: (context: any) => string[];\n}\n\n/**\n * Generate welcome message from framework name\n */\nexport function getWelcomeMessage(frameworkName: string): string {\n return `PostHog ${frameworkName} wizard (agent-powered)`;\n}\n\n/**\n * Shared spinner message for all frameworks\n */\nexport const SPINNER_MESSAGE =\n 'Writing your PostHog setup with events, error capture and more...';\n"]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LINTING_TOOLS = void 0;
|
|
4
|
+
exports.LINTING_TOOLS = [
|
|
5
|
+
// All (general purpose)
|
|
6
|
+
'codespell',
|
|
7
|
+
'cspell',
|
|
8
|
+
'git-diff-check',
|
|
9
|
+
'gitleaks',
|
|
10
|
+
'trufflehog',
|
|
11
|
+
// Amazon States Language
|
|
12
|
+
'asl-validator',
|
|
13
|
+
// Ansible
|
|
14
|
+
'ansible-lint',
|
|
15
|
+
// Apex, Java
|
|
16
|
+
'pmd',
|
|
17
|
+
// Astro, CSS, GraphQL, GritQL, HTML, JavaScript, JSON, JSONC, JSON5, JSX, TSX, Svelte, TypeScript, Vue
|
|
18
|
+
'biome',
|
|
19
|
+
// AWS CloudFormation templates
|
|
20
|
+
'cfn-lint',
|
|
21
|
+
'cfnlint',
|
|
22
|
+
// AWS CloudFormation, Azure ARM, Dockerfile, Helm, Kubernetes, Security, Terraform
|
|
23
|
+
'checkov',
|
|
24
|
+
// AWS CloudFormation, Azure ARM, Dockerfile, Kubernetes, Secrets, Security, Terraform, Vulnerabilities
|
|
25
|
+
'trivy',
|
|
26
|
+
// Azure Resource Manager (ARM)
|
|
27
|
+
'test-aztemplate',
|
|
28
|
+
// Bash / Shell
|
|
29
|
+
'shellcheck',
|
|
30
|
+
'shfmt',
|
|
31
|
+
// Bazel, Starlark
|
|
32
|
+
'buildifier',
|
|
33
|
+
// C, C++
|
|
34
|
+
'cpplint',
|
|
35
|
+
'clang-format',
|
|
36
|
+
'clang-tidy',
|
|
37
|
+
'cmake-format',
|
|
38
|
+
'iwyu',
|
|
39
|
+
'pragma-once',
|
|
40
|
+
// C#, Dotnet (.NET)
|
|
41
|
+
'dotnet-format',
|
|
42
|
+
// CircleCI Config
|
|
43
|
+
'circleci',
|
|
44
|
+
// Clojure
|
|
45
|
+
'clj-kondo',
|
|
46
|
+
// CoffeeScript
|
|
47
|
+
'coffeelint',
|
|
48
|
+
// Commit messages
|
|
49
|
+
'commitlint',
|
|
50
|
+
// Copy/paste detection
|
|
51
|
+
'jscpd',
|
|
52
|
+
// CSS, SCSS, Sass
|
|
53
|
+
'stylelint',
|
|
54
|
+
// CSS, GraphQL, HTML, JavaScript, JSON, JSONC, JSON5, JSX, TSX, Markdown, TypeScript, Vue, YAML
|
|
55
|
+
'prettier',
|
|
56
|
+
// Cue
|
|
57
|
+
'cue-fmt',
|
|
58
|
+
// Dart
|
|
59
|
+
'dart',
|
|
60
|
+
// Dockerfile / Docker
|
|
61
|
+
'hadolint',
|
|
62
|
+
// Dotenv
|
|
63
|
+
'dotenv-linter',
|
|
64
|
+
// EditorConfig
|
|
65
|
+
'editorconfig-checker',
|
|
66
|
+
// GitHub Actions
|
|
67
|
+
'actionlint',
|
|
68
|
+
'zizmor',
|
|
69
|
+
// Go
|
|
70
|
+
'gofmt',
|
|
71
|
+
'gofumpt',
|
|
72
|
+
'goimports',
|
|
73
|
+
'gokart',
|
|
74
|
+
'golangci-lint',
|
|
75
|
+
'golines',
|
|
76
|
+
// Go, Java, JavaScript, JSON, Python, Ruby, TypeScript, YAML
|
|
77
|
+
'semgrep',
|
|
78
|
+
// GoReleaser
|
|
79
|
+
'goreleaser',
|
|
80
|
+
// GraphQL
|
|
81
|
+
'graphql-schema-linter',
|
|
82
|
+
// Groovy
|
|
83
|
+
'npm-groovy-lint',
|
|
84
|
+
// HAML
|
|
85
|
+
'haml-lint',
|
|
86
|
+
// HTML
|
|
87
|
+
'htmlhint',
|
|
88
|
+
// HTML Templates
|
|
89
|
+
'djlint',
|
|
90
|
+
// Java
|
|
91
|
+
'checkstyle',
|
|
92
|
+
'google-java-format',
|
|
93
|
+
// JavaScript, JSON, TypeScript
|
|
94
|
+
'eslint',
|
|
95
|
+
// Next.js
|
|
96
|
+
'next lint',
|
|
97
|
+
// JavaScript, JSON, Markdown, TypeScript
|
|
98
|
+
'deno',
|
|
99
|
+
// JavaScript, TypeScript
|
|
100
|
+
'rome',
|
|
101
|
+
// JSON, JSONC, JSON5
|
|
102
|
+
'eslint-plugin-jsonc',
|
|
103
|
+
'eslint-plugin-json',
|
|
104
|
+
// JSX, TSX
|
|
105
|
+
'eslint-plugin-jsx-a11y',
|
|
106
|
+
'eslint-plugin-react',
|
|
107
|
+
// Jupyter Notebook
|
|
108
|
+
'nbqa',
|
|
109
|
+
// Kotlin
|
|
110
|
+
'detekt',
|
|
111
|
+
'ktlint',
|
|
112
|
+
// Kubernetes
|
|
113
|
+
'kubeconform',
|
|
114
|
+
'kube-linter',
|
|
115
|
+
// LaTeX
|
|
116
|
+
'chktex',
|
|
117
|
+
// Lua
|
|
118
|
+
'luacheck',
|
|
119
|
+
'stylua',
|
|
120
|
+
// Markdown
|
|
121
|
+
'markdownlint',
|
|
122
|
+
'markdownlint-cli2',
|
|
123
|
+
'markdown-link-check',
|
|
124
|
+
'markdown-table-prettify',
|
|
125
|
+
'remark-lint',
|
|
126
|
+
// Natural language / Prose
|
|
127
|
+
'textlint',
|
|
128
|
+
'vale',
|
|
129
|
+
// Nix
|
|
130
|
+
'nixpkgs-fmt',
|
|
131
|
+
// OpenAPI
|
|
132
|
+
'spectral',
|
|
133
|
+
// package.json
|
|
134
|
+
'sort-package-json',
|
|
135
|
+
// Perl
|
|
136
|
+
'perlcritic',
|
|
137
|
+
'perltidy',
|
|
138
|
+
// PHP
|
|
139
|
+
'php-cs-fixer',
|
|
140
|
+
'phpcs',
|
|
141
|
+
'phpstan',
|
|
142
|
+
'psalm',
|
|
143
|
+
// PNG
|
|
144
|
+
'oxipng',
|
|
145
|
+
// PowerShell
|
|
146
|
+
'psscriptanalyzer',
|
|
147
|
+
// Prisma
|
|
148
|
+
'prisma',
|
|
149
|
+
// Protocol Buffers (Protobuf)
|
|
150
|
+
'protolint',
|
|
151
|
+
'buf',
|
|
152
|
+
// Python
|
|
153
|
+
'pylint',
|
|
154
|
+
'flake8',
|
|
155
|
+
'isort',
|
|
156
|
+
'ruff',
|
|
157
|
+
'black',
|
|
158
|
+
'autopep8',
|
|
159
|
+
'bandit',
|
|
160
|
+
'mypy',
|
|
161
|
+
'pyright',
|
|
162
|
+
'sourcery',
|
|
163
|
+
'yapf',
|
|
164
|
+
// R
|
|
165
|
+
'lintr',
|
|
166
|
+
// Rego
|
|
167
|
+
'opa',
|
|
168
|
+
'regal',
|
|
169
|
+
// Ruby
|
|
170
|
+
'rubocop',
|
|
171
|
+
'brakeman',
|
|
172
|
+
'rufo',
|
|
173
|
+
'standardrb',
|
|
174
|
+
// Rust
|
|
175
|
+
'clippy',
|
|
176
|
+
'rustfmt',
|
|
177
|
+
// Scala
|
|
178
|
+
'scalafmt',
|
|
179
|
+
// Security, Vulnerabilities
|
|
180
|
+
'osv-scanner',
|
|
181
|
+
// Security, Terraform
|
|
182
|
+
'terrascan',
|
|
183
|
+
'tfsec',
|
|
184
|
+
// Snakemake
|
|
185
|
+
'snakemake --lint',
|
|
186
|
+
'snakefmt',
|
|
187
|
+
// SQL
|
|
188
|
+
'sqlfluff',
|
|
189
|
+
'sql-formatter',
|
|
190
|
+
'sqlfmt',
|
|
191
|
+
'squawk',
|
|
192
|
+
// SVG
|
|
193
|
+
'svgo',
|
|
194
|
+
// Swift
|
|
195
|
+
'stringslint',
|
|
196
|
+
'swiftformat',
|
|
197
|
+
'swiftlint',
|
|
198
|
+
// Terraform
|
|
199
|
+
'tflint',
|
|
200
|
+
'terraform',
|
|
201
|
+
'tofu',
|
|
202
|
+
// Terragrunt
|
|
203
|
+
'terragrunt',
|
|
204
|
+
// Textproto
|
|
205
|
+
'txtpbfmt',
|
|
206
|
+
// TOML
|
|
207
|
+
'taplo',
|
|
208
|
+
// Vue
|
|
209
|
+
'eslint-plugin-vue',
|
|
210
|
+
// XML
|
|
211
|
+
'xmllint',
|
|
212
|
+
// YAML
|
|
213
|
+
'yamllint',
|
|
214
|
+
];
|
|
215
|
+
//# sourceMappingURL=safe-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-tools.js","sourceRoot":"","sources":["../../../src/lib/safe-tools.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAa;IACrC,wBAAwB;IACxB,WAAW;IACX,QAAQ;IACR,gBAAgB;IAChB,UAAU;IACV,YAAY;IAEZ,yBAAyB;IACzB,eAAe;IAEf,UAAU;IACV,cAAc;IAEd,aAAa;IACb,KAAK;IAEL,uGAAuG;IACvG,OAAO;IAEP,+BAA+B;IAC/B,UAAU;IACV,SAAS;IAET,mFAAmF;IACnF,SAAS;IAET,uGAAuG;IACvG,OAAO;IAEP,+BAA+B;IAC/B,iBAAiB;IAEjB,eAAe;IACf,YAAY;IACZ,OAAO;IAEP,kBAAkB;IAClB,YAAY;IAEZ,SAAS;IACT,SAAS;IACT,cAAc;IACd,YAAY;IACZ,cAAc;IACd,MAAM;IACN,aAAa;IAEb,oBAAoB;IACpB,eAAe;IAEf,kBAAkB;IAClB,UAAU;IAEV,UAAU;IACV,WAAW;IAEX,eAAe;IACf,YAAY;IAEZ,kBAAkB;IAClB,YAAY;IAEZ,uBAAuB;IACvB,OAAO;IAEP,kBAAkB;IAClB,WAAW;IAEX,gGAAgG;IAChG,UAAU;IAEV,MAAM;IACN,SAAS;IAET,OAAO;IACP,MAAM;IAEN,sBAAsB;IACtB,UAAU;IAEV,SAAS;IACT,eAAe;IAEf,eAAe;IACf,sBAAsB;IAEtB,iBAAiB;IACjB,YAAY;IACZ,QAAQ;IAER,KAAK;IACL,OAAO;IACP,SAAS;IACT,WAAW;IACX,QAAQ;IACR,eAAe;IACf,SAAS;IAET,6DAA6D;IAC7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EV,4BAA4B;IAC5B,aAAa;IAEb,sBAAsB;IACtB,WAAW;IACX,OAAO;IAEP,YAAY;IACZ,kBAAkB;IAClB,UAAU;IAEV,MAAM;IACN,UAAU;IACV,eAAe;IACf,QAAQ;IACR,QAAQ;IAER,MAAM;IACN,MAAM;IAEN,QAAQ;IACR,aAAa;IACb,aAAa;IACb,WAAW;IAEX,YAAY;IACZ,QAAQ;IACR,WAAW;IACX,MAAM;IAEN,aAAa;IACb,YAAY;IAEZ,YAAY;IACZ,UAAU;IAEV,OAAO;IACP,OAAO;IAEP,MAAM;IACN,mBAAmB;IAEnB,MAAM;IACN,SAAS;IAET,OAAO;IACP,UAAU;CACF,CAAC","sourcesContent":["export const LINTING_TOOLS: string[] = [\n // All (general purpose)\n 'codespell',\n 'cspell',\n 'git-diff-check',\n 'gitleaks',\n 'trufflehog',\n\n // Amazon States Language\n 'asl-validator',\n\n // Ansible\n 'ansible-lint',\n\n // Apex, Java\n 'pmd',\n\n // Astro, CSS, GraphQL, GritQL, HTML, JavaScript, JSON, JSONC, JSON5, JSX, TSX, Svelte, TypeScript, Vue\n 'biome',\n\n // AWS CloudFormation templates\n 'cfn-lint',\n 'cfnlint',\n\n // AWS CloudFormation, Azure ARM, Dockerfile, Helm, Kubernetes, Security, Terraform\n 'checkov',\n\n // AWS CloudFormation, Azure ARM, Dockerfile, Kubernetes, Secrets, Security, Terraform, Vulnerabilities\n 'trivy',\n\n // Azure Resource Manager (ARM)\n 'test-aztemplate',\n\n // Bash / Shell\n 'shellcheck',\n 'shfmt',\n\n // Bazel, Starlark\n 'buildifier',\n\n // C, C++\n 'cpplint',\n 'clang-format',\n 'clang-tidy',\n 'cmake-format',\n 'iwyu',\n 'pragma-once',\n\n // C#, Dotnet (.NET)\n 'dotnet-format',\n\n // CircleCI Config\n 'circleci',\n\n // Clojure\n 'clj-kondo',\n\n // CoffeeScript\n 'coffeelint',\n\n // Commit messages\n 'commitlint',\n\n // Copy/paste detection\n 'jscpd',\n\n // CSS, SCSS, Sass\n 'stylelint',\n\n // CSS, GraphQL, HTML, JavaScript, JSON, JSONC, JSON5, JSX, TSX, Markdown, TypeScript, Vue, YAML\n 'prettier',\n\n // Cue\n 'cue-fmt',\n\n // Dart\n 'dart',\n\n // Dockerfile / Docker\n 'hadolint',\n\n // Dotenv\n 'dotenv-linter',\n\n // EditorConfig\n 'editorconfig-checker',\n\n // GitHub Actions\n 'actionlint',\n 'zizmor',\n\n // Go\n 'gofmt',\n 'gofumpt',\n 'goimports',\n 'gokart',\n 'golangci-lint',\n 'golines',\n\n // Go, Java, JavaScript, JSON, Python, Ruby, TypeScript, YAML\n 'semgrep',\n\n // GoReleaser\n 'goreleaser',\n\n // GraphQL\n 'graphql-schema-linter',\n\n // Groovy\n 'npm-groovy-lint',\n\n // HAML\n 'haml-lint',\n\n // HTML\n 'htmlhint',\n\n // HTML Templates\n 'djlint',\n\n // Java\n 'checkstyle',\n 'google-java-format',\n\n // JavaScript, JSON, TypeScript\n 'eslint',\n\n // Next.js\n 'next lint',\n\n // JavaScript, JSON, Markdown, TypeScript\n 'deno',\n\n // JavaScript, TypeScript\n 'rome',\n\n // JSON, JSONC, JSON5\n 'eslint-plugin-jsonc',\n 'eslint-plugin-json',\n\n // JSX, TSX\n 'eslint-plugin-jsx-a11y',\n 'eslint-plugin-react',\n\n // Jupyter Notebook\n 'nbqa',\n\n // Kotlin\n 'detekt',\n 'ktlint',\n\n // Kubernetes\n 'kubeconform',\n 'kube-linter',\n\n // LaTeX\n 'chktex',\n\n // Lua\n 'luacheck',\n 'stylua',\n\n // Markdown\n 'markdownlint',\n 'markdownlint-cli2',\n 'markdown-link-check',\n 'markdown-table-prettify',\n 'remark-lint',\n\n // Natural language / Prose\n 'textlint',\n 'vale',\n\n // Nix\n 'nixpkgs-fmt',\n\n // OpenAPI\n 'spectral',\n\n // package.json\n 'sort-package-json',\n\n // Perl\n 'perlcritic',\n 'perltidy',\n\n // PHP\n 'php-cs-fixer',\n 'phpcs',\n 'phpstan',\n 'psalm',\n\n // PNG\n 'oxipng',\n\n // PowerShell\n 'psscriptanalyzer',\n\n // Prisma\n 'prisma',\n\n // Protocol Buffers (Protobuf)\n 'protolint',\n 'buf',\n\n // Python\n 'pylint',\n 'flake8',\n 'isort',\n 'ruff',\n 'black',\n 'autopep8',\n 'bandit',\n 'mypy',\n 'pyright',\n 'sourcery',\n 'yapf',\n\n // R\n 'lintr',\n\n // Rego\n 'opa',\n 'regal',\n\n // Ruby\n 'rubocop',\n 'brakeman',\n 'rufo',\n 'standardrb',\n\n // Rust\n 'clippy',\n 'rustfmt',\n\n // Scala\n 'scalafmt',\n\n // Security, Vulnerabilities\n 'osv-scanner',\n\n // Security, Terraform\n 'terrascan',\n 'tfsec',\n\n // Snakemake\n 'snakemake --lint',\n 'snakefmt',\n\n // SQL\n 'sqlfluff',\n 'sql-formatter',\n 'sqlfmt',\n 'squawk',\n\n // SVG\n 'svgo',\n\n // Swift\n 'stringslint',\n 'swiftformat',\n 'swiftlint',\n\n // Terraform\n 'tflint',\n 'terraform',\n 'tofu',\n\n // Terragrunt\n 'terragrunt',\n\n // Textproto\n 'txtpbfmt',\n\n // TOML\n 'taplo',\n\n // Vue\n 'eslint-plugin-vue',\n\n // XML\n 'xmllint',\n\n // YAML\n 'yamllint',\n] as const;\n\nexport type LintingTool = (typeof LINTING_TOOLS)[number];\n"]}
|
|
@@ -56,7 +56,6 @@ const NEXTJS_AGENT_CONFIG = {
|
|
|
56
56
|
integration: constants_1.Integration.nextjs,
|
|
57
57
|
docsUrl: 'https://posthog.com/docs/libraries/next-js',
|
|
58
58
|
unsupportedVersionDocsUrl: 'https://posthog.com/docs/libraries/next-js',
|
|
59
|
-
abortMessage: 'This wizard uses an LLM agent to intelligently modify your project. Please view the docs to setup Next.js manually instead: https://posthog.com/docs/libraries/next-js',
|
|
60
59
|
gatherContext: async (options) => {
|
|
61
60
|
const router = await (0, utils_1.getNextJsRouter)(options);
|
|
62
61
|
return { router };
|
|
@@ -91,8 +90,6 @@ const NEXTJS_AGENT_CONFIG = {
|
|
|
91
90
|
},
|
|
92
91
|
},
|
|
93
92
|
ui: {
|
|
94
|
-
welcomeMessage: 'PostHog Next.js wizard (agent-powered)',
|
|
95
|
-
spinnerMessage: 'Writing your PostHog setup with events, error capture and more...',
|
|
96
93
|
successMessage: 'PostHog integration complete',
|
|
97
94
|
estimatedDurationMinutes: 8,
|
|
98
95
|
getOutroChanges: (context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-wizard-agent.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard-agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"nextjs-wizard-agent.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard-agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,oDA4BC;AApHD,0CAAiD;AACjD,sDAAqD;AACrD,gDAA+C;AAC/C,wDAA0D;AAC1D,sDAAyD;AACzD,2DAAmC;AACnC,kDAA0B;AAC1B,+CAAiC;AACjC,mCAKiB;AAEjB;;GAEG;AACH,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAExC,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,uBAAW,CAAC,MAAM;QAC/B,OAAO,EAAE,4CAA4C;QACrD,yBAAyB,EAAE,4CAA4C;QACvE,aAAa,EAAE,KAAK,EAAE,OAAsB,EAAE,EAAE;YAC9C,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;KACF;IAED,SAAS,EAAE;QACT,WAAW,EAAE,MAAM;QACnB,kBAAkB,EAAE,SAAS;QAC7B,UAAU,EAAE,CAAC,WAAgB,EAAE,EAAE,C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C;AAEF;;GAEG;AACI,KAAK,UAAU,oBAAoB,CACxC,OAAsB;IAEtB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,IAAA,uBAAe,GAAE,CAAC;IACpB,CAAC;IAED,0DAA0D;IAC1D,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,IAAA,gCAAiB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAE3D,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,cAAc,IAAI,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,sBAAsB,CAAC,EAAE,CAAC;YACxE,MAAM,OAAO,GACX,mBAAmB,CAAC,QAAQ,CAAC,yBAAyB;gBACtD,mBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC;YAEvC,eAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iDAAiD,WAAW,wBAAwB,sBAAsB,iDAAiD,CAC5J,CAAC;YACF,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,2BAA2B,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACjE,eAAK,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,IAAA,6BAAc,EAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/* Simplified Next.js wizard using posthog-agent with PostHog MCP */\nimport type { WizardOptions } from '../utils/types';\nimport { enableDebugLogs } from '../utils/debug';\nimport { runAgentWizard } from '../lib/agent-runner';\nimport { Integration } from '../lib/constants';\nimport { getPackageVersion } from '../utils/package-json';\nimport { getPackageDotJson } from '../utils/clack-utils';\nimport clack from '../utils/clack';\nimport chalk from 'chalk';\nimport * as semver from 'semver';\nimport {\n getNextJsRouter,\n getNextJsVersionBucket,\n getNextJsRouterName,\n NextJsRouter,\n} from './utils';\n\n/**\n * Next.js framework configuration for the universal agent runner.\n */\nconst MINIMUM_NEXTJS_VERSION = '15.3.0';\n\nconst NEXTJS_AGENT_CONFIG = {\n metadata: {\n name: 'Next.js',\n integration: Integration.nextjs,\n docsUrl: 'https://posthog.com/docs/libraries/next-js',\n unsupportedVersionDocsUrl: 'https://posthog.com/docs/libraries/next-js',\n gatherContext: async (options: WizardOptions) => {\n const router = await getNextJsRouter(options);\n return { router };\n },\n },\n\n detection: {\n packageName: 'next',\n packageDisplayName: 'Next.js',\n getVersion: (packageJson: any) => getPackageVersion('next', packageJson),\n getVersionBucket: getNextJsVersionBucket,\n },\n\n environment: {\n uploadToHosting: true,\n getEnvVars: (apiKey: string, host: string) => ({\n NEXT_PUBLIC_POSTHOG_KEY: apiKey,\n NEXT_PUBLIC_POSTHOG_HOST: host,\n }),\n },\n\n analytics: {\n getTags: (context: any) => {\n const router = context.router as NextJsRouter;\n return {\n router: router === NextJsRouter.APP_ROUTER ? 'app' : 'pages',\n };\n },\n },\n\n prompts: {\n getAdditionalContextLines: (context: any) => {\n const router = context.router as NextJsRouter;\n const routerType = router === NextJsRouter.APP_ROUTER ? 'app' : 'pages';\n return [`Router: ${routerType}`];\n },\n },\n\n ui: {\n successMessage: 'PostHog integration complete',\n estimatedDurationMinutes: 8,\n getOutroChanges: (context: any) => {\n const router = context.router as NextJsRouter;\n const routerName = getNextJsRouterName(router);\n return [\n `Analyzed your Next.js project structure (${routerName})`,\n `Created and configured PostHog initializers`,\n `Integrated PostHog into your application`,\n ];\n },\n getOutroNextSteps: () => {\n return [\n 'Start your development server to see PostHog in action',\n 'Visit your PostHog dashboard to see incoming events',\n ];\n },\n },\n};\n\n/**\n * Next.js wizard powered by the universal agent runner.\n */\nexport async function runNextjsWizardAgent(\n options: WizardOptions,\n): Promise<void> {\n if (options.debug) {\n enableDebugLogs();\n }\n\n // Check Next.js version - agent wizard requires >= 15.3.0\n const packageJson = await getPackageDotJson(options);\n const nextVersion = getPackageVersion('next', packageJson);\n\n if (nextVersion) {\n const coercedVersion = semver.coerce(nextVersion);\n if (coercedVersion && semver.lt(coercedVersion, MINIMUM_NEXTJS_VERSION)) {\n const docsUrl =\n NEXTJS_AGENT_CONFIG.metadata.unsupportedVersionDocsUrl ??\n NEXTJS_AGENT_CONFIG.metadata.docsUrl;\n\n clack.log.warn(\n `Sorry: the wizard can't help you with Next.js ${nextVersion}. Upgrade to Next.js ${MINIMUM_NEXTJS_VERSION} or later, or check out the manual setup guide.`,\n );\n clack.log.info(`Setup Next.js manually: ${chalk.cyan(docsUrl)}`);\n clack.outro('PostHog wizard will see you next time!');\n return;\n }\n }\n\n await runAgentWizard(NEXTJS_AGENT_CONFIG, options);\n}\n"]}
|
|
@@ -104,6 +104,7 @@ async function runReactWizard(options) {
|
|
|
104
104
|
await (0, steps_1.addMCPServerToClientsStep)({
|
|
105
105
|
cloudRegion,
|
|
106
106
|
integration: constants_1.Integration.react,
|
|
107
|
+
ci: options.ci,
|
|
107
108
|
});
|
|
108
109
|
const outroMessage = (0, messages_1.getOutroMessage)({
|
|
109
110
|
options,
|