everydaycats commited on
Commit
f918ae6
Β·
verified Β·
1 Parent(s): c734db0

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +31 -32
app.js CHANGED
@@ -13,8 +13,12 @@ const app = express();
13
  app.use(cors());
14
  app.use(bodyParser.json({ limit: "50mb" }));
15
 
16
- // Options: 'NONE', 'BUILD_PART', 'FETCH_SCRIPT', 'FETCH_LOGS', 'SCAN_HIERARCHY', 'SCAN_SERVER_SERVICE'
17
- const DEMO_MODE = "FETCH_SCRIPT"; // 'SCAN_HIERARCHY';
 
 
 
 
18
 
19
  app.post("/api/ai-build", async (req, res) => {
20
  try {
@@ -22,58 +26,53 @@ app.post("/api/ai-build", async (req, res) => {
22
 
23
  console.log("------------------------------------------------");
24
  console.log("πŸ“₯ INSTRUCTION:", instruction);
25
- if(selection) console.log(" Selected:", selection.name);
26
 
27
- // 1. Script Response
28
  if (scriptContext) {
29
- console.log(`πŸ“˜ SCRIPT [${scriptContext.targetName}]:`);
 
30
  console.log(scriptContext.scriptSource.substring(0, 150) + "...\n");
31
- return res.json({ success: true, message: `Read ${scriptContext.targetName}.` });
32
  }
33
 
34
- // 2. Log Response
35
- if (logContext) {
36
- console.log("πŸ“ LOGS:", logContext.logs.substring(0, 200) + "...");
37
- return res.json({ success: true, message: "Logs analyzed." });
38
- }
39
-
40
- // 3. Hierarchy Response
41
  if (hierarchyContext) {
42
- console.log(`🌳 HIERARCHY [${hierarchyContext.rootName}]:`);
43
- // Limit log output so terminal doesn't flood
44
- const treePreview = hierarchyContext.tree;//.split('\n').slice(0, 200).join('\n');
45
  console.log(treePreview);
46
- //console.log("... (and more)");
47
  return res.json({ success: true, message: `Scanned ${hierarchyContext.rootName}.` });
48
  }
49
 
50
- // 4. Demo Triggers
51
  if (DEMO_MODE === 'BUILD_PART') {
52
- const luaCode = `\`\`\`lua
53
  local p = Instance.new("Part", workspace)
54
  p.Position = Vector3.new(0,20,0)
55
  p.Anchored = true
56
  print("Created Part")
57
- \`\`\``;
58
- return res.send(luaCode);
59
  }
60
  else if (DEMO_MODE === 'FETCH_SCRIPT') {
61
- return res.json({ action: "read_script", targetName: "BikeLogic" });
62
- }
63
- else if (DEMO_MODE === 'SCAN_HIERARCHY') {
64
- // Scans whatever is selected (default behavior)
65
- return res.json({ action: "read_hierarchy",
66
- targetName: "Workspace"
67
- });
68
  }
69
- else if (DEMO_MODE === 'SCAN_SERVER_SERVICE') {
70
- // NEW: Specifically asks to scan ServerScriptService
71
- console.log(" πŸ‘‰ Asking to scan ServerScriptService...");
72
  return res.json({
73
  action: "read_hierarchy",
74
- targetName: "ServerScriptService"
75
  });
76
  }
 
 
 
 
 
77
 
78
  return res.json({ success: true, message: "Thinking..." });
79
 
 
13
  app.use(cors());
14
  app.use(bodyParser.json({ limit: "50mb" }));
15
 
16
+ // === TEST MODES ===
17
+ // 'BUILD_PART' -> Makes a part
18
+ // 'FETCH_SCRIPT' -> Finds a script by name anywhere
19
+ // 'SCAN_SERVER_STORAGE' -> Scans "ServerStorage" explicitly
20
+ // 'SCAN_SELECTION' -> Scans whatever you clicked on in Roblox
21
+ const DEMO_MODE = 'SCAN_SERVER_STORAGE';
22
 
23
  app.post("/api/ai-build", async (req, res) => {
24
  try {
 
26
 
27
  console.log("------------------------------------------------");
28
  console.log("πŸ“₯ INSTRUCTION:", instruction);
 
29
 
30
+ // 1. Script Found
31
  if (scriptContext) {
32
+ console.log(`πŸ“˜ SCRIPT FOUND [${scriptContext.targetName}]:`);
33
+ console.log(` Parent: ${scriptContext.parentName}`);
34
  console.log(scriptContext.scriptSource.substring(0, 150) + "...\n");
35
+ return res.json({ success: true, message: `Read ${scriptContext.targetName} successfully.` });
36
  }
37
 
38
+ // 2. Hierarchy Scanned
 
 
 
 
 
 
39
  if (hierarchyContext) {
40
+ console.log(`🌳 SCANNED HIERARCHY [${hierarchyContext.rootName}]:`);
41
+ const treePreview = hierarchyContext.tree.split('\n').slice(0, 20).join('\n');
 
42
  console.log(treePreview);
 
43
  return res.json({ success: true, message: `Scanned ${hierarchyContext.rootName}.` });
44
  }
45
 
46
+ // 3. Demo Triggers
47
  if (DEMO_MODE === 'BUILD_PART') {
48
+ return res.send(`\`\`\`lua
49
  local p = Instance.new("Part", workspace)
50
  p.Position = Vector3.new(0,20,0)
51
  p.Anchored = true
52
  print("Created Part")
53
+ \`\`\``);
 
54
  }
55
  else if (DEMO_MODE === 'FETCH_SCRIPT') {
56
+ // AI asks to find "MyServerScript" (put this script in ServerScriptService to test)
57
+ console.log(" πŸ‘‰ Asking to find 'MyServerScript'...");
58
+ return res.json({
59
+ action: "read_script",
60
+ targetName: "BikeLogic"
61
+ });
 
62
  }
63
+ else if (DEMO_MODE === 'SCAN_SERVER_STORAGE') {
64
+ // AI explicitly asks to see what's in ServerStorage
65
+ console.log(" πŸ‘‰ Asking to scan ServerStorage...");
66
  return res.json({
67
  action: "read_hierarchy",
68
+ targetName: "ServerStorage"
69
  });
70
  }
71
+ else if (DEMO_MODE === 'SCAN_SELECTION') {
72
+ // AI asks to scan whatever you have selected
73
+ console.log(" πŸ‘‰ Asking to scan selection...");
74
+ return res.json({ action: "read_hierarchy", targetName: "Workspace" });
75
+ }
76
 
77
  return res.json({ success: true, message: "Thinking..." });
78