Spaces:
Sleeping
Sleeping
Update app.js
Browse files
app.js
CHANGED
|
@@ -263,7 +263,7 @@ app.post('/new/project', validateRequest, async (req, res) => {
|
|
| 263 |
const { userId, projectId, description } = req.body;
|
| 264 |
try {
|
| 265 |
const pmHistory = [];
|
| 266 |
-
await db.ref(`projects/${projectId}/info/
|
| 267 |
|
| 268 |
const gddPrompt = `Create a comprehensive GDD for: ${description}`;
|
| 269 |
const gddResponse = await AIEngine.callPM(pmHistory, gddPrompt);
|
|
@@ -295,7 +295,9 @@ app.post('/new/project', validateRequest, async (req, res) => {
|
|
| 295 |
});
|
| 296 |
|
| 297 |
await processAndQueueResponse(projectId, workerResponse);
|
| 298 |
-
|
|
|
|
|
|
|
| 299 |
} catch (err) {
|
| 300 |
console.error("Init Error:", err);
|
| 301 |
res.status(500).json({ error: "Initialization Failed" });
|
|
@@ -309,7 +311,9 @@ app.post('/project/feedback', async (req, res) => {
|
|
| 309 |
const project = await StateManager.getProject(projectId);
|
| 310 |
|
| 311 |
if (!project) return res.status(404).json({ error: "Project not found." });
|
| 312 |
-
|
|
|
|
|
|
|
| 313 |
if (taskComplete) {
|
| 314 |
console.log(`[${projectId}] ✅ TASK COMPLETE.`);
|
| 315 |
const summary = `Worker completed the previous task. Logs: ${logContext?.logs || "Clean"}. \nGenerate the NEXT task using 'WORKER_PROMPT:' format.`;
|
|
@@ -412,7 +416,9 @@ app.post('/project/feedback', async (req, res) => {
|
|
| 412 |
});
|
| 413 |
|
| 414 |
await processAndQueueResponse(projectId, response);
|
| 415 |
-
|
|
|
|
|
|
|
| 416 |
} catch (err) {
|
| 417 |
console.error("AI Error:", err);
|
| 418 |
res.status(500).json({ error: "AI Failed" });
|
|
@@ -432,6 +438,7 @@ app.post('/project/ping', async (req, res) => {
|
|
| 432 |
|
| 433 |
if (!project) {
|
| 434 |
// If project doesn't exist in Memory or DB
|
|
|
|
| 435 |
return res.status(404).json({ action: "IDLE", error: "Project not found" });
|
| 436 |
}
|
| 437 |
|
|
|
|
| 263 |
const { userId, projectId, description } = req.body;
|
| 264 |
try {
|
| 265 |
const pmHistory = [];
|
| 266 |
+
await db.ref(`projects/${projectId}/info/status`).set("working");
|
| 267 |
|
| 268 |
const gddPrompt = `Create a comprehensive GDD for: ${description}`;
|
| 269 |
const gddResponse = await AIEngine.callPM(pmHistory, gddPrompt);
|
|
|
|
| 295 |
});
|
| 296 |
|
| 297 |
await processAndQueueResponse(projectId, workerResponse);
|
| 298 |
+
await db.ref(`projects/${projectId}/info/status`).set("working");
|
| 299 |
+
|
| 300 |
+
res.json({ success: true, message: "Workspace Initialized", gddPreview: gddResponse.substring(0, 200) });
|
| 301 |
} catch (err) {
|
| 302 |
console.error("Init Error:", err);
|
| 303 |
res.status(500).json({ error: "Initialization Failed" });
|
|
|
|
| 311 |
const project = await StateManager.getProject(projectId);
|
| 312 |
|
| 313 |
if (!project) return res.status(404).json({ error: "Project not found." });
|
| 314 |
+
|
| 315 |
+
await db.ref(`projects/${projectId}/info/status`).set("working");
|
| 316 |
+
|
| 317 |
if (taskComplete) {
|
| 318 |
console.log(`[${projectId}] ✅ TASK COMPLETE.`);
|
| 319 |
const summary = `Worker completed the previous task. Logs: ${logContext?.logs || "Clean"}. \nGenerate the NEXT task using 'WORKER_PROMPT:' format.`;
|
|
|
|
| 416 |
});
|
| 417 |
|
| 418 |
await processAndQueueResponse(projectId, response);
|
| 419 |
+
await db.ref(`projects/${projectId}/info/status`).set("working");
|
| 420 |
+
|
| 421 |
+
res.json({ success: true });
|
| 422 |
} catch (err) {
|
| 423 |
console.error("AI Error:", err);
|
| 424 |
res.status(500).json({ error: "AI Failed" });
|
|
|
|
| 438 |
|
| 439 |
if (!project) {
|
| 440 |
// If project doesn't exist in Memory or DB
|
| 441 |
+
console.log("project not found in db, id: ", projectId);
|
| 442 |
return res.status(404).json({ action: "IDLE", error: "Project not found" });
|
| 443 |
}
|
| 444 |
|