Update stateManager.js
Browse files- stateManager.js +20 -20
stateManager.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
// stateManager.js
|
| 2 |
const activeProjects = new Map();
|
| 3 |
|
| 4 |
export const StateManager = {
|
|
@@ -23,27 +22,30 @@ export const StateManager = {
|
|
| 23 |
queueCommand: async (projectId, rawResponse) => {
|
| 24 |
const project = activeProjects.get(projectId);
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
let command = null;
|
| 27 |
|
| 28 |
-
// 1. Check for Code Execution (Improved Regex)
|
| 29 |
-
// Matches ```lua, ```luau, or just ``` followed by code
|
| 30 |
const codeMatch = rawResponse.match(/```(?:lua|luau)?([\s\S]*?)```/i);
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if (codeMatch) {
|
| 33 |
command = { type: "EXECUTE", payload: codeMatch[1].trim() };
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
else if (
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
else if (rawResponse.match(/\[READ_HIERARCHY:\s*(.*?)\]/)) {
|
| 42 |
-
const match = rawResponse.match(/\[READ_HIERARCHY:\s*(.*?)\]/);
|
| 43 |
-
command = { type: "READ_HIERARCHY", payload: match[1].trim() };
|
| 44 |
-
}
|
| 45 |
-
// 4. Check for Logs
|
| 46 |
-
else if (rawResponse.includes("[READ_LOGS]")) {
|
| 47 |
command = { type: "READ_LOGS", payload: null };
|
| 48 |
}
|
| 49 |
|
|
@@ -51,9 +53,7 @@ export const StateManager = {
|
|
| 51 |
project.commandQueue.push(command);
|
| 52 |
console.log(`[${projectId}] Queued Action: ${command.type}`);
|
| 53 |
} else {
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
console.log(`[${projectId}] AI Replied (No Action/Chatter):`, rawResponse);
|
| 57 |
}
|
| 58 |
|
| 59 |
activeProjects.set(projectId, project);
|
|
|
|
|
|
|
| 1 |
const activeProjects = new Map();
|
| 2 |
|
| 3 |
export const StateManager = {
|
|
|
|
| 22 |
queueCommand: async (projectId, rawResponse) => {
|
| 23 |
const project = activeProjects.get(projectId);
|
| 24 |
|
| 25 |
+
// If the response is purely a question for the PM, we do NOT queue a command for the plugin.
|
| 26 |
+
// The server handles the question logic internally.
|
| 27 |
+
if (rawResponse.includes("[ASK_PM:")) {
|
| 28 |
+
console.log(`[${projectId}] Skipped Plugin Queue (Internal PM Consultation)`);
|
| 29 |
+
return;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
let command = null;
|
| 33 |
|
|
|
|
|
|
|
| 34 |
const codeMatch = rawResponse.match(/```(?:lua|luau)?([\s\S]*?)```/i);
|
| 35 |
+
const readScriptMatch = rawResponse.match(/\[READ_SCRIPT:\s*(.*?)\]/);
|
| 36 |
+
const readHierarchyMatch = rawResponse.match(/\[READ_HIERARCHY:\s*(.*?)\]/);
|
| 37 |
+
const generateImageMatch = rawResponse.match(/\[GENERATE_IMAGE:\s*(.*?)\]/);
|
| 38 |
+
const readLogsMatch = rawResponse.includes("[READ_LOGS]");
|
| 39 |
+
|
| 40 |
if (codeMatch) {
|
| 41 |
command = { type: "EXECUTE", payload: codeMatch[1].trim() };
|
| 42 |
+
} else if (readScriptMatch) {
|
| 43 |
+
command = { type: "READ_SCRIPT", payload: readScriptMatch[1].trim() };
|
| 44 |
+
} else if (readHierarchyMatch) {
|
| 45 |
+
command = { type: "READ_HIERARCHY", payload: readHierarchyMatch[1].trim() };
|
| 46 |
+
} else if (generateImageMatch) {
|
| 47 |
+
command = { type: "GENERATE_IMAGE", payload: generateImageMatch[1].trim() };
|
| 48 |
+
} else if (readLogsMatch) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
command = { type: "READ_LOGS", payload: null };
|
| 50 |
}
|
| 51 |
|
|
|
|
| 53 |
project.commandQueue.push(command);
|
| 54 |
console.log(`[${projectId}] Queued Action: ${command.type}`);
|
| 55 |
} else {
|
| 56 |
+
if(rawResponse.length < 500) console.log(`[${projectId}] Chatter (No Command):`, rawResponse);
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
activeProjects.set(projectId, project);
|