@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
299 lines • 8.12 kB
JavaScript
/**
* Domain-Specific Pattern Definitions for Optimizely
*
* IMPLEMENTATION STATUS:
* COMPLETE: Optimizely-specific terminology and concepts
*
* Last Updated: July 3, 2025
*/
/**
* Optimizely-specific terminology mappings
*/
export const DOMAIN_TERMS = [
// Feature Experimentation terms
{
term: 'feature flag',
canonical: 'flag',
context: 'feature',
entityType: 'flags',
description: 'A feature toggle for controlling feature rollout'
},
{
term: 'toggle',
canonical: 'flag',
context: 'feature',
entityType: 'flags',
description: 'Short for feature toggle'
},
{
term: 'rollout',
canonical: 'rule',
context: 'feature',
entityType: 'rules',
description: 'A rule that controls feature distribution'
},
{
term: 'kill switch',
canonical: 'flag',
context: 'feature',
entityType: 'flags',
description: 'Emergency feature disable mechanism'
},
{
term: 'feature gate',
canonical: 'flag',
context: 'feature',
entityType: 'flags',
description: 'Another term for feature flag'
},
// Web Experimentation terms
{
term: 'A/B test',
canonical: 'experiment',
context: 'web',
entityType: 'experiments',
description: 'Split test comparing variations'
},
{
term: 'split test',
canonical: 'experiment',
context: 'web',
entityType: 'experiments',
description: 'Another term for A/B test'
},
{
term: 'multivariate test',
canonical: 'experiment',
context: 'web',
entityType: 'experiments',
description: 'Test with multiple variables'
},
{
term: 'MVT',
canonical: 'experiment',
context: 'web',
entityType: 'experiments',
description: 'Abbreviation for multivariate test'
},
{
term: 'personalization',
canonical: 'campaign',
context: 'web',
entityType: 'campaigns',
description: 'Targeted experience delivery'
},
// Cross-platform terms
{
term: 'visitor',
canonical: 'user',
context: 'both',
description: 'End user being experimented on'
},
{
term: 'conversion',
canonical: 'event',
context: 'both',
entityType: 'events',
description: 'Goal completion event'
},
{
term: 'goal',
canonical: 'event',
context: 'both',
entityType: 'events',
description: 'Tracked objective'
},
{
term: 'metric',
canonical: 'event',
context: 'both',
entityType: 'events',
description: 'Measured outcome'
},
{
term: 'segment',
canonical: 'audience',
context: 'both',
entityType: 'audiences',
description: 'User grouping'
},
{
term: 'cohort',
canonical: 'audience',
context: 'both',
entityType: 'audiences',
description: 'User group for analysis'
},
// Technical terms
{
term: 'bucketing',
canonical: 'allocation',
context: 'both',
description: 'User assignment to variations'
},
{
term: 'holdback',
canonical: 'exclusion_group',
context: 'both',
description: 'Users excluded from experiments'
},
{
term: 'whitelisting',
canonical: 'forced_variation',
context: 'both',
description: 'Manual user assignment'
},
{
term: 'mutual exclusion',
canonical: 'group',
context: 'web',
entityType: 'groups',
description: 'Experiments that cannot overlap'
},
// Status terms
{
term: 'live',
canonical: 'running',
context: 'both',
description: 'Active state'
},
{
term: 'paused',
canonical: 'not_started',
context: 'both',
description: 'Temporarily stopped'
},
{
term: 'draft',
canonical: 'not_started',
context: 'both',
description: 'Not yet launched'
},
{
term: 'archived',
canonical: 'archived',
context: 'both',
description: 'Completed and stored'
}
];
/**
* Common Optimizely concepts and their query implications
*/
export const DOMAIN_CONCEPTS = {
// Traffic allocation concepts
trafficAllocation: {
terms: ['traffic', 'allocation', 'percentage', 'split'],
implies: {
fields: ['percentage_included', 'traffic_allocation'],
filters: [],
joins: []
}
},
// Targeting concepts
targeting: {
terms: ['targeting', 'audience', 'conditions', 'rules'],
implies: {
fields: ['audience_conditions'],
filters: [],
joins: ['audiences']
}
},
// Performance concepts
performance: {
terms: ['performance', 'results', 'metrics', 'conversion', 'winner'],
implies: {
fields: ['metrics', 'results'],
filters: [],
joins: ['results']
}
},
// Environment concepts
environments: {
terms: ['production', 'staging', 'development', 'environment'],
implies: {
fields: ['environment_key', 'enabled'],
filters: [],
joins: ['flag_environments', 'environments']
}
},
// Time-based concepts
recent: {
terms: ['recent', 'new', 'latest', 'today', 'yesterday'],
implies: {
fields: ['created_time', 'last_modified'],
filters: [{
field: 'created_time',
operator: '>',
value: 'NOW() - INTERVAL 7 DAY'
}],
joins: []
}
},
// Status concepts
active: {
terms: ['active', 'running', 'live', 'enabled'],
implies: {
fields: ['status', 'enabled'],
filters: [{
field: 'status',
operator: 'IN',
value: ['running', 'active']
}],
joins: []
}
}
};
/**
* Apply domain-specific transformations
*/
export function applyDomainTransformations(query) {
let transformed = query.toLowerCase();
const appliedTerms = [];
const impliedConcepts = [];
// Apply term replacements
for (const domainTerm of DOMAIN_TERMS) {
const regex = new RegExp(`\\b${domainTerm.term}\\b`, 'gi');
if (regex.test(transformed)) {
transformed = transformed.replace(regex, domainTerm.canonical);
appliedTerms.push(domainTerm);
}
}
// Detect implied concepts
for (const [conceptName, concept] of Object.entries(DOMAIN_CONCEPTS)) {
for (const term of concept.terms) {
if (new RegExp(`\\b${term}\\b`, 'i').test(query)) {
impliedConcepts.push(conceptName);
break;
}
}
}
return {
transformed,
appliedTerms,
impliedConcepts
};
}
/**
* Get domain context for a query
*/
export function getDomainContext(query) {
const { appliedTerms, impliedConcepts } = applyDomainTransformations(query);
// Determine platform from terms
const featureTerms = appliedTerms.filter(t => t.context === 'feature').length;
const webTerms = appliedTerms.filter(t => t.context === 'web').length;
let platform = 'both';
if (featureTerms > 0 && webTerms === 0)
platform = 'feature';
else if (webTerms > 0 && featureTerms === 0)
platform = 'web';
// Suggest entities based on terms
const suggestedEntities = [...new Set(appliedTerms
.filter(t => t.entityType)
.map(t => t.entityType))];
return {
platform,
concepts: impliedConcepts,
suggestedEntities
};
}
//# sourceMappingURL=DomainPatterns.js.map