File size: 34,359 Bytes
b143d69
 
 
 
c4b9fba
 
 
 
 
 
 
 
64ebfd5
 
 
 
 
 
c4b9fba
b143d69
 
 
 
 
 
 
c4b9fba
b143d69
 
 
 
 
c4b9fba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b143d69
 
 
 
 
 
 
 
c4b9fba
b143d69
 
c4b9fba
b143d69
 
 
 
 
 
 
c4b9fba
b143d69
 
 
 
 
 
 
 
 
 
c4b9fba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b143d69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b9fba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b569ba
 
c4b9fba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b569ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64ebfd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b9fba
 
64ebfd5
c4b9fba
64ebfd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b9fba
 
 
b143d69
 
5b569ba
b143d69
 
 
 
 
 
5b569ba
c4b9fba
 
 
 
 
5b569ba
 
c4b9fba
b143d69
64ebfd5
5b569ba
 
 
 
 
 
 
 
 
64ebfd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b143d69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b9fba
b143d69
 
 
 
 
c4b9fba
 
 
 
64ebfd5
c4b9fba
64ebfd5
 
 
 
 
b143d69
 
 
 
c4b9fba
 
 
 
64ebfd5
b143d69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64ebfd5
 
 
 
b143d69
 
64ebfd5
b143d69
 
 
 
 
64ebfd5
 
b143d69
 
 
64ebfd5
b143d69
 
 
 
64ebfd5
b143d69
 
64ebfd5
b143d69
 
64ebfd5
b143d69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b9fba
b143d69
c4b9fba
b143d69
 
c4b9fba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b143d69
 
 
c4b9fba
 
 
 
 
 
 
 
 
 
 
 
 
b143d69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b9fba
 
b143d69
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
# Design System Extractor v2 β€” Master Context File

> **Upload this file to refresh Claude's context when continuing work on this project.**

**Last Updated:** January 2026

---

## πŸ“ Files Changed in Latest Session

| File | What Changed |
|------|--------------|
| `agents/extractor.py` | Enhanced 7-source extraction (DOM, CSS vars, SVG, inline, stylesheets, external CSS, page scan) |
| `agents/firecrawl_extractor.py` | **NEW** Agent 1B for deep CSS parsing |
| `agents/semantic_analyzer.py` | **NEW** Agent 1C for semantic color categorization (brand/text/bg/border) |
| `core/preview_generator.py` | AS-IS previews + Color Ramps sorted by brand priority |
| `app.py` | Stage 1 UI now has 6 preview tabs including Semantic Colors |
| `docs/CONTEXT.md` | Updated with semantic analyzer, full architecture diagrams |

---

## 🎯 Project Goal

Build a **semi-automated, human-in-the-loop agentic system** that:
1. Reverse-engineers a design system from a live website
2. Reconstructs and upgrades it into a modern, scalable design system
3. Outputs production-ready JSON tokens (Figma Tokens Studio compatible)

**Philosophy:** This is a design-aware co-pilot, NOT a magic button. Humans decide, agents propose.

---

## πŸ€” Why This Project? (Market Differentiation)

### The Problem We Solve

| Pain Point | Who Has It | Current Solutions | Why They Fail |
|------------|------------|-------------------|---------------|
| Legacy websites with no design system | Enterprise teams | Manual audit (weeks) | Time-consuming, error-prone |
| Inconsistent design tokens scattered in CSS | Agencies inheriting projects | Figma plugins (style extractors) | Only extract from Figma, not live sites |
| Need to modernize without breaking existing | Product teams | Design system generators | Generate new, don't reverse-engineer existing |
| AA compliance gaps unknown | Accessibility teams | Contrast checkers | Check one color at a time, no system view |

### Existing Tools & Their Gaps

