Atualização automática: 2026-05-23 22:40:43

This commit is contained in:
Hermes
2026-05-23 22:40:43 +00:00
parent 1e421864fa
commit 1c85ce772b
3 changed files with 49 additions and 18 deletions
+17 -4
View File
@@ -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);
+6
View File
@@ -421,6 +421,12 @@
<div class="agent-inputs">
<input type="text" id="designUrl" class="form-control" placeholder="URL do site para redesign...">
<div class="mt-3">
<label><i class="fas fa-folder-open"></i> OU Informar Caminho Específico da Pasta (Host/Diretório)</label>
<input type="text" id="designerCustomPath" class="form-control" placeholder="ex: /root/Desktop/Clonados/meu_site">
<small class="text-muted">Se preenchido, o agente usará esta pasta exata ignorando a seleção acima.</small>
</div>
<button id="startDesignBtn" class="btn btn-primary">
<i class="fas fa-rocket"></i> Iniciar Redesign
</button>
+21 -9
View File
@@ -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
// 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:', newFolderName);
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);