← back to Designer Wallcoverings

DW-Agents/dw-agents/agent-task-orchestrator/inject-theme-styles.js

76 lines

#!/usr/bin/env node
/**
 * Inject Modern Minimalist Theme into all agent HTML
 * This script adds theme styles while preserving existing agent functionality
 */

const fs = require('fs');
const path = require('path');

const AGENTS = [
    'zendesk-chat-agent.ts',
    'marketing-agent.ts',
    'purchasing-office-agent.ts',
    'accounting-agent.ts',
    'digital-samples-agent.ts',
    'trend-research-agent.ts',
    'task-orchestrator-agent.ts',
    'completed-tasks-agent.ts',
    'needs-attention-agent.ts',
    'new-client-signup-agent.ts',
    'todays-highlights-agent.ts',
    'server-uptime-agent.ts',
    'in-parallel-agent.ts',
    'parallel-processes-agent.ts',
];

const THEME_INJECTION = `\${getThemeStyles('modern-minimalist')}`;

console.log('🎨 Injecting Modern Minimalist Theme into agents...\n');

let updated = 0;
let skipped = 0;

AGENTS.forEach(agentFile => {
    const filePath = path.join('/root/Projects/Designer-Wallcoverings/DW-Agents', agentFile);

    if (!fs.existsSync(filePath)) {
        console.log(`⚠️  ${agentFile} not found`);
        skipped++;
        return;
    }

    let content = fs.readFileSync(filePath, 'utf8');

    // Check if already has theme injection
    if (content.includes('getThemeStyles')) {
        console.log(`✅ ${agentFile} already has theme`);
        skipped++;
        return;
    }

    // Find <style> tag in HTML and inject theme before it
    // Pattern: Look for </title> and inject after it
    const titlePattern = /<\/title>/g;

    if (titlePattern.test(content)) {
        content = content.replace(
            /<\/title>/g,
            `</title>\n      \${getThemeStyles('modern-minimalist')}`
        );

        // Write back
        fs.writeFileSync(filePath, content, 'utf8');
        console.log(`✅ ${agentFile} updated with theme`);
        updated++;
    } else {
        console.log(`⚠️  ${agentFile} - couldn't find </title> tag`);
        skipped++;
    }
});

console.log(`\n📊 Summary:`);
console.log(`   ✅ Updated: ${updated}`);
console.log(`   ⏭️  Skipped: ${skipped}`);
console.log(`\n🔄 Next: Restart agents with: pm2 restart all`);