@nguyenphp/antigravity-marketing 1.0.16 → 1.0.18

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.
Files changed (252) hide show
  1. package/README.md +10 -5
  2. package/bin/index.js +4 -4
  3. package/package.json +1 -1
  4. package/templates/.agent/agents/backend-specialist.md +263 -0
  5. package/templates/.agent/agents/database-architect.md +226 -0
  6. package/templates/.agent/agents/debugger.md +225 -0
  7. package/templates/.agent/agents/devops-engineer.md +242 -0
  8. package/templates/.agent/agents/documentation-writer.md +104 -0
  9. package/templates/.agent/agents/explorer-agent.md +73 -0
  10. package/templates/.agent/agents/frontend-specialist.md +527 -0
  11. package/templates/.agent/agents/game-developer.md +162 -0
  12. package/templates/.agent/agents/mobile-developer.md +377 -0
  13. package/templates/.agent/agents/orchestrator.md +400 -0
  14. package/templates/.agent/agents/penetration-tester.md +188 -0
  15. package/templates/.agent/agents/performance-optimizer.md +187 -0
  16. package/templates/.agent/agents/project-planner.md +403 -0
  17. package/templates/.agent/agents/security-auditor.md +170 -0
  18. package/templates/.agent/agents/seo-specialist.md +111 -0
  19. package/templates/.agent/agents/test-engineer.md +158 -0
  20. package/templates/.agent/rules/GEMINI.md +248 -0
  21. package/templates/.agent/skills/analytics-marketing/SKILL.md +172 -324
  22. package/templates/.agent/skills/api-patterns/SKILL.md +81 -0
  23. package/templates/.agent/skills/api-patterns/api-style.md +42 -0
  24. package/templates/.agent/skills/api-patterns/auth.md +24 -0
  25. package/templates/.agent/skills/api-patterns/documentation.md +26 -0
  26. package/templates/.agent/skills/api-patterns/graphql.md +41 -0
  27. package/templates/.agent/skills/api-patterns/rate-limiting.md +31 -0
  28. package/templates/.agent/skills/api-patterns/response.md +37 -0
  29. package/templates/.agent/skills/api-patterns/rest.md +40 -0
  30. package/templates/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  31. package/templates/.agent/skills/api-patterns/security-testing.md +122 -0
  32. package/templates/.agent/skills/api-patterns/trpc.md +41 -0
  33. package/templates/.agent/skills/api-patterns/versioning.md +22 -0
  34. package/templates/.agent/skills/app-builder/SKILL.md +75 -0
  35. package/templates/.agent/skills/app-builder/agent-coordination.md +71 -0
  36. package/templates/.agent/skills/app-builder/feature-building.md +53 -0
  37. package/templates/.agent/skills/app-builder/project-detection.md +34 -0
  38. package/templates/.agent/skills/app-builder/scaffolding.md +118 -0
  39. package/templates/.agent/skills/app-builder/tech-stack.md +40 -0
  40. package/templates/.agent/skills/app-builder/templates/SKILL.md +39 -0
  41. package/templates/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  42. package/templates/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  43. package/templates/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  44. package/templates/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  45. package/templates/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  46. package/templates/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  47. package/templates/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  48. package/templates/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
  49. package/templates/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
  50. package/templates/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
  51. package/templates/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
  52. package/templates/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  53. package/templates/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
  54. package/templates/.agent/skills/architecture/SKILL.md +55 -0
  55. package/templates/.agent/skills/architecture/context-discovery.md +43 -0
  56. package/templates/.agent/skills/architecture/examples.md +94 -0
  57. package/templates/.agent/skills/architecture/pattern-selection.md +68 -0
  58. package/templates/.agent/skills/architecture/patterns-reference.md +50 -0
  59. package/templates/.agent/skills/architecture/trade-off-analysis.md +77 -0
  60. package/templates/.agent/skills/banner-design/SKILL.md +192 -0
  61. package/templates/.agent/skills/banner-design/references/banner-sizes-and-styles.md +118 -0
  62. package/templates/.agent/skills/bash-linux/SKILL.md +199 -0
  63. package/templates/.agent/skills/behavioral-modes/SKILL.md +242 -0
  64. package/templates/.agent/skills/brainstorming/SKILL.md +163 -0
  65. package/templates/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
  66. package/templates/.agent/skills/brand/SKILL.md +97 -0
  67. package/templates/.agent/skills/brand/references/approval-checklist.md +169 -0
  68. package/templates/.agent/skills/brand/references/asset-organization.md +157 -0
  69. package/templates/.agent/skills/brand/references/brand-guideline-template.md +140 -0
  70. package/templates/.agent/skills/brand/references/color-palette-management.md +186 -0
  71. package/templates/.agent/skills/brand/references/consistency-checklist.md +94 -0
  72. package/templates/.agent/skills/brand/references/logo-usage-rules.md +185 -0
  73. package/templates/.agent/skills/brand/references/messaging-framework.md +85 -0
  74. package/templates/.agent/skills/brand/references/typography-specifications.md +214 -0
  75. package/templates/.agent/skills/brand/references/update.md +118 -0
  76. package/templates/.agent/skills/brand/references/visual-identity.md +96 -0
  77. package/templates/.agent/skills/brand/references/voice-framework.md +88 -0
  78. package/templates/.agent/skills/brand/scripts/extract-colors.cjs +341 -0
  79. package/templates/.agent/skills/brand/scripts/inject-brand-context.cjs +349 -0
  80. package/templates/.agent/skills/brand/scripts/sync-brand-to-tokens.cjs +266 -0
  81. package/templates/.agent/skills/brand/scripts/validate-asset.cjs +387 -0
  82. package/templates/.agent/skills/brand/templates/brand-guidelines-starter.md +275 -0
  83. package/templates/.agent/skills/clean-code/SKILL.md +201 -0
  84. package/templates/.agent/skills/code-review-checklist/SKILL.md +109 -0
  85. package/templates/.agent/skills/copywriting/SKILL.md +250 -0
  86. package/templates/.agent/skills/database-design/SKILL.md +52 -0
  87. package/templates/.agent/skills/database-design/database-selection.md +43 -0
  88. package/templates/.agent/skills/database-design/indexing.md +39 -0
  89. package/templates/.agent/skills/database-design/migrations.md +48 -0
  90. package/templates/.agent/skills/database-design/optimization.md +36 -0
  91. package/templates/.agent/skills/database-design/orm-selection.md +30 -0
  92. package/templates/.agent/skills/database-design/schema-design.md +56 -0
  93. package/templates/.agent/skills/database-design/scripts/schema_validator.py +172 -0
  94. package/templates/.agent/skills/deployment-procedures/SKILL.md +241 -0
  95. package/templates/.agent/skills/docker-expert/SKILL.md +409 -0
  96. package/templates/.agent/skills/frontend-design/animation-guide.md +331 -0
  97. package/templates/.agent/skills/frontend-design/color-system.md +311 -0
  98. package/templates/.agent/skills/frontend-design/decision-trees.md +418 -0
  99. package/templates/.agent/skills/frontend-design/motion-graphics.md +306 -0
  100. package/templates/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  101. package/templates/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  102. package/templates/.agent/skills/frontend-design/typography-system.md +345 -0
  103. package/templates/.agent/skills/frontend-design/ux-psychology.md +541 -0
  104. package/templates/.agent/skills/frontend-design/visual-effects.md +383 -0
  105. package/templates/.agent/skills/frontend-slides/SKILL.md +92 -0
  106. package/templates/.agent/skills/frontend-slides/STYLE_PRESETS.md +347 -0
  107. package/templates/.agent/skills/frontend-slides/animation-patterns.md +110 -0
  108. package/templates/.agent/skills/frontend-slides/examples/n8n-jupviec-automation.html +789 -0
  109. package/templates/.agent/skills/frontend-slides/examples/n8n-jupviec-automation.pptx +0 -0
  110. package/templates/.agent/skills/frontend-slides/html-template.md +347 -0
  111. package/templates/.agent/skills/frontend-slides/scripts/export-pptx.py +58 -0
  112. package/templates/.agent/skills/frontend-slides/scripts/extract-pptx.py +96 -0
  113. package/templates/.agent/skills/frontend-slides/viewport-base.css +153 -0
  114. package/templates/.agent/skills/game-development/2d-games/SKILL.md +119 -0
  115. package/templates/.agent/skills/game-development/3d-games/SKILL.md +135 -0
  116. package/templates/.agent/skills/game-development/SKILL.md +167 -0
  117. package/templates/.agent/skills/game-development/game-art/SKILL.md +185 -0
  118. package/templates/.agent/skills/game-development/game-audio/SKILL.md +190 -0
  119. package/templates/.agent/skills/game-development/game-design/SKILL.md +129 -0
  120. package/templates/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
  121. package/templates/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
  122. package/templates/.agent/skills/game-development/pc-games/SKILL.md +144 -0
  123. package/templates/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
  124. package/templates/.agent/skills/game-development/web-games/SKILL.md +150 -0
  125. package/templates/.agent/skills/geo-fundamentals/SKILL.md +156 -0
  126. package/templates/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
  127. package/templates/.agent/skills/growth-engine/SKILL.md +244 -0
  128. package/templates/.agent/skills/i18n-localization/SKILL.md +154 -0
  129. package/templates/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  130. package/templates/.agent/skills/lint-and-validate/SKILL.md +45 -0
  131. package/templates/.agent/skills/lint-and-validate/scripts/lint_runner.py +172 -0
  132. package/templates/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
  133. package/templates/.agent/skills/mcp-builder/SKILL.md +176 -0
  134. package/templates/.agent/skills/mobile-design/SKILL.md +394 -0
  135. package/templates/.agent/skills/mobile-design/decision-trees.md +516 -0
  136. package/templates/.agent/skills/mobile-design/mobile-backend.md +491 -0
  137. package/templates/.agent/skills/mobile-design/mobile-color-system.md +420 -0
  138. package/templates/.agent/skills/mobile-design/mobile-debugging.md +122 -0
  139. package/templates/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
  140. package/templates/.agent/skills/mobile-design/mobile-navigation.md +458 -0
  141. package/templates/.agent/skills/mobile-design/mobile-performance.md +767 -0
  142. package/templates/.agent/skills/mobile-design/mobile-testing.md +356 -0
  143. package/templates/.agent/skills/mobile-design/mobile-typography.md +433 -0
  144. package/templates/.agent/skills/mobile-design/platform-android.md +666 -0
  145. package/templates/.agent/skills/mobile-design/platform-ios.md +561 -0
  146. package/templates/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
  147. package/templates/.agent/skills/mobile-design/touch-psychology.md +537 -0
  148. package/templates/.agent/skills/nestjs-expert/SKILL.md +552 -0
  149. package/templates/.agent/skills/nextjs-best-practices/SKILL.md +203 -0
  150. package/templates/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
  151. package/templates/.agent/skills/parallel-agents/SKILL.md +175 -0
  152. package/templates/.agent/skills/performance-profiling/SKILL.md +143 -0
  153. package/templates/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
  154. package/templates/.agent/skills/plan-writing/SKILL.md +152 -0
  155. package/templates/.agent/skills/powershell-windows/SKILL.md +167 -0
  156. package/templates/.agent/skills/ppc-advertising/SKILL.md +183 -475
  157. package/templates/.agent/skills/prisma-expert/SKILL.md +355 -0
  158. package/templates/.agent/skills/python-patterns/SKILL.md +441 -0
  159. package/templates/.agent/skills/react-patterns/SKILL.md +198 -0
  160. package/templates/.agent/skills/red-team-tactics/SKILL.md +199 -0
  161. package/templates/.agent/skills/remotion-best-practices/SKILL.md +45 -111
  162. package/templates/.agent/skills/remotion-best-practices/rules/3d.md +4 -4
  163. package/templates/.agent/skills/remotion-best-practices/rules/animations.md +5 -7
  164. package/templates/.agent/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
  165. package/templates/.agent/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
  166. package/templates/.agent/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +103 -0
  167. package/templates/.agent/skills/remotion-best-practices/rules/assets.md +78 -0
  168. package/templates/.agent/skills/remotion-best-practices/rules/audio-visualization.md +198 -0
  169. package/templates/.agent/skills/remotion-best-practices/rules/audio.md +1 -4
  170. package/templates/.agent/skills/remotion-best-practices/rules/calculate-metadata.md +47 -17
  171. package/templates/.agent/skills/remotion-best-practices/rules/can-decode.md +75 -0
  172. package/templates/.agent/skills/remotion-best-practices/rules/charts.md +80 -48
  173. package/templates/.agent/skills/remotion-best-practices/rules/compositions.md +22 -14
  174. package/templates/.agent/skills/remotion-best-practices/rules/display-captions.md +79 -21
  175. package/templates/.agent/skills/remotion-best-practices/rules/extract-frames.md +229 -0
  176. package/templates/.agent/skills/remotion-best-practices/rules/ffmpeg.md +38 -0
  177. package/templates/.agent/skills/remotion-best-practices/rules/fonts.md +96 -54
  178. package/templates/.agent/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
  179. package/templates/.agent/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
  180. package/templates/.agent/skills/remotion-best-practices/rules/get-video-duration.md +60 -0
  181. package/templates/.agent/skills/remotion-best-practices/rules/gifs.md +21 -18
  182. package/templates/.agent/skills/remotion-best-practices/rules/images.md +6 -2
  183. package/templates/.agent/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
  184. package/templates/.agent/skills/remotion-best-practices/rules/light-leaks.md +73 -0
  185. package/templates/.agent/skills/remotion-best-practices/rules/lottie.md +10 -7
  186. package/templates/.agent/skills/remotion-best-practices/rules/maps.md +412 -0
  187. package/templates/.agent/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
  188. package/templates/.agent/skills/remotion-best-practices/rules/measuring-text.md +140 -0
  189. package/templates/.agent/skills/remotion-best-practices/rules/parameters.md +109 -0
  190. package/templates/.agent/skills/remotion-best-practices/rules/sequencing.md +13 -1
  191. package/templates/.agent/skills/remotion-best-practices/rules/sfx.md +26 -0
  192. package/templates/.agent/skills/remotion-best-practices/rules/subtitles.md +36 -0
  193. package/templates/.agent/skills/remotion-best-practices/rules/tailwind.md +11 -0
  194. package/templates/.agent/skills/remotion-best-practices/rules/text-animations.md +4 -115
  195. package/templates/.agent/skills/remotion-best-practices/rules/timing.md +19 -19
  196. package/templates/.agent/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
  197. package/templates/.agent/skills/remotion-best-practices/rules/transitions.md +117 -42
  198. package/templates/.agent/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
  199. package/templates/.agent/skills/remotion-best-practices/rules/trimming.md +51 -0
  200. package/templates/.agent/skills/remotion-best-practices/rules/voiceover.md +99 -0
  201. package/templates/.agent/skills/seo-fundamentals/SKILL.md +83 -441
  202. package/templates/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
  203. package/templates/.agent/skills/server-management/SKILL.md +161 -0
  204. package/templates/.agent/skills/systematic-debugging/SKILL.md +109 -0
  205. package/templates/.agent/skills/tdd-workflow/SKILL.md +149 -0
  206. package/templates/.agent/skills/testing-patterns/SKILL.md +178 -0
  207. package/templates/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
  208. package/templates/.agent/skills/typescript-expert/SKILL.md +429 -0
  209. package/templates/.agent/skills/ui-ux-pro-max/SKILL.md +585 -170
  210. package/templates/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
  211. package/templates/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
  212. package/templates/.agent/skills/ui-ux-pro-max/data/icons.csv +101 -0
  213. package/templates/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
  214. package/templates/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
  215. package/templates/.agent/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  216. package/templates/.agent/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  217. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  218. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  219. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  220. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  221. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  222. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  223. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  224. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  225. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  226. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  227. package/templates/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  228. package/templates/.agent/skills/ui-ux-pro-max/data/styles.csv +59 -0
  229. package/templates/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
  230. package/templates/.agent/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  231. package/templates/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  232. package/templates/.agent/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  233. package/templates/.agent/skills/ui-ux-pro-max/scripts/core.py +257 -0
  234. package/templates/.agent/skills/ui-ux-pro-max/scripts/design_system.py +487 -0
  235. package/templates/.agent/skills/ui-ux-pro-max/scripts/search.py +76 -0
  236. package/templates/.agent/skills/vue-expert/SKILL.md +374 -0
  237. package/templates/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
  238. package/templates/.agent/skills/vulnerability-scanner/checklists.md +121 -0
  239. package/templates/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
  240. package/templates/.agent/skills/webapp-testing/SKILL.md +187 -0
  241. package/templates/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
  242. package/templates/.agent/workflows/brainstorm.md +113 -0
  243. package/templates/.agent/workflows/create.md +59 -0
  244. package/templates/.agent/workflows/debug.md +103 -0
  245. package/templates/.agent/workflows/deploy.md +176 -0
  246. package/templates/.agent/workflows/enhance.md +63 -0
  247. package/templates/.agent/workflows/orchestrate.md +237 -0
  248. package/templates/.agent/workflows/plan.md +89 -0
  249. package/templates/.agent/workflows/preview.md +80 -0
  250. package/templates/.agent/workflows/status.md +86 -0
  251. package/templates/.agent/workflows/test.md +144 -0
  252. package/templates/.agent/workflows/ui-ux-pro-max.md +231 -0
