|
| 1 | +# React to Svelte Migration - Agentic Flow Architecture |
| 2 | + |
| 3 | +This diagram shows the complete agentic flow for migrating React components to Svelte in the Blade Design System. |
| 4 | + |
| 5 | +```mermaid |
| 6 | +graph TB |
| 7 | + Start([User: Provide Component Name]) --> Orchestrator[Orchestrator Agent] |
| 8 | + |
| 9 | + Orchestrator --> Phase0[Phase 0: Discovery] |
| 10 | + |
| 11 | + subgraph Phase0["🔍 Phase 0: Discovery Phase"] |
| 12 | + style Phase0 fill:#e3f2fd,stroke:#1976d2,stroke-width:2px |
| 13 | + A1[React Component Discovery Agent] |
| 14 | + A1 --> A1Out[Output: REACT_COMPONENT_DISCOVERY.md] |
| 15 | + end |
| 16 | + |
| 17 | + Phase0 --> Phase1[Phase 1: Planning] |
| 18 | + |
| 19 | + subgraph Phase1["📋 Phase 1: Planning Phase"] |
| 20 | + style Phase1 fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px |
| 21 | + B1[Svelte Migration Planner Agent] |
| 22 | + B1 --> B1Out[Output: MIGRATION_PLAN.md] |
| 23 | + B1Out --> B2[Migration Plan Reviewer Agent] |
| 24 | + B2 --> B2Out[Output: Updated MIGRATION_PLAN.md<br/>with Review] |
| 25 | + end |
| 26 | + |
| 27 | + Phase1 --> Phase2[Phase 2: Execution] |
| 28 | + |
| 29 | + subgraph Phase2["⚙️ Phase 2: Execution Phase"] |
| 30 | + style Phase2 fill:#e8f5e9,stroke:#388e3c,stroke-width:2px |
| 31 | + C1[Svelte Component Executor Agent] |
| 32 | + C1 --> C1Out[Output: MIGRATION_CHANGELOG.md] |
| 33 | + |
| 34 | + C1 -.-> Files1[Creates: Svelte Component Files] |
| 35 | + C1 -.-> Files2[Creates: CSS Modules in blade-core] |
| 36 | + C1 -.-> Files3[Creates/Updates: Utilities in blade-core] |
| 37 | + end |
| 38 | + |
| 39 | + Phase2 --> Phase3[Phase 3: Testing] |
| 40 | + |
| 41 | + subgraph Phase3["🧪 Phase 3: Test & Validation Phase"] |
| 42 | + style Phase3 fill:#fff3e0,stroke:#f57c00,stroke-width:2px |
| 43 | + D1[Svelte Story Creator Agent] |
| 44 | + D1 --> D1Out[Output: STORY_CREATION_LOG.md] |
| 45 | + D1 -.-> Story[Creates: Storybook Stories] |
| 46 | + D1Out --> D2[Svelte Migration Validator Agent] |
| 47 | + D2 --> D2Out[Output: VALIDATION_REPORT.md] |
| 48 | + end |
| 49 | + |
| 50 | + Phase3 --> Decision{Validation<br/>Passed?} |
| 51 | + |
| 52 | + Decision -->|✅ Yes| Success([Migration Complete]) |
| 53 | + Decision -->|❌ No| Review[Review Issues] |
| 54 | + Review --> Phase2 |
| 55 | + |
| 56 | + style Start fill:#fce4ec,stroke:#c2185b,stroke-width:3px |
| 57 | + style Orchestrator fill:#fff9c4,stroke:#f57f17,stroke-width:3px,color:#000 |
| 58 | + style Success fill:#c8e6c9,stroke:#2e7d32,stroke-width:3px |
| 59 | + style Decision fill:#ffccbc,stroke:#d84315,stroke-width:2px |
| 60 | + style Review fill:#ffcdd2,stroke:#c62828,stroke-width:2px |
| 61 | + |
| 62 | + style A1 fill:#bbdefb,stroke:#1565c0,color:#000 |
| 63 | + style A1Out fill:#e3f2fd,stroke:#0d47a1,color:#000 |
| 64 | + |
| 65 | + style B1 fill:#e1bee7,stroke:#6a1b9a,color:#000 |
| 66 | + style B1Out fill:#f3e5f5,stroke:#4a148c,color:#000 |
| 67 | + style B2 fill:#e1bee7,stroke:#6a1b9a,color:#000 |
| 68 | + style B2Out fill:#f3e5f5,stroke:#4a148c,color:#000 |
| 69 | + |
| 70 | + style C1 fill:#c8e6c9,stroke:#2e7d32,color:#000 |
| 71 | + style C1Out fill:#e8f5e9,stroke:#1b5e20,color:#000 |
| 72 | + style Files1 fill:#dcedc8,stroke:#558b2f,color:#000 |
| 73 | + style Files2 fill:#dcedc8,stroke:#558b2f,color:#000 |
| 74 | + style Files3 fill:#dcedc8,stroke:#558b2f,color:#000 |
| 75 | + |
| 76 | + style D1 fill:#ffe0b2,stroke:#e65100,color:#000 |
| 77 | + style D1Out fill:#fff3e0,stroke:#bf360c,color:#000 |
| 78 | + style Story fill:#ffccbc,stroke:#d84315,color:#000 |
| 79 | + style D2 fill:#ffe0b2,stroke:#e65100,color:#000 |
| 80 | + style D2Out fill:#fff3e0,stroke:#bf360c,color:#000 |
| 81 | +``` |
| 82 | + |
| 83 | +## Flow Overview |
| 84 | + |
| 85 | +### Phase 0: Discovery 🔍 |
| 86 | +**Purpose**: Understand the React component structure before migration |
| 87 | + |
| 88 | +1. **React Component Discovery Agent** |
| 89 | + - Analyzes React component in `packages/blade/src/components` |
| 90 | + - Extracts props, dependencies, styling approach |
| 91 | + - Identifies compound components and special features |
| 92 | + - **Output**: `REACT_COMPONENT_DISCOVERY.md` |
| 93 | + |
| 94 | +### Phase 1: Planning 📋 |
| 95 | +**Purpose**: Create and review a detailed migration plan |
| 96 | + |
| 97 | +2. **Svelte Migration Planner Agent** |
| 98 | + - Creates migration plan based on discovery |
| 99 | + - Maps React props to Svelte props |
| 100 | + - Plans CSS module and CVA structure |
| 101 | + - Identifies utilities needed in blade-core |
| 102 | + - **Output**: `MIGRATION_PLAN.md` |
| 103 | + |
| 104 | +3. **Migration Plan Reviewer Agent** |
| 105 | + - Reviews plan for guideline compliance |
| 106 | + - Validates directory structure, CSS approach, CVA usage |
| 107 | + - Ensures no inline styles planned |
| 108 | + - Checks prop consistency |
| 109 | + - **Output**: Updated `MIGRATION_PLAN.md` with review |
| 110 | + |
| 111 | +### Phase 2: Execution ⚙️ |
| 112 | +**Purpose**: Implement the Svelte component |
| 113 | + |
| 114 | +4. **Svelte Component Executor Agent** |
| 115 | + - Creates Svelte component files in `packages/blade-svelte/src/components` |
| 116 | + - Creates CSS modules in `packages/blade-core/src/styles` |
| 117 | + - Adds/updates utilities in `packages/blade-core/src/utils` |
| 118 | + - Implements component following guidelines |
| 119 | + - Uses CVA for conditional styling |
| 120 | + - **Output**: `MIGRATION_CHANGELOG.md` |
| 121 | + |
| 122 | +### Phase 3: Testing & Validation 🧪 |
| 123 | +**Purpose**: Create stories and validate the migration |
| 124 | + |
| 125 | +5. **Svelte Story Creator Agent** |
| 126 | + - Creates comprehensive Storybook stories |
| 127 | + - Tests all props and variants |
| 128 | + - Includes accessibility scenarios |
| 129 | + - **Output**: `STORY_CREATION_LOG.md` + Story files |
| 130 | + |
| 131 | +6. **Svelte Migration Validator Agent** |
| 132 | + - Compares React and Svelte implementations |
| 133 | + - Validates props completeness |
| 134 | + - Checks guidelines compliance |
| 135 | + - Verifies CSS modules, CVA, and utilities |
| 136 | + - Generates quality score |
| 137 | + - **Output**: `VALIDATION_REPORT.md` |
| 138 | + |
| 139 | +### Iteration Loop |
| 140 | +If validation fails, issues are reviewed and execution phase is repeated until validation passes. |
| 141 | + |
| 142 | +## Key Guidelines Enforced |
| 143 | + |
| 144 | +- ✅ Props consistency between React and Svelte |
| 145 | +- ✅ CSS classes only (no inline styles) |
| 146 | +- ✅ CVA for conditional styling |
| 147 | +- ✅ Utilities in blade-core (platform-agnostic) |
| 148 | +- ✅ Prop-based event handlers |
| 149 | +- ✅ PascalCase naming conventions |
| 150 | +- ✅ Compound components structure |
| 151 | +- ✅ TypeScript strict checks |
| 152 | + |
| 153 | +## File Outputs |
| 154 | + |
| 155 | +All log files are created in: |
| 156 | +``` |
| 157 | +.cursor/agents/.logs/{component_name}/ |
| 158 | +├── REACT_COMPONENT_DISCOVERY.md |
| 159 | +├── MIGRATION_PLAN.md |
| 160 | +├── MIGRATION_CHANGELOG.md |
| 161 | +├── STORY_CREATION_LOG.md |
| 162 | +└── VALIDATION_REPORT.md |
| 163 | +``` |
| 164 | + |
| 165 | +## Usage |
| 166 | + |
| 167 | +To start the migration flow: |
| 168 | + |
| 169 | +```bash |
| 170 | +/react-to-svelte-migration-orchestrator component_name: "ComponentName" |
| 171 | +``` |
| 172 | + |
| 173 | +Example: |
| 174 | +```bash |
| 175 | +/react-to-svelte-migration-orchestrator component_name: "Badge" |
| 176 | +``` |
| 177 | + |
0 commit comments