humanbehavior-js 0.5.45 → 0.5.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,8 @@
1
1
  #!/usr/bin/env node
2
- #!/usr/bin/env node
3
- 'use strict';
4
-
5
- var fs = require('fs');
6
- var path = require('path');
7
- var child_process = require('child_process');
8
- var clack = require('@clack/prompts');
9
-
10
- function _interopNamespaceDefault(e) {
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n.default = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
28
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
29
- var clack__namespace = /*#__PURE__*/_interopNamespaceDefault(clack);
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { execSync } from 'child_process';
5
+ import * as clack from '@clack/prompts';
30
6
 
31
7
  /**
32
8
  * HumanBehavior SDK Auto-Installation Wizard
@@ -99,15 +75,15 @@ class AutoInstallationWizard {
99
75
  * Detect the current framework and project setup
100
76
  */
101
77
  async detectFramework() {
102
- const packageJsonPath = path__namespace.join(this.projectRoot, 'package.json');
103
- if (!fs__namespace.existsSync(packageJsonPath)) {
78
+ const packageJsonPath = path.join(this.projectRoot, 'package.json');
79
+ if (!fs.existsSync(packageJsonPath)) {
104
80
  return {
105
81
  name: 'vanilla',
106
82
  type: 'vanilla',
107
83
  projectRoot: this.projectRoot
108
84
  };
109
85
  }
110
- const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, 'utf8'));
86
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
111
87
  const dependencies = {
112
88
  ...packageJson.dependencies,
113
89
  ...packageJson.devDependencies
@@ -268,10 +244,10 @@ class AutoInstallationWizard {
268
244
  framework.bundler = 'rollup';
269
245
  }
270
246
  // Detect package manager
271
- if (fs__namespace.existsSync(path__namespace.join(this.projectRoot, 'yarn.lock'))) {
247
+ if (fs.existsSync(path.join(this.projectRoot, 'yarn.lock'))) {
272
248
  framework.packageManager = 'yarn';
273
249
  }
274
- else if (fs__namespace.existsSync(path__namespace.join(this.projectRoot, 'pnpm-lock.yaml'))) {
250
+ else if (fs.existsSync(path.join(this.projectRoot, 'pnpm-lock.yaml'))) {
275
251
  framework.packageManager = 'pnpm';
276
252
  }
277
253
  else {
@@ -294,7 +270,7 @@ class AutoInstallationWizard {
294
270
  command += ' --legacy-peer-deps';
295
271
  }
296
272
  try {
297
- child_process.execSync(command, { cwd: this.projectRoot, stdio: 'inherit' });
273
+ execSync(command, { cwd: this.projectRoot, stdio: 'inherit' });
298
274
  }
299
275
  catch (error) {
300
276
  throw new Error(`Failed to install humanbehavior-js: ${error}`);
@@ -346,7 +322,7 @@ class AutoInstallationWizard {
346
322
  // Find main App component or index file
347
323
  const appFile = this.findReactAppFile();
348
324
  if (appFile) {
349
- const content = fs__namespace.readFileSync(appFile, 'utf8');
325
+ const content = fs.readFileSync(appFile, 'utf8');
350
326
  const modifiedContent = this.injectReactProvider(content, appFile);
351
327
  modifications.push({
352
328
  filePath: appFile,
@@ -365,12 +341,12 @@ class AutoInstallationWizard {
365
341
  async generateNextJSModifications() {
366
342
  const modifications = [];
367
343
  // Check for App Router
368
- const appLayoutFile = path__namespace.join(this.projectRoot, 'src', 'app', 'layout.tsx');
369
- const pagesLayoutFile = path__namespace.join(this.projectRoot, 'src', 'pages', '_app.tsx');
370
- if (fs__namespace.existsSync(appLayoutFile)) {
344
+ const appLayoutFile = path.join(this.projectRoot, 'src', 'app', 'layout.tsx');
345
+ const pagesLayoutFile = path.join(this.projectRoot, 'src', 'pages', '_app.tsx');
346
+ if (fs.existsSync(appLayoutFile)) {
371
347
  // Create providers.tsx file for App Router
372
348
  modifications.push({
373
- filePath: path__namespace.join(this.projectRoot, 'src', 'app', 'providers.tsx'),
349
+ filePath: path.join(this.projectRoot, 'src', 'app', 'providers.tsx'),
374
350
  action: 'create',
375
351
  content: `'use client';
376
352
 
@@ -386,7 +362,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
386
362
  description: 'Created providers.tsx file for Next.js App Router'
387
363
  });
388
364
  // Modify layout.tsx to use the provider
389
- const content = fs__namespace.readFileSync(appLayoutFile, 'utf8');
365
+ const content = fs.readFileSync(appLayoutFile, 'utf8');
390
366
  const modifiedContent = this.injectNextJSAppRouter(content);
391
367
  modifications.push({
392
368
  filePath: appLayoutFile,
@@ -395,10 +371,10 @@ export function Providers({ children }: { children: React.ReactNode }) {
395
371
  description: 'Added Providers wrapper to Next.js App Router layout'
396
372
  });
397
373
  }
398
- else if (fs__namespace.existsSync(pagesLayoutFile)) {
374
+ else if (fs.existsSync(pagesLayoutFile)) {
399
375
  // Create providers.tsx file for Pages Router
400
376
  modifications.push({
401
- filePath: path__namespace.join(this.projectRoot, 'src', 'components', 'providers.tsx'),
377
+ filePath: path.join(this.projectRoot, 'src', 'components', 'providers.tsx'),
402
378
  action: 'create',
403
379
  content: `'use client';
404
380
 
@@ -414,7 +390,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
414
390
  description: 'Created providers.tsx file for Pages Router'
415
391
  });
416
392
  // Modify _app.tsx to use the provider
417
- const content = fs__namespace.readFileSync(pagesLayoutFile, 'utf8');
393
+ const content = fs.readFileSync(pagesLayoutFile, 'utf8');
418
394
  const modifiedContent = this.injectNextJSPagesRouter(content);
419
395
  modifications.push({
420
396
  filePath: pagesLayoutFile,
@@ -433,7 +409,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
433
409
  async generateAstroModifications() {
434
410
  const modifications = [];
435
411
  // Create Astro component for HumanBehavior
436
- const astroComponentPath = path__namespace.join(this.projectRoot, 'src', 'components', 'HumanBehavior.astro');
412
+ const astroComponentPath = path.join(this.projectRoot, 'src', 'components', 'HumanBehavior.astro');
437
413
  const astroComponentContent = `---
438
414
  // This component will only run on the client side
439
415
  ---
@@ -453,19 +429,19 @@ export function Providers({ children }: { children: React.ReactNode }) {
453
429
  });
454
430
  // Find and update layout file
455
431
  const layoutFiles = [
456
- path__namespace.join(this.projectRoot, 'src', 'layouts', 'Layout.astro'),
457
- path__namespace.join(this.projectRoot, 'src', 'layouts', 'layout.astro'),
458
- path__namespace.join(this.projectRoot, 'src', 'layouts', 'BaseLayout.astro')
432
+ path.join(this.projectRoot, 'src', 'layouts', 'Layout.astro'),
433
+ path.join(this.projectRoot, 'src', 'layouts', 'layout.astro'),
434
+ path.join(this.projectRoot, 'src', 'layouts', 'BaseLayout.astro')
459
435
  ];
460
436
  let layoutFile = null;
461
437
  for (const file of layoutFiles) {
462
- if (fs__namespace.existsSync(file)) {
438
+ if (fs.existsSync(file)) {
463
439
  layoutFile = file;
464
440
  break;
465
441
  }
466
442
  }
467
443
  if (layoutFile) {
468
- const content = fs__namespace.readFileSync(layoutFile, 'utf8');
444
+ const content = fs.readFileSync(layoutFile, 'utf8');
469
445
  const modifiedContent = this.injectAstroLayout(content);
470
446
  modifications.push({
471
447
  filePath: layoutFile,
@@ -484,7 +460,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
484
460
  async generateNuxtModifications() {
485
461
  const modifications = [];
486
462
  // Create plugin file for Nuxt (in app directory)
487
- const pluginFile = path__namespace.join(this.projectRoot, 'app', 'plugins', 'humanbehavior.client.ts');
463
+ const pluginFile = path.join(this.projectRoot, 'app', 'plugins', 'humanbehavior.client.ts');
488
464
  modifications.push({
489
465
  filePath: pluginFile,
490
466
  action: 'create',
@@ -502,7 +478,7 @@ export default defineNuxtPlugin(() => {
502
478
  description: 'Created Nuxt plugin for HumanBehavior SDK in app directory'
503
479
  });
504
480
  // Create environment configuration
505
- const nuxtConfigFile = path__namespace.join(this.projectRoot, 'nuxt.config.ts');
481
+ const nuxtConfigFile = path.join(this.projectRoot, 'nuxt.config.ts');
506
482
  {
507
483
  const mod = this.applyOrNotify(nuxtConfigFile, (c) => this.injectNuxtConfig(c), 'Added HumanBehavior runtime config to Nuxt config', 'Nuxt: Add inside defineNuxtConfig({ … }):\nruntimeConfig: { public: { humanBehaviorApiKey: process.env.NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY } },');
508
484
  if (mod)
@@ -518,9 +494,9 @@ export default defineNuxtPlugin(() => {
518
494
  async generateRemixModifications() {
519
495
  const modifications = [];
520
496
  // Find root.tsx file
521
- const rootFile = path__namespace.join(this.projectRoot, 'app', 'root.tsx');
522
- if (fs__namespace.existsSync(rootFile)) {
523
- const content = fs__namespace.readFileSync(rootFile, 'utf8');
497
+ const rootFile = path.join(this.projectRoot, 'app', 'root.tsx');
498
+ if (fs.existsSync(rootFile)) {
499
+ const content = fs.readFileSync(rootFile, 'utf8');
524
500
  const modifiedContent = this.injectRemixProvider(content);
525
501
  modifications.push({
526
502
  filePath: rootFile,
@@ -541,8 +517,8 @@ export default defineNuxtPlugin(() => {
541
517
  // Find main.js or main.ts
542
518
  const mainFile = this.findVueMainFile();
543
519
  // Create Vue composable per docs (idempotent)
544
- const composableDir = path__namespace.join(this.projectRoot, 'src', 'composables');
545
- const composablePath = path__namespace.join(composableDir, 'useHumanBehavior.ts');
520
+ const composableDir = path.join(this.projectRoot, 'src', 'composables');
521
+ const composablePath = path.join(composableDir, 'useHumanBehavior.ts');
546
522
  const composableContent = `import { HumanBehaviorTracker } from 'humanbehavior-js'
547
523
 
548
524
  export function useHumanBehavior() {
@@ -558,10 +534,10 @@ export function useHumanBehavior() {
558
534
  }
559
535
  `;
560
536
  try {
561
- if (!fs__namespace.existsSync(composableDir)) {
562
- fs__namespace.mkdirSync(composableDir, { recursive: true });
537
+ if (!fs.existsSync(composableDir)) {
538
+ fs.mkdirSync(composableDir, { recursive: true });
563
539
  }
564
- if (!fs__namespace.existsSync(composablePath)) {
540
+ if (!fs.existsSync(composablePath)) {
565
541
  modifications.push({
566
542
  filePath: composablePath,
567
543
  action: 'create',
@@ -572,7 +548,7 @@ export function useHumanBehavior() {
572
548
  }
573
549
  catch { }
574
550
  if (mainFile) {
575
- const content = fs__namespace.readFileSync(mainFile, 'utf8');
551
+ const content = fs.readFileSync(mainFile, 'utf8');
576
552
  const modifiedContent = this.injectVuePlugin(content);
577
553
  modifications.push({
578
554
  filePath: mainFile,
@@ -591,8 +567,8 @@ export function useHumanBehavior() {
591
567
  async generateAngularModifications() {
592
568
  const modifications = [];
593
569
  // Create Angular service (docs pattern)
594
- const serviceDir = path__namespace.join(this.projectRoot, 'src', 'app', 'services');
595
- const servicePath = path__namespace.join(serviceDir, 'hb.service.ts');
570
+ const serviceDir = path.join(this.projectRoot, 'src', 'app', 'services');
571
+ const servicePath = path.join(serviceDir, 'hb.service.ts');
596
572
  const serviceContent = `import { Injectable, NgZone, Inject, PLATFORM_ID } from '@angular/core';
597
573
  import { isPlatformBrowser } from '@angular/common';
598
574
  import { HumanBehaviorTracker } from 'humanbehavior-js';
@@ -623,10 +599,10 @@ export class HumanBehavior {
623
599
  }
624
600
  }
625
601
  `;
626
- if (!fs__namespace.existsSync(serviceDir)) {
627
- fs__namespace.mkdirSync(serviceDir, { recursive: true });
602
+ if (!fs.existsSync(serviceDir)) {
603
+ fs.mkdirSync(serviceDir, { recursive: true });
628
604
  }
629
- if (!fs__namespace.existsSync(servicePath)) {
605
+ if (!fs.existsSync(servicePath)) {
630
606
  modifications.push({
631
607
  filePath: servicePath,
632
608
  action: 'create',
@@ -635,16 +611,16 @@ export class HumanBehavior {
635
611
  });
636
612
  }
637
613
  // Handle Angular environment files (proper Angular way)
638
- const envFile = path__namespace.join(this.projectRoot, 'src', 'environments', 'environment.ts');
639
- const envProdFile = path__namespace.join(this.projectRoot, 'src', 'environments', 'environment.prod.ts');
614
+ const envFile = path.join(this.projectRoot, 'src', 'environments', 'environment.ts');
615
+ const envProdFile = path.join(this.projectRoot, 'src', 'environments', 'environment.prod.ts');
640
616
  // Create environments directory if it doesn't exist
641
- const envDir = path__namespace.dirname(envFile);
642
- if (!fs__namespace.existsSync(envDir)) {
643
- fs__namespace.mkdirSync(envDir, { recursive: true });
617
+ const envDir = path.dirname(envFile);
618
+ if (!fs.existsSync(envDir)) {
619
+ fs.mkdirSync(envDir, { recursive: true });
644
620
  }
645
621
  // Create or update development environment
646
- if (fs__namespace.existsSync(envFile)) {
647
- const content = fs__namespace.readFileSync(envFile, 'utf8');
622
+ if (fs.existsSync(envFile)) {
623
+ const content = fs.readFileSync(envFile, 'utf8');
648
624
  if (!content.includes('humanBehaviorApiKey')) {
649
625
  const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
650
626
  $1,
@@ -671,8 +647,8 @@ export class HumanBehavior {
671
647
  });
672
648
  }
673
649
  // Create or update production environment
674
- if (fs__namespace.existsSync(envProdFile)) {
675
- const content = fs__namespace.readFileSync(envProdFile, 'utf8');
650
+ if (fs.existsSync(envProdFile)) {
651
+ const content = fs.readFileSync(envProdFile, 'utf8');
676
652
  if (!content.includes('humanBehaviorApiKey')) {
677
653
  const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
678
654
  $1,
@@ -701,9 +677,9 @@ export class HumanBehavior {
701
677
  // For Angular, we don't need .env files since we use environment.ts
702
678
  // The environment files are already created above
703
679
  // Inject service into app component
704
- const appComponentPath = path__namespace.join(this.projectRoot, 'src', 'app', 'app.ts');
705
- if (fs__namespace.existsSync(appComponentPath)) {
706
- const appContent = fs__namespace.readFileSync(appComponentPath, 'utf8');
680
+ const appComponentPath = path.join(this.projectRoot, 'src', 'app', 'app.ts');
681
+ if (fs.existsSync(appComponentPath)) {
682
+ const appContent = fs.readFileSync(appComponentPath, 'utf8');
707
683
  // Check if already has HumanBehavior service
708
684
  if (!appContent.includes('HumanBehavior')) {
709
685
  let modifiedAppContent = appContent
@@ -728,13 +704,13 @@ import { HumanBehavior } from './services/hb.service';`)
728
704
  async generateSvelteModifications() {
729
705
  const modifications = [];
730
706
  // Check for SvelteKit
731
- const svelteConfigFile = path__namespace.join(this.projectRoot, 'svelte.config.js');
732
- const isSvelteKit = fs__namespace.existsSync(svelteConfigFile);
707
+ const svelteConfigFile = path.join(this.projectRoot, 'svelte.config.js');
708
+ const isSvelteKit = fs.existsSync(svelteConfigFile);
733
709
  if (isSvelteKit) {
734
710
  // SvelteKit - create layout file
735
- const layoutFile = path__namespace.join(this.projectRoot, 'src', 'routes', '+layout.svelte');
736
- if (fs__namespace.existsSync(layoutFile)) {
737
- const content = fs__namespace.readFileSync(layoutFile, 'utf8');
711
+ const layoutFile = path.join(this.projectRoot, 'src', 'routes', '+layout.svelte');
712
+ if (fs.existsSync(layoutFile)) {
713
+ const content = fs.readFileSync(layoutFile, 'utf8');
738
714
  const modifiedContent = this.injectSvelteKitLayout(content);
739
715
  modifications.push({
740
716
  filePath: layoutFile,
@@ -748,7 +724,7 @@ import { HumanBehavior } from './services/hb.service';`)
748
724
  // Regular Svelte - modify main file
749
725
  const mainFile = this.findSvelteMainFile();
750
726
  if (mainFile) {
751
- const content = fs__namespace.readFileSync(mainFile, 'utf8');
727
+ const content = fs.readFileSync(mainFile, 'utf8');
752
728
  const modifiedContent = this.injectSvelteStore(content);
753
729
  modifications.push({
754
730
  filePath: mainFile,
@@ -770,7 +746,7 @@ import { HumanBehavior } from './services/hb.service';`)
770
746
  // Find HTML file to inject script
771
747
  const htmlFile = this.findHTMLFile();
772
748
  if (htmlFile) {
773
- const content = fs__namespace.readFileSync(htmlFile, 'utf8');
749
+ const content = fs.readFileSync(htmlFile, 'utf8');
774
750
  const modifiedContent = this.injectVanillaScript(content);
775
751
  modifications.push({
776
752
  filePath: htmlFile,
@@ -789,9 +765,9 @@ import { HumanBehavior } from './services/hb.service';`)
789
765
  async generateGatsbyModifications() {
790
766
  const modifications = [];
791
767
  // Modify or create gatsby-browser.js for Gatsby
792
- const gatsbyBrowserFile = path__namespace.join(this.projectRoot, 'gatsby-browser.js');
793
- if (fs__namespace.existsSync(gatsbyBrowserFile)) {
794
- const content = fs__namespace.readFileSync(gatsbyBrowserFile, 'utf8');
768
+ const gatsbyBrowserFile = path.join(this.projectRoot, 'gatsby-browser.js');
769
+ if (fs.existsSync(gatsbyBrowserFile)) {
770
+ const content = fs.readFileSync(gatsbyBrowserFile, 'utf8');
795
771
  const modifiedContent = this.injectGatsbyBrowser(content);
796
772
  modifications.push({
797
773
  filePath: gatsbyBrowserFile,
@@ -826,19 +802,19 @@ export const onClientEntry = () => {
826
802
  async applyModifications(modifications) {
827
803
  for (const modification of modifications) {
828
804
  try {
829
- const dir = path__namespace.dirname(modification.filePath);
830
- if (!fs__namespace.existsSync(dir)) {
831
- fs__namespace.mkdirSync(dir, { recursive: true });
805
+ const dir = path.dirname(modification.filePath);
806
+ if (!fs.existsSync(dir)) {
807
+ fs.mkdirSync(dir, { recursive: true });
832
808
  }
833
809
  switch (modification.action) {
834
810
  case 'create':
835
- fs__namespace.writeFileSync(modification.filePath, modification.content);
811
+ fs.writeFileSync(modification.filePath, modification.content);
836
812
  break;
837
813
  case 'modify':
838
- fs__namespace.writeFileSync(modification.filePath, modification.content);
814
+ fs.writeFileSync(modification.filePath, modification.content);
839
815
  break;
840
816
  case 'append':
841
- fs__namespace.appendFileSync(modification.filePath, '\n' + modification.content);
817
+ fs.appendFileSync(modification.filePath, '\n' + modification.content);
842
818
  break;
843
819
  }
844
820
  }
@@ -870,11 +846,11 @@ export const onClientEntry = () => {
870
846
  * Helper: apply a file transform or record a manual instruction if unchanged/missing
871
847
  */
872
848
  applyOrNotify(filePath, transform, description, manualNote) {
873
- if (!fs__namespace.existsSync(filePath)) {
874
- this.manualNotes.push(`${manualNote} (file missing: ${path__namespace.relative(this.projectRoot, filePath)})`);
849
+ if (!fs.existsSync(filePath)) {
850
+ this.manualNotes.push(`${manualNote} (file missing: ${path.relative(this.projectRoot, filePath)})`);
875
851
  return null;
876
852
  }
877
- const original = fs__namespace.readFileSync(filePath, 'utf8');
853
+ const original = fs.readFileSync(filePath, 'utf8');
878
854
  const updated = transform(original);
879
855
  if (updated !== original) {
880
856
  return {
@@ -894,8 +870,8 @@ export const onClientEntry = () => {
894
870
  'src/index.js', 'src/index.tsx', 'src/main.js', 'src/main.tsx'
895
871
  ];
896
872
  for (const file of possibleFiles) {
897
- const fullPath = path__namespace.join(this.projectRoot, file);
898
- if (fs__namespace.existsSync(fullPath)) {
873
+ const fullPath = path.join(this.projectRoot, file);
874
+ if (fs.existsSync(fullPath)) {
899
875
  return fullPath;
900
876
  }
901
877
  }
@@ -906,8 +882,8 @@ export const onClientEntry = () => {
906
882
  'src/main.js', 'src/main.ts', 'src/main.jsx', 'src/main.tsx'
907
883
  ];
908
884
  for (const file of possibleFiles) {
909
- const fullPath = path__namespace.join(this.projectRoot, file);
910
- if (fs__namespace.existsSync(fullPath)) {
885
+ const fullPath = path.join(this.projectRoot, file);
886
+ if (fs.existsSync(fullPath)) {
911
887
  return fullPath;
912
888
  }
913
889
  }
@@ -918,8 +894,8 @@ export const onClientEntry = () => {
918
894
  'src/main.js', 'src/main.ts', 'src/main.svelte'
919
895
  ];
920
896
  for (const file of possibleFiles) {
921
- const fullPath = path__namespace.join(this.projectRoot, file);
922
- if (fs__namespace.existsSync(fullPath)) {
897
+ const fullPath = path.join(this.projectRoot, file);
898
+ if (fs.existsSync(fullPath)) {
923
899
  return fullPath;
924
900
  }
925
901
  }
@@ -928,8 +904,8 @@ export const onClientEntry = () => {
928
904
  findHTMLFile() {
929
905
  const possibleFiles = ['index.html', 'public/index.html', 'dist/index.html'];
930
906
  for (const file of possibleFiles) {
931
- const fullPath = path__namespace.join(this.projectRoot, file);
932
- if (fs__namespace.existsSync(fullPath)) {
907
+ const fullPath = path.join(this.projectRoot, file);
908
+ if (fs.existsSync(fullPath)) {
933
909
  return fullPath;
934
910
  }
935
911
  }
@@ -1318,8 +1294,8 @@ if (typeof window !== 'undefined') {
1318
1294
  const envVarName = getEnvVarName(framework);
1319
1295
  // Check for existing files
1320
1296
  for (const envFile of possibleEnvFiles) {
1321
- const fullPath = path__namespace.join(this.projectRoot, envFile);
1322
- if (fs__namespace.existsSync(fullPath)) {
1297
+ const fullPath = path.join(this.projectRoot, envFile);
1298
+ if (fs.existsSync(fullPath)) {
1323
1299
  return { filePath: fullPath, envVarName };
1324
1300
  }
1325
1301
  }
@@ -1340,7 +1316,7 @@ if (typeof window !== 'undefined') {
1340
1316
  };
1341
1317
  const defaultFile = defaultFiles[framework.type] || '.env';
1342
1318
  return {
1343
- filePath: path__namespace.join(this.projectRoot, defaultFile),
1319
+ filePath: path.join(this.projectRoot, defaultFile),
1344
1320
  envVarName
1345
1321
  };
1346
1322
  }
@@ -1351,16 +1327,16 @@ if (typeof window !== 'undefined') {
1351
1327
  const { filePath, envVarName } = this.findBestEnvFile(framework);
1352
1328
  // Clean the API key to prevent formatting issues
1353
1329
  const cleanApiKey = this.apiKey.trim();
1354
- if (fs__namespace.existsSync(filePath)) {
1330
+ if (fs.existsSync(filePath)) {
1355
1331
  // Check if the variable already exists
1356
- const content = fs__namespace.readFileSync(filePath, 'utf8');
1332
+ const content = fs.readFileSync(filePath, 'utf8');
1357
1333
  if (content.includes(envVarName)) {
1358
1334
  // Variable exists, don't modify
1359
1335
  return {
1360
1336
  filePath,
1361
1337
  action: 'modify',
1362
1338
  content: content, // No change
1363
- description: `API key already exists in ${path__namespace.basename(filePath)}`
1339
+ description: `API key already exists in ${path.basename(filePath)}`
1364
1340
  };
1365
1341
  }
1366
1342
  else {
@@ -1369,7 +1345,7 @@ if (typeof window !== 'undefined') {
1369
1345
  filePath,
1370
1346
  action: 'append',
1371
1347
  content: `\n${envVarName}=${cleanApiKey}`,
1372
- description: `Added API key to existing ${path__namespace.basename(filePath)}`
1348
+ description: `Added API key to existing ${path.basename(filePath)}`
1373
1349
  };
1374
1350
  }
1375
1351
  }
@@ -1379,7 +1355,7 @@ if (typeof window !== 'undefined') {
1379
1355
  filePath,
1380
1356
  action: 'create',
1381
1357
  content: `${envVarName}=${cleanApiKey}`,
1382
- description: `Created ${path__namespace.basename(filePath)} with API key`
1358
+ description: `Created ${path.basename(filePath)} with API key`
1383
1359
  };
1384
1360
  }
1385
1361
  }
@@ -1398,12 +1374,12 @@ class AutoInstallCLI {
1398
1374
  this.options = options;
1399
1375
  }
1400
1376
  async run() {
1401
- clack__namespace.intro('🚀 HumanBehavior SDK Auto-Installation');
1377
+ clack.intro('🚀 HumanBehavior SDK Auto-Installation');
1402
1378
  try {
1403
1379
  // Get API key
1404
1380
  const apiKey = await this.getApiKey();
1405
1381
  if (!apiKey) {
1406
- clack__namespace.cancel('API key is required');
1382
+ clack.cancel('API key is required');
1407
1383
  process.exit(1);
1408
1384
  }
1409
1385
  // Get project path
@@ -1412,12 +1388,12 @@ class AutoInstallCLI {
1412
1388
  if (!this.options.yes) {
1413
1389
  const confirmed = await this.confirmInstallation(projectPath);
1414
1390
  if (!confirmed) {
1415
- clack__namespace.cancel('Installation cancelled.');
1391
+ clack.cancel('Installation cancelled.');
1416
1392
  process.exit(0);
1417
1393
  }
1418
1394
  }
1419
1395
  // Run installation
1420
- const spinner = clack__namespace.spinner();
1396
+ const spinner = clack.spinner();
1421
1397
  spinner.start('🔍 Detecting framework and applying integration...');
1422
1398
  const wizard = new AutoInstallationWizard(apiKey, projectPath);
1423
1399
  const result = await wizard.install();
@@ -1426,7 +1402,7 @@ class AutoInstallCLI {
1426
1402
  this.displayResults(result);
1427
1403
  }
1428
1404
  catch (error) {
1429
- clack__namespace.cancel(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
1405
+ clack.cancel(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
1430
1406
  process.exit(1);
1431
1407
  }
1432
1408
  }
@@ -1434,7 +1410,7 @@ class AutoInstallCLI {
1434
1410
  if (this.options.apiKey) {
1435
1411
  return this.options.apiKey;
1436
1412
  }
1437
- const apiKey = await clack__namespace.text({
1413
+ const apiKey = await clack.text({
1438
1414
  message: 'Enter your HumanBehavior API key:',
1439
1415
  placeholder: 'hb_...',
1440
1416
  validate: (value) => {
@@ -1449,30 +1425,30 @@ class AutoInstallCLI {
1449
1425
  }
1450
1426
  // Framework selection no longer needed; AutoInstallationWizard auto-detects
1451
1427
  async confirmInstallation(projectPath) {
1452
- const confirmed = await clack__namespace.confirm({
1428
+ const confirmed = await clack.confirm({
1453
1429
  message: `Ready to install HumanBehavior SDK in ${projectPath}?`
1454
1430
  });
1455
1431
  return confirmed;
1456
1432
  }
1457
1433
  displayResults(result) {
1458
1434
  if (result.success) {
1459
- clack__namespace.outro('🎉 Installation completed successfully!');
1435
+ clack.outro('🎉 Installation completed successfully!');
1460
1436
  // Display framework info
1461
- clack__namespace.note(`Framework detected: ${result.framework.name} (${result.framework.type})`, 'Framework Info');
1437
+ clack.note(`Framework detected: ${result.framework.name} (${result.framework.type})`, 'Framework Info');
1462
1438
  // Display modifications
1463
1439
  if (result.modifications && result.modifications.length > 0) {
1464
1440
  const modifications = result.modifications.map((mod) => `${mod.action}: ${mod.filePath} - ${mod.description}`);
1465
- clack__namespace.note(modifications.join('\n'), 'Files Modified');
1441
+ clack.note(modifications.join('\n'), 'Files Modified');
1466
1442
  }
1467
1443
  // Display next steps
1468
1444
  if (result.nextSteps && result.nextSteps.length > 0) {
1469
- clack__namespace.note(result.nextSteps.join('\n'), 'Next Steps');
1445
+ clack.note(result.nextSteps.join('\n'), 'Next Steps');
1470
1446
  }
1471
1447
  }
1472
1448
  else {
1473
- clack__namespace.cancel('Installation failed');
1449
+ clack.cancel('Installation failed');
1474
1450
  if (result.errors && result.errors.length > 0) {
1475
- clack__namespace.note(result.errors.join('\n'), 'Errors');
1451
+ clack.note(result.errors.join('\n'), 'Errors');
1476
1452
  }
1477
1453
  }
1478
1454
  }
@@ -1534,9 +1510,9 @@ Examples:
1534
1510
  const options = parseArgs();
1535
1511
  const cli = new AutoInstallCLI(options);
1536
1512
  cli.run().catch((error) => {
1537
- clack__namespace.cancel(`Unexpected error: ${error.message}`);
1513
+ clack.cancel(`Unexpected error: ${error.message}`);
1538
1514
  process.exit(1);
1539
1515
  });
1540
1516
 
1541
- exports.AutoInstallCLI = AutoInstallCLI;
1517
+ export { AutoInstallCLI };
1542
1518
  //# sourceMappingURL=auto-install.js.map