@rune-kit/rune 2.2.0 → 2.2.1

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 (144) hide show
  1. package/README.md +40 -34
  2. package/compiler/__tests__/pack-split.test.js +145 -0
  3. package/compiler/bin/rune.js +0 -5
  4. package/compiler/doctor.js +42 -0
  5. package/compiler/emitter.js +27 -4
  6. package/compiler/parser.js +41 -3
  7. package/compiler/transformer.js +10 -6
  8. package/compiler/transforms/compliance.js +40 -0
  9. package/extensions/ai-ml/PACK.md +38 -474
  10. package/extensions/ai-ml/skills/ai-agents.md +172 -0
  11. package/extensions/ai-ml/skills/code-sandbox.md +187 -0
  12. package/extensions/ai-ml/skills/deep-research.md +146 -0
  13. package/extensions/ai-ml/skills/embedding-search.md +66 -0
  14. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -0
  15. package/extensions/ai-ml/skills/llm-architect.md +125 -0
  16. package/extensions/ai-ml/skills/llm-integration.md +64 -0
  17. package/extensions/ai-ml/skills/prompt-patterns.md +72 -0
  18. package/extensions/ai-ml/skills/rag-patterns.md +66 -0
  19. package/extensions/ai-ml/skills/web-extraction.md +114 -0
  20. package/extensions/analytics/PACK.md +19 -484
  21. package/extensions/analytics/skills/ab-testing.md +72 -0
  22. package/extensions/analytics/skills/dashboard-patterns.md +83 -0
  23. package/extensions/analytics/skills/data-validation.md +68 -0
  24. package/extensions/analytics/skills/funnel-analysis.md +81 -0
  25. package/extensions/analytics/skills/sql-patterns.md +57 -0
  26. package/extensions/analytics/skills/statistical-analysis.md +79 -0
  27. package/extensions/analytics/skills/tracking-setup.md +71 -0
  28. package/extensions/backend/PACK.md +44 -618
  29. package/extensions/backend/skills/api-patterns.md +84 -0
  30. package/extensions/backend/skills/async-pipeline.md +193 -0
  31. package/extensions/backend/skills/auth-patterns.md +97 -0
  32. package/extensions/backend/skills/background-jobs.md +133 -0
  33. package/extensions/backend/skills/caching-patterns.md +108 -0
  34. package/extensions/backend/skills/cli-generation.md +133 -0
  35. package/extensions/backend/skills/database-patterns.md +87 -0
  36. package/extensions/backend/skills/middleware-patterns.md +104 -0
  37. package/extensions/chrome-ext/PACK.md +19 -921
  38. package/extensions/chrome-ext/skills/cws-preflight.md +143 -0
  39. package/extensions/chrome-ext/skills/cws-publish.md +104 -0
  40. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -0
  41. package/extensions/chrome-ext/skills/ext-messaging.md +139 -0
  42. package/extensions/chrome-ext/skills/ext-storage.md +133 -0
  43. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -0
  44. package/extensions/content/PACK.md +43 -335
  45. package/extensions/content/skills/blog-patterns.md +88 -0
  46. package/extensions/content/skills/cms-integration.md +131 -0
  47. package/extensions/content/skills/content-scoring.md +107 -0
  48. package/extensions/content/skills/i18n.md +83 -0
  49. package/extensions/content/skills/mdx-authoring.md +137 -0
  50. package/extensions/content/skills/reference.md +1014 -0
  51. package/extensions/content/skills/seo-patterns.md +67 -0
  52. package/extensions/content/skills/video-repurpose.md +153 -0
  53. package/extensions/devops/PACK.md +38 -457
  54. package/extensions/devops/skills/chaos-testing.md +67 -0
  55. package/extensions/devops/skills/ci-cd.md +75 -0
  56. package/extensions/devops/skills/docker.md +58 -0
  57. package/extensions/devops/skills/edge-serverless.md +163 -0
  58. package/extensions/devops/skills/infra-as-code.md +158 -0
  59. package/extensions/devops/skills/kubernetes.md +110 -0
  60. package/extensions/devops/skills/monitoring.md +57 -0
  61. package/extensions/devops/skills/server-setup.md +64 -0
  62. package/extensions/devops/skills/ssl-domain.md +42 -0
  63. package/extensions/ecommerce/PACK.md +62 -226
  64. package/extensions/ecommerce/skills/cart-system.md +79 -0
  65. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -0
  66. package/extensions/ecommerce/skills/order-management.md +126 -0
  67. package/extensions/ecommerce/skills/payment-integration.md +472 -0
  68. package/extensions/ecommerce/skills/shopify-dev.md +69 -0
  69. package/extensions/ecommerce/skills/subscription-billing.md +93 -0
  70. package/extensions/ecommerce/skills/tax-compliance.md +117 -0
  71. package/extensions/gamedev/PACK.md +66 -317
  72. package/extensions/gamedev/skills/asset-pipeline.md +74 -0
  73. package/extensions/gamedev/skills/audio-system.md +129 -0
  74. package/extensions/gamedev/skills/camera-system.md +87 -0
  75. package/extensions/gamedev/skills/ecs.md +98 -0
  76. package/extensions/gamedev/skills/game-loops.md +72 -0
  77. package/extensions/gamedev/skills/input-system.md +199 -0
  78. package/extensions/gamedev/skills/multiplayer.md +180 -0
  79. package/extensions/gamedev/skills/particles.md +105 -0
  80. package/extensions/gamedev/skills/physics-engine.md +89 -0
  81. package/extensions/gamedev/skills/scene-management.md +146 -0
  82. package/extensions/gamedev/skills/threejs-patterns.md +90 -0
  83. package/extensions/gamedev/skills/webgl.md +71 -0
  84. package/extensions/mobile/PACK.md +56 -223
  85. package/extensions/mobile/skills/app-store-connect.md +152 -0
  86. package/extensions/mobile/skills/app-store-prep.md +66 -0
  87. package/extensions/mobile/skills/deep-linking.md +109 -0
  88. package/extensions/mobile/skills/flutter.md +60 -0
  89. package/extensions/mobile/skills/ios-build-pipeline.md +142 -0
  90. package/extensions/mobile/skills/native-bridge.md +66 -0
  91. package/extensions/mobile/skills/ota-updates.md +97 -0
  92. package/extensions/mobile/skills/push-notifications.md +111 -0
  93. package/extensions/mobile/skills/react-native.md +82 -0
  94. package/extensions/saas/PACK.md +26 -720
  95. package/extensions/saas/skills/billing-integration.md +121 -0
  96. package/extensions/saas/skills/feature-flags.md +130 -0
  97. package/extensions/saas/skills/multi-tenant.md +103 -0
  98. package/extensions/saas/skills/onboarding-flow.md +139 -0
  99. package/extensions/saas/skills/subscription-flow.md +95 -0
  100. package/extensions/saas/skills/team-management.md +144 -0
  101. package/extensions/security/PACK.md +10 -448
  102. package/extensions/security/skills/api-security.md +140 -0
  103. package/extensions/security/skills/compliance.md +68 -0
  104. package/extensions/security/skills/owasp-audit.md +64 -0
  105. package/extensions/security/skills/pentest-patterns.md +77 -0
  106. package/extensions/security/skills/secret-mgmt.md +65 -0
  107. package/extensions/security/skills/supply-chain.md +65 -0
  108. package/extensions/trading/PACK.md +18 -535
  109. package/extensions/trading/skills/chart-components.md +55 -0
  110. package/extensions/trading/skills/experiment-loop.md +125 -0
  111. package/extensions/trading/skills/fintech-patterns.md +47 -0
  112. package/extensions/trading/skills/indicator-library.md +58 -0
  113. package/extensions/trading/skills/quant-analysis.md +111 -0
  114. package/extensions/trading/skills/realtime-data.md +58 -0
  115. package/extensions/trading/skills/trade-logic.md +104 -0
  116. package/extensions/ui/PACK.md +34 -853
  117. package/extensions/ui/skills/a11y-audit.md +91 -0
  118. package/extensions/ui/skills/animation-patterns.md +106 -0
  119. package/extensions/ui/skills/component-patterns.md +75 -0
  120. package/extensions/ui/skills/design-decision.md +98 -0
  121. package/extensions/ui/skills/design-system.md +68 -0
  122. package/extensions/ui/skills/landing-patterns.md +155 -0
  123. package/extensions/ui/skills/palette-picker.md +162 -0
  124. package/extensions/ui/skills/react-health.md +90 -0
  125. package/extensions/ui/skills/type-system.md +125 -0
  126. package/extensions/ui/skills/web-vitals.md +153 -0
  127. package/extensions/zalo/PACK.md +117 -0
  128. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -0
  129. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -0
  130. package/extensions/zalo/skills/zalo-oa-setup.md +236 -0
  131. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -0
  132. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -0
  133. package/extensions/zalo/skills/zalo-personal-setup.md +153 -0
  134. package/extensions/zalo/skills/zalo-rate-guard.md +219 -0
  135. package/package.json +1 -1
  136. package/skills/brainstorm/SKILL.md +63 -1
  137. package/skills/cook/SKILL.md +84 -5
  138. package/skills/mcp-builder/SKILL.md +48 -1
  139. package/skills/review/SKILL.md +42 -5
  140. package/skills/review-intake/SKILL.md +17 -1
  141. package/skills/skill-router/SKILL.md +89 -7
  142. package/skills/team/SKILL.md +24 -1
  143. package/skills/test/SKILL.md +18 -0
  144. package/skills/verification/SKILL.md +40 -1
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: "palette-picker"
3
+ pack: "@rune/ui"
4
+ description: "Color palette database organized by product type. 25 curated palettes covering fintech, healthcare, education, gaming, ecommerce, SaaS, social, news/content, productivity, and developer tools — each with CSS custom properties, Tailwind config extension, dark/light variants, and colorblind-safe alternatives."
5
+ model: sonnet
6
+ tools: [Read, Edit, Write, Grep, Glob, Bash]
7
+ ---
8
+
9
+ # palette-picker
10
+
11
+ Color palette database organized by product type. 25 curated palettes covering fintech, healthcare, education, gaming, ecommerce, SaaS, social, news/content, productivity, and developer tools — each with CSS custom properties, Tailwind config extension, dark/light variants, and colorblind-safe alternatives.
12
+
13
+ #### Workflow
14
+
15
+ **Step 1 — Detect product type**
16
+ Read `CLAUDE.md`, `README.md`, or ask: "What does this product do?" Classify into one of: fintech | healthcare | education | gaming | ecommerce | saas | social | news-content | productivity | devtools.
17
+
18
+ **Step 2 — Recommend palette**
19
+ Apply the decision tree below. Output the top 2 palette candidates with rationale (mood, contrast profile, brand signal).
20
+
21
+ **Step 3 — Generate token file**
22
+ Emit `palette.css` with CSS custom properties for the chosen palette. Include both dark and light variants. Include Tailwind `theme.extend.colors` block.
23
+
24
+ **Step 4 — Verify contrast ratios**
25
+ Run contrast checks: primary text on background (≥ 4.5:1), large headings (≥ 3:1), interactive elements on their backgrounds. Flag any failure. Substitute colorblind-safe alternative if requested.
26
+
27
+ #### Decision Tree
28
+
29
+ ```
30
+ Product Type → Palette Recommendation
31
+ ─────────────────────────────────────────────────
32
+ fintech / trading → Midnight Profit (dark bg + green/red signals)
33
+ healthcare → Clean Clinic (white/teal, high readability)
34
+ education / kids → Warm Academy (amber/orange, approachable)
35
+ gaming → Neon Arena (dark + electric cyan/magenta)
36
+ ecommerce → Trust Cart (white + amber CTA + forest green)
37
+ saas / dashboard → Slate Precision (slate-900 + blue-500 accents)
38
+ social / community → Gradient Social (slate + violet/fuchsia gradient)
39
+ news / content → Neutral Ink (off-white + near-black, serif-ready)
40
+ productivity / tools → Calm Focus (gray-50 + indigo-700, minimal noise)
41
+ developer tools → Terminal Dark (zinc-950 + emerald-400 mono)
42
+ ```
43
+
44
+ #### Palette Reference
45
+
46
+ ```css
47
+ /* ── PALETTE: Midnight Profit (Fintech/Trading) ─────────────── */
48
+ [data-palette="midnight-profit"][data-theme="dark"] {
49
+ --bg-base: #0c1419;
50
+ --bg-card: #121a20;
51
+ --bg-elevated: #1a2332;
52
+ --text-primary: #ffffff;
53
+ --text-secondary: #a0aeb8;
54
+ --border: #2a3f52;
55
+ --profit: #00d084; /* green — gains */
56
+ --loss: #ff6b6b; /* red — losses */
57
+ --accent: #2196f3;
58
+ /* Colorblind (deuteranopia): profit→#1e88e5, loss→#ffa726 */
59
+ }
60
+ [data-palette="midnight-profit"][data-theme="light"] {
61
+ --bg-base: #faf8f3;
62
+ --bg-card: #f5f0ea;
63
+ --text-primary: #0c1419;
64
+ --text-secondary: #4a5568;
65
+ --border: #d1cfc9;
66
+ --profit: #059669;
67
+ --loss: #dc2626;
68
+ --accent: #1d4ed8;
69
+ }
70
+
71
+ /* ── PALETTE: Clean Clinic (Healthcare) ─────────────────────── */
72
+ [data-palette="clean-clinic"] {
73
+ --bg-base: #f0fafa;
74
+ --bg-card: #ffffff;
75
+ --text-primary: #0d1f2d;
76
+ --text-secondary: #4b6070;
77
+ --border: #c7e8ea;
78
+ --primary: #0891b2; /* cyan-600 */
79
+ --secondary: #0d9488; /* teal-600 */
80
+ --accent: #06b6d4;
81
+ --danger: #ef4444;
82
+ --success: #16a34a;
83
+ }
84
+
85
+ /* ── PALETTE: Slate Precision (SaaS/Dashboard) ───────────────── */
86
+ [data-palette="slate-precision"][data-theme="dark"] {
87
+ --bg-base: #0f172a;
88
+ --bg-card: #1e293b;
89
+ --bg-elevated: #334155;
90
+ --text-primary: #f8fafc;
91
+ --text-secondary: #94a3b8;
92
+ --primary: #3b82f6; /* blue-500 */
93
+ --success: #10b981;
94
+ --danger: #ef4444;
95
+ --warning: #f59e0b;
96
+ }
97
+ [data-palette="slate-precision"][data-theme="light"] {
98
+ --bg-base: #ffffff;
99
+ --bg-card: #f8fafc;
100
+ --bg-elevated: #f1f5f9;
101
+ --text-primary: #0f172a;
102
+ --text-secondary: #475569;
103
+ --primary: #2563eb;
104
+ }
105
+
106
+ /* ── PALETTE: Neon Arena (Gaming) ────────────────────────────── */
107
+ [data-palette="neon-arena"] {
108
+ --bg-base: #080c10;
109
+ --bg-card: #0f1520;
110
+ --text-primary: #e8f4f8;
111
+ --text-secondary: #7a9ab0;
112
+ --primary: #00ffe0; /* electric cyan */
113
+ --secondary: #ff2d78; /* hot magenta */
114
+ --accent: #ffe600; /* warning yellow */
115
+ --border: rgba(0, 255, 224, 0.15);
116
+ }
117
+
118
+ /* ── PALETTE: Trust Cart (Ecommerce) ─────────────────────────── */
119
+ [data-palette="trust-cart"][data-theme="light"] {
120
+ --bg-base: #ffffff;
121
+ --bg-card: #fafafa;
122
+ --text-primary: #111827;
123
+ --text-secondary: #6b7280;
124
+ --cta: #f97316; /* orange-500 — add-to-cart */
125
+ --success: #16a34a; /* forest green — in stock */
126
+ --trust: #1d4ed8; /* blue — secure badge */
127
+ --border: #e5e7eb;
128
+ }
129
+
130
+ /* ── PALETTE: Terminal Dark (Developer Tools) ────────────────── */
131
+ [data-palette="terminal-dark"] {
132
+ --bg-base: #09090b; /* zinc-950 */
133
+ --bg-card: #18181b; /* zinc-900 */
134
+ --bg-elevated: #27272a; /* zinc-800 */
135
+ --text-primary: #fafafa;
136
+ --text-secondary: #a1a1aa;
137
+ --primary: #34d399; /* emerald-400 — code green */
138
+ --accent: #818cf8; /* indigo-400 — links */
139
+ --border: #3f3f46;
140
+ --comment: #71717a;
141
+ }
142
+ ```
143
+
144
+ ```js
145
+ // tailwind.config.js — extending with palette tokens
146
+ /** @type {import('tailwindcss').Config} */
147
+ module.exports = {
148
+ theme: {
149
+ extend: {
150
+ colors: {
151
+ profit: 'var(--profit)',
152
+ loss: 'var(--loss)',
153
+ primary: 'var(--primary)',
154
+ 'bg-base': 'var(--bg-base)',
155
+ 'bg-card': 'var(--bg-card)',
156
+ 'text-primary': 'var(--text-primary)',
157
+ 'text-secondary': 'var(--text-secondary)',
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ```
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: "react-health"
3
+ pack: "@rune/ui"
4
+ description: "React codebase health scoring — 0-100 health score across 6 dimensions: state management, effects hygiene, performance patterns, architecture, bundle efficiency, and accessibility."
5
+ model: sonnet
6
+ tools: [Read, Edit, Write, Grep, Glob, Bash]
7
+ ---
8
+
9
+ # react-health
10
+
11
+ React codebase health scoring — 0-100 health score across 6 dimensions: state management, effects hygiene, performance patterns, architecture, bundle efficiency, and accessibility. Detects anti-patterns that automated linters miss, quantifies technical debt, and produces a prioritized fix list.
12
+
13
+ #### Workflow
14
+
15
+ **Step 1 — Detect framework and React version**
16
+ Read `package.json` to identify: React version (17/18/19), framework (Next.js, Vite, Remix, Astro), compiler status (`react-compiler` or `babel-plugin-react-compiler`), and styling approach (Tailwind, CSS Modules, styled-components). Framework context changes which rules apply — Next.js has App Router-specific patterns, Vite has different chunking strategies.
17
+
18
+ **Step 2 — State and effects audit**
19
+ Use Grep to scan for these anti-patterns across all `*.tsx`, `*.jsx` files:
20
+
21
+ | Anti-Pattern | Grep Pattern | Why It's Bad |
22
+ |---|---|---|
23
+ | Derived state in useState | `useState.*=.*props\.` or `useEffect.*setState` that mirrors a prop | Causes sync bugs — compute during render instead |
24
+ | Unnecessary effects for data transform | `useEffect.*setState.*filter\|map\|reduce` | Runs after render for no reason — move to useMemo or compute inline |
25
+ | Missing cleanup in effects | `useEffect` without `return () =>` when subscribing | Memory leaks on unmount (WebSocket, intervals, event listeners) |
26
+ | State for ref-appropriate values | `useState` tracking DOM measurements, timers, previous values | Causes unnecessary re-renders — use useRef |
27
+ | Prop drilling > 3 levels | Component chains passing the same prop through 3+ files | Extract to Context or Zustand store |
28
+ | God component > 300 lines | Component files exceeding 300 LOC | Split into composed smaller components |
29
+
30
+ Score: count violations, weight by severity (critical=5, high=3, medium=1), calculate percentage against total component count.
31
+
32
+ **Step 3 — Dead code detection**
33
+ Scan for unused exports, orphaned files, and dead types:
34
+ - **Unused exports**: Use Grep to find all `export` declarations, then cross-reference with import statements across the codebase. Any export not imported anywhere (excluding entry points and barrel files) is dead.
35
+ - **Orphan files**: Use Glob to find all `.tsx`/`.ts` files, then check which are never imported. Exclude test files, config files, and entry points.
36
+ - **Duplicate components**: Find components with similar names or identical prop interfaces that could be consolidated.
37
+ - **Barrel file bloat**: Flag `index.ts` files that re-export everything — these break tree-shaking and increase bundle size.
38
+
39
+ **Step 4 — Bundle efficiency audit**
40
+ Check for common bundle bloat patterns:
41
+ - **Wholesale imports**: `import _ from 'lodash'` instead of `import groupBy from 'lodash/groupBy'` — can add 70KB+ to bundle
42
+ - **Moment.js usage**: Flag any `import moment` — suggest `date-fns` or `dayjs` (moment is 300KB with locales)
43
+ - **Icon library imports**: `import { Icon } from 'react-icons'` importing the full set — use specific pack imports
44
+ - **Missing dynamic imports**: Large components (charts, editors, modals) loaded eagerly — should use `React.lazy()` or Next.js `dynamic()`
45
+ - **Polyfill sprawl**: Check `browserslist` or `@babel/preset-env` targets — modern-only targets can drop 20-50KB of polyfills
46
+ - **CSS-in-JS runtime cost**: Flag `styled-components` or `@emotion/styled` in performance-critical paths — suggest extraction or Tailwind
47
+
48
+ **Step 5 — Performance patterns check**
49
+ Scan for React-specific performance issues:
50
+ - `React.memo` wrapping components that receive new object/array literals as props (memo is useless with `style={{}}` or `data={[...]}}`)
51
+ - Missing `key` prop on list items, or using array index as key on dynamic lists
52
+ - Inline function creation in JSX (`onClick={() => fn(id)}`) inside large lists (>50 items) without `useCallback`
53
+ - `useEffect` with missing dependencies (lint-suppressed with `// eslint-disable-next-line`)
54
+ - Context providers wrapping the entire app when only a subtree needs them (causes full-app re-renders)
55
+ - Unvirtualized lists rendering >50 items — flag for `@tanstack/react-virtual` or `react-window`
56
+
57
+ **Step 6 — Generate health report**
58
+ Produce a structured health report with scores:
59
+
60
+ ```
61
+ React Health Report — [Project Name]
62
+ ═══════════════════════════════════════
63
+ Overall Score: 72/100 (Needs work)
64
+
65
+ Dimension Score Issues Found
66
+ ─────────────────────────────────────
67
+ State/Effects 65/100 3 derived states, 2 missing cleanups
68
+ Performance 78/100 1 unvirtualized list, barrel file bloat
69
+ Architecture 80/100 1 god component (412 lines)
70
+ Bundle Efficiency 60/100 lodash wholesale import, no dynamic imports
71
+ Dead Code 85/100 4 unused exports, 1 orphan file
72
+ Accessibility 70/100 6 icon buttons missing aria-label
73
+
74
+ Score Tiers: 75+ Great │ 50-74 Needs Work │ <50 Critical
75
+
76
+ Top 5 Fixes (by impact):
77
+ 1. [CRITICAL] Replace lodash wholesale import → save ~70KB
78
+ 2. [HIGH] Add React.lazy() to ChartPanel and RichEditor
79
+ 3. [HIGH] Extract derived state from useEffect in UserList
80
+ 4. [MEDIUM] Virtualize TransactionTable (renders 200+ rows)
81
+ 5. [MEDIUM] Remove 4 unused exports in utils/
82
+ ```
83
+
84
+ #### Sharp Edges
85
+
86
+ | Failure Mode | Mitigation |
87
+ |---|---|
88
+ | False positives on "unused exports" in library packages | Exclude files matching `package.json` `main`/`exports` entry points |
89
+ | Barrel file detection flags intentional public API re-exports | Only flag barrel files in `src/` not in package root |
90
+ | God component count includes generated files | Exclude files matching `*.generated.*`, `*.auto.*` patterns |
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: "type-system"
3
+ pack: "@rune/ui"
4
+ description: "Typography pairing database — 22 font pairings organized by product vibe. Each pairing includes Google Fonts URL, Tailwind config, size scale from display to caption, weight mapping, and line height ratios."
5
+ model: sonnet
6
+ tools: [Read, Edit, Write, Grep, Glob, Bash]
7
+ ---
8
+
9
+ # type-system
10
+
11
+ Typography pairing database — 22 font pairings organized by product vibe. Each pairing includes Google Fonts URL, Tailwind config, size scale from display to caption, weight mapping, and line height ratios. Decision tree maps product type and tone to the right pairing.
12
+
13
+ #### Workflow
14
+
15
+ **Step 1 — Detect product tone**
16
+ Read `CLAUDE.md` or ask: "What is the product tone?" Classify: modern-tech | editorial | playful | corporate | developer | luxury | humanist | brutalist | minimal.
17
+
18
+ **Step 2 — Recommend pairing**
19
+ Apply the decision tree. Output the top 2 pairings with rationale (brand signal, readability score, Google Fonts load weight).
20
+
21
+ **Step 3 — Generate @font-face / config**
22
+ Emit the `<link>` preconnect + stylesheet tag for Google Fonts. Emit Tailwind `fontFamily` config. Emit a CSS type scale (`--text-display` through `--text-caption`).
23
+
24
+ **Step 4 — Verify readability**
25
+ Check: body size ≥ 14px, line-height ≥ 1.5 for body, ≤ 1.25 for headings. Flag any contrast failure using the project's background token.
26
+
27
+ #### Decision Tree
28
+
29
+ ```
30
+ Product Tone → Pairing
31
+ ──────────────────────────────────────────────────────────
32
+ modern tech / saas → Space Grotesk + Inter
33
+ editorial / blog → Playfair Display + Source Serif 4
34
+ playful / kids / app → Fredoka + Nunito
35
+ corporate / enterprise→ IBM Plex Sans + IBM Plex Serif
36
+ developer tools / CLI → JetBrains Mono + Inter
37
+ luxury / fashion → Cormorant Garamond + Montserrat
38
+ humanist / health → DM Sans + DM Serif Display
39
+ brutalist / bold → Bebas Neue + IBM Plex Mono
40
+ minimal / productivity→ Inter + Inter (weight-only hierarchy)
41
+ gaming / esports → Rajdhani + Exo 2
42
+ ```
43
+
44
+ #### Pairing Reference
45
+
46
+ ```html
47
+ <!-- Space Grotesk + Inter (modern-tech / saas) -->
48
+ <link rel="preconnect" href="https://fonts.googleapis.com">
49
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
50
+ <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
51
+
52
+ <!-- Playfair Display + Source Serif 4 (editorial) -->
53
+ <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400&family=Source+Serif+4:wght@400;600&display=swap" rel="stylesheet">
54
+
55
+ <!-- Fredoka + Nunito (playful) -->
56
+ <link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Nunito:wght@400;600&display=swap" rel="stylesheet">
57
+
58
+ <!-- IBM Plex Sans + IBM Plex Serif (corporate) -->
59
+ <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Serif:wght@400;600&display=swap" rel="stylesheet">
60
+
61
+ <!-- JetBrains Mono + Inter (developer tools) -->
62
+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
63
+
64
+ <!-- Cormorant Garamond + Montserrat (luxury) -->
65
+ <link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,600;1,400&family=Montserrat:wght@400;500;700&display=swap" rel="stylesheet">
66
+
67
+ <!-- DM Sans + DM Serif Display (humanist / health) -->
68
+ <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Serif+Display&display=swap" rel="stylesheet">
69
+ ```
70
+
71
+ ```css
72
+ /* Type scale — Space Grotesk + Inter pairing */
73
+ :root {
74
+ --font-display: 'Space Grotesk', system-ui, sans-serif;
75
+ --font-body: 'Inter', system-ui, sans-serif;
76
+ --font-mono: 'JetBrains Mono', monospace;
77
+
78
+ /* Scale */
79
+ --text-display: clamp(2.5rem, 5vw, 4.5rem); /* 40–72px */
80
+ --text-h1: clamp(2rem, 4vw, 2.5rem); /* 32–40px */
81
+ --text-h2: clamp(1.375rem, 2.5vw, 1.75rem); /* 22–28px */
82
+ --text-h3: 1.125rem; /* 18px */
83
+ --text-body: 1rem; /* 16px */
84
+ --text-small: 0.875rem; /* 14px */
85
+ --text-caption: 0.75rem; /* 12px */
86
+
87
+ /* Leading */
88
+ --leading-tight: 1.2;
89
+ --leading-snug: 1.35;
90
+ --leading-normal: 1.5;
91
+ --leading-relaxed:1.75;
92
+ }
93
+
94
+ h1, h2, h3 { font-family: var(--font-display); line-height: var(--leading-tight); }
95
+ body { font-family: var(--font-body); line-height: var(--leading-normal); }
96
+ code, pre { font-family: var(--font-mono); }
97
+
98
+ /* Financial numbers — always mono + bold */
99
+ .number, .price, .stat {
100
+ font-family: var(--font-mono);
101
+ font-weight: 700;
102
+ font-variant-numeric: tabular-nums;
103
+ }
104
+ ```
105
+
106
+ ```js
107
+ // tailwind.config.js — font pairing extension
108
+ module.exports = {
109
+ theme: {
110
+ extend: {
111
+ fontFamily: {
112
+ display: ['Space Grotesk', 'system-ui', 'sans-serif'],
113
+ body: ['Inter', 'system-ui', 'sans-serif'],
114
+ mono: ['JetBrains Mono','monospace'],
115
+ },
116
+ fontSize: {
117
+ 'display': ['clamp(2.5rem, 5vw, 4.5rem)', { lineHeight: '1.1' }],
118
+ 'h1': ['clamp(2rem, 4vw, 2.5rem)', { lineHeight: '1.2' }],
119
+ 'h2': ['1.75rem', { lineHeight: '1.3' }],
120
+ 'h3': ['1.125rem', { lineHeight: '1.4' }],
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ```
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: "web-vitals"
3
+ pack: "@rune/ui"
4
+ description: "Core Web Vitals performance audit — measures LCP, CLS, FCP, TBT, INP, and Speed Index against Google thresholds. Identifies render-blocking resources, network dependency chains, layout shift culprits, missing preloads, caching gaps, and tree-shaking opportunities."
5
+ model: sonnet
6
+ tools: [Read, Edit, Write, Grep, Glob, Bash]
7
+ ---
8
+
9
+ # web-vitals
10
+
11
+ Core Web Vitals performance audit — measures LCP, CLS, FCP, TBT, INP, and Speed Index against Google thresholds. Identifies render-blocking resources, network dependency chains, layout shift culprits, missing preloads, caching gaps, and tree-shaking opportunities. Framework-aware analysis for Next.js, Vite, SvelteKit, and Astro.
12
+
13
+ #### Workflow
14
+
15
+ **Step 1 — Detect build tooling and framework**
16
+ Read `package.json`, config files (`next.config.*`, `vite.config.*`, `svelte.config.*`, `astro.config.*`), and build scripts. Identify:
17
+ - Bundler: Webpack, Vite, Rollup, esbuild, Turbopack
18
+ - Framework: Next.js (App Router vs Pages), SvelteKit, Astro, Remix
19
+ - CSS strategy: Tailwind (content config), CSS Modules, global CSS
20
+ - Compression: gzip/brotli configuration
21
+ - Source maps: enabled in production? (should be external or disabled)
22
+
23
+ **Step 2 — Audit render-blocking resources**
24
+ Use Grep to scan HTML entry points and framework layouts for:
25
+ - `<link rel="stylesheet">` in `<head>` without `media` attribute — blocks first paint
26
+ - `<script>` tags without `async` or `defer` — blocks HTML parsing
27
+ - CSS `@import` chains — each import is a sequential network request
28
+ - Large inline `<style>` blocks (>50KB) — delays first paint
29
+
30
+ For each blocking resource, estimate impact: 0ms impact = note but don't prioritize. Focus on resources that delay FCP by >100ms.
31
+
32
+ **Step 3 — Analyze layout shift sources (CLS)**
33
+ Use Grep to find common CLS culprits:
34
+ - `<img>` and `<video>` without explicit `width` and `height` attributes — causes layout shift when media loads
35
+ - Dynamic content injection above the fold (`insertBefore`, `prepend`, or React `useState` toggling visibility)
36
+ - Web fonts without `font-display: swap` or `font-display: optional` — FOIT causes text layout shift
37
+ - Ads or embeds without reserved space (`aspect-ratio` or `min-height` on container)
38
+ - CSS animations that trigger layout (`top`, `left`, `width`, `height`) instead of composited properties (`transform`, `opacity`)
39
+
40
+ #### CLS Fix Patterns
41
+
42
+ ```html
43
+ <!-- BEFORE: no dimensions → layout shift when image loads -->
44
+ <img src="/hero.jpg" alt="Hero" />
45
+
46
+ <!-- AFTER: explicit dimensions prevent CLS -->
47
+ <img src="/hero.jpg" alt="Hero" width="1200" height="630"
48
+ class="w-full h-auto" loading="lazy" decoding="async" />
49
+ ```
50
+
51
+ ```css
52
+ /* Font display — prevent FOIT layout shift */
53
+ @font-face {
54
+ font-family: 'Space Grotesk';
55
+ src: url('/fonts/space-grotesk.woff2') format('woff2');
56
+ font-display: swap; /* show fallback immediately, swap when loaded */
57
+ }
58
+
59
+ /* Reserve space for dynamic content */
60
+ .ad-container {
61
+ min-height: 250px; /* match ad unit height */
62
+ contain: layout; /* prevent layout influence on siblings */
63
+ }
64
+ ```
65
+
66
+ **Step 4 — Network dependency chain analysis**
67
+ Identify critical rendering path bottlenecks:
68
+ - **Waterfall chains**: Resource A loads → discovers Resource B → discovers Resource C. Each link adds latency. Fix with `<link rel="preload">` for critical assets.
69
+ - **Missing preconnects**: Third-party origins (fonts.googleapis.com, CDN, analytics) without `<link rel="preconnect">`. But verify the origin is actually used — unused preconnects waste connection resources.
70
+ - **Large payloads without compression**: JS/CSS bundles >100KB served without gzip/brotli. Check server response headers for `Content-Encoding`.
71
+ - **Duplicate requests**: Same resource fetched multiple times (common with CSS @import or uncoordinated dynamic imports).
72
+
73
+ ```html
74
+ <!-- Preload critical resources discovered late in the waterfall -->
75
+ <link rel="preload" href="/fonts/inter-var.woff2" as="font"
76
+ type="font/woff2" crossorigin />
77
+ <link rel="preload" href="/hero-image.webp" as="image"
78
+ fetchpriority="high" />
79
+
80
+ <!-- Preconnect to third-party origins ACTUALLY used -->
81
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
82
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
83
+ ```
84
+
85
+ **Step 5 — Tree-shaking and code splitting audit**
86
+ Check bundler configuration and import patterns:
87
+
88
+ | Issue | Detection | Fix |
89
+ |---|---|---|
90
+ | Barrel file re-exports break tree-shaking | `index.ts` with `export * from` or `export { A, B, C, ... }` importing everything | Import directly from source: `import { Button } from './Button'` not `from '.'` |
91
+ | `sideEffects: false` missing in package.json | Check `package.json` `sideEffects` field | Add `"sideEffects": false` (or list files with side effects like CSS imports) |
92
+ | No code splitting at route level | Framework routes without `React.lazy()` or `dynamic()` | Next.js does this automatically; Vite needs manual `React.lazy()` |
93
+ | Vendor chunk too large (>250KB) | Check build output for single large chunk | Configure `splitChunks` (Webpack) or `manualChunks` (Vite/Rollup) |
94
+ | CSS not purged | Tailwind without `content` config, or unused CSS classes shipping | Verify `tailwind.config.js` `content` paths cover all template files |
95
+
96
+ **Step 6 — Image optimization audit**
97
+ Scan for image-related performance issues:
98
+ - Serving JPEG/PNG when WebP/AVIF would save 30-60% bandwidth — check `<img>` `src` extensions
99
+ - Missing `loading="lazy"` on below-the-fold images
100
+ - Missing `fetchpriority="high"` on LCP image (hero image, above-the-fold banner)
101
+ - Images served at full resolution without responsive `srcset` — wastes bandwidth on mobile
102
+ - No `<picture>` element for art direction (different crops for mobile/desktop)
103
+
104
+ ```html
105
+ <!-- Optimized responsive image with modern formats -->
106
+ <picture>
107
+ <source srcset="/hero.avif" type="image/avif" />
108
+ <source srcset="/hero.webp" type="image/webp" />
109
+ <img
110
+ src="/hero.jpg"
111
+ alt="Product dashboard showing real-time analytics"
112
+ width="1200" height="630"
113
+ class="w-full h-auto"
114
+ fetchpriority="high"
115
+ decoding="async"
116
+ />
117
+ </picture>
118
+
119
+ <!-- Below-the-fold: lazy load -->
120
+ <img src="/feature.webp" alt="..." loading="lazy" decoding="async"
121
+ width="600" height="400" class="w-full h-auto" />
122
+ ```
123
+
124
+ **Step 7 — Generate performance report**
125
+ Produce a structured report with Core Web Vitals thresholds:
126
+
127
+ ```
128
+ Web Vitals Audit — [Project Name]
129
+ ═══════════════════════════════════════
130
+ Thresholds (Good / Needs Improvement / Poor):
131
+ LCP: < 2.5s / < 4.0s / > 4.0s
132
+ FCP: < 1.8s / < 3.0s / > 3.0s
133
+ CLS: < 0.1 / < 0.25 / > 0.25
134
+ INP: < 200ms / < 500ms / > 500ms
135
+ TBT: < 200ms / < 600ms / > 600ms
136
+ TTFB: < 800ms / < 1.8s / > 1.8s
137
+
138
+ Top Issues (by estimated impact):
139
+ 1. [HIGH] Hero image served as 2.4MB PNG — convert to WebP, save ~1.5MB
140
+ 2. [HIGH] 3 render-blocking stylesheets in <head> — defer non-critical CSS
141
+ 3. [MEDIUM] 4 images missing width/height — causes CLS on load
142
+ 4. [MEDIUM] lodash imported wholesale — tree-shake or replace with lodash-es
143
+ 5. [LOW] Font preconnect to unused origin — remove to free connection slot
144
+ ```
145
+
146
+ #### Sharp Edges
147
+
148
+ | Failure Mode | Mitigation |
149
+ |---|---|
150
+ | Recommending image lazy-load on LCP element | Never lazy-load the LCP image — it must load eagerly with `fetchpriority="high"` |
151
+ | Flagging render-blocking CSS that's actually critical | Distinguish critical (above-fold) CSS from non-critical before recommending defer |
152
+ | Tree-shaking audit false positives on CSS-in-JS | CSS `import './styles.css'` is a side effect — don't flag as unused |
153
+ | Preconnect removal breaks actual resource loading | Always verify zero requests went to the origin before recommending removal |
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: "@rune/zalo"
3
+ description: Zalo platform integration — Official Account API (OAuth2, messaging, webhooks, MCP server) and personal account automation (zca-js). Dual-track with explicit risk gating.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.1.0"
7
+ layer: L4
8
+ price: free
9
+ target: Vietnamese developers building Zalo bots, OA automation, and AI agent integrations
10
+ format: split
11
+ ---
12
+
13
+ # @rune/zalo
14
+
15
+ ## Purpose
16
+
17
+ Zalo is Vietnam's dominant messaging platform (~75M users) but its developer ecosystem has critical gaps: no Node.js SDK, zero webhook handling in official SDKs, undocumented rate limits, and confusing dual-token OAuth2 flows. This pack provides production-ready guidance for two tracks:
18
+
19
+ **Track A — Official Account API** (production-safe): OAuth2 PKCE, 8 message types, webhook server, token lifecycle, and MCP server blueprint for AI agent integration. Use this for business chatbots, customer support automation, and notification systems.
20
+
21
+ **Track B — Personal Account via zca-js** (unofficial, risk-gated): QR login, personal/group messaging, media handling. Use this for personal bots, group utilities, and rapid prototyping before committing to OA.
22
+
23
+ Both tracks share a rate limiting skill — the #1 cause of account bans.
24
+
25
+ ## Best Fit
26
+
27
+ - Vietnamese dev teams building Zalo OA chatbots or customer support automation
28
+ - AI agent projects that need Zalo as a communication channel (MCP server pattern)
29
+ - Personal automation: group bots, notification forwarders, quick prototypes
30
+ - Projects migrating from unofficial to official Zalo API
31
+
32
+ ## Not a Fit
33
+
34
+ - Facebook Messenger, Telegram, or Discord bots — different APIs entirely
35
+ - ZaloPay payment integration (separate API surface, not covered here)
36
+ - Zalo Mini App development (JSAPI bridge, not OA/personal messaging)
37
+
38
+ ## Triggers
39
+
40
+ - Auto-trigger: when `zalo`, `zca-js`, `@anthropic-ai/sdk` + Zalo context detected
41
+ - `/rune zalo-oa` — Official Account setup and messaging
42
+ - `/rune zalo-personal` — Personal account automation
43
+ - `/rune zalo-mcp` — MCP server for AI agent ↔ Zalo
44
+ - `/rune zalo-rate` — Rate limiting and anti-ban strategies
45
+ - Called by `cook` (L1) when Zalo integration task detected
46
+ - Called by `mcp-builder` (L2) when building Zalo MCP server
47
+
48
+ ## Skills Included
49
+
50
+ | Skill | Model | Track | Description |
51
+ |-------|-------|-------|-------------|
52
+ | [zalo-oa-setup](skills/zalo-oa-setup.md) | sonnet | A | OAuth2 PKCE flow, dual token management (User vs OA), app registration, appsecret_proof signing, token auto-refresh middleware. |
53
+ | [zalo-oa-messaging](skills/zalo-oa-messaging.md) | sonnet | A | All 8 OA message types (text, image, file, sticker, list, template, transaction, promotion), follower management, broadcast with demographic targeting. |
54
+ | [zalo-oa-webhook](skills/zalo-oa-webhook.md) | sonnet | A | Webhook server setup, event routing, signature verification, retry handling, event type catalog, Express/Fastify/Hono patterns. |
55
+ | [zalo-oa-mcp](skills/zalo-oa-mcp.md) | sonnet | A | MCP server blueprint — tools for read/send/broadcast, webhook-to-MCP bridge, credential storage, AI agent conversation loop. |
56
+ | [zalo-personal-setup](skills/zalo-personal-setup.md) | sonnet | B | zca-js setup, QR login flow, credential persistence, session management, WebSocket listener, keepAlive, anti-detection baseline. |
57
+ | [zalo-personal-messaging](skills/zalo-personal-messaging.md) | sonnet | B | Personal/group messaging, media (image/video/voice/sticker), reactions, group management (create, members, settings), mention gating, message buffer. |
58
+ | [zalo-rate-guard](skills/zalo-rate-guard.md) | sonnet | Shared | Rate limiting patterns for both tracks — token bucket per endpoint, exponential backoff, queue management, quota monitoring, anti-ban strategies. |
59
+
60
+ ## Risk Gate — Track B (Personal Account)
61
+
62
+ <HARD-GATE>
63
+ Track B skills use unofficial reverse-engineered APIs via zca-js.
64
+ Before ANY Track B implementation, the developer MUST acknowledge:
65
+
66
+ 1. **ToS violation**: Personal account automation violates Zalo's Terms of Service
67
+ 2. **Ban risk**: Account can be suspended without warning
68
+ 3. **Single-session**: Cannot run bot + personal Zalo simultaneously on same account
69
+ 4. **API instability**: Zalo can break the internal API at any time without notice
70
+ 5. **No support**: Zalo will not help with issues caused by unofficial API usage
71
+
72
+ Track B is for: personal projects, prototypes, group utilities.
73
+ Track B is NOT for: production business systems, customer-facing bots, high-volume messaging.
74
+
75
+ For production use → Track A (Official Account API).
76
+ </HARD-GATE>
77
+
78
+ ## Connections
79
+
80
+ ```
81
+ Calls → mcp-builder (L2): zalo-oa-mcp uses mcp-builder patterns for server scaffolding
82
+ Calls → sentinel (L2): credential handling triggers security review
83
+ Calls → rate-guard (shared): all messaging skills call rate-guard before API calls
84
+ Calls → verification (L3): verify webhook server is running and receiving events
85
+ Called By ← cook (L1): when Zalo integration task detected in project
86
+ Called By ← scaffold (L1): when bootstrapping a Zalo bot project
87
+ Called By ← mcp-builder (L2): when building Zalo-specific MCP server
88
+ ```
89
+
90
+ ## Tech Stack
91
+
92
+ | Component | Recommended | Alternatives |
93
+ |-----------|-------------|--------------|
94
+ | Runtime | Node.js 20+ | Bun, Deno |
95
+ | OA HTTP client | undici / fetch | axios |
96
+ | Personal API | zca-js | none (only option) |
97
+ | Webhook server | Hono | Express, Fastify |
98
+ | MCP framework | @anthropic-ai/sdk | custom |
99
+ | Queue (rate limit) | p-queue | bottleneck, bull |
100
+ | Validation | zod | joi |
101
+
102
+ ## Constraints
103
+
104
+ 1. All skills MUST reference Zalo OA API v3 (not deprecated v2)
105
+ 2. Track B skills MUST display HARD-GATE risk disclaimer before execution
106
+ 3. Rate limiting MUST be implemented before any messaging — no fire-and-forget
107
+ 4. Credentials (tokens, cookies, secrets) MUST never be logged or committed
108
+ 5. Webhook signature verification MUST NOT be skipped — even in development
109
+
110
+ ## Done When
111
+
112
+ - OA OAuth2 flow working with auto-refresh
113
+ - All 8 message types documented with request/response examples
114
+ - Webhook server receiving and routing events correctly
115
+ - MCP server operational: agent can read and send Zalo messages
116
+ - Rate limiting active on all outbound API calls
117
+ - Track B: QR login + personal/group messaging working with risk gate shown