ai-codegen-cli-vrk 2.0.4 → 2.0.5
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/package.json +1 -1
- package/src/aiClient.js +25 -9
- package/src/runner.js +3 -1
package/package.json
CHANGED
package/src/aiClient.js
CHANGED
|
@@ -28,11 +28,27 @@ export async function generateFullProject(task, tests, retryCount = 0) {
|
|
|
28
28
|
const modelPath = await findActiveModel();
|
|
29
29
|
const url = `https://generativelanguage.googleapis.com/v1/${modelPath}:generateContent?key=${API_KEY}`;
|
|
30
30
|
|
|
31
|
-
const prompt = `
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const prompt = `
|
|
32
|
+
Generate the ENTIRE project in a SINGLE response.
|
|
33
|
+
Strictly pass all test cases.
|
|
34
|
+
|
|
35
|
+
### FORMATTING:
|
|
36
|
+
File headers must be exactly:
|
|
37
|
+
// ==========================================
|
|
38
|
+
// FILE: path/to/filename.js
|
|
39
|
+
// ==========================================
|
|
40
|
+
|
|
41
|
+
TASK:
|
|
42
|
+
${task}
|
|
43
|
+
|
|
44
|
+
TESTS:
|
|
45
|
+
${tests}
|
|
46
|
+
|
|
47
|
+
### RULES:
|
|
48
|
+
- Minimalist logic only.
|
|
49
|
+
- Bare minimum code to pass.
|
|
50
|
+
- No talk or explanations.
|
|
51
|
+
`;
|
|
36
52
|
|
|
37
53
|
const response = await fetch(url, {
|
|
38
54
|
method: "POST",
|
|
@@ -42,10 +58,10 @@ TESTS: ${tests}`;
|
|
|
42
58
|
|
|
43
59
|
const data = await response.json();
|
|
44
60
|
|
|
45
|
-
//
|
|
46
|
-
if ((response.status === 503 || response.status === 429) && retryCount <
|
|
47
|
-
console.log(`..... (
|
|
48
|
-
await new Promise(r => setTimeout(r,
|
|
61
|
+
// If overloaded (503) or rate limited (429), wait 10 seconds and retry
|
|
62
|
+
if ((response.status === 503 || response.status === 429) && retryCount < 5) {
|
|
63
|
+
console.log(`..... (Server busy, waiting 10s to retry ${retryCount + 1}/5)`);
|
|
64
|
+
await new Promise(r => setTimeout(r, 10000));
|
|
49
65
|
return generateFullProject(task, tests, retryCount + 1);
|
|
50
66
|
}
|
|
51
67
|
|
package/src/runner.js
CHANGED
|
@@ -4,14 +4,16 @@ import { setApiKey, generateFullProject } from "./aiClient.js";
|
|
|
4
4
|
import { writeSingleFile } from "./fileWriter.js";
|
|
5
5
|
|
|
6
6
|
async function main() {
|
|
7
|
-
//
|
|
7
|
+
// Input API Key - set to visible
|
|
8
8
|
const apiKey = readlineSync.question("--- ", { hideEchoBack: false });
|
|
9
9
|
if (!apiKey || apiKey.trim().length === 0) process.exit(1);
|
|
10
10
|
setApiKey(apiKey.trim());
|
|
11
11
|
|
|
12
|
+
// Input Task
|
|
12
13
|
const task = readlineSync.question("- ");
|
|
13
14
|
if (!task || task.trim().length === 0) process.exit(1);
|
|
14
15
|
|
|
16
|
+
// Input Tests
|
|
15
17
|
const testsInput = readlineSync.question("-- ");
|
|
16
18
|
let tests = "";
|
|
17
19
|
try {
|