mongossee 1.0.16 → 1.0.18

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.
Files changed (2) hide show
  1. package/index.js +0 -133
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,133 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs'); // Node.js File System
4
- const path = require('path'); // Node.js Path module
5
- const yargs = require('yargs/yargs');
6
- const { hideBin } = require('yargs/helpers');
7
-
8
- // šŸ‘‡ IMP: Yahan apni Vercel App ka link daalna hoga (Deploy karne ke baad milega)
9
- // Filhal ye placeholder rakhein, baad me edit karke update kar dena.
10
- const SERVER_URL = "https://mongossee.vercel.app/api/server";
11
-
12
-
13
- /**
14
- * Generates a full project structure based on a prompt.
15
- * @param {string} prompt - The user's project request.
16
- * @param {string} directoryName - The name of the folder to create the project in.
17
- */
18
- async function generateProject(prompt, directoryName) {
19
-
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
-
24
- // āš ļø CHANGE: Humne prompt me strict instruction add kar di hai
25
- // taaki AI response me comments na bheje.
26
- const body = {
27
- prompt: prompt + " . IMPORTANT: Return strictly code only. Do not include any comments, docstrings, or explanations inside the code files."
28
- };
29
-
30
- try {
31
- console.log(`Code Running in Expresss`);
32
-
33
- const response = await fetch(SERVER_URL, {
34
- method: 'POST',
35
- headers: { 'Content-Type': 'application/json' },
36
- body: JSON.stringify(body),
37
- });
38
-
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
- const data = await response.json();
47
- let responseText = data.candidates[0].content.parts[0].text;
48
-
49
- // --- 2. UPDATED SMART JSON PARSING (Ye naya hissa hai) ---
50
-
51
- // Code start '[' aur end ']' dhoondho taaki faltu text ignore ho jaye
52
- const jsonStartIndex = responseText.indexOf('[');
53
- const jsonEndIndex = responseText.lastIndexOf(']');
54
-
55
- if (jsonStartIndex === -1 || jsonEndIndex === -1) {
56
- console.error("āŒ ERROR: AI response me Valid JSON nahi mila.");
57
- console.log("Raw Response:", responseText);
58
- return;
59
- }
60
-
61
- // Sirf kaam ka JSON hissa nikalo
62
- let cleanJson = responseText.substring(jsonStartIndex, jsonEndIndex + 1);
63
-
64
- let files;
65
- try {
66
- files = JSON.parse(cleanJson);
67
- } catch (parseError) {
68
- // Agar normal parse fail ho, to control characters hata kar try karo
69
- try {
70
- cleanJson = cleanJson.replace(/[\u0000-\u0019]+/g, "");
71
- files = JSON.parse(cleanJson);
72
- } catch (retryError) {
73
- console.error("āŒ Parsing Failed. Raw Response niche dekhein:");
74
- console.log(responseText);
75
- return;
76
- }
77
- }
78
-
79
- if (!Array.isArray(files)) throw new Error("AI did not return a JSON array.");
80
-
81
- // --- FILE CREATION LOGIC ---
82
-
83
- // Create the main project directory
84
- fs.mkdirSync(directoryName, { recursive: true });
85
- console.log(``);
86
-
87
- // Loop through the files array and create each file
88
- for (const file of files) {
89
- const filePath = path.join(directoryName, file.filename);
90
- const fileDir = path.dirname(filePath);
91
-
92
- // Create subdirectories if they don't exist
93
- if (!fs.existsSync(fileDir)) {
94
- fs.mkdirSync(fileDir, { recursive: true });
95
- }
96
-
97
- // Write the code to the file
98
- fs.writeFileSync(filePath, file.code);
99
- //console.log(`Created file: ${filePath}`);
100
- }
101
-
102
- // console.log(`\nšŸŽ‰ Project "${directoryName}" created successfully!`);
103
-
104
- } catch (error) {
105
- console.error('āŒ An error occurred:', error.message);
106
- }
107
- }
108
-
109
- // --- NEW YARGS SETUP ---
110
- yargs(hideBin(process.argv))
111
- .command(
112
- '$0 <prompt>', // The default command
113
- 'Generates a full project structure from a text prompt.',
114
- (yargs) => {
115
- return yargs
116
- .positional('prompt', {
117
- describe: 'The project you want to generate',
118
- type: 'string',
119
- })
120
- .option('directory', { // Replaces the old 'output' flag
121
- alias: 'd',
122
- describe: 'The name of the new directory to create the project in',
123
- type: 'string',
124
- demandOption: true, // This flag is now required
125
- });
126
- },
127
- (argv) => {
128
-
129
- generateProject(argv.prompt, argv.directory);
130
- }
131
- )
132
- .demandCommand(1, 'Please provide a prompt.')
133
- .parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongossee",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {