@sofianedjerbi/knowledge-tree-mcp
Version:
MCP server for hierarchical project knowledge management
92 lines • 2.63 kB
JavaScript
/**
* Relationship-related constants for the Knowledge Tree system
*/
/**
* All available relationship types
*/
export const RELATIONSHIP_TYPES = [
'related',
'supersedes',
'superseded_by',
'conflicts_with',
'implements',
'implemented_by'
];
/**
* Bidirectional relationship types
* These automatically create reverse links when applied
*/
export const BIDIRECTIONAL_RELATIONSHIPS = [
'related',
'conflicts_with'
];
/**
* Inverse relationship mappings
* Used to determine the reverse relationship when creating links
*/
export const INVERSE_RELATIONSHIPS = {
'supersedes': 'superseded_by',
'superseded_by': 'supersedes',
'implements': 'implemented_by',
'implemented_by': 'implements',
'related': 'related',
'conflicts_with': 'conflicts_with'
};
/**
* Relationship display names for UI
*/
export const RELATIONSHIP_DISPLAY_NAMES = {
'related': 'Related To',
'supersedes': 'Supersedes',
'superseded_by': 'Superseded By',
'conflicts_with': 'Conflicts With',
'implements': 'Implements',
'implemented_by': 'Implemented By'
};
/**
* Relationship descriptions for help text
*/
export const RELATIONSHIP_DESCRIPTIONS = {
'related': 'General connection between entries (bidirectional)',
'supersedes': 'This entry replaces the target entry',
'superseded_by': 'This entry is replaced by the target entry',
'conflicts_with': 'Conflicting approaches or patterns (bidirectional)',
'implements': 'This entry implements a pattern defined in the target',
'implemented_by': 'This entry has implementations in the target'
};
/**
* Relationship icons/emojis for display
*/
export const RELATIONSHIP_ICONS = {
'related': '↔️',
'supersedes': '→',
'superseded_by': '←',
'conflicts_with': '⚡',
'implements': '📝',
'implemented_by': '🔧'
};
/**
* Check if a value is a valid relationship type
*/
export function isValidRelationshipType(value) {
return typeof value === 'string' && RELATIONSHIP_TYPES.includes(value);
}
/**
* Check if a relationship type is bidirectional
*/
export function isBidirectionalRelationship(type) {
return BIDIRECTIONAL_RELATIONSHIPS.includes(type);
}
/**
* Get the inverse of a relationship type
*/
export function getInverseRelationship(type) {
return INVERSE_RELATIONSHIPS[type];
}
/**
* Check if two relationship types are inverses of each other
*/
export function areInverseRelationships(type1, type2) {
return INVERSE_RELATIONSHIPS[type1] === type2 || INVERSE_RELATIONSHIPS[type2] === type1;
}
//# sourceMappingURL=relationships.js.map