@posthog/wizard 2.0.2 → 2.1.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 (50) hide show
  1. package/dist/bin.js +22 -4
  2. package/dist/bin.js.map +1 -1
  3. package/dist/src/__tests__/cli.test.js +50 -3
  4. package/dist/src/__tests__/cli.test.js.map +1 -1
  5. package/dist/src/__tests__/package-json.test.d.ts +1 -0
  6. package/dist/src/__tests__/package-json.test.js +173 -0
  7. package/dist/src/__tests__/package-json.test.js.map +1 -0
  8. package/dist/src/lib/__tests__/agent-interface.test.js +1 -0
  9. package/dist/src/lib/__tests__/agent-interface.test.js.map +1 -1
  10. package/dist/src/lib/__tests__/yara-hooks.test.d.ts +1 -0
  11. package/dist/src/lib/__tests__/yara-hooks.test.js +432 -0
  12. package/dist/src/lib/__tests__/yara-hooks.test.js.map +1 -0
  13. package/dist/src/lib/__tests__/yara-scanner.test.d.ts +1 -0
  14. package/dist/src/lib/__tests__/yara-scanner.test.js +613 -0
  15. package/dist/src/lib/__tests__/yara-scanner.test.js.map +1 -0
  16. package/dist/src/lib/agent-interface.d.ts +4 -2
  17. package/dist/src/lib/agent-interface.js +40 -26
  18. package/dist/src/lib/agent-interface.js.map +1 -1
  19. package/dist/src/lib/agent-runner.js +34 -1
  20. package/dist/src/lib/agent-runner.js.map +1 -1
  21. package/dist/src/lib/commandments.js +1 -0
  22. package/dist/src/lib/commandments.js.map +1 -1
  23. package/dist/src/lib/constants.d.ts +4 -3
  24. package/dist/src/lib/constants.js +3 -2
  25. package/dist/src/lib/constants.js.map +1 -1
  26. package/dist/src/lib/skill-install.d.ts +10 -0
  27. package/dist/src/lib/skill-install.js +23 -0
  28. package/dist/src/lib/skill-install.js.map +1 -0
  29. package/dist/src/lib/version.d.ts +1 -1
  30. package/dist/src/lib/version.js +1 -1
  31. package/dist/src/lib/version.js.map +1 -1
  32. package/dist/src/lib/wizard-session.d.ts +2 -0
  33. package/dist/src/lib/wizard-session.js +1 -0
  34. package/dist/src/lib/wizard-session.js.map +1 -1
  35. package/dist/src/lib/yara-hooks.d.ts +44 -0
  36. package/dist/src/lib/yara-hooks.js +377 -0
  37. package/dist/src/lib/yara-hooks.js.map +1 -0
  38. package/dist/src/lib/yara-scanner.d.ts +61 -0
  39. package/dist/src/lib/yara-scanner.js +328 -0
  40. package/dist/src/lib/yara-scanner.js.map +1 -0
  41. package/dist/src/run.d.ts +3 -0
  42. package/dist/src/run.js +10 -0
  43. package/dist/src/run.js.map +1 -1
  44. package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +2 -1
  45. package/dist/src/steps/add-mcp-server-to-clients/index.js +1 -1
  46. package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
  47. package/dist/src/utils/rules/universal.md +12 -0
  48. package/dist/src/utils/types.d.ts +9 -0
  49. package/dist/src/utils/types.js.map +1 -1
  50. package/package.json +1 -1
@@ -37,6 +37,7 @@ exports.runAgentWizard = runAgentWizard;
37
37
  const framework_config_1 = require("./framework-config");
38
38
  const wizard_session_1 = require("./wizard-session");
39
39
  const setup_utils_1 = require("../utils/setup-utils");
40
+ const constants_1 = require("./constants");
40
41
  const analytics_1 = require("../utils/analytics");
41
42
  const ui_1 = require("../ui");
42
43
  const agent_interface_1 = require("./agent-interface");
@@ -46,6 +47,7 @@ const anthropic_status_1 = require("../utils/anthropic-status");
46
47
  const debug_1 = require("../utils/debug");
47
48
  const benchmark_1 = require("./middleware/benchmark");
48
49
  const wizard_abort_1 = require("../utils/wizard-abort");
50
+ const yara_hooks_1 = require("./yara-hooks");
49
51
  /**
50
52
  * Build a WizardOptions bag from a WizardSession (for code that still expects WizardOptions).
51
53
  */
@@ -62,6 +64,7 @@ function sessionToOptions(session) {
62
64
  benchmark: session.benchmark,
63
65
  projectId: session.projectId,
64
66
  apiKey: session.apiKey,
67
+ yaraReport: session.yaraReport,
65
68
  };
66
69
  }
