foliko 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/agents/code-assistant.json +17 -0
- package/.agent/agents/email-assistant.json +14 -0
- package/.agent/agents/file-assistant.json +18 -0
- package/.agent/agents/orchestrator-demo.md +53 -0
- package/.agent/agents/orchestrator.json +7 -0
- package/.agent/agents/poster-expert.md +228 -0
- package/.agent/agents/system-assistant.json +15 -0
- package/.agent/agents/web-assistant.json +12 -0
- package/.agent/data/default.json +5 -404
- package/.agent/data/email/processed-emails.json +1 -0
- package/.agent/data/plugins-state.json +173 -172
- package/.agent/data/scheduler/tasks.json +1 -0
- package/.agent/data/web/web-config.json +5 -0
- package/.agent/mcp_config.json +0 -14
- package/.agent/package.json +8 -0
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +89 -0
- package/.agent/plugins/daytona/index.js +377 -0
- package/.agent/plugins/daytona/package.json +12 -0
- package/.agent/plugins/marknative/README.md +134 -0
- package/.agent/plugins/marknative/fonts.zip +0 -0
- package/.agent/plugins/marknative/index.js +256 -0
- package/.agent/plugins/marknative/package.json +12 -0
- package/.agent/plugins/system-info/index.js +387 -0
- package/.agent/plugins/system-info/package.json +4 -0
- package/.agent/plugins/system-info/test.js +40 -0
- package/.agent/plugins/test-plugin.py +123 -0
- package/.agent/plugins/test_nested_plugin.py +85 -0
- package/.agent/plugins.json +11 -5
- package/.agent/python-scripts/test_sample.py +24 -0
- package/.agent/sessions/cli_default.json +96 -249
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +189 -0
- package/.agent/skills/agent-browser/SKILL.md +311 -0
- package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
- package/.agent/skills/sysinfo/SKILL.md +38 -0
- package/.agent/skills/sysinfo/system-info.sh +130 -0
- package/.agent/skills/workflow/SKILL.md +324 -0
- package/.agent/test-agent.js +35 -0
- package/.agent/weixin.json +6 -0
- package/.agent/workflows/email-digest.json +50 -0
- package/.agent/workflows/file-backup.json +21 -0
- package/.agent/workflows/get-ip-notify.json +32 -0
- package/.agent/workflows/news-aggregator.json +93 -0
- package/.agent/workflows/news-dashboard-v2.json +94 -0
- package/.agent/workflows/notification-batch.json +32 -0
- package/.claude/settings.local.json +9 -1
- package/.env.example +56 -56
- package/README.md +441 -441
- package/cli/src/ui/chat-ui.js +32 -21
- package/foliko_poster.png +0 -0
- package/output/business_poster_final.png +0 -0
- package/output/emoji_test_v2.png +0 -0
- package/output/foliko-ai-launch-poster.png +0 -0
- package/output/foliko-poster.png +0 -0
- package/output/muji_style_poster.png +0 -0
- package/output/new_product_launch.png +0 -0
- package/output/news_poster_625yi_subsidy.png +0 -0
- package/output/tech_future_2026.png +0 -0
- package/output/tech_future_poster.png +0 -0
- package/package.json +1 -2
- package/plugins/default-plugins.js +58 -6
- package/plugins/extension-executor-plugin.js +8 -21
- package/plugins/python-plugin-loader.js +461 -40
- package/plugins/python-plugin-loader.js.bak +856 -0
- package/plugins/subagent-plugin.js +0 -121
- package/plugins/weixin-plugin.js +38 -29
- package/poster.png +0 -0
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/foliko-dev/SKILL.md +6 -0
- package/skills/python-plugin-dev/SKILL.md +124 -2
- package/src/core/agent-chat.js +220 -281
- package/src/core/agent.js +10 -0
- package/src/utils/plugin-helpers.js +22 -4
- package/system.md +1678 -1574
- package/test-scan.js +18 -0
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
- package/.agent/ARCHITECTURE.md +0 -288
- package/.agent/agents/ambient-agent.md +0 -57
- package/.agent/agents/debugger.md +0 -55
- package/.agent/agents/email-assistant.md +0 -49
- package/.agent/agents/file-manager.md +0 -42
- package/.agent/agents/python-developer.md +0 -60
- package/.agent/agents/scheduler.md +0 -59
- package/.agent/agents/web-developer.md +0 -45
- package/.agent/data/puppeteer-sessions/undefined.json +0 -6
- package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
- package/.agent/memory/feedback/mnrdvj5i-ca3dkd.md +0 -9
- package/.agent/memory/feedback/mnre365e-7s4zax.md +0 -9
- package/.agent/memory/feedback/mnre36jn-nkfgmp.md +0 -9
- package/.agent/memory/feedback/mnre3805-kjiq6h.md +0 -9
- package/.agent/memory/feedback/mnsf66kp-b10rcd.md +0 -9
- package/.agent/memory/feedback/mnsi3sz8-p5g2cw.md +0 -9
- package/.agent/memory/feedback/mnsibe47-sv2ni1.md +0 -9
- package/.agent/memory/feedback/mnsic89w-nn228o.md +0 -9
- package/.agent/memory/feedback/mnsj1xe9-x83ba0.md +0 -9
- package/.agent/memory/feedback/mnsj21iv-wnwelx.md +0 -9
- package/.agent/memory/feedback/mnsj2g4a-cog7a2.md +0 -9
- package/.agent/memory/feedback/mnsj4js7-lktjp6.md +0 -9
- package/.agent/memory/feedback/mnsj5d4y-uglwvp.md +0 -9
- package/.agent/memory/feedback/mnslkuo9-uous66.md +0 -24
- package/.agent/memory/feedback/mnsm3vq0-megoil.md +0 -9
- package/.agent/memory/feedback/mnsnn5x2-sxcihd.md +0 -9
- package/.agent/memory/feedback/mnsnq17s-nabrn9.md +0 -9
- package/.agent/memory/feedback/mnsnybet-wz7rn3.md +0 -9
- package/.agent/memory/feedback/mnsrw0s7-7s9e30.md +0 -9
- package/.agent/memory/feedback/mnu5hpnd-tlm16q.md +0 -9
- package/.agent/memory/feedback/mnu60uqe-xuoxp4.md +0 -9
- package/.agent/memory/project/mnqx54u5-loqtoe.md +0 -9
- package/.agent/memory/project/mnqx84cv-mx6dmd.md +0 -9
- package/.agent/memory/project/mnsacuyr-hgtk5n.md +0 -20
- package/.agent/memory/project/mnu5hy2x-bjsg7u.md +0 -9
- package/.agent/memory/reference/mnre3cww-penbo1.md +0 -9
- package/.agent/memory/reference/mns9wn48-luerua.md +0 -14
- package/.agent/memory/reference/mns9yz5c-thc2s0.md +0 -16
- package/.agent/memory/reference/mnsfy4um-910f1o.md +0 -23
- package/.agent/memory/reference/mnsg37dp-lmfj18.md +0 -32
- package/.agent/memory/reference/mnsll60q-0j911u.md +0 -36
- package/.agent/memory/reference/mnsmlb5y-nej31u.md +0 -16
- package/.agent/memory/reference/mnssle72-yrot96.md +0 -9
- package/.agent/memory/user/mnsfuon6-l416q1.md +0 -21
- package/.agent/memory/user/mnsg9kut-95m7rf.md +0 -20
- package/.agent/memory/user/mnu2eo1v-yy6fhe.md +0 -9
- package/.agent/memory/user/mnu2etuo-8u8jk8.md +0 -9
- package/.agent/plugins/poster-plugin/README.md +0 -304
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/Symbola_hint.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
- package/.agent/plugins/poster-plugin/index.js +0 -13
- package/.agent/plugins/poster-plugin/package.json +0 -29
- package/.agent/plugins/poster-plugin/src/canvas.js +0 -232
- package/.agent/plugins/poster-plugin/src/components/arrow.js +0 -84
- package/.agent/plugins/poster-plugin/src/components/avatar.js +0 -71
- package/.agent/plugins/poster-plugin/src/components/badge.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/barcode.js +0 -123
- package/.agent/plugins/poster-plugin/src/components/bubble.js +0 -154
- package/.agent/plugins/poster-plugin/src/components/button.js +0 -168
- package/.agent/plugins/poster-plugin/src/components/card.js +0 -88
- package/.agent/plugins/poster-plugin/src/components/chart.js +0 -127
- package/.agent/plugins/poster-plugin/src/components/chip.js +0 -88
- package/.agent/plugins/poster-plugin/src/components/columns.js +0 -121
- package/.agent/plugins/poster-plugin/src/components/cta.js +0 -87
- package/.agent/plugins/poster-plugin/src/components/divider.js +0 -55
- package/.agent/plugins/poster-plugin/src/components/feature.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/frame.js +0 -230
- package/.agent/plugins/poster-plugin/src/components/grid.js +0 -130
- package/.agent/plugins/poster-plugin/src/components/highlightText.js +0 -145
- package/.agent/plugins/poster-plugin/src/components/icon.js +0 -94
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +0 -205
- package/.agent/plugins/poster-plugin/src/components/index.js +0 -81
- package/.agent/plugins/poster-plugin/src/components/listItem.js +0 -147
- package/.agent/plugins/poster-plugin/src/components/notification.js +0 -123
- package/.agent/plugins/poster-plugin/src/components/progress.js +0 -79
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/qrcode.js +0 -74
- package/.agent/plugins/poster-plugin/src/components/quote.js +0 -169
- package/.agent/plugins/poster-plugin/src/components/rating.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/ribbon.js +0 -197
- package/.agent/plugins/poster-plugin/src/components/seal.js +0 -148
- package/.agent/plugins/poster-plugin/src/components/star.js +0 -70
- package/.agent/plugins/poster-plugin/src/components/statCard.js +0 -105
- package/.agent/plugins/poster-plugin/src/components/stepper.js +0 -118
- package/.agent/plugins/poster-plugin/src/components/table.js +0 -167
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/timeline.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/watermark.js +0 -54
- package/.agent/plugins/poster-plugin/src/composer.js +0 -2314
- package/.agent/plugins/poster-plugin/src/elements/artText.js +0 -69
- package/.agent/plugins/poster-plugin/src/elements/background.js +0 -99
- package/.agent/plugins/poster-plugin/src/elements/circle.js +0 -31
- package/.agent/plugins/poster-plugin/src/elements/image.js +0 -28
- package/.agent/plugins/poster-plugin/src/elements/index.js +0 -28
- package/.agent/plugins/poster-plugin/src/elements/line.js +0 -23
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +0 -63
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +0 -32
- package/.agent/plugins/poster-plugin/src/elements/richText.js +0 -283
- package/.agent/plugins/poster-plugin/src/elements/svg.js +0 -108
- package/.agent/plugins/poster-plugin/src/elements/text.js +0 -112
- package/.agent/plugins/poster-plugin/src/fonts.js +0 -674
- package/.agent/plugins/poster-plugin/src/index.js +0 -2126
- package/.agent/plugins/poster-plugin/src/presets.js +0 -36
- package/.agent/plugins/poster-plugin/src/templates/business.js +0 -60
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +0 -64
- package/.agent/plugins/poster-plugin/src/templates/index.js +0 -43
- package/.agent/plugins/poster-plugin/src/templates/modern.js +0 -69
- package/.agent/plugins/poster-plugin/src/templates/simple.js +0 -58
- package/.agent/plugins/poster-plugin/src/templates/social.js +0 -62
- package/.agent/plugins/poster-plugin/src/templates/tech.js +0 -84
- package/.agent/plugins/poster-plugin/src/utils/imageLoader.js +0 -84
- package/.agent/plugins/poster-plugin/yarn.lock +0 -837
- package/.agent/plugins/puppeteer-plugin/README.md +0 -147
- package/.agent/plugins/puppeteer-plugin/index.js +0 -1422
- package/.agent/plugins/puppeteer-plugin/package.json +0 -9
- package/.agent/rules/GEMINI.md +0 -273
- package/.agent/rules/allow-rule.md +0 -77
- package/.agent/rules/log-rule.md +0 -83
- package/.agent/rules/security-rule.md +0 -93
- package/.agent/scripts/auto_preview.py +0 -148
- package/.agent/scripts/checklist.py +0 -217
- package/.agent/scripts/session_manager.py +0 -120
- package/.agent/scripts/verify_all.py +0 -327
- package/.agent/skills/api-patterns/SKILL.md +0 -81
- package/.agent/skills/api-patterns/api-style.md +0 -42
- package/.agent/skills/api-patterns/auth.md +0 -24
- package/.agent/skills/api-patterns/documentation.md +0 -26
- package/.agent/skills/api-patterns/graphql.md +0 -41
- package/.agent/skills/api-patterns/rate-limiting.md +0 -31
- package/.agent/skills/api-patterns/response.md +0 -37
- package/.agent/skills/api-patterns/rest.md +0 -40
- package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
- package/.agent/skills/api-patterns/security-testing.md +0 -122
- package/.agent/skills/api-patterns/trpc.md +0 -41
- package/.agent/skills/api-patterns/versioning.md +0 -22
- package/.agent/skills/app-builder/SKILL.md +0 -75
- package/.agent/skills/app-builder/agent-coordination.md +0 -71
- package/.agent/skills/app-builder/feature-building.md +0 -53
- package/.agent/skills/app-builder/project-detection.md +0 -34
- package/.agent/skills/app-builder/scaffolding.md +0 -118
- package/.agent/skills/app-builder/tech-stack.md +0 -40
- package/.agent/skills/app-builder/templates/SKILL.md +0 -39
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
- package/.agent/skills/architecture/SKILL.md +0 -55
- package/.agent/skills/architecture/context-discovery.md +0 -43
- package/.agent/skills/architecture/examples.md +0 -94
- package/.agent/skills/architecture/pattern-selection.md +0 -68
- package/.agent/skills/architecture/patterns-reference.md +0 -50
- package/.agent/skills/architecture/trade-off-analysis.md +0 -77
- package/.agent/skills/clean-code/SKILL.md +0 -201
- package/.agent/skills/doc.md +0 -177
- package/.agent/skills/frontend-design/SKILL.md +0 -418
- package/.agent/skills/frontend-design/animation-guide.md +0 -331
- package/.agent/skills/frontend-design/color-system.md +0 -311
- package/.agent/skills/frontend-design/decision-trees.md +0 -418
- package/.agent/skills/frontend-design/motion-graphics.md +0 -306
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
- package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
- package/.agent/skills/frontend-design/typography-system.md +0 -345
- package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
- package/.agent/skills/frontend-design/visual-effects.md +0 -383
- package/.agent/skills/i18n-localization/SKILL.md +0 -154
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
- package/.agent/skills/mcp-builder/SKILL.md +0 -176
- package/.agent/skills/poster-design/SKILL.md +0 -385
- package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
- package/.agent/workflows/brainstorm.md +0 -113
- package/.agent/workflows/create.md +0 -59
- package/.agent/workflows/debug.md +0 -103
- package/.agent/workflows/deploy.md +0 -176
- package/.agent/workflows/enhance.md +0 -63
- package/.agent/workflows/orchestrate.md +0 -237
- package/.agent/workflows/plan.md +0 -89
- package/.agent/workflows/preview.md +0 -81
- package/.agent/workflows/simple-test.md +0 -42
- package/.agent/workflows/status.md +0 -86
- package/.agent/workflows/structured-orchestrate.md +0 -180
- package/.agent/workflows/test.md +0 -144
- package/.agent/workflows/ui-ux-pro-max.md +0 -296
- package/outputs/emoji-font-showcase.png +0 -0
- package/outputs/foliko-muji-style.png +0 -0
- /package/.agent/plugins/{poster-plugin → marknative}/fonts/SegoeUI Emoji.ttf +0 -0
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
UI/UX Pro Max Core - BM25 search engine for UI/UX style guides
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import csv
|
|
8
|
-
import re
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
from math import log
|
|
11
|
-
from collections import defaultdict
|
|
12
|
-
|
|
13
|
-
# ============ CONFIGURATION ============
|
|
14
|
-
DATA_DIR = Path(__file__).parent.parent / "data"
|
|
15
|
-
MAX_RESULTS = 3
|
|
16
|
-
|
|
17
|
-
CSV_CONFIG = {
|
|
18
|
-
"style": {
|
|
19
|
-
"file": "styles.csv",
|
|
20
|
-
"search_cols": ["Style Category", "Keywords", "Best For", "Type"],
|
|
21
|
-
"output_cols": ["Style Category", "Type", "Keywords", "Primary Colors", "Effects & Animation", "Best For", "Performance", "Accessibility", "Framework Compatibility", "Complexity"]
|
|
22
|
-
},
|
|
23
|
-
"prompt": {
|
|
24
|
-
"file": "prompts.csv",
|
|
25
|
-
"search_cols": ["Style Category", "AI Prompt Keywords (Copy-Paste Ready)", "CSS/Technical Keywords"],
|
|
26
|
-
"output_cols": ["Style Category", "AI Prompt Keywords (Copy-Paste Ready)", "CSS/Technical Keywords", "Implementation Checklist"]
|
|
27
|
-
},
|
|
28
|
-
"color": {
|
|
29
|
-
"file": "colors.csv",
|
|
30
|
-
"search_cols": ["Product Type", "Keywords", "Notes"],
|
|
31
|
-
"output_cols": ["Product Type", "Keywords", "Primary (Hex)", "Secondary (Hex)", "CTA (Hex)", "Background (Hex)", "Text (Hex)", "Border (Hex)", "Notes"]
|
|
32
|
-
},
|
|
33
|
-
"chart": {
|
|
34
|
-
"file": "charts.csv",
|
|
35
|
-
"search_cols": ["Data Type", "Keywords", "Best Chart Type", "Accessibility Notes"],
|
|
36
|
-
"output_cols": ["Data Type", "Keywords", "Best Chart Type", "Secondary Options", "Color Guidance", "Accessibility Notes", "Library Recommendation", "Interactive Level"]
|
|
37
|
-
},
|
|
38
|
-
"landing": {
|
|
39
|
-
"file": "landing.csv",
|
|
40
|
-
"search_cols": ["Pattern Name", "Keywords", "Conversion Optimization", "Section Order"],
|
|
41
|
-
"output_cols": ["Pattern Name", "Keywords", "Section Order", "Primary CTA Placement", "Color Strategy", "Conversion Optimization"]
|
|
42
|
-
},
|
|
43
|
-
"product": {
|
|
44
|
-
"file": "products.csv",
|
|
45
|
-
"search_cols": ["Product Type", "Keywords", "Primary Style Recommendation", "Key Considerations"],
|
|
46
|
-
"output_cols": ["Product Type", "Keywords", "Primary Style Recommendation", "Secondary Styles", "Landing Page Pattern", "Dashboard Style (if applicable)", "Color Palette Focus"]
|
|
47
|
-
},
|
|
48
|
-
"ux": {
|
|
49
|
-
"file": "ux-guidelines.csv",
|
|
50
|
-
"search_cols": ["Category", "Issue", "Description", "Platform"],
|
|
51
|
-
"output_cols": ["Category", "Issue", "Platform", "Description", "Do", "Don't", "Code Example Good", "Code Example Bad", "Severity"]
|
|
52
|
-
},
|
|
53
|
-
"typography": {
|
|
54
|
-
"file": "typography.csv",
|
|
55
|
-
"search_cols": ["Font Pairing Name", "Category", "Mood/Style Keywords", "Best For", "Heading Font", "Body Font"],
|
|
56
|
-
"output_cols": ["Font Pairing Name", "Category", "Heading Font", "Body Font", "Mood/Style Keywords", "Best For", "Google Fonts URL", "CSS Import", "Tailwind Config", "Notes"]
|
|
57
|
-
},
|
|
58
|
-
"icons": {
|
|
59
|
-
"file": "icons.csv",
|
|
60
|
-
"search_cols": ["Category", "Icon Name", "Keywords", "Best For"],
|
|
61
|
-
"output_cols": ["Category", "Icon Name", "Keywords", "Library", "Import Code", "Usage", "Best For", "Style"]
|
|
62
|
-
},
|
|
63
|
-
"react": {
|
|
64
|
-
"file": "react-performance.csv",
|
|
65
|
-
"search_cols": ["Category", "Issue", "Keywords", "Description"],
|
|
66
|
-
"output_cols": ["Category", "Issue", "Platform", "Description", "Do", "Don't", "Code Example Good", "Code Example Bad", "Severity"]
|
|
67
|
-
},
|
|
68
|
-
"web": {
|
|
69
|
-
"file": "web-interface.csv",
|
|
70
|
-
"search_cols": ["Category", "Issue", "Keywords", "Description"],
|
|
71
|
-
"output_cols": ["Category", "Issue", "Platform", "Description", "Do", "Don't", "Code Example Good", "Code Example Bad", "Severity"]
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
STACK_CONFIG = {
|
|
76
|
-
"html-tailwind": {"file": "stacks/html-tailwind.csv"},
|
|
77
|
-
"react": {"file": "stacks/react.csv"},
|
|
78
|
-
"nextjs": {"file": "stacks/nextjs.csv"},
|
|
79
|
-
"vue": {"file": "stacks/vue.csv"},
|
|
80
|
-
"nuxtjs": {"file": "stacks/nuxtjs.csv"},
|
|
81
|
-
"nuxt-ui": {"file": "stacks/nuxt-ui.csv"},
|
|
82
|
-
"svelte": {"file": "stacks/svelte.csv"},
|
|
83
|
-
"swiftui": {"file": "stacks/swiftui.csv"},
|
|
84
|
-
"react-native": {"file": "stacks/react-native.csv"},
|
|
85
|
-
"flutter": {"file": "stacks/flutter.csv"},
|
|
86
|
-
"shadcn": {"file": "stacks/shadcn.csv"},
|
|
87
|
-
"jetpack-compose": {"file": "stacks/jetpack-compose.csv"}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
# Common columns for all stacks
|
|
91
|
-
_STACK_COLS = {
|
|
92
|
-
"search_cols": ["Category", "Guideline", "Description", "Do", "Don't"],
|
|
93
|
-
"output_cols": ["Category", "Guideline", "Description", "Do", "Don't", "Code Good", "Code Bad", "Severity", "Docs URL"]
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
AVAILABLE_STACKS = list(STACK_CONFIG.keys())
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
# ============ BM25 IMPLEMENTATION ============
|
|
100
|
-
class BM25:
|
|
101
|
-
"""BM25 ranking algorithm for text search"""
|
|
102
|
-
|
|
103
|
-
def __init__(self, k1=1.5, b=0.75):
|
|
104
|
-
self.k1 = k1
|
|
105
|
-
self.b = b
|
|
106
|
-
self.corpus = []
|
|
107
|
-
self.doc_lengths = []
|
|
108
|
-
self.avgdl = 0
|
|
109
|
-
self.idf = {}
|
|
110
|
-
self.doc_freqs = defaultdict(int)
|
|
111
|
-
self.N = 0
|
|
112
|
-
|
|
113
|
-
def tokenize(self, text):
|
|
114
|
-
"""Lowercase, split, remove punctuation, filter short words"""
|
|
115
|
-
text = re.sub(r'[^\w\s]', ' ', str(text).lower())
|
|
116
|
-
return [w for w in text.split() if len(w) > 2]
|
|
117
|
-
|
|
118
|
-
def fit(self, documents):
|
|
119
|
-
"""Build BM25 index from documents"""
|
|
120
|
-
self.corpus = [self.tokenize(doc) for doc in documents]
|
|
121
|
-
self.N = len(self.corpus)
|
|
122
|
-
if self.N == 0:
|
|
123
|
-
return
|
|
124
|
-
self.doc_lengths = [len(doc) for doc in self.corpus]
|
|
125
|
-
self.avgdl = sum(self.doc_lengths) / self.N
|
|
126
|
-
|
|
127
|
-
for doc in self.corpus:
|
|
128
|
-
seen = set()
|
|
129
|
-
for word in doc:
|
|
130
|
-
if word not in seen:
|
|
131
|
-
self.doc_freqs[word] += 1
|
|
132
|
-
seen.add(word)
|
|
133
|
-
|
|
134
|
-
for word, freq in self.doc_freqs.items():
|
|
135
|
-
self.idf[word] = log((self.N - freq + 0.5) / (freq + 0.5) + 1)
|
|
136
|
-
|
|
137
|
-
def score(self, query):
|
|
138
|
-
"""Score all documents against query"""
|
|
139
|
-
query_tokens = self.tokenize(query)
|
|
140
|
-
scores = []
|
|
141
|
-
|
|
142
|
-
for idx, doc in enumerate(self.corpus):
|
|
143
|
-
score = 0
|
|
144
|
-
doc_len = self.doc_lengths[idx]
|
|
145
|
-
term_freqs = defaultdict(int)
|
|
146
|
-
for word in doc:
|
|
147
|
-
term_freqs[word] += 1
|
|
148
|
-
|
|
149
|
-
for token in query_tokens:
|
|
150
|
-
if token in self.idf:
|
|
151
|
-
tf = term_freqs[token]
|
|
152
|
-
idf = self.idf[token]
|
|
153
|
-
numerator = tf * (self.k1 + 1)
|
|
154
|
-
denominator = tf + self.k1 * (1 - self.b + self.b * doc_len / self.avgdl)
|
|
155
|
-
score += idf * numerator / denominator
|
|
156
|
-
|
|
157
|
-
scores.append((idx, score))
|
|
158
|
-
|
|
159
|
-
return sorted(scores, key=lambda x: x[1], reverse=True)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
# ============ SEARCH FUNCTIONS ============
|
|
163
|
-
def _load_csv(filepath):
|
|
164
|
-
"""Load CSV and return list of dicts"""
|
|
165
|
-
with open(filepath, 'r', encoding='utf-8') as f:
|
|
166
|
-
return list(csv.DictReader(f))
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
def _search_csv(filepath, search_cols, output_cols, query, max_results):
|
|
170
|
-
"""Core search function using BM25"""
|
|
171
|
-
if not filepath.exists():
|
|
172
|
-
return []
|
|
173
|
-
|
|
174
|
-
data = _load_csv(filepath)
|
|
175
|
-
|
|
176
|
-
# Build documents from search columns
|
|
177
|
-
documents = [" ".join(str(row.get(col, "")) for col in search_cols) for row in data]
|
|
178
|
-
|
|
179
|
-
# BM25 search
|
|
180
|
-
bm25 = BM25()
|
|
181
|
-
bm25.fit(documents)
|
|
182
|
-
ranked = bm25.score(query)
|
|
183
|
-
|
|
184
|
-
# Get top results with score > 0
|
|
185
|
-
results = []
|
|
186
|
-
for idx, score in ranked[:max_results]:
|
|
187
|
-
if score > 0:
|
|
188
|
-
row = data[idx]
|
|
189
|
-
results.append({col: row.get(col, "") for col in output_cols if col in row})
|
|
190
|
-
|
|
191
|
-
return results
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
def detect_domain(query):
|
|
195
|
-
"""Auto-detect the most relevant domain from query"""
|
|
196
|
-
query_lower = query.lower()
|
|
197
|
-
|
|
198
|
-
domain_keywords = {
|
|
199
|
-
"color": ["color", "palette", "hex", "#", "rgb"],
|
|
200
|
-
"chart": ["chart", "graph", "visualization", "trend", "bar", "pie", "scatter", "heatmap", "funnel"],
|
|
201
|
-
"landing": ["landing", "page", "cta", "conversion", "hero", "testimonial", "pricing", "section"],
|
|
202
|
-
"product": ["saas", "ecommerce", "e-commerce", "fintech", "healthcare", "gaming", "portfolio", "crypto", "dashboard"],
|
|
203
|
-
"prompt": ["prompt", "css", "implementation", "variable", "checklist", "tailwind"],
|
|
204
|
-
"style": ["style", "design", "ui", "minimalism", "glassmorphism", "neumorphism", "brutalism", "dark mode", "flat", "aurora"],
|
|
205
|
-
"ux": ["ux", "usability", "accessibility", "wcag", "touch", "scroll", "animation", "keyboard", "navigation", "mobile"],
|
|
206
|
-
"typography": ["font", "typography", "heading", "serif", "sans"],
|
|
207
|
-
"icons": ["icon", "icons", "lucide", "heroicons", "symbol", "glyph", "pictogram", "svg icon"],
|
|
208
|
-
"react": ["react", "next.js", "nextjs", "suspense", "memo", "usecallback", "useeffect", "rerender", "bundle", "waterfall", "barrel", "dynamic import", "rsc", "server component"],
|
|
209
|
-
"web": ["aria", "focus", "outline", "semantic", "virtualize", "autocomplete", "form", "input type", "preconnect"]
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
scores = {domain: sum(1 for kw in keywords if kw in query_lower) for domain, keywords in domain_keywords.items()}
|
|
213
|
-
best = max(scores, key=scores.get)
|
|
214
|
-
return best if scores[best] > 0 else "style"
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
def search(query, domain=None, max_results=MAX_RESULTS):
|
|
218
|
-
"""Main search function with auto-domain detection"""
|
|
219
|
-
if domain is None:
|
|
220
|
-
domain = detect_domain(query)
|
|
221
|
-
|
|
222
|
-
config = CSV_CONFIG.get(domain, CSV_CONFIG["style"])
|
|
223
|
-
filepath = DATA_DIR / config["file"]
|
|
224
|
-
|
|
225
|
-
if not filepath.exists():
|
|
226
|
-
return {"error": f"File not found: {filepath}", "domain": domain}
|
|
227
|
-
|
|
228
|
-
results = _search_csv(filepath, config["search_cols"], config["output_cols"], query, max_results)
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
"domain": domain,
|
|
232
|
-
"query": query,
|
|
233
|
-
"file": config["file"],
|
|
234
|
-
"count": len(results),
|
|
235
|
-
"results": results
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
def search_stack(query, stack, max_results=MAX_RESULTS):
|
|
240
|
-
"""Search stack-specific guidelines"""
|
|
241
|
-
if stack not in STACK_CONFIG:
|
|
242
|
-
return {"error": f"Unknown stack: {stack}. Available: {', '.join(AVAILABLE_STACKS)}"}
|
|
243
|
-
|
|
244
|
-
filepath = DATA_DIR / STACK_CONFIG[stack]["file"]
|
|
245
|
-
|
|
246
|
-
if not filepath.exists():
|
|
247
|
-
return {"error": f"Stack file not found: {filepath}", "stack": stack}
|
|
248
|
-
|
|
249
|
-
results = _search_csv(filepath, _STACK_COLS["search_cols"], _STACK_COLS["output_cols"], query, max_results)
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
"domain": "stack",
|
|
253
|
-
"stack": stack,
|
|
254
|
-
"query": query,
|
|
255
|
-
"file": STACK_CONFIG[stack]["file"],
|
|
256
|
-
"count": len(results),
|
|
257
|
-
"results": results
|
|
258
|
-
}
|