zobro-cli 1.1.1 ā 1.1.2
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/index.js +29 -25
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const yargs = require('yargs/yargs');
|
|
6
|
-
const { hideBin } = require('yargs/helpers');
|
|
7
5
|
|
|
8
|
-
// š”ļø SECURE:
|
|
6
|
+
// š”ļø SECURE: This pulls the key from your computer's hidden settings
|
|
9
7
|
const API_KEY = process.env.GEMINI_API_KEY;
|
|
10
8
|
|
|
11
9
|
async function generateProject(prompt, directoryName) {
|
|
12
|
-
// Check if the key exists before running
|
|
13
10
|
if (!API_KEY) {
|
|
14
11
|
console.error('ā ERROR: API Key not found on this system.');
|
|
15
12
|
console.log('š To fix this, run: setx GEMINI_API_KEY "your_real_key_here"');
|
|
@@ -17,7 +14,7 @@ async function generateProject(prompt, directoryName) {
|
|
|
17
14
|
return;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
|
-
const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.
|
|
17
|
+
const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${API_KEY}`;
|
|
21
18
|
|
|
22
19
|
const newPrompt = `
|
|
23
20
|
You are an expert software developer and project scaffolder.
|
|
@@ -26,7 +23,7 @@ Each object in the array must have two keys:
|
|
|
26
23
|
1. "filename": (string) The full relative path for the file.
|
|
27
24
|
2. "code": (string) The complete code for that file.
|
|
28
25
|
|
|
29
|
-
Only return the raw JSON array, with no other text or markdown fences.
|
|
26
|
+
Only return the raw JSON array, with no other text, explanations, or markdown fences.
|
|
30
27
|
User Prompt: "${prompt}"`;
|
|
31
28
|
|
|
32
29
|
const body = { contents: [{ parts: [{ text: newPrompt }] }] };
|
|
@@ -43,15 +40,14 @@ User Prompt: "${prompt}"`;
|
|
|
43
40
|
if (!response.ok) {
|
|
44
41
|
const errorData = await response.json();
|
|
45
42
|
console.error('ā API Error Details:', JSON.stringify(errorData.error, null, 2));
|
|
46
|
-
|
|
43
|
+
return;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
const data = await response.json();
|
|
50
47
|
let responseText = data.candidates[0].content.parts[0].text;
|
|
51
48
|
|
|
52
|
-
if
|
|
53
|
-
|
|
54
|
-
}
|
|
49
|
+
// Clean up markdown if AI adds it
|
|
50
|
+
responseText = responseText.replace(/```json|```/g, "").trim();
|
|
55
51
|
|
|
56
52
|
const files = JSON.parse(responseText);
|
|
57
53
|
fs.mkdirSync(directoryName, { recursive: true });
|
|
@@ -64,24 +60,32 @@ User Prompt: "${prompt}"`;
|
|
|
64
60
|
console.log(`ā
Created: ${file.filename}`);
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
console.log(`\nš Done!
|
|
63
|
+
console.log(`\nš Done! Your project is ready in the folder: ${directoryName}`);
|
|
68
64
|
|
|
69
65
|
} catch (error) {
|
|
70
66
|
console.error('ā An error occurred:', error.message);
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
70
|
+
// Fixed Yargs setup to prevent ESM errors
|
|
71
|
+
async function startCLI() {
|
|
72
|
+
const yargs = (await import('yargs/yargs')).default;
|
|
73
|
+
const { hideBin } = await import('yargs/helpers');
|
|
74
|
+
|
|
75
|
+
yargs(hideBin(process.argv))
|
|
76
|
+
.command(
|
|
77
|
+
'$0 <prompt>',
|
|
78
|
+
'Generates a full project structure.',
|
|
79
|
+
(yargs) => {
|
|
80
|
+
return yargs
|
|
81
|
+
.positional('prompt', { type: 'string' })
|
|
82
|
+
.option('directory', { alias: 'd', type: 'string', demandOption: true });
|
|
83
|
+
},
|
|
84
|
+
(argv) => {
|
|
85
|
+
generateProject(argv.prompt, argv.directory);
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
.parse();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
startCLI();
|