| Tool | What It Does | Gap We Fill |
|------|--------------|-------------|
| **Figma Tokens Studio** | Manages tokens in Figma | Doesn't extract from websites |
| **Style Dictionary** | Transforms tokens to code | Needs tokens first (we create them) |
| **Polypane/VisBug** | Inspect live sites | No systematic extraction or upgrade |
| **AI Design Tools** (Galileo, Uizard) | Generate new designs | Don't reverse-engineer existing |
| **CSS Stats** | Analyze CSS files | Statistics only, no actionable tokens |
| **Chromatic/Percy** | Visual regression | Compare, don't extract or upgrade |

### Our Unique Value Proposition

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     WHAT MAKES US DIFFERENT                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚  1. REVERSE-ENGINEERING (not generation)                                    β”‚
β”‚     β€’ Extracts from LIVE websites, not design files                         β”‚
β”‚     β€’ Preserves what's working, upgrades what's broken                      β”‚
β”‚     β€’ Respects existing brand decisions                                     β”‚
β”‚                                                                             β”‚
β”‚  2. MULTI-AGENT REASONING (not single LLM)                                  β”‚
β”‚     β€’ Two analysts with different perspectives                              β”‚
β”‚     β€’ HEAD compiler resolves conflicts                                      β”‚
β”‚     β€’ Shows reasoning, not just results                                     β”‚
β”‚                                                                             β”‚
β”‚  3. HUMAN-IN-THE-LOOP (not magic button)                                    β”‚
β”‚     β€’ Designer reviews every stage                                          β”‚
β”‚     β€’ Accept/reject individual tokens                                       β”‚
β”‚     β€’ Choose from upgrade OPTIONS, not forced decisions                     β”‚
β”‚                                                                             β”‚
β”‚  4. VISUAL PREVIEWS (not just data tables)                                  β”‚
β”‚     β€’ Typography rendered in actual detected font                           β”‚
β”‚     β€’ Color ramps with AA compliance per shade                              β”‚
β”‚     β€’ See before you export                                                 β”‚
β”‚                                                                             β”‚
β”‚  5. COST-TRANSPARENT (not black box)                                        β”‚
β”‚     β€’ Shows token usage and cost per analysis                               β”‚
β”‚     β€’ Uses HF free tier ($0.10/mo) or Pro ($2/mo)                          β”‚
β”‚     β€’ ~$0.05 per full analysis                                              β”‚
β”‚                                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Target Users

| User | Use Case | Value |
|------|----------|-------|
| **UX Managers** (like you!) | Modernize legacy booking platforms | Weeks β†’ Hours |
| **Design System Teams** | Audit and standardize existing properties | Systematic, not ad-hoc |
| **Agencies** | Onboard client projects with no documentation | Instant design inventory |
| **Accessibility Consultants** | AA compliance audit with fixes | Full palette view |
| **Developers** | Get production-ready tokens from designer's website | No manual translation |

### Why Not Just Use [X]?

**"Why not just inspect the CSS manually?"**
β†’ You could, but it takes weeks for a complex site. We do it in minutes with systematic coverage.

**"Why not use Figma's native styles?"**
β†’ Many legacy sites were never in Figma. We extract from the source of truth: the live website.

**"Why do you need AI? Can't rules handle this?"**
β†’ Rules extract tokens. AI understands *design intent* β€” why is this color used here? What scale was intended? Where does it deviate from best practices?

**"Isn't this just CSS Stats with AI?"**
β†’ CSS Stats tells you what exists. We tell you what it *should* be and give you actionable upgrade paths.

---

## πŸ—οΈ Architecture Overview

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              TECH STACK                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Frontend:        Gradio (long-scroll, sectioned UI with live preview)      β”‚
β”‚  Orchestration:   LangGraph (agent state management & workflow)             β”‚
β”‚  Models:          HuggingFace Inference Providers (Novita, Groq, etc.)     β”‚
β”‚  Hosting:         Hugging Face Spaces                                       β”‚
β”‚  Storage:         HF Spaces persistent storage                              β”‚
β”‚  Output:          Platform-agnostic JSON tokens (Figma Tokens Studio)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## 🧠 Model Assignments

### Stage 2: Multi-Agent Analysis

| Agent | Role | Model | Provider | Cost |
|-------|------|-------|----------|------|
| **LLM 1** | Design Analyst 1 | `Qwen/Qwen2.5-72B-Instruct` | Novita | $0.29/M in, $0.59/M out |
| **LLM 2** | Design Analyst 2 | `meta-llama/Llama-3.3-70B-Instruct` | Novita | $0.59/M in, $0.79/M out |
| **HEAD** | Compiler | `meta-llama/Llama-3.3-70B-Instruct` | Novita | $0.59/M in, $0.79/M out |
| **Rules** | Calculations | None (Rule-based) | β€” | FREE |

**Architecture:**
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         PARALLEL ANALYSIS                                    β”‚
β”‚                                                                             β”‚
β”‚   LLM 1 (Qwen)          LLM 2 (Llama)         Rule Engine                  β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚   β”‚ Global   β”‚          β”‚ Western  β”‚          β”‚ Math     β”‚                 β”‚
β”‚   β”‚ Design   β”‚          β”‚ Design   β”‚          β”‚ Only     β”‚                 β”‚
β”‚   β”‚ Patterns β”‚          β”‚ Patterns β”‚          β”‚ (FREE)   β”‚                 β”‚
β”‚   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚        β”‚                     β”‚                     β”‚                        β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β”‚                              β”‚                                              β”‚
β”‚                              β–Ό                                              β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                      β”‚
β”‚                    β”‚   HEAD COMPILER β”‚                                      β”‚
β”‚                    β”‚                 β”‚                                      β”‚
β”‚                    β”‚ β€’ Compare views β”‚                                      β”‚
β”‚                    β”‚ β€’ Resolve diff  β”‚                                      β”‚
β”‚                    β”‚ β€’ Final recs    β”‚                                      β”‚
β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Other Agents

| Agent | Role | Model | Provider | Why |
|-------|------|-------|----------|-----|
| **Agent 1** | Crawler & Extractor | None (Rule-based) | β€” | Pure CSS extraction, no LLM needed |
| **Agent 2** | Normalizer | `microsoft/Phi-3.5-mini-instruct` | Novita | Fast, great structured output |
| **Agent 4** | Generator | `mistralai/Codestral-22B-v0.1` | Novita | Code specialist, JSON formatting |

### Provider Configuration

Default provider: **Novita** (configurable in `config/agents.yaml`)

Available providers (via HuggingFace Inference Providers):
- **novita** - Default, good balance
- **groq** - Fastest
- **cerebras** - Ultra-fast
- **sambanova** - Good for Llama
- **together** - Wide model selection

### Cost Tracking

Estimated cost per Stage 2 analysis: **~$0.05**
- Free tier: $0.10/month
- Pro tier: $2.00/month ($9/mo subscription)

---

## πŸ‘οΈ Visual Previews

### Stage 1: AS-IS Previews (No Enhancements)

Shows raw extracted values exactly as found on the website:

| Preview | What It Shows |
|---------|---------------|
| **Typography** | Actual font rendered with detected styles |
| **Colors** | Simple swatches with hex, frequency, context, AA status |
| **Spacing** | Visual bars representing each spacing value |
| **Radius** | Boxes with each border-radius applied |
| **Shadows** | Cards with each box-shadow applied |

### Stage 2: Enhanced Previews (Upgraded)

Shows proposed upgrades and improvements:

| Preview | What It Shows |
|---------|---------------|
| **Typography** | Type scale comparison (1.2, 1.25, 1.333 ratios) |
| **Color Ramps** | 11 shades (50-950) with AA compliance per shade |

---

## πŸ” Enhanced Extraction (Agent 1)

Agent 1 now extracts from **5 sources** to capture ALL colors:

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ENHANCED EXTRACTION SOURCES                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚  1. DOM Computed Styles                                                     β”‚
β”‚     β€’ window.getComputedStyle(element)                                      β”‚
β”‚     β€’ Captures: color, background-color, border-color, etc.                 β”‚
β”‚                                                                             β”‚
β”‚  2. CSS Variables                                                           β”‚
β”‚     β€’ :root { --primary-color: #3860be; }                                  β”‚
β”‚     β€’ Parses all stylesheets for CSS custom properties                     β”‚
β”‚                                                                             β”‚
β”‚  3. SVG Colors                                                              β”‚
β”‚     β€’ <svg fill="#00c4cc">                                                 β”‚
β”‚     β€’ <path stroke="#3860be">                                              β”‚
β”‚                                                                             β”‚
β”‚  4. Inline Styles                                                           β”‚
β”‚     β€’ <div style="background-color: #bcd432;">                             β”‚
β”‚     β€’ Parses style attributes for color values                             β”‚
β”‚                                                                             β”‚
β”‚  5. Stylesheet Rules                                                        β”‚
β”‚     β€’ Parses CSS rules that may not be applied to visible elements         β”‚
β”‚     β€’ Catches hover states, pseudo-elements, etc.                          β”‚
β”‚                                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## πŸ“‹ Enhanced Logging

### Stage 1 Extraction Logs

Shows detailed extraction progress:
```
============================================================
πŸ–₯️ DESKTOP EXTRACTION (1440px)
============================================================

πŸ“‘ Enhanced extraction from 5 sources:
   1. DOM computed styles (getComputedStyle)
   2. CSS variables (:root { --color: })
   3. SVG colors (fill, stroke)
   4. Inline styles (style='color:')
   5. Stylesheet rules (CSS files)
   6. External CSS files (fetch & parse)
   7. Page content scan (brute-force)

πŸ“Š EXTRACTION RESULTS:
   Colors:     45 unique
   Typography: 12 styles
   Spacing:    28 values
   Radius:     8 values
   Shadows:    4 values

🎨 CSS Variables found: 15
   --primary-color: #3860be
   --accent-color: #00c4cc
   --brand-lime: #bcd432
   ... and 12 more

πŸ”„ Normalizing (deduping, naming)...
   βœ… Normalized: 32 colors, 10 typography, 18 spacing

============================================================
πŸ”₯ FIRECRAWL CSS EXTRACTION
============================================================

   🌐 Scraping: https://example.com
   βœ… Page scraped (125000 chars)
   πŸ“ Parsing <style> blocks...
      Found 5 style blocks
   πŸ”— Finding linked CSS files...
      Found 8 CSS files
   πŸ“„ Fetching: main.css...
      βœ… Parsed (234 colors)
   πŸ“„ Fetching: theme.css...
      βœ… Parsed (45 colors)

πŸ“Š FIRECRAWL RESULTS:
   CSS files parsed:    8
   Style blocks parsed: 5
   CSS variables found: 23
   Unique colors found: 156

   🎨 Top colors found:
      #06b2c4 (used 45x)
      #c1df1f (used 38x)
      #373737 (used 120x)

πŸ”€ Merging Firecrawl colors with Playwright extraction...
   βœ… Added 12 new colors from Firecrawl
   πŸ“Š Total colors now: 44

============================================================
🧠 SEMANTIC COLOR ANALYSIS
============================================================

   πŸ“Š Analyzing 143 colors...
   Using rule-based analysis (no LLM)

πŸ“Š SEMANTIC ANALYSIS RESULTS:

   🎨 BRAND COLORS:
      primary: #06b2c4 (high)
         └─ Most frequent saturated color on interactive elements (freq: 33)
      secondary: #c1df1f (medium)
         └─ Second most frequent brand color (freq: 15)

   πŸ“ TEXT COLORS:
      primary: #373737 (high)
      secondary: #666666 (medium)

   πŸ–ΌοΈ BACKGROUND COLORS:
      primary: #ffffff (high)
      secondary: #f5f5f5 (medium)

   πŸ“ˆ SUMMARY:
      Total colors analyzed: 143
      Brand colors found: 2
      Clear hierarchy: Yes
      Analysis method: rule-based
```

### Stage 2 LLM Analysis Logs (With Semantic Context)

Shows detailed reasoning from each agent WITH semantic context:

```
============================================================
🧠 STAGE 2: MULTI-AGENT ANALYSIS
============================================================

🧠 SEMANTIC CONTEXT FROM STAGE 1:
   Brand Primary: #06b2c4
   Text Primary: #373737
   Analysis Method: rule-based

=======================================================
πŸ€– LLM 1: meta-llama/Llama-3.1-70B-Instruct
=======================================================
   Provider: novita
   πŸ’° Cost: $0.29/M in, $0.59/M out
   πŸ“ Task: Typography, Colors, AA, Spacing analysis
   🧠 Semantic context: Yes  ← NEW: LLM knows color roles!

   πŸ“Š LLM 1 FINDINGS:
   
   COLORS (with semantic context):
   β”œβ”€ Brand Primary (#06b2c4): "Fails AA on white (3.2:1)"
   β”œβ”€ Suggested fix: "#0891a8 (4.6:1)"
   └─ Score: 6/10

=======================================================
🎯 HEAD: Compiling final recommendations...
=======================================================

   πŸ“₯ INPUT: Analyzing outputs from LLM 1 + LLM 2 + Rules + Semantic...
   
   πŸ“Š HEAD SYNTHESIS:
   
   COLOR RECOMMENDATIONS (per semantic role):
   β”œβ”€ brand.primary: #06b2c4 β†’ Keep for branding, use #0891a8 for text
   β”œβ”€ text.primary: #373737 β†’ Keep (passes AA)
   └─ Generate ramps for: brand.primary, brand.secondary, neutral
```

---

## πŸ€– Agent Personas

### Agent 1A: Website Crawler & Enhanced Extractor
- **Persona:** Meticulous Design Archaeologist
- **Tool:** Playwright
- **Job:** 
  - Auto-discover 10+ pages from base URL
  - Crawl Desktop (1440px) + Mobile (375px) separately
  - Scroll to bottom + wait for network idle
  - **ENHANCED: Extract from 7 sources:**
    1. DOM computed styles (`getComputedStyle`)
    2. CSS variables (`:root { --primary: #xxx }`)
    3. SVG colors (`fill`, `stroke` attributes)
    4. Inline styles (`style="background-color: #xxx"`)
    5. Stylesheet rules (CSS files, hover states, pseudo-elements)
    6. External CSS files (fetch & parse to bypass CORS)
    7. Page content scan (brute-force regex on HTML)
- **Output:** Raw tokens with frequency, context, confidence, source type

### Agent 1B: Firecrawl CSS Deep Diver
- **Persona:** CSS Deep Diver
- **Tool:** Firecrawl / httpx fallback
- **Job:**
  - Fetch and parse ALL linked CSS files
  - Extract colors from CSS rules and variables
  - Bypass CORS restrictions
  - Find colors missed by DOM inspection
- **Output:** Additional colors merged into main extraction

### Agent 1C: Semantic Color Analyzer (NEW - LLM)
- **Persona:** Design System Semanticist
- **Tool:** Rule-based analysis (LLM optional)
- **Job:**
  - Analyze colors based on actual CSS usage (not guessing)
  - Categorize into semantic roles:
    - **Brand Colors:** Used on buttons, CTAs, links (interactive elements)
    - **Text Colors:** Used with `color` property on p, span, h1-h6
    - **Background Colors:** Used with `background-color` on containers
    - **Border Colors:** Used with `border-color` properties
    - **Feedback Colors:** Error (red), success (green), warning (yellow)
  - Detect color hierarchy (primary β†’ secondary β†’ muted)
- **Input:** Colors WITH context data (css_properties, elements, frequency)
- **Output:** Semantic categorization with confidence levels
- **Why:** Stage 2 LLMs can now give SPECIFIC recommendations per role

### Agent 2: Token Normalizer & Structurer
- **Persona:** Design System Librarian
- **Job:**
  - Clean noisy extraction, dedupe
  - Infer naming patterns
  - Tag tokens as: `detected` | `inferred` | `low-confidence`
- **Output:** Structured token sets with metadata

### Agent 3: Design System Best Practices Advisor
- **Persona:** Senior Staff Design Systems Architect
- **Job:**
  - Research modern DS patterns (Material, Polaris, Carbon, etc.)
  - Propose upgrade OPTIONS (not decisions)
  - Suggest: type scales (3 options), spacing (8px), color ramps (AA compliant), naming conventions
- **Output:** Option sets with rationale

### Agent 4: Plugin & JSON Generator
- **Persona:** Automation Engineer
- **Job:**
  - Convert finalized tokens to Figma-compatible JSON
  - Generate: typography, color (with tints/shades), spacing variables
  - Maintain Desktop + Mobile + version metadata
- **Output:** Production-ready JSON (flat structure for Figma Tokens Studio)

---

## πŸ–₯️ UI Stages (3 Stages)

### Stage 1: Extraction Review (AS-IS)
- **Purpose:** Trust building β€” show exactly what was extracted
- **Shows:** 
  - Token tables (colors, typography, spacing)
  - **6 Visual Preview Tabs (AS-IS, no enhancements):**
    1. πŸ”€ Typography β€” actual font rendered
    2. 🎨 Colors β€” simple swatches sorted by frequency (no ramps)
    3. 🧠 Semantic Colors β€” colors organized by usage (brand/text/bg/border)
    4. πŸ“ Spacing β€” visual bars
    5. πŸ”˜ Radius β€” rounded boxes
    6. πŸŒ‘ Shadows β€” shadow cards
- **Human Actions:** Accept/reject tokens, flag anomalies, toggle Desktop↔Mobile

### Stage 2: Upgrade Playground (MOST IMPORTANT)
- **Purpose:** Decision-making through live visuals
- **Shows:** 
  - Side-by-side option selector + live preview
  - **Color Ramps (50-950 shades with AA compliance)**
  - Type scale options (1.2, 1.25, 1.333)
  - **Semantic-aware recommendations:** "Your brand primary #06b2c4 fails AA, consider #0891a8"
- **Human Actions:** Select type scale A/B/C, spacing system, color ramps β€” preview updates instantly

### Stage 3: Final Review & Export
- **Purpose:** Confidence before export
- **Shows:** Token preview, JSON tree, diff view (original vs final)
- **Human Actions:** Download JSON, save version, label version

---

## πŸ“ Project Structure

```
design-system-extractor/
β”œβ”€β”€ app.py                          # Gradio main entry point
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”‚
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ .env.example                # Environment variables template
β”‚   β”œβ”€β”€ agents.yaml                 # Agent personas & configurations
β”‚   └── settings.py                 # Application settings
β”‚
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ state.py                    # LangGraph state definitions
β”‚   β”œβ”€β”€ graph.py                    # LangGraph workflow orchestration
β”‚   β”œβ”€β”€ crawler.py                  # Agent 1A: Website crawler
β”‚   β”œβ”€β”€ extractor.py                # Agent 1A: Token extraction (7 sources)
β”‚   β”œβ”€β”€ firecrawl_extractor.py      # Agent 1B: Deep CSS parsing
β”‚   β”œβ”€β”€ semantic_analyzer.py        # Agent 1C: Semantic color categorization
β”‚   β”œβ”€β”€ normalizer.py               # Agent 2: Token normalization
β”‚   β”œβ”€β”€ advisor.py                  # Agent 3: Best practices
β”‚   β”œβ”€β”€ stage2_graph.py             # Stage 2 multi-agent LLM workflow
β”‚   └── generator.py                # Agent 4: JSON generator
β”‚
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ color_utils.py              # Color analysis, contrast, ramps
β”‚   β”œβ”€β”€ preview_generator.py        # HTML preview generation
β”‚   β”œβ”€β”€ hf_inference.py             # HuggingFace LLM inference
β”‚   └── token_schema.py             # Token data structures (Pydantic)
β”‚
β”œβ”€β”€ ui/
β”‚   └── __init__.py
β”‚
β”œβ”€β”€ templates/
β”‚
β”œβ”€β”€ storage/
β”‚   └── __init__.py
β”‚
β”œβ”€β”€ tests/
β”‚   └── __init__.py
β”‚
└── docs/
    └── CONTEXT.md                  # THIS FILE - upload for context refresh
```

---

## πŸ”§ Key Technical Decisions

| Decision | Choice | Rationale |
|----------|--------|-----------|
| Viewports | Fixed 1440px + 375px | Simplicity, covers main use cases |
| Scrolling | Bottom + network idle | Captures lazy-loaded content |
| Infinite scroll | Skip | Avoid complexity |
| Modals | Manual trigger | User decides what to capture |
| Color ramps | 5-10 shades, AA compliant | Industry standard |
| Type scales | 3 options (1.25, 1.333, 1.414) | User selects |
| Spacing | 8px base system | Modern standard |
| ML models | Minimal, rule-based preferred | Simplicity, reliability |
| Versioning | HF Spaces persistent storage | Built-in, free |
| Preview | Gradio + iframe (best for dynamic) | Smooth updates |

---

## πŸ“Š Token Schema (Core Data Structures)

```python
class TokenSource(Enum):
    DETECTED = "detected"       # Directly found in CSS
    INFERRED = "inferred"       # Derived from patterns
    UPGRADED = "upgraded"       # User-selected improvement
    
class Confidence(Enum):
    HIGH = "high"               # 10+ occurrences
    MEDIUM = "medium"           # 3-9 occurrences
    LOW = "low"                 # 1-2 occurrences

class Viewport(Enum):
    DESKTOP = "desktop"         # 1440px
    MOBILE = "mobile"           # 375px
```

### Token Types:
- **ColorToken:** value, frequency, contexts, elements, contrast ratios
- **TypographyToken:** family, size, weight, line-height, elements
- **SpacingToken:** value, frequency, contexts, fits_base_8
- **RadiusToken:** value, frequency, elements
- **ShadowToken:** value, frequency, elements

---

## πŸ”„ LangGraph Workflow

```
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   START     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ URL Input   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Agent 1: Discover     β”‚
              β”‚  (find pages)          β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  HUMAN: Confirm pages  │◄─── Checkpoint 1
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Agent 1: Extract      β”‚
              β”‚  (crawl & extract)     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Agent 2: Normalize    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  HUMAN: Review tokens  │◄─── Checkpoint 2 (Stage 1 UI)
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚                               β”‚
          β–Ό                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Agent 3: Advise  β”‚            β”‚  (parallel)      β”‚
β”‚ (best practices) β”‚            β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HUMAN: Select options │◄─── Checkpoint 3 (Stage 2 UI)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Agent 4: Generate     β”‚
β”‚  (final JSON)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HUMAN: Export         │◄─── Checkpoint 4 (Stage 3 UI)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚   END   β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## 🚦 Human-in-the-Loop Rules

1. **No irreversible automation**
2. **Agents propose β†’ Humans decide**
3. **Every auto action must be:**
   - Visible
   - Reversible
   - Previewed

---

## πŸ“¦ Output JSON Format

```json
{
  "metadata": {
    "source_url": "https://example.com",
    "extracted_at": "2025-01-23T10:00:00Z",
    "version": "v1-recovered",
    "viewport": "desktop"
  },
  "colors": {
    "primary": {
      "50": { "value": "#e6f2ff", "source": "upgraded" },
      "500": { "value": "#007bff", "source": "detected" },
      "900": { "value": "#001a33", "source": "upgraded" }
    }
  },
  "typography": {
    "heading-xl": {
      "fontFamily": "Inter",
      "fontSize": "32px",
      "fontWeight": 700,
      "lineHeight": "1.2",
      "source": "detected"
    }
  },
  "spacing": {
    "xs": { "value": "4px", "source": "upgraded" },
    "sm": { "value": "8px", "source": "detected" },
    "md": { "value": "16px", "source": "detected" }
  }
}
```

---

## πŸ› οΈ Implementation Phases & Current Status

### Phase 1 βœ… COMPLETE
- [x] Project structure
- [x] Configuration files
- [x] Token schema (Pydantic models)
- [x] Agent 1: Crawler (page discovery)
- [x] Agent 1: Enhanced Extractor (5-source extraction)
- [x] Agent 2: Normalizer
- [x] Stage 1 UI with 5 AS-IS preview tabs
- [x] LangGraph basic workflow
- [x] JSON export (flat structure for Figma)

### Phase 2 βœ… MOSTLY COMPLETE
- [x] Agent 3: Multi-LLM Advisor (Qwen + Llama + HEAD)
- [x] Stage 2 UI (Upgrade Playground)
- [x] Live preview system (typography, color ramps)
- [x] Enhanced LLM logging with reasoning
- [ ] Accept/Reject checkbox wiring to export

### Phase 3 πŸ”„ IN PROGRESS
- [ ] Agent 4: Generator (component patterns)
- [ ] Stage 3 UI (diff view)
- [ ] Arabic page filtering

### Phase 4 ⏳ PENDING
- [ ] Full LangGraph orchestration
- [ ] HF Spaces deployment
- [ ] Persistent storage
- [ ] MCP Claude / Figma plugin integration (Part 2 of article)

---

## πŸ› Known Issues & Pending Fixes

| Issue | Status | Fix |
|-------|--------|-----|
| Arabic pages included | Pending | Filter `/ar/` URLs in crawler |
| Accept/Reject not wired | Pending | Export should respect checkbox state |
| Stage 1 vs Stage 2 preview confusion | βœ… Fixed | Stage 1 now shows AS-IS (no ramps) |
| Colors missed from CSS variables | βœ… Fixed | Enhanced 5-source extraction |
| JSON nested structure | βœ… Fixed | Flat structure for Figma compatibility |

---

## πŸ”‘ Environment Variables

```env
# Required
HF_TOKEN=your_huggingface_token

# Model Configuration (defaults shown β€” diverse providers)
AGENT2_MODEL=microsoft/Phi-3.5-mini-instruct      # Microsoft - Fast naming
AGENT3_MODEL=meta-llama/Llama-3.1-70B-Instruct    # Meta - Strong reasoning
AGENT4_MODEL=mistralai/Codestral-22B-v0.1         # Mistral - Code/JSON

# Optional
DEBUG=true
LOG_LEVEL=INFO
```

---

## πŸ“ Notes for Claude

When continuing this project:
1. **Check current phase** in Implementation Phases section
2. **Review agent personas** in agents.yaml for consistent behavior
3. **Follow token schema** defined in core/token_schema.py
4. **Maintain LangGraph state** consistency across agents
5. **Use Gradio components** from ui/components.py for consistency
6. **Test with** real websites before deployment
7. **Enhanced extraction** captures from 5 sources β€” check logs to verify
8. **Stage 1 = AS-IS** (no ramps), **Stage 2 = Enhanced** (with ramps)

---

*Last updated: 2025-01-23*