From 1c85ce772be6ab38ff41402a9bda62f26f0c575f Mon Sep 17 00:00:00 2001 From: Hermes Date: Sat, 23 May 2026 22:40:43 +0000 Subject: [PATCH] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20autom=C3=A1tica:=202026?= =?UTF-8?q?-05-23=2022:40:43?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-interface/public/agents-panel.js | 21 ++++++++++++--- web-interface/public/index-new.html | 6 +++++ web-interface/server.js | 40 ++++++++++++++++++---------- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/web-interface/public/agents-panel.js b/web-interface/public/agents-panel.js index 99ba7ef..cd443d4 100644 --- a/web-interface/public/agents-panel.js +++ b/web-interface/public/agents-panel.js @@ -230,21 +230,34 @@ async function loadDesignerClonesSelect() { async function startDesign() { const selectEl = document.getElementById('designerCloneSelect'); const urlEl = document.getElementById('designUrl'); + const customPathEl = document.getElementById('designerCustomPath'); + const customPath = customPathEl?.value?.trim(); + + // Se informou caminho específico (nova funcionalidade) + if (customPath) { + agentsState.designer.currentClone = { + directory: customPath, + name: customPath.split('/').pop() || 'Site Customizado', + url: customPath, + isCustomPath: true + }; + } // Se escolheu na droplist - if (selectEl && selectEl.value) { + else if (selectEl && selectEl.value) { agentsState.designer.currentClone = { directory: 'cloned-sites/' + selectEl.value, name: selectEl.value.split('_')[0], - url: 'https://' + selectEl.value.split('_')[0] + url: 'https://' + selectEl.value.split('_')[0], + isCustomPath: false }; } else { const url = urlEl?.value?.trim(); if (!url) { - showAgentError('Designer', 'Selecione um site já clonado na lista ou insira uma URL válida.'); + showAgentError('Designer', 'Selecione um site, insira uma URL ou informe um Caminho Específico de pasta.'); return; } - agentsState.designer.currentClone = { url, name: 'Site selecionado' }; + agentsState.designer.currentClone = { url, name: 'Site selecionado', isCustomPath: false }; } setDesignerWorking(true); diff --git a/web-interface/public/index-new.html b/web-interface/public/index-new.html index 819792a..7213ec5 100644 --- a/web-interface/public/index-new.html +++ b/web-interface/public/index-new.html @@ -421,6 +421,12 @@
+ +
+ + + Se preenchido, o agente usará esta pasta exata ignorando a seleção acima. +
diff --git a/web-interface/server.js b/web-interface/server.js index cb25f60..e0821f8 100644 --- a/web-interface/server.js +++ b/web-interface/server.js @@ -670,11 +670,24 @@ app.post('/api/ai/agent', async (req, res) => { // AI Inject Redesign Route (Pilar 1 - Agente Designer Real) app.post('/api/ai/inject-redesign', (req, res) => { - const { cloneDir, appliedStyles, elementsRedesigned, outputDir, agentName } = req.body; + const { cloneDir, appliedStyles, elementsRedesigned, outputDir, agentName, isCustomPath } = req.body; if (!cloneDir) return res.status(400).json({ error: 'cloneDir is required' }); - const originalFolderName = cloneDir.split('/').pop(); - const folderPath = path.join(__dirname, '..', 'cloned-sites', originalFolderName); + let originalFolderName = ''; + let folderPath = ''; + let newFolderPath = ''; + + if (isCustomPath) { + // Se for um caminho customizado absoluto fornecido pelo usuário + folderPath = cloneDir; + originalFolderName = path.basename(folderPath); + newFolderPath = path.join(path.dirname(folderPath), `${originalFolderName}_${agentName || 'designer'}`); + } else { + // Comportamento padrão (lendo da storage interna cloned-sites) + originalFolderName = cloneDir.split('/').pop(); + folderPath = path.join(__dirname, '..', 'cloned-sites', originalFolderName); + newFolderPath = path.join(__dirname, '..', 'cloned-sites', `${originalFolderName}_${agentName || 'designer'}`); + } if (!fs.existsSync(folderPath)) { return res.status(404).json({ error: 'Cloned site folder not found' }); @@ -789,9 +802,6 @@ p, span, li, label, td, th { } `; - const newFolderName = `${originalFolderName}_${agentName || 'designer'}`; - const newFolderPath = path.join(__dirname, '..', 'cloned-sites', newFolderName); - // Copy the original folder to the new folder exec(`cp -r "${folderPath}" "${newFolderPath}"`, (copyErr) => { if (copyErr) { @@ -819,15 +829,17 @@ p, span, li, label, td, th { } } - // 3. Sincronizar o novo diretório com o host - const hostDir = outputDir || '/root/Desktop/Clonados'; - const containerId = require('os').hostname(); - exec(`mkdir -p "${hostDir}" && cp -r "${newFolderPath}" "${hostDir}/" 2>/dev/null || docker cp ${containerId}:"${newFolderPath}" "${hostDir}/" 2>/dev/null`, (syncErr) => { - if (syncErr) console.log('⚠️ Redesign sync to host failed:', syncErr.message); - else console.log('✅ Redesign synced to host output dir:', newFolderName); - }); + // 3. Sincronizar o novo diretório com o host (somente se NÃO for customPath, pois customPath já está no lugar certo) + if (!isCustomPath) { + const hostDir = outputDir || '/root/Desktop/Clonados'; + const containerId = require('os').hostname(); + exec(`mkdir -p "${hostDir}" && cp -r "${newFolderPath}" "${hostDir}/" 2>/dev/null || docker cp ${containerId}:"${newFolderPath}" "${hostDir}/" 2>/dev/null`, (syncErr) => { + if (syncErr) console.log('⚠️ Redesign sync to host failed:', syncErr.message); + else console.log('✅ Redesign synced to host output dir:', path.basename(newFolderPath)); + }); + } - res.json({ success: true, message: 'AI Redesign CSS injected successfully', newFolderName }); + res.json({ success: true, message: 'AI Redesign CSS injected successfully', newFolderName: path.basename(newFolderPath) }); }); } catch (err) { console.error('Error injecting AI redesign:', err);