@thebros/create-benjamin 1.0.9 ā 1.0.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/.env +1 -1
- package/bin/index.js +27 -29
- package/package.json +5 -5
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
OPENAI_API_KEY=sk-proj-
|
|
1
|
+
OPENAI_API_KEY=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
|
package/bin/index.js
CHANGED
|
@@ -8,27 +8,32 @@ import inquirer from "inquirer";
|
|
|
8
8
|
import ora from "ora";
|
|
9
9
|
import OpenAI from "openai";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!apiKey) {
|
|
14
|
-
const answer = await inquirer.prompt([
|
|
15
|
-
{
|
|
16
|
-
type: "password",
|
|
17
|
-
name: "key",
|
|
18
|
-
message: "Enter OpenAI API Key (or press enter to skip):",
|
|
19
|
-
},
|
|
20
|
-
]);
|
|
11
|
+
async function main() {
|
|
12
|
+
console.log(chalk.cyan("\nš¤ Create Benjamin AI Generator\n"));
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
// ===== GET API KEY =====
|
|
15
|
+
let apiKey = process.env.OPENAI_API_KEY;
|
|
23
16
|
|
|
24
17
|
if (!apiKey) {
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
const answer = await inquirer.prompt([
|
|
19
|
+
{
|
|
20
|
+
type: "password",
|
|
21
|
+
name: "key",
|
|
22
|
+
message: "Enter OpenAI API Key:",
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
apiKey = answer.key;
|
|
27
|
+
|
|
28
|
+
if (!apiKey) {
|
|
29
|
+
console.log("ā No API key provided");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
|
-
}
|
|
29
|
-
async function main() {
|
|
30
|
-
console.log(chalk.cyan("\nš¤ Create Benjamin AI Project Generator\n"));
|
|
31
33
|
|
|
34
|
+
const openai = new OpenAI({ apiKey });
|
|
35
|
+
|
|
36
|
+
// ===== USER INPUT =====
|
|
32
37
|
const answers = await inquirer.prompt([
|
|
33
38
|
{
|
|
34
39
|
type: "input",
|
|
@@ -39,7 +44,7 @@ async function main() {
|
|
|
39
44
|
{
|
|
40
45
|
type: "input",
|
|
41
46
|
name: "description",
|
|
42
|
-
message: "Describe your project
|
|
47
|
+
message: "Describe your project:",
|
|
43
48
|
},
|
|
44
49
|
]);
|
|
45
50
|
|
|
@@ -55,22 +60,15 @@ async function main() {
|
|
|
55
60
|
|
|
56
61
|
const spinner = ora("Generating project with AI...").start();
|
|
57
62
|
|
|
58
|
-
// =====
|
|
63
|
+
// ===== PROMPT =====
|
|
59
64
|
const prompt = `
|
|
60
65
|
You are a senior full-stack developer.
|
|
61
66
|
|
|
62
|
-
Generate a
|
|
67
|
+
Generate a full project for:
|
|
63
68
|
|
|
64
|
-
|
|
69
|
+
${answers.description}
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
- Must be Node.js backend + React frontend if needed
|
|
68
|
-
- Use Express for backend
|
|
69
|
-
- Use React + Vite for frontend
|
|
70
|
-
- Use MySQL if database needed
|
|
71
|
-
- Include folder structure
|
|
72
|
-
- Include working code files
|
|
73
|
-
- Return ONLY JSON in this format:
|
|
71
|
+
Return ONLY valid JSON:
|
|
74
72
|
|
|
75
73
|
{
|
|
76
74
|
"files": {
|
|
@@ -79,6 +77,7 @@ Rules:
|
|
|
79
77
|
}
|
|
80
78
|
`;
|
|
81
79
|
|
|
80
|
+
// ===== AI CALL =====
|
|
82
81
|
const response = await openai.chat.completions.create({
|
|
83
82
|
model: "gpt-4o-mini",
|
|
84
83
|
messages: [{ role: "user", content: prompt }],
|
|
@@ -87,7 +86,6 @@ Rules:
|
|
|
87
86
|
|
|
88
87
|
let text = response.choices[0].message.content;
|
|
89
88
|
|
|
90
|
-
// Clean AI response
|
|
91
89
|
text = text.replace(/```json/g, "").replace(/```/g, "");
|
|
92
90
|
|
|
93
91
|
let project;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thebros/create-benjamin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-benjamin": "./bin/index.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"chalk": "^5.
|
|
9
|
+
"chalk": "^5.6.2",
|
|
10
10
|
"dotenv": "^17.4.2",
|
|
11
11
|
"execa": "^8.0.1",
|
|
12
12
|
"figlet": "^1.7.0",
|
|
13
|
-
"fs-extra": "^11.
|
|
14
|
-
"inquirer": "^9.
|
|
13
|
+
"fs-extra": "^11.3.5",
|
|
14
|
+
"inquirer": "^9.3.8",
|
|
15
15
|
"openai": "^6.39.0",
|
|
16
|
-
"ora": "^8.0
|
|
16
|
+
"ora": "^8.2.0"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|