@posthog/wizard 0.2.10 → 0.2.11
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 +10 -10
- package/dist/src/lib/config.d.ts +21 -0
- package/dist/src/lib/config.js +49 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/constants.d.ts +2 -1
- package/dist/src/lib/constants.js +3 -0
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/prompts.d.ts +16 -0
- package/dist/src/{nextjs → lib}/prompts.js +18 -9
- package/dist/src/lib/prompts.js.map +1 -0
- package/dist/src/nextjs/docs.js +28 -16
- package/dist/src/nextjs/docs.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.d.ts +0 -7
- package/dist/src/nextjs/nextjs-wizard.js +20 -304
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/utils.d.ts +1 -4
- package/dist/src/nextjs/utils.js +1 -32
- package/dist/src/nextjs/utils.js.map +1 -1
- package/dist/src/react/docs.d.ts +4 -0
- package/dist/src/react/docs.js +37 -0
- package/dist/src/react/docs.js.map +1 -0
- package/dist/src/react/react-wizard.d.ts +2 -0
- package/dist/src/react/react-wizard.js +94 -0
- package/dist/src/react/react-wizard.js.map +1 -0
- package/dist/src/run.js +10 -4
- package/dist/src/run.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +2 -0
- package/dist/src/utils/clack-utils.js +45 -2
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/environment.d.ts +6 -0
- package/dist/src/utils/environment.js +100 -0
- package/dist/src/utils/environment.js.map +1 -1
- package/dist/src/utils/file-utils.d.ts +27 -0
- package/dist/src/utils/file-utils.js +139 -0
- package/dist/src/utils/file-utils.js.map +1 -1
- package/dist/src/utils/query.js +2 -2
- package/dist/src/utils/query.js.map +1 -1
- package/dist/src/utils/types.d.ts +5 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/utils/urls.d.ts +4 -0
- package/dist/src/utils/urls.js +35 -0
- package/dist/src/utils/urls.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/nextjs/prompts.d.ts +0 -12
- package/dist/src/nextjs/prompts.js.map +0 -1
|
@@ -1,2 +1,29 @@
|
|
|
1
|
+
import type { CloudRegion, FileChange, WizardOptions } from './types';
|
|
2
|
+
import { Integration } from '../lib/constants';
|
|
1
3
|
export declare const GLOBAL_IGNORE_PATTERN: string[];
|
|
2
4
|
export declare function getAllFilesInProject(dir: string): Promise<string[]>;
|
|
5
|
+
export declare function getDotGitignore({ installDir, }: Pick<WizardOptions, 'installDir'>): string | undefined;
|
|
6
|
+
export declare function updateFile(change: FileChange, { installDir }: Pick<WizardOptions, 'installDir'>): Promise<void>;
|
|
7
|
+
export declare function getFilesToChange({ integration, relevantFiles, documentation, wizardHash, cloudRegion, }: {
|
|
8
|
+
integration: Integration;
|
|
9
|
+
relevantFiles: string[];
|
|
10
|
+
documentation: string;
|
|
11
|
+
wizardHash: string;
|
|
12
|
+
cloudRegion: CloudRegion;
|
|
13
|
+
}): Promise<string[]>;
|
|
14
|
+
export declare function generateFileContent({ prompt, wizardHash, cloudRegion, }: {
|
|
15
|
+
prompt: string;
|
|
16
|
+
wizardHash: string;
|
|
17
|
+
cloudRegion: CloudRegion;
|
|
18
|
+
}): Promise<string>;
|
|
19
|
+
export declare function generateFileChangesForIntegration({ integration, filesToChange, wizardHash, documentation, installDir, cloudRegion, }: {
|
|
20
|
+
integration: Integration;
|
|
21
|
+
filesToChange: string[];
|
|
22
|
+
wizardHash: string;
|
|
23
|
+
documentation: string;
|
|
24
|
+
installDir: string;
|
|
25
|
+
cloudRegion: CloudRegion;
|
|
26
|
+
}): Promise<FileChange[]>;
|
|
27
|
+
export declare function getRelevantFilesForIntegration({ installDir, integration, }: Pick<WizardOptions, 'installDir'> & {
|
|
28
|
+
integration: Integration;
|
|
29
|
+
}): Promise<string[]>;
|
|
@@ -5,8 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GLOBAL_IGNORE_PATTERN = void 0;
|
|
7
7
|
exports.getAllFilesInProject = getAllFilesInProject;
|
|
8
|
+
exports.getDotGitignore = getDotGitignore;
|
|
9
|
+
exports.updateFile = updateFile;
|
|
10
|
+
exports.getFilesToChange = getFilesToChange;
|
|
11
|
+
exports.generateFileContent = generateFileContent;
|
|
12
|
+
exports.generateFileChangesForIntegration = generateFileChangesForIntegration;
|
|
13
|
+
exports.getRelevantFilesForIntegration = getRelevantFilesForIntegration;
|
|
8
14
|
const path_1 = __importDefault(require("path"));
|
|
9
15
|
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const clack_1 = __importDefault(require("./clack"));
|
|
17
|
+
const zod_1 = __importDefault(require("zod"));
|
|
18
|
+
const query_1 = require("./query");
|
|
19
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
20
|
+
const analytics_1 = require("./analytics");
|
|
21
|
+
const clack_utils_1 = require("./clack-utils");
|
|
22
|
+
const config_1 = require("../lib/config");
|
|
23
|
+
const prompts_1 = require("../lib/prompts");
|
|
10
24
|
exports.GLOBAL_IGNORE_PATTERN = [
|
|
11
25
|
'node_modules',
|
|
12
26
|
'dist',
|
|
@@ -35,4 +49,129 @@ async function getAllFilesInProject(dir) {
|
|
|
35
49
|
}
|
|
36
50
|
return results;
|
|
37
51
|
}
|
|
52
|
+
function getDotGitignore({ installDir, }) {
|
|
53
|
+
const gitignorePath = path_1.default.join(installDir, '.gitignore');
|
|
54
|
+
const gitignoreExists = fs_1.default.existsSync(gitignorePath);
|
|
55
|
+
if (gitignoreExists) {
|
|
56
|
+
return gitignorePath;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
async function updateFile(change, { installDir }) {
|
|
61
|
+
const dir = path_1.default.dirname(path_1.default.join(installDir, change.filePath));
|
|
62
|
+
await fs_1.default.promises.mkdir(dir, { recursive: true });
|
|
63
|
+
await fs_1.default.promises.writeFile(path_1.default.join(installDir, change.filePath), change.newContent);
|
|
64
|
+
}
|
|
65
|
+
async function getFilesToChange({ integration, relevantFiles, documentation, wizardHash, cloudRegion, }) {
|
|
66
|
+
const filterFilesSpinner = clack_1.default.spinner();
|
|
67
|
+
filterFilesSpinner.start('Selecting files to change...');
|
|
68
|
+
const filterFilesResponseSchmea = zod_1.default.object({
|
|
69
|
+
files: zod_1.default.array(zod_1.default.string()),
|
|
70
|
+
});
|
|
71
|
+
const prompt = await prompts_1.baseFilterFilesPromptTemplate.format({
|
|
72
|
+
documentation,
|
|
73
|
+
file_list: relevantFiles.join('\n'),
|
|
74
|
+
integration_name: integration,
|
|
75
|
+
integration_rules: config_1.INTEGRATION_CONFIG[integration].filterFilesRules,
|
|
76
|
+
});
|
|
77
|
+
const filterFilesResponse = await (0, query_1.query)({
|
|
78
|
+
message: prompt,
|
|
79
|
+
schema: filterFilesResponseSchmea,
|
|
80
|
+
wizardHash,
|
|
81
|
+
region: cloudRegion,
|
|
82
|
+
});
|
|
83
|
+
const filesToChange = filterFilesResponse.files;
|
|
84
|
+
filterFilesSpinner.stop(`Found ${filesToChange.length} files to change`);
|
|
85
|
+
analytics_1.analytics.capture('wizard interaction', {
|
|
86
|
+
action: 'detected files to change',
|
|
87
|
+
integration,
|
|
88
|
+
files: filesToChange,
|
|
89
|
+
});
|
|
90
|
+
return filesToChange;
|
|
91
|
+
}
|
|
92
|
+
async function generateFileContent({ prompt, wizardHash, cloudRegion, }) {
|
|
93
|
+
const response = await (0, query_1.query)({
|
|
94
|
+
message: prompt,
|
|
95
|
+
schema: zod_1.default.object({
|
|
96
|
+
newContent: zod_1.default.string(),
|
|
97
|
+
}),
|
|
98
|
+
wizardHash: wizardHash,
|
|
99
|
+
region: cloudRegion,
|
|
100
|
+
});
|
|
101
|
+
return response.newContent;
|
|
102
|
+
}
|
|
103
|
+
async function generateFileChangesForIntegration({ integration, filesToChange, wizardHash, documentation, installDir, cloudRegion, }) {
|
|
104
|
+
const changes = [];
|
|
105
|
+
for (const filePath of filesToChange) {
|
|
106
|
+
const fileChangeSpinner = clack_1.default.spinner();
|
|
107
|
+
analytics_1.analytics.capture('wizard interaction', {
|
|
108
|
+
action: 'processing file',
|
|
109
|
+
integration,
|
|
110
|
+
file: filePath,
|
|
111
|
+
});
|
|
112
|
+
try {
|
|
113
|
+
let oldContent = undefined;
|
|
114
|
+
try {
|
|
115
|
+
oldContent = await fs_1.default.promises.readFile(path_1.default.join(installDir, filePath), 'utf8');
|
|
116
|
+
}
|
|
117
|
+
catch (readError) {
|
|
118
|
+
if (readError.code !== 'ENOENT') {
|
|
119
|
+
await (0, clack_utils_1.abort)(`Error reading file ${filePath}`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
fileChangeSpinner.start(`${oldContent ? 'Updating' : 'Creating'} file ${filePath}`);
|
|
124
|
+
const unchangedFiles = filesToChange.filter((filePath) => !changes.some((change) => change.filePath === filePath));
|
|
125
|
+
const prompt = await prompts_1.baseGenerateFileChangesPromptTemplate.format({
|
|
126
|
+
file_content: oldContent,
|
|
127
|
+
file_path: filePath,
|
|
128
|
+
documentation,
|
|
129
|
+
integration_name: config_1.INTEGRATION_CONFIG[integration].name,
|
|
130
|
+
integration_rules: config_1.INTEGRATION_CONFIG[integration].generateFilesRules,
|
|
131
|
+
changed_files: changes
|
|
132
|
+
.map((change) => `${change.filePath}\n${change.oldContent}`)
|
|
133
|
+
.join('\n'),
|
|
134
|
+
unchanged_files: unchangedFiles,
|
|
135
|
+
});
|
|
136
|
+
const newContent = await generateFileContent({
|
|
137
|
+
prompt,
|
|
138
|
+
wizardHash,
|
|
139
|
+
cloudRegion,
|
|
140
|
+
});
|
|
141
|
+
if (newContent !== oldContent) {
|
|
142
|
+
await updateFile({ filePath, oldContent, newContent }, { installDir });
|
|
143
|
+
changes.push({ filePath, oldContent, newContent });
|
|
144
|
+
}
|
|
145
|
+
fileChangeSpinner.stop(`${oldContent ? 'Updated' : 'Created'} file ${filePath}`);
|
|
146
|
+
analytics_1.analytics.capture('wizard interaction', {
|
|
147
|
+
action: 'processed file',
|
|
148
|
+
integration,
|
|
149
|
+
file: filePath,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
await (0, clack_utils_1.abort)(`Error processing file ${filePath}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
analytics_1.analytics.capture('wizard interaction', {
|
|
157
|
+
action: 'completed file changes',
|
|
158
|
+
integration,
|
|
159
|
+
files: filesToChange,
|
|
160
|
+
});
|
|
161
|
+
return changes;
|
|
162
|
+
}
|
|
163
|
+
async function getRelevantFilesForIntegration({ installDir, integration, }) {
|
|
164
|
+
const filterPatterns = config_1.INTEGRATION_CONFIG[integration].filterPatterns;
|
|
165
|
+
const ignorePatterns = config_1.INTEGRATION_CONFIG[integration].ignorePatterns;
|
|
166
|
+
const filteredFiles = await (0, fast_glob_1.default)(filterPatterns, {
|
|
167
|
+
cwd: installDir,
|
|
168
|
+
ignore: ignorePatterns,
|
|
169
|
+
});
|
|
170
|
+
analytics_1.analytics.capture('wizard interaction', {
|
|
171
|
+
action: 'detected relevant files',
|
|
172
|
+
integration,
|
|
173
|
+
number_of_files: filteredFiles.length,
|
|
174
|
+
});
|
|
175
|
+
return filteredFiles;
|
|
176
|
+
}
|
|
38
177
|
//# sourceMappingURL=file-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../../src/utils/file-utils.ts"],"names":[],"mappings":";;;;;;AAYA,oDAsBC;AAlCD,gDAAwB;AACxB,4CAAoB;AAEP,QAAA,qBAAqB,GAAG;IACnC,cAAc;IACd,MAAM;IACN,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;CACR,CAAC;AACK,KAAK,UAAU,oBAAoB,CAAC,GAAW;IACpD,IAAI,OAAO,GAAa,EAAE,CAAC;IAE3B,MAAM,OAAO,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAExE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAE5C,IAAI,6BAAqB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;YACxE,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,4CAA4C;YAC5C,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YACzD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import path from 'path';\nimport fs from 'fs';\n\nexport const GLOBAL_IGNORE_PATTERN = [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n '.git',\n '.next',\n];\nexport async function getAllFilesInProject(dir: string): Promise<string[]> {\n let results: string[] = [];\n\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (GLOBAL_IGNORE_PATTERN.some((pattern) => fullPath.includes(pattern))) {\n continue;\n }\n\n if (entry.isDirectory()) {\n // Recursively get files from subdirectories\n const subDirFiles = await getAllFilesInProject(fullPath);\n results = results.concat(subDirFiles);\n } else {\n results.push(fullPath);\n }\n }\n\n return results;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"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AAM,EAAE,yBAAyB;QACjC,WAAW;QACX,eAAe,EAAE,aAAa,CAAC,MAAM;KACtC,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport type { CloudRegion, FileChange, WizardOptions } from './types';\nimport clack from './clack';\nimport z from 'zod';\nimport { query } from './query';\nimport fg from 'fast-glob';\nimport { analytics } from './analytics';\nimport { Integration } from '../lib/constants';\nimport { abort } from './clack-utils';\nimport { INTEGRATION_CONFIG } from '../lib/config';\nimport {\n baseFilterFilesPromptTemplate,\n baseGenerateFileChangesPromptTemplate,\n} from '../lib/prompts';\n\nexport const GLOBAL_IGNORE_PATTERN = [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n '.git',\n '.next',\n];\nexport async function getAllFilesInProject(dir: string): Promise<string[]> {\n let results: string[] = [];\n\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (GLOBAL_IGNORE_PATTERN.some((pattern) => fullPath.includes(pattern))) {\n continue;\n }\n\n if (entry.isDirectory()) {\n // Recursively get files from subdirectories\n const subDirFiles = await getAllFilesInProject(fullPath);\n results = results.concat(subDirFiles);\n } else {\n results.push(fullPath);\n }\n }\n\n return results;\n}\n\nexport function getDotGitignore({\n installDir,\n}: Pick<WizardOptions, 'installDir'>) {\n const gitignorePath = path.join(installDir, '.gitignore');\n const gitignoreExists = fs.existsSync(gitignorePath);\n\n if (gitignoreExists) {\n return gitignorePath;\n }\n\n return undefined;\n}\n\nexport async function updateFile(\n change: FileChange,\n { installDir }: Pick<WizardOptions, 'installDir'>,\n) {\n const dir = path.dirname(path.join(installDir, change.filePath));\n await fs.promises.mkdir(dir, { recursive: true });\n await fs.promises.writeFile(\n path.join(installDir, change.filePath),\n change.newContent,\n );\n}\n\nexport async function getFilesToChange({\n integration,\n relevantFiles,\n documentation,\n wizardHash,\n cloudRegion,\n}: {\n integration: Integration;\n relevantFiles: string[];\n documentation: string;\n wizardHash: string;\n cloudRegion: CloudRegion;\n}) {\n const filterFilesSpinner = clack.spinner();\n\n filterFilesSpinner.start('Selecting files to change...');\n\n const filterFilesResponseSchmea = z.object({\n files: z.array(z.string()),\n });\n\n const prompt = await baseFilterFilesPromptTemplate.format({\n documentation,\n file_list: relevantFiles.join('\\n'),\n integration_name: integration,\n integration_rules: INTEGRATION_CONFIG[integration].filterFilesRules,\n });\n\n const filterFilesResponse = await query({\n message: prompt,\n schema: filterFilesResponseSchmea,\n wizardHash,\n region: cloudRegion,\n });\n\n const filesToChange = filterFilesResponse.files;\n\n filterFilesSpinner.stop(`Found ${filesToChange.length} files to change`);\n\n analytics.capture('wizard interaction', {\n action: 'detected files to change',\n integration,\n files: filesToChange,\n });\n\n return filesToChange;\n}\n\nexport async function generateFileContent({\n prompt,\n wizardHash,\n cloudRegion,\n}: {\n prompt: string;\n wizardHash: string;\n cloudRegion: CloudRegion;\n}) {\n const response = await query({\n message: prompt,\n schema: z.object({\n newContent: z.string(),\n }),\n wizardHash: wizardHash,\n region: cloudRegion,\n });\n\n return response.newContent;\n}\n\nexport async function generateFileChangesForIntegration({\n integration,\n filesToChange,\n wizardHash,\n documentation,\n installDir,\n cloudRegion,\n}: {\n integration: Integration;\n filesToChange: string[];\n wizardHash: string;\n documentation: string;\n installDir: string;\n cloudRegion: CloudRegion;\n}) {\n const changes: FileChange[] = [];\n\n for (const filePath of filesToChange) {\n const fileChangeSpinner = clack.spinner();\n\n analytics.capture('wizard interaction', {\n action: 'processing file',\n integration,\n file: filePath,\n });\n\n try {\n let oldContent = undefined;\n try {\n oldContent = await fs.promises.readFile(\n path.join(installDir, filePath),\n 'utf8',\n );\n } catch (readError) {\n if (readError.code !== 'ENOENT') {\n await abort(`Error reading file ${filePath}`);\n continue;\n }\n }\n\n fileChangeSpinner.start(\n `${oldContent ? 'Updating' : 'Creating'} file ${filePath}`,\n );\n\n const unchangedFiles = filesToChange.filter(\n (filePath) => !changes.some((change) => change.filePath === filePath),\n );\n\n const prompt = await baseGenerateFileChangesPromptTemplate.format({\n file_content: oldContent,\n file_path: filePath,\n documentation,\n integration_name: INTEGRATION_CONFIG[integration].name,\n integration_rules: INTEGRATION_CONFIG[integration].generateFilesRules,\n changed_files: changes\n .map((change) => `${change.filePath}\\n${change.oldContent}`)\n .join('\\n'),\n unchanged_files: unchangedFiles,\n });\n\n const newContent = await generateFileContent({\n prompt,\n wizardHash,\n cloudRegion,\n });\n\n if (newContent !== oldContent) {\n await updateFile({ filePath, oldContent, newContent }, { installDir });\n changes.push({ filePath, oldContent, newContent });\n }\n\n fileChangeSpinner.stop(\n `${oldContent ? 'Updated' : 'Created'} file ${filePath}`,\n );\n\n analytics.capture('wizard interaction', {\n action: 'processed file',\n integration,\n file: filePath,\n });\n } catch (error) {\n await abort(`Error processing file ${filePath}`);\n }\n }\n\n analytics.capture('wizard interaction', {\n action: 'completed file changes',\n integration,\n files: filesToChange,\n });\n\n return changes;\n}\n\nexport async function getRelevantFilesForIntegration({\n installDir,\n integration,\n}: Pick<WizardOptions, 'installDir'> & {\n integration: Integration;\n}) {\n const filterPatterns = INTEGRATION_CONFIG[integration].filterPatterns;\n const ignorePatterns = INTEGRATION_CONFIG[integration].ignorePatterns;\n\n const filteredFiles = await fg(filterPatterns, {\n cwd: installDir,\n ignore: ignorePatterns,\n });\n\n analytics.capture('wizard interaction', {\n action: 'detected relevant files',\n integration,\n number_of_files: filteredFiles.length,\n });\n\n return filteredFiles;\n}\n"]}
|
package/dist/src/utils/query.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.query = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
9
|
-
const
|
|
9
|
+
const urls_1 = require("./urls");
|
|
10
10
|
const query = async ({ message, region, schema, wizardHash, }) => {
|
|
11
11
|
const jsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(schema, 'schema').definitions;
|
|
12
|
-
const response = await axios_1.default.post(`${(0,
|
|
12
|
+
const response = await axios_1.default.post(`${(0, urls_1.getCloudUrlFromRegion)(region)}/api/wizard/query`, {
|
|
13
13
|
message,
|
|
14
14
|
json_schema: { ...jsonSchema, name: 'schema', strict: true },
|
|
15
15
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/utils/query.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,2DAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/utils/query.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,2DAAqD;AAErD,iCAA+C;AAExC,MAAM,KAAK,GAAG,KAAK,EAAK,EAC7B,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,GAMX,EAAc,EAAE;IACf,MAAM,UAAU,GAAG,IAAA,oCAAe,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,WAAW,CAAC;IAEjE,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,GAAG,IAAA,4BAAqB,EAAC,MAAM,CAAC,mBAAmB,EACnD;QACE,OAAO;QACP,WAAW,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE;KAC7D,EACD;QACE,OAAO,EAAE;YACP,uBAAuB,EAAE,UAAU;SACpC;KACF,CACF,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAExD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC,CAAC;AAjCW,QAAA,KAAK,SAiChB","sourcesContent":["import axios from 'axios';\nimport type { ZodSchema } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport type { CloudRegion } from './types';\nimport { getCloudUrlFromRegion } from './urls';\n\nexport const query = async <S>({\n message,\n region,\n schema,\n wizardHash,\n}: {\n message: string;\n region: CloudRegion;\n schema: ZodSchema<S>;\n wizardHash: string;\n}): Promise<S> => {\n const jsonSchema = zodToJsonSchema(schema, 'schema').definitions;\n\n const response = await axios.post<{ data: unknown }>(\n `${getCloudUrlFromRegion(region)}/api/wizard/query`,\n {\n message,\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n },\n {\n headers: {\n 'X-PostHog-Wizard-Hash': wizardHash,\n },\n },\n );\n\n const validation = schema.safeParse(response.data.data);\n\n if (!validation.success) {\n throw new Error(`Invalid response from wizard: ${validation.error}`);\n }\n\n return validation.data;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PostHogProjectData = Record<string, unknown>;\n\nexport type PreselectedProject = {\n project: PostHogProjectData;\n authToken: string;\n};\n\nexport type WizardOptions = {\n /**\n * Whether to enable debug mode.\n */\n debug: boolean;\n\n /**\n * Whether to force install the SDK package to continue with the installation in case\n * any package manager checks are failing (e.g. peer dependency versions).\n *\n * Use with caution and only if you know what you're doing.\n *\n * Does not apply to all wizard flows (currently NPM only)\n */\n forceInstall: boolean;\n\n /**\n * The directory to run the wizard in.\n */\n installDir: string;\n\n /**\n * The cloud region to use.\n */\n cloudRegion?: CloudRegion;\n\n /**\n * Whether to select the default option for all questions automatically.\n */\n default: boolean;\n};\n\nexport interface Feature {\n id: string;\n prompt: string;\n enabledHint?: string;\n disabledHint?: string;\n}\n\nexport type CloudRegion = 'us' | 'eu';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PostHogProjectData = Record<string, unknown>;\n\nexport type PreselectedProject = {\n project: PostHogProjectData;\n authToken: string;\n};\n\nexport type WizardOptions = {\n /**\n * Whether to enable debug mode.\n */\n debug: boolean;\n\n /**\n * Whether to force install the SDK package to continue with the installation in case\n * any package manager checks are failing (e.g. peer dependency versions).\n *\n * Use with caution and only if you know what you're doing.\n *\n * Does not apply to all wizard flows (currently NPM only)\n */\n forceInstall: boolean;\n\n /**\n * The directory to run the wizard in.\n */\n installDir: string;\n\n /**\n * The cloud region to use.\n */\n cloudRegion?: CloudRegion;\n\n /**\n * Whether to select the default option for all questions automatically.\n */\n default: boolean;\n};\n\nexport interface Feature {\n id: string;\n prompt: string;\n enabledHint?: string;\n disabledHint?: string;\n}\n\nexport type FileChange = {\n filePath: string;\n oldContent?: string;\n newContent: string;\n};\n\nexport type CloudRegion = 'us' | 'eu';\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CloudRegion } from './types';
|
|
2
|
+
export declare const getAssetHostFromHost: (host: string) => string;
|
|
3
|
+
export declare const getUiHostFromHost: (host: string) => string;
|
|
4
|
+
export declare const getCloudUrlFromRegion: (region: CloudRegion) => "http://localhost:8010" | "https://us.posthog.com" | "https://eu.posthog.com";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCloudUrlFromRegion = exports.getUiHostFromHost = exports.getAssetHostFromHost = void 0;
|
|
4
|
+
const constants_1 = require("../lib/constants");
|
|
5
|
+
const getAssetHostFromHost = (host) => {
|
|
6
|
+
if (host.includes('us.i.posthog.com')) {
|
|
7
|
+
return 'https://us-assets.i.posthog.com';
|
|
8
|
+
}
|
|
9
|
+
if (host.includes('eu.i.posthog.com')) {
|
|
10
|
+
return 'https://eu-assets.i.posthog.com';
|
|
11
|
+
}
|
|
12
|
+
return host;
|
|
13
|
+
};
|
|
14
|
+
exports.getAssetHostFromHost = getAssetHostFromHost;
|
|
15
|
+
const getUiHostFromHost = (host) => {
|
|
16
|
+
if (host.includes('us.i.posthog.com')) {
|
|
17
|
+
return 'https://us.posthog.com';
|
|
18
|
+
}
|
|
19
|
+
if (host.includes('eu.i.posthog.com')) {
|
|
20
|
+
return 'https://eu.posthog.com';
|
|
21
|
+
}
|
|
22
|
+
return host;
|
|
23
|
+
};
|
|
24
|
+
exports.getUiHostFromHost = getUiHostFromHost;
|
|
25
|
+
const getCloudUrlFromRegion = (region) => {
|
|
26
|
+
if (constants_1.IS_DEV) {
|
|
27
|
+
return 'http://localhost:8010';
|
|
28
|
+
}
|
|
29
|
+
if (region === 'us') {
|
|
30
|
+
return 'https://us.posthog.com';
|
|
31
|
+
}
|
|
32
|
+
return 'https://eu.posthog.com';
|
|
33
|
+
};
|
|
34
|
+
exports.getCloudUrlFromRegion = getCloudUrlFromRegion;
|
|
35
|
+
//# sourceMappingURL=urls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../../src/utils/urls.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAGnC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE;IACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,oBAAoB,wBAU/B;AAEK,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;IAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,qBAAqB,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC3D,IAAI,kBAAM,EAAE,CAAC;QACX,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,wBAAwB,CAAC;IAClC,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC","sourcesContent":["import { IS_DEV } from '../lib/constants';\nimport type { CloudRegion } from './types';\n\nexport const getAssetHostFromHost = (host: string) => {\n if (host.includes('us.i.posthog.com')) {\n return 'https://us-assets.i.posthog.com';\n }\n\n if (host.includes('eu.i.posthog.com')) {\n return 'https://eu-assets.i.posthog.com';\n }\n\n return host;\n};\n\nexport const getUiHostFromHost = (host: string) => {\n if (host.includes('us.i.posthog.com')) {\n return 'https://us.posthog.com';\n }\n\n if (host.includes('eu.i.posthog.com')) {\n return 'https://eu.posthog.com';\n }\n\n return host;\n};\n\nexport const getCloudUrlFromRegion = (region: CloudRegion) => {\n if (IS_DEV) {\n return 'http://localhost:8010';\n }\n\n if (region === 'us') {\n return 'https://us.posthog.com';\n }\n return 'https://eu.posthog.com';\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PromptTemplate } from '@langchain/core/prompts';
|
|
2
|
-
export declare const filterFilesPromptTemplate: PromptTemplate<{
|
|
3
|
-
documentation: any;
|
|
4
|
-
file_list: any;
|
|
5
|
-
}, any>;
|
|
6
|
-
export declare const generateFileChangesPromptTemplate: PromptTemplate<{
|
|
7
|
-
documentation: any;
|
|
8
|
-
file_content: any;
|
|
9
|
-
file_path: any;
|
|
10
|
-
changed_files: any;
|
|
11
|
-
unchanged_files: any;
|
|
12
|
-
}, any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/nextjs/prompts.ts"],"names":[],"mappings":";;;AAAA,qDAAyD;AAE5C,QAAA,yBAAyB,GAAG,IAAI,wBAAc,CAAC;IAC1D,cAAc,EAAE,CAAC,eAAe,EAAE,WAAW,CAAC;IAC9C,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;YAuBA;CACX,CAAC,CAAC;AAEU,QAAA,iCAAiC,GAAG,IAAI,wBAAc,CAAC;IAClE,cAAc,EAAE;QACd,cAAc;QACd,eAAe;QACf,WAAW;QACX,eAAe;QACf,iBAAiB;KAClB;IACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6BG;CACd,CAAC,CAAC","sourcesContent":["import { PromptTemplate } from '@langchain/core/prompts';\n\nexport const filterFilesPromptTemplate = new PromptTemplate({\n inputVariables: ['documentation', 'file_list'],\n template: `You are a PostHog installation wizard, a master AI programming assistant that implements PostHog for Next.js projects.\nGiven the following list of Next.js file paths from a project, determine which files are likely to require modifications \nto integrate PostHog. Use the installation documentation as a reference for what files might need modifications, do not include files that are unlikely to require modification based on the documentation.\n\n- If you would like to create a new file, you can include the file path in your response.\n- If you would like to modify an existing file, you can include the file path in your response.\n\nYou should return all files that you think will be required to look at or modify to integrate PostHog. You should return them in the order you would like to see them processed, with new files first, followed by the files that you want to update to integrate PostHog.\n\nRules:\n- Only return files that you think will be required to look at or modify to integrate PostHog.\n- Do not return files that are unlikely to require modification based on the documentation.\n- If you are unsure, return the file, since it's better to have more files than less.\n- If you create a new file, it should not conflict with any existing files.\n- If the user is using TypeScript, you should return .ts and .tsx files.\n- You should implement both posthog-js and posthog-node.\n- The file structure of the project may be different than the documentation, you should follow the file structure of the project.\n\nInstallation documentation:\n{documentation}\n\nAll current files in the repository:\n\n{file_list}`,\n});\n\nexport const generateFileChangesPromptTemplate = new PromptTemplate({\n inputVariables: [\n 'file_content',\n 'documentation',\n 'file_path',\n 'changed_files',\n 'unchanged_files',\n ],\n template: `You are a PostHog installation wizard, a master AI programming assistant that implements PostHog for Next.js projects.\n\nYour task is to update the file to integrate PostHog according to the documentation.\nDo not return a diff — you should return the complete updated file content.\n\nRules:\n- Preserve the existing code formatting and style.\n- Only make the changes required by the documentation.\n- If no changes are needed, return the file as-is.\n- If the current file is empty, and you think it should be created, you can add the contents of the new file.\n- The file structure of the project may be different than the documentation, you should follow the file structure of the project.\n- Use relative imports if you are unsure what the project import paths are.\n\nCONTEXT\n---\n\nDocumentation for integrating PostHog with Next.js:\n{documentation}\n\nThe file you are updating is:\n{file_path}\n\nHere are the changes you have already made to the project:\n{changed_files}\n\nHere are the files that have not been changed yet:\n{unchanged_files}\n\nBelow is the current file contents:\n{file_content}`,\n});\n"]}
|