67
70
  /**
@@ -176,9 +179,22 @@ async function runAgentWizard(config, session) {
176
179
  // Determine MCP URL: CLI flag > env var > production default
177
180
  const mcpUrl = session.localMcp
178
181
  ? 'http://localhost:8787/mcp'
179
- : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';
182
+ : process.env.MCP_URL ||
183
+ (cloudRegion === 'eu'
184
+ ? 'https://mcp-eu.posthog.com/mcp'
185
+ : 'https://mcp.posthog.com/mcp');
180
186
  const restoreSettings = () => (0, agent_interface_1.restoreClaudeSettings)(session.installDir);
181
187
  (0, ui_1.getUI)().onEnterScreen('outro', restoreSettings);
188
+ // Register YARA report as cleanup so it fires on any exit path (including wizardAbort)
189
+ if (session.yaraReport) {
190
+ (0, wizard_abort_1.registerCleanup)(() => {
191
+ const reportPath = (0, yara_hooks_1.writeScanReport)();
192
+ if (reportPath) {
193
+ const summary = (0, yara_hooks_1.formatScanReport)();
194
+ (0, ui_1.getUI)().log.info(`YARA scan report: ${reportPath}${summary ?? ''}`);
195
+ }
196
+ });
197
+ }
182
198
  (0, ui_1.getUI)().startRun();
183
199
  const agent = await (0, agent_interface_1.initializeAgent)({
184
200
  workingDirectory: session.installDir,
@@ -221,6 +237,15 @@ async function runAgentWizard(config, session) {
221
237
  }),
222
238
  });
223
239
  }
240
+ if (agentResult.error === agent_interface_1.AgentErrorType.YARA_VIOLATION) {
241
+ await (0, wizard_abort_1.wizardAbort)({
242
+ message: 'Security violation detected\n\nThe YARA scanner terminated the session after detecting a security violation.\nThis may indicate prompt injection, poisoned skill files, or a policy breach.\n\nPlease report this to: wizard@posthog.com',
243
+ error: new wizard_abort_1.WizardError('YARA scanner terminated session', {
244
+ integration: config.metadata.integration,
245
+ error_type: agent_interface_1.AgentErrorType.YARA_VIOLATION,
246
+ }),
247
+ });
248
+ }
224
249
  if (agentResult.error === agent_interface_1.AgentErrorType.RATE_LIMIT ||
225
250
  agentResult.error === agent_interface_1.AgentErrorType.API_ERROR) {
226
251
  analytics_1.analytics.wizardCapture('agent api error', {
@@ -246,6 +271,14 @@ async function runAgentWizard(config, session) {
246
271
  integration: config.metadata.integration,
247
272
  session,
248
273
  });
274
+ if (uploadedEnvVars.length > 0) {
275
+ analytics_1.analytics.capture(constants_1.WIZARD_INTERACTION_EVENT_NAME, {
276
+ action: 'wizard_env_vars_uploaded',
277
+ integration: config.metadata.integration,
278
+ variable_count: uploadedEnvVars.length,
279
+ variable_keys: uploadedEnvVars,
280
+ });
281
+ }
249
282
  }
250
283
  // MCP installation is handled by McpScreen — no prompt here
251
284
  // Build outro data and store it for OutroScreen
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,wCA+QC;AAzUD,yDAI4B;AAC5B,qDAAiE;AACjE,sDAI8B;AAG9B,kDAA+C;AAC/C,8BAA8B;AAC9B,uDAS2B;AAC3B,wCAAsD;AAEtD,+CAAiC;AACjC,gEAAiE;AACjE,0CAAyE;AACzE,sDAAiE;AACjE,wDAAiE;AAEjE;;GAEG;AACH,SAAS,gBAAgB,CAAC,OAAsB;IAC9C,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAClC,MAAuB,EACvB,OAAsB;IAEtB,IAAA,mBAAW,GAAE,CAAC;IACd,IAAA,iBAAS,EAAC,oCAAo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AQ,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAC7B,MAAuB,EACvB,OAMC,EACD,gBAAyC;IAEzC,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,yBAAyB;QAC9D,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,CAAC;QAC5D,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,iBAAiB,GACrB,eAAe,CAAC,MAAM,GAAG,CAAC;QACxB,CAAC,CAAC,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,kGACL,MAAM,CAAC,QAAQ,CAAC,IAClB;;;wBAGsB,OAAO,CAAC,SAAS;eAC1B,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,gBAAgB;gBAC/C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;0BACvB,OAAO,CAAC,aAAa;kBAC7B,OAAO,CAAC,IAAI;kBACZ,MAAM,CAAC,OAAO,CAAC,oBAAoB;0BAEjD,MAAM,CAAC,OAAO,CAAC,mBAAmB,IAAI,+CACxC,GAAG,iBAAiB;;;;0KAKlB,8BAAY,CAAC,iBACf;;;mFAIG,8BAAY,CAAC,sBACf;;;;;;;;;;;;;;;kJAgBE,MAAM,CAAC,QAAQ,CAAC,IAClB;;;;;;CAMF,CAAC;AACF,CAAC","sourcesContent":["import {\n DEFAULT_PACKAGE_INSTALLATION,\n SPINNER_MESSAGE,\n type FrameworkConfig,\n} from './framework-config';\nimport { type WizardSession, OutroKind } from './wizard-session';\nimport {\n tryGetPackageJson,\n isUsingTypeScript,\n getOrAskForProjectData,\n} from '../utils/setup-utils';\nimport type { PackageDotJson } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { analytics } from '../utils/analytics';\nimport { getUI } from '../ui';\nimport {\n initializeAgent,\n runAgent,\n AgentSignals,\n AgentErrorType,\n buildWizardMetadata,\n checkClaudeSettingsOverrides,\n backupAndFixClaudeSettings,\n restoreClaudeSettings,\n} from './agent-interface';\nimport { getCloudUrlFromRegion } from '../utils/urls';\n\nimport * as semver from 'semver';\nimport { checkAnthropicStatus } from '../utils/anthropic-status';\nimport { enableDebugLogs, initLogFile, logToFile } from '../utils/debug';\nimport { createBenchmarkPipeline } from './middleware/benchmark';\nimport { wizardAbort, WizardError } from '../utils/wizard-abort';\n\n/**\n * Build a WizardOptions bag from a WizardSession (for code that still expects WizardOptions).\n */\nfunction sessionToOptions(session: WizardSession): WizardOptions {\n return {\n installDir: session.installDir,\n debug: session.debug,\n forceInstall: session.forceInstall,\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: session.ci,\n menu: session.menu,\n benchmark: session.benchmark,\n projectId: session.projectId,\n apiKey: session.apiKey,\n };\n}\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using PostHog MCP integration.\n *\n * All user decisions come from the session — no UI prompts.\n */\nexport async function runAgentWizard(\n config: FrameworkConfig,\n session: WizardSession,\n): Promise<void> {\n initLogFile();\n logToFile(`[agent-runner] START integration=${config.metadata.integration}`);\n\n if (session.debug) {\n enableDebugLogs();\n }\n\n // Version check\n if (config.detection.minimumVersion && config.detection.getInstalledVersion) {\n logToFile('[agent-runner] checking version');\n const version = await config.detection.getInstalledVersion(\n sessionToOptions(session),\n );\n if (version) {\n logToFile(\n `[agent-runner] version=${version} minimum=${config.detection.minimumVersion}`,\n );\n const coerced = semver.coerce(version);\n if (coerced && semver.lt(coerced, config.detection.minimumVersion)) {\n const docsUrl =\n config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl;\n await wizardAbort({\n message:\n `Sorry: the wizard can't help you with ${config.metadata.name} ${version}. ` +\n `Upgrade to ${config.metadata.name} ${config.detection.minimumVersion} or later, ` +\n `or check out the manual setup guide.\\n\\n` +\n `Setup ${config.metadata.name} manually: ${docsUrl}`,\n });\n }\n }\n }\n\n // Check Anthropic/Claude service status (pure — no prompt)\n logToFile('[agent-runner] checking anthropic status');\n const statusResult = await checkAnthropicStatus();\n logToFile(`[agent-runner] anthropic status=${statusResult.status}`);\n if (statusResult.status === 'down' || statusResult.status === 'degraded') {\n getUI().showServiceStatus({\n description: statusResult.description,\n statusPageUrl: 'https://status.claude.com',\n });\n }\n\n // Check for blocking env overrides in .claude/settings.json before login.\n const blockingOverrideKeys = checkClaudeSettingsOverrides(session.installDir);\n logToFile(\n `[agent-runner] settings overrides: ${\n blockingOverrideKeys.length > 0 ? blockingOverrideKeys.join(', ') : 'none'\n }`,\n );\n if (blockingOverrideKeys.length > 0) {\n await getUI().showSettingsOverride(blockingOverrideKeys, () =>\n backupAndFixClaudeSettings(session.installDir),\n );\n logToFile('[agent-runner] settings override resolved');\n }\n\n const typeScriptDetected = isUsingTypeScript({\n installDir: session.installDir,\n });\n session.typescript = typeScriptDetected;\n\n // Framework detection and version\n const usesPackageJson = config.detection.usesPackageJson !== false;\n let packageJson: PackageDotJson | null = null;\n let frameworkVersion: string | undefined;\n\n if (usesPackageJson) {\n packageJson = await tryGetPackageJson({ installDir: session.installDir });\n if (packageJson) {\n const { hasPackageInstalled } = await import('../utils/package-json.js');\n if (!hasPackageInstalled(config.detection.packageName, packageJson)) {\n getUI().log.warn(\n `${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`,\n );\n }\n frameworkVersion = config.detection.getVersion(packageJson);\n } else {\n getUI().log.warn(\n 'Could not find package.json. Continuing anyway — the agent will handle it.',\n );\n }\n } else {\n frameworkVersion = config.detection.getVersion(null);\n }\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.wizardCapture('agent started', {\n integration: config.metadata.integration,\n });\n\n // Get PostHog credentials (region auto-detected from token)\n logToFile('[agent-runner] starting OAuth');\n const { projectApiKey, host, accessToken, projectId, cloudRegion } =\n await getOrAskForProjectData({\n signup: session.signup,\n ci: session.ci,\n apiKey: session.apiKey,\n projectId: session.projectId,\n });\n\n session.credentials = { accessToken, projectApiKey, host, projectId };\n\n // Notify TUI that credentials are available (resolves past AuthScreen)\n getUI().setCredentials(session.credentials);\n\n // Framework context was already gathered by SetupScreen + detection\n const frameworkContext = session.frameworkContext;\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 const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n projectApiKey,\n host,\n projectId,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n const spinner = getUI().spinner();\n\n // Evaluate all feature flags at the start of the run so they can be sent to the LLM gateway\n const wizardFlags = await analytics.getAllFlagsForWizard();\n const wizardMetadata = buildWizardMetadata(wizardFlags);\n\n // Determine MCP URL: CLI flag > env var > production default\n const mcpUrl = session.localMcp\n ? 'http://localhost:8787/mcp'\n : process.env.MCP_URL || 'https://mcp.posthog.com/mcp';\n\n const restoreSettings = () => restoreClaudeSettings(session.installDir);\n getUI().onEnterScreen('outro', restoreSettings);\n getUI().startRun();\n\n const agent = await initializeAgent(\n {\n workingDirectory: session.installDir,\n posthogMcpUrl: mcpUrl,\n posthogApiKey: accessToken,\n posthogApiHost: host,\n additionalMcpServers: config.metadata.additionalMcpServers,\n detectPackageManager: config.detection.detectPackageManager,\n wizardFlags,\n wizardMetadata,\n },\n sessionToOptions(session),\n );\n\n const middleware = session.benchmark\n ? createBenchmarkPipeline(spinner, sessionToOptions(session))\n : undefined;\n\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n sessionToOptions(session),\n spinner,\n {\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n additionalFeatureQueue: session.additionalFeatureQueue,\n },\n middleware,\n );\n\n // Handle error cases detected in agent output\n if (agentResult.error === AgentErrorType.MCP_MISSING) {\n await wizardAbort({\n message: `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 ${config.metadata.name} manually by following our documentation:\\n${config.metadata.docsUrl}`,\n error: new WizardError('Agent could not access PostHog MCP server', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.MCP_MISSING,\n signal: AgentSignals.ERROR_MCP_MISSING,\n }),\n });\n }\n\n if (agentResult.error === AgentErrorType.RESOURCE_MISSING) {\n await wizardAbort({\n message: `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 ${config.metadata.name} manually by following our documentation:\\n${config.metadata.docsUrl}`,\n error: new WizardError('Agent could not access setup resource', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.RESOURCE_MISSING,\n signal: AgentSignals.ERROR_RESOURCE_MISSING,\n }),\n });\n }\n\n if (\n agentResult.error === AgentErrorType.RATE_LIMIT ||\n agentResult.error === AgentErrorType.API_ERROR\n ) {\n analytics.wizardCapture('agent api error', {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n error_message: agentResult.message,\n });\n\n await wizardAbort({\n message: `API Error\\n\\n${\n agentResult.message || 'Unknown error'\n }\\n\\nPlease report this error to: wizard@posthog.com`,\n error: new WizardError(`API error: ${agentResult.message}`, {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n }),\n });\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 (auto-accept)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n const { uploadEnvironmentVariablesStep } = await import(\n '../steps/index.js'\n );\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n session,\n });\n }\n\n // MCP installation is handled by McpScreen — no prompt here\n\n // Build outro data and store it for OutroScreen\n const continueUrl = session.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 session.outroData = {\n kind: OutroKind.Success,\n changes,\n docsUrl: config.metadata.docsUrl,\n continueUrl,\n };\n\n getUI().outro(`Successfully installed PostHog!`);\n\n await analytics.shutdown('success');\n}\n\n/**\n * Build the integration prompt for the agent.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n projectApiKey: string;\n host: string;\n projectId: number;\n },\n frameworkContext: Record<string, unknown>,\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 skills to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- PostHog Project ID: ${context.projectId}\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}\n- PostHog public token: ${context.projectApiKey}\n- PostHog Host: ${context.host}\n- Project type: ${config.prompts.projectTypeDetection}\n- Package installation: ${\n config.prompts.packageInstallation ?? DEFAULT_PACKAGE_INSTALLATION\n }${additionalContext}\n\nInstructions (follow these steps IN ORDER - do not skip or reorder):\n\nSTEP 1: List available skills from the PostHog MCP server using ListMcpResourcesTool. If this tool is not available or you cannot access the MCP server, you must emit: ${\n AgentSignals.ERROR_MCP_MISSING\n } Could not access the PostHog MCP server and halt.\n\n Review the skill descriptions and choose the one that best matches this project's framework and configuration.\n If no suitable skill is found, or you cannot access the MCP server, you emit: ${\n AgentSignals.ERROR_RESOURCE_MISSING\n } Could not find a suitable skill for this project.\n\nSTEP 2: Fetch the chosen skill resource (e.g., posthog://skills/{skill-id}).\n The resource returns a shell command to install the skill.\n\nSTEP 3: Run the installation command using Bash:\n - Execute the EXACT command returned by the resource (do not modify it)\n - This will download and extract the skill to .claude/skills/{skill-id}/\n\nSTEP 4: Load the installed skill's SKILL.md file to understand what references are available.\n\nSTEP 5: Follow the skill's workflow files in sequence. Look for numbered workflow files in the references (e.g., files with patterns like \"1.0-\", \"1.1-\", \"1.2-\"). Start with the first one and proceed through each step until completion. Each workflow file will tell you what to do and which file comes next. Never directly write PostHog tokens directly to code files; always use environment variables.\n\nSTEP 6: Set up environment variables for PostHog using the wizard-tools MCP server (this runs locally — secret values never leave the machine):\n - Use check_env_keys to see which keys already exist in the project's .env file (e.g. .env.local or .env).\n - Use set_env_values to create or update the PostHog public token and host, using the appropriate environment variable naming convention for ${\n config.metadata.name\n }, which you'll find in example code. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.\n - Reference these environment variables in the code files you create instead of hardcoding the public token and host.\n\nImportant: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.\n\n\n`;\n}\n"]}
1
+ {"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,wCAiTC;AAlXD,yDAI4B;AAC5B,qDAAiE;AACjE,sDAI8B;AAG9B,2CAA4D;AAC5D,kDAA+C;AAC/C,8BA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U,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;0BACvB,OAAO,CAAC,aAAa;kBAC7B,OAAO,CAAC,IAAI;kBACZ,MAAM,CAAC,OAAO,CAAC,oBAAoB;0BAEjD,MAAM,CAAC,OAAO,CAAC,mBAAmB,IAAI,+CACxC,GAAG,iBAAiB;;;;0KAKlB,8BAAY,CAAC,iBACf;;;mFAIG,8BAAY,CAAC,sBACf;;;;;;;;;;;;;;;kJAgBE,MAAM,CAAC,QAAQ,CAAC,IAClB;;;;;;CAMF,CAAC;AACF,CAAC","sourcesContent":["import {\n DEFAULT_PACKAGE_INSTALLATION,\n SPINNER_MESSAGE,\n type FrameworkConfig,\n} from './framework-config';\nimport { type WizardSession, OutroKind } from './wizard-session';\nimport {\n tryGetPackageJson,\n isUsingTypeScript,\n getOrAskForProjectData,\n} from '../utils/setup-utils';\nimport type { PackageDotJson } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { WIZARD_INTERACTION_EVENT_NAME } from './constants';\nimport { analytics } from '../utils/analytics';\nimport { getUI } from '../ui';\nimport {\n initializeAgent,\n runAgent,\n AgentSignals,\n AgentErrorType,\n buildWizardMetadata,\n checkClaudeSettingsOverrides,\n backupAndFixClaudeSettings,\n restoreClaudeSettings,\n} from './agent-interface';\nimport { getCloudUrlFromRegion } from '../utils/urls';\n\nimport * as semver from 'semver';\nimport { checkAnthropicStatus } from '../utils/anthropic-status';\nimport { enableDebugLogs, initLogFile, logToFile } from '../utils/debug';\nimport { createBenchmarkPipeline } from './middleware/benchmark';\nimport {\n wizardAbort,\n WizardError,\n registerCleanup,\n} from '../utils/wizard-abort';\nimport { formatScanReport, writeScanReport } from './yara-hooks';\n\n/**\n * Build a WizardOptions bag from a WizardSession (for code that still expects WizardOptions).\n */\nfunction sessionToOptions(session: WizardSession): WizardOptions {\n return {\n installDir: session.installDir,\n debug: session.debug,\n forceInstall: session.forceInstall,\n default: false,\n signup: session.signup,\n localMcp: session.localMcp,\n ci: session.ci,\n menu: session.menu,\n benchmark: session.benchmark,\n projectId: session.projectId,\n apiKey: session.apiKey,\n yaraReport: session.yaraReport,\n };\n}\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using PostHog MCP integration.\n *\n * All user decisions come from the session — no UI prompts.\n */\nexport async function runAgentWizard(\n config: FrameworkConfig,\n session: WizardSession,\n): Promise<void> {\n initLogFile();\n logToFile(`[agent-runner] START integration=${config.metadata.integration}`);\n\n if (session.debug) {\n enableDebugLogs();\n }\n\n // Version check\n if (config.detection.minimumVersion && config.detection.getInstalledVersion) {\n logToFile('[agent-runner] checking version');\n const version = await config.detection.getInstalledVersion(\n sessionToOptions(session),\n );\n if (version) {\n logToFile(\n `[agent-runner] version=${version} minimum=${config.detection.minimumVersion}`,\n );\n const coerced = semver.coerce(version);\n if (coerced && semver.lt(coerced, config.detection.minimumVersion)) {\n const docsUrl =\n config.metadata.unsupportedVersionDocsUrl ?? config.metadata.docsUrl;\n await wizardAbort({\n message:\n `Sorry: the wizard can't help you with ${config.metadata.name} ${version}. ` +\n `Upgrade to ${config.metadata.name} ${config.detection.minimumVersion} or later, ` +\n `or check out the manual setup guide.\\n\\n` +\n `Setup ${config.metadata.name} manually: ${docsUrl}`,\n });\n }\n }\n }\n\n // Check Anthropic/Claude service status (pure — no prompt)\n logToFile('[agent-runner] checking anthropic status');\n const statusResult = await checkAnthropicStatus();\n logToFile(`[agent-runner] anthropic status=${statusResult.status}`);\n if (statusResult.status === 'down' || statusResult.status === 'degraded') {\n getUI().showServiceStatus({\n description: statusResult.description,\n statusPageUrl: 'https://status.claude.com',\n });\n }\n\n // Check for blocking env overrides in .claude/settings.json before login.\n const blockingOverrideKeys = checkClaudeSettingsOverrides(session.installDir);\n logToFile(\n `[agent-runner] settings overrides: ${\n blockingOverrideKeys.length > 0 ? blockingOverrideKeys.join(', ') : 'none'\n }`,\n );\n if (blockingOverrideKeys.length > 0) {\n await getUI().showSettingsOverride(blockingOverrideKeys, () =>\n backupAndFixClaudeSettings(session.installDir),\n );\n logToFile('[agent-runner] settings override resolved');\n }\n\n const typeScriptDetected = isUsingTypeScript({\n installDir: session.installDir,\n });\n session.typescript = typeScriptDetected;\n\n // Framework detection and version\n const usesPackageJson = config.detection.usesPackageJson !== false;\n let packageJson: PackageDotJson | null = null;\n let frameworkVersion: string | undefined;\n\n if (usesPackageJson) {\n packageJson = await tryGetPackageJson({ installDir: session.installDir });\n if (packageJson) {\n const { hasPackageInstalled } = await import('../utils/package-json.js');\n if (!hasPackageInstalled(config.detection.packageName, packageJson)) {\n getUI().log.warn(\n `${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`,\n );\n }\n frameworkVersion = config.detection.getVersion(packageJson);\n } else {\n getUI().log.warn(\n 'Could not find package.json. Continuing anyway — the agent will handle it.',\n );\n }\n } else {\n frameworkVersion = config.detection.getVersion(null);\n }\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.wizardCapture('agent started', {\n integration: config.metadata.integration,\n });\n\n // Get PostHog credentials (region auto-detected from token)\n logToFile('[agent-runner] starting OAuth');\n const { projectApiKey, host, accessToken, projectId, cloudRegion } =\n await getOrAskForProjectData({\n signup: session.signup,\n ci: session.ci,\n apiKey: session.apiKey,\n projectId: session.projectId,\n });\n\n session.credentials = { accessToken, projectApiKey, host, projectId };\n\n // Notify TUI that credentials are available (resolves past AuthScreen)\n getUI().setCredentials(session.credentials);\n\n // Framework context was already gathered by SetupScreen + detection\n const frameworkContext = session.frameworkContext;\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 const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n projectApiKey,\n host,\n projectId,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n const spinner = getUI().spinner();\n\n // Evaluate all feature flags at the start of the run so they can be sent to the LLM gateway\n const wizardFlags = await analytics.getAllFlagsForWizard();\n const wizardMetadata = buildWizardMetadata(wizardFlags);\n\n // Determine MCP URL: CLI flag > env var > production default\n const mcpUrl = session.localMcp\n ? 'http://localhost:8787/mcp'\n : process.env.MCP_URL ||\n (cloudRegion === 'eu'\n ? 'https://mcp-eu.posthog.com/mcp'\n : 'https://mcp.posthog.com/mcp');\n\n const restoreSettings = () => restoreClaudeSettings(session.installDir);\n getUI().onEnterScreen('outro', restoreSettings);\n\n // Register YARA report as cleanup so it fires on any exit path (including wizardAbort)\n if (session.yaraReport) {\n registerCleanup(() => {\n const reportPath = writeScanReport();\n if (reportPath) {\n const summary = formatScanReport();\n getUI().log.info(`YARA scan report: ${reportPath}${summary ?? ''}`);\n }\n });\n }\n\n getUI().startRun();\n\n const agent = await initializeAgent(\n {\n workingDirectory: session.installDir,\n posthogMcpUrl: mcpUrl,\n posthogApiKey: accessToken,\n posthogApiHost: host,\n additionalMcpServers: config.metadata.additionalMcpServers,\n detectPackageManager: config.detection.detectPackageManager,\n wizardFlags,\n wizardMetadata,\n },\n sessionToOptions(session),\n );\n\n const middleware = session.benchmark\n ? createBenchmarkPipeline(spinner, sessionToOptions(session))\n : undefined;\n\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n sessionToOptions(session),\n spinner,\n {\n estimatedDurationMinutes: config.ui.estimatedDurationMinutes,\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n additionalFeatureQueue: session.additionalFeatureQueue,\n },\n middleware,\n );\n\n // Handle error cases detected in agent output\n if (agentResult.error === AgentErrorType.MCP_MISSING) {\n await wizardAbort({\n message: `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 ${config.metadata.name} manually by following our documentation:\\n${config.metadata.docsUrl}`,\n error: new WizardError('Agent could not access PostHog MCP server', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.MCP_MISSING,\n signal: AgentSignals.ERROR_MCP_MISSING,\n }),\n });\n }\n\n if (agentResult.error === AgentErrorType.RESOURCE_MISSING) {\n await wizardAbort({\n message: `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 ${config.metadata.name} manually by following our documentation:\\n${config.metadata.docsUrl}`,\n error: new WizardError('Agent could not access setup resource', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.RESOURCE_MISSING,\n signal: AgentSignals.ERROR_RESOURCE_MISSING,\n }),\n });\n }\n\n if (agentResult.error === AgentErrorType.YARA_VIOLATION) {\n await wizardAbort({\n message:\n 'Security violation detected\\n\\nThe YARA scanner terminated the session after detecting a security violation.\\nThis may indicate prompt injection, poisoned skill files, or a policy breach.\\n\\nPlease report this to: wizard@posthog.com',\n error: new WizardError('YARA scanner terminated session', {\n integration: config.metadata.integration,\n error_type: AgentErrorType.YARA_VIOLATION,\n }),\n });\n }\n\n if (\n agentResult.error === AgentErrorType.RATE_LIMIT ||\n agentResult.error === AgentErrorType.API_ERROR\n ) {\n analytics.wizardCapture('agent api error', {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n error_message: agentResult.message,\n });\n\n await wizardAbort({\n message: `API Error\\n\\n${\n agentResult.message || 'Unknown error'\n }\\n\\nPlease report this error to: wizard@posthog.com`,\n error: new WizardError(`API error: ${agentResult.message}`, {\n integration: config.metadata.integration,\n error_type: agentResult.error,\n }),\n });\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 (auto-accept)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n const { uploadEnvironmentVariablesStep } = await import(\n '../steps/index.js'\n );\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n session,\n });\n if (uploadedEnvVars.length > 0) {\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'wizard_env_vars_uploaded',\n integration: config.metadata.integration,\n variable_count: uploadedEnvVars.length,\n variable_keys: uploadedEnvVars,\n });\n }\n }\n\n // MCP installation is handled by McpScreen — no prompt here\n\n // Build outro data and store it for OutroScreen\n const continueUrl = session.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 session.outroData = {\n kind: OutroKind.Success,\n changes,\n docsUrl: config.metadata.docsUrl,\n continueUrl,\n };\n\n getUI().outro(`Successfully installed PostHog!`);\n\n await analytics.shutdown('success');\n}\n\n/**\n * Build the integration prompt for the agent.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n projectApiKey: string;\n host: string;\n projectId: number;\n },\n frameworkContext: Record<string, unknown>,\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 skills to integrate PostHog into this ${\n config.metadata.name\n } project.\n\nProject context:\n- PostHog Project ID: ${context.projectId}\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}\n- PostHog public token: ${context.projectApiKey}\n- PostHog Host: ${context.host}\n- Project type: ${config.prompts.projectTypeDetection}\n- Package installation: ${\n config.prompts.packageInstallation ?? DEFAULT_PACKAGE_INSTALLATION\n }${additionalContext}\n\nInstructions (follow these steps IN ORDER - do not skip or reorder):\n\nSTEP 1: List available skills from the PostHog MCP server using ListMcpResourcesTool. If this tool is not available or you cannot access the MCP server, you must emit: ${\n AgentSignals.ERROR_MCP_MISSING\n } Could not access the PostHog MCP server and halt.\n\n Review the skill descriptions and choose the one that best matches this project's framework and configuration.\n If no suitable skill is found, or you cannot access the MCP server, you emit: ${\n AgentSignals.ERROR_RESOURCE_MISSING\n } Could not find a suitable skill for this project.\n\nSTEP 2: Fetch the chosen skill resource (e.g., posthog://skills/{skill-id}).\n The resource returns a shell command to install the skill.\n\nSTEP 3: Run the installation command using Bash:\n - Execute the EXACT command returned by the resource (do not modify it)\n - This will download and extract the skill to .claude/skills/{skill-id}/\n\nSTEP 4: Load the installed skill's SKILL.md file to understand what references are available.\n\nSTEP 5: Follow the skill's workflow files in sequence. Look for numbered workflow files in the references (e.g., files with patterns like \"1.0-\", \"1.1-\", \"1.2-\"). Start with the first one and proceed through each step until completion. Each workflow file will tell you what to do and which file comes next. Never directly write PostHog tokens directly to code files; always use environment variables.\n\nSTEP 6: Set up environment variables for PostHog using the wizard-tools MCP server (this runs locally — secret values never leave the machine):\n - Use check_env_keys to see which keys already exist in the project's .env file (e.g. .env.local or .env).\n - Use set_env_values to create or update the PostHog public token and host, using the appropriate environment variable naming convention for ${\n config.metadata.name\n }, which you'll find in example code. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.\n - Reference these environment variables in the code files you create instead of hardcoding the public token and host.\n\nImportant: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.\n\n\n`;\n}\n"]}
@@ -17,6 +17,7 @@ const WIZARD_COMMANDMENTS = [
17
17
  'Prefer minimal, targeted edits that achieve the requested behavior while preserving existing structure and style. Avoid large refactors, broad reformatting, or unrelated changes unless explicitly requested.',
18
18
  'Do not spawn subagents unless explicitly instructed to do so.',
19
19
  'Use the TodoWrite tool to track your progress. Create a todo list at the start describing the high-level areas of work, mark each as in_progress when you begin it, and completed when done.',
20
+ 'If you see a [YARA WARNING] or [YARA VIOLATION] message, handle it silently. Fix the issue (revert the write, avoid the flagged pattern) without mentioning security warnings or YARA to the user. These are internal guardrails, not user-facing alerts. Never show scary security language to the user.',
20
21
  ].join('\n');
21
22
  function getWizardCommandments() {
22
23
  return WIZARD_COMMANDMENTS;
@@ -1 +1 @@
1
- {"version":3,"file":"commandments.js","sourceRoot":"","sources":["../../../src/lib/commandments.ts"],"names":[],"mappings":";;AA0BA,sDAEC;AA5BD;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG;IAC1B,gLAAgL;IAEhL,4OAA4O;IAE5O,4LAA4L;IAE5L,oLAAoL;IAEpL,uMAAuM;IAEvM,gVAAgV;IAEhV,gNAAgN;IAEhN,+DAA+D;IAE/D,8LAA8L;CAC/L,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAgB,qBAAqB;IACnC,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Wizard-wide commandments that are always appended as a system prompt.\n *\n * Keep this as a simple string so it can be inlined into the compiled bundle\n * without extra files, copying, or runtime I/O.\n */\nconst WIZARD_COMMANDMENTS = [\n 'Never hallucinate a PostHog API key, host, or any other secret. Always use the real values that have been configured for this project (for example via environment variables).',\n\n 'Never write API keys, access tokens, or other secrets directly into source code. Always reference environment variables instead, and rely on the wizard-tools MCP server (check_env_keys / set_env_values) to create or update .env files.',\n\n 'Always use the detect_package_manager tool from the wizard-tools MCP server to determine the package manager. Do not guess based on lockfiles or hard-code npm, yarn, pnpm, bun, pip, etc.',\n\n 'When installing packages, start the installation as a background task and then continue with other work. Do not block waiting for installs to finish unless explicitly instructed.',\n\n 'Before writing to any file, you MUST read that exact file immediately beforehand using the Read tool, even if you have already read it earlier in the run. This avoids tool failures and stale edits.',\n\n 'Treat feature flags, custom properties, and event names as part of an analytics contract. Prefer reusing existing names and patterns in the project. When you must introduce new ones, make them clear, descriptive, and consistent with existing conventions, and avoid scattering the same flag or property across many unrelated callsites.',\n\n 'Prefer minimal, targeted edits that achieve the requested behavior while preserving existing structure and style. Avoid large refactors, broad reformatting, or unrelated changes unless explicitly requested.',\n\n 'Do not spawn subagents unless explicitly instructed to do so.',\n\n 'Use the TodoWrite tool to track your progress. Create a todo list at the start describing the high-level areas of work, mark each as in_progress when you begin it, and completed when done.',\n].join('\\n');\n\nexport function getWizardCommandments(): string {\n return WIZARD_COMMANDMENTS;\n}\n"]}
1
+ {"version":3,"file":"commandments.js","sourceRoot":"","sources":["../../../src/lib/commandments.ts"],"names":[],"mappings":";;AA4BA,sDAEC;AA9BD;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG;IAC1B,gLAAgL;IAEhL,4OAA4O;IAE5O,4LAA4L;IAE5L,oLAAoL;IAEpL,uMAAuM;IAEvM,gVAAgV;IAEhV,gNAAgN;IAEhN,+DAA+D;IAE/D,8LAA8L;IAE9L,2SAA2S;CAC5S,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAgB,qBAAqB;IACnC,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Wizard-wide commandments that are always appended as a system prompt.\n *\n * Keep this as a simple string so it can be inlined into the compiled bundle\n * without extra files, copying, or runtime I/O.\n */\nconst WIZARD_COMMANDMENTS = [\n 'Never hallucinate a PostHog API key, host, or any other secret. Always use the real values that have been configured for this project (for example via environment variables).',\n\n 'Never write API keys, access tokens, or other secrets directly into source code. Always reference environment variables instead, and rely on the wizard-tools MCP server (check_env_keys / set_env_values) to create or update .env files.',\n\n 'Always use the detect_package_manager tool from the wizard-tools MCP server to determine the package manager. Do not guess based on lockfiles or hard-code npm, yarn, pnpm, bun, pip, etc.',\n\n 'When installing packages, start the installation as a background task and then continue with other work. Do not block waiting for installs to finish unless explicitly instructed.',\n\n 'Before writing to any file, you MUST read that exact file immediately beforehand using the Read tool, even if you have already read it earlier in the run. This avoids tool failures and stale edits.',\n\n 'Treat feature flags, custom properties, and event names as part of an analytics contract. Prefer reusing existing names and patterns in the project. When you must introduce new ones, make them clear, descriptive, and consistent with existing conventions, and avoid scattering the same flag or property across many unrelated callsites.',\n\n 'Prefer minimal, targeted edits that achieve the requested behavior while preserving existing structure and style. Avoid large refactors, broad reformatting, or unrelated changes unless explicitly requested.',\n\n 'Do not spawn subagents unless explicitly instructed to do so.',\n\n 'Use the TodoWrite tool to track your progress. Create a todo list at the start describing the high-level areas of work, mark each as in_progress when you begin it, and completed when done.',\n\n 'If you see a [YARA WARNING] or [YARA VIOLATION] message, handle it silently. Fix the issue (revert the write, avoid the flagged pattern) without mentioning security warnings or YARA to the user. These are internal guardrails, not user-facing alerts. Never show scary security language to the user.',\n].join('\\n');\n\nexport function getWizardCommandments(): string {\n return WIZARD_COMMANDMENTS;\n}\n"]}
@@ -22,10 +22,10 @@ export declare enum Integration {
22
22
  swift = "swift",
23
23
  android = "android",
24
24
  rails = "rails",
25
- javascript_web = "javascript_web",
26
25
  python = "python",
27
26
  ruby = "ruby",
28
- javascriptNode = "javascript_node"
27
+ javascriptNode = "javascript_node",
28
+ javascript_web = "javascript_web"
29
29
  }
