mongossee 1.0.29 โ 1.0.31
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 +13 -39
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const { hideBin } = require('yargs/helpers');
|
|
|
9
9
|
const SERVER_URL = "https://mongossee.vercel.app/api/server";
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Generates a full project structure based on a prompt.
|
|
14
15
|
* @param {string} prompt - The user's project request.
|
|
@@ -17,35 +18,8 @@ const SERVER_URL = "https://mongossee.vercel.app/api/server";
|
|
|
17
18
|
async function generateProject(prompt, directoryName) {
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
prompt:
|
|
22
|
-
TASK: Generate a coding project based on this user request: "${prompt}"
|
|
23
|
-
|
|
24
|
-
STRICT TECHNICAL CONSTRAINTS (Follow for every project):
|
|
25
|
-
1. AUTO-DETECT LANGUAGE & TECH:
|
|
26
|
-
- If the request mentions "Typescript" or ".ts/.tsx", use TypeScript strictly.
|
|
27
|
-
- If it mentions React/Components, use React (JSX/TSX).
|
|
28
|
-
- For DSA/Logic, choose Java, Python, or C++ based on context.
|
|
29
|
-
2. TYPESCRIPT RULES: If using TypeScript, define proper Interfaces/Types for Props and State.
|
|
30
|
-
3. REACT RULES: If using React, always use functional components with hooks (useState, useEffect).
|
|
31
|
-
|
|
32
|
-
4. โ REMOVE FALTU STUFF: Do NOT include @testing-library, web-vitals, or eslintConfig.
|
|
33
|
-
5. ๐ง SMART LOGIC: If the prompt says "Logic", "Algorithm", or "DSA", generate only the core logic without UI or framework code
|
|
34
|
-
6. ๐งฑ COMPONENT STRUCTURE: If the prompt mentions "component", "ui", or "frontend", build a complete component with proper imports, exports, and structure.
|
|
35
|
-
|
|
36
|
-
7. โ ZERO COMMENTS: Return strictly functional code. No // or /* */ comments, and no explanations.
|
|
37
|
-
|
|
38
|
-
8. ๐ ARCHITECTURE: If the prompt mentions Parent/Child or Props, strictly follow React best practices (state in parent, props to child, arrow functions for events).
|
|
39
|
-
|
|
40
|
-
9. ๐ FORMAT: Return ONLY a valid JSON array of objects: [{"filename": "string", "code": "string"}].
|
|
41
|
-
|
|
42
|
-
10. ๐ซ NO MARKDOWN: Do not wrap the response in \`\`\`json blocks.
|
|
43
|
-
11. ๐งน CLEAN CODE: Ensure the 'code' string has proper indentation (spaces/tabs) and newlines so it is human-readable after being written to a file. Single-line code is not acceptable.
|
|
44
|
-
12. IMPORTANT: I need 'Pretty-Printed' code. Use multi-line formatting. Single-line code is strictly forbidden.
|
|
45
|
-
13. ๐ ๏ธ BOILERPLATE: Include all necessary boilerplate files (e.g. package.json for Node.js, pom.xml for Java, etc.) based on the detected language and framework.
|
|
46
|
-
14. ๐งฉ FILE STRUCTURE: If the prompt implies multiple files (e.g. "Create a React app with components"), generate a structured file hierarchy with appropriate imports/exports.
|
|
47
|
-
15. ๐งโ๐ป FULL SOURCE CODE: The 'code' field must contain the complete source code for the file, including all necessary imports, exports, and boilerplate. Do not return partial code snippets.
|
|
48
|
-
`
|
|
21
|
+
const body = {
|
|
22
|
+
prompt: prompt // Ye wahi prompt hai jo user terminal mein likhega
|
|
49
23
|
};
|
|
50
24
|
|
|
51
25
|
try {
|
|
@@ -63,16 +37,16 @@ async function generateProject(prompt, directoryName) {
|
|
|
63
37
|
|
|
64
38
|
if (!response.ok || !data.success) {
|
|
65
39
|
const errorMessage = data.error || 'Unknown Server Error';
|
|
66
|
-
console.error(`\n
|
|
40
|
+
console.error(`\n Server Error: ${errorMessage}`);
|
|
67
41
|
if (data.raw_response) {
|
|
68
|
-
|
|
42
|
+
// console.log("Raw Output (Debug):");
|
|
69
43
|
try {
|
|
70
44
|
// AI ka response agar markdown mein ho toh clean karke parse karein
|
|
71
45
|
const cleanRaw = data.raw_response.replace(/```json|```/g, "").trim();
|
|
72
46
|
const prettyJson = JSON.stringify(JSON.parse(cleanRaw), null, 2);
|
|
73
47
|
console.log(prettyJson);
|
|
74
48
|
} catch (e) {
|
|
75
|
-
console.log("Raw Response:", data.raw_response);
|
|
49
|
+
//console.log("Raw Response:", data.raw_response);
|
|
76
50
|
}
|
|
77
51
|
}
|
|
78
52
|
return; // Stop here
|
|
@@ -106,13 +80,13 @@ async function generateProject(prompt, directoryName) {
|
|
|
106
80
|
|
|
107
81
|
if (typeof formattedCode === 'string') {
|
|
108
82
|
formattedCode = formattedCode
|
|
109
|
-
.replace(
|
|
110
|
-
.replace(/\\
|
|
111
|
-
.replace(/\\
|
|
112
|
-
.replace(/\\
|
|
113
|
-
.replace(/\\
|
|
114
|
-
.replace(
|
|
115
|
-
|
|
83
|
+
.replace(/\\\\"/g, '"') // 1. Triple escaped quotes (\\") pehle
|
|
84
|
+
.replace(/\\"/g, '"') // 2. Normal escaped quotes (\")
|
|
85
|
+
.replace(/\\r/g, '') // 3. Carriage returns hatao
|
|
86
|
+
.replace(/\\n/g, '\n') // 4. Newlines (Actual line breaks) ko restore karo ๐
|
|
87
|
+
.replace(/\\t/g, ' ') // 5. Tabs ko 2 spaces banao
|
|
88
|
+
.replace(/\\{2,}/g, '\\') // 6. Multiple backslashes ko handle karo
|
|
89
|
+
.replace(/\\\\/g, '\\'); // 7. Generic backslashes last mein
|
|
116
90
|
}
|
|
117
91
|
|
|
118
92
|
// 2. โจ JSON Pretty-Print Fix:
|