@@ -0,0 +1,257 @@
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
+ }
88
+
89
+ # Common columns for all stacks
90
+ _STACK_COLS = {
91
+ "search_cols": ["Category", "Guideline", "Description", "Do", "Don't"],
92
+ "output_cols": ["Category", "Guideline", "Description", "Do", "Don't", "Code Good", "Code Bad", "Severity", "Docs URL"]
93
+ }
94
+
95
+ AVAILABLE_STACKS = list(STACK_CONFIG.keys())
96
+
97
+
98
+ # ============ BM25 IMPLEMENTATION ============
99
+ class BM25:
100
+ """BM25 ranking algorithm for text search"""
101
+
102
+ def __init__(self, k1=1.5, b=0.75):
103
+ self.k1 = k1
104
+ self.b = b
105
+ self.corpus = []
106
+ self.doc_lengths = []
107
+ self.avgdl = 0
108
+ self.idf = {}
109
+ self.doc_freqs = defaultdict(int)
110
+ self.N = 0
111
+
112
+ def tokenize(self, text):
113
+ """Lowercase, split, remove punctuation, filter short words"""
114
+ text = re.sub(r'[^\w\s]', ' ', str(text).lower())
115
+ return [w for w in text.split() if len(w) > 2]
116
+
117
+ def fit(self, documents):
118
+ """Build BM25 index from documents"""
119
+ self.corpus = [self.tokenize(doc) for doc in documents]
120
+ self.N = len(self.corpus)
121
+ if self.N == 0:
122
+ return
123
+ self.doc_lengths = [len(doc) for doc in self.corpus]
124
+ self.avgdl = sum(self.doc_lengths) / self.N
125
+
126
+ for doc in self.corpus:
127
+ seen = set()
128
+ for word in doc:
129
+ if word not in seen:
130
+ self.doc_freqs[word] += 1
131
+ seen.add(word)
132
+
133
+ for word, freq in self.doc_freqs.items():
134
+ self.idf[word] = log((self.N - freq + 0.5) / (freq + 0.5) + 1)
135
+
136
+ def score(self, query):
137
+ """Score all documents against query"""
138
+ query_tokens = self.tokenize(query)
139
+ scores = []
140
+
141
+ for idx, doc in enumerate(self.corpus):
142
+ score = 0
143
+ doc_len = self.doc_lengths[idx]
144
+ term_freqs = defaultdict(int)
145
+ for word in doc:
146
+ term_freqs[word] += 1
147
+
148
+ for token in query_tokens:
149
+ if token in self.idf:
150
+ tf = term_freqs[token]
151
+ idf = self.idf[token]
152
+ numerator = tf * (self.k1 + 1)
153
+ denominator = tf + self.k1 * (1 - self.b + self.b * doc_len / self.avgdl)
154
+ score += idf * numerator / denominator
155
+
156
+ scores.append((idx, score))
157
+
158
+ return sorted(scores, key=lambda x: x[1], reverse=True)
159
+
160
+
161
+ # ============ SEARCH FUNCTIONS ============
162
+ def _load_csv(filepath):
163
+ """Load CSV and return list of dicts"""
164
+ with open(filepath, 'r', encoding='utf-8') as f:
165
+ return list(csv.DictReader(f))
166
+
167
+
168
+ def _search_csv(filepath, search_cols, output_cols, query, max_results):
169
+ """Core search function using BM25"""
170
+ if not filepath.exists():
171
+ return []
172
+
173
+ data = _load_csv(filepath)
174
+
175
+ # Build documents from search columns
176
+ documents = [" ".join(str(row.get(col, "")) for col in search_cols) for row in data]
177
+
178
+ # BM25 search
179
+ bm25 = BM25()
180
+ bm25.fit(documents)
181
+ ranked = bm25.score(query)
182
+
183
+ # Get top results with score > 0
184
+ results = []
185
+ for idx, score in ranked[:max_results]:
186
+ if score > 0:
187
+ row = data[idx]
188
+ results.append({col: row.get(col, "") for col in output_cols if col in row})
189
+
190
+ return results
191
+
192
+
193
+ def detect_domain(query):
194
+ """Auto-detect the most relevant domain from query"""
195
+ query_lower = query.lower()
196
+
197
+ domain_keywords = {
198
+ "color": ["color", "palette", "hex", "#", "rgb"],
199
+ "chart": ["chart", "graph", "visualization", "trend", "bar", "pie", "scatter", "heatmap", "funnel"],
200
+ "landing": ["landing", "page", "cta", "conversion", "hero", "testimonial", "pricing", "section"],
201
+ "product": ["saas", "ecommerce", "e-commerce", "fintech", "healthcare", "gaming", "portfolio", "crypto", "dashboard"],
202
+ "prompt": ["prompt", "css", "implementation", "variable", "checklist", "tailwind"],
203
+ "style": ["style", "design", "ui", "minimalism", "glassmorphism", "neumorphism", "brutalism", "dark mode", "flat", "aurora"],
204
+ "ux": ["ux", "usability", "accessibility", "wcag", "touch", "scroll", "animation", "keyboard", "navigation", "mobile"],
205
+ "typography": ["font", "typography", "heading", "serif", "sans"],
206
+ "icons": ["icon", "icons", "lucide", "heroicons", "symbol", "glyph", "pictogram", "svg icon"],
207
+ "react": ["react", "next.js", "nextjs", "suspense", "memo", "usecallback", "useeffect", "rerender", "bundle", "waterfall", "barrel", "dynamic import", "rsc", "server component"],
208
+ "web": ["aria", "focus", "outline", "semantic", "virtualize", "autocomplete", "form", "input type", "preconnect"]
209
+ }
210
+
211
+ scores = {domain: sum(1 for kw in keywords if kw in query_lower) for domain, keywords in domain_keywords.items()}
212
+ best = max(scores, key=scores.get)
213
+ return best if scores[best] > 0 else "style"
214
+
215
+
216
+ def search(query, domain=None, max_results=MAX_RESULTS):
217
+ """Main search function with auto-domain detection"""
218
+ if domain is None:
219
+ domain = detect_domain(query)
220
+
221
+ config = CSV_CONFIG.get(domain, CSV_CONFIG["style"])
222
+ filepath = DATA_DIR / config["file"]
223
+
224
+ if not filepath.exists():
225
+ return {"error": f"File not found: {filepath}", "domain": domain}
226
+
227
+ results = _search_csv(filepath, config["search_cols"], config["output_cols"], query, max_results)
228
+
229
+ return {
230
+ "domain": domain,
231
+ "query": query,
232
+ "file": config["file"],
233
+ "count": len(results),
234
+ "results": results
235
+ }
236
+
237
+
238
+ def search_stack(query, stack, max_results=MAX_RESULTS):
239
+ """Search stack-specific guidelines"""
240
+ if stack not in STACK_CONFIG:
241
+ return {"error": f"Unknown stack: {stack}. Available: {', '.join(AVAILABLE_STACKS)}"}
242
+
243
+ filepath = DATA_DIR / STACK_CONFIG[stack]["file"]
244
+
245
+ if not filepath.exists():
246
+ return {"error": f"Stack file not found: {filepath}", "stack": stack}
247
+
248
+ results = _search_csv(filepath, _STACK_COLS["search_cols"], _STACK_COLS["output_cols"], query, max_results)
249
+
250
+ return {
251
+ "domain": "stack",
252
+ "stack": stack,
253
+ "query": query,
254
+ "file": STACK_CONFIG[stack]["file"],
255
+ "count": len(results),
256
+ "results": results
257
+ }