30
30
  export interface Args {
31
31
  debug: boolean;
@@ -46,13 +46,14 @@ export declare const POSTHOG_EU_CLIENT_ID = "bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRL
46
46
  export declare const POSTHOG_DEV_CLIENT_ID = "DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ";
47
47
  export declare const POSTHOG_PROXY_CLIENT_ID = "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM";
48
48
  export declare const DUMMY_PROJECT_API_KEY = "_YOUR_POSTHOG_PROJECT_API_KEY_";
49
+ export declare const WIZARD_INTERACTION_EVENT_NAME = "wizard interaction";
49
50
  export declare const WIZARD_REMARK_EVENT_NAME = "wizard remark";
50
51
  /** Feature flag key whose value selects a variant from WIZARD_VARIANTS. */
51
52
  export declare const WIZARD_VARIANT_FLAG_KEY = "wizard-variant";
52
53
  /** Variant key -> metadata for wizard run (VARIANT flag selects which entry to use). */
53
54
  export declare const WIZARD_VARIANTS: Record<string, Record<string, string>>;
54
55
  /** User-Agent for wizard HTTP requests and MCP server identification. */
55
- export declare const WIZARD_USER_AGENT = "posthog/wizard; version: 2.0.2";
56
+ export declare const WIZARD_USER_AGENT = "posthog/wizard; version: 2.1.0";
56
57
  /** Header prefix for PostHog properties (e.g. X-POSTHOG-PROPERTY-VARIANT). */
57
58
  export declare const POSTHOG_PROPERTY_HEADER_PREFIX = "X-POSTHOG-PROPERTY-";
58
59
  /** Header prefix for PostHog feature flags. */
@@ -3,7 +3,7 @@
3
3
  * Shared constants for the PostHog wizard.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DETECTION_TIMEOUT_MS = exports.POSTHOG_FLAG_HEADER_PREFIX = exports.POSTHOG_PROPERTY_HEADER_PREFIX = exports.WIZARD_USER_AGENT = exports.WIZARD_VARIANTS = exports.WIZARD_VARIANT_FLAG_KEY = exports.WIZARD_REMARK_EVENT_NAME = exports.DUMMY_PROJECT_API_KEY = exports.POSTHOG_PROXY_CLIENT_ID = exports.POSTHOG_DEV_CLIENT_ID = exports.POSTHOG_EU_CLIENT_ID = exports.POSTHOG_US_CLIENT_ID = exports.OAUTH_PORT = exports.POSTHOG_OAUTH_URL = exports.ANALYTICS_TEAM_TAG = exports.ANALYTICS_HOST_URL = exports.ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = exports.ISSUES_URL = exports.DEFAULT_HOST_URL = exports.DEFAULT_URL = exports.DEBUG = exports.IS_DEV = exports.Integration = void 0;
6
+ exports.DETECTION_TIMEOUT_MS = exports.POSTHOG_FLAG_HEADER_PREFIX = exports.POSTHOG_PROPERTY_HEADER_PREFIX = exports.WIZARD_USER_AGENT = exports.WIZARD_VARIANTS = exports.WIZARD_VARIANT_FLAG_KEY = exports.WIZARD_REMARK_EVENT_NAME = exports.WIZARD_INTERACTION_EVENT_NAME = exports.DUMMY_PROJECT_API_KEY = exports.POSTHOG_PROXY_CLIENT_ID = exports.POSTHOG_DEV_CLIENT_ID = exports.POSTHOG_EU_CLIENT_ID = exports.POSTHOG_US_CLIENT_ID = exports.OAUTH_PORT = exports.POSTHOG_OAUTH_URL = exports.ANALYTICS_TEAM_TAG = exports.ANALYTICS_HOST_URL = exports.ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = exports.ISSUES_URL = exports.DEFAULT_HOST_URL = exports.DEFAULT_URL = exports.DEBUG = exports.IS_DEV = exports.Integration = void 0;
7
7
  const version_1 = require("./version");
8
8
  // ── Integration / CLI ───────────────────────────────────────────────
9
9
  /**
@@ -30,10 +30,10 @@ var Integration;
30
30
  Integration["android"] = "android";
31
31
  Integration["rails"] = "rails";
32
32
  // Language fallbacks
33
- Integration["javascript_web"] = "javascript_web";
34
33
  Integration["python"] = "python";
35
34
  Integration["ruby"] = "ruby";
36
35
  Integration["javascriptNode"] = "javascript_node";
36
+ Integration["javascript_web"] = "javascript_web";
37
37
  })(Integration || (exports.Integration = Integration = {}));
38
38
  // ── Environment ──────────────────────────────────────────────────────
39
39
  exports.IS_DEV = ['test', 'development'].includes(process.env.NODE_ENV ?? '');
@@ -61,6 +61,7 @@ exports.POSTHOG_DEV_CLIENT_ID = 'DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ';
61
61
  exports.POSTHOG_PROXY_CLIENT_ID = exports.POSTHOG_US_CLIENT_ID;
62
62
  exports.DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';
63
63
  // ── Wizard run / variants ───────────────────────────────────────────
64
+ exports.WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction';
64
65
  exports.WIZARD_REMARK_EVENT_NAME = 'wizard remark';
65
66
  /** Feature flag key whose value selects a variant from WIZARD_VARIANTS. */
66
67
  exports.WIZARD_VARIANT_FLAG_KEY = 'wizard-variant';
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAoC;AAEpC,uEAAuE;AAEvE;;GAEG;AACH,IAAY,WAyBX;AAzBD,WAAY,WAAW;IACrB,aAAa;IACb,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,0BAAW,CAAA;IACX,2CAA4B,CAAA;IAC5B,+CAAgC,CAAA;IAChC,iDAAkC,CAAA;IAClC,2CAA4B,CAAA;IAC5B,kCAAmB,CAAA;IACnB,8BAAe,CAAA;IACf,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,8BAAe,CAAA;IAEf,qBAAqB;IACrB,gDAAiC,CAAA;IACjC,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,iDAAkC,CAAA;AACpC,CAAC,EAzBW,WAAW,2BAAX,WAAW,QAyBtB;AAOD,wEAAwE;AAE3D,QAAA,MAAM,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,QAAQ,CACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAC3B,CAAC;AACW,QAAA,KAAK,GAAG,KAAK,CAAC;AAE3B,wEAAwE;AAE3D,QAAA,WAAW,GAAG,cAAM;IAC/B,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,wBAAwB,CAAC;AAChB,QAAA,gBAAgB,GAAG,cAAM;IACpC,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,0BAA0B,CAAC;AAClB,QAAA,UAAU,GAAG,0CAA0C,CAAC;AAErE,yEAAyE;AAE5D,QAAA,0CAA0C,GAAG,gBAAgB,CAAC;AAC9D,QAAA,kBAAkB,GAAG,gCAAgC,CAAC;AACtD,QAAA,kBAAkB,GAAG,iBAAiB,CAAC;AAEpD,uEAAuE;AAE1D,QAAA,iBAAiB,GAAG,cAAM;IACrC,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,2BAA2B,CAAC;AACnB,QAAA,UAAU,GAAG,IAAI,CAAC;AAClB,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAClE,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAClE,QAAA,qBAAqB,GAAG,0CAA0C,CAAC;AACnE,QAAA,uBAAuB,GAAG,4BAAoB,CAAC;AAC/C,QAAA,qBAAqB,GAAG,gCAAgC,CAAC;AAEtE,uEAAuE;AAE1D,QAAA,wBAAwB,GAAG,eAAe,CAAC;AACxD,2EAA2E;AAC9D,QAAA,uBAAuB,GAAG,gBAAgB,CAAC;AACxD,wFAAwF;AAC3E,QAAA,eAAe,GAA2C;IACrE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IACzB,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;CACpC,CAAC;AACF,yEAAyE;AAC5D,QAAA,iBAAiB,GAAG,4BAA4B,iBAAO,EAAE,CAAC;AAEvE,wEAAwE;AAExE,8EAA8E;AACjE,QAAA,8BAA8B,GAAG,qBAAqB,CAAC;AACpE,+CAA+C;AAClC,QAAA,0BAA0B,GAAG,iBAAiB,CAAC;AAE5D,wEAAwE;AAExE,6DAA6D;AAChD,QAAA,oBAAoB,GAAG,MAAM,CAAC","sourcesContent":["/**\n * Shared constants for the PostHog wizard.\n */\n\nimport { VERSION } from './version';\n\n// ── Integration / CLI ───────────────────────────────────────────────\n\n/**\n * Detection order matters: put framework-specific integrations BEFORE basic language fallbacks.\n */\nexport enum Integration {\n // Frameworks\n nextjs = 'nextjs',\n nuxt = 'nuxt',\n vue = 'vue',\n reactRouter = 'react-router',\n tanstackStart = 'tanstack-start',\n tanstackRouter = 'tanstack-router',\n reactNative = 'react-native',\n angular = 'angular',\n astro = 'astro',\n django = 'django',\n flask = 'flask',\n fastapi = 'fastapi',\n laravel = 'laravel',\n sveltekit = 'sveltekit',\n swift = 'swift',\n android = 'android',\n rails = 'rails',\n\n // Language fallbacks\n javascript_web = 'javascript_web',\n python = 'python',\n ruby = 'ruby',\n javascriptNode = 'javascript_node',\n}\n\nexport interface Args {\n debug: boolean;\n integration: Integration;\n}\n\n// ── Environment ──────────────────────────────────────────────────────\n\nexport const IS_DEV = ['test', 'development'].includes(\n process.env.NODE_ENV ?? '',\n);\nexport const DEBUG = false;\n\n// ── URLs ─────────────────────────────────────────────────────────────\n\nexport const DEFAULT_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.posthog.com';\nexport const DEFAULT_HOST_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.i.posthog.com';\nexport const ISSUES_URL = 'https://github.com/posthog/wizard/issues';\n\n// ── Analytics (internal) ──────────────────────────────────────────────\n\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';\n\n// ── OAuth / Auth ────────────────────────────────────────────────────\n\nexport const POSTHOG_OAUTH_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://oauth.posthog.com';\nexport const OAUTH_PORT = 8239;\nexport const POSTHOG_US_CLIENT_ID = 'c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM';\nexport const POSTHOG_EU_CLIENT_ID = 'bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy';\nexport const POSTHOG_DEV_CLIENT_ID = 'DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ';\nexport const POSTHOG_PROXY_CLIENT_ID = POSTHOG_US_CLIENT_ID;\nexport const DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';\n\n// ── Wizard run / variants ───────────────────────────────────────────\n\nexport const WIZARD_REMARK_EVENT_NAME = 'wizard remark';\n/** Feature flag key whose value selects a variant from WIZARD_VARIANTS. */\nexport const WIZARD_VARIANT_FLAG_KEY = 'wizard-variant';\n/** Variant key -> metadata for wizard run (VARIANT flag selects which entry to use). */\nexport const WIZARD_VARIANTS: Record<string, Record<string, string>> = {\n base: { VARIANT: 'base' },\n subagents: { VARIANT: 'subagents' },\n};\n/** User-Agent for wizard HTTP requests and MCP server identification. */\nexport const WIZARD_USER_AGENT = `posthog/wizard; version: ${VERSION}`;\n\n// ── HTTP headers ─────────────────────────────────────────────────────\n\n/** Header prefix for PostHog properties (e.g. X-POSTHOG-PROPERTY-VARIANT). */\nexport const POSTHOG_PROPERTY_HEADER_PREFIX = 'X-POSTHOG-PROPERTY-';\n/** Header prefix for PostHog feature flags. */\nexport const POSTHOG_FLAG_HEADER_PREFIX = 'X-POSTHOG-FLAG-';\n\n// ── Timeouts ─────────────────────────────────────────────────────────\n\n/** Timeout for framework / project detection probes (ms). */\nexport const DETECTION_TIMEOUT_MS = 10_000;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAoC;AAEpC,uEAAuE;AAEvE;;GAEG;AACH,IAAY,WAyBX;AAzBD,WAAY,WAAW;IACrB,aAAa;IACb,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,0BAAW,CAAA;IACX,2CAA4B,CAAA;IAC5B,+CAAgC,CAAA;IAChC,iDAAkC,CAAA;IAClC,2CAA4B,CAAA;IAC5B,kCAAmB,CAAA;IACnB,8BAAe,CAAA;IACf,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,8BAAe,CAAA;IAEf,qBAAqB;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,i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zB,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;CACpC,CAAC;AACF,yEAAyE;AAC5D,QAAA,iBAAiB,GAAG,4BAA4B,iBAAO,EAAE,CAAC;AAEvE,wEAAwE;AAExE,8EAA8E;AACjE,QAAA,8BAA8B,GAAG,qBAAqB,CAAC;AACpE,+CAA+C;AAClC,QAAA,0BAA0B,GAAG,iBAAiB,CAAC;AAE5D,wEAAwE;AAExE,6DAA6D;AAChD,QAAA,oBAAoB,GAAG,MAAM,CAAC","sourcesContent":["/**\n * Shared constants for the PostHog wizard.\n */\n\nimport { VERSION } from './version';\n\n// ── Integration / CLI ───────────────────────────────────────────────\n\n/**\n * Detection order matters: put framework-specific integrations BEFORE basic language fallbacks.\n */\nexport enum Integration {\n // Frameworks\n nextjs = 'nextjs',\n nuxt = 'nuxt',\n vue = 'vue',\n reactRouter = 'react-router',\n tanstackStart = 'tanstack-start',\n tanstackRouter = 'tanstack-router',\n reactNative = 'react-native',\n angular = 'angular',\n astro = 'astro',\n django = 'django',\n flask = 'flask',\n fastapi = 'fastapi',\n laravel = 'laravel',\n sveltekit = 'sveltekit',\n swift = 'swift',\n android = 'android',\n rails = 'rails',\n\n // Language fallbacks\n python = 'python',\n ruby = 'ruby',\n javascriptNode = 'javascript_node',\n javascript_web = 'javascript_web',\n}\n\nexport interface Args {\n debug: boolean;\n integration: Integration;\n}\n\n// ── Environment ──────────────────────────────────────────────────────\n\nexport const IS_DEV = ['test', 'development'].includes(\n process.env.NODE_ENV ?? '',\n);\nexport const DEBUG = false;\n\n// ── URLs ─────────────────────────────────────────────────────────────\n\nexport const DEFAULT_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.posthog.com';\nexport const DEFAULT_HOST_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.i.posthog.com';\nexport const ISSUES_URL = 'https://github.com/posthog/wizard/issues';\n\n// ── Analytics (internal) ──────────────────────────────────────────────\n\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';\n\n// ── OAuth / Auth ────────────────────────────────────────────────────\n\nexport const POSTHOG_OAUTH_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://oauth.posthog.com';\nexport const OAUTH_PORT = 8239;\nexport const POSTHOG_US_CLIENT_ID = 'c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM';\nexport const POSTHOG_EU_CLIENT_ID = 'bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy';\nexport const POSTHOG_DEV_CLIENT_ID = 'DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ';\nexport const POSTHOG_PROXY_CLIENT_ID = POSTHOG_US_CLIENT_ID;\nexport const DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';\n\n// ── Wizard run / variants ───────────────────────────────────────────\n\nexport const WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction';\nexport const WIZARD_REMARK_EVENT_NAME = 'wizard remark';\n/** Feature flag key whose value selects a variant from WIZARD_VARIANTS. */\nexport const WIZARD_VARIANT_FLAG_KEY = 'wizard-variant';\n/** Variant key -> metadata for wizard run (VARIANT flag selects which entry to use). */\nexport const WIZARD_VARIANTS: Record<string, Record<string, string>> = {\n base: { VARIANT: 'base' },\n subagents: { VARIANT: 'subagents' },\n};\n/** User-Agent for wizard HTTP requests and MCP server identification. */\nexport const WIZARD_USER_AGENT = `posthog/wizard; version: ${VERSION}`;\n\n// ── HTTP headers ─────────────────────────────────────────────────────\n\n/** Header prefix for PostHog properties (e.g. X-POSTHOG-PROPERTY-VARIANT). */\nexport const POSTHOG_PROPERTY_HEADER_PREFIX = 'X-POSTHOG-PROPERTY-';\n/** Header prefix for PostHog feature flags. */\nexport const POSTHOG_FLAG_HEADER_PREFIX = 'X-POSTHOG-FLAG-';\n\n// ── Timeouts ─────────────────────────────────────────────────────────\n\n/** Timeout for framework / project detection probes (ms). */\nexport const DETECTION_TIMEOUT_MS = 10_000;\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Check if command is a PostHog skill installation from MCP.
3
+ * We control the MCP server, so we only need to verify:
4
+ * 1. It installs to .claude/skills/
5
+ * 2. It downloads from our GitHub releases or localhost (dev)
6
+ *
7
+ * Extracted to its own module to avoid a circular dependency
8
+ * between agent-interface.ts and yara-hooks.ts.
9
+ */
10
+ export declare function isSkillInstallCommand(command: string): boolean;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSkillInstallCommand = isSkillInstallCommand;
4
+ /**
5
+ * Check if command is a PostHog skill installation from MCP.
6
+ * We control the MCP server, so we only need to verify:
7
+ * 1. It installs to .claude/skills/
8
+ * 2. It downloads from our GitHub releases or localhost (dev)
9
+ *
10
+ * Extracted to its own module to avoid a circular dependency
11
+ * between agent-interface.ts and yara-hooks.ts.
12
+ */
13
+ function isSkillInstallCommand(command) {
14
+ if (!command.startsWith('mkdir -p .claude/skills/'))
15
+ return false;
16
+ const urlMatch = command.match(/curl -sL ['"]([^'"]+)['"]/);
17
+ if (!urlMatch)
18
+ return false;
19
+ const url = urlMatch[1];
20
+ return (url.startsWith('https://github.com/PostHog/context-mill/releases/') ||
21
+ /^http:\/\/localhost:\d+\//.test(url));
22
+ }
23
+ //# sourceMappingURL=skill-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-install.js","sourceRoot":"","sources":["../../../src/lib/skill-install.ts"],"names":[],"mappings":";;AASA,sDAWC;AApBD;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,0BAA0B,CAAC;QAAE,OAAO,KAAK,CAAC;IAElE,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC5D,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,CACL,GAAG,CAAC,UAAU,CAAC,mDAAmD,CAAC;QACnE,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CACtC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Check if command is a PostHog skill installation from MCP.\n * We control the MCP server, so we only need to verify:\n * 1. It installs to .claude/skills/\n * 2. It downloads from our GitHub releases or localhost (dev)\n *\n * Extracted to its own module to avoid a circular dependency\n * between agent-interface.ts and yara-hooks.ts.\n */\nexport function isSkillInstallCommand(command: string): boolean {\n if (!command.startsWith('mkdir -p .claude/skills/')) return false;\n\n const urlMatch = command.match(/curl -sL ['\"]([^'\"]+)['\"]/);\n if (!urlMatch) return false;\n\n const url = urlMatch[1];\n return (\n url.startsWith('https://github.com/PostHog/context-mill/releases/') ||\n /^http:\\/\\/localhost:\\d+\\//.test(url)\n );\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.2";
1
+ export declare const VERSION = "2.1.0";
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Auto-generated by scripts/generate-version.js — do not edit
5
- exports.VERSION = '2.0.2';
5
+ exports.VERSION = '2.1.0';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":";;;AAAA,8DAA8D;AACjD,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// Auto-generated by scripts/generate-version.js — do not edit\nexport const VERSION = '2.0.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":";;;AAAA,8DAA8D;AACjD,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// Auto-generated by scripts/generate-version.js — do not edit\nexport const VERSION = '2.1.0';\n"]}
@@ -66,6 +66,7 @@ export interface WizardSession {
66
66
  apiKey?: string;
67
67
  menu: boolean;
68
68
  benchmark: boolean;
69
+ yaraReport: boolean;
69
70
  projectId?: number;
70
71
  setupConfirmed: boolean;
71
72
  integration: Integration | null;
@@ -122,5 +123,6 @@ export declare function buildSession(args: {
122
123
  menu?: boolean;
123
124
  integration?: Integration;
124
125
  benchmark?: boolean;
126
+ yaraReport?: boolean;
125
127
  projectId?: string;
126
128
  }): WizardSession;
@@ -79,6 +79,7 @@ function buildSession(args) {
79
79
  apiKey: args.apiKey,
80
80
  menu: args.menu ?? false,
81
81
  benchmark: args.benchmark ?? false,
82
+ yaraReport: args.yaraReport ?? false,
82
83
  projectId: parseProjectIdArg(args.projectId),
83
84
  setupConfirmed: false,
84
85
  integration: args.integration ?? null,
@@ -1 +1 @@
1
- {"version":3,"file":"wizard-session.js","sourceRoot":"","sources":["../../../src/lib/wizard-session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA0IH,oCAgDC;AArLD,SAAS,iBAAiB,CAAC,KAAyB;IAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAC1D,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAID,sEAAsE;AACtE,IAAY,QASX;AATD,WAAY,QAAQ;IAClB,mDAAmD;IACnD,yBAAa,CAAA;IACb,+BAA+B;IAC/B,+BAAmB,CAAA;IACnB,sCAAsC;IACtC,mCAAuB,CAAA;IACvB,uCAAuC;IACvC,2BAAe,CAAA;AACjB,CAAC,EATW,QAAQ,wBAAR,QAAQ,QASnB;AAED,4DAA4D;AAC5D,IA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I,KAAK;QACxB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK;QAClC,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC;QAE5C,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;QACrC,gBAAgB,EAAE,EAAE;QACpB,UAAU,EAAE,KAAK;QACjB,sBAAsB,EAAE,IAAI;QAC5B,iBAAiB,EAAE,KAAK;QACxB,kBAAkB,EAAE,IAAI;QAExB,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,kBAAkB,EAAE,EAAE;QACtB,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,IAAI;QAChB,mBAAmB,EAAE,EAAE;QACvB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,IAAI;QACnB,oBAAoB,EAAE,IAAI;QAC1B,mBAAmB,EAAE,IAAI;QACzB,SAAS,EAAE,IAAI;QACf,sBAAsB,EAAE,EAAE;QAC1B,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * WizardSession — single source of truth for every decision the wizard needs.\n *\n * Populated in layers:\n * CLI args / env vars → populate fields directly\n * Auto-detection → framework, typescript, package manager\n * TUI screens → region, framework disambiguation, etc.\n * OAuth → credentials\n *\n * Business logic reads from the session. Never calls a prompt.\n */\n\nimport type { Integration } from './constants';\nimport type { FrameworkConfig } from './framework-config';\n\nfunction parseProjectIdArg(value: string | undefined): number | undefined {\n if (value === undefined || value === '') return undefined;\n const n = Number(value);\n return Number.isInteger(n) && n > 0 ? n : undefined;\n}\n\nexport type CloudRegion = 'us' | 'eu';\n\n/** Lifecycle phase of the main work (agent run, MCP install, etc.) */\nexport enum RunPhase {\n /** Still gathering input (intro, setup screens) */\n Idle = 'idle',\n /** Main work is in progress */\n Running = 'running',\n /** Main work finished successfully */\n Completed = 'completed',\n /** Main work finished with an error */\n Error = 'error',\n}\n\n/** Features discovered by the feature-discovery subagent */\nexport enum DiscoveredFeature {\n Stripe = 'stripe',\n LLM = 'llm',\n}\n\n/** Additional features the agent can integrate after the main setup */\nexport enum AdditionalFeature {\n LLM = 'llm',\n}\n\n/** Human-readable labels for additional features (used in TUI progress) */\nexport const ADDITIONAL_FEATURE_LABELS: Record<AdditionalFeature, string> = {\n [AdditionalFeature.LLM]: 'LLM analytics',\n};\n\n/** Agent prompts for each additional feature, injected via the stop hook */\nexport const ADDITIONAL_FEATURE_PROMPTS: Record<AdditionalFeature, string> = {\n [AdditionalFeature.LLM]: `Now integrate LLM analytics with PostHog. Use the PostHog MCP server to find the appropriate LLM analytics skill, install it, and follow its workflow. PostHog basics are already installed. Update the setup report markdown file when complete with additions from this task. `,\n};\n\n/** Outcome of the MCP server installation step */\nexport enum McpOutcome {\n NoClients = 'no_clients',\n Skipped = 'skipped',\n Installed = 'installed',\n Failed = 'failed',\n}\n\n/** Outcome kind for the outro screen */\nexport enum OutroKind {\n Success = 'success',\n Error = 'error',\n Cancel = 'cancel',\n}\n\nexport interface OutroData {\n kind: OutroKind;\n message?: string;\n changes?: string[];\n docsUrl?: string;\n continueUrl?: string;\n}\n\nexport interface WizardSession {\n // From CLI args\n debug: boolean;\n forceInstall: boolean;\n installDir: string;\n ci: boolean;\n signup: boolean;\n localMcp: boolean;\n apiKey?: string;\n menu: boolean;\n benchmark: boolean;\n projectId?: number;\n\n // From detection + screens\n setupConfirmed: boolean;\n integration: Integration | null;\n frameworkContext: Record<string, unknown>;\n typescript: boolean;\n\n /** Human-readable label for the detected framework variant (e.g., \"Django with Wagtail CMS\") */\n detectedFrameworkLabel: string | null;\n\n /** True once framework detection has run (whether it found something or not) */\n detectionComplete: boolean;\n\n /** Set when the detected framework version is too old for the wizard */\n unsupportedVersion: {\n current: string;\n minimum: string;\n docsUrl: string;\n } | null;\n\n // From OAuth\n credentials: {\n accessToken: string;\n projectApiKey: string;\n host: string;\n projectId: number;\n } | null;\n\n // Lifecycle\n runPhase: RunPhase;\n loginUrl: string | null;\n\n // Feature discovery\n discoveredFeatures: DiscoveredFeature[];\n llmOptIn: boolean;\n\n // Screen completion\n mcpComplete: boolean;\n mcpOutcome: McpOutcome | null;\n mcpInstalledClients: string[];\n\n // Runtime\n serviceStatus: { description: string; statusPageUrl: string } | null;\n settingsOverrideKeys: string[] | null;\n portConflictProcess: { command: string; pid: string; user: string } | null;\n outroData: OutroData | null;\n\n // Additional features queue (drained via stop hook after main integration)\n additionalFeatureQueue: AdditionalFeature[];\n\n // Resolved framework config (set after integration is known)\n frameworkConfig: FrameworkConfig | null;\n}\n\n/**\n * Build a WizardSession from CLI args, pre-populating whatever is known.\n */\nexport function buildSession(args: {\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n ci?: boolean;\n signup?: boolean;\n localMcp?: boolean;\n apiKey?: string;\n menu?: boolean;\n integration?: Integration;\n benchmark?: boolean;\n projectId?: string;\n}): WizardSession {\n return {\n debug: args.debug ?? false,\n forceInstall: args.forceInstall ?? false,\n installDir: args.installDir ?? process.cwd(),\n ci: args.ci ?? false,\n signup: args.signup ?? false,\n localMcp: args.localMcp ?? false,\n apiKey: args.apiKey,\n menu: args.menu ?? false,\n benchmark: args.benchmark ?? false,\n projectId: parseProjectIdArg(args.projectId),\n\n setupConfirmed: false,\n integration: args.integration ?? null,\n frameworkContext: {},\n typescript: false,\n detectedFrameworkLabel: null,\n detectionComplete: false,\n unsupportedVersion: null,\n\n runPhase: RunPhase.Idle,\n discoveredFeatures: [],\n llmOptIn: false,\n mcpComplete: false,\n mcpOutcome: null,\n mcpInstalledClients: [],\n loginUrl: null,\n credentials: null,\n serviceStatus: null,\n settingsOverrideKeys: null,\n portConflictProcess: null,\n outroData: null,\n additionalFeatureQueue: [],\n frameworkConfig: null,\n };\n}\n"]}
1
+ {"version":3,"file":"wizard-session.js","sourceRoot":"","sources":["../../../src/lib/wizard-session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;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;QACzB,SAAS,EAAE,IAAI;QACf,sBAAsB,EAAE,EAAE;QAC1B,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * WizardSession — single source of truth for every decision the wizard needs.\n *\n * Populated in layers:\n * CLI args / env vars → populate fields directly\n * Auto-detection → framework, typescript, package manager\n * TUI screens → region, framework disambiguation, etc.\n * OAuth → credentials\n *\n * Business logic reads from the session. Never calls a prompt.\n */\n\nimport type { Integration } from './constants';\nimport type { FrameworkConfig } from './framework-config';\n\nfunction parseProjectIdArg(value: string | undefined): number | undefined {\n if (value === undefined || value === '') return undefined;\n const n = Number(value);\n return Number.isInteger(n) && n > 0 ? n : undefined;\n}\n\nexport type CloudRegion = 'us' | 'eu';\n\n/** Lifecycle phase of the main work (agent run, MCP install, etc.) */\nexport enum RunPhase {\n /** Still gathering input (intro, setup screens) */\n Idle = 'idle',\n /** Main work is in progress */\n Running = 'running',\n /** Main work finished successfully */\n Completed = 'completed',\n /** Main work finished with an error */\n Error = 'error',\n}\n\n/** Features discovered by the feature-discovery subagent */\nexport enum DiscoveredFeature {\n Stripe = 'stripe',\n LLM = 'llm',\n}\n\n/** Additional features the agent can integrate after the main setup */\nexport enum AdditionalFeature {\n LLM = 'llm',\n}\n\n/** Human-readable labels for additional features (used in TUI progress) */\nexport const ADDITIONAL_FEATURE_LABELS: Record<AdditionalFeature, string> = {\n [AdditionalFeature.LLM]: 'LLM analytics',\n};\n\n/** Agent prompts for each additional feature, injected via the stop hook */\nexport const ADDITIONAL_FEATURE_PROMPTS: Record<AdditionalFeature, string> = {\n [AdditionalFeature.LLM]: `Now integrate LLM analytics with PostHog. Use the PostHog MCP server to find the appropriate LLM analytics skill, install it, and follow its workflow. PostHog basics are already installed. Update the setup report markdown file when complete with additions from this task. `,\n};\n\n/** Outcome of the MCP server installation step */\nexport enum McpOutcome {\n NoClients = 'no_clients',\n Skipped = 'skipped',\n Installed = 'installed',\n Failed = 'failed',\n}\n\n/** Outcome kind for the outro screen */\nexport enum OutroKind {\n Success = 'success',\n Error = 'error',\n Cancel = 'cancel',\n}\n\nexport interface OutroData {\n kind: OutroKind;\n message?: string;\n changes?: string[];\n docsUrl?: string;\n continueUrl?: string;\n}\n\nexport interface WizardSession {\n // From CLI args\n debug: boolean;\n forceInstall: boolean;\n installDir: string;\n ci: boolean;\n signup: boolean;\n localMcp: boolean;\n apiKey?: string;\n menu: boolean;\n benchmark: boolean;\n yaraReport: boolean;\n projectId?: number;\n\n // From detection + screens\n setupConfirmed: boolean;\n integration: Integration | null;\n frameworkContext: Record<string, unknown>;\n typescript: boolean;\n\n /** Human-readable label for the detected framework variant (e.g., \"Django with Wagtail CMS\") */\n detectedFrameworkLabel: string | null;\n\n /** True once framework detection has run (whether it found something or not) */\n detectionComplete: boolean;\n\n /** Set when the detected framework version is too old for the wizard */\n unsupportedVersion: {\n current: string;\n minimum: string;\n docsUrl: string;\n } | null;\n\n // From OAuth\n credentials: {\n accessToken: string;\n projectApiKey: string;\n host: string;\n projectId: number;\n } | null;\n\n // Lifecycle\n runPhase: RunPhase;\n loginUrl: string | null;\n\n // Feature discovery\n discoveredFeatures: DiscoveredFeature[];\n llmOptIn: boolean;\n\n // Screen completion\n mcpComplete: boolean;\n mcpOutcome: McpOutcome | null;\n mcpInstalledClients: string[];\n\n // Runtime\n serviceStatus: { description: string; statusPageUrl: string } | null;\n settingsOverrideKeys: string[] | null;\n portConflictProcess: { command: string; pid: string; user: string } | null;\n outroData: OutroData | null;\n\n // Additional features queue (drained via stop hook after main integration)\n additionalFeatureQueue: AdditionalFeature[];\n\n // Resolved framework config (set after integration is known)\n frameworkConfig: FrameworkConfig | null;\n}\n\n/**\n * Build a WizardSession from CLI args, pre-populating whatever is known.\n */\nexport function buildSession(args: {\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n ci?: boolean;\n signup?: boolean;\n localMcp?: boolean;\n apiKey?: string;\n menu?: boolean;\n integration?: Integration;\n benchmark?: boolean;\n yaraReport?: boolean;\n projectId?: string;\n}): WizardSession {\n return {\n debug: args.debug ?? false,\n forceInstall: args.forceInstall ?? false,\n installDir: args.installDir ?? process.cwd(),\n ci: args.ci ?? false,\n signup: args.signup ?? false,\n localMcp: args.localMcp ?? false,\n apiKey: args.apiKey,\n menu: args.menu ?? false,\n benchmark: args.benchmark ?? false,\n yaraReport: args.yaraReport ?? false,\n projectId: parseProjectIdArg(args.projectId),\n\n setupConfirmed: false,\n integration: args.integration ?? null,\n frameworkContext: {},\n typescript: false,\n detectedFrameworkLabel: null,\n detectionComplete: false,\n unsupportedVersion: null,\n\n runPhase: RunPhase.Idle,\n discoveredFeatures: [],\n llmOptIn: false,\n mcpComplete: false,\n mcpOutcome: null,\n mcpInstalledClients: [],\n loginUrl: null,\n credentials: null,\n serviceStatus: null,\n settingsOverrideKeys: null,\n portConflictProcess: null,\n outroData: null,\n additionalFeatureQueue: [],\n frameworkConfig: null,\n };\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * YARA hook wiring for the Claude Agent SDK.
3
+ *
4
+ * Creates PreToolUse and PostToolUse hook callback arrays that
5
+ * integrate the YARA scanner into the wizard's agent loop. These
6
+ * hooks are registered in the SDK's query() options alongside the
7
+ * existing Stop hook.
8
+ *
9
+ * PreToolUse hooks block dangerous commands before execution.
10
+ * PostToolUse hooks detect violations in written code and prompt
11
+ * injection in read content, and scan context-mill skill downloads.
12
+ */
13
+ type HookInput = Record<string, unknown>;
14
+ type HookOutput = Record<string, unknown>;
15
+ type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
16
+ signal: AbortSignal;
17
+ }) => Promise<HookOutput>;
18
+ export interface HookCallbackMatcher {
19
+ matcher?: string;
20
+ hooks: HookCallback[];
21
+ timeout?: number;
22
+ }
23
+ /** Reset counters (for testing) */
24
+ export declare function resetScanReport(): void;
25
+ /** Format the scan report summary. Returns null if no scans occurred */
26
+ export declare function formatScanReport(): string | null;
27
+ /** Write the scan report to a JSON file. Returns the file path, or null if no scans occurred. */
28
+ export declare function writeScanReport(): string | null;
29
+ /**
30
+ * Create PreToolUse hook matchers for YARA scanning.
31
+ * Scans Bash commands before execution for exfiltration,
32
+ * destructive operations, and supply chain violations.
33
+ */
34
+ export declare function createPreToolUseYaraHooks(): HookCallbackMatcher[];
35
+ /**
36
+ * Create PostToolUse hook matchers for YARA scanning.
37
+ *
38
+ * Three matchers:
39
+ * 1. Write/Edit — scan written content for PII, secrets, config violations
40
+ * 2. Read/Grep — scan read content for prompt injection
41
+ * 3. Bash (skill install) — scan downloaded skill files for poisoned content
42
+ */
43
+ export declare function createPostToolUseYaraHooks(): HookCallbackMatcher[];
44
+ export {};