diff --git a/web-interface/public/agents-panel.js b/web-interface/public/agents-panel.js
index f9a0967..99ba7ef 100644
--- a/web-interface/public/agents-panel.js
+++ b/web-interface/public/agents-panel.js
@@ -312,21 +312,33 @@ async function applyUltraModernRedesign(cloneDir) {
}
// Injetar o CSS de Redesign Ultra-Moderno gerado pela IA no site clonado
+ let newPreviewUrl = `/api/preview/${cloneDir.split('/').pop()}`;
try {
- await fetch('/api/ai/inject-redesign', {
+ const response = await fetch('/api/ai/inject-redesign', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ cloneDir, appliedStyles, elementsRedesigned })
+ body: JSON.stringify({
+ cloneDir,
+ appliedStyles,
+ elementsRedesigned,
+ outputDir: settings.outputDir,
+ agentName: 'designer'
+ })
});
+ const data = await response.json();
+ if (data.newFolderName) {
+ newPreviewUrl = `/api/preview/${data.newFolderName}`;
+ if (agentsState.designer.currentClone) {
+ agentsState.designer.currentClone.directory = 'cloned-sites/' + data.newFolderName;
+ }
+ }
} catch (e) {
console.error("Erro ao injetar CSS de redesign:", e);
}
- const previewUrl = `/api/preview/${cloneDir.split('/').pop()}`;
-
return {
success: true,
- previewUrl,
+ previewUrl: newPreviewUrl,
appliedStyles,
elementsRedesigned
};
diff --git a/web-interface/public/app-new.js b/web-interface/public/app-new.js
index 9d9c5a7..3ff4601 100644
--- a/web-interface/public/app-new.js
+++ b/web-interface/public/app-new.js
@@ -304,7 +304,10 @@ async function startCloning(url, options) {
response = await fetch('/api/smart-clone', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ url })
+ body: JSON.stringify({
+ url,
+ outputDir: settings.outputDir
+ })
});
} else {
// WGET logic
@@ -313,7 +316,8 @@ async function startCloning(url, options) {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
url,
- depth: options.depth
+ depth: options.depth,
+ outputDir: settings.outputDir
})
});
}
@@ -584,9 +588,13 @@ function loadSettings() {
}
// Populate settings form (if needed)
+ const outDirInput = document.getElementById('settingsOutputDir');
+ if (outDirInput) outDirInput.value = settings.outputDir || '/root/Desktop/Clonados';
}
function saveSettings() {
+ const outDirInput = document.getElementById('settingsOutputDir');
+ if (outDirInput) settings.outputDir = outDirInput.value;
localStorage.setItem('cloneSettings', JSON.stringify(settings));
showToast('Configurações salvas!', 'success');
}
diff --git a/web-interface/public/index-new.html b/web-interface/public/index-new.html
index b4611e3..360706f 100644
--- a/web-interface/public/index-new.html
+++ b/web-interface/public/index-new.html
@@ -250,8 +250,8 @@
Local onde os sites clonados serão salvos
-
-
@@ -293,7 +293,7 @@
-
+
Salvar Configurações
diff --git a/web-interface/server.js b/web-interface/server.js
index 64b73fb..4f3ac19 100644
--- a/web-interface/server.js
+++ b/web-interface/server.js
@@ -301,7 +301,7 @@ app.post('/api/wget-clone', async (req, res) => {
const { exec } = require('child_process');
const containerId = require('os').hostname();
const cloneDir = directory.split('/').pop();
- const hostDir = '/root/Desktop/Clonados';
+ const hostDir = req.body.outputDir || '/root/Desktop/Clonados';
exec(`mkdir -p ${hostDir} && cp -r ${directory} ${hostDir}/ 2>/dev/null || docker cp ${containerId}:${directory} ${hostDir}/ 2>/dev/null`, (err) => {
if (err) console.log('⚠️ Sync to host failed:', err.message);
else console.log('✅ Clone synced to host Desktop:', cloneDir);
@@ -378,7 +378,7 @@ app.post('/api/smart-clone', (req, res) => {
const { exec } = require('child_process');
const containerId = require('os').hostname();
const cloneDir = directory.split('/').pop();
- const hostDir = '/root/Desktop/Clonados';
+ const hostDir = req.body.outputDir || '/root/Desktop/Clonados';
exec(`mkdir -p ${hostDir} && cp -r ${directory} ${hostDir}/ 2>/dev/null || docker cp ${containerId}:${directory} ${hostDir}/ 2>/dev/null`, (err) => {
if (err) console.log('⚠️ SmartClone sync to host failed:', err.message);
else console.log('✅ SmartClone synced to host Desktop:', cloneDir);
@@ -634,11 +634,11 @@ 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 } = req.body;
+ const { cloneDir, appliedStyles, elementsRedesigned, outputDir, agentName } = req.body;
if (!cloneDir) return res.status(400).json({ error: 'cloneDir is required' });
- const folderName = cloneDir.split('/').pop();
- const folderPath = path.join(__dirname, '..', 'cloned-sites', folderName);
+ const originalFolderName = cloneDir.split('/').pop();
+ const folderPath = path.join(__dirname, '..', 'cloned-sites', originalFolderName);
if (!fs.existsSync(folderPath)) {
return res.status(404).json({ error: 'Cloned site folder not found' });
@@ -753,26 +753,46 @@ p, span, li, label, td, th {
}
`;
- const cssPath = path.join(folderPath, '__ai_redesign.css');
- fs.writeFileSync(cssPath, cssContent, 'utf8');
-
- // 2. Injetar a tag no index.html do clone
- const indexPath = path.join(folderPath, 'index.html');
- if (fs.existsSync(indexPath)) {
- let html = fs.readFileSync(indexPath, 'utf8');
- const linkTag = `\n\n`;
-
- if (!html.includes('__ai_redesign.css')) {
- if (html.includes('')) {
- html = html.replace('', linkTag + '');
- } else {
- html = linkTag + html;
- }
- fs.writeFileSync(indexPath, html, 'utf8');
+ 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) {
+ console.error('Error copying folder for agent redesign:', copyErr);
+ return res.status(500).json({ error: 'Failed to create new agent folder' });
}
- }
- res.json({ success: true, message: 'AI Redesign CSS injected successfully' });
+ // 1. Criar o arquivo CSS de Redesign Ultra-Moderno (__ai_redesign.css) no novo diretório
+ const cssPath = path.join(newFolderPath, '__ai_redesign.css');
+ fs.writeFileSync(cssPath, cssContent, 'utf8');
+
+ // 2. Injetar a tag no index.html do novo clone
+ const indexPath = path.join(newFolderPath, 'index.html');
+ if (fs.existsSync(indexPath)) {
+ let html = fs.readFileSync(indexPath, 'utf8');
+ const linkTag = `\n\n`;
+
+ if (!html.includes('__ai_redesign.css')) {
+ if (html.includes('')) {
+ html = html.replace('', linkTag + '');
+ } else {
+ html = linkTag + html;
+ }
+ fs.writeFileSync(indexPath, html, 'utf8');
+ }
+ }
+
+ // 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);
+ });
+
+ res.json({ success: true, message: 'AI Redesign CSS injected successfully', newFolderName });
+ });
} catch (err) {
console.error('Error injecting AI redesign:', err);
res.status(500).json({ error: err.message });