humanbehavior-js 0.4.13 → 0.4.15
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/dist/cjs/install-wizard.cjs +396 -25
- package/dist/cjs/install-wizard.cjs.map +1 -1
- package/dist/cjs/wizard/index.cjs +633 -395
- package/dist/cjs/wizard/index.cjs.map +1 -1
- package/dist/cli/ai-auto-install.cjs +57161 -0
- package/dist/cli/ai-auto-install.cjs.map +1 -0
- package/dist/cli/ai-auto-install.js +520 -575
- package/dist/cli/ai-auto-install.js.map +1 -1
- package/dist/cli/auto-install.cjs +56352 -0
- package/dist/cli/auto-install.cjs.map +1 -0
- package/dist/cli/auto-install.js +925 -140
- package/dist/cli/auto-install.js.map +1 -1
- package/dist/esm/install-wizard.js +396 -25
- package/dist/esm/install-wizard.js.map +1 -1
- package/dist/esm/wizard/index.js +631 -394
- package/dist/esm/wizard/index.js.map +1 -1
- package/dist/types/install-wizard.d.ts +31 -1
- package/dist/types/wizard/index.d.ts +44 -10
- package/package.json +3 -1
- package/rollup.config.js +5 -1
- package/src/types/clack.d.ts +31 -0
- package/src/wizard/ai/ai-install-wizard.ts +4 -1
- package/src/wizard/ai/manual-framework-wizard.ts +2 -0
- package/src/wizard/cli/ai-auto-install.ts +122 -248
- package/src/wizard/cli/auto-install.ts +116 -117
- package/src/wizard/core/install-wizard.ts +498 -60
- package/src/wizard/services/centralized-ai-service.ts +1 -1
- package/src/wizard/services/remote-ai-service.ts +18 -2
- package/tsconfig.json +1 -1
|
@@ -6,12 +6,22 @@
|
|
|
6
6
|
*/
|
|
7
7
|
interface FrameworkInfo$2 {
|
|
8
8
|
name: string;
|
|
9
|
-
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'node' | 'auto';
|
|
9
|
+
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node' | 'auto';
|
|
10
10
|
bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
|
|
11
11
|
packageManager?: 'npm' | 'yarn' | 'pnpm';
|
|
12
12
|
hasTypeScript?: boolean;
|
|
13
13
|
hasRouter?: boolean;
|
|
14
14
|
projectRoot?: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
majorVersion?: number;
|
|
17
|
+
features?: {
|
|
18
|
+
hasReact18?: boolean;
|
|
19
|
+
hasVue3?: boolean;
|
|
20
|
+
hasNuxt3?: boolean;
|
|
21
|
+
hasAngularStandalone?: boolean;
|
|
22
|
+
hasNextAppRouter?: boolean;
|
|
23
|
+
hasSvelteKit?: boolean;
|
|
24
|
+
};
|
|
15
25
|
}
|
|
16
26
|
interface CodeModification {
|
|
17
27
|
filePath: string;
|
|
@@ -31,6 +41,12 @@ declare class AutoInstallationWizard {
|
|
|
31
41
|
protected projectRoot: string;
|
|
32
42
|
protected framework: FrameworkInfo$2 | null;
|
|
33
43
|
constructor(apiKey: string, projectRoot?: string);
|
|
44
|
+
/**
|
|
45
|
+
* Simple version comparison utility
|
|
46
|
+
*/
|
|
47
|
+
private compareVersions;
|
|
48
|
+
private isVersionGte;
|
|
49
|
+
private getMajorVersion;
|
|
34
50
|
/**
|
|
35
51
|
* Main installation method - detects framework and auto-installs
|
|
36
52
|
*/
|
|
@@ -55,6 +71,10 @@ declare class AutoInstallationWizard {
|
|
|
55
71
|
* Generate Next.js-specific modifications
|
|
56
72
|
*/
|
|
57
73
|
private generateNextJSModifications;
|
|
74
|
+
/**
|
|
75
|
+
* Generate Astro-specific modifications
|
|
76
|
+
*/
|
|
77
|
+
private generateAstroModifications;
|
|
58
78
|
/**
|
|
59
79
|
* Generate Nuxt-specific modifications
|
|
60
80
|
*/
|
|
@@ -79,6 +99,10 @@ declare class AutoInstallationWizard {
|
|
|
79
99
|
* Generate vanilla JS/TS modifications
|
|
80
100
|
*/
|
|
81
101
|
private generateVanillaModifications;
|
|
102
|
+
/**
|
|
103
|
+
* Generate Gatsby-specific modifications
|
|
104
|
+
*/
|
|
105
|
+
private generateGatsbyModifications;
|
|
82
106
|
/**
|
|
83
107
|
* Apply modifications to the codebase
|
|
84
108
|
*/
|
|
@@ -101,7 +125,13 @@ declare class AutoInstallationWizard {
|
|
|
101
125
|
private injectSvelteStore;
|
|
102
126
|
private injectSvelteKitLayout;
|
|
103
127
|
private injectVanillaScript;
|
|
128
|
+
/**
|
|
129
|
+
* Inject Astro layout with HumanBehavior component
|
|
130
|
+
*/
|
|
131
|
+
private injectAstroLayout;
|
|
104
132
|
private injectNuxtConfig;
|
|
133
|
+
private injectGatsbyLayout;
|
|
134
|
+
private injectGatsbyBrowser;
|
|
105
135
|
/**
|
|
106
136
|
* Helper method to find the best environment file for a framework
|
|
107
137
|
*/
|
|
@@ -269,20 +299,14 @@ interface AICLIOptions {
|
|
|
269
299
|
projectPath?: string;
|
|
270
300
|
yes?: boolean;
|
|
271
301
|
dryRun?: boolean;
|
|
272
|
-
useAI?: boolean;
|
|
273
|
-
browser?: boolean;
|
|
274
302
|
framework?: string;
|
|
275
|
-
manual?: boolean;
|
|
276
303
|
}
|
|
277
304
|
declare class AIAutoInstallCLI {
|
|
278
|
-
private rl;
|
|
279
305
|
private options;
|
|
280
306
|
constructor(options: AICLIOptions);
|
|
281
307
|
run(): Promise<void>;
|
|
282
308
|
private getApiKey;
|
|
283
|
-
private chooseInstallationMode;
|
|
284
309
|
private confirmInstallation;
|
|
285
|
-
private getInstallationModeDisplay;
|
|
286
310
|
private chooseFramework;
|
|
287
311
|
private displayResults;
|
|
288
312
|
}
|
|
@@ -302,11 +326,11 @@ interface CLIOptions {
|
|
|
302
326
|
dryRun?: boolean;
|
|
303
327
|
}
|
|
304
328
|
declare class AutoInstallCLI {
|
|
305
|
-
private rl;
|
|
306
329
|
private options;
|
|
307
330
|
constructor(options: CLIOptions);
|
|
308
331
|
run(): Promise<void>;
|
|
309
332
|
private getApiKey;
|
|
333
|
+
private chooseFramework;
|
|
310
334
|
private confirmInstallation;
|
|
311
335
|
private displayResults;
|
|
312
336
|
}
|
|
@@ -319,12 +343,22 @@ declare class AutoInstallCLI {
|
|
|
319
343
|
|
|
320
344
|
interface FrameworkInfo$1 {
|
|
321
345
|
name: string;
|
|
322
|
-
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'node';
|
|
346
|
+
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node';
|
|
323
347
|
bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
|
|
324
348
|
packageManager?: 'npm' | 'yarn' | 'pnpm';
|
|
325
349
|
hasTypeScript?: boolean;
|
|
326
350
|
hasRouter?: boolean;
|
|
327
351
|
projectRoot?: string;
|
|
352
|
+
version?: string;
|
|
353
|
+
majorVersion?: number;
|
|
354
|
+
features?: {
|
|
355
|
+
hasReact18?: boolean;
|
|
356
|
+
hasVue3?: boolean;
|
|
357
|
+
hasNuxt3?: boolean;
|
|
358
|
+
hasAngularStandalone?: boolean;
|
|
359
|
+
hasNextAppRouter?: boolean;
|
|
360
|
+
hasSvelteKit?: boolean;
|
|
361
|
+
};
|
|
328
362
|
}
|
|
329
363
|
interface RemoteAIServiceConfig {
|
|
330
364
|
apiEndpoint: string;
|
|
@@ -374,7 +408,7 @@ declare class RemoteAIService {
|
|
|
374
408
|
|
|
375
409
|
interface FrameworkInfo {
|
|
376
410
|
name: string;
|
|
377
|
-
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'node';
|
|
411
|
+
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'node';
|
|
378
412
|
bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
|
|
379
413
|
packageManager?: 'npm' | 'yarn' | 'pnpm';
|
|
380
414
|
hasTypeScript?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "humanbehavior-js",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "SDK for HumanBehavior session and event recording",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
"author": "Chirag Kawediya, Skyler Ji, Amogh Chaturvedi",
|
|
61
61
|
"license": "ISC",
|
|
62
62
|
"dependencies": {
|
|
63
|
+
"@clack/prompts": "^0.11.0",
|
|
64
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
63
65
|
"@rrweb/record": "^2.0.0-alpha.17",
|
|
64
66
|
"@types/react": "^19.0.12",
|
|
65
67
|
"openai": "^5.12.0",
|
package/rollup.config.js
CHANGED
|
@@ -3,10 +3,11 @@ import resolve from '@rollup/plugin-node-resolve';
|
|
|
3
3
|
import commonjs from '@rollup/plugin-commonjs';
|
|
4
4
|
import terser from '@rollup/plugin-terser';
|
|
5
5
|
import dts from 'rollup-plugin-dts';
|
|
6
|
+
import json from '@rollup/plugin-json';
|
|
6
7
|
|
|
7
8
|
// External dependencies that shouldn't be bundled
|
|
8
9
|
const external = ['react', 'react-dom', 'react/jsx-runtime'];
|
|
9
|
-
const nodeExternal = ['fs', 'path', 'child_process', 'readline'];
|
|
10
|
+
const nodeExternal = ['fs', 'path', 'child_process', 'readline', '@clack/prompts'];
|
|
10
11
|
|
|
11
12
|
// Global variables for UMD build
|
|
12
13
|
const globals = {
|
|
@@ -305,6 +306,7 @@ export default [
|
|
|
305
306
|
preferBuiltins: true
|
|
306
307
|
}),
|
|
307
308
|
commonjs(),
|
|
309
|
+
json(),
|
|
308
310
|
typescript({
|
|
309
311
|
tsconfig: './tsconfig.json',
|
|
310
312
|
declaration: false,
|
|
@@ -327,6 +329,7 @@ export default [
|
|
|
327
329
|
preferBuiltins: true
|
|
328
330
|
}),
|
|
329
331
|
commonjs(),
|
|
332
|
+
json(),
|
|
330
333
|
typescript({
|
|
331
334
|
tsconfig: './tsconfig.json',
|
|
332
335
|
declaration: false,
|
|
@@ -396,6 +399,7 @@ export default [
|
|
|
396
399
|
preferBuiltins: true
|
|
397
400
|
}),
|
|
398
401
|
commonjs(),
|
|
402
|
+
json(),
|
|
399
403
|
typescript({
|
|
400
404
|
tsconfig: './tsconfig.json',
|
|
401
405
|
declaration: false,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare module '@clack/prompts' {
|
|
2
|
+
export function intro(message: string): void;
|
|
3
|
+
export function outro(message: string): void;
|
|
4
|
+
export function cancel(message: string): void;
|
|
5
|
+
export function note(message: string, title?: string): void;
|
|
6
|
+
|
|
7
|
+
export function text(options: {
|
|
8
|
+
message: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
validate?: (value: string) => string | undefined;
|
|
12
|
+
}): Promise<string>;
|
|
13
|
+
|
|
14
|
+
export function select(options: {
|
|
15
|
+
message: string;
|
|
16
|
+
options: Array<{
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
hint?: string;
|
|
20
|
+
}>;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
|
|
23
|
+
export function confirm(options: {
|
|
24
|
+
message: string;
|
|
25
|
+
}): Promise<boolean>;
|
|
26
|
+
|
|
27
|
+
export function spinner(): {
|
|
28
|
+
start(message: string): void;
|
|
29
|
+
stop(message?: string): void;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -123,6 +123,9 @@ class DefaultAIService implements CentralizedAIService {
|
|
|
123
123
|
} 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/')) {
|
|
124
124
|
framework = { name: 'nextjs', type: 'nextjs' };
|
|
125
125
|
confidence = 0.95;
|
|
126
|
+
} 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')) {
|
|
127
|
+
framework = { name: 'gatsby', type: 'gatsby' };
|
|
128
|
+
confidence = 0.95;
|
|
126
129
|
} else if (patterns.includes('react')) {
|
|
127
130
|
framework = { name: 'react', type: 'react' };
|
|
128
131
|
confidence = 0.9;
|
|
@@ -139,7 +142,7 @@ class DefaultAIService implements CentralizedAIService {
|
|
|
139
142
|
|
|
140
143
|
// Integration strategy
|
|
141
144
|
let integrationStrategy: 'provider' | 'plugin' | 'module' | 'script' | 'standalone' = 'script';
|
|
142
|
-
if (framework.type === 'react' || framework.type === 'nextjs') {
|
|
145
|
+
if (framework.type === 'react' || framework.type === 'nextjs' || framework.type === 'gatsby') {
|
|
143
146
|
integrationStrategy = 'provider';
|
|
144
147
|
} else if (framework.type === 'vue') {
|
|
145
148
|
integrationStrategy = 'plugin';
|
|
@@ -187,6 +187,8 @@ export class ManualFrameworkInstallationWizard extends AutoInstallationWizard {
|
|
|
187
187
|
'svelte': { name: 'svelte', type: 'svelte' },
|
|
188
188
|
'sveltekit': { name: 'svelte', type: 'svelte' },
|
|
189
189
|
'remix': { name: 'remix', type: 'remix' },
|
|
190
|
+
'astro': { name: 'astro', type: 'astro' },
|
|
191
|
+
'gatsby': { name: 'gatsby', type: 'gatsby' },
|
|
190
192
|
'vanilla': { name: 'vanilla', type: 'vanilla' },
|
|
191
193
|
'node': { name: 'node', type: 'node' },
|
|
192
194
|
'auto': { name: 'auto-detected', type: 'auto' }
|