- Add complete modular demo interface (public/modular-pipeline-demo.html) - Add standalone demo server (simple-server.js) on port 3333 - Integrate real SelectiveCore, AdversarialCore, HumanSimulation, PatternBreaking modules - Add configurable pipeline with step-by-step content transformation display - Add new trend management and workflow configuration modules - Add comprehensive test suite for full pipeline validation - Update core modules for better modular integration and demo compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
357 lines
11 KiB
JavaScript
357 lines
11 KiB
JavaScript
// ========================================
|
|
// TREND MANAGER - GESTION TENDANCES PROMPTS
|
|
// Responsabilité: Configuration tendances pour moduler les prompts selon contexte
|
|
// ========================================
|
|
|
|
const { logSh } = require('../ErrorReporting');
|
|
const { tracer } = require('../trace');
|
|
|
|
/**
|
|
* TREND MANAGER
|
|
* Gère les tendances configurables pour adapter les prompts selon le contexte
|
|
*/
|
|
class TrendManager {
|
|
constructor() {
|
|
this.name = 'TrendManager';
|
|
this.currentTrend = null;
|
|
this.customTrends = new Map();
|
|
|
|
// Initialiser les tendances prédéfinies
|
|
this.initializePredefinedTrends();
|
|
}
|
|
|
|
/**
|
|
* TENDANCES PRÉDÉFINIES
|
|
*/
|
|
initializePredefinedTrends() {
|
|
this.predefinedTrends = {
|
|
// ========== TENDANCES SECTORIELLES ==========
|
|
|
|
'eco-responsable': {
|
|
name: 'Eco-Responsable',
|
|
description: 'Accent sur durabilité, écologie, responsabilité environnementale',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['durable', 'écologique', 'responsable', 'recyclé', 'bio', 'naturel'],
|
|
focusAreas: ['impact environnemental', 'cycle de vie', 'matériaux durables']
|
|
},
|
|
style: {
|
|
targetStyle: 'conscient et responsable',
|
|
tone: 'engagé mais pédagogique',
|
|
values: ['durabilité', 'respect environnement', 'qualité long terme']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['jetable', 'synthétique', 'intensive'],
|
|
emphasize: ['naturel', 'durable', 'responsable']
|
|
}
|
|
}
|
|
},
|
|
|
|
'tech-innovation': {
|
|
name: 'Tech Innovation',
|
|
description: 'Focus technologie avancée, innovation, digitalisation',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['intelligent', 'connecté', 'automatisé', 'numérique', 'innovation'],
|
|
focusAreas: ['technologie avancée', 'connectivité', 'automatisation']
|
|
},
|
|
style: {
|
|
targetStyle: 'moderne et dynamique',
|
|
tone: 'enthousiaste et précis',
|
|
values: ['innovation', 'performance', 'efficacité']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['traditionnel', 'manuel', 'basique'],
|
|
emphasize: ['intelligent', 'avancé', 'innovant']
|
|
}
|
|
}
|
|
},
|
|
|
|
'artisanal-premium': {
|
|
name: 'Artisanal Premium',
|
|
description: 'Savoir-faire artisanal, qualité premium, tradition',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['artisanal', 'fait main', 'traditionnel', 'savoir-faire', 'premium'],
|
|
focusAreas: ['qualité artisanale', 'techniques traditionnelles', 'finitions soignées']
|
|
},
|
|
style: {
|
|
targetStyle: 'authentique et raffiné',
|
|
tone: 'respectueux et valorisant',
|
|
values: ['authenticité', 'qualité', 'tradition']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['industriel', 'masse', 'standard'],
|
|
emphasize: ['unique', 'authentique', 'raffiné']
|
|
}
|
|
}
|
|
},
|
|
|
|
// ========== TENDANCES GÉNÉRATIONNELLES ==========
|
|
|
|
'generation-z': {
|
|
name: 'Génération Z',
|
|
description: 'Style moderne, inclusif, digital native',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['tendance', 'viral', 'personnalisable', 'inclusif', 'durable'],
|
|
focusAreas: ['personnalisation', 'impact social', 'durabilité']
|
|
},
|
|
style: {
|
|
targetStyle: 'moderne et inclusif',
|
|
tone: 'décontracté mais informatif',
|
|
values: ['authenticité', 'inclusivité', 'durabilité']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['traditionnel', 'conventionnel'],
|
|
emphasize: ['moderne', 'inclusif', 'authentique']
|
|
}
|
|
}
|
|
},
|
|
|
|
'millenial-pro': {
|
|
name: 'Millennial Pro',
|
|
description: 'Efficacité, équilibre vie-travail, qualité',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['efficace', 'pratique', 'gain de temps', 'qualité de vie'],
|
|
focusAreas: ['efficacité', 'praticité', 'équilibre']
|
|
},
|
|
style: {
|
|
targetStyle: 'pratique et équilibré',
|
|
tone: 'professionnel mais humain',
|
|
values: ['efficacité', 'équilibre', 'qualité']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['compliqué', 'chronophage'],
|
|
emphasize: ['pratique', 'efficace', 'équilibré']
|
|
}
|
|
}
|
|
},
|
|
|
|
// ========== TENDANCES SAISONNIÈRES ==========
|
|
|
|
'automne-cocooning': {
|
|
name: 'Automne Cocooning',
|
|
description: 'Chaleur, confort, intérieur douillet',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['chaleureux', 'confortable', 'douillet', 'cosy', 'réconfortant'],
|
|
focusAreas: ['ambiance chaleureuse', 'confort', 'bien-être']
|
|
},
|
|
style: {
|
|
targetStyle: 'chaleureux et enveloppant',
|
|
tone: 'bienveillant et réconfortant',
|
|
values: ['confort', 'chaleur', 'sérénité']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['froid', 'strict', 'minimaliste'],
|
|
emphasize: ['chaleureux', 'confortable', 'accueillant']
|
|
}
|
|
}
|
|
},
|
|
|
|
'printemps-renouveau': {
|
|
name: 'Printemps Renouveau',
|
|
description: 'Fraîcheur, renouveau, énergie positive',
|
|
config: {
|
|
technical: {
|
|
targetTerms: ['frais', 'nouveau', 'énergisant', 'revitalisant', 'lumineux'],
|
|
focusAreas: ['renouveau', 'fraîcheur', 'dynamisme']
|
|
},
|
|
style: {
|
|
targetStyle: 'frais et dynamique',
|
|
tone: 'optimiste et énergique',
|
|
values: ['renouveau', 'fraîcheur', 'vitalité']
|
|
},
|
|
adversarial: {
|
|
avoidTerms: ['terne', 'monotone', 'statique'],
|
|
emphasize: ['frais', 'nouveau', 'dynamique']
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
logSh(`✅ TrendManager: ${Object.keys(this.predefinedTrends).length} tendances prédéfinies chargées`, 'DEBUG');
|
|
}
|
|
|
|
/**
|
|
* SÉLECTIONNER UNE TENDANCE
|
|
*/
|
|
setTrend(trendId, customConfig = null) {
|
|
return tracer.run('TrendManager.setTrend()', async () => {
|
|
try {
|
|
if (customConfig) {
|
|
// Tendance personnalisée
|
|
this.currentTrend = {
|
|
id: trendId,
|
|
name: customConfig.name || trendId,
|
|
description: customConfig.description || 'Tendance personnalisée',
|
|
config: customConfig.config,
|
|
isCustom: true
|
|
};
|
|
|
|
logSh(`🎯 Tendance personnalisée appliquée: ${trendId}`, 'INFO');
|
|
|
|
} else if (this.predefinedTrends[trendId]) {
|
|
// Tendance prédéfinie
|
|
this.currentTrend = {
|
|
id: trendId,
|
|
...this.predefinedTrends[trendId],
|
|
isCustom: false
|
|
};
|
|
|
|
logSh(`🎯 Tendance appliquée: ${this.currentTrend.name}`, 'INFO');
|
|
|
|
} else if (this.customTrends.has(trendId)) {
|
|
// Tendance personnalisée existante
|
|
const customTrend = this.customTrends.get(trendId);
|
|
this.currentTrend = {
|
|
id: trendId,
|
|
...customTrend,
|
|
isCustom: true
|
|
};
|
|
|
|
logSh(`🎯 Tendance personnalisée appliquée: ${this.currentTrend.name}`, 'INFO');
|
|
|
|
} else {
|
|
throw new Error(`Tendance inconnue: ${trendId}`);
|
|
}
|
|
|
|
await tracer.annotate({
|
|
trendId,
|
|
trendName: this.currentTrend.name,
|
|
isCustom: this.currentTrend.isCustom
|
|
});
|
|
|
|
return this.currentTrend;
|
|
|
|
} catch (error) {
|
|
logSh(`❌ Erreur sélection tendance: ${error.message}`, 'ERROR');
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* APPLIQUER TENDANCE À UNE CONFIGURATION DE COUCHE
|
|
*/
|
|
applyTrendToLayerConfig(layerType, baseConfig = {}) {
|
|
if (!this.currentTrend) {
|
|
return baseConfig;
|
|
}
|
|
|
|
const trendConfig = this.currentTrend.config[layerType];
|
|
if (!trendConfig) {
|
|
return baseConfig;
|
|
}
|
|
|
|
// Fusionner configuration tendance avec configuration de base
|
|
const enhancedConfig = {
|
|
...baseConfig,
|
|
...trendConfig,
|
|
// Préserver les paramètres existants tout en ajoutant la tendance
|
|
trendApplied: this.currentTrend.id,
|
|
trendName: this.currentTrend.name
|
|
};
|
|
|
|
logSh(`🎨 Tendance "${this.currentTrend.name}" appliquée à ${layerType}`, 'DEBUG');
|
|
|
|
return enhancedConfig;
|
|
}
|
|
|
|
/**
|
|
* OBTENIR CONFIGURATION POUR UNE COUCHE SPÉCIFIQUE
|
|
*/
|
|
getLayerConfig(layerType, baseConfig = {}) {
|
|
const config = this.applyTrendToLayerConfig(layerType, baseConfig);
|
|
|
|
return {
|
|
...config,
|
|
_trend: this.currentTrend ? {
|
|
id: this.currentTrend.id,
|
|
name: this.currentTrend.name,
|
|
appliedTo: layerType
|
|
} : null
|
|
};
|
|
}
|
|
|
|
/**
|
|
* LISTER TOUTES LES TENDANCES DISPONIBLES
|
|
*/
|
|
getAvailableTrends() {
|
|
const trends = Object.keys(this.predefinedTrends).map(id => ({
|
|
id,
|
|
name: this.predefinedTrends[id].name,
|
|
description: this.predefinedTrends[id].description,
|
|
category: this.getTrendCategory(id),
|
|
isCustom: false
|
|
}));
|
|
|
|
// Ajouter tendances personnalisées
|
|
for (const [id, trend] of this.customTrends) {
|
|
trends.push({
|
|
id,
|
|
name: trend.name,
|
|
description: trend.description,
|
|
category: 'custom',
|
|
isCustom: true
|
|
});
|
|
}
|
|
|
|
return trends;
|
|
}
|
|
|
|
/**
|
|
* OBTENIR CATÉGORIE D'UNE TENDANCE
|
|
*/
|
|
getTrendCategory(trendId) {
|
|
if (trendId.includes('generation')) return 'générationnelle';
|
|
if (trendId.includes('eco') || trendId.includes('tech') || trendId.includes('artisanal')) return 'sectorielle';
|
|
if (trendId.includes('automne') || trendId.includes('printemps')) return 'saisonnière';
|
|
return 'autre';
|
|
}
|
|
|
|
/**
|
|
* CRÉER UNE TENDANCE PERSONNALISÉE
|
|
*/
|
|
createCustomTrend(id, config) {
|
|
this.customTrends.set(id, config);
|
|
logSh(`✨ Tendance personnalisée créée: ${id}`, 'INFO');
|
|
return config;
|
|
}
|
|
|
|
/**
|
|
* RÉINITIALISER (AUCUNE TENDANCE)
|
|
*/
|
|
clearTrend() {
|
|
this.currentTrend = null;
|
|
logSh('🔄 Aucune tendance appliquée', 'DEBUG');
|
|
}
|
|
|
|
/**
|
|
* OBTENIR TENDANCE ACTUELLE
|
|
*/
|
|
getCurrentTrend() {
|
|
return this.currentTrend;
|
|
}
|
|
|
|
/**
|
|
* OBTENIR STATUT
|
|
*/
|
|
getStatus() {
|
|
return {
|
|
activeTrend: this.currentTrend ? {
|
|
id: this.currentTrend.id,
|
|
name: this.currentTrend.name,
|
|
description: this.currentTrend.description,
|
|
isCustom: this.currentTrend.isCustom
|
|
} : null,
|
|
availableTrends: this.getAvailableTrends().length,
|
|
customTrends: this.customTrends.size
|
|
};
|
|
}
|
|
}
|
|
|
|
// ============= EXPORTS =============
|
|
module.exports = { TrendManager }; |