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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanbehavior-js",
3
- "version": "0.5.45",
3
+ "version": "0.5.48",
4
4
  "description": "SDK for HumanBehavior session and event recording",
5
5
  "private": false,
6
6
  "packageManager": "npm@10.0.0",
@@ -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
  }
@@ -1684,10 +1660,10 @@ class ManualFrameworkInstallationWizard extends AutoInstallationWizard {
1684
1660
  if (depth > 3)
1685
1661
  return; // Limit depth
1686
1662
  try {
1687
- const items = fs__namespace.readdirSync(dir);
1663
+ const items = fs.readdirSync(dir);
1688
1664
  for (const item of items) {
1689
- const fullPath = path__namespace.join(dir, item);
1690
- const stat = fs__namespace.statSync(fullPath);
1665
+ const fullPath = path.join(dir, item);
1666
+ const stat = fs.statSync(fullPath);
1691
1667
  if (stat.isDirectory() && !item.startsWith('.') && item !== 'node_modules') {
1692
1668
  scanDir(fullPath, depth + 1);
1693
1669
  }
@@ -1725,8 +1701,8 @@ class ManualFrameworkInstallationWizard extends AutoInstallationWizard {
1725
1701
  const samples = [];
1726
1702
  for (const file of files.slice(0, 20)) { // Limit to 20 files
1727
1703
  try {
1728
- const content = fs__namespace.readFileSync(file, 'utf8');
1729
- const relativePath = path__namespace.relative(this.projectRoot, file);
1704
+ const content = fs.readFileSync(file, 'utf8');
1705
+ const relativePath = path.relative(this.projectRoot, file);
1730
1706
  samples.push(`File: ${relativePath}\n${content.substring(0, 1000)}`);
1731
1707
  }
1732
1708
  catch (error) {
@@ -1809,12 +1785,12 @@ class AIAutoInstallCLI {
1809
1785
  this.options = options;
1810
1786
  }
1811
1787
  async run() {
1812
- clack__namespace.intro('🤖 AI-Enhanced HumanBehavior SDK Auto-Installation');
1788
+ clack.intro('🤖 AI-Enhanced HumanBehavior SDK Auto-Installation');
1813
1789
  try {
1814
1790
  // Get API key
1815
1791
  const apiKey = await this.getApiKey();
1816
1792
  if (!apiKey) {
1817
- clack__namespace.cancel('API key is required');
1793
+ clack.cancel('API key is required');
1818
1794
  process.exit(1);
1819
1795
  }
1820
1796
  // Get project path
@@ -1822,19 +1798,19 @@ class AIAutoInstallCLI {
1822
1798
  // Choose framework
1823
1799
  const framework = await this.chooseFramework();
1824
1800
  if (!framework) {
1825
- clack__namespace.cancel('Installation cancelled.');
1801
+ clack.cancel('Installation cancelled.');
1826
1802
  process.exit(0);
1827
1803
  }
1828
1804
  // Confirm installation
1829
1805
  if (!this.options.yes) {
1830
1806
  const confirmed = await this.confirmInstallation(projectPath, framework);
1831
1807
  if (!confirmed) {
1832
- clack__namespace.cancel('Installation cancelled.');
1808
+ clack.cancel('Installation cancelled.');
1833
1809
  process.exit(0);
1834
1810
  }
1835
1811
  }
1836
1812
  // Run installation
1837
- const spinner = clack__namespace.spinner();
1813
+ const spinner = clack.spinner();
1838
1814
  spinner.start('🔍 Analyzing your project with AI...');
1839
1815
  const wizard = new ManualFrameworkInstallationWizard(apiKey, projectPath, framework);
1840
1816
  const result = await wizard.install();
@@ -1843,7 +1819,7 @@ class AIAutoInstallCLI {
1843
1819
  this.displayResults(result, framework);
1844
1820
  }
1845
1821
  catch (error) {
1846
- clack__namespace.cancel(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
1822
+ clack.cancel(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
1847
1823
  process.exit(1);
1848
1824
  }
1849
1825
  }
@@ -1851,7 +1827,7 @@ class AIAutoInstallCLI {
1851
1827
  if (this.options.apiKey) {
1852
1828
  return this.options.apiKey;
1853
1829
  }
1854
- const apiKey = await clack__namespace.text({
1830
+ const apiKey = await clack.text({
1855
1831
  message: 'Enter your HumanBehavior API key:',
1856
1832
  placeholder: 'hb_...',
1857
1833
  validate: (value) => {
@@ -1865,13 +1841,13 @@ class AIAutoInstallCLI {
1865
1841
  return apiKey;
1866
1842
  }
1867
1843
  async confirmInstallation(projectPath, framework) {
1868
- const confirmed = await clack__namespace.confirm({
1844
+ const confirmed = await clack.confirm({
1869
1845
  message: `Ready to install HumanBehavior SDK in ${projectPath} for ${framework}?`
1870
1846
  });
1871
1847
  return confirmed;
1872
1848
  }
1873
1849
  async chooseFramework() {
1874
- const framework = await clack__namespace.select({
1850
+ const framework = await clack.select({
1875
1851
  message: 'Select your framework:',
1876
1852
  options: [
1877
1853
  { label: 'React', value: 'react' },
@@ -1890,30 +1866,30 @@ class AIAutoInstallCLI {
1890
1866
  }
1891
1867
  displayResults(result, framework) {
1892
1868
  if (result.success) {
1893
- clack__namespace.outro('🎉 Installation completed successfully!');
1869
+ clack.outro('🎉 Installation completed successfully!');
1894
1870
  // Display framework info
1895
- clack__namespace.note(`Framework detected: ${result.framework.name} (${result.framework.type})`, 'Framework Info');
1871
+ clack.note(`Framework detected: ${result.framework.name} (${result.framework.type})`, 'Framework Info');
1896
1872
  // Display modifications
1897
1873
  if (result.modifications && result.modifications.length > 0) {
1898
1874
  const modifications = result.modifications.map((mod) => `${mod.action}: ${mod.filePath} - ${mod.description}`);
1899
- clack__namespace.note(modifications.join('\n'), 'Files Modified');
1875
+ clack.note(modifications.join('\n'), 'Files Modified');
1900
1876
  }
1901
1877
  // Display next steps
1902
1878
  if (result.nextSteps && result.nextSteps.length > 0) {
1903
- clack__namespace.note(result.nextSteps.join('\n'), 'Next Steps');
1879
+ clack.note(result.nextSteps.join('\n'), 'Next Steps');
1904
1880
  }
1905
1881
  // Display AI insights if available
1906
1882
  if (result.aiAnalysis) {
1907
- clack__namespace.note(`Confidence: ${Math.round(result.aiAnalysis.confidence * 100)}%`, 'AI Analysis');
1883
+ clack.note(`Confidence: ${Math.round(result.aiAnalysis.confidence * 100)}%`, 'AI Analysis');
1908
1884
  if (result.aiAnalysis.recommendations && result.aiAnalysis.recommendations.length > 0) {
1909
- clack__namespace.note(result.aiAnalysis.recommendations.join('\n'), 'AI Recommendations');
1885
+ clack.note(result.aiAnalysis.recommendations.join('\n'), 'AI Recommendations');
1910
1886
  }
1911
1887
  }
1912
1888
  }
1913
1889
  else {
1914
- clack__namespace.cancel('Installation failed');
1890
+ clack.cancel('Installation failed');
1915
1891
  if (result.errors && result.errors.length > 0) {
1916
- clack__namespace.note(result.errors.join('\n'), 'Errors');
1892
+ clack.note(result.errors.join('\n'), 'Errors');
1917
1893
  }
1918
1894
  }
1919
1895
  }
@@ -1978,9 +1954,9 @@ Examples:
1978
1954
  const options = parseArgs();
1979
1955
  const cli = new AIAutoInstallCLI(options);
1980
1956
  cli.run().catch((error) => {
1981
- clack__namespace.cancel(`Unexpected error: ${error.message}`);
1957
+ clack.cancel(`Unexpected error: ${error.message}`);
1982
1958
  process.exit(1);
1983
1959
  });
1984
1960
 
1985
- exports.AIAutoInstallCLI = AIAutoInstallCLI;
1961
+ export { AIAutoInstallCLI };
1986
1962
  //# sourceMappingURL=ai-auto-install.js.map