mongossee 1.0.11 → 1.0.12

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 +1 -131
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,131 +1 @@
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
- // ⚠️ Paste your official Google Gemini API key here.
9
- const part1 = "AIzaSyCxR0aATnWVzi";
10
- const part2= "TaM2fojD0l5KLpI5LJK2U";
11
-
12
- const API_KEY = part1 + part2;
13
-
14
-
15
- /**
16
- * Generates a full project structure based on a prompt.
17
- * @param {string} prompt - The user's project request.
18
- * @param {string} directoryName - The name of the folder to create the project in.
19
- */
20
- async function generateProject(prompt, directoryName) {
21
- const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${API_KEY}`;
22
-
23
- // --- This is the new, "smarter" prompt ---
24
- // We are asking the AI to act as a file structure generator
25
- // and return a specific JSON format.
26
- const newPrompt = `
27
- You are an expert software developer and project scaffolder.
28
- Based on the user's prompt, generate a complete file structure as a JSON array.
29
- Each object in the array must have two keys:
30
- 1. "filename": (string) The full relative path for the file (e.g., "index.html", "src/styles.css", "js/app.js").
31
- 2. "code": (string) The complete code for that file.
32
-
33
- Only return the raw JSON array, with no other text, explanations, or markdown fences.
34
-
35
- User Prompt: "${prompt}"
36
- `;
37
-
38
- const body = {
39
- contents: [{ parts: [{ text: newPrompt }] }]
40
- };
41
-
42
- try {
43
- console.log(`Code Running in Expresss`);
44
-
45
- const response = await fetch(url, {
46
- method: 'POST',
47
- headers: { 'Content-Type': 'application/json' },
48
- body: JSON.stringify(body),
49
- });
50
-
51
- if (!response.ok) {
52
- const errorData = await response.json();
53
- console.error('❌ API Error Details:', JSON.stringify(errorData.error, null, 2));
54
- throw new Error(`API request failed with status ${response.status}`);
55
- }
56
-
57
- const data = await response.json();
58
- let responseText = data.candidates[0].content.parts[0].text;
59
-
60
- // --- NEW JSON PARSING & FILE CREATION LOGIC ---
61
- // console.log("Building project...");
62
-
63
- // Clean up potential markdown fences from the AI's response
64
- if (responseText.startsWith("```json")) {
65
- responseText = responseText.substring(7, responseText.length - 3).trim();
66
- }
67
-
68
- let files;
69
- try {
70
- files = JSON.parse(responseText);
71
- if (!Array.isArray(files)) throw new Error("AI did not return a JSON array.");
72
- } catch (parseError) {
73
- console.error("❌ ERROR: Failed to parse the AI's response. The response was not valid JSON.");
74
- console.error("Raw AI Response:", responseText);
75
- return;
76
- }
77
-
78
- // Create the main project directory
79
- fs.mkdirSync(directoryName, { recursive: true });
80
- console.log(``);
81
-
82
- // Loop through the files array and create each file
83
- for (const file of files) {
84
- const filePath = path.join(directoryName, file.filename);
85
- const fileDir = path.dirname(filePath);
86
-
87
- // Create subdirectories if they don't exist
88
- if (!fs.existsSync(fileDir)) {
89
- fs.mkdirSync(fileDir, { recursive: true });
90
- }
91
-
92
- // Write the code to the file
93
- fs.writeFileSync(filePath, file.code);
94
- //console.log(`Created file: ${filePath}`);
95
- }
96
-
97
- // console.log(`\n🎉 Project "${directoryName}" created successfully!`);
98
-
99
- } catch (error) {
100
- console.error('❌ An error occurred:', error.message);
101
- }
102
- }
103
-
104
- // --- NEW YARGS SETUP ---
105
- yargs(hideBin(process.argv))
106
- .command(
107
- '$0 <prompt>', // The default command
108
- 'Generates a full project structure from a text prompt.',
109
- (yargs) => {
110
- return yargs
111
- .positional('prompt', {
112
- describe: 'The project you want to generate',
113
- type: 'string',
114
- })
115
- .option('directory', { // Replaces the old 'output' flag
116
- alias: 'd',
117
- describe: 'The name of the new directory to create the project in',
118
- type: 'string',
119
- demandOption: true, // This flag is now required
120
- });
121
- },
122
- (argv) => {
123
- if (!API_KEY || API_KEY === "YOUR_GEMINI_API_KEY_HERE") {
124
- console.error('❌ ERROR: Please add your API key to the index.js file.');
125
- return;
126
- }
127
- generateProject(argv.prompt, argv.directory);
128
- }
129
- )
130
- .demandCommand(1, 'Please provide a prompt.')
131
- .parse();
1
+ link
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongossee",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {