Spaces:
Sleeping
Sleeping
Upload CONTEXT.md
Browse files- docs/CONTEXT.md +111 -38
docs/CONTEXT.md
CHANGED
|
@@ -10,10 +10,12 @@
|
|
| 10 |
|
| 11 |
| File | What Changed |
|
| 12 |
|------|--------------|
|
| 13 |
-
| `agents/extractor.py` | Enhanced
|
| 14 |
-
| `
|
| 15 |
-
| `
|
| 16 |
-
| `
|
|
|
|
|
|
|
| 17 |
|
| 18 |
---
|
| 19 |
|
|
@@ -314,17 +316,79 @@ Shows detailed extraction progress:
|
|
| 314 |
π Merging Firecrawl colors with Playwright extraction...
|
| 315 |
β
Added 12 new colors from Firecrawl
|
| 316 |
π Total colors now: 44
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
```
|
| 318 |
|
| 319 |
-
### Stage 2 LLM Analysis Logs
|
| 320 |
|
| 321 |
-
Shows detailed reasoning from each agent:
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
-
|
| 326 |
-
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
---
|
| 330 |
|
|
@@ -347,7 +411,7 @@ Shows detailed reasoning from each agent:
|
|
| 347 |
7. Page content scan (brute-force regex on HTML)
|
| 348 |
- **Output:** Raw tokens with frequency, context, confidence, source type
|
| 349 |
|
| 350 |
-
### Agent 1B: Firecrawl CSS Deep Diver
|
| 351 |
- **Persona:** CSS Deep Diver
|
| 352 |
- **Tool:** Firecrawl / httpx fallback
|
| 353 |
- **Job:**
|
|
@@ -357,6 +421,22 @@ Shows detailed reasoning from each agent:
|
|
| 357 |
- Find colors missed by DOM inspection
|
| 358 |
- **Output:** Additional colors merged into main extraction
|
| 359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
### Agent 2: Token Normalizer & Structurer
|
| 361 |
- **Persona:** Design System Librarian
|
| 362 |
- **Job:**
|
|
@@ -389,12 +469,13 @@ Shows detailed reasoning from each agent:
|
|
| 389 |
- **Purpose:** Trust building β show exactly what was extracted
|
| 390 |
- **Shows:**
|
| 391 |
- Token tables (colors, typography, spacing)
|
| 392 |
-
- **
|
| 393 |
1. π€ Typography β actual font rendered
|
| 394 |
-
2. π¨ Colors β simple swatches (no ramps)
|
| 395 |
-
3.
|
| 396 |
-
4.
|
| 397 |
-
5.
|
|
|
|
| 398 |
- **Human Actions:** Accept/reject tokens, flag anomalies, toggle DesktopβMobile
|
| 399 |
|
| 400 |
### Stage 2: Upgrade Playground (MOST IMPORTANT)
|
|
@@ -403,6 +484,7 @@ Shows detailed reasoning from each agent:
|
|
| 403 |
- Side-by-side option selector + live preview
|
| 404 |
- **Color Ramps (50-950 shades with AA compliance)**
|
| 405 |
- Type scale options (1.2, 1.25, 1.333)
|
|
|
|
| 406 |
- **Human Actions:** Select type scale A/B/C, spacing system, color ramps β preview updates instantly
|
| 407 |
|
| 408 |
### Stage 3: Final Review & Export
|
|
@@ -429,44 +511,35 @@ design-system-extractor/
|
|
| 429 |
β βββ __init__.py
|
| 430 |
β βββ state.py # LangGraph state definitions
|
| 431 |
β βββ graph.py # LangGraph workflow orchestration
|
| 432 |
-
β βββ crawler.py # Agent
|
| 433 |
-
β βββ extractor.py # Agent
|
|
|
|
|
|
|
| 434 |
β βββ normalizer.py # Agent 2: Token normalization
|
| 435 |
β βββ advisor.py # Agent 3: Best practices
|
|
|
|
| 436 |
β βββ generator.py # Agent 4: JSON generator
|
| 437 |
β
|
| 438 |
βββ core/
|
| 439 |
β βββ __init__.py
|
| 440 |
-
β βββ browser.py # Playwright browser management
|
| 441 |
-
β βββ css_parser.py # CSS/computed style extraction
|
| 442 |
β βββ color_utils.py # Color analysis, contrast, ramps
|
| 443 |
-
β βββ
|
| 444 |
-
β βββ
|
| 445 |
β βββ token_schema.py # Token data structures (Pydantic)
|
| 446 |
β
|
| 447 |
βββ ui/
|
| 448 |
-
β
|
| 449 |
-
β βββ components.py # Reusable Gradio components
|
| 450 |
-
β βββ stage1_extraction.py # Stage 1 UI
|
| 451 |
-
β βββ stage2_upgrade.py # Stage 2 UI
|
| 452 |
-
β βββ stage3_export.py # Stage 3 UI
|
| 453 |
-
β βββ preview_generator.py # HTML preview generation
|
| 454 |
β
|
| 455 |
βββ templates/
|
| 456 |
-
β βββ preview.html # Live preview base template
|
| 457 |
-
β βββ specimen.html # Design system specimen template
|
| 458 |
β
|
| 459 |
βββ storage/
|
| 460 |
-
β βββ
|
| 461 |
β
|
| 462 |
βββ tests/
|
| 463 |
-
β
|
| 464 |
-
β βββ test_extractor.py
|
| 465 |
-
β βββ test_normalizer.py
|
| 466 |
β
|
| 467 |
βββ docs/
|
| 468 |
-
|
| 469 |
-
βββ API.md # API documentation
|
| 470 |
```
|
| 471 |
|
| 472 |
---
|
|
|
|
| 10 |
|
| 11 |
| File | What Changed |
|
| 12 |
|------|--------------|
|
| 13 |
+
| `agents/extractor.py` | Enhanced 7-source extraction (DOM, CSS vars, SVG, inline, stylesheets, external CSS, page scan) |
|
| 14 |
+
| `agents/firecrawl_extractor.py` | **NEW** Agent 1B for deep CSS parsing |
|
| 15 |
+
| `agents/semantic_analyzer.py` | **NEW** Agent 1C for semantic color categorization (brand/text/bg/border) |
|
| 16 |
+
| `core/preview_generator.py` | AS-IS previews + Color Ramps sorted by brand priority |
|
| 17 |
+
| `app.py` | Stage 1 UI now has 6 preview tabs including Semantic Colors |
|
| 18 |
+
| `docs/CONTEXT.md` | Updated with semantic analyzer, full architecture diagrams |
|
| 19 |
|
| 20 |
---
|
| 21 |
|
|
|
|
| 316 |
π Merging Firecrawl colors with Playwright extraction...
|
| 317 |
β
Added 12 new colors from Firecrawl
|
| 318 |
π Total colors now: 44
|
| 319 |
+
|
| 320 |
+
============================================================
|
| 321 |
+
π§ SEMANTIC COLOR ANALYSIS
|
| 322 |
+
============================================================
|
| 323 |
+
|
| 324 |
+
π Analyzing 143 colors...
|
| 325 |
+
Using rule-based analysis (no LLM)
|
| 326 |
+
|
| 327 |
+
π SEMANTIC ANALYSIS RESULTS:
|
| 328 |
+
|
| 329 |
+
π¨ BRAND COLORS:
|
| 330 |
+
primary: #06b2c4 (high)
|
| 331 |
+
ββ Most frequent saturated color on interactive elements (freq: 33)
|
| 332 |
+
secondary: #c1df1f (medium)
|
| 333 |
+
ββ Second most frequent brand color (freq: 15)
|
| 334 |
+
|
| 335 |
+
π TEXT COLORS:
|
| 336 |
+
primary: #373737 (high)
|
| 337 |
+
secondary: #666666 (medium)
|
| 338 |
+
|
| 339 |
+
πΌοΈ BACKGROUND COLORS:
|
| 340 |
+
primary: #ffffff (high)
|
| 341 |
+
secondary: #f5f5f5 (medium)
|
| 342 |
+
|
| 343 |
+
π SUMMARY:
|
| 344 |
+
Total colors analyzed: 143
|
| 345 |
+
Brand colors found: 2
|
| 346 |
+
Clear hierarchy: Yes
|
| 347 |
+
Analysis method: rule-based
|
| 348 |
```
|
| 349 |
|
| 350 |
+
### Stage 2 LLM Analysis Logs (With Semantic Context)
|
| 351 |
|
| 352 |
+
Shows detailed reasoning from each agent WITH semantic context:
|
| 353 |
+
|
| 354 |
+
```
|
| 355 |
+
============================================================
|
| 356 |
+
π§ STAGE 2: MULTI-AGENT ANALYSIS
|
| 357 |
+
============================================================
|
| 358 |
+
|
| 359 |
+
π§ SEMANTIC CONTEXT FROM STAGE 1:
|
| 360 |
+
Brand Primary: #06b2c4
|
| 361 |
+
Text Primary: #373737
|
| 362 |
+
Analysis Method: rule-based
|
| 363 |
+
|
| 364 |
+
=======================================================
|
| 365 |
+
π€ LLM 1: meta-llama/Llama-3.1-70B-Instruct
|
| 366 |
+
=======================================================
|
| 367 |
+
Provider: novita
|
| 368 |
+
π° Cost: $0.29/M in, $0.59/M out
|
| 369 |
+
π Task: Typography, Colors, AA, Spacing analysis
|
| 370 |
+
π§ Semantic context: Yes β NEW: LLM knows color roles!
|
| 371 |
+
|
| 372 |
+
π LLM 1 FINDINGS:
|
| 373 |
+
|
| 374 |
+
COLORS (with semantic context):
|
| 375 |
+
ββ Brand Primary (#06b2c4): "Fails AA on white (3.2:1)"
|
| 376 |
+
ββ Suggested fix: "#0891a8 (4.6:1)"
|
| 377 |
+
ββ Score: 6/10
|
| 378 |
+
|
| 379 |
+
=======================================================
|
| 380 |
+
π― HEAD: Compiling final recommendations...
|
| 381 |
+
=======================================================
|
| 382 |
+
|
| 383 |
+
π₯ INPUT: Analyzing outputs from LLM 1 + LLM 2 + Rules + Semantic...
|
| 384 |
+
|
| 385 |
+
π HEAD SYNTHESIS:
|
| 386 |
+
|
| 387 |
+
COLOR RECOMMENDATIONS (per semantic role):
|
| 388 |
+
ββ brand.primary: #06b2c4 β Keep for branding, use #0891a8 for text
|
| 389 |
+
ββ text.primary: #373737 β Keep (passes AA)
|
| 390 |
+
ββ Generate ramps for: brand.primary, brand.secondary, neutral
|
| 391 |
+
```
|
| 392 |
|
| 393 |
---
|
| 394 |
|
|
|
|
| 411 |
7. Page content scan (brute-force regex on HTML)
|
| 412 |
- **Output:** Raw tokens with frequency, context, confidence, source type
|
| 413 |
|
| 414 |
+
### Agent 1B: Firecrawl CSS Deep Diver
|
| 415 |
- **Persona:** CSS Deep Diver
|
| 416 |
- **Tool:** Firecrawl / httpx fallback
|
| 417 |
- **Job:**
|
|
|
|
| 421 |
- Find colors missed by DOM inspection
|
| 422 |
- **Output:** Additional colors merged into main extraction
|
| 423 |
|
| 424 |
+
### Agent 1C: Semantic Color Analyzer (NEW - LLM)
|
| 425 |
+
- **Persona:** Design System Semanticist
|
| 426 |
+
- **Tool:** Rule-based analysis (LLM optional)
|
| 427 |
+
- **Job:**
|
| 428 |
+
- Analyze colors based on actual CSS usage (not guessing)
|
| 429 |
+
- Categorize into semantic roles:
|
| 430 |
+
- **Brand Colors:** Used on buttons, CTAs, links (interactive elements)
|
| 431 |
+
- **Text Colors:** Used with `color` property on p, span, h1-h6
|
| 432 |
+
- **Background Colors:** Used with `background-color` on containers
|
| 433 |
+
- **Border Colors:** Used with `border-color` properties
|
| 434 |
+
- **Feedback Colors:** Error (red), success (green), warning (yellow)
|
| 435 |
+
- Detect color hierarchy (primary β secondary β muted)
|
| 436 |
+
- **Input:** Colors WITH context data (css_properties, elements, frequency)
|
| 437 |
+
- **Output:** Semantic categorization with confidence levels
|
| 438 |
+
- **Why:** Stage 2 LLMs can now give SPECIFIC recommendations per role
|
| 439 |
+
|
| 440 |
### Agent 2: Token Normalizer & Structurer
|
| 441 |
- **Persona:** Design System Librarian
|
| 442 |
- **Job:**
|
|
|
|
| 469 |
- **Purpose:** Trust building β show exactly what was extracted
|
| 470 |
- **Shows:**
|
| 471 |
- Token tables (colors, typography, spacing)
|
| 472 |
+
- **6 Visual Preview Tabs (AS-IS, no enhancements):**
|
| 473 |
1. π€ Typography β actual font rendered
|
| 474 |
+
2. π¨ Colors β simple swatches sorted by frequency (no ramps)
|
| 475 |
+
3. π§ Semantic Colors β colors organized by usage (brand/text/bg/border)
|
| 476 |
+
4. π Spacing β visual bars
|
| 477 |
+
5. π Radius β rounded boxes
|
| 478 |
+
6. π Shadows β shadow cards
|
| 479 |
- **Human Actions:** Accept/reject tokens, flag anomalies, toggle DesktopβMobile
|
| 480 |
|
| 481 |
### Stage 2: Upgrade Playground (MOST IMPORTANT)
|
|
|
|
| 484 |
- Side-by-side option selector + live preview
|
| 485 |
- **Color Ramps (50-950 shades with AA compliance)**
|
| 486 |
- Type scale options (1.2, 1.25, 1.333)
|
| 487 |
+
- **Semantic-aware recommendations:** "Your brand primary #06b2c4 fails AA, consider #0891a8"
|
| 488 |
- **Human Actions:** Select type scale A/B/C, spacing system, color ramps β preview updates instantly
|
| 489 |
|
| 490 |
### Stage 3: Final Review & Export
|
|
|
|
| 511 |
β βββ __init__.py
|
| 512 |
β βββ state.py # LangGraph state definitions
|
| 513 |
β βββ graph.py # LangGraph workflow orchestration
|
| 514 |
+
β βββ crawler.py # Agent 1A: Website crawler
|
| 515 |
+
β βββ extractor.py # Agent 1A: Token extraction (7 sources)
|
| 516 |
+
β βββ firecrawl_extractor.py # Agent 1B: Deep CSS parsing
|
| 517 |
+
β βββ semantic_analyzer.py # Agent 1C: Semantic color categorization
|
| 518 |
β βββ normalizer.py # Agent 2: Token normalization
|
| 519 |
β βββ advisor.py # Agent 3: Best practices
|
| 520 |
+
β βββ stage2_graph.py # Stage 2 multi-agent LLM workflow
|
| 521 |
β βββ generator.py # Agent 4: JSON generator
|
| 522 |
β
|
| 523 |
βββ core/
|
| 524 |
β βββ __init__.py
|
|
|
|
|
|
|
| 525 |
β βββ color_utils.py # Color analysis, contrast, ramps
|
| 526 |
+
β βββ preview_generator.py # HTML preview generation
|
| 527 |
+
β βββ hf_inference.py # HuggingFace LLM inference
|
| 528 |
β βββ token_schema.py # Token data structures (Pydantic)
|
| 529 |
β
|
| 530 |
βββ ui/
|
| 531 |
+
β βββ __init__.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
β
|
| 533 |
βββ templates/
|
|
|
|
|
|
|
| 534 |
β
|
| 535 |
βββ storage/
|
| 536 |
+
β βββ __init__.py
|
| 537 |
β
|
| 538 |
βββ tests/
|
| 539 |
+
β βββ __init__.py
|
|
|
|
|
|
|
| 540 |
β
|
| 541 |
βββ docs/
|
| 542 |
+
βββ CONTEXT.md # THIS FILE - upload for context refresh
|
|
|
|
| 543 |
```
|
| 544 |
|
| 545 |
---
|