mongossee 1.0.27 → 1.0.29
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 +34 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -26,14 +26,25 @@ async function generateProject(prompt, directoryName) {
|
|
|
26
26
|
- If the request mentions "Typescript" or ".ts/.tsx", use TypeScript strictly.
|
|
27
27
|
- If it mentions React/Components, use React (JSX/TSX).
|
|
28
28
|
- For DSA/Logic, choose Java, Python, or C++ based on context.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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.
|
|
37
48
|
`
|
|
38
49
|
};
|
|
39
50
|
|
|
@@ -99,7 +110,21 @@ async function generateProject(prompt, directoryName) {
|
|
|
99
110
|
.replace(/\\r/g, '') // Carriage returns hatao
|
|
100
111
|
.replace(/\\n/g, '\n') // Double backslash ko newline banao
|
|
101
112
|
.replace(/\\t/g, ' ') // Tabs ko spaces banao
|
|
102
|
-
.replace(/\\"/g, '"')
|
|
113
|
+
.replace(/\\"/g, '"') // Escaped quotes ko sahi karo
|
|
114
|
+
.replace(/\\\\"/g, '"'); // Agar AI ne code ko ek single line mein diya hai, toh usko pretty-print karne ki koshish karo
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 2. ✨ JSON Pretty-Print Fix:
|
|
119
|
+
// Agar file .json hai, toh usey dubara parse karke sundar format mein badlo
|
|
120
|
+
if (file.filename.endsWith('.json')) {
|
|
121
|
+
try {
|
|
122
|
+
const jsonObject = JSON.parse(formattedCode);
|
|
123
|
+
formattedCode = JSON.stringify(jsonObject, null, 2);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
// Agar parse fail ho jaye toh purana formatted code hi rehne do
|
|
126
|
+
//console.log(` ${file.filename}`);
|
|
127
|
+
}
|
|
103
128
|
}
|
|
104
129
|
|
|
105
130
|
// Write the code to the file
|