humanbehavior-js 0.4.28 → 0.5.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 +151 -0
- package/package.json +114 -79
- package/packages/angular/dist/index.d.ts +46 -0
- package/packages/angular/dist/index.d.ts.map +1 -0
- package/packages/angular/dist/index.js +2 -0
- package/packages/angular/dist/index.js.map +1 -0
- package/packages/angular/dist/index.mjs +2 -0
- package/packages/angular/dist/index.mjs.map +1 -0
- package/packages/browser/dist/index.d.ts +5 -0
- package/packages/browser/dist/index.d.ts.map +1 -0
- package/packages/browser/dist/index.iife.js +12095 -0
- package/packages/browser/dist/index.iife.js.map +1 -0
- package/packages/browser/dist/index.js +2 -0
- package/packages/browser/dist/index.js.map +1 -0
- package/packages/browser/dist/index.min.js +2 -0
- package/packages/browser/dist/index.min.js.map +1 -0
- package/packages/browser/dist/index.mjs +2 -0
- package/packages/browser/dist/index.mjs.map +1 -0
- package/packages/react/dist/browser.d.ts +2 -0
- package/packages/react/dist/browser.d.ts.map +1 -0
- package/packages/react/dist/index.d.ts +48 -0
- package/packages/react/dist/index.d.ts.map +1 -0
- package/packages/react/dist/index.js +2 -0
- package/packages/react/dist/index.js.map +1 -0
- package/packages/react/dist/index.mjs +2 -0
- package/packages/react/dist/index.mjs.map +1 -0
- package/packages/remix/dist/index.d.ts +8 -0
- package/packages/remix/dist/index.d.ts.map +1 -0
- package/packages/remix/dist/index.js +2 -0
- package/packages/remix/dist/index.js.map +1 -0
- package/packages/remix/dist/index.mjs +2 -0
- package/packages/remix/dist/index.mjs.map +1 -0
- package/packages/svelte/dist/index.d.ts +11 -0
- package/packages/svelte/dist/index.d.ts.map +1 -0
- package/packages/svelte/dist/index.js +2 -0
- package/packages/svelte/dist/index.js.map +1 -0
- package/packages/svelte/dist/index.mjs +2 -0
- package/packages/svelte/dist/index.mjs.map +1 -0
- package/{dist/types/vue → packages/vue/dist}/index.d.ts +4 -5
- package/packages/vue/dist/index.d.ts.map +1 -0
- package/packages/vue/dist/index.js +2 -0
- package/packages/vue/dist/index.js.map +1 -0
- package/packages/vue/dist/index.mjs +2 -0
- package/packages/vue/dist/index.mjs.map +1 -0
- package/packages/wizard/dist/ai/ai-install-wizard.d.ts +145 -0
- package/packages/wizard/dist/ai/ai-install-wizard.d.ts.map +1 -0
- package/packages/wizard/dist/ai/manual-framework-wizard.d.ts +52 -0
- package/packages/wizard/dist/ai/manual-framework-wizard.d.ts.map +1 -0
- package/packages/wizard/dist/cli/ai-auto-install.d.ts +27 -0
- package/packages/wizard/dist/cli/ai-auto-install.d.ts.map +1 -0
- package/{dist → packages/wizard/dist}/cli/ai-auto-install.js +821 -905
- package/packages/wizard/dist/cli/ai-auto-install.js.map +1 -0
- package/packages/wizard/dist/cli/auto-install.d.ts +26 -0
- package/packages/wizard/dist/cli/auto-install.d.ts.map +1 -0
- package/{dist → packages/wizard/dist}/cli/auto-install.js +821 -905
- package/packages/wizard/dist/cli/auto-install.js.map +1 -0
- package/{dist/types → packages/wizard/dist/core}/install-wizard.d.ts +6 -8
- package/packages/wizard/dist/core/install-wizard.d.ts.map +1 -0
- package/packages/wizard/dist/index.d.ts +18 -0
- package/packages/wizard/dist/index.d.ts.map +1 -0
- package/packages/wizard/dist/index.js +2 -0
- package/packages/wizard/dist/index.js.map +1 -0
- package/packages/wizard/dist/index.mjs +2 -0
- package/packages/wizard/dist/index.mjs.map +1 -0
- package/packages/wizard/dist/services/centralized-ai-service.d.ts +159 -0
- package/packages/wizard/dist/services/centralized-ai-service.d.ts.map +1 -0
- package/packages/wizard/dist/services/remote-ai-service.d.ts +58 -0
- package/packages/wizard/dist/services/remote-ai-service.d.ts.map +1 -0
- package/WIZARD_USAGE_GUIDE.md +0 -381
- package/dist/cjs/angular/index.cjs +0 -14979
- package/dist/cjs/angular/index.cjs.map +0 -1
- package/dist/cjs/index.cjs +0 -14964
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/install-wizard.cjs +0 -1576
- package/dist/cjs/install-wizard.cjs.map +0 -1
- package/dist/cjs/react/index.cjs +0 -15103
- package/dist/cjs/react/index.cjs.map +0 -1
- package/dist/cjs/remix/index.cjs +0 -15077
- package/dist/cjs/remix/index.cjs.map +0 -1
- package/dist/cjs/svelte/index.cjs +0 -14933
- package/dist/cjs/svelte/index.cjs.map +0 -1
- package/dist/cjs/vue/index.cjs +0 -14942
- package/dist/cjs/vue/index.cjs.map +0 -1
- package/dist/cjs/wizard/index.cjs +0 -3490
- package/dist/cjs/wizard/index.cjs.map +0 -1
- package/dist/cli/ai-auto-install.js.map +0 -1
- package/dist/cli/auto-install.js.map +0 -1
- package/dist/esm/angular/index.js +0 -14975
- package/dist/esm/angular/index.js.map +0 -1
- package/dist/esm/index.js +0 -14941
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/install-wizard.js +0 -1553
- package/dist/esm/install-wizard.js.map +0 -1
- package/dist/esm/react/index.js +0 -15097
- package/dist/esm/react/index.js.map +0 -1
- package/dist/esm/remix/index.js +0 -15073
- package/dist/esm/remix/index.js.map +0 -1
- package/dist/esm/svelte/index.js +0 -14931
- package/dist/esm/svelte/index.js.map +0 -1
- package/dist/esm/vue/index.js +0 -14940
- package/dist/esm/vue/index.js.map +0 -1
- package/dist/esm/wizard/index.js +0 -3459
- package/dist/esm/wizard/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/dist/types/angular/index.d.ts +0 -357
- package/dist/types/index.d.ts +0 -644
- package/dist/types/react/index.d.ts +0 -345
- package/dist/types/remix/index.d.ts +0 -336
- package/dist/types/svelte/index.d.ts +0 -322
- package/dist/types/wizard/index.d.ts +0 -523
- package/readme.md +0 -335
- package/rollup.config.js +0 -422
- package/simple-spa.html +0 -1000
- package/src/angular/index.ts +0 -79
- package/src/api.ts +0 -416
- package/src/index.ts +0 -35
- package/src/react/AutoInstallWizard.tsx +0 -557
- package/src/react/browser.ts +0 -8
- package/src/react/index.tsx +0 -308
- package/src/redact.ts +0 -327
- package/src/remix/index.ts +0 -16
- package/src/svelte/index.ts +0 -14
- package/src/tracker.ts +0 -1587
- package/src/types/clack.d.ts +0 -31
- package/src/utils/ip-detector.ts +0 -158
- package/src/utils/logger.ts +0 -144
- package/src/utils/property-detector.ts +0 -345
- package/src/utils/property-manager.ts +0 -274
- package/src/vue/index.ts +0 -29
- package/src/wizard/README.md +0 -114
- package/src/wizard/ai/ai-install-wizard.ts +0 -897
- package/src/wizard/ai/manual-framework-wizard.ts +0 -238
- package/src/wizard/cli/ai-auto-install.ts +0 -241
- package/src/wizard/cli/auto-install.ts +0 -224
- package/src/wizard/core/install-wizard.ts +0 -1794
- package/src/wizard/index.ts +0 -23
- package/src/wizard/services/centralized-ai-service.ts +0 -668
- package/src/wizard/services/remote-ai-service.ts +0 -240
- package/tsconfig.json +0 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-install.js","sources":["../../src/core/install-wizard.ts","../../src/services/remote-ai-service.ts","../../src/ai/manual-framework-wizard.ts","../../src/cli/auto-install.ts"],"sourcesContent":["/**\n * HumanBehavior SDK Auto-Installation Wizard\n * \n * This wizard automatically detects the user's framework and modifies their codebase\n * to integrate the SDK with minimal user intervention.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport interface FrameworkInfo {\n name: string;\n type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node' | 'auto';\n bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';\n packageManager?: 'npm' | 'yarn' | 'pnpm';\n hasTypeScript?: boolean;\n hasRouter?: boolean;\n projectRoot?: string;\n version?: string;\n majorVersion?: number;\n features?: {\n hasReact18?: boolean;\n hasVue3?: boolean;\n hasNuxt3?: boolean;\n hasAngularStandalone?: boolean;\n hasNextAppRouter?: boolean;\n hasSvelteKit?: boolean;\n };\n}\n\nexport interface CodeModification {\n filePath: string;\n action: 'create' | 'modify' | 'append';\n content: string;\n description: string;\n}\n\nexport interface InstallationResult {\n success: boolean;\n framework: FrameworkInfo;\n modifications: CodeModification[];\n errors: string[];\n nextSteps: string[];\n}\n\nexport class AutoInstallationWizard {\n protected apiKey: string;\n protected projectRoot: string;\n protected framework: FrameworkInfo | null = null;\n\n constructor(apiKey: string, projectRoot: string = process.cwd()) {\n this.apiKey = apiKey;\n this.projectRoot = projectRoot;\n }\n\n /**\n * Simple version comparison utility\n */\n private compareVersions(version1: string, version2: string): number {\n const v1Parts = version1.split('.').map(Number);\n const v2Parts = version2.split('.').map(Number);\n \n for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {\n const v1 = v1Parts[i] || 0;\n const v2 = v2Parts[i] || 0;\n if (v1 > v2) return 1;\n if (v1 < v2) return -1;\n }\n return 0;\n }\n\n private isVersionGte(version: string, target: string): boolean {\n return this.compareVersions(version, target) >= 0;\n }\n\n private getMajorVersion(version: string): number {\n return parseInt(version.split('.')[0]) || 0;\n }\n\n /**\n * Main installation method - detects framework and auto-installs\n */\n async install(): Promise<InstallationResult> {\n try {\n // Step 1: Detect framework\n this.framework = await this.detectFramework();\n \n // Step 2: Install package\n await this.installPackage();\n \n // Step 3: Generate and apply code modifications\n const modifications = await this.generateModifications();\n await this.applyModifications(modifications);\n \n // Step 4: Generate next steps\n const nextSteps = this.generateNextSteps();\n \n return {\n success: true,\n framework: this.framework,\n modifications,\n errors: [],\n nextSteps\n };\n } catch (error) {\n return {\n success: false,\n framework: this.framework || { name: 'unknown', type: 'vanilla' },\n modifications: [],\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n nextSteps: []\n };\n }\n }\n\n /**\n * Detect the current framework and project setup\n */\n public async detectFramework(): Promise<FrameworkInfo> {\n const packageJsonPath = path.join(this.projectRoot, 'package.json');\n \n if (!fs.existsSync(packageJsonPath)) {\n return {\n name: 'vanilla',\n type: 'vanilla',\n projectRoot: this.projectRoot\n };\n }\n\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies\n };\n\n // Detect framework with version information\n let framework: FrameworkInfo = {\n name: 'vanilla',\n type: 'vanilla',\n projectRoot: this.projectRoot,\n features: {}\n };\n\n if (dependencies.nuxt) {\n const nuxtVersion = dependencies.nuxt;\n const isNuxt3 = this.isVersionGte(nuxtVersion, '3.0.0');\n \n framework = {\n name: 'nuxt',\n type: 'nuxt',\n version: nuxtVersion,\n majorVersion: this.getMajorVersion(nuxtVersion),\n hasTypeScript: !!dependencies.typescript,\n hasRouter: true,\n projectRoot: this.projectRoot,\n features: {\n hasNuxt3: isNuxt3\n }\n };\n } else if (dependencies.next) {\n const nextVersion = dependencies.next;\n const isNext13 = this.isVersionGte(nextVersion, '13.0.0');\n \n framework = {\n name: 'nextjs',\n type: 'nextjs',\n version: nextVersion,\n majorVersion: this.getMajorVersion(nextVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['@types/node'],\n hasRouter: true,\n projectRoot: this.projectRoot,\n features: {\n hasNextAppRouter: isNext13\n }\n };\n } else if (dependencies['@remix-run/react'] || dependencies['@remix-run/dev']) {\n const remixVersion = dependencies['@remix-run/react'] || dependencies['@remix-run/dev'];\n framework = {\n name: 'remix',\n type: 'remix',\n version: remixVersion,\n majorVersion: this.getMajorVersion(remixVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['@types/react'],\n hasRouter: true,\n projectRoot: this.projectRoot,\n features: {}\n };\n } else if (dependencies.react) {\n const reactVersion = dependencies.react;\n const isReact18 = this.isVersionGte(reactVersion, '18.0.0');\n \n framework = {\n name: 'react',\n type: 'react',\n version: reactVersion,\n majorVersion: this.getMajorVersion(reactVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['@types/react'],\n hasRouter: !!dependencies['react-router-dom'] || !!dependencies['react-router'],\n projectRoot: this.projectRoot,\n features: {\n hasReact18: isReact18\n }\n };\n } else if (dependencies.vue) {\n const vueVersion = dependencies.vue;\n const isVue3 = this.isVersionGte(vueVersion, '3.0.0');\n \n framework = {\n name: 'vue',\n type: 'vue',\n version: vueVersion,\n majorVersion: this.getMajorVersion(vueVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['@vue/cli-service'],\n hasRouter: !!dependencies['vue-router'],\n projectRoot: this.projectRoot,\n features: {\n hasVue3: isVue3\n }\n };\n } else if (dependencies['@angular/core']) {\n const angularVersion = dependencies['@angular/core'];\n const isAngular17 = this.isVersionGte(angularVersion, '17.0.0');\n \n framework = {\n name: 'angular',\n type: 'angular',\n version: angularVersion,\n majorVersion: this.getMajorVersion(angularVersion),\n hasTypeScript: true,\n hasRouter: true,\n projectRoot: this.projectRoot,\n features: {\n hasAngularStandalone: isAngular17\n }\n };\n } else if (dependencies.svelte) {\n const svelteVersion = dependencies.svelte;\n const isSvelteKit = !!dependencies['@sveltejs/kit'];\n \n framework = {\n name: 'svelte',\n type: 'svelte',\n version: svelteVersion,\n majorVersion: this.getMajorVersion(svelteVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['svelte-check'],\n hasRouter: !!dependencies['svelte-routing'] || !!dependencies['@sveltejs/kit'],\n projectRoot: this.projectRoot,\n features: {\n hasSvelteKit: isSvelteKit\n }\n };\n } else if (dependencies.astro) {\n const astroVersion = dependencies.astro;\n framework = {\n name: 'astro',\n type: 'astro',\n version: astroVersion,\n majorVersion: this.getMajorVersion(astroVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['@astrojs/ts-plugin'],\n hasRouter: true,\n projectRoot: this.projectRoot,\n features: {}\n };\n } else if (dependencies.gatsby) {\n const gatsbyVersion = dependencies.gatsby;\n framework = {\n name: 'gatsby',\n type: 'gatsby',\n version: gatsbyVersion,\n majorVersion: this.getMajorVersion(gatsbyVersion),\n hasTypeScript: !!dependencies.typescript || !!dependencies['@types/react'],\n hasRouter: true,\n projectRoot: this.projectRoot,\n features: {}\n };\n }\n\n // Detect bundler\n if (dependencies.vite) {\n framework.bundler = 'vite';\n } else if (dependencies.webpack) {\n framework.bundler = 'webpack';\n } else if (dependencies.esbuild) {\n framework.bundler = 'esbuild';\n } else if (dependencies.rollup) {\n framework.bundler = 'rollup';\n }\n\n // Detect package manager\n if (fs.existsSync(path.join(this.projectRoot, 'yarn.lock'))) {\n framework.packageManager = 'yarn';\n } else if (fs.existsSync(path.join(this.projectRoot, 'pnpm-lock.yaml'))) {\n framework.packageManager = 'pnpm';\n } else {\n framework.packageManager = 'npm';\n }\n\n return framework;\n }\n\n /**\n * Install the SDK package with latest version range\n */\n protected async installPackage(): Promise<void> {\n const { execSync } = await import('child_process');\n \n // Build base command with latest version range\n let command = this.framework?.packageManager === 'yarn' \n ? 'yarn add humanbehavior-js@latest'\n : this.framework?.packageManager === 'pnpm'\n ? 'pnpm add humanbehavior-js@latest'\n : 'npm install humanbehavior-js@latest';\n \n // Add legacy peer deps flag for npm to handle dependency conflicts\n if (this.framework?.packageManager !== 'yarn' && this.framework?.packageManager !== 'pnpm') {\n command += ' --legacy-peer-deps';\n }\n\n try {\n execSync(command, { cwd: this.projectRoot, stdio: 'inherit' });\n } catch (error) {\n throw new Error(`Failed to install humanbehavior-js: ${error}`);\n }\n }\n\n /**\n * Generate code modifications based on framework\n */\n protected async generateModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n\n switch (this.framework?.type) {\n case 'react':\n modifications.push(...await this.generateReactModifications());\n break;\n case 'nextjs':\n modifications.push(...await this.generateNextJSModifications());\n break;\n case 'nuxt':\n modifications.push(...await this.generateNuxtModifications());\n break;\n case 'astro':\n modifications.push(...await this.generateAstroModifications());\n break;\n case 'gatsby':\n modifications.push(...await this.generateGatsbyModifications());\n break;\n case 'remix':\n modifications.push(...await this.generateRemixModifications());\n break;\n case 'vue':\n modifications.push(...await this.generateVueModifications());\n break;\n case 'angular':\n modifications.push(...await this.generateAngularModifications());\n break;\n case 'svelte':\n modifications.push(...await this.generateSvelteModifications());\n break;\n default:\n modifications.push(...await this.generateVanillaModifications());\n }\n\n return modifications;\n }\n\n /**\n * Generate React-specific modifications\n */\n private async generateReactModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Find main App component or index file\n const appFile = this.findReactAppFile();\n if (appFile) {\n const content = fs.readFileSync(appFile, 'utf8');\n const modifiedContent = this.injectReactProvider(content, appFile);\n \n modifications.push({\n filePath: appFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehaviorProvider to React app'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Next.js-specific modifications\n */\n private async generateNextJSModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Check for App Router\n const appLayoutFile = path.join(this.projectRoot, 'src', 'app', 'layout.tsx');\n const pagesLayoutFile = path.join(this.projectRoot, 'src', 'pages', '_app.tsx');\n \n if (fs.existsSync(appLayoutFile)) {\n // Create providers.tsx file for App Router\n modifications.push({\n filePath: path.join(this.projectRoot, 'src', 'app', 'providers.tsx'),\n action: 'create',\n content: `'use client';\n\nimport { HumanBehaviorProvider } from 'humanbehavior-js/react';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <HumanBehaviorProvider apiKey={process.env.NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY}>\n {children}\n </HumanBehaviorProvider>\n );\n}`,\n description: 'Created providers.tsx file for Next.js App Router'\n });\n\n // Modify layout.tsx to use the provider\n const content = fs.readFileSync(appLayoutFile, 'utf8');\n const modifiedContent = this.injectNextJSAppRouter(content);\n \n modifications.push({\n filePath: appLayoutFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added Providers wrapper to Next.js App Router layout'\n });\n } else if (fs.existsSync(pagesLayoutFile)) {\n // Create providers.tsx file for Pages Router\n modifications.push({\n filePath: path.join(this.projectRoot, 'src', 'components', 'providers.tsx'),\n action: 'create',\n content: `'use client';\n\nimport { HumanBehaviorProvider } from 'humanbehavior-js/react';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <HumanBehaviorProvider apiKey={process.env.NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY}>\n {children}\n </HumanBehaviorProvider>\n );\n}`,\n description: 'Created providers.tsx file for Pages Router'\n });\n\n // Modify _app.tsx to use the provider\n const content = fs.readFileSync(pagesLayoutFile, 'utf8');\n const modifiedContent = this.injectNextJSPagesRouter(content);\n \n modifications.push({\n filePath: pagesLayoutFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added Providers wrapper to Next.js Pages Router'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Astro-specific modifications\n */\n private async generateAstroModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n\n // Create Astro component for HumanBehavior\n const astroComponentPath = path.join(this.projectRoot, 'src', 'components', 'HumanBehavior.astro');\n const astroComponentContent = `---\n// This component will only run on the client side\n---\n\n<script>\n import { HumanBehaviorTracker } from 'humanbehavior-js';\n \n // Get API key from environment variable\n const apiKey = import.meta.env.PUBLIC_HUMANBEHAVIOR_API_KEY;\n \n console.log('HumanBehavior: API key found:', apiKey ? 'Yes' : 'No');\n \n if (apiKey) {\n try {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior: Tracker initialized successfully');\n \n // Test event to verify tracking is working\n setTimeout(() => {\n tracker.customEvent('astro_page_view', {\n page: window.location.pathname,\n framework: 'astro'\n }).then(() => {\n console.log('HumanBehavior: Test event sent successfully');\n }).catch((error) => {\n console.error('HumanBehavior: Failed to send test event:', error);\n });\n }, 1000);\n \n } catch (error) {\n console.error('HumanBehavior: Failed to initialize tracker:', error);\n }\n } else {\n console.error('HumanBehavior: No API key found');\n }\n</script>`;\n\n modifications.push({\n filePath: astroComponentPath,\n action: 'create',\n content: astroComponentContent,\n description: 'Created Astro component for HumanBehavior SDK'\n });\n\n // Find and update layout file\n const layoutFiles = [\n path.join(this.projectRoot, 'src', 'layouts', 'Layout.astro'),\n path.join(this.projectRoot, 'src', 'layouts', 'layout.astro'),\n path.join(this.projectRoot, 'src', 'layouts', 'BaseLayout.astro')\n ];\n\n let layoutFile = null;\n for (const file of layoutFiles) {\n if (fs.existsSync(file)) {\n layoutFile = file;\n break;\n }\n }\n\n if (layoutFile) {\n const content = fs.readFileSync(layoutFile, 'utf8');\n const modifiedContent = this.injectAstroLayout(content);\n \n modifications.push({\n filePath: layoutFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior component to Astro layout'\n });\n }\n\n // Add environment variable\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Nuxt-specific modifications\n */\n private async generateNuxtModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Create plugin file for Nuxt (in app directory)\n const pluginFile = path.join(this.projectRoot, 'app', 'plugins', 'humanbehavior.client.ts');\n modifications.push({\n filePath: pluginFile,\n action: 'create',\n content: `import { HumanBehaviorTracker } from 'humanbehavior-js';\n\nexport default defineNuxtPlugin(() => {\n const config = useRuntimeConfig();\n \n // Initialize HumanBehavior SDK (client-side only)\n if (typeof window !== 'undefined') {\n const apiKey = config.public.humanBehaviorApiKey;\n console.log('HumanBehavior: API key:', apiKey ? 'present' : 'missing');\n \n if (apiKey) {\n try {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior: Tracker initialized successfully');\n } catch (error) {\n console.error('HumanBehavior: Failed to initialize tracker:', error);\n }\n } else {\n console.error('HumanBehavior: No API key found in runtime config');\n }\n }\n});`,\n description: 'Created Nuxt plugin for HumanBehavior SDK in app directory'\n });\n\n // Create environment configuration\n const nuxtConfigFile = path.join(this.projectRoot, 'nuxt.config.ts');\n if (fs.existsSync(nuxtConfigFile)) {\n const content = fs.readFileSync(nuxtConfigFile, 'utf8');\n const modifiedContent = this.injectNuxtConfig(content);\n \n modifications.push({\n filePath: nuxtConfigFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior runtime config to Nuxt config'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Remix-specific modifications\n */\n private async generateRemixModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Find root.tsx file\n const rootFile = path.join(this.projectRoot, 'app', 'root.tsx');\n if (fs.existsSync(rootFile)) {\n const content = fs.readFileSync(rootFile, 'utf8');\n const modifiedContent = this.injectRemixProvider(content);\n \n modifications.push({\n filePath: rootFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehaviorProvider to Remix root component'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Vue-specific modifications\n */\n private async generateVueModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Find main.js or main.ts\n const mainFile = this.findVueMainFile();\n if (mainFile) {\n const content = fs.readFileSync(mainFile, 'utf8');\n const modifiedContent = this.injectVuePlugin(content);\n \n modifications.push({\n filePath: mainFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehaviorPlugin to Vue app'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Angular-specific modifications\n */\n private async generateAngularModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Check for modern Angular (standalone components) vs legacy (NgModule)\n const appModuleFile = path.join(this.projectRoot, 'src', 'app', 'app.module.ts');\n const appComponentFile = path.join(this.projectRoot, 'src', 'app', 'app.ts');\n const mainFile = path.join(this.projectRoot, 'src', 'main.ts');\n \n const isModernAngular = fs.existsSync(appComponentFile) && !fs.existsSync(appModuleFile);\n \n if (isModernAngular) {\n // Modern Angular 17+ with standalone components\n if (fs.existsSync(mainFile)) {\n const content = fs.readFileSync(mainFile, 'utf8');\n const modifiedContent = this.injectAngularStandaloneInit(content);\n \n modifications.push({\n filePath: mainFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior initialization to Angular main.ts'\n });\n }\n } else if (fs.existsSync(appModuleFile)) {\n // Legacy Angular with NgModule\n const content = fs.readFileSync(appModuleFile, 'utf8');\n const modifiedContent = this.injectAngularModule(content);\n \n modifications.push({\n filePath: appModuleFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehaviorModule to Angular app'\n });\n }\n\n // Handle Angular environment files (proper Angular way)\n const envFile = path.join(this.projectRoot, 'src', 'environments', 'environment.ts');\n const envProdFile = path.join(this.projectRoot, 'src', 'environments', 'environment.prod.ts');\n \n // Create environments directory if it doesn't exist\n const envDir = path.dirname(envFile);\n if (!fs.existsSync(envDir)) {\n fs.mkdirSync(envDir, { recursive: true });\n }\n \n // Create or update development environment\n if (fs.existsSync(envFile)) {\n const content = fs.readFileSync(envFile, 'utf8');\n if (!content.includes('humanBehaviorApiKey')) {\n const modifiedContent = content.replace(\n /export const environment = {([\\s\\S]*?)};/,\n `export const environment = {\n $1,\n humanBehaviorApiKey: '${this.apiKey}'\n};`\n );\n modifications.push({\n filePath: envFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added API key to Angular development environment'\n });\n }\n } else {\n // Create new development environment file\n modifications.push({\n filePath: envFile,\n action: 'create',\n content: `export const environment = {\n production: false,\n humanBehaviorApiKey: '${this.apiKey}'\n};`,\n description: 'Created Angular development environment file'\n });\n }\n \n // Create or update production environment\n if (fs.existsSync(envProdFile)) {\n const content = fs.readFileSync(envProdFile, 'utf8');\n if (!content.includes('humanBehaviorApiKey')) {\n const modifiedContent = content.replace(\n /export const environment = {([\\s\\S]*?)};/,\n `export const environment = {\n $1,\n humanBehaviorApiKey: '${this.apiKey}'\n};`\n );\n modifications.push({\n filePath: envProdFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added API key to Angular production environment'\n });\n }\n } else {\n // Create new production environment file\n modifications.push({\n filePath: envProdFile,\n action: 'create',\n content: `export const environment = {\n production: true,\n humanBehaviorApiKey: '${this.apiKey}'\n};`,\n description: 'Created Angular production environment file'\n });\n }\n\n // For Angular, we don't need .env files since we use environment.ts\n // The environment files are already created above\n\n return modifications;\n }\n\n /**\n * Generate Svelte-specific modifications\n */\n private async generateSvelteModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Check for SvelteKit\n const svelteConfigFile = path.join(this.projectRoot, 'svelte.config.js');\n const isSvelteKit = fs.existsSync(svelteConfigFile);\n \n if (isSvelteKit) {\n // SvelteKit - create layout file\n const layoutFile = path.join(this.projectRoot, 'src', 'routes', '+layout.svelte');\n if (fs.existsSync(layoutFile)) {\n const content = fs.readFileSync(layoutFile, 'utf8');\n const modifiedContent = this.injectSvelteKitLayout(content);\n \n modifications.push({\n filePath: layoutFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior store to SvelteKit layout'\n });\n }\n } else {\n // Regular Svelte - modify main file\n const mainFile = this.findSvelteMainFile();\n if (mainFile) {\n const content = fs.readFileSync(mainFile, 'utf8');\n const modifiedContent = this.injectSvelteStore(content);\n \n modifications.push({\n filePath: mainFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior store to Svelte app'\n });\n }\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate vanilla JS/TS modifications\n */\n private async generateVanillaModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Find HTML file to inject script\n const htmlFile = this.findHTMLFile();\n if (htmlFile) {\n const content = fs.readFileSync(htmlFile, 'utf8');\n const modifiedContent = this.injectVanillaScript(content);\n \n modifications.push({\n filePath: htmlFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior CDN script to HTML file'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n /**\n * Generate Gatsby-specific modifications\n */\n private async generateGatsbyModifications(): Promise<CodeModification[]> {\n const modifications: CodeModification[] = [];\n \n // Modify or create gatsby-browser.js for Gatsby\n const gatsbyBrowserFile = path.join(this.projectRoot, 'gatsby-browser.js');\n \n if (fs.existsSync(gatsbyBrowserFile)) {\n const content = fs.readFileSync(gatsbyBrowserFile, 'utf8');\n const modifiedContent = this.injectGatsbyBrowser(content);\n \n modifications.push({\n filePath: gatsbyBrowserFile,\n action: 'modify',\n content: modifiedContent,\n description: 'Added HumanBehavior initialization to Gatsby browser'\n });\n } else {\n // Create gatsby-browser.js if it doesn't exist\n modifications.push({\n filePath: gatsbyBrowserFile,\n action: 'create',\n content: `import { HumanBehaviorTracker } from 'humanbehavior-js';\n\nexport const onClientEntry = () => {\n console.log('Gatsby browser entry point loaded');\n const apiKey = process.env.GATSBY_HUMANBEHAVIOR_API_KEY;\n console.log('API Key found:', apiKey ? 'Yes' : 'No');\n if (apiKey) {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior SDK initialized for Gatsby');\n } else {\n console.log('No API key found in environment variables');\n }\n};`,\n description: 'Created gatsby-browser.js with HumanBehavior initialization'\n });\n }\n\n // Create or append to environment file\n modifications.push(this.createEnvironmentModification(this.framework!));\n\n return modifications;\n }\n\n\n\n /**\n * Apply modifications to the codebase\n */\n protected async applyModifications(modifications: CodeModification[]): Promise<void> {\n for (const modification of modifications) {\n try {\n const dir = path.dirname(modification.filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n switch (modification.action) {\n case 'create':\n fs.writeFileSync(modification.filePath, modification.content);\n break;\n case 'modify':\n fs.writeFileSync(modification.filePath, modification.content);\n break;\n case 'append':\n fs.appendFileSync(modification.filePath, '\\n' + modification.content);\n break;\n }\n } catch (error) {\n throw new Error(`Failed to apply modification to ${modification.filePath}: ${error}`);\n }\n }\n }\n\n /**\n * Generate next steps for the user\n */\n private generateNextSteps(): string[] {\n const steps = [\n '✅ SDK installed and configured automatically!',\n '🚀 Your app is now tracking user behavior',\n '📊 View sessions in your HumanBehavior dashboard',\n '🔧 Customize tracking in your code as needed'\n ];\n\n if (this.framework?.type === 'react' || this.framework?.type === 'nextjs') {\n steps.push('💡 Use the useHumanBehavior() hook to track custom events');\n }\n\n return steps;\n }\n\n // Helper methods for file detection and content injection\n private findReactAppFile(): string | null {\n const possibleFiles = [\n 'src/App.jsx', 'src/App.js', 'src/App.tsx', 'src/App.ts',\n 'src/index.js', 'src/index.tsx', 'src/main.js', 'src/main.tsx'\n ];\n\n for (const file of possibleFiles) {\n const fullPath = path.join(this.projectRoot, file);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n }\n\n private findVueMainFile(): string | null {\n const possibleFiles = [\n 'src/main.js', 'src/main.ts', 'src/main.jsx', 'src/main.tsx'\n ];\n\n for (const file of possibleFiles) {\n const fullPath = path.join(this.projectRoot, file);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n }\n\n private findSvelteMainFile(): string | null {\n const possibleFiles = [\n 'src/main.js', 'src/main.ts', 'src/main.svelte'\n ];\n\n for (const file of possibleFiles) {\n const fullPath = path.join(this.projectRoot, file);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n }\n\n private findHTMLFile(): string | null {\n const possibleFiles = ['index.html', 'public/index.html', 'dist/index.html'];\n\n for (const file of possibleFiles) {\n const fullPath = path.join(this.projectRoot, file);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n }\n\n private injectReactProvider(content: string, filePath: string): string {\n const isTypeScript = filePath.endsWith('.tsx') || filePath.endsWith('.ts');\n \n // Check if already has HumanBehaviorProvider\n if (content.includes('HumanBehaviorProvider')) {\n return content;\n }\n\n // Determine the correct environment variable syntax based on bundler\n const isVite = this.framework?.bundler === 'vite';\n const envVar = isVite \n ? 'import.meta.env.VITE_HUMANBEHAVIOR_API_KEY!' \n : 'process.env.HUMANBEHAVIOR_API_KEY!';\n\n const importStatement = `import { HumanBehaviorProvider } from 'humanbehavior-js/react';`;\n\n // Enhanced parsing for React 18+ features\n const hasReact18 = this.framework?.features?.hasReact18;\n \n // Handle different React patterns\n if (content.includes('function App()') || content.includes('const App =')) {\n // Add import statement\n let modifiedContent = content.replace(\n /(import.*?from.*?['\"]react['\"];?)/,\n `$1\\n${importStatement}`\n );\n \n // If no React import found, add it at the top\n if (!modifiedContent.includes(importStatement)) {\n modifiedContent = `${importStatement}\\n\\n${modifiedContent}`;\n }\n \n // Wrap the App component return with HumanBehaviorProvider\n modifiedContent = modifiedContent.replace(\n /(return\\s*\\([\\s\\S]*?\\)\\s*;)/,\n `return (\n <HumanBehaviorProvider apiKey={${envVar}}>\n $1\n </HumanBehaviorProvider>\n );`\n );\n \n return modifiedContent;\n }\n \n // Handle React 18+ createRoot pattern\n if (hasReact18 && content.includes('createRoot')) {\n let modifiedContent = content.replace(\n /(import.*?from.*?['\"]react['\"];?)/,\n `$1\\n${importStatement}`\n );\n \n if (!modifiedContent.includes(importStatement)) {\n modifiedContent = `${importStatement}\\n\\n${modifiedContent}`;\n }\n \n // Wrap the root render with HumanBehaviorProvider\n modifiedContent = modifiedContent.replace(\n /(root\\.render\\s*\\([\\s\\S]*?\\)\\s*;)/,\n `root.render(\n <HumanBehaviorProvider apiKey={${envVar}}>\n $1\n </HumanBehaviorProvider>\n );`\n );\n \n return modifiedContent;\n }\n\n // Fallback: simple injection\n return `${importStatement}\\n\\n${content}`;\n }\n\n private injectNextJSAppRouter(content: string): string {\n if (content.includes('Providers')) {\n return content;\n }\n\n const importStatement = `import { Providers } from './providers';`;\n \n // First, add the import statement\n let modifiedContent = content.replace(\n /export default function RootLayout/,\n `${importStatement}\\n\\nexport default function RootLayout`\n );\n \n // Then wrap the body content with Providers\n // Use a more specific approach to handle the body content\n modifiedContent = modifiedContent.replace(\n /<body([^>]*)>([\\s\\S]*?)<\\/body>/,\n (match, bodyAttrs, bodyContent) => {\n // Trim whitespace and newlines from bodyContent\n const trimmedContent = bodyContent.trim();\n return `<body${bodyAttrs}>\n <Providers>\n ${trimmedContent}\n </Providers>\n </body>`;\n }\n );\n \n return modifiedContent;\n }\n\n private injectNextJSPagesRouter(content: string): string {\n if (content.includes('Providers')) {\n return content;\n }\n\n const importStatement = `import { Providers } from '../components/providers';`;\n \n return content.replace(\n /function MyApp/,\n `${importStatement}\\n\\nfunction MyApp`\n ).replace(\n /return \\(([\\s\\S]*?)\\);/,\n `return (\n <Providers>\n $1\n </Providers>\n );`\n );\n }\n\n private injectRemixProvider(content: string): string {\n if (content.includes('HumanBehaviorProvider')) {\n return content;\n }\n\n const importStatement = `import { HumanBehaviorProvider, createHumanBehaviorLoader } from 'humanbehavior-js/remix';`;\n const useLoaderDataImport = `import { useLoaderData } from \"@remix-run/react\";`;\n \n // Add imports more robustly\n let modifiedContent = content;\n \n // Add HumanBehaviorProvider import - find the last import and add after it\n if (!content.includes('HumanBehaviorProvider')) {\n const lastImportIndex = modifiedContent.lastIndexOf('import');\n if (lastImportIndex !== -1) {\n const nextLineIndex = modifiedContent.indexOf('\\n', lastImportIndex);\n if (nextLineIndex !== -1) {\n modifiedContent = modifiedContent.slice(0, nextLineIndex + 1) + \n importStatement + '\\n' + \n modifiedContent.slice(nextLineIndex + 1);\n } else {\n modifiedContent = modifiedContent + '\\n' + importStatement;\n }\n } else {\n modifiedContent = importStatement + '\\n' + modifiedContent;\n }\n }\n \n // Add useLoaderData import - find the last import and add after it\n if (!content.includes('useLoaderData')) {\n const lastImportIndex = modifiedContent.lastIndexOf('import');\n if (lastImportIndex !== -1) {\n const nextLineIndex = modifiedContent.indexOf('\\n', lastImportIndex);\n if (nextLineIndex !== -1) {\n modifiedContent = modifiedContent.slice(0, nextLineIndex + 1) + \n useLoaderDataImport + '\\n' + \n modifiedContent.slice(nextLineIndex + 1);\n } else {\n modifiedContent = modifiedContent + '\\n' + useLoaderDataImport;\n }\n } else {\n modifiedContent = useLoaderDataImport + '\\n' + modifiedContent;\n }\n }\n \n\n\n // Add loader function before the App component\n if (!content.includes('export const loader')) {\n modifiedContent = modifiedContent.replace(\n /export default function App\\(\\)/,\n `export const loader = createHumanBehaviorLoader();\n\nexport default function App()`\n );\n }\n\n // Wrap the App component content with HumanBehaviorProvider\n modifiedContent = modifiedContent.replace(\n /export default function App\\(\\) \\{[\\s\\S]*?return \\(([\\s\\S]*?)\\);[\\s\\S]*?\\}/,\n `export default function App() {\n const data = useLoaderData<typeof loader>();\n \n return (\n <HumanBehaviorProvider apiKey={data.ENV.HUMANBEHAVIOR_API_KEY}>\n $1\n </HumanBehaviorProvider>\n );\n}`\n );\n\n return modifiedContent;\n }\n\n private injectVuePlugin(content: string): string {\n if (content.includes('HumanBehaviorPlugin')) {\n return content;\n }\n\n const importStatement = `import { HumanBehaviorPlugin } from 'humanbehavior-js/vue';`;\n \n // Enhanced Vue 3 support with version detection\n const hasVue3 = this.framework?.features?.hasVue3;\n \n if (hasVue3) {\n // Vue 3 with Composition API\n const pluginUsage = `app.use(HumanBehaviorPlugin, {\n apiKey: import.meta.env.VITE_HUMANBEHAVIOR_API_KEY\n});`;\n\n let modifiedContent = content;\n \n // Add import statement\n if (!content.includes(importStatement)) {\n modifiedContent = content.replace(\n /(import.*?from.*?['\"]vue['\"];?)/,\n `$1\\n${importStatement}`\n );\n \n // If no Vue import found, add it at the top\n if (!modifiedContent.includes(importStatement)) {\n modifiedContent = `${importStatement}\\n\\n${modifiedContent}`;\n }\n }\n \n // Handle createApp pattern\n if (content.includes('createApp')) {\n modifiedContent = modifiedContent.replace(\n /(app\\.mount\\(.*?\\))/,\n `${pluginUsage}\\n\\n$1`\n );\n }\n \n return modifiedContent;\n } else {\n // Vue 2 with Options API\n const pluginUsage = `Vue.use(HumanBehaviorPlugin, {\n apiKey: process.env.VUE_APP_HUMANBEHAVIOR_API_KEY\n});`;\n\n let modifiedContent = content;\n \n // Add import statement\n if (!content.includes(importStatement)) {\n modifiedContent = content.replace(\n /(import.*?from.*?['\"]vue['\"];?)/,\n `$1\\n${importStatement}`\n );\n \n if (!modifiedContent.includes(importStatement)) {\n modifiedContent = `${importStatement}\\n\\n${modifiedContent}`;\n }\n }\n \n // Handle new Vue pattern\n if (content.includes('new Vue')) {\n modifiedContent = modifiedContent.replace(\n /(new Vue\\(.*?\\))/,\n `${pluginUsage}\\n\\n$1`\n );\n }\n \n return modifiedContent;\n }\n }\n\n private injectAngularModule(content: string): string {\n if (content.includes('HumanBehaviorModule')) {\n return content;\n }\n\n const importStatement = `import { HumanBehaviorModule } from 'humanbehavior-js/angular';`;\n const environmentImport = `import { environment } from '../environments/environment';`;\n \n // Add environment import if not present\n let modifiedContent = content;\n if (!content.includes('environment')) {\n modifiedContent = content.replace(\n /import.*from.*['\"]@angular/,\n `${environmentImport}\\n$&`\n );\n }\n \n return modifiedContent.replace(\n /imports:\\s*\\[([\\s\\S]*?)\\]/,\n `imports: [\n $1,\n HumanBehaviorModule.forRoot({\n apiKey: environment.humanBehaviorApiKey\n })\n ]`\n ).replace(\n /import.*from.*['\"]@angular/,\n `$&\\n${importStatement}`\n );\n }\n\n private injectAngularStandaloneInit(content: string): string {\n if (content.includes('initializeHumanBehavior')) {\n return content;\n }\n\n const importStatement = `import { initializeHumanBehavior } from 'humanbehavior-js/angular';`;\n const environmentImport = `import { environment } from './environments/environment';`;\n \n // Add imports at the top\n let modifiedContent = content.replace(\n /import.*from.*['\"]@angular/,\n `${importStatement}\\n${environmentImport}\\n$&`\n );\n\n // Add initialization after bootstrapApplication\n modifiedContent = modifiedContent.replace(\n /(bootstrapApplication\\([^}]+\\}?\\)(?:\\s*\\.catch[^;]+;)?)/,\n `$1\n\n// Initialize HumanBehavior SDK (client-side only)\nif (typeof window !== 'undefined') {\n const tracker = initializeHumanBehavior(environment.humanBehaviorApiKey);\n}`\n );\n\n return modifiedContent;\n }\n\n private injectSvelteStore(content: string): string {\n if (content.includes('humanBehaviorStore')) {\n return content;\n }\n\n const importStatement = `import { humanBehaviorStore } from 'humanbehavior-js/svelte';`;\n const initCode = `humanBehaviorStore.init(process.env.PUBLIC_HUMANBEHAVIOR_API_KEY || '');`;\n\n return `${importStatement}\\n${initCode}\\n\\n${content}`;\n }\n\n private injectSvelteKitLayout(content: string): string {\n if (content.includes('humanBehaviorStore')) {\n return content;\n }\n\n const importStatement = `import { humanBehaviorStore } from 'humanbehavior-js/svelte';`;\n const envImport = `import { PUBLIC_HUMANBEHAVIOR_API_KEY } from '$env/static/public';`;\n const initCode = `humanBehaviorStore.init(PUBLIC_HUMANBEHAVIOR_API_KEY || '');`;\n\n // Add to script section - handle different script tag patterns\n if (content.includes('<script lang=\"ts\">')) {\n return content.replace(\n /<script lang=\"ts\">/,\n `<script lang=\"ts\">\\n\\t${envImport}\\n\\t${importStatement}\\n\\t${initCode}`\n );\n } else if (content.includes('<script>')) {\n return content.replace(\n /<script>/,\n `<script>\\n\\t${envImport}\\n\\t${importStatement}\\n\\t${initCode}`\n );\n } else if (content.includes('<script context=\"module\">')) {\n return content.replace(\n /<script\\s+context=\"module\">/,\n `<script context=\"module\">\\n\\t${envImport}\\n\\t${importStatement}\\n\\t${initCode}`\n );\n } else {\n // If no script tag found, add one at the beginning\n return content.replace(\n /<svelte:head>/,\n `<script lang=\"ts\">\\n\\t${envImport}\\n\\t${importStatement}\\n\\t${initCode}\\n</script>\\n\\n<svelte:head>`\n );\n }\n }\n\n private injectVanillaScript(content: string): string {\n if (content.includes('humanbehavior-js')) {\n return content;\n }\n\n const cdnScript = `<script src=\"https://unpkg.com/humanbehavior-js@latest/dist/index.min.js\"></script>`;\n const initScript = `<script>\n // Initialize HumanBehavior SDK\n // Note: For vanilla HTML, the API key must be hardcoded since env vars aren't available\n const tracker = HumanBehaviorTracker.init('${this.apiKey}');\n</script>`;\n \n return content.replace(\n /<\\/head>/,\n ` ${cdnScript}\\n ${initScript}\\n</head>`\n );\n }\n\n /**\n * Inject Astro layout with HumanBehavior component\n */\n private injectAstroLayout(content: string): string {\n // Check if HumanBehavior component is already imported\n if (content.includes('HumanBehavior') || content.includes('humanbehavior-js')) {\n return content; // Already has HumanBehavior\n }\n\n // Add import inside frontmatter if not present\n let modifiedContent = content;\n if (!content.includes('import HumanBehavior')) {\n const importStatement = 'import HumanBehavior from \\'../components/HumanBehavior.astro\\';';\n const frontmatterEndIndex = content.indexOf('---', 3);\n if (frontmatterEndIndex !== -1) {\n // Insert import inside frontmatter, before the closing ---\n modifiedContent = content.slice(0, frontmatterEndIndex) + '\\n' + importStatement + '\\n' + content.slice(frontmatterEndIndex);\n } else {\n // No frontmatter, add at the very beginning\n modifiedContent = '---\\n' + importStatement + '\\n---\\n\\n' + content;\n }\n }\n\n // Find the closing </body> tag and add HumanBehavior component before it\n const bodyCloseIndex = modifiedContent.lastIndexOf('</body>');\n if (bodyCloseIndex === -1) {\n // No body tag found, append to end\n return modifiedContent + '\\n\\n<HumanBehavior />';\n }\n\n // Add component before closing body tag\n return modifiedContent.slice(0, bodyCloseIndex) + ' <HumanBehavior />\\n' + modifiedContent.slice(bodyCloseIndex);\n }\n\n private injectNuxtConfig(content: string): string {\n if (content.includes('humanBehaviorApiKey')) {\n return content;\n }\n\n // Enhanced Nuxt 3 support with version detection\n const hasNuxt3 = this.framework?.features?.hasNuxt3;\n \n if (hasNuxt3) {\n // Nuxt 3 with runtime config\n return content.replace(\n /export default defineNuxtConfig\\(\\{/,\n `export default defineNuxtConfig({\n runtimeConfig: {\n public: {\n humanBehaviorApiKey: process.env.NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY\n }\n },`\n );\n } else {\n // Nuxt 2 with env config\n return content.replace(\n /export default \\{/,\n `export default {\n env: {\n humanBehaviorApiKey: process.env.HUMANBEHAVIOR_API_KEY\n },`\n );\n }\n }\n\n private injectGatsbyLayout(content: string): string {\n if (content.includes('HumanBehavior')) {\n return content;\n }\n\n const importStatement = `import HumanBehavior from './HumanBehavior';`;\n const componentUsage = `<HumanBehavior apiKey={process.env.GATSBY_HUMANBEHAVIOR_API_KEY || ''} />`;\n\n // Add import at the top\n let modifiedContent = content.replace(\n /import.*from.*['\"]\\./,\n `${importStatement}\\n$&`\n );\n\n // Add component before closing body tag\n modifiedContent = modifiedContent.replace(\n /(\\s*<\\/body>)/,\n `\\n ${componentUsage}\\n$1`\n );\n\n return modifiedContent;\n }\n\n private injectGatsbyBrowser(content: string): string {\n if (content.includes('HumanBehaviorTracker')) {\n return content;\n }\n\n const importStatement = `import { HumanBehaviorTracker } from 'humanbehavior-js';`;\n const initCode = `\n// Initialize HumanBehavior SDK\nexport const onClientEntry = () => {\n console.log('Gatsby browser entry point loaded');\n const apiKey = process.env.GATSBY_HUMANBEHAVIOR_API_KEY;\n console.log('API Key found:', apiKey ? 'Yes' : 'No');\n if (apiKey) {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior SDK initialized for Gatsby');\n } else {\n console.log('No API key found in environment variables');\n }\n};`;\n\n // If the file already has content, add the import and init code\n if (content.trim()) {\n return `${importStatement}${initCode}\\n\\n${content}`;\n } else {\n // If file is empty, just return the new content\n return `${importStatement}${initCode}`;\n }\n }\n\n\n\n /**\n * Helper method to find the best environment file for a framework\n */\n private findBestEnvFile(framework: FrameworkInfo): { filePath: string; envVarName: string } {\n const possibleEnvFiles = [\n '.env.local',\n '.env.development.local',\n '.env.development',\n '.env.local.development',\n '.env',\n '.env.production',\n '.env.staging'\n ];\n\n // Framework-specific environment variable names\n const getEnvVarName = (framework: FrameworkInfo) => {\n // Handle React+Vite specifically\n if (framework.type === 'react' && framework.bundler === 'vite') {\n return 'VITE_HUMANBEHAVIOR_API_KEY';\n }\n \n // Framework-specific mappings\n const envVarNames = {\n react: 'HUMANBEHAVIOR_API_KEY',\n nextjs: 'NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY',\n vue: 'VITE_HUMANBEHAVIOR_API_KEY',\n svelte: 'PUBLIC_HUMANBEHAVIOR_API_KEY',\n angular: 'HUMANBEHAVIOR_API_KEY',\n nuxt: 'NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY',\n remix: 'HUMANBEHAVIOR_API_KEY',\n vanilla: 'HUMANBEHAVIOR_API_KEY',\n astro: 'PUBLIC_HUMANBEHAVIOR_API_KEY',\n gatsby: 'GATSBY_HUMANBEHAVIOR_API_KEY',\n node: 'HUMANBEHAVIOR_API_KEY',\n auto: 'HUMANBEHAVIOR_API_KEY'\n };\n \n return envVarNames[framework.type] || 'HUMANBEHAVIOR_API_KEY';\n };\n\n const envVarName = getEnvVarName(framework);\n\n // Check for existing files\n for (const envFile of possibleEnvFiles) {\n const fullPath = path.join(this.projectRoot, envFile);\n if (fs.existsSync(fullPath)) {\n return { filePath: fullPath, envVarName };\n }\n }\n\n // Framework-specific default file creation\n const defaultFiles = {\n react: '.env.local',\n nextjs: '.env.local',\n vue: '.env.local',\n svelte: '.env',\n angular: '.env',\n nuxt: '.env',\n remix: '.env.local',\n vanilla: '.env',\n astro: '.env',\n gatsby: '.env.development',\n node: '.env',\n auto: '.env'\n };\n\n const defaultFile = defaultFiles[framework.type] || '.env';\n return {\n filePath: path.join(this.projectRoot, defaultFile),\n envVarName\n };\n }\n\n /**\n * Helper method to create or append to environment files\n */\n private createEnvironmentModification(framework: FrameworkInfo): CodeModification {\n const { filePath, envVarName } = this.findBestEnvFile(framework);\n\n // Clean the API key to prevent formatting issues\n const cleanApiKey = this.apiKey.trim();\n\n if (fs.existsSync(filePath)) {\n // Check if the variable already exists\n const content = fs.readFileSync(filePath, 'utf8');\n if (content.includes(envVarName)) {\n // Variable exists, don't modify\n return {\n filePath,\n action: 'modify',\n content: content, // No change\n description: `API key already exists in ${path.basename(filePath)}`\n };\n } else {\n // Append to existing file\n return {\n filePath,\n action: 'append',\n content: `\\n${envVarName}=${cleanApiKey}`,\n description: `Added API key to existing ${path.basename(filePath)}`\n };\n }\n } else {\n // Create new file\n return {\n filePath,\n action: 'create',\n content: `${envVarName}=${cleanApiKey}`,\n description: `Created ${path.basename(filePath)} with API key`\n };\n }\n }\n}\n\n/**\n * Browser-based auto-installation wizard\n */\nexport class BrowserAutoInstallationWizard {\n private apiKey: string;\n\n constructor(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n async install(): Promise<InstallationResult> {\n try {\n // Detect framework in browser\n const framework = this.detectFramework();\n \n // Generate installation instructions\n const modifications = this.generateBrowserModifications(framework);\n \n return {\n success: true,\n framework,\n modifications,\n errors: [],\n nextSteps: [\n '✅ Framework detected automatically',\n '📋 Copy the generated code to your project',\n '🚀 Your app will be ready to track user behavior'\n ]\n };\n } catch (error) {\n return {\n success: false,\n framework: { name: 'unknown', type: 'vanilla' },\n modifications: [],\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n nextSteps: []\n };\n }\n }\n\n private detectFramework(): FrameworkInfo {\n if (typeof window !== 'undefined') {\n if ((window as any).React) {\n return { name: 'react', type: 'react' };\n }\n if ((window as any).Vue) {\n return { name: 'vue', type: 'vue' };\n }\n if ((window as any).angular) {\n return { name: 'angular', type: 'angular' };\n }\n }\n \n return { name: 'vanilla', type: 'vanilla' };\n }\n\n private generateBrowserModifications(framework: FrameworkInfo): CodeModification[] {\n // Return code snippets for browser environment\n const modifications: CodeModification[] = [];\n \n switch (framework.type) {\n case 'react':\n modifications.push({\n filePath: 'App.jsx',\n action: 'create',\n content: `import { HumanBehaviorProvider } from 'humanbehavior-js/react';\n\nfunction App() {\n return (\n <HumanBehaviorProvider apiKey=\"${this.apiKey}\">\n {/* Your app components */}\n </HumanBehaviorProvider>\n );\n}\n\nexport default App;`,\n description: 'React component with HumanBehaviorProvider'\n });\n break;\n \n case 'remix':\n modifications.push({\n filePath: 'app/root.tsx',\n action: 'create',\n content: `import {\n Links,\n Meta,\n Outlet,\n Scripts,\n ScrollRestoration,\n useLoaderData,\n} from \"@remix-run/react\";\nimport { HumanBehaviorProvider } from 'humanbehavior-js/react';\nimport type { LoaderFunctionArgs } from \"@remix-run/node\";\n\nexport async function loader({ request }: LoaderFunctionArgs) {\n return {\n ENV: {\n HUMANBEHAVIOR_API_KEY: process.env.HUMANBEHAVIOR_API_KEY,\n },\n };\n}\n\nexport function Layout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <head>\n <meta charSet=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <Meta />\n <Links />\n </head>\n <body>\n {children}\n <ScrollRestoration />\n <Scripts />\n </body>\n </html>\n );\n}\n\nexport default function App() {\n const data = useLoaderData<typeof loader>();\n \n return (\n <HumanBehaviorProvider apiKey={data.ENV.HUMANBEHAVIOR_API_KEY}>\n <div className=\"min-h-screen bg-gray-50\">\n {/* Your app content */}\n <Outlet />\n </div>\n </HumanBehaviorProvider>\n );\n}`,\n description: 'Remix root component with HumanBehaviorProvider'\n });\n break;\n \n case 'vue':\n modifications.push({\n filePath: 'main.js',\n action: 'create',\n content: `import { createApp } from 'vue';\nimport { HumanBehaviorPlugin } from 'humanbehavior-js/vue';\nimport App from './App.vue';\n\nconst app = createApp(App);\napp.use(HumanBehaviorPlugin, {\n apiKey: '${this.apiKey}'\n});\napp.mount('#app');`,\n description: 'Vue app with HumanBehaviorPlugin'\n });\n break;\n \n default:\n modifications.push({\n filePath: 'humanbehavior-init.js',\n action: 'create',\n content: `import { HumanBehaviorTracker } from 'humanbehavior-js';\n\nconst tracker = HumanBehaviorTracker.init('${this.apiKey}');`,\n description: 'Vanilla JS initialization'\n });\n }\n \n return modifications;\n }\n} ","/**\n * Remote AI Service Implementation\n * \n * This connects to your deployed Lambda function via API Gateway\n */\n\nimport { AICodeAnalysis } from '../ai/ai-install-wizard';\n\nexport interface FrameworkInfo {\n name: string;\n type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node';\n bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';\n packageManager?: 'npm' | 'yarn' | 'pnpm';\n hasTypeScript?: boolean;\n hasRouter?: boolean;\n projectRoot?: string;\n version?: string;\n majorVersion?: number;\n features?: {\n hasReact18?: boolean;\n hasVue3?: boolean;\n hasNuxt3?: boolean;\n hasAngularStandalone?: boolean;\n hasNextAppRouter?: boolean;\n hasSvelteKit?: boolean;\n };\n}\n\nexport interface RemoteAIServiceConfig {\n apiEndpoint: string;\n timeout?: number;\n}\n\nexport class RemoteAIService {\n private config: RemoteAIServiceConfig;\n\n constructor(config: RemoteAIServiceConfig) {\n this.config = {\n timeout: 10000, // 10 seconds\n ...config\n };\n }\n\n /**\n * Analyze code patterns using your deployed AI service\n */\n async analyzeCodePatterns(codeSamples: string[]): Promise<AICodeAnalysis> {\n try {\n const response = await fetch(`${this.config.apiEndpoint}/analyze`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ codeSamples }),\n signal: AbortSignal.timeout(this.config.timeout || 10000)\n });\n\n if (!response.ok) {\n throw new Error(`AI service returned ${response.status}: ${response.statusText}`);\n }\n\n const result = await response.json();\n return result.analysis;\n } catch (error) {\n console.warn('Remote AI service failed, falling back to heuristic analysis:', error);\n return this.performHeuristicAnalysis(codeSamples);\n }\n }\n\n /**\n * Resolve conflicts using your deployed AI service\n */\n async resolveConflicts(conflicts: string[], framework: FrameworkInfo): Promise<string[]> {\n try {\n const response = await fetch(`${this.config.apiEndpoint}/resolve-conflicts`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ conflicts, framework }),\n signal: AbortSignal.timeout(this.config.timeout || 10000)\n });\n\n if (!response.ok) {\n throw new Error(`AI service returned ${response.status}: ${response.statusText}`);\n }\n\n const result = await response.json();\n return result.resolutions || [];\n } catch (error) {\n console.warn('Remote AI conflict resolution failed, using heuristic approach:', error);\n return this.resolveConflictsHeuristic(conflicts, framework);\n }\n }\n\n /**\n * Generate optimizations using your deployed AI service\n */\n async generateOptimizations(framework: FrameworkInfo, patterns: string[]): Promise<string[]> {\n try {\n const response = await fetch(`${this.config.apiEndpoint}/optimize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ framework, patterns }),\n signal: AbortSignal.timeout(this.config.timeout || 10000)\n });\n\n if (!response.ok) {\n throw new Error(`AI service returned ${response.status}: ${response.statusText}`);\n }\n\n const result = await response.json();\n return result.optimizations || [];\n } catch (error) {\n console.warn('Remote AI optimization generation failed, using heuristic approach:', error);\n return this.generateOptimizationsHeuristic(framework, patterns);\n }\n }\n\n /**\n * Heuristic analysis fallback\n */\n private performHeuristicAnalysis(codeSamples: string[]): AICodeAnalysis {\n const patterns = codeSamples.join(' ').toLowerCase();\n \n // Framework detection\n let framework: FrameworkInfo = { name: 'vanilla', type: 'vanilla' };\n let confidence = 0.5;\n \n if (patterns.includes('nuxt') || patterns.includes('nuxtjs') || patterns.includes('defineNuxtConfig') || patterns.includes('nuxt.config') || patterns.includes('@nuxt/') || patterns.includes('useNuxtApp') || patterns.includes('useRuntimeConfig') || patterns.includes('useSeoMeta') || patterns.includes('useHead') || patterns.includes('useLazyFetch') || patterns.includes('useFetch') || patterns.includes('useAsyncData') || patterns.includes('#app')) {\n framework = { name: 'nuxt', type: 'nuxt' };\n confidence = 0.95;\n } else if (patterns.includes('next') || patterns.includes('nextjs') || patterns.includes('next/link') || patterns.includes('next/image') || patterns.includes('next/navigation') || patterns.includes('next/router') || patterns.includes('getserverSideProps') || patterns.includes('getstaticProps') || patterns.includes('getstaticPaths') || patterns.includes('app/layout') || patterns.includes('app/page') || patterns.includes('pages/')) {\n framework = { name: 'nextjs', type: 'nextjs' };\n confidence = 0.95;\n } else if (patterns.includes('gatsby') || patterns.includes('gatsby-browser') || patterns.includes('gatsby-ssr') || patterns.includes('gatsby-node') || patterns.includes('gatsby-config') || patterns.includes('useStaticQuery') || patterns.includes('graphql')) {\n framework = { name: 'gatsby', type: 'gatsby' };\n confidence = 0.95;\n } else if (patterns.includes('react')) {\n framework = { name: 'react', type: 'react' };\n confidence = 0.9;\n } else if (patterns.includes('vue')) {\n framework = { name: 'vue', type: 'vue' };\n confidence = 0.9;\n } else if (patterns.includes('angular')) {\n framework = { name: 'angular', type: 'angular' };\n confidence = 0.9;\n } else if (patterns.includes('svelte')) {\n framework = { name: 'svelte', type: 'svelte' };\n confidence = 0.9;\n } else if (patterns.includes('astro')) {\n framework = { name: 'astro', type: 'astro' };\n confidence = 0.9;\n }\n \n // Integration strategy\n let integrationStrategy: 'provider' | 'plugin' | 'module' | 'script' | 'standalone' = 'script';\n if (framework.type === 'react' || framework.type === 'nextjs' || framework.type === 'gatsby') {\n integrationStrategy = 'provider';\n } else if (framework.type === 'vue') {\n integrationStrategy = 'plugin';\n } else if (framework.type === 'angular') {\n integrationStrategy = 'module';\n }\n \n // Compatibility mode\n let compatibilityMode: 'modern' | 'legacy' | 'hybrid' = 'modern';\n if (patterns.includes('require(') || patterns.includes('var ')) {\n compatibilityMode = 'legacy';\n }\n \n return {\n framework,\n confidence,\n patterns: codeSamples,\n conflicts: [],\n recommendations: [],\n integrationStrategy,\n compatibilityMode\n };\n }\n\n /**\n * Heuristic conflict resolution\n */\n private resolveConflictsHeuristic(conflicts: string[], framework: FrameworkInfo): string[] {\n const resolutions: string[] = [];\n \n for (const conflict of conflicts) {\n switch (conflict) {\n case 'existing_humanbehavior_code':\n resolutions.push('update_existing_integration');\n break;\n case 'existing_provider':\n resolutions.push('merge_providers');\n break;\n case 'module_system_conflict':\n resolutions.push('hybrid_module_support');\n break;\n default:\n resolutions.push('skip_conflict');\n }\n }\n \n return resolutions;\n }\n\n /**\n * Heuristic optimization generation\n */\n private generateOptimizationsHeuristic(framework: FrameworkInfo, patterns: string[]): string[] {\n const optimizations: string[] = [];\n \n switch (framework.type) {\n case 'react':\n optimizations.push('Use React.memo for performance optimization');\n optimizations.push('Implement error boundaries for better error tracking');\n optimizations.push('Consider using React.lazy for code splitting');\n break;\n case 'vue':\n optimizations.push('Use Vue 3 Composition API for better performance');\n optimizations.push('Implement proper error handling in components');\n optimizations.push('Consider using Vue Router for navigation tracking');\n break;\n case 'angular':\n optimizations.push('Use Angular standalone components for better tree-shaking');\n optimizations.push('Implement proper error handling with ErrorHandler');\n optimizations.push('Consider using Angular signals for state management');\n break;\n default:\n optimizations.push('Enable performance tracking');\n optimizations.push('Implement error tracking');\n optimizations.push('Consider progressive enhancement');\n }\n \n return optimizations;\n }\n} ","/**\n * Manual Framework Installation Wizard\n * \n * This wizard allows users to manually specify their framework instead of auto-detection.\n * Useful when auto-detection fails or users want more control.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { AutoInstallationWizard, FrameworkInfo, CodeModification, InstallationResult } from '../core/install-wizard';\nimport { RemoteAIService } from '../services/remote-ai-service';\n\nexport interface ManualInstallationResult extends InstallationResult {\n selectedFramework: string;\n manualMode: boolean;\n}\n\nexport class ManualFrameworkInstallationWizard extends AutoInstallationWizard {\n private selectedFramework: string;\n\n constructor(apiKey: string, projectRoot: string = process.cwd(), framework: string) {\n super(apiKey, projectRoot);\n this.selectedFramework = framework.toLowerCase();\n this.framework = this.createFrameworkInfo(this.selectedFramework);\n }\n\n /**\n * Manual installation with user-specified framework\n */\n async install(): Promise<ManualInstallationResult> {\n try {\n // Step 1: Handle framework selection\n if (this.selectedFramework === 'auto') {\n // Use full AI detection for \"Other\" option\n this.framework = await this.runFullDetection();\n } else {\n // Set framework based on user selection\n this.framework = this.createFrameworkInfo(this.selectedFramework);\n if (!this.framework) {\n this.framework = { name: 'unknown', type: 'vanilla' };\n }\n \n // Step 2: Run full detection logic to find entry points, file names, etc.\n const detectedFramework = await this.runFullDetection();\n \n // Step 3: Merge manual framework with detected details\n this.framework = {\n ...detectedFramework,\n name: this.framework.name,\n type: this.framework.type\n };\n }\n \n // Step 4: Install package\n await this.installPackage();\n \n // Step 5: Generate and apply code modifications\n const modifications = await this.generateModifications();\n await this.applyModifications(modifications);\n \n // Step 6: Generate next steps\n const nextSteps = this.generateManualNextSteps();\n \n return {\n success: true,\n framework: this.framework,\n modifications,\n errors: [],\n nextSteps,\n selectedFramework: this.selectedFramework,\n manualMode: true\n };\n } catch (error) {\n return {\n success: false,\n framework: this.framework || { name: 'unknown', type: 'vanilla' },\n modifications: [],\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n nextSteps: [],\n selectedFramework: this.selectedFramework,\n manualMode: true\n };\n }\n }\n\n /**\n * Run full detection logic to find entry points, file names, bundler, etc.\n */\n private async runFullDetection(): Promise<FrameworkInfo> {\n if (this.selectedFramework === 'auto') {\n // Use AI service for auto-detection\n const aiService = new RemoteAIService({\n apiEndpoint: 'https://ik3zxh4790.execute-api.us-east-1.amazonaws.com/prod'\n });\n \n // Use AI service directly for detection\n const projectFiles = await this.scanProjectFiles();\n const codeSamples = await this.extractCodeSamples(projectFiles);\n const aiAnalysis = await aiService.analyzeCodePatterns(codeSamples);\n return aiAnalysis.framework;\n } else {\n // Use traditional detection for manual frameworks\n const tempWizard = new AutoInstallationWizard(this.apiKey, this.projectRoot);\n const detected = await tempWizard.detectFramework();\n return detected;\n }\n }\n\n /**\n * Scan project files for analysis\n */\n private async scanProjectFiles(): Promise<string[]> {\n const files: string[] = [];\n const scanDir = (dir: string, depth: number = 0) => {\n if (depth > 3) return; // Limit depth\n \n try {\n const items = fs.readdirSync(dir);\n for (const item of items) {\n const fullPath = path.join(dir, item);\n const stat = fs.statSync(fullPath);\n \n if (stat.isDirectory() && !item.startsWith('.') && item !== 'node_modules') {\n scanDir(fullPath, depth + 1);\n } else if (stat.isFile() && this.isRelevantFile(item)) {\n files.push(fullPath);\n }\n }\n } catch (error) {\n // Skip inaccessible directories\n }\n };\n \n scanDir(this.projectRoot);\n return files;\n }\n\n /**\n * Check if file is relevant for analysis\n */\n private isRelevantFile(filename: string): boolean {\n const relevantExtensions = [\n '.js', '.jsx', '.ts', '.tsx', '.vue', '.svelte', '.html',\n '.json', '.config.js', '.config.ts', '.babelrc', '.eslintrc'\n ];\n \n const relevantNames = [\n 'package.json', 'tsconfig.json', 'vite.config', 'webpack.config',\n 'next.config', 'nuxt.config', 'angular.json', 'svelte.config'\n ];\n \n return relevantExtensions.some(ext => filename.endsWith(ext)) ||\n relevantNames.some(name => filename.includes(name));\n }\n\n /**\n * Extract code samples for AI analysis\n */\n private async extractCodeSamples(files: string[]): Promise<string[]> {\n const samples: string[] = [];\n \n for (const file of files.slice(0, 20)) { // Limit to 20 files\n try {\n const content = fs.readFileSync(file, 'utf8');\n const relativePath = path.relative(this.projectRoot, file);\n samples.push(`File: ${relativePath}\\n${content.substring(0, 1000)}`);\n } catch (error) {\n // Skip unreadable files\n }\n }\n \n return samples;\n }\n\n /**\n * Create framework info based on user selection\n */\n private createFrameworkInfo(framework: string): FrameworkInfo {\n const frameworkMap: Record<string, FrameworkInfo> = {\n 'react': { name: 'react', type: 'react' },\n 'nextjs': { name: 'nextjs', type: 'nextjs' },\n 'next': { name: 'nextjs', type: 'nextjs' },\n 'vue': { name: 'vue', type: 'vue' },\n 'nuxt': { name: 'nuxt', type: 'nuxt' },\n 'nuxtjs': { name: 'nuxt', type: 'nuxt' },\n 'angular': { name: 'angular', type: 'angular' },\n 'svelte': { name: 'svelte', type: 'svelte' },\n 'sveltekit': { name: 'svelte', type: 'svelte' },\n 'remix': { name: 'remix', type: 'remix' },\n 'astro': { name: 'astro', type: 'astro' },\n 'gatsby': { name: 'gatsby', type: 'gatsby' },\n 'vanilla': { name: 'vanilla', type: 'vanilla' },\n 'node': { name: 'node', type: 'node' },\n 'auto': { name: 'auto-detected', type: 'auto' }\n };\n\n return frameworkMap[framework] || { name: framework, type: 'vanilla' };\n }\n\n /**\n * Override framework detection to use manual selection\n */\n public async detectFramework(): Promise<FrameworkInfo> {\n return this.framework || { name: 'unknown', type: 'vanilla' };\n }\n\n /**\n * Generate next steps with manual mode info\n */\n private generateManualNextSteps(): string[] {\n return [\n '✅ Manual framework installation completed!',\n `🎯 Selected framework: ${this.framework?.name || 'unknown'}`,\n `🔧 Integration strategy: ${this.getIntegrationStrategy()}`,\n '🚀 Your app is now ready to track user behavior',\n '📊 View sessions in your HumanBehavior dashboard'\n ];\n }\n\n /**\n * Get integration strategy based on framework\n */\n private getIntegrationStrategy(): string {\n if (!this.framework?.type) return 'script';\n \n switch (this.framework.type) {\n case 'react':\n case 'nextjs':\n return 'provider';\n case 'vue':\n return 'plugin';\n case 'angular':\n return 'module';\n default:\n return 'script';\n }\n }\n} ","#!/usr/bin/env node\n\n/**\n * HumanBehavior SDK Auto-Installation CLI\n * \n * Usage: npx humanbehavior-js auto-install [api-key]\n * \n * This tool automatically detects the user's framework and modifies their codebase\n * to integrate the SDK with minimal user intervention.\n */\n\nimport { AutoInstallationWizard } from '../core/install-wizard';\nimport { ManualFrameworkInstallationWizard } from '../ai/manual-framework-wizard';\nimport * as clack from '@clack/prompts';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\ninterface CLIOptions {\n apiKey?: string;\n projectPath?: string;\n yes?: boolean;\n dryRun?: boolean;\n}\n\nclass AutoInstallCLI {\n private options: CLIOptions;\n\n constructor(options: CLIOptions) {\n this.options = options;\n }\n\n async run() {\n clack.intro('🚀 HumanBehavior SDK Auto-Installation');\n\n try {\n // Get API key\n const apiKey = await this.getApiKey();\n if (!apiKey) {\n clack.cancel('API key is required');\n process.exit(1);\n }\n\n // Get project path\n const projectPath = this.options.projectPath || process.cwd();\n \n // Choose framework\n const framework = await this.chooseFramework();\n if (!framework) {\n clack.cancel('Installation cancelled.');\n process.exit(0);\n }\n \n // Confirm installation\n if (!this.options.yes) {\n const confirmed = await this.confirmInstallation(projectPath, framework);\n if (!confirmed) {\n clack.cancel('Installation cancelled.');\n process.exit(0);\n }\n }\n\n // Run installation\n const spinner = clack.spinner();\n spinner.start('🔍 Analyzing your project...');\n \n const wizard = new ManualFrameworkInstallationWizard(apiKey, projectPath, framework);\n const result = await wizard.install();\n\n spinner.stop('Detection complete!');\n\n // Display results\n this.displayResults(result);\n\n } catch (error) {\n clack.cancel(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);\n process.exit(1);\n }\n }\n\n private async getApiKey(): Promise<string> {\n if (this.options.apiKey) {\n return this.options.apiKey;\n }\n\n const apiKey = await clack.text({\n message: 'Enter your HumanBehavior API key:',\n placeholder: 'hb_...',\n validate: (value) => {\n if (!value) return 'API key is required';\n if (!value.startsWith('hb_')) return 'API key should start with \"hb_\"';\n return undefined;\n }\n });\n\n return apiKey as string;\n }\n\n\n\n private async chooseFramework(): Promise<string> {\n const framework = await clack.select({\n message: 'Select your framework:',\n options: [\n { label: 'React', value: 'react' },\n { label: 'Next.js', value: 'nextjs' },\n { label: 'Vue', value: 'vue' },\n { label: 'Angular', value: 'angular' },\n { label: 'Svelte', value: 'svelte' },\n { label: 'Nuxt.js', value: 'nuxt' },\n { label: 'Remix', value: 'remix' },\n { label: 'Astro', value: 'astro' },\n { label: 'Gatsby', value: 'gatsby' },\n { label: 'Vanilla JS/TS', value: 'vanilla' }\n ]\n });\n\n return framework as string;\n }\n\n private async confirmInstallation(projectPath: string, framework: string): Promise<boolean> {\n const confirmed = await clack.confirm({\n message: `Ready to install HumanBehavior SDK in ${projectPath} for ${framework}?`\n });\n\n return confirmed as boolean;\n }\n\n private displayResults(result: any) {\n if (result.success) {\n clack.outro('🎉 Installation completed successfully!');\n\n // Display framework info\n clack.note(`Framework detected: ${result.framework.name} (${result.framework.type})`, 'Framework Info');\n\n // Display modifications\n if (result.modifications && result.modifications.length > 0) {\n const modifications = result.modifications.map((mod: any) => \n `${mod.action}: ${mod.filePath} - ${mod.description}`\n );\n clack.note(modifications.join('\\n'), 'Files Modified');\n }\n\n // Display next steps\n if (result.nextSteps && result.nextSteps.length > 0) {\n clack.note(result.nextSteps.join('\\n'), 'Next Steps');\n }\n\n } else {\n clack.cancel('Installation failed');\n \n if (result.errors && result.errors.length > 0) {\n clack.note(result.errors.join('\\n'), 'Errors');\n }\n }\n }\n}\n\nfunction parseArgs(): CLIOptions {\n const args = process.argv.slice(2);\n const options: CLIOptions = {};\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n \n switch (arg) {\n case '--help':\n case '-h':\n showHelp();\n process.exit(0);\n break;\n case '--yes':\n case '-y':\n options.yes = true;\n break;\n case '--dry-run':\n options.dryRun = true;\n break;\n case '--project':\n case '-p':\n options.projectPath = args[++i];\n break;\n default:\n if (!options.apiKey && !arg.startsWith('-')) {\n options.apiKey = arg;\n }\n break;\n }\n }\n\n return options;\n}\n\nfunction showHelp() {\n console.log(`\n🚀 HumanBehavior SDK Auto-Installation\n\nUsage: npx humanbehavior-js auto-install [api-key] [options]\n\nThis tool automatically detects your framework and integrates the HumanBehavior SDK.\n\nOptions:\n -h, --help Show this help message\n -y, --yes Skip all prompts and use defaults\n --dry-run Show what would be changed without making changes\n -p, --project <path> Specify project directory\n\nExamples:\n npx humanbehavior-js auto-install\n npx humanbehavior-js auto-install hb_your_api_key_here\n npx humanbehavior-js auto-install --project ./my-app --yes\n`);\n}\n\n// Main execution\nif (import.meta.url === `file://${process.argv[1]}`) {\n const options = parseArgs();\n const cli = new AutoInstallCLI(options);\n cli.run().catch((error) => {\n clack.cancel(`Unexpected error: ${error.message}`);\n process.exit(1);\n });\n}\n\nexport { AutoInstallCLI }; "],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;MAwCU,sBAAsB,CAAA;AAKjC,IAAA,WAAA,CAAY,MAAc,EAAE,WAAA,GAAsB,OAAO,CAAC,GAAG,EAAE,EAAA;QAFrD,IAAA,CAAA,SAAS,GAAyB,IAAI;AAG9C,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;IAChC;AAEA;;AAEG;IACK,eAAe,CAAC,QAAgB,EAAE,QAAgB,EAAA;AACxD,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;AAC/C,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QAE/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,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I;gBACrB;AACF,YAAA,KAAK,WAAW;AAChB,YAAA,KAAK,IAAI;gBACP,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B;AACF,YAAA;AACE,gBAAA,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AAC3C,oBAAA,OAAO,CAAC,MAAM,GAAG,GAAG;gBACtB;gBACA;;IAEN;AAEA,IAAA,OAAO,OAAO;AAChB;AAEA,SAAS,QAAQ,GAAA;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;AAiBb,CAAA,CAAC;AACF;AAEA;AACA,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA,OAAA,EAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,EAAE;AACnD,IAAA,MAAM,OAAO,GAAG,SAAS,EAAE;AAC3B,IAAA,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC;IACvC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;QACxB,KAAK,CAAC,MAAM,CAAC,CAAA,kBAAA,EAAqB,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;AAClD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This wizard automatically detects the user's framework and modifies their codebase
|
|
5
5
|
* to integrate the SDK with minimal user intervention.
|
|
6
6
|
*/
|
|
7
|
-
interface FrameworkInfo {
|
|
7
|
+
export interface FrameworkInfo {
|
|
8
8
|
name: string;
|
|
9
9
|
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node' | 'auto';
|
|
10
10
|
bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
|
|
@@ -23,20 +23,20 @@ interface FrameworkInfo {
|
|
|
23
23
|
hasSvelteKit?: boolean;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
interface CodeModification {
|
|
26
|
+
export interface CodeModification {
|
|
27
27
|
filePath: string;
|
|
28
28
|
action: 'create' | 'modify' | 'append';
|
|
29
29
|
content: string;
|
|
30
30
|
description: string;
|
|
31
31
|
}
|
|
32
|
-
interface InstallationResult {
|
|
32
|
+
export interface InstallationResult {
|
|
33
33
|
success: boolean;
|
|
34
34
|
framework: FrameworkInfo;
|
|
35
35
|
modifications: CodeModification[];
|
|
36
36
|
errors: string[];
|
|
37
37
|
nextSteps: string[];
|
|
38
38
|
}
|
|
39
|
-
declare class AutoInstallationWizard {
|
|
39
|
+
export declare class AutoInstallationWizard {
|
|
40
40
|
protected apiKey: string;
|
|
41
41
|
protected projectRoot: string;
|
|
42
42
|
protected framework: FrameworkInfo | null;
|
|
@@ -144,13 +144,11 @@ declare class AutoInstallationWizard {
|
|
|
144
144
|
/**
|
|
145
145
|
* Browser-based auto-installation wizard
|
|
146
146
|
*/
|
|
147
|
-
declare class BrowserAutoInstallationWizard {
|
|
147
|
+
export declare class BrowserAutoInstallationWizard {
|
|
148
148
|
private apiKey;
|
|
149
149
|
constructor(apiKey: string);
|
|
150
150
|
install(): Promise<InstallationResult>;
|
|
151
151
|
private detectFramework;
|
|
152
152
|
private generateBrowserModifications;
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
export { AutoInstallationWizard, BrowserAutoInstallationWizard };
|
|
156
|
-
export type { CodeModification, FrameworkInfo, InstallationResult };
|
|
154
|
+
//# sourceMappingURL=install-wizard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-wizard.d.ts","sourceRoot":"","sources":["../../src/core/install-wizard.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;I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AC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,mBAAmB;IA+B3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAsEvB;;OAEG;IACH,OAAO,CAAC,6BAA6B;CAoCtC;AAED;;GAEG;AACH,qBAAa,6BAA6B;IACxC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAIpB,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA8B5C,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,4BAA4B;CA+GrC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HumanBehavior SDK Wizard Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides AI-enhanced auto-installation capabilities for the HumanBehavior SDK.
|
|
5
|
+
* It includes traditional installation, AI-powered analysis, and centralized AI services.
|
|
6
|
+
*/
|
|
7
|
+
export { AutoInstallationWizard } from './core/install-wizard';
|
|
8
|
+
export type { FrameworkInfo, CodeModification, InstallationResult } from './core/install-wizard';
|
|
9
|
+
export { AIEnhancedInstallationWizard, AIBrowserInstallationWizard } from './ai/ai-install-wizard';
|
|
10
|
+
export type { AICodeAnalysis, AIInstallationResult } from './ai/ai-install-wizard';
|
|
11
|
+
export { AIAutoInstallCLI } from './cli/ai-auto-install';
|
|
12
|
+
export { AutoInstallCLI } from './cli/auto-install';
|
|
13
|
+
export { RemoteAIService } from './services/remote-ai-service';
|
|
14
|
+
export type { RemoteAIServiceConfig } from './services/remote-ai-service';
|
|
15
|
+
export { CentralizedAIService } from './services/centralized-ai-service';
|
|
16
|
+
export type { CentralizedAIServiceConfig } from './services/centralized-ai-service';
|
|
17
|
+
export { AutoInstallationWizard as InstallWizard } from './core/install-wizard';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGjG,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACnG,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,YAAY,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAGpF,OAAO,EAAE,sBAAsB,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("fs"),t=require("path"),n=require("@clack/prompts"),i="undefined"!=typeof document?document.currentScript:null;function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var a=r(e),o=r(t),s=r(n);class c{constructor(e,t=process.cwd()){this.framework=null,this.apiKey=e,this.projectRoot=t}compareVersions(e,t){const n=e.split(".").map(Number),i=t.split(".").map(Number);for(let e=0;e<Math.max(n.length,i.length);e++){const t=n[e]||0,r=i[e]||0;if(t>r)return 1;if(t<r)return-1}return 0}isVersionGte(e,t){return this.compareVersions(e,t)>=0}getMajorVersion(e){return parseInt(e.split(".")[0])||0}async install(){try{this.framework=await this.detectFramework(),await this.installPackage();const e=await this.generateModifications();await this.applyModifications(e);const t=this.generateNextSteps();return{success:!0,framework:this.framework,modifications:e,errors:[],nextSteps:t}}catch(e){return{success:!1,framework:this.framework||{name:"unknown",type:"vanilla"},modifications:[],errors:[e instanceof Error?e.message:"Unknown error"],nextSteps:[]}}}async detectFramework(){const e=o.join(this.projectRoot,"package.json");if(!a.existsSync(e))return{name:"vanilla",type:"vanilla",projectRoot:this.projectRoot};const t=JSON.parse(a.readFileSync(e,"utf8")),n={...t.dependencies,...t.devDependencies};let i={name:"vanilla",type:"vanilla",projectRoot:this.projectRoot,features:{}};if(n.nuxt){const e=n.nuxt,t=this.isVersionGte(e,"3.0.0");i={name:"nuxt",type:"nuxt",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript,hasRouter:!0,projectRoot:this.projectRoot,features:{hasNuxt3:t}}}else if(n.next){const e=n.next,t=this.isVersionGte(e,"13.0.0");i={name:"nextjs",type:"nextjs",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["@types/node"],hasRouter:!0,projectRoot:this.projectRoot,features:{hasNextAppRouter:t}}}else if(n["@remix-run/react"]||n["@remix-run/dev"]){const e=n["@remix-run/react"]||n["@remix-run/dev"];i={name:"remix",type:"remix",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["@types/react"],hasRouter:!0,projectRoot:this.projectRoot,features:{}}}else if(n.react){const e=n.react,t=this.isVersionGte(e,"18.0.0");i={name:"react",type:"react",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["@types/react"],hasRouter:!!n["react-router-dom"]||!!n["react-router"],projectRoot:this.projectRoot,features:{hasReact18:t}}}else if(n.vue){const e=n.vue,t=this.isVersionGte(e,"3.0.0");i={name:"vue",type:"vue",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["@vue/cli-service"],hasRouter:!!n["vue-router"],projectRoot:this.projectRoot,features:{hasVue3:t}}}else if(n["@angular/core"]){const e=n["@angular/core"],t=this.isVersionGte(e,"17.0.0");i={name:"angular",type:"angular",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!0,hasRouter:!0,projectRoot:this.projectRoot,features:{hasAngularStandalone:t}}}else if(n.svelte){const e=n.svelte,t=!!n["@sveltejs/kit"];i={name:"svelte",type:"svelte",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["svelte-check"],hasRouter:!!n["svelte-routing"]||!!n["@sveltejs/kit"],projectRoot:this.projectRoot,features:{hasSvelteKit:t}}}else if(n.astro){const e=n.astro;i={name:"astro",type:"astro",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["@astrojs/ts-plugin"],hasRouter:!0,projectRoot:this.projectRoot,features:{}}}else if(n.gatsby){const e=n.gatsby;i={name:"gatsby",type:"gatsby",version:e,majorVersion:this.getMajorVersion(e),hasTypeScript:!!n.typescript||!!n["@types/react"],hasRouter:!0,projectRoot:this.projectRoot,features:{}}}return n.vite?i.bundler="vite":n.webpack?i.bundler="webpack":n.esbuild?i.bundler="esbuild":n.rollup&&(i.bundler="rollup"),a.existsSync(o.join(this.projectRoot,"yarn.lock"))?i.packageManager="yarn":a.existsSync(o.join(this.projectRoot,"pnpm-lock.yaml"))?i.packageManager="pnpm":i.packageManager="npm",i}async installPackage(){const{execSync:e}=await import("child_process");let t="yarn"===this.framework?.packageManager?"yarn add humanbehavior-js@latest":"pnpm"===this.framework?.packageManager?"pnpm add humanbehavior-js@latest":"npm install humanbehavior-js@latest";"yarn"!==this.framework?.packageManager&&"pnpm"!==this.framework?.packageManager&&(t+=" --legacy-peer-deps");try{e(t,{cwd:this.projectRoot,stdio:"inherit"})}catch(e){throw new Error(`Failed to install humanbehavior-js: ${e}`)}}async generateModifications(){const e=[];switch(this.framework?.type){case"react":e.push(...await this.generateReactModifications());break;case"nextjs":e.push(...await this.generateNextJSModifications());break;case"nuxt":e.push(...await this.generateNuxtModifications());break;case"astro":e.push(...await this.generateAstroModifications());break;case"gatsby":e.push(...await this.generateGatsbyModifications());break;case"remix":e.push(...await this.generateRemixModifications());break;case"vue":e.push(...await this.generateVueModifications());break;case"angular":e.push(...await this.generateAngularModifications());break;case"svelte":e.push(...await this.generateSvelteModifications());break;default:e.push(...await this.generateVanillaModifications())}return e}async generateReactModifications(){const e=[],t=this.findReactAppFile();if(t){const n=a.readFileSync(t,"utf8"),i=this.injectReactProvider(n,t);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehaviorProvider to React app"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateNextJSModifications(){const e=[],t=o.join(this.projectRoot,"src","app","layout.tsx"),n=o.join(this.projectRoot,"src","pages","_app.tsx");if(a.existsSync(t)){e.push({filePath:o.join(this.projectRoot,"src","app","providers.tsx"),action:"create",content:"'use client';\n\nimport { HumanBehaviorProvider } from 'humanbehavior-js/react';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <HumanBehaviorProvider apiKey={process.env.NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY}>\n {children}\n </HumanBehaviorProvider>\n );\n}",description:"Created providers.tsx file for Next.js App Router"});const n=a.readFileSync(t,"utf8"),i=this.injectNextJSAppRouter(n);e.push({filePath:t,action:"modify",content:i,description:"Added Providers wrapper to Next.js App Router layout"})}else if(a.existsSync(n)){e.push({filePath:o.join(this.projectRoot,"src","components","providers.tsx"),action:"create",content:"'use client';\n\nimport { HumanBehaviorProvider } from 'humanbehavior-js/react';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <HumanBehaviorProvider apiKey={process.env.NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY}>\n {children}\n </HumanBehaviorProvider>\n );\n}",description:"Created providers.tsx file for Pages Router"});const t=a.readFileSync(n,"utf8"),i=this.injectNextJSPagesRouter(t);e.push({filePath:n,action:"modify",content:i,description:"Added Providers wrapper to Next.js Pages Router"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateAstroModifications(){const e=[],t=o.join(this.projectRoot,"src","components","HumanBehavior.astro");e.push({filePath:t,action:"create",content:"---\n// This component will only run on the client side\n---\n\n<script>\n import { HumanBehaviorTracker } from 'humanbehavior-js';\n \n // Get API key from environment variable\n const apiKey = import.meta.env.PUBLIC_HUMANBEHAVIOR_API_KEY;\n \n console.log('HumanBehavior: API key found:', apiKey ? 'Yes' : 'No');\n \n if (apiKey) {\n try {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior: Tracker initialized successfully');\n \n // Test event to verify tracking is working\n setTimeout(() => {\n tracker.customEvent('astro_page_view', {\n page: window.location.pathname,\n framework: 'astro'\n }).then(() => {\n console.log('HumanBehavior: Test event sent successfully');\n }).catch((error) => {\n console.error('HumanBehavior: Failed to send test event:', error);\n });\n }, 1000);\n \n } catch (error) {\n console.error('HumanBehavior: Failed to initialize tracker:', error);\n }\n } else {\n console.error('HumanBehavior: No API key found');\n }\n<\/script>",description:"Created Astro component for HumanBehavior SDK"});const n=[o.join(this.projectRoot,"src","layouts","Layout.astro"),o.join(this.projectRoot,"src","layouts","layout.astro"),o.join(this.projectRoot,"src","layouts","BaseLayout.astro")];let i=null;for(const e of n)if(a.existsSync(e)){i=e;break}if(i){const t=a.readFileSync(i,"utf8"),n=this.injectAstroLayout(t);e.push({filePath:i,action:"modify",content:n,description:"Added HumanBehavior component to Astro layout"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateNuxtModifications(){const e=[],t=o.join(this.projectRoot,"app","plugins","humanbehavior.client.ts");e.push({filePath:t,action:"create",content:"import { HumanBehaviorTracker } from 'humanbehavior-js';\n\nexport default defineNuxtPlugin(() => {\n const config = useRuntimeConfig();\n \n // Initialize HumanBehavior SDK (client-side only)\n if (typeof window !== 'undefined') {\n const apiKey = config.public.humanBehaviorApiKey;\n console.log('HumanBehavior: API key:', apiKey ? 'present' : 'missing');\n \n if (apiKey) {\n try {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior: Tracker initialized successfully');\n } catch (error) {\n console.error('HumanBehavior: Failed to initialize tracker:', error);\n }\n } else {\n console.error('HumanBehavior: No API key found in runtime config');\n }\n }\n});",description:"Created Nuxt plugin for HumanBehavior SDK in app directory"});const n=o.join(this.projectRoot,"nuxt.config.ts");if(a.existsSync(n)){const t=a.readFileSync(n,"utf8"),i=this.injectNuxtConfig(t);e.push({filePath:n,action:"modify",content:i,description:"Added HumanBehavior runtime config to Nuxt config"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateRemixModifications(){const e=[],t=o.join(this.projectRoot,"app","root.tsx");if(a.existsSync(t)){const n=a.readFileSync(t,"utf8"),i=this.injectRemixProvider(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehaviorProvider to Remix root component"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateVueModifications(){const e=[],t=this.findVueMainFile();if(t){const n=a.readFileSync(t,"utf8"),i=this.injectVuePlugin(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehaviorPlugin to Vue app"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateAngularModifications(){const e=[],t=o.join(this.projectRoot,"src","app","app.module.ts"),n=o.join(this.projectRoot,"src","app","app.ts"),i=o.join(this.projectRoot,"src","main.ts");if(a.existsSync(n)&&!a.existsSync(t)){if(a.existsSync(i)){const t=a.readFileSync(i,"utf8"),n=this.injectAngularStandaloneInit(t);e.push({filePath:i,action:"modify",content:n,description:"Added HumanBehavior initialization to Angular main.ts"})}}else if(a.existsSync(t)){const n=a.readFileSync(t,"utf8"),i=this.injectAngularModule(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehaviorModule to Angular app"})}const r=o.join(this.projectRoot,"src","environments","environment.ts"),s=o.join(this.projectRoot,"src","environments","environment.prod.ts"),c=o.dirname(r);if(a.existsSync(c)||a.mkdirSync(c,{recursive:!0}),a.existsSync(r)){const t=a.readFileSync(r,"utf8");if(!t.includes("humanBehaviorApiKey")){const n=t.replace(/export const environment = {([\s\S]*?)};/,`export const environment = {\n $1,\n humanBehaviorApiKey: '${this.apiKey}'\n};`);e.push({filePath:r,action:"modify",content:n,description:"Added API key to Angular development environment"})}}else e.push({filePath:r,action:"create",content:`export const environment = {\n production: false,\n humanBehaviorApiKey: '${this.apiKey}'\n};`,description:"Created Angular development environment file"});if(a.existsSync(s)){const t=a.readFileSync(s,"utf8");if(!t.includes("humanBehaviorApiKey")){const n=t.replace(/export const environment = {([\s\S]*?)};/,`export const environment = {\n $1,\n humanBehaviorApiKey: '${this.apiKey}'\n};`);e.push({filePath:s,action:"modify",content:n,description:"Added API key to Angular production environment"})}}else e.push({filePath:s,action:"create",content:`export const environment = {\n production: true,\n humanBehaviorApiKey: '${this.apiKey}'\n};`,description:"Created Angular production environment file"});return e}async generateSvelteModifications(){const e=[],t=o.join(this.projectRoot,"svelte.config.js");if(a.existsSync(t)){const t=o.join(this.projectRoot,"src","routes","+layout.svelte");if(a.existsSync(t)){const n=a.readFileSync(t,"utf8"),i=this.injectSvelteKitLayout(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehavior store to SvelteKit layout"})}}else{const t=this.findSvelteMainFile();if(t){const n=a.readFileSync(t,"utf8"),i=this.injectSvelteStore(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehavior store to Svelte app"})}}return e.push(this.createEnvironmentModification(this.framework)),e}async generateVanillaModifications(){const e=[],t=this.findHTMLFile();if(t){const n=a.readFileSync(t,"utf8"),i=this.injectVanillaScript(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehavior CDN script to HTML file"})}return e.push(this.createEnvironmentModification(this.framework)),e}async generateGatsbyModifications(){const e=[],t=o.join(this.projectRoot,"gatsby-browser.js");if(a.existsSync(t)){const n=a.readFileSync(t,"utf8"),i=this.injectGatsbyBrowser(n);e.push({filePath:t,action:"modify",content:i,description:"Added HumanBehavior initialization to Gatsby browser"})}else e.push({filePath:t,action:"create",content:"import { HumanBehaviorTracker } from 'humanbehavior-js';\n\nexport const onClientEntry = () => {\n console.log('Gatsby browser entry point loaded');\n const apiKey = process.env.GATSBY_HUMANBEHAVIOR_API_KEY;\n console.log('API Key found:', apiKey ? 'Yes' : 'No');\n if (apiKey) {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior SDK initialized for Gatsby');\n } else {\n console.log('No API key found in environment variables');\n }\n};",description:"Created gatsby-browser.js with HumanBehavior initialization"});return e.push(this.createEnvironmentModification(this.framework)),e}async applyModifications(e){for(const t of e)try{const e=o.dirname(t.filePath);switch(a.existsSync(e)||a.mkdirSync(e,{recursive:!0}),t.action){case"create":case"modify":a.writeFileSync(t.filePath,t.content);break;case"append":a.appendFileSync(t.filePath,"\n"+t.content)}}catch(e){throw new Error(`Failed to apply modification to ${t.filePath}: ${e}`)}}generateNextSteps(){const e=["✅ SDK installed and configured automatically!","🚀 Your app is now tracking user behavior","📊 View sessions in your HumanBehavior dashboard","🔧 Customize tracking in your code as needed"];return"react"!==this.framework?.type&&"nextjs"!==this.framework?.type||e.push("💡 Use the useHumanBehavior() hook to track custom events"),e}findReactAppFile(){const e=["src/App.jsx","src/App.js","src/App.tsx","src/App.ts","src/index.js","src/index.tsx","src/main.js","src/main.tsx"];for(const t of e){const e=o.join(this.projectRoot,t);if(a.existsSync(e))return e}return null}findVueMainFile(){const e=["src/main.js","src/main.ts","src/main.jsx","src/main.tsx"];for(const t of e){const e=o.join(this.projectRoot,t);if(a.existsSync(e))return e}return null}findSvelteMainFile(){const e=["src/main.js","src/main.ts","src/main.svelte"];for(const t of e){const e=o.join(this.projectRoot,t);if(a.existsSync(e))return e}return null}findHTMLFile(){const e=["index.html","public/index.html","dist/index.html"];for(const t of e){const e=o.join(this.projectRoot,t);if(a.existsSync(e))return e}return null}injectReactProvider(e,t){if(t.endsWith(".tsx")||t.endsWith(".ts"),e.includes("HumanBehaviorProvider"))return e;const n="vite"===this.framework?.bundler?"import.meta.env.VITE_HUMANBEHAVIOR_API_KEY!":"process.env.HUMANBEHAVIOR_API_KEY!",i="import { HumanBehaviorProvider } from 'humanbehavior-js/react';",r=this.framework?.features?.hasReact18;if(e.includes("function App()")||e.includes("const App =")){let t=e.replace(/(import.*?from.*?['"]react['"];?)/,`$1\n${i}`);return t.includes(i)||(t=`${i}\n\n${t}`),t=t.replace(/(return\s*\([\s\S]*?\)\s*;)/,`return (\n <HumanBehaviorProvider apiKey={${n}}>\n $1\n </HumanBehaviorProvider>\n );`),t}if(r&&e.includes("createRoot")){let t=e.replace(/(import.*?from.*?['"]react['"];?)/,`$1\n${i}`);return t.includes(i)||(t=`${i}\n\n${t}`),t=t.replace(/(root\.render\s*\([\s\S]*?\)\s*;)/,`root.render(\n <HumanBehaviorProvider apiKey={${n}}>\n $1\n </HumanBehaviorProvider>\n );`),t}return`${i}\n\n${e}`}injectNextJSAppRouter(e){if(e.includes("Providers"))return e;let t=e.replace(/export default function RootLayout/,"import { Providers } from './providers';\n\nexport default function RootLayout");return t=t.replace(/<body([^>]*)>([\s\S]*?)<\/body>/,(e,t,n)=>`<body${t}>\n <Providers>\n ${n.trim()}\n </Providers>\n </body>`),t}injectNextJSPagesRouter(e){if(e.includes("Providers"))return e;return e.replace(/function MyApp/,"import { Providers } from '../components/providers';\n\nfunction MyApp").replace(/return \(([\s\S]*?)\);/,"return (\n <Providers>\n $1\n </Providers>\n );")}injectRemixProvider(e){if(e.includes("HumanBehaviorProvider"))return e;const t="import { HumanBehaviorProvider, createHumanBehaviorLoader } from 'humanbehavior-js/remix';",n='import { useLoaderData } from "@remix-run/react";';let i=e;if(!e.includes("HumanBehaviorProvider")){const e=i.lastIndexOf("import");if(-1!==e){const n=i.indexOf("\n",e);i=-1!==n?i.slice(0,n+1)+t+"\n"+i.slice(n+1):i+"\n"+t}else i=t+"\n"+i}if(!e.includes("useLoaderData")){const e=i.lastIndexOf("import");if(-1!==e){const t=i.indexOf("\n",e);i=-1!==t?i.slice(0,t+1)+n+"\n"+i.slice(t+1):i+"\n"+n}else i=n+"\n"+i}return e.includes("export const loader")||(i=i.replace(/export default function App\(\)/,"export const loader = createHumanBehaviorLoader();\n\nexport default function App()")),i=i.replace(/export default function App\(\) \{[\s\S]*?return \(([\s\S]*?)\);[\s\S]*?\}/,"export default function App() {\n const data = useLoaderData<typeof loader>();\n \n return (\n <HumanBehaviorProvider apiKey={data.ENV.HUMANBEHAVIOR_API_KEY}>\n $1\n </HumanBehaviorProvider>\n );\n}"),i}injectVuePlugin(e){if(e.includes("HumanBehaviorPlugin"))return e;const t="import { HumanBehaviorPlugin } from 'humanbehavior-js/vue';",n=this.framework?.features?.hasVue3;if(n){const n="app.use(HumanBehaviorPlugin, {\n apiKey: import.meta.env.VITE_HUMANBEHAVIOR_API_KEY\n});";let i=e;return e.includes(t)||(i=e.replace(/(import.*?from.*?['"]vue['"];?)/,`$1\n${t}`),i.includes(t)||(i=`${t}\n\n${i}`)),e.includes("createApp")&&(i=i.replace(/(app\.mount\(.*?\))/,`${n}\n\n$1`)),i}{const n="Vue.use(HumanBehaviorPlugin, {\n apiKey: process.env.VUE_APP_HUMANBEHAVIOR_API_KEY\n});";let i=e;return e.includes(t)||(i=e.replace(/(import.*?from.*?['"]vue['"];?)/,`$1\n${t}`),i.includes(t)||(i=`${t}\n\n${i}`)),e.includes("new Vue")&&(i=i.replace(/(new Vue\(.*?\))/,`${n}\n\n$1`)),i}}injectAngularModule(e){if(e.includes("HumanBehaviorModule"))return e;let t=e;return e.includes("environment")||(t=e.replace(/import.*from.*['"]@angular/,"import { environment } from '../environments/environment';\n$&")),t.replace(/imports:\s*\[([\s\S]*?)\]/,"imports: [\n $1,\n HumanBehaviorModule.forRoot({\n apiKey: environment.humanBehaviorApiKey\n })\n ]").replace(/import.*from.*['"]@angular/,"$&\nimport { HumanBehaviorModule } from 'humanbehavior-js/angular';")}injectAngularStandaloneInit(e){if(e.includes("initializeHumanBehavior"))return e;let t=e.replace(/import.*from.*['"]@angular/,"import { initializeHumanBehavior } from 'humanbehavior-js/angular';\nimport { environment } from './environments/environment';\n$&");return t=t.replace(/(bootstrapApplication\([^}]+\}?\)(?:\s*\.catch[^;]+;)?)/,"$1\n\n// Initialize HumanBehavior SDK (client-side only)\nif (typeof window !== 'undefined') {\n const tracker = initializeHumanBehavior(environment.humanBehaviorApiKey);\n}"),t}injectSvelteStore(e){if(e.includes("humanBehaviorStore"))return e;return`import { humanBehaviorStore } from 'humanbehavior-js/svelte';\nhumanBehaviorStore.init(process.env.PUBLIC_HUMANBEHAVIOR_API_KEY || '');\n\n${e}`}injectSvelteKitLayout(e){if(e.includes("humanBehaviorStore"))return e;const t="import { humanBehaviorStore } from 'humanbehavior-js/svelte';",n="import { PUBLIC_HUMANBEHAVIOR_API_KEY } from '$env/static/public';",i="humanBehaviorStore.init(PUBLIC_HUMANBEHAVIOR_API_KEY || '');";return e.includes('<script lang="ts">')?e.replace(/<script lang="ts">/,`<script lang="ts">\n\t${n}\n\t${t}\n\t${i}`):e.includes("<script>")?e.replace(/<script>/,`<script>\n\t${n}\n\t${t}\n\t${i}`):e.includes('<script context="module">')?e.replace(/<script\s+context="module">/,`<script context="module">\n\t${n}\n\t${t}\n\t${i}`):e.replace(/<svelte:head>/,`<script lang="ts">\n\t${n}\n\t${t}\n\t${i}\n<\/script>\n\n<svelte:head>`)}injectVanillaScript(e){if(e.includes("humanbehavior-js"))return e;const t=`<script>\n // Initialize HumanBehavior SDK\n // Note: For vanilla HTML, the API key must be hardcoded since env vars aren't available\n const tracker = HumanBehaviorTracker.init('${this.apiKey}');\n<\/script>`;return e.replace(/<\/head>/,` <script src="https://unpkg.com/humanbehavior-js@latest/dist/index.min.js"><\/script>\n ${t}\n</head>`)}injectAstroLayout(e){if(e.includes("HumanBehavior")||e.includes("humanbehavior-js"))return e;let t=e;if(!e.includes("import HumanBehavior")){const n="import HumanBehavior from '../components/HumanBehavior.astro';",i=e.indexOf("---",3);t=-1!==i?e.slice(0,i)+"\n"+n+"\n"+e.slice(i):"---\n"+n+"\n---\n\n"+e}const n=t.lastIndexOf("</body>");return-1===n?t+"\n\n<HumanBehavior />":t.slice(0,n)+" <HumanBehavior />\n"+t.slice(n)}injectNuxtConfig(e){if(e.includes("humanBehaviorApiKey"))return e;const t=this.framework?.features?.hasNuxt3;return t?e.replace(/export default defineNuxtConfig\(\{/,"export default defineNuxtConfig({\n runtimeConfig: {\n public: {\n humanBehaviorApiKey: process.env.NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY\n }\n },"):e.replace(/export default \{/,"export default {\n env: {\n humanBehaviorApiKey: process.env.HUMANBEHAVIOR_API_KEY\n },")}injectGatsbyLayout(e){if(e.includes("HumanBehavior"))return e;let t=e.replace(/import.*from.*['"]\./,"import HumanBehavior from './HumanBehavior';\n$&");return t=t.replace(/(\s*<\/body>)/,"\n <HumanBehavior apiKey={process.env.GATSBY_HUMANBEHAVIOR_API_KEY || ''} />\n$1"),t}injectGatsbyBrowser(e){if(e.includes("HumanBehaviorTracker"))return e;const t="import { HumanBehaviorTracker } from 'humanbehavior-js';",n="\n// Initialize HumanBehavior SDK\nexport const onClientEntry = () => {\n console.log('Gatsby browser entry point loaded');\n const apiKey = process.env.GATSBY_HUMANBEHAVIOR_API_KEY;\n console.log('API Key found:', apiKey ? 'Yes' : 'No');\n if (apiKey) {\n const tracker = HumanBehaviorTracker.init(apiKey);\n console.log('HumanBehavior SDK initialized for Gatsby');\n } else {\n console.log('No API key found in environment variables');\n }\n};";return e.trim()?`${t}${n}\n\n${e}`:`${t}${n}`}findBestEnvFile(e){const t=[".env.local",".env.development.local",".env.development",".env.local.development",".env",".env.production",".env.staging"],n=(e=>{if("react"===e.type&&"vite"===e.bundler)return"VITE_HUMANBEHAVIOR_API_KEY";return{react:"HUMANBEHAVIOR_API_KEY",nextjs:"NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY",vue:"VITE_HUMANBEHAVIOR_API_KEY",svelte:"PUBLIC_HUMANBEHAVIOR_API_KEY",angular:"HUMANBEHAVIOR_API_KEY",nuxt:"NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY",remix:"HUMANBEHAVIOR_API_KEY",vanilla:"HUMANBEHAVIOR_API_KEY",astro:"PUBLIC_HUMANBEHAVIOR_API_KEY",gatsby:"GATSBY_HUMANBEHAVIOR_API_KEY",node:"HUMANBEHAVIOR_API_KEY",auto:"HUMANBEHAVIOR_API_KEY"}[e.type]||"HUMANBEHAVIOR_API_KEY"})(e);for(const e of t){const t=o.join(this.projectRoot,e);if(a.existsSync(t))return{filePath:t,envVarName:n}}const i={react:".env.local",nextjs:".env.local",vue:".env.local",svelte:".env",angular:".env",nuxt:".env",remix:".env.local",vanilla:".env",astro:".env",gatsby:".env.development",node:".env",auto:".env"}[e.type]||".env";return{filePath:o.join(this.projectRoot,i),envVarName:n}}createEnvironmentModification(e){const{filePath:t,envVarName:n}=this.findBestEnvFile(e),i=this.apiKey.trim();if(a.existsSync(t)){const e=a.readFileSync(t,"utf8");return e.includes(n)?{filePath:t,action:"modify",content:e,description:`API key already exists in ${o.basename(t)}`}:{filePath:t,action:"append",content:`\n${n}=${i}`,description:`Added API key to existing ${o.basename(t)}`}}return{filePath:t,action:"create",content:`${n}=${i}`,description:`Created ${o.basename(t)} with API key`}}}class l{async analyzeCodePatterns(e){return this.analyzeWithHeuristics(e)}async resolveConflicts(e,t){const n=[];for(const t of e)switch(t){case"existing_humanbehavior_code":n.push("update_existing_integration");break;case"existing_provider":n.push("merge_providers");break;case"module_system_conflict":n.push("hybrid_module_support");break;default:n.push("skip_conflict")}return n}async generateOptimizations(e,t){const n=[];switch(e.type){case"react":n.push("Use React.memo for performance optimization"),n.push("Implement error boundaries for better error tracking"),n.push("Consider using React.lazy for code splitting");break;case"vue":n.push("Use Vue 3 Composition API for better performance"),n.push("Implement proper error handling in components"),n.push("Consider using Vue Router for navigation tracking");break;case"angular":n.push("Use Angular standalone components for better tree-shaking"),n.push("Implement proper error handling with ErrorHandler"),n.push("Consider using Angular signals for state management");break;default:n.push("Enable performance tracking"),n.push("Implement error tracking"),n.push("Consider progressive enhancement")}return n}analyzeWithHeuristics(e){const t=e.join(" ").toLowerCase();let n={name:"vanilla",type:"vanilla"},i=.5;t.includes("nuxt")||t.includes("nuxtjs")||t.includes("defineNuxtConfig")||t.includes("nuxt.config")||t.includes("@nuxt/")||t.includes("useNuxtApp")||t.includes("useRuntimeConfig")||t.includes("useSeoMeta")||t.includes("useHead")||t.includes("useLazyFetch")||t.includes("useFetch")||t.includes("useAsyncData")||t.includes("#app")?(n={name:"nuxt",type:"nuxt"},i=.95):t.includes("next")||t.includes("nextjs")||t.includes("next/link")||t.includes("next/image")||t.includes("next/navigation")||t.includes("next/router")||t.includes("getserverSideProps")||t.includes("getstaticProps")||t.includes("getstaticPaths")||t.includes("app/layout")||t.includes("app/page")||t.includes("pages/")?(n={name:"nextjs",type:"nextjs"},i=.95):t.includes("gatsby")||t.includes("gatsby-browser")||t.includes("gatsby-ssr")||t.includes("gatsby-node")||t.includes("gatsby-config")||t.includes("useStaticQuery")||t.includes("graphql")?(n={name:"gatsby",type:"gatsby"},i=.95):t.includes("react")?(n={name:"react",type:"react"},i=.9):t.includes("vue")?(n={name:"vue",type:"vue"},i=.9):t.includes("angular")?(n={name:"angular",type:"angular"},i=.9):t.includes("svelte")&&(n={name:"svelte",type:"svelte"},i=.9);let r="script";"react"===n.type||"nextjs"===n.type||"gatsby"===n.type?r="provider":"vue"===n.type?r="plugin":"angular"===n.type&&(r="module");let a="modern";return(t.includes("require(")||t.includes("var "))&&(a="legacy"),{framework:n,confidence:i,patterns:e,conflicts:[],recommendations:[],integrationStrategy:r,compatibilityMode:a}}}class u{constructor(e){this.config={timeout:1e4,...e}}async analyzeCodePatterns(e){try{const t=await fetch(`${this.config.apiEndpoint}/analyze`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({codeSamples:e}),signal:AbortSignal.timeout(this.config.timeout||1e4)});if(!t.ok)throw new Error(`AI service returned ${t.status}: ${t.statusText}`);return(await t.json()).analysis}catch(t){return console.warn("Remote AI service failed, falling back to heuristic analysis:",t),this.performHeuristicAnalysis(e)}}async resolveConflicts(e,t){try{const n=await fetch(`${this.config.apiEndpoint}/resolve-conflicts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conflicts:e,framework:t}),signal:AbortSignal.timeout(this.config.timeout||1e4)});if(!n.ok)throw new Error(`AI service returned ${n.status}: ${n.statusText}`);return(await n.json()).resolutions||[]}catch(n){return console.warn("Remote AI conflict resolution failed, using heuristic approach:",n),this.resolveConflictsHeuristic(e,t)}}async generateOptimizations(e,t){try{const n=await fetch(`${this.config.apiEndpoint}/optimize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({framework:e,patterns:t}),signal:AbortSignal.timeout(this.config.timeout||1e4)});if(!n.ok)throw new Error(`AI service returned ${n.status}: ${n.statusText}`);return(await n.json()).optimizations||[]}catch(n){return console.warn("Remote AI optimization generation failed, using heuristic approach:",n),this.generateOptimizationsHeuristic(e,t)}}performHeuristicAnalysis(e){const t=e.join(" ").toLowerCase();let n={name:"vanilla",type:"vanilla"},i=.5;t.includes("nuxt")||t.includes("nuxtjs")||t.includes("defineNuxtConfig")||t.includes("nuxt.config")||t.includes("@nuxt/")||t.includes("useNuxtApp")||t.includes("useRuntimeConfig")||t.includes("useSeoMeta")||t.includes("useHead")||t.includes("useLazyFetch")||t.includes("useFetch")||t.includes("useAsyncData")||t.includes("#app")?(n={name:"nuxt",type:"nuxt"},i=.95):t.includes("next")||t.includes("nextjs")||t.includes("next/link")||t.includes("next/image")||t.includes("next/navigation")||t.includes("next/router")||t.includes("getserverSideProps")||t.includes("getstaticProps")||t.includes("getstaticPaths")||t.includes("app/layout")||t.includes("app/page")||t.includes("pages/")?(n={name:"nextjs",type:"nextjs"},i=.95):t.includes("gatsby")||t.includes("gatsby-browser")||t.includes("gatsby-ssr")||t.includes("gatsby-node")||t.includes("gatsby-config")||t.includes("useStaticQuery")||t.includes("graphql")?(n={name:"gatsby",type:"gatsby"},i=.95):t.includes("react")?(n={name:"react",type:"react"},i=.9):t.includes("vue")?(n={name:"vue",type:"vue"},i=.9):t.includes("angular")?(n={name:"angular",type:"angular"},i=.9):t.includes("svelte")?(n={name:"svelte",type:"svelte"},i=.9):t.includes("astro")&&(n={name:"astro",type:"astro"},i=.9);let r="script";"react"===n.type||"nextjs"===n.type||"gatsby"===n.type?r="provider":"vue"===n.type?r="plugin":"angular"===n.type&&(r="module");let a="modern";return(t.includes("require(")||t.includes("var "))&&(a="legacy"),{framework:n,confidence:i,patterns:e,conflicts:[],recommendations:[],integrationStrategy:r,compatibilityMode:a}}resolveConflictsHeuristic(e,t){const n=[];for(const t of e)switch(t){case"existing_humanbehavior_code":n.push("update_existing_integration");break;case"existing_provider":n.push("merge_providers");break;case"module_system_conflict":n.push("hybrid_module_support");break;default:n.push("skip_conflict")}return n}generateOptimizationsHeuristic(e,t){const n=[];switch(e.type){case"react":n.push("Use React.memo for performance optimization"),n.push("Implement error boundaries for better error tracking"),n.push("Consider using React.lazy for code splitting");break;case"vue":n.push("Use Vue 3 Composition API for better performance"),n.push("Implement proper error handling in components"),n.push("Consider using Vue Router for navigation tracking");break;case"angular":n.push("Use Angular standalone components for better tree-shaking"),n.push("Implement proper error handling with ErrorHandler"),n.push("Consider using Angular signals for state management");break;default:n.push("Enable performance tracking"),n.push("Implement error tracking"),n.push("Consider progressive enhancement")}return n}}class p extends c{constructor(e,t=process.cwd(),n){super(e,t),this.selectedFramework=n.toLowerCase(),this.framework=this.createFrameworkInfo(this.selectedFramework)}async install(){try{if("auto"===this.selectedFramework)this.framework=await this.runFullDetection();else{this.framework=this.createFrameworkInfo(this.selectedFramework),this.framework||(this.framework={name:"unknown",type:"vanilla"});const e=await this.runFullDetection();this.framework={...e,name:this.framework.name,type:this.framework.type}}await this.installPackage();const e=await this.generateModifications();await this.applyModifications(e);const t=this.generateManualNextSteps();return{success:!0,framework:this.framework,modifications:e,errors:[],nextSteps:t,selectedFramework:this.selectedFramework,manualMode:!0}}catch(e){return{success:!1,framework:this.framework||{name:"unknown",type:"vanilla"},modifications:[],errors:[e instanceof Error?e.message:"Unknown error"],nextSteps:[],selectedFramework:this.selectedFramework,manualMode:!0}}}async runFullDetection(){if("auto"===this.selectedFramework){const e=new u({apiEndpoint:"https://ik3zxh4790.execute-api.us-east-1.amazonaws.com/prod"}),t=await this.scanProjectFiles(),n=await this.extractCodeSamples(t);return(await e.analyzeCodePatterns(n)).framework}{const e=new c(this.apiKey,this.projectRoot);return await e.detectFramework()}}async scanProjectFiles(){const e=[],t=(n,i=0)=>{if(!(i>3))try{const r=a.readdirSync(n);for(const s of r){const r=o.join(n,s),c=a.statSync(r);c.isDirectory()&&!s.startsWith(".")&&"node_modules"!==s?t(r,i+1):c.isFile()&&this.isRelevantFile(s)&&e.push(r)}}catch(e){}};return t(this.projectRoot),e}isRelevantFile(e){return[".js",".jsx",".ts",".tsx",".vue",".svelte",".html",".json",".config.js",".config.ts",".babelrc",".eslintrc"].some(t=>e.endsWith(t))||["package.json","tsconfig.json","vite.config","webpack.config","next.config","nuxt.config","angular.json","svelte.config"].some(t=>e.includes(t))}async extractCodeSamples(e){const t=[];for(const n of e.slice(0,20))try{const e=a.readFileSync(n,"utf8"),i=o.relative(this.projectRoot,n);t.push(`File: ${i}\n${e.substring(0,1e3)}`)}catch(e){}return t}createFrameworkInfo(e){return{react:{name:"react",type:"react"},nextjs:{name:"nextjs",type:"nextjs"},next:{name:"nextjs",type:"nextjs"},vue:{name:"vue",type:"vue"},nuxt:{name:"nuxt",type:"nuxt"},nuxtjs:{name:"nuxt",type:"nuxt"},angular:{name:"angular",type:"angular"},svelte:{name:"svelte",type:"svelte"},sveltekit:{name:"svelte",type:"svelte"},remix:{name:"remix",type:"remix"},astro:{name:"astro",type:"astro"},gatsby:{name:"gatsby",type:"gatsby"},vanilla:{name:"vanilla",type:"vanilla"},node:{name:"node",type:"node"},auto:{name:"auto-detected",type:"auto"}}[e]||{name:e,type:"vanilla"}}async detectFramework(){return this.framework||{name:"unknown",type:"vanilla"}}generateManualNextSteps(){return["✅ Manual framework installation completed!",`🎯 Selected framework: ${this.framework?.name||"unknown"}`,`🔧 Integration strategy: ${this.getIntegrationStrategy()}`,"🚀 Your app is now ready to track user behavior","📊 View sessions in your HumanBehavior dashboard"]}getIntegrationStrategy(){if(!this.framework?.type)return"script";switch(this.framework.type){case"react":case"nextjs":return"provider";case"vue":return"plugin";case"angular":return"module";default:return"script"}}}class m{constructor(e){this.options=e}async run(){s.intro("🤖 AI-Enhanced HumanBehavior SDK Auto-Installation");try{const e=await this.getApiKey();e||(s.cancel("API key is required"),process.exit(1));const t=this.options.projectPath||process.cwd(),n=await this.chooseFramework();if(n||(s.cancel("Installation cancelled."),process.exit(0)),!this.options.yes){await this.confirmInstallation(t,n)||(s.cancel("Installation cancelled."),process.exit(0))}const i=s.spinner();i.start("🔍 Analyzing your project with AI...");const r=new p(e,t,n),a=await r.install();i.stop("Analysis complete!"),this.displayResults(a,n)}catch(e){s.cancel(`Error: ${e instanceof Error?e.message:"Unknown error"}`),process.exit(1)}}async getApiKey(){if(this.options.apiKey)return this.options.apiKey;return await s.text({message:"Enter your HumanBehavior API key:",placeholder:"hb_...",validate:e=>e?e.startsWith("hb_")?void 0:'API key should start with "hb_"':"API key is required"})}async confirmInstallation(e,t){return await s.confirm({message:`Ready to install HumanBehavior SDK in ${e} for ${t}?`})}async chooseFramework(){return await s.select({message:"Select your framework:",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Angular",value:"angular"},{label:"Svelte",value:"svelte"},{label:"Nuxt.js",value:"nuxt"},{label:"Remix",value:"remix"},{label:"Astro",value:"astro"},{label:"Gatsby",value:"gatsby"},{label:"Vanilla JS/TS",value:"vanilla"}]})}displayResults(e,t){if(e.success){if(s.outro("🎉 Installation completed successfully!"),s.note(`Framework detected: ${e.framework.name} (${e.framework.type})`,"Framework Info"),e.modifications&&e.modifications.length>0){const t=e.modifications.map(e=>`${e.action}: ${e.filePath} - ${e.description}`);s.note(t.join("\n"),"Files Modified")}e.nextSteps&&e.nextSteps.length>0&&s.note(e.nextSteps.join("\n"),"Next Steps"),e.aiAnalysis&&(s.note(`Confidence: ${Math.round(100*e.aiAnalysis.confidence)}%`,"AI Analysis"),e.aiAnalysis.recommendations&&e.aiAnalysis.recommendations.length>0&&s.note(e.aiAnalysis.recommendations.join("\n"),"AI Recommendations"))}else s.cancel("Installation failed"),e.errors&&e.errors.length>0&&s.note(e.errors.join("\n"),"Errors")}}function d(){console.log("\n🤖 HumanBehavior SDK AI Auto-Installation\n\nUsage: npx humanbehavior-js ai-auto-install [api-key] [options]\n\nOptions:\n -h, --help Show this help message\n -y, --yes Skip all prompts and use defaults\n --dry-run Show what would be changed without making changes\n\n -p, --project <path> Specify project directory\n -f, --framework <name> Specify framework manually\n\nExamples:\n npx humanbehavior-js ai-auto-install\n npx humanbehavior-js ai-auto-install hb_your_api_key_here\n npx humanbehavior-js ai-auto-install --project ./my-app --ai\n npx humanbehavior-js ai-auto-install --framework react --yes\n")}new m(function(){const e=process.argv.slice(2),t={};for(let n=0;n<e.length;n++){const i=e[n];switch(i){case"--help":case"-h":d(),process.exit(0);break;case"--yes":case"-y":t.yes=!0;break;case"--dry-run":t.dryRun=!0;break;case"--project":case"-p":t.projectPath=e[++n];break;case"--framework":case"-f":t.framework=e[++n];break;default:t.apiKey||i.startsWith("-")||(t.apiKey=i)}}return t}()).run().catch(e=>{s.cancel(`Unexpected error: ${e.message}`),process.exit(1)});class h{constructor(e){this.options=e}async run(){s.intro("🚀 HumanBehavior SDK Auto-Installation");try{const e=await this.getApiKey();e||(s.cancel("API key is required"),process.exit(1));const t=this.options.projectPath||process.cwd(),n=await this.chooseFramework();if(n||(s.cancel("Installation cancelled."),process.exit(0)),!this.options.yes){await this.confirmInstallation(t,n)||(s.cancel("Installation cancelled."),process.exit(0))}const i=s.spinner();i.start("🔍 Analyzing your project...");const r=new p(e,t,n),a=await r.install();i.stop("Detection complete!"),this.displayResults(a)}catch(e){s.cancel(`Error: ${e instanceof Error?e.message:"Unknown error"}`),process.exit(1)}}async getApiKey(){if(this.options.apiKey)return this.options.apiKey;return await s.text({message:"Enter your HumanBehavior API key:",placeholder:"hb_...",validate:e=>e?e.startsWith("hb_")?void 0:'API key should start with "hb_"':"API key is required"})}async chooseFramework(){return await s.select({message:"Select your framework:",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Angular",value:"angular"},{label:"Svelte",value:"svelte"},{label:"Nuxt.js",value:"nuxt"},{label:"Remix",value:"remix"},{label:"Astro",value:"astro"},{label:"Gatsby",value:"gatsby"},{label:"Vanilla JS/TS",value:"vanilla"}]})}async confirmInstallation(e,t){return await s.confirm({message:`Ready to install HumanBehavior SDK in ${e} for ${t}?`})}displayResults(e){if(e.success){if(s.outro("🎉 Installation completed successfully!"),s.note(`Framework detected: ${e.framework.name} (${e.framework.type})`,"Framework Info"),e.modifications&&e.modifications.length>0){const t=e.modifications.map(e=>`${e.action}: ${e.filePath} - ${e.description}`);s.note(t.join("\n"),"Files Modified")}e.nextSteps&&e.nextSteps.length>0&&s.note(e.nextSteps.join("\n"),"Next Steps")}else s.cancel("Installation failed"),e.errors&&e.errors.length>0&&s.note(e.errors.join("\n"),"Errors")}}function f(){console.log("\n🚀 HumanBehavior SDK Auto-Installation\n\nUsage: npx humanbehavior-js auto-install [api-key] [options]\n\nThis tool automatically detects your framework and integrates the HumanBehavior SDK.\n\nOptions:\n -h, --help Show this help message\n -y, --yes Skip all prompts and use defaults\n --dry-run Show what would be changed without making changes\n -p, --project <path> Specify project directory\n\nExamples:\n npx humanbehavior-js auto-install\n npx humanbehavior-js auto-install hb_your_api_key_here\n npx humanbehavior-js auto-install --project ./my-app --yes\n")}if(("undefined"==typeof document?require("url").pathToFileURL(__filename).href:i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("index.js",document.baseURI).href)===`file://${process.argv[1]}`){new h(function(){const e=process.argv.slice(2),t={};for(let n=0;n<e.length;n++){const i=e[n];switch(i){case"--help":case"-h":f(),process.exit(0);break;case"--yes":case"-y":t.yes=!0;break;case"--dry-run":t.dryRun=!0;break;case"--project":case"-p":t.projectPath=e[++n];break;default:t.apiKey||i.startsWith("-")||(t.apiKey=i)}}return t}()).run().catch(e=>{s.cancel(`Unexpected error: ${e.message}`),process.exit(1)})}exports.AIAutoInstallCLI=m,exports.AIBrowserInstallationWizard=class{constructor(e,t){this.apiKey=e,this.aiService=t||new l}async install(){try{const e=await this.performBrowserAIAnalysis(),t=this.generateAIBrowserModifications(e);return{success:!0,framework:e.framework,modifications:t,errors:[],nextSteps:["✅ AI-optimized browser integration ready!",`🎯 Framework detected: ${e.framework.name}`,`🔧 Integration strategy: ${e.integrationStrategy}`,"📋 Copy the generated code to your project","🚀 Your app will be ready to track user behavior"],aiAnalysis:e,learningData:{patterns:e.patterns,framework:e.framework.name,success:!0}}}catch(e){return{success:!1,framework:{name:"unknown",type:"vanilla"},modifications:[],errors:[e instanceof Error?e.message:"Unknown error"],nextSteps:[],aiAnalysis:{framework:{name:"unknown",type:"vanilla"},confidence:0,patterns:[],conflicts:[],recommendations:[],integrationStrategy:"script",compatibilityMode:"legacy"},learningData:{patterns:[],framework:"unknown",success:!1}}}}async performBrowserAIAnalysis(){this.detectBrowserFramework();const e=[`Browser Environment: ${this.analyzeBrowserPatterns().join(", ")}`];return await this.aiService.analyzeCodePatterns(e)}detectBrowserFramework(){if("undefined"!=typeof window){if(window.React)return{name:"react",type:"react"};if(window.Vue)return{name:"vue",type:"vue"};if(window.angular)return{name:"angular",type:"angular"}}return{name:"vanilla",type:"vanilla"}}analyzeBrowserPatterns(){const e=[];if("undefined"!=typeof window){window.React&&e.push("React global detected"),window.Vue&&e.push("Vue global detected"),window.angular&&e.push("Angular global detected"),document.querySelector("[data-reactroot]")&&e.push("React DOM detected"),document.querySelector("[data-vue]")&&e.push("Vue DOM detected");document.querySelectorAll("script").forEach(t=>{t.src.includes("react")&&e.push("React script detected"),t.src.includes("vue")&&e.push("Vue script detected")})}return e}generateAIBrowserModifications(e){const t=[];if("react"===e.framework.type)t.push({filePath:"App.jsx",action:"create",content:`// AI-Optimized React Integration\nimport { HumanBehaviorProvider } from 'humanbehavior-js/react';\n\nfunction App() {\n return (\n <HumanBehaviorProvider \n apiKey="${this.apiKey}"\n config={{\n // AI-generated optimizations\n enablePerformanceTracking: true,\n enableErrorTracking: true,\n framework: '${e.framework.name}',\n integrationStrategy: '${e.integrationStrategy}'\n }}\n >\n {/* Your app components */}\n </HumanBehaviorProvider>\n );\n}\n\nexport default App;`,description:"AI-optimized React component with HumanBehaviorProvider"});else t.push({filePath:"humanbehavior-init.js",action:"create",content:`// AI-Optimized Vanilla JS Integration\nimport { HumanBehaviorTracker } from 'humanbehavior-js';\n\nconst tracker = HumanBehaviorTracker.init('${this.apiKey}', {\n // AI-generated configuration\n framework: '${e.framework.name}',\n integrationStrategy: '${e.integrationStrategy}',\n compatibilityMode: '${e.compatibilityMode}',\n enablePerformanceTracking: true,\n enableErrorTracking: true\n});`,description:"AI-optimized vanilla JS initialization"});return t}},exports.AIEnhancedInstallationWizard=class extends c{constructor(e,t=process.cwd(),n){super(e,t),this.learningCache=new Map,this.patternDatabase=new Map,this.aiService=n||new l,this.loadLearningData()}async install(){try{const e=await this.performAICodeAnalysis();this.framework=await this.detectFrameworkWithAI(e);const t=await this.generateAIOptimizedModifications(e);await this.applyModificationsWithAI(t,e);const n=this.generateAINextSteps(e);return await this.learnFromInstallation(e,t),{success:!0,framework:this.framework,modifications:t,errors:[],nextSteps:n,aiAnalysis:e,learningData:{patterns:e.patterns,framework:this.framework.name,success:!0}}}catch(e){return{success:!1,framework:this.framework||{name:"unknown",type:"vanilla"},modifications:[],errors:[e instanceof Error?e.message:"Unknown error"],nextSteps:[],aiAnalysis:{framework:{name:"unknown",type:"vanilla"},confidence:0,patterns:[],conflicts:[],recommendations:[],integrationStrategy:"script",compatibilityMode:"legacy"},learningData:{patterns:[],framework:"unknown",success:!1}}}}async performAICodeAnalysis(){const e=await this.scanProjectFiles(),t=await this.extractCodeSamples(e);return await this.aiService.analyzeCodePatterns(t)}async scanProjectFiles(){const e=[],t=(n,i=0)=>{if(!(i>3))try{const r=a.readdirSync(n);for(const s of r){const r=o.join(n,s),c=a.statSync(r);c.isDirectory()&&!s.startsWith(".")&&"node_modules"!==s?t(r,i+1):c.isFile()&&this.isRelevantFile(s)&&e.push(r)}}catch(e){}};return t(this.projectRoot),e}isRelevantFile(e){return[".js",".jsx",".ts",".tsx",".vue",".svelte",".html",".json",".config.js",".config.ts",".babelrc",".eslintrc"].some(t=>e.endsWith(t))||["package.json","tsconfig.json","vite.config","webpack.config","next.config","nuxt.config","angular.json","svelte.config","app/layout","app/page","pages/index","pages/_app","pages/_document"].some(t=>e.includes(t))}async extractCodeSamples(e){const t=[];for(const n of e.slice(0,20))try{const e=a.readFileSync(n,"utf8"),i=o.relative(this.projectRoot,n),r=this.extractCodePatterns(e);r.length>0&&t.push(`File: ${i}\n${r.join("\n")}`)}catch(e){}return t}extractCodePatterns(e){const t=[],n={react:[/import\s+React\s+from\s+['"]react['"]/gi,/from\s+['"]react['"]/gi,/function\s+\w+\s*\(\s*\)\s*{/gi,/const\s+\w+\s*=\s*\(\s*\)\s*=>\s*{/gi],vue:[/import\s+{\s*createApp\s*}\s+from\s+['"]vue['"]/gi,/from\s+['"]vue['"]/gi,/<template>/gi,/<script\s+setup>/gi],angular:[/import\s+{\s*Component\s*}\s+from\s+['"]@angular\/core['"]/gi,/@Component\s*\(\s*{/gi,/from\s+['"]@angular/gi],svelte:[/<script>/gi,/import\s+.*\s+from\s+['"]svelte/gi,/from\s+['"]svelte/gi],nextjs:[/import\s+.*\s+from\s+['"]next/gi,/from\s+['"]next/gi,/export\s+default\s+function\s+Page/gi,/export\s+default\s+function\s+Layout/gi,/export\s+default\s+function\s+Loading/gi,/export\s+default\s+function\s+Error/gi,/export\s+default\s+function\s+Not-found/gi,/useRouter\s+from\s+['"]next\/navigation['"]/gi,/useRouter\s+from\s+['"]next\/router['"]/gi,/Link\s+from\s+['"]next\/link['"]/gi,/Image\s+from\s+['"]next\/image['"]/gi,/getServerSideProps/gi,/getStaticProps/gi,/getStaticPaths/gi,/next\.config/gi,/app\/layout\.tsx/gi,/app\/page\.tsx/gi,/pages\/.*\.tsx/gi,/pages\/.*\.jsx/gi,/pages\/.*\.ts/gi,/pages\/.*\.js/gi],nuxt:[/import\s+.*\s+from\s+['"]nuxt/gi,/from\s+['"]nuxt/gi,/export\s+default\s+defineNuxtConfig/gi,/defineNuxtConfig/gi,/nuxt\.config\.ts/gi,/nuxt\.config\.js/gi,/@nuxt\//gi,/#app/gi,/useNuxtApp/gi,/useRuntimeConfig/gi,/useSeoMeta/gi,/useHead/gi,/useLazyFetch/gi,/useFetch/gi,/useAsyncData/gi,/<NuxtLayout/gi,/<NuxtPage/gi,/NuxtLayout/gi,/NuxtPage/gi,/pages\/.*\.vue/gi,/layouts\/.*\.vue/gi,/components\/.*\.vue/gi,/composables\/.*\.ts/gi,/middleware\/.*\.ts/gi,/server\/.*\.ts/gi,/plugins\/.*\.ts/gi,/public\//gi,/assets\//gi,/content\//gi]};for(const[i,r]of Object.entries(n))for(const n of r){const r=e.match(n);r&&(t.push(...r.slice(0,3)),t.push(`${i.toUpperCase()}: ${r.slice(0,3).join(", ")}`))}const i=e.match(/import\s+.*\s+from\s+['"][^'"]+['"]/gi);i&&t.push(`IMPORTS: ${i.slice(0,5).join(", ")}`);const r=e.match(/export\s+.*/gi);return r&&t.push(`EXPORTS: ${r.slice(0,3).join(", ")}`),t}async detectFrameworkWithAI(e){const t=await super.detectFramework();return e.confidence>.8?{...e.framework,bundler:t.bundler,packageManager:t.packageManager,hasTypeScript:t.hasTypeScript,hasRouter:t.hasRouter,projectRoot:this.projectRoot}:{...t,..."vanilla"!==e.framework.type&&{type:e.framework.type,name:e.framework.name}}}async generateAIOptimizedModifications(e){const t=(await super.generateModifications()).map(t=>this.enhanceModificationWithAI(t,e)),n=this.generateAIOptimizations(e);return t.push(...n),t}enhanceModificationWithAI(e,t){let n=e.content;return"legacy"===t.compatibilityMode&&(n=`// HumanBehavior SDK - Legacy Compatibility Mode\n${n}`),"provider"===t.integrationStrategy&&(n=`// HumanBehavior SDK - Provider Pattern (Future-proof)\n${n}`),t.conflicts.length>0&&(n=`// Conflict Resolution: ${t.conflicts.join(", ")}\n${n}`),{...e,content:n,description:`${e.description} (AI-optimized)`}}generateAIOptimizations(e){return[]}async applyModificationsWithAI(e,t){for(const n of e)try{const e=await this.detectConflicts(n);if(e.length>0){const i=await this.aiService.resolveConflicts(e,t.framework),r=await this.resolveConflicts(n,e,i,t);await this.applyModification(r)}else await this.applyModification(n)}catch(e){throw new Error(`Failed to apply AI-optimized modification to ${n.filePath}: ${e}`)}}async detectConflicts(e){const t=[];if(a.existsSync(e.filePath)){const n=a.readFileSync(e.filePath,"utf8");(n.includes("HumanBehavior")||n.includes("humanbehavior"))&&t.push("existing_humanbehavior_code"),e.content.includes("Provider")&&n.includes("Provider")&&t.push("existing_provider"),e.content.includes("import")&&n.includes("require(")&&t.push("module_system_conflict")}return t}async resolveConflicts(e,t,n,i){let r=e.content;for(let i=0;i<t.length;i++){const a=t[i];switch(n[i]){case"update_existing_integration":r=`// Updated HumanBehavior Integration\n${r}`;break;case"merge_providers":r=r.replace(/<HumanBehaviorProvider/g,'<HumanBehaviorProvider key="updated"');break;case"hybrid_module_support":r=`// Hybrid module system support\n${r}`;break;case"skip_conflict":return{...e,content:"",description:`${e.description} (skipped due to conflict)`};default:r=`// Conflict resolved: ${a}\n${r}`}}return{...e,content:r,description:`${e.description} (conflict-resolved)`}}async applyModification(e){if(!e.content)return;const t=o.dirname(e.filePath);switch(a.existsSync(t)||a.mkdirSync(t,{recursive:!0}),e.action){case"create":case"modify":a.writeFileSync(e.filePath,e.content);break;case"append":a.appendFileSync(e.filePath,"\n"+e.content)}}generateAINextSteps(e){const t=["✅ AI-optimized SDK installation completed!",`🎯 Framework detected: ${e.framework.name} (confidence: ${Math.round(100*e.confidence)}%)`,`🔧 Integration strategy: ${e.integrationStrategy}`,`🔄 Compatibility mode: ${e.compatibilityMode}`,"🚀 Your app is now tracking user behavior with AI-optimized configuration"];return e.recommendations.length>0&&(t.push("💡 AI Recommendations:"),e.recommendations.forEach(e=>t.push(` • ${e}`))),t}async learnFromInstallation(e,t){const n={timestamp:(new Date).toISOString(),framework:e.framework.name,patterns:e.patterns,integrationStrategy:e.integrationStrategy,compatibilityMode:e.compatibilityMode,modifications:t.length,success:!0};this.learningCache.set(`${e.framework.name}_${Date.now()}`,n),this.patternDatabase.has(e.framework.name)||this.patternDatabase.set(e.framework.name,[]),this.patternDatabase.get(e.framework.name).push(n),await this.saveLearningData()}loadLearningData(){}async saveLearningData(){}getAIInsights(e){return this.patternDatabase.get(e)||[]}getLearningStats(){const e={totalInstallations:this.learningCache.size,frameworks:{},patterns:{}};for(const[t,n]of this.patternDatabase.entries())e.frameworks[t]=n.length;return e}},exports.AutoInstallCLI=h,exports.AutoInstallationWizard=c,exports.CentralizedAIService=class{constructor(e){this.cache=new Map,this.config={openaiModel:"gpt-4",maxTokens:2e3,temperature:.3,enableCaching:!0,cacheTTL:3600,...e},this.initializeOpenAI()}initializeOpenAI(){try{const{OpenAI:e}=require("openai");this.openai=new e({apiKey:this.config.openaiApiKey})}catch(e){console.warn("OpenAI not available, falling back to heuristic analysis"),this.openai=null}}async analyzeCodePatterns(e){const t={codeSamples:e,timestamp:(new Date).toISOString()},n=this.generateCacheKey(t);if(this.config.enableCaching){const e=this.cache.get(n);if(e&&this.isCacheValid(e.timestamp))return e.analysis}const i=await this.performAIAnalysis(t);return this.config.enableCaching&&this.cache.set(n,{analysis:i,timestamp:Date.now()}),i}async resolveConflicts(e,t){const n={conflicts:e,framework:t,codeContext:"HumanBehavior SDK integration"};if(!this.openai)return this.resolveConflictsHeuristic(e,t);try{const e=this.buildConflictResolutionPrompt(n),t=await this.openai.chat.completions.create({model:this.config.openaiModel,messages:[{role:"system",content:"You are an expert at resolving code integration conflicts. Provide specific resolution strategies."},{role:"user",content:e}],max_tokens:this.config.maxTokens,temperature:this.config.temperature}),i=t.choices[0]?.message?.content;return i&&"string"==typeof i?this.parseConflictResolutions(i):[]}catch(e){console.warn("AI conflict resolution failed, using heuristic approach:",e instanceof Error?e.message:"Unknown error")}return this.resolveConflictsHeuristic(e,t)}async generateOptimizations(e,t){const n={framework:e,patterns:t,projectContext:"HumanBehavior SDK integration"};if(!this.openai)return this.generateOptimizationsHeuristic(e,t);try{const e=this.buildOptimizationPrompt(n),t=await this.openai.chat.completions.create({model:this.config.openaiModel,messages:[{role:"system",content:"You are an expert at optimizing code integration. Provide specific, actionable recommendations."},{role:"user",content:e}],max_tokens:this.config.maxTokens,temperature:this.config.temperature}),i=t.choices[0]?.message?.content;if(i)return this.parseOptimizations(i)}catch(e){console.warn("AI optimization generation failed, using heuristic approach:",e instanceof Error?e.message:"Unknown error")}return this.generateOptimizationsHeuristic(e,t)}async performAIAnalysis(e){if(!this.openai)return this.performHeuristicAnalysis(e);try{const t=this.buildAnalysisPrompt(e),n=await this.openai.chat.completions.create({model:this.config.openaiModel,messages:[{role:"system",content:"You are an expert at analyzing code patterns and determining optimal integration strategies. Provide detailed analysis in JSON format."},{role:"user",content:t}],max_tokens:this.config.maxTokens,temperature:this.config.temperature,response_format:{type:"json_object"}}),i=n.choices[0]?.message?.content;if(i)return this.parseAnalysisResult(i)}catch(e){console.warn("AI analysis failed, using heuristic approach:",e instanceof Error?e.message:"Unknown error")}return this.performHeuristicAnalysis(e)}buildAnalysisPrompt(e){return`Analyze these code samples to determine the framework and integration strategy:\n\n${e.codeSamples.join("\n\n")}\n\nProvide analysis in JSON format with:\n- framework: { name, type, confidence (0-1) }\n- patterns: array of detected patterns\n- conflicts: array of potential conflicts\n- recommendations: array of integration recommendations\n- integrationStrategy: "provider" | "plugin" | "module" | "script" | "standalone"\n- compatibilityMode: "modern" | "legacy" | "hybrid"\n\nFocus on:\n1. Framework detection beyond package.json\n2. Code patterns and architecture\n3. Integration compatibility\n4. Future-proof strategies\n5. Backward compatibility needs\n\nRespond with valid JSON only.`}buildConflictResolutionPrompt(e){return`Resolve these integration conflicts for ${e.framework.name}:\n\nConflicts: ${e.conflicts.join(", ")}\n\nFramework: ${e.framework.name} (${e.framework.type})\nContext: ${e.codeContext}\n\nProvide specific resolution strategies for each conflict. Options:\n- update_existing_integration: Update existing code\n- merge_providers: Merge multiple providers\n- hybrid_module_support: Support both module systems\n- skip_conflict: Skip the modification\n- custom_resolution: Custom resolution strategy\n\nRespond with a JSON array of resolution strategies.`}buildOptimizationPrompt(e){return`Generate optimizations for ${e.framework.name} integration:\n\nFramework: ${e.framework.name} (${e.framework.type})\nPatterns: ${e.patterns.join(", ")}\nContext: ${e.projectContext}\n\nProvide specific, actionable optimization recommendations for:\n1. Performance improvements\n2. Error handling\n3. Code organization\n4. Future-proofing\n5. Backward compatibility\n\nRespond with a JSON array of optimization recommendations.`}parseAnalysisResult(e){try{const t=JSON.parse(e);return{framework:t.framework||{name:"vanilla",type:"vanilla"},confidence:t.confidence||.5,patterns:t.patterns||[],conflicts:t.conflicts||[],recommendations:t.recommendations||[],integrationStrategy:t.integrationStrategy||"script",compatibilityMode:t.compatibilityMode||"modern"}}catch(e){return console.warn("Failed to parse AI analysis result:",e),this.getDefaultAnalysis()}}parseConflictResolutions(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return console.warn("Failed to parse conflict resolutions:",e),[]}}parseOptimizations(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return console.warn("Failed to parse optimizations:",e),[]}}performHeuristicAnalysis(e){const t=e.codeSamples.join(" ").toLowerCase();let n={name:"vanilla",type:"vanilla"},i=.5;t.includes("react")?(n={name:"react",type:"react"},i=.9):t.includes("vue")?(n={name:"vue",type:"vue"},i=.9):t.includes("angular")?(n={name:"angular",type:"angular"},i=.9):t.includes("svelte")?(n={name:"svelte",type:"svelte"},i=.9):t.includes("next")?(n={name:"nextjs",type:"nextjs"},i=.9):t.includes("nuxt")&&(n={name:"nuxt",type:"nuxt"},i=.9);let r="script";"react"===n.type||"nextjs"===n.type?r="provider":"vue"===n.type?r="plugin":"angular"===n.type&&(r="module");let a="modern";return(t.includes("require(")||t.includes("var "))&&(a="legacy"),{framework:n,confidence:i,patterns:e.codeSamples,conflicts:[],recommendations:[],integrationStrategy:r,compatibilityMode:a}}resolveConflictsHeuristic(e,t){const n=[];for(const t of e)switch(t){case"existing_humanbehavior_code":n.push("update_existing_integration");break;case"existing_provider":n.push("merge_providers");break;case"module_system_conflict":n.push("hybrid_module_support");break;default:n.push("skip_conflict")}return n}generateOptimizationsHeuristic(e,t){const n=[];switch(e.type){case"react":n.push("Use React.memo for performance optimization"),n.push("Implement error boundaries for better error tracking"),n.push("Consider using React.lazy for code splitting");break;case"vue":n.push("Use Vue 3 Composition API for better performance"),n.push("Implement proper error handling in components"),n.push("Consider using Vue Router for navigation tracking");break;case"angular":n.push("Use Angular standalone components for better tree-shaking"),n.push("Implement proper error handling with ErrorHandler"),n.push("Consider using Angular signals for state management");break;default:n.push("Enable performance tracking"),n.push("Implement error tracking"),n.push("Consider progressive enhancement")}return n}generateCacheKey(e){const t=JSON.stringify(e);return Buffer.from(t).toString("base64").substring(0,32)}isCacheValid(e){return Date.now()-e<1e3*(this.config.cacheTTL||3600)}getDefaultAnalysis(){return{framework:{name:"vanilla",type:"vanilla"},confidence:.5,patterns:[],conflicts:[],recommendations:[],integrationStrategy:"script",compatibilityMode:"modern"}}getStats(){return{cacheSize:this.cache.size,config:{model:this.config.openaiModel,maxTokens:this.config.maxTokens,temperature:this.config.temperature,caching:this.config.enableCaching},openaiAvailable:!!this.openai}}clearCache(){this.cache.clear()}},exports.InstallWizard=c,exports.RemoteAIService=u;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|