Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm
Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)
Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability
Migration completed: $(date)
🤖 Clean migration with full functionality preserved
88 lines
3.2 KiB
Python
Executable File
88 lines
3.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Example 2: Token Merging with Conflict Resolution
|
|
|
|
Shows how to merge tokens from multiple sources using different strategies.
|
|
"""
|
|
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
|
|
async def main():
|
|
print("=" * 60)
|
|
print("EXAMPLE 2: Token Merging & Conflict Resolution")
|
|
print("=" * 60)
|
|
|
|
from tools.ingest.merge import TokenMerger, MergeStrategy
|
|
from tools.ingest.base import TokenCollection, DesignToken, TokenType
|
|
|
|
# Create tokens from different sources
|
|
print("\n1. Creating token collections from different sources...")
|
|
print("-" * 60)
|
|
|
|
css_tokens = TokenCollection([
|
|
DesignToken(name="color.primary", value="#FF0000", type=TokenType.COLOR, source="css"),
|
|
DesignToken(name="color.secondary", value="#00FF00", type=TokenType.COLOR, source="css"),
|
|
DesignToken(name="spacing.md", value="16px", type=TokenType.SPACING, source="css"),
|
|
])
|
|
|
|
figma_tokens = TokenCollection([
|
|
DesignToken(name="color.primary", value="#3B82F6", type=TokenType.COLOR, source="figma"),
|
|
DesignToken(name="color.accent", value="#F59E0B", type=TokenType.COLOR, source="figma"),
|
|
])
|
|
|
|
tailwind_tokens = TokenCollection([
|
|
DesignToken(name="color.primary", value="#2563EB", type=TokenType.COLOR, source="tailwind"),
|
|
DesignToken(name="spacing.lg", value="24px", type=TokenType.SPACING, source="tailwind"),
|
|
])
|
|
|
|
print(f"CSS: {len(css_tokens.tokens)} tokens")
|
|
print(f"Figma: {len(figma_tokens.tokens)} tokens")
|
|
print(f"Tailwind: {len(tailwind_tokens.tokens)} tokens")
|
|
|
|
# Test different merge strategies
|
|
strategies = [
|
|
MergeStrategy.FIRST,
|
|
MergeStrategy.LAST,
|
|
MergeStrategy.PREFER_FIGMA,
|
|
]
|
|
|
|
for strategy in strategies:
|
|
print(f"\n2. Merge Strategy: {strategy.value.upper()}")
|
|
print("-" * 60)
|
|
|
|
merger = TokenMerger(strategy=strategy)
|
|
result = merger.merge([css_tokens, figma_tokens, tailwind_tokens])
|
|
|
|
print(f"✅ Merged: {len(result.collection.tokens)} tokens")
|
|
print(f"⚠️ Conflicts: {len(result.conflicts)}")
|
|
|
|
if result.conflicts:
|
|
print("\nConflict Resolutions:")
|
|
for conflict in result.conflicts:
|
|
print(f" • {conflict.token_name}:")
|
|
print(f" Existing: {conflict.existing.value} (from {conflict.existing.source})")
|
|
print(f" Incoming: {conflict.incoming.value} (from {conflict.incoming.source})")
|
|
print(f" ✓ Chose: {conflict.resolved_token.value} (from {conflict.resolved_token.source})")
|
|
|
|
# Show final token values
|
|
print("\nFinal Tokens:")
|
|
for token in result.collection.tokens:
|
|
print(f" {token.name}: {token.value} (source: {token.source})")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("💡 Key Takeaways:")
|
|
print(" • FIRST: Keeps first occurrence, ignores later sources")
|
|
print(" • LAST: Override with latest source")
|
|
print(" • PREFER_FIGMA: Prioritizes Figma as source of truth")
|
|
print(" • PREFER_CODE: Prioritizes code sources (CSS, SCSS)")
|
|
print("=" * 60)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|