@thebros/create-benjamin 1.0.8 ā 1.0.10
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 +30 -24
- 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,19 +8,32 @@ import inquirer from "inquirer";
|
|
|
8
8
|
import ora from "ora";
|
|
9
9
|
import OpenAI from "openai";
|
|
10
10
|
|
|
11
|
-
const apiKey = process.env.OPENAI_API_KEY;
|
|
12
|
-
|
|
13
|
-
if (!apiKey) {
|
|
14
|
-
console.error(chalk.red("ā Missing OPENAI_API_KEY"));
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const openai = new OpenAI({
|
|
19
|
-
apiKey,
|
|
20
|
-
});
|
|
21
11
|
async function main() {
|
|
22
|
-
console.log(chalk.cyan("\nš¤ Create Benjamin AI
|
|
12
|
+
console.log(chalk.cyan("\nš¤ Create Benjamin AI Generator\n"));
|
|
13
|
+
|
|
14
|
+
// ===== GET API KEY =====
|
|
15
|
+
let apiKey = process.env.OPENAI_API_KEY;
|
|
16
|
+
|
|
17
|
+
if (!apiKey) {
|
|
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
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const openai = new OpenAI({ apiKey });
|
|
23
35
|
|
|
36
|
+
// ===== USER INPUT =====
|
|
24
37
|
const answers = await inquirer.prompt([
|
|
25
38
|
{
|
|
26
39
|
type: "input",
|
|
@@ -31,7 +44,7 @@ async function main() {
|
|
|
31
44
|
{
|
|
32
45
|
type: "input",
|
|
33
46
|
name: "description",
|
|
34
|
-
message: "Describe your project
|
|
47
|
+
message: "Describe your project:",
|
|
35
48
|
},
|
|
36
49
|
]);
|
|
37
50
|
|
|
@@ -47,22 +60,15 @@ async function main() {
|
|
|
47
60
|
|
|
48
61
|
const spinner = ora("Generating project with AI...").start();
|
|
49
62
|
|
|
50
|
-
// =====
|
|
63
|
+
// ===== PROMPT =====
|
|
51
64
|
const prompt = `
|
|
52
65
|
You are a senior full-stack developer.
|
|
53
66
|
|
|
54
|
-
Generate a
|
|
67
|
+
Generate a full project for:
|
|
55
68
|
|
|
56
|
-
|
|
69
|
+
${answers.description}
|
|
57
70
|
|
|
58
|
-
|
|
59
|
-
- Must be Node.js backend + React frontend if needed
|
|
60
|
-
- Use Express for backend
|
|
61
|
-
- Use React + Vite for frontend
|
|
62
|
-
- Use MySQL if database needed
|
|
63
|
-
- Include folder structure
|
|
64
|
-
- Include working code files
|
|
65
|
-
- Return ONLY JSON in this format:
|
|
71
|
+
Return ONLY valid JSON:
|
|
66
72
|
|
|
67
73
|
{
|
|
68
74
|
"files": {
|
|
@@ -71,6 +77,7 @@ Rules:
|
|
|
71
77
|
}
|
|
72
78
|
`;
|
|
73
79
|
|
|
80
|
+
// ===== AI CALL =====
|
|
74
81
|
const response = await openai.chat.completions.create({
|
|
75
82
|
model: "gpt-4o-mini",
|
|
76
83
|
messages: [{ role: "user", content: prompt }],
|
|
@@ -79,7 +86,6 @@ Rules:
|
|
|
79
86
|
|
|
80
87
|
let text = response.choices[0].message.content;
|
|
81
88
|
|
|
82
|
-
// Clean AI response
|
|
83
89
|
text = text.replace(/```json/g, "").replace(/```/g, "");
|
|
84
90
|
|
|
85
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.10",
|
|
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"
|