@rune-kit/rune 2.2.0 → 2.2.2
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/README.md +72 -40
- package/compiler/__tests__/pack-split.test.js +145 -0
- package/compiler/bin/rune.js +26 -9
- package/compiler/doctor.js +42 -0
- package/compiler/emitter.js +27 -4
- package/compiler/parser.js +41 -3
- package/compiler/transformer.js +10 -6
- package/compiler/transforms/compliance.js +40 -0
- package/docs/ANTIGRAVITY-GAP-ANALYSIS.md +369 -0
- package/docs/ARCHITECTURE.md +332 -0
- package/docs/COMMUNITY-PACKS.md +109 -0
- package/docs/CONTRIBUTING-L4.md +215 -0
- package/docs/CROSS-IDE-ANALYSIS.md +164 -0
- package/docs/EXTENSION-TEMPLATE.md +108 -0
- package/docs/MESH-RULES.md +34 -0
- package/docs/MULTI-PLATFORM.md +804 -0
- package/docs/SKILL-DEPTH-AUDIT.md +191 -0
- package/docs/SKILL-TEMPLATE.md +72 -0
- package/docs/TRADE-MATRIX.md +327 -0
- package/docs/VERSIONING.md +91 -0
- package/docs/VISION.md +263 -0
- package/docs/assets/demo-subtitles.srt +215 -0
- package/docs/assets/end-card.html +276 -0
- package/docs/assets/mesh-diagram.html +654 -0
- package/docs/assets/thumbnail.html +295 -0
- package/docs/guides/cli.md +403 -0
- package/docs/guides/index.html +1346 -0
- package/docs/index.html +674 -0
- package/docs/references/claudekit-analysis.md +414 -0
- package/docs/references/voltagent-analysis.md +189 -0
- package/docs/script.js +277 -0
- package/docs/skills/index.html +832 -0
- package/docs/style.css +583 -0
- package/docs/video-demo-plan.md +172 -0
- package/extensions/ai-ml/PACK.md +38 -474
- package/extensions/ai-ml/skills/ai-agents.md +172 -0
- package/extensions/ai-ml/skills/code-sandbox.md +187 -0
- package/extensions/ai-ml/skills/deep-research.md +146 -0
- package/extensions/ai-ml/skills/embedding-search.md +66 -0
- package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -0
- package/extensions/ai-ml/skills/llm-architect.md +125 -0
- package/extensions/ai-ml/skills/llm-integration.md +64 -0
- package/extensions/ai-ml/skills/prompt-patterns.md +72 -0
- package/extensions/ai-ml/skills/rag-patterns.md +66 -0
- package/extensions/ai-ml/skills/web-extraction.md +114 -0
- package/extensions/analytics/PACK.md +19 -484
- package/extensions/analytics/skills/ab-testing.md +72 -0
- package/extensions/analytics/skills/dashboard-patterns.md +83 -0
- package/extensions/analytics/skills/data-validation.md +68 -0
- package/extensions/analytics/skills/funnel-analysis.md +81 -0
- package/extensions/analytics/skills/sql-patterns.md +57 -0
- package/extensions/analytics/skills/statistical-analysis.md +79 -0
- package/extensions/analytics/skills/tracking-setup.md +71 -0
- package/extensions/backend/PACK.md +44 -618
- package/extensions/backend/skills/api-patterns.md +84 -0
- package/extensions/backend/skills/async-pipeline.md +193 -0
- package/extensions/backend/skills/auth-patterns.md +97 -0
- package/extensions/backend/skills/background-jobs.md +133 -0
- package/extensions/backend/skills/caching-patterns.md +108 -0
- package/extensions/backend/skills/cli-generation.md +133 -0
- package/extensions/backend/skills/database-patterns.md +87 -0
- package/extensions/backend/skills/middleware-patterns.md +104 -0
- package/extensions/chrome-ext/PACK.md +19 -921
- package/extensions/chrome-ext/skills/cws-preflight.md +143 -0
- package/extensions/chrome-ext/skills/cws-publish.md +104 -0
- package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -0
- package/extensions/chrome-ext/skills/ext-messaging.md +139 -0
- package/extensions/chrome-ext/skills/ext-storage.md +133 -0
- package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -0
- package/extensions/content/PACK.md +43 -335
- package/extensions/content/skills/blog-patterns.md +88 -0
- package/extensions/content/skills/cms-integration.md +131 -0
- package/extensions/content/skills/content-scoring.md +107 -0
- package/extensions/content/skills/i18n.md +83 -0
- package/extensions/content/skills/mdx-authoring.md +137 -0
- package/extensions/content/skills/reference.md +1014 -0
- package/extensions/content/skills/seo-patterns.md +67 -0
- package/extensions/content/skills/video-repurpose.md +153 -0
- package/extensions/devops/PACK.md +38 -457
- package/extensions/devops/skills/chaos-testing.md +67 -0
- package/extensions/devops/skills/ci-cd.md +75 -0
- package/extensions/devops/skills/docker.md +58 -0
- package/extensions/devops/skills/edge-serverless.md +163 -0
- package/extensions/devops/skills/infra-as-code.md +158 -0
- package/extensions/devops/skills/kubernetes.md +110 -0
- package/extensions/devops/skills/monitoring.md +57 -0
- package/extensions/devops/skills/server-setup.md +64 -0
- package/extensions/devops/skills/ssl-domain.md +42 -0
- package/extensions/ecommerce/PACK.md +62 -226
- package/extensions/ecommerce/skills/cart-system.md +79 -0
- package/extensions/ecommerce/skills/inventory-mgmt.md +102 -0
- package/extensions/ecommerce/skills/order-management.md +126 -0
- package/extensions/ecommerce/skills/payment-integration.md +472 -0
- package/extensions/ecommerce/skills/shopify-dev.md +69 -0
- package/extensions/ecommerce/skills/subscription-billing.md +93 -0
- package/extensions/ecommerce/skills/tax-compliance.md +117 -0
- package/extensions/gamedev/PACK.md +66 -317
- package/extensions/gamedev/skills/asset-pipeline.md +74 -0
- package/extensions/gamedev/skills/audio-system.md +129 -0
- package/extensions/gamedev/skills/camera-system.md +87 -0
- package/extensions/gamedev/skills/ecs.md +98 -0
- package/extensions/gamedev/skills/game-loops.md +72 -0
- package/extensions/gamedev/skills/input-system.md +199 -0
- package/extensions/gamedev/skills/multiplayer.md +180 -0
- package/extensions/gamedev/skills/particles.md +105 -0
- package/extensions/gamedev/skills/physics-engine.md +89 -0
- package/extensions/gamedev/skills/scene-management.md +146 -0
- package/extensions/gamedev/skills/threejs-patterns.md +90 -0
- package/extensions/gamedev/skills/webgl.md +71 -0
- package/extensions/mobile/PACK.md +56 -223
- package/extensions/mobile/skills/app-store-connect.md +152 -0
- package/extensions/mobile/skills/app-store-prep.md +66 -0
- package/extensions/mobile/skills/deep-linking.md +109 -0
- package/extensions/mobile/skills/flutter.md +60 -0
- package/extensions/mobile/skills/ios-build-pipeline.md +142 -0
- package/extensions/mobile/skills/native-bridge.md +66 -0
- package/extensions/mobile/skills/ota-updates.md +97 -0
- package/extensions/mobile/skills/push-notifications.md +111 -0
- package/extensions/mobile/skills/react-native.md +82 -0
- package/extensions/saas/PACK.md +26 -720
- package/extensions/saas/skills/billing-integration.md +121 -0
- package/extensions/saas/skills/feature-flags.md +130 -0
- package/extensions/saas/skills/multi-tenant.md +103 -0
- package/extensions/saas/skills/onboarding-flow.md +139 -0
- package/extensions/saas/skills/subscription-flow.md +95 -0
- package/extensions/saas/skills/team-management.md +144 -0
- package/extensions/security/PACK.md +10 -448
- package/extensions/security/skills/api-security.md +140 -0
- package/extensions/security/skills/compliance.md +68 -0
- package/extensions/security/skills/owasp-audit.md +64 -0
- package/extensions/security/skills/pentest-patterns.md +77 -0
- package/extensions/security/skills/secret-mgmt.md +65 -0
- package/extensions/security/skills/supply-chain.md +65 -0
- package/extensions/trading/PACK.md +18 -535
- package/extensions/trading/skills/chart-components.md +55 -0
- package/extensions/trading/skills/experiment-loop.md +125 -0
- package/extensions/trading/skills/fintech-patterns.md +47 -0
- package/extensions/trading/skills/indicator-library.md +58 -0
- package/extensions/trading/skills/quant-analysis.md +111 -0
- package/extensions/trading/skills/realtime-data.md +58 -0
- package/extensions/trading/skills/trade-logic.md +104 -0
- package/extensions/ui/PACK.md +36 -853
- package/extensions/ui/skills/a11y-audit.md +91 -0
- package/extensions/ui/skills/animation-patterns.md +106 -0
- package/extensions/ui/skills/component-patterns.md +75 -0
- package/extensions/ui/skills/design-decision.md +108 -0
- package/extensions/ui/skills/design-system.md +68 -0
- package/extensions/ui/skills/landing-patterns.md +155 -0
- package/extensions/ui/skills/palette-picker.md +173 -0
- package/extensions/ui/skills/react-health.md +90 -0
- package/extensions/ui/skills/type-system.md +125 -0
- package/extensions/ui/skills/web-vitals.md +153 -0
- package/extensions/zalo/PACK.md +117 -0
- package/extensions/zalo/skills/zalo-oa-mcp.md +317 -0
- package/extensions/zalo/skills/zalo-oa-messaging.md +429 -0
- package/extensions/zalo/skills/zalo-oa-setup.md +236 -0
- package/extensions/zalo/skills/zalo-oa-webhook.md +189 -0
- package/extensions/zalo/skills/zalo-personal-messaging.md +194 -0
- package/extensions/zalo/skills/zalo-personal-setup.md +153 -0
- package/extensions/zalo/skills/zalo-rate-guard.md +219 -0
- package/hooks/.gitkeep +0 -0
- package/hooks/auto-format/index.cjs +48 -0
- package/hooks/context-watch/index.cjs +68 -0
- package/hooks/hooks.json +99 -0
- package/hooks/metrics-collector/index.cjs +42 -0
- package/hooks/post-session-reflect/index.cjs +153 -0
- package/hooks/pre-compact/index.cjs +95 -0
- package/hooks/pre-tool-guard/index.cjs +68 -0
- package/hooks/run-hook +17 -0
- package/hooks/run-hook.cjs +16 -0
- package/hooks/run-hook.cmd +1 -0
- package/hooks/secrets-scan/index.cjs +100 -0
- package/hooks/session-start/index.cjs +65 -0
- package/hooks/typecheck/index.cjs +65 -0
- package/package.json +9 -4
- package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -0
- package/references/ui-pro-max-data/charts.csv +26 -0
- package/references/ui-pro-max-data/colors.csv +162 -0
- package/references/ui-pro-max-data/styles.csv +85 -0
- package/references/ui-pro-max-data/typography.csv +74 -0
- package/references/ui-pro-max-data/ui-reasoning.csv +162 -0
- package/references/ui-pro-max-data/ux-guidelines.csv +100 -0
- package/skills/ba/SKILL.md +10 -0
- package/skills/brainstorm/SKILL.md +63 -1
- package/skills/completion-gate/SKILL.md +34 -1
- package/skills/context-engine/SKILL.md +13 -0
- package/skills/cook/SKILL.md +155 -5
- package/skills/debug/SKILL.md +56 -1
- package/skills/design/SKILL.md +11 -0
- package/skills/fix/SKILL.md +26 -1
- package/skills/mcp-builder/SKILL.md +48 -1
- package/skills/plan/SKILL.md +23 -6
- package/skills/review/SKILL.md +44 -5
- package/skills/review-intake/SKILL.md +17 -1
- package/skills/skill-forge/SKILL.md +38 -3
- package/skills/skill-router/SKILL.md +89 -7
- package/skills/team/SKILL.md +24 -1
- package/skills/test/SKILL.md +28 -1
- package/skills/verification/SKILL.md +98 -1
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
The tree below provides 10 default palettes. When `references/ui-pro-max-data/colors.csv` is available, query it for **161 industry-specific palettes** with full dark/light variants, semantic tokens, and design psychology notes. Filter by domain column for expanded options.
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Product Type → Palette Recommendation
|
|
33
|
+
─────────────────────────────────────────────────
|
|
34
|
+
fintech / trading → Midnight Profit (dark bg + green/red signals)
|
|
35
|
+
healthcare → Clean Clinic (white/teal, high readability)
|
|
36
|
+
education / kids → Warm Academy (amber/orange, approachable)
|
|
37
|
+
gaming → Neon Arena (dark + electric cyan/magenta)
|
|
38
|
+
ecommerce → Trust Cart (white + amber CTA + forest green)
|
|
39
|
+
saas / dashboard → Slate Precision (slate-900 + blue-500 accents)
|
|
40
|
+
social / community → Gradient Social (slate + violet/fuchsia gradient)
|
|
41
|
+
news / content → Neutral Ink (off-white + near-black, serif-ready)
|
|
42
|
+
productivity / tools → Calm Focus (gray-50 + indigo-700, minimal noise)
|
|
43
|
+
developer tools → Terminal Dark (zinc-950 + emerald-400 mono)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Extended Palette DB (UI/UX Pro Max)
|
|
47
|
+
|
|
48
|
+
When `references/ui-pro-max-data/colors.csv` exists:
|
|
49
|
+
- 161 palettes with Primary, Secondary, Accent, Background, Foreground (dark+light)
|
|
50
|
+
- Semantic tokens: Card, Muted, Border, Destructive, Ring variants
|
|
51
|
+
- Design psychology notes per palette
|
|
52
|
+
- Query: `grep -i "<domain>" references/ui-pro-max-data/colors.csv` → get domain-matched palettes
|
|
53
|
+
- Anti-AI check: if selected palette uses #6366f1 (indigo) or #8b5cf6 (violet) as primary → flag and suggest alternatives from DB
|
|
54
|
+
|
|
55
|
+
#### Palette Reference
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
/* ── PALETTE: Midnight Profit (Fintech/Trading) ─────────────── */
|
|
59
|
+
[data-palette="midnight-profit"][data-theme="dark"] {
|
|
60
|
+
--bg-base: #0c1419;
|
|
61
|
+
--bg-card: #121a20;
|
|
62
|
+
--bg-elevated: #1a2332;
|
|
63
|
+
--text-primary: #ffffff;
|
|
64
|
+
--text-secondary: #a0aeb8;
|
|
65
|
+
--border: #2a3f52;
|
|
66
|
+
--profit: #00d084; /* green — gains */
|
|
67
|
+
--loss: #ff6b6b; /* red — losses */
|
|
68
|
+
--accent: #2196f3;
|
|
69
|
+
/* Colorblind (deuteranopia): profit→#1e88e5, loss→#ffa726 */
|
|
70
|
+
}
|
|
71
|
+
[data-palette="midnight-profit"][data-theme="light"] {
|
|
72
|
+
--bg-base: #faf8f3;
|
|
73
|
+
--bg-card: #f5f0ea;
|
|
74
|
+
--text-primary: #0c1419;
|
|
75
|
+
--text-secondary: #4a5568;
|
|
76
|
+
--border: #d1cfc9;
|
|
77
|
+
--profit: #059669;
|
|
78
|
+
--loss: #dc2626;
|
|
79
|
+
--accent: #1d4ed8;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ── PALETTE: Clean Clinic (Healthcare) ─────────────────────── */
|
|
83
|
+
[data-palette="clean-clinic"] {
|
|
84
|
+
--bg-base: #f0fafa;
|
|
85
|
+
--bg-card: #ffffff;
|
|
86
|
+
--text-primary: #0d1f2d;
|
|
87
|
+
--text-secondary: #4b6070;
|
|
88
|
+
--border: #c7e8ea;
|
|
89
|
+
--primary: #0891b2; /* cyan-600 */
|
|
90
|
+
--secondary: #0d9488; /* teal-600 */
|
|
91
|
+
--accent: #06b6d4;
|
|
92
|
+
--danger: #ef4444;
|
|
93
|
+
--success: #16a34a;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* ── PALETTE: Slate Precision (SaaS/Dashboard) ───────────────── */
|
|
97
|
+
[data-palette="slate-precision"][data-theme="dark"] {
|
|
98
|
+
--bg-base: #0f172a;
|
|
99
|
+
--bg-card: #1e293b;
|
|
100
|
+
--bg-elevated: #334155;
|
|
101
|
+
--text-primary: #f8fafc;
|
|
102
|
+
--text-secondary: #94a3b8;
|
|
103
|
+
--primary: #3b82f6; /* blue-500 */
|
|
104
|
+
--success: #10b981;
|
|
105
|
+
--danger: #ef4444;
|
|
106
|
+
--warning: #f59e0b;
|
|
107
|
+
}
|
|
108
|
+
[data-palette="slate-precision"][data-theme="light"] {
|
|
109
|
+
--bg-base: #ffffff;
|
|
110
|
+
--bg-card: #f8fafc;
|
|
111
|
+
--bg-elevated: #f1f5f9;
|
|
112
|
+
--text-primary: #0f172a;
|
|
113
|
+
--text-secondary: #475569;
|
|
114
|
+
--primary: #2563eb;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* ── PALETTE: Neon Arena (Gaming) ────────────────────────────── */
|
|
118
|
+
[data-palette="neon-arena"] {
|
|
119
|
+
--bg-base: #080c10;
|
|
120
|
+
--bg-card: #0f1520;
|
|
121
|
+
--text-primary: #e8f4f8;
|
|
122
|
+
--text-secondary: #7a9ab0;
|
|
123
|
+
--primary: #00ffe0; /* electric cyan */
|
|
124
|
+
--secondary: #ff2d78; /* hot magenta */
|
|
125
|
+
--accent: #ffe600; /* warning yellow */
|
|
126
|
+
--border: rgba(0, 255, 224, 0.15);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* ── PALETTE: Trust Cart (Ecommerce) ─────────────────────────── */
|
|
130
|
+
[data-palette="trust-cart"][data-theme="light"] {
|
|
131
|
+
--bg-base: #ffffff;
|
|
132
|
+
--bg-card: #fafafa;
|
|
133
|
+
--text-primary: #111827;
|
|
134
|
+
--text-secondary: #6b7280;
|
|
135
|
+
--cta: #f97316; /* orange-500 — add-to-cart */
|
|
136
|
+
--success: #16a34a; /* forest green — in stock */
|
|
137
|
+
--trust: #1d4ed8; /* blue — secure badge */
|
|
138
|
+
--border: #e5e7eb;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* ── PALETTE: Terminal Dark (Developer Tools) ────────────────── */
|
|
142
|
+
[data-palette="terminal-dark"] {
|
|
143
|
+
--bg-base: #09090b; /* zinc-950 */
|
|
144
|
+
--bg-card: #18181b; /* zinc-900 */
|
|
145
|
+
--bg-elevated: #27272a; /* zinc-800 */
|
|
146
|
+
--text-primary: #fafafa;
|
|
147
|
+
--text-secondary: #a1a1aa;
|
|
148
|
+
--primary: #34d399; /* emerald-400 — code green */
|
|
149
|
+
--accent: #818cf8; /* indigo-400 — links */
|
|
150
|
+
--border: #3f3f46;
|
|
151
|
+
--comment: #71717a;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
// tailwind.config.js — extending with palette tokens
|
|
157
|
+
/** @type {import('tailwindcss').Config} */
|
|
158
|
+
module.exports = {
|
|
159
|
+
theme: {
|
|
160
|
+
extend: {
|
|
161
|
+
colors: {
|
|
162
|
+
profit: 'var(--profit)',
|
|
163
|
+
loss: 'var(--loss)',
|
|
164
|
+
primary: 'var(--primary)',
|
|
165
|
+
'bg-base': 'var(--bg-base)',
|
|
166
|
+
'bg-card': 'var(--bg-card)',
|
|
167
|
+
'text-primary': 'var(--text-primary)',
|
|
168
|
+
'text-secondary': 'var(--text-secondary)',
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
@@ -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
|