mongossee 1.0.15 ā 1.0.17
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.
Potentially problematic release.
This version of mongossee might be problematic. Click here for more details.
- package/index.js +21 -32
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,8 +5,7 @@ const path = require('path'); // Node.js Path module
|
|
|
5
5
|
const yargs = require('yargs/yargs');
|
|
6
6
|
const { hideBin } = require('yargs/helpers');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
// Filhal ye placeholder rakhein, baad me edit karke update kar dena.
|
|
8
|
+
|
|
10
9
|
const SERVER_URL = "https://mongossee.vercel.app/api/server";
|
|
11
10
|
|
|
12
11
|
|
|
@@ -17,12 +16,7 @@ const SERVER_URL = "https://mongossee.vercel.app/api/server";
|
|
|
17
16
|
*/
|
|
18
17
|
async function generateProject(prompt, directoryName) {
|
|
19
18
|
|
|
20
|
-
// ā ļø CHANGE 3: Hum ab Google ko nahi, apne Server ko call kar rahe hain
|
|
21
|
-
// Note: 'newPrompt' wala logic ab Server (api/server.js) ke paas hai,
|
|
22
|
-
// isliye yahan se hata diya taki code simple rahe.
|
|
23
19
|
|
|
24
|
-
// ā ļø CHANGE: Humne prompt me strict instruction add kar di hai
|
|
25
|
-
// taaki AI response me comments na bheje.
|
|
26
20
|
const body = {
|
|
27
21
|
prompt: prompt + " . IMPORTANT: Return strictly code only. Do not include any comments, docstrings, or explanations inside the code files."
|
|
28
22
|
};
|
|
@@ -36,34 +30,29 @@ async function generateProject(prompt, directoryName) {
|
|
|
36
30
|
body: JSON.stringify(body),
|
|
37
31
|
});
|
|
38
32
|
|
|
39
|
-
if (!response.ok) {
|
|
40
|
-
// Agar server down hai ya error hai
|
|
41
|
-
const errorText = await response.text();
|
|
42
|
-
console.error('ā Server Error:', response.status, errorText);
|
|
43
|
-
throw new Error(`Server request failed with status ${response.status}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
33
|
const data = await response.json();
|
|
47
|
-
let responseText = data.candidates[0].content.parts[0].text;
|
|
48
|
-
|
|
49
|
-
// --- NEW JSON PARSING & FILE CREATION LOGIC ---
|
|
50
|
-
// console.log("Building project...");
|
|
51
34
|
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
// 1. Check Server Success
|
|
36
|
+
// Ab server khud bata dega ki success hua ya fail
|
|
37
|
+
if (!response.ok || !data.success) {
|
|
38
|
+
const errorMessage = data.error || 'Unknown Server Error';
|
|
39
|
+
console.error(`\nā Server Error: ${errorMessage}`);
|
|
40
|
+
if (data.raw_response) {
|
|
41
|
+
console.log("Raw Output (Debug):", data.raw_response);
|
|
42
|
+
}
|
|
43
|
+
return; // Stop here
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
console.error("Raw AI Response:", responseText);
|
|
64
|
-
return;
|
|
46
|
+
// 2. Get Files Directly (No Parsing Needed)
|
|
47
|
+
// Server ne saaf-suthra array bheja hai
|
|
48
|
+
const files = data.files;
|
|
49
|
+
|
|
50
|
+
if (!Array.isArray(files)) {
|
|
51
|
+
throw new Error("Invalid response format: 'files' is not an array.");
|
|
65
52
|
}
|
|
66
53
|
|
|
54
|
+
// --- FILE CREATION LOGIC ---
|
|
55
|
+
|
|
67
56
|
// Create the main project directory
|
|
68
57
|
fs.mkdirSync(directoryName, { recursive: true });
|
|
69
58
|
console.log(``);
|
|
@@ -93,7 +82,7 @@ async function generateProject(prompt, directoryName) {
|
|
|
93
82
|
// --- NEW YARGS SETUP ---
|
|
94
83
|
yargs(hideBin(process.argv))
|
|
95
84
|
.command(
|
|
96
|
-
'$0 <prompt>',
|
|
85
|
+
'$0 <prompt>',
|
|
97
86
|
'Generates a full project structure from a text prompt.',
|
|
98
87
|
(yargs) => {
|
|
99
88
|
return yargs
|
|
@@ -101,11 +90,11 @@ yargs(hideBin(process.argv))
|
|
|
101
90
|
describe: 'The project you want to generate',
|
|
102
91
|
type: 'string',
|
|
103
92
|
})
|
|
104
|
-
.option('directory', {
|
|
93
|
+
.option('directory', {
|
|
105
94
|
alias: 'd',
|
|
106
95
|
describe: 'The name of the new directory to create the project in',
|
|
107
96
|
type: 'string',
|
|
108
|
-
demandOption: true,
|
|
97
|
+
demandOption: true,
|
|
109
98
|
});
|
|
110
99
|
},
|
|
111
100
|
(argv) => {
|