@skriv/ads 0.0.0-stage → 0.1.0
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 +45 -2
- package/bin/ads.mjs +59 -0
- package/dist/manifest.json +36 -0
- package/dist/skills/ads-code-review/SKILL.md +12 -0
- package/dist/skills/ads-code-to-figma/SKILL.md +10 -0
- package/dist/skills/ads-figma-to-code/SKILL.md +10 -0
- package/dist/skills/ads-init/SKILL.md +14 -0
- package/dist/skills/ads-init/profile.md +11 -0
- package/dist/skills/ads-init/scripts/connect.py +75 -0
- package/dist/skills/ads-record/SKILL.md +12 -0
- package/dist/skills/heroui-react/LICENSE.txt +199 -0
- package/dist/skills/heroui-react/SKILL.md +234 -0
- package/dist/skills/heroui-react/scripts/get_component_docs.mjs +157 -0
- package/dist/skills/heroui-react/scripts/get_docs.mjs +148 -0
- package/dist/skills/heroui-react/scripts/get_source.mjs +160 -0
- package/dist/skills/heroui-react/scripts/get_styles.mjs +160 -0
- package/dist/skills/heroui-react/scripts/get_theme.mjs +177 -0
- package/dist/skills/heroui-react/scripts/list_components.mjs +134 -0
- package/dist/templates/flow.md +12 -0
- package/dist/templates/project.md +13 -0
- package/dist/templates/review.md +14 -0
- package/dist/templates/routing.md +9 -0
- package/package.json +17 -4
- package/src/doctor.mjs +38 -0
- package/src/install.mjs +139 -0
- package/src/video.mjs +18 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: heroui-react
|
|
3
|
+
description: "HeroUI v3 React component library (Tailwind CSS v4 + React Aria). Use when building UIs with HeroUI — creating Buttons, Modals, Forms, Cards; installing @heroui/react; configuring dark/light themes with oklch variables; or fetching component docs. Keywords: HeroUI, Hero UI, heroui, @heroui/react, @heroui/styles."
|
|
4
|
+
metadata:
|
|
5
|
+
author: heroui
|
|
6
|
+
version: "3.0.1"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# HeroUI v3 React Development Guide
|
|
10
|
+
|
|
11
|
+
HeroUI v3 is a component library built on **Tailwind CSS v4** and **React Aria Components**, providing accessible, customizable UI components for React applications.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
curl -fsSL https://heroui.com/install | bash -s heroui-react
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## CRITICAL: v3 Only - Ignore v2 Knowledge
|
|
24
|
+
|
|
25
|
+
**This guide is for HeroUI v3 ONLY.** Do NOT apply v2 patterns — the provider, styling, and component API all changed:
|
|
26
|
+
|
|
27
|
+
| Feature | v2 (DO NOT USE) | v3 (USE THIS) |
|
|
28
|
+
| ------------- | --------------------------------- | ------------------------------------------- |
|
|
29
|
+
| Provider | `<HeroUIProvider>` required | **No Provider needed** |
|
|
30
|
+
| Animations | `framer-motion` package | CSS-based, no extra deps |
|
|
31
|
+
| Component API | Flat props: `<Card title="x">` | Compound: `<Card><Card.Header>` |
|
|
32
|
+
| Styling | Tailwind v3 + `@heroui/theme` | Tailwind v4 + `@heroui/styles` |
|
|
33
|
+
| Packages | `@heroui/system`, `@heroui/theme` | `@heroui/react`, `@heroui/styles` |
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
// DO NOT DO THIS - v2 pattern
|
|
37
|
+
import { HeroUIProvider } from "@heroui/react";
|
|
38
|
+
import { motion } from "framer-motion";
|
|
39
|
+
|
|
40
|
+
<HeroUIProvider>
|
|
41
|
+
<Card title="Product" description="A great product" />
|
|
42
|
+
</HeroUIProvider>;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### CORRECT (v3 patterns)
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
// DO THIS - v3 pattern (no provider, compound components)
|
|
49
|
+
import { Card } from "@heroui/react";
|
|
50
|
+
|
|
51
|
+
<Card>
|
|
52
|
+
<Card.Header>
|
|
53
|
+
<Card.Title>Product</Card.Title>
|
|
54
|
+
<Card.Description>A great product</Card.Description>
|
|
55
|
+
</Card.Header>
|
|
56
|
+
</Card>;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Always fetch v3 docs before implementing.**
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Core Principles
|
|
64
|
+
|
|
65
|
+
- Semantic variants (`primary`, `secondary`, `tertiary`) over visual descriptions
|
|
66
|
+
- Composition over configuration (compound components)
|
|
67
|
+
- CSS variable-based theming with `oklch` color space
|
|
68
|
+
- BEM naming convention for predictable styling
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Accessing Documentation & Component Information
|
|
73
|
+
|
|
74
|
+
**For component details, examples, props, and implementation patterns, always fetch documentation:**
|
|
75
|
+
|
|
76
|
+
### Using Scripts
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# List all available components
|
|
80
|
+
node scripts/list_components.mjs
|
|
81
|
+
|
|
82
|
+
# Get component documentation (MDX)
|
|
83
|
+
node scripts/get_component_docs.mjs Button
|
|
84
|
+
node scripts/get_component_docs.mjs Button Card TextField
|
|
85
|
+
|
|
86
|
+
# Get component source code
|
|
87
|
+
node scripts/get_source.mjs Button
|
|
88
|
+
|
|
89
|
+
# Get component CSS styles (BEM classes)
|
|
90
|
+
node scripts/get_styles.mjs Button
|
|
91
|
+
|
|
92
|
+
# Get theme variables
|
|
93
|
+
node scripts/get_theme.mjs
|
|
94
|
+
|
|
95
|
+
# Get non-component docs (guides, releases)
|
|
96
|
+
node scripts/get_docs.mjs /docs/react/getting-started/theming
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Direct MDX URLs
|
|
100
|
+
|
|
101
|
+
Component docs: fetch `.mdx` with a concrete kebab-case slug. Run `node scripts/list_components.mjs` when the slug is unknown, and never fetch a URL that still contains a placeholder.
|
|
102
|
+
|
|
103
|
+
Examples:
|
|
104
|
+
|
|
105
|
+
- Button: `https://heroui.com/docs/react/components/button.mdx`
|
|
106
|
+
- Modal: `https://heroui.com/docs/react/components/modal.mdx`
|
|
107
|
+
- Form: `https://heroui.com/docs/react/components/form.mdx`
|
|
108
|
+
|
|
109
|
+
Getting started guides: use a concrete topic URL such as `https://heroui.com/docs/react/getting-started/quick-start.mdx`.
|
|
110
|
+
|
|
111
|
+
**Important:** Always fetch component docs before implementing. The MDX docs include complete examples, props, anatomy, and API references.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Installation Essentials
|
|
116
|
+
|
|
117
|
+
### Quick Install
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm i @heroui/styles @heroui/react tailwind-variants
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Framework Setup (Next.js App Router - Recommended)
|
|
124
|
+
|
|
125
|
+
1. **Install dependencies:**
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm i @heroui/styles @heroui/react tailwind-variants tailwindcss @tailwindcss/postcss postcss
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
2. **Create/update `app/globals.css`:**
|
|
132
|
+
|
|
133
|
+
```css
|
|
134
|
+
/* Tailwind CSS v4 - Must be first */
|
|
135
|
+
@import "tailwindcss";
|
|
136
|
+
|
|
137
|
+
/* HeroUI v3 styles - Must be after Tailwind */
|
|
138
|
+
@import "@heroui/styles";
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
3. **Import in `app/layout.tsx`:**
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import "./globals.css";
|
|
145
|
+
|
|
146
|
+
export default function RootLayout({
|
|
147
|
+
children,
|
|
148
|
+
}: {
|
|
149
|
+
children: React.ReactNode;
|
|
150
|
+
}) {
|
|
151
|
+
return (
|
|
152
|
+
<html lang="en" suppressHydrationWarning>
|
|
153
|
+
<body>
|
|
154
|
+
{/* No Provider needed in HeroUI v3! */}
|
|
155
|
+
{children}
|
|
156
|
+
</body>
|
|
157
|
+
</html>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
4. **Configure PostCSS (`postcss.config.mjs`):**
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
export default {
|
|
166
|
+
plugins: {
|
|
167
|
+
"@tailwindcss/postcss": {},
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Critical Setup Requirements
|
|
173
|
+
|
|
174
|
+
1. **Tailwind CSS v4 is MANDATORY** - HeroUI v3 will NOT work with Tailwind CSS v3
|
|
175
|
+
2. **Use Compound Components** - Components use compound structure (e.g., `Card.Header`, `Card.Content`)
|
|
176
|
+
3. **Use onPress, not onClick** - For better accessibility, use `onPress` event handlers
|
|
177
|
+
4. **Import Order Matters** - Always import Tailwind CSS before HeroUI styles
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Component Patterns
|
|
182
|
+
|
|
183
|
+
All components use the **compound pattern** shown above (dot-notation subcomponents like `Card.Header`, `Card.Content`). Don't flatten to props — always compose with subcomponents. Fetch component docs for complete anatomy and examples.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Semantic Variants
|
|
188
|
+
|
|
189
|
+
HeroUI uses semantic naming to communicate functional intent:
|
|
190
|
+
|
|
191
|
+
| Variant | Purpose | Usage |
|
|
192
|
+
| ----------- | --------------------------------- | -------------- |
|
|
193
|
+
| `primary` | Main action to move forward | 1 per context |
|
|
194
|
+
| `secondary` | Alternative actions | Multiple |
|
|
195
|
+
| `tertiary` | Dismissive actions (cancel, skip) | Sparingly |
|
|
196
|
+
| `danger` | Destructive actions | When needed |
|
|
197
|
+
| `ghost` | Low-emphasis actions | Minimal weight |
|
|
198
|
+
| `outline` | Secondary actions | Bordered style |
|
|
199
|
+
|
|
200
|
+
**Don't use raw colors** - semantic variants adapt to themes and accessibility.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Theming
|
|
205
|
+
|
|
206
|
+
HeroUI v3 uses CSS variables with `oklch` color space:
|
|
207
|
+
|
|
208
|
+
```css
|
|
209
|
+
:root {
|
|
210
|
+
--accent: oklch(0.6204 0.195 253.83);
|
|
211
|
+
--accent-foreground: var(--snow);
|
|
212
|
+
--background: oklch(0.9702 0 0);
|
|
213
|
+
--foreground: var(--eclipse);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Get current theme variables:**
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
node scripts/get_theme.mjs
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Color naming:**
|
|
224
|
+
|
|
225
|
+
- Without suffix = background (e.g., `--accent`)
|
|
226
|
+
- With `-foreground` = text color (e.g., `--accent-foreground`)
|
|
227
|
+
|
|
228
|
+
**Theme switching:**
|
|
229
|
+
|
|
230
|
+
```html
|
|
231
|
+
<html class="dark" data-theme="dark"></html>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
For detailed theming, fetch: `https://heroui.com/docs/react/getting-started/theming.mdx`
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Get complete component documentation (MDX) for HeroUI v3 components.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node get_component_docs.mjs Button
|
|
7
|
+
* node get_component_docs.mjs Button Card TextField
|
|
8
|
+
*
|
|
9
|
+
* Output:
|
|
10
|
+
* MDX documentation including imports, usage, variants, props, examples
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const API_BASE = process.env.HEROUI_API_BASE || "https://mcp-api.heroui.com";
|
|
14
|
+
const FALLBACK_BASE = "https://heroui.com";
|
|
15
|
+
const APP_PARAM = "app=react-skills";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Convert PascalCase to kebab-case.
|
|
19
|
+
*/
|
|
20
|
+
function toKebabCase(name) {
|
|
21
|
+
return name
|
|
22
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
23
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2")
|
|
24
|
+
.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Fetch data from HeroUI API with app parameter for analytics.
|
|
29
|
+
*/
|
|
30
|
+
async function fetchApi(endpoint, method = "GET", body = null) {
|
|
31
|
+
const separator = endpoint.includes("?") ? "&" : "?";
|
|
32
|
+
const url = `${API_BASE}${endpoint}${separator}${APP_PARAM}`;
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const options = {
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
"User-Agent": "HeroUI-Skill/1.0",
|
|
39
|
+
},
|
|
40
|
+
method,
|
|
41
|
+
signal: AbortSignal.timeout(30000),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (body) {
|
|
45
|
+
options.body = JSON.stringify(body);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const response = await fetch(url, options);
|
|
49
|
+
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return await response.json();
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Fetch MDX directly from v3.heroui.com as fallback.
|
|
62
|
+
*/
|
|
63
|
+
async function fetchFallback(component) {
|
|
64
|
+
const kebabName = toKebabCase(component);
|
|
65
|
+
const url = `${FALLBACK_BASE}/docs/react/components/${kebabName}.mdx`;
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const response = await fetch(url, {
|
|
69
|
+
headers: {"User-Agent": "HeroUI-Skill/1.0"},
|
|
70
|
+
signal: AbortSignal.timeout(30000),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
return {component, error: `Failed to fetch docs for ${component}`};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const content = await response.text();
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
component,
|
|
81
|
+
content,
|
|
82
|
+
contentType: "mdx",
|
|
83
|
+
source: "fallback",
|
|
84
|
+
url,
|
|
85
|
+
};
|
|
86
|
+
} catch {
|
|
87
|
+
return {component, error: `Failed to fetch docs for ${component}`};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Main function to get component documentation.
|
|
93
|
+
*/
|
|
94
|
+
async function main() {
|
|
95
|
+
const args = process.argv.slice(2);
|
|
96
|
+
|
|
97
|
+
if (args.length === 0) {
|
|
98
|
+
console.error("Usage: node get_component_docs.mjs <Component1> [Component2] ...");
|
|
99
|
+
console.error("Example: node get_component_docs.mjs Button Card");
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const components = args;
|
|
104
|
+
|
|
105
|
+
// Try API first - use POST /v1/components/docs for batch requests
|
|
106
|
+
console.error(`# Fetching docs for: ${components.join(", ")}...`);
|
|
107
|
+
const data = await fetchApi("/v1/components/docs", "POST", {components});
|
|
108
|
+
|
|
109
|
+
if (data && data.results) {
|
|
110
|
+
// Output results
|
|
111
|
+
if (data.results.length === 1) {
|
|
112
|
+
// Single component - output content directly for easier reading
|
|
113
|
+
const result = data.results[0];
|
|
114
|
+
|
|
115
|
+
if (result.content) {
|
|
116
|
+
console.log(result.content);
|
|
117
|
+
} else if (result.error) {
|
|
118
|
+
console.error(`# Error for ${result.component}: ${result.error}`);
|
|
119
|
+
console.log(JSON.stringify(result, null, 2));
|
|
120
|
+
} else {
|
|
121
|
+
console.log(JSON.stringify(result, null, 2));
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
// Multiple components - output as JSON array
|
|
125
|
+
console.log(JSON.stringify(data, null, 2));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Fallback to individual component fetches
|
|
132
|
+
console.error("# API failed, using fallback...");
|
|
133
|
+
const results = [];
|
|
134
|
+
|
|
135
|
+
for (const component of components) {
|
|
136
|
+
const result = await fetchFallback(component);
|
|
137
|
+
|
|
138
|
+
results.push(result);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Output results
|
|
142
|
+
if (results.length === 1) {
|
|
143
|
+
// Single component - output content directly for easier reading
|
|
144
|
+
const result = results[0];
|
|
145
|
+
|
|
146
|
+
if (result.content) {
|
|
147
|
+
console.log(result.content);
|
|
148
|
+
} else {
|
|
149
|
+
console.log(JSON.stringify(result, null, 2));
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
// Multiple components - output as JSON array
|
|
153
|
+
console.log(JSON.stringify(results, null, 2));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
main();
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Get non-component HeroUI documentation (guides, theming, releases).
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node get_docs.mjs /docs/react/getting-started/theming
|
|
7
|
+
* node get_docs.mjs /docs/react/releases/v3-0-0-beta-3
|
|
8
|
+
*
|
|
9
|
+
* Output:
|
|
10
|
+
* MDX documentation content
|
|
11
|
+
*
|
|
12
|
+
* Note: For component docs, use get_component_docs.mjs instead.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const API_BASE = process.env.HEROUI_API_BASE || "https://mcp-api.heroui.com";
|
|
16
|
+
const FALLBACK_BASE = "https://heroui.com";
|
|
17
|
+
const APP_PARAM = "app=react-skills";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fetch documentation from HeroUI API.
|
|
21
|
+
* Uses v1 endpoint pattern: /v1/docs/:path
|
|
22
|
+
*/
|
|
23
|
+
async function fetchApi(path) {
|
|
24
|
+
// The v1 API expects path without /docs/ prefix
|
|
25
|
+
// Input: /docs/react/getting-started/theming
|
|
26
|
+
// API expects: react/getting-started/theming (route is /v1/docs/:path(*))
|
|
27
|
+
let apiPath = path.startsWith("/docs/")
|
|
28
|
+
? path.slice(6) // Remove /docs/ prefix
|
|
29
|
+
: path.startsWith("/")
|
|
30
|
+
? path.slice(1) // Remove leading /
|
|
31
|
+
: path;
|
|
32
|
+
|
|
33
|
+
const separator = "?";
|
|
34
|
+
const url = `${API_BASE}/v1/docs/${apiPath}${separator}${APP_PARAM}`;
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(url, {
|
|
38
|
+
headers: {"User-Agent": "HeroUI-Skill/1.0"},
|
|
39
|
+
signal: AbortSignal.timeout(30000),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
console.error(`# API Error: HTTP ${response.status}`);
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return await response.json();
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error(`# API Error: ${error.message}`);
|
|
51
|
+
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Fetch MDX directly from v3.heroui.com as fallback.
|
|
58
|
+
*/
|
|
59
|
+
async function fetchFallback(path) {
|
|
60
|
+
// Ensure path starts with /docs and ends with .mdx
|
|
61
|
+
let cleanPath = path.replace(/^\//, "");
|
|
62
|
+
|
|
63
|
+
if (!cleanPath.endsWith(".mdx")) {
|
|
64
|
+
cleanPath = `${cleanPath}.mdx`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const url = `${FALLBACK_BASE}/${cleanPath}`;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const response = await fetch(url, {
|
|
71
|
+
headers: {"User-Agent": "HeroUI-Skill/1.0"},
|
|
72
|
+
signal: AbortSignal.timeout(30000),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
return {error: `HTTP ${response.status}: ${response.statusText}`, path};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const content = await response.text();
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
content,
|
|
83
|
+
contentType: "mdx",
|
|
84
|
+
path,
|
|
85
|
+
source: "fallback",
|
|
86
|
+
url,
|
|
87
|
+
};
|
|
88
|
+
} catch (error) {
|
|
89
|
+
return {error: `Fetch Error: ${error.message}`, path};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Main function to get documentation for specified path.
|
|
95
|
+
*/
|
|
96
|
+
async function main() {
|
|
97
|
+
const args = process.argv.slice(2);
|
|
98
|
+
|
|
99
|
+
if (args.length === 0) {
|
|
100
|
+
console.error("Usage: node get_docs.mjs <path>");
|
|
101
|
+
console.error("Example: node get_docs.mjs /docs/react/getting-started/theming");
|
|
102
|
+
console.error();
|
|
103
|
+
console.error("Available paths include:");
|
|
104
|
+
console.error(" /docs/react/getting-started/theming");
|
|
105
|
+
console.error(" /docs/react/getting-started/colors");
|
|
106
|
+
console.error(" /docs/react/getting-started/animations");
|
|
107
|
+
console.error(" /docs/react/releases/v3-0-0-beta-3");
|
|
108
|
+
console.error();
|
|
109
|
+
console.error("Note: For component docs, use get_component_docs.mjs instead.");
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const path = args[0];
|
|
114
|
+
|
|
115
|
+
// Check if user is trying to get component docs
|
|
116
|
+
if (path.includes("/components/")) {
|
|
117
|
+
console.error("# Warning: Use get_component_docs.mjs for component documentation.");
|
|
118
|
+
const componentName = path.split("/").pop().replace(".mdx", "");
|
|
119
|
+
const titleCase = componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
120
|
+
|
|
121
|
+
console.error(`# Example: node get_component_docs.mjs ${titleCase}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
console.error(`# Fetching documentation for ${path}...`);
|
|
125
|
+
|
|
126
|
+
// Try API first
|
|
127
|
+
const data = await fetchApi(path);
|
|
128
|
+
|
|
129
|
+
if (data && data.content) {
|
|
130
|
+
data.source = "api";
|
|
131
|
+
console.log(data.content);
|
|
132
|
+
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Fallback to direct fetch
|
|
137
|
+
console.error("# API failed, using fallback...");
|
|
138
|
+
const fallbackData = await fetchFallback(path);
|
|
139
|
+
|
|
140
|
+
if (fallbackData.content) {
|
|
141
|
+
console.log(fallbackData.content);
|
|
142
|
+
} else {
|
|
143
|
+
console.log(JSON.stringify(fallbackData, null, 2));
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
main();
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Get React/TypeScript source code implementation for HeroUI v3 components.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node get_source.mjs Button
|
|
7
|
+
* node get_source.mjs Button Accordion Card
|
|
8
|
+
*
|
|
9
|
+
* Output:
|
|
10
|
+
* Full TSX source code with GitHub URL for each component
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const API_BASE = process.env.HEROUI_API_BASE || "https://mcp-api.heroui.com";
|
|
14
|
+
const GITHUB_RAW_BASE = "https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3";
|
|
15
|
+
const APP_PARAM = "app=react-skills";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Fetch data from HeroUI API with app parameter for analytics.
|
|
19
|
+
*/
|
|
20
|
+
async function fetchApi(endpoint, method = "GET", body = null) {
|
|
21
|
+
const separator = endpoint.includes("?") ? "&" : "?";
|
|
22
|
+
const url = `${API_BASE}${endpoint}${separator}${APP_PARAM}`;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const options = {
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
"User-Agent": "HeroUI-Skill/1.0",
|
|
29
|
+
},
|
|
30
|
+
method,
|
|
31
|
+
signal: AbortSignal.timeout(30000),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (body) {
|
|
35
|
+
options.body = JSON.stringify(body);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const response = await fetch(url, options);
|
|
39
|
+
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
console.error(`# API Error: HTTP ${response.status}`);
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return await response.json();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(`# API Error: ${error.message}`);
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Fetch source code directly from GitHub as fallback.
|
|
56
|
+
*/
|
|
57
|
+
async function fetchGithubFallback(component) {
|
|
58
|
+
// Try common patterns for component paths
|
|
59
|
+
const patterns = [
|
|
60
|
+
`packages/react/src/components/${component.toLowerCase()}/${component.toLowerCase()}.tsx`,
|
|
61
|
+
`packages/react/src/components/${component.toLowerCase()}/index.tsx`,
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
for (const path of patterns) {
|
|
65
|
+
const url = `${GITHUB_RAW_BASE}/${path}`;
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const response = await fetch(url, {
|
|
69
|
+
headers: {"User-Agent": "HeroUI-Skill/1.0"},
|
|
70
|
+
signal: AbortSignal.timeout(30000),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (response.ok) {
|
|
74
|
+
const content = await response.text();
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
component,
|
|
78
|
+
filePath: path,
|
|
79
|
+
githubUrl: `https://github.com/heroui-inc/heroui/blob/v3/${path}`,
|
|
80
|
+
source: "fallback",
|
|
81
|
+
sourceCode: content,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {component, error: `Failed to fetch source for ${component}`};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Main function to get source code for specified components.
|
|
94
|
+
*/
|
|
95
|
+
async function main() {
|
|
96
|
+
const args = process.argv.slice(2);
|
|
97
|
+
|
|
98
|
+
if (args.length === 0) {
|
|
99
|
+
console.error("Usage: node get_source.mjs <Component1> [Component2] ...");
|
|
100
|
+
console.error("Example: node get_source.mjs Button Accordion");
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const components = args;
|
|
105
|
+
|
|
106
|
+
// Try API first
|
|
107
|
+
console.error(`# Fetching source code for: ${components.join(", ")}...`);
|
|
108
|
+
const data = await fetchApi("/v1/components/source", "POST", {components});
|
|
109
|
+
|
|
110
|
+
if (data && data.results) {
|
|
111
|
+
for (const result of data.results) {
|
|
112
|
+
result.source = "api";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Output results
|
|
116
|
+
if (data.results.length === 1) {
|
|
117
|
+
const result = data.results[0];
|
|
118
|
+
|
|
119
|
+
if (result.sourceCode) {
|
|
120
|
+
console.log(`// File: ${result.filePath || "unknown"}`);
|
|
121
|
+
console.log(`// GitHub: ${result.githubUrl || "unknown"}`);
|
|
122
|
+
console.log();
|
|
123
|
+
console.log(result.sourceCode);
|
|
124
|
+
} else {
|
|
125
|
+
console.log(JSON.stringify(result, null, 2));
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
console.log(JSON.stringify(data, null, 2));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Fallback to GitHub direct fetch
|
|
135
|
+
console.error("# API failed, using GitHub fallback...");
|
|
136
|
+
const results = [];
|
|
137
|
+
|
|
138
|
+
for (const component of components) {
|
|
139
|
+
const result = await fetchGithubFallback(component);
|
|
140
|
+
|
|
141
|
+
results.push(result);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (results.length === 1) {
|
|
145
|
+
const result = results[0];
|
|
146
|
+
|
|
147
|
+
if (result.sourceCode) {
|
|
148
|
+
console.log(`// File: ${result.filePath || "unknown"}`);
|
|
149
|
+
console.log(`// GitHub: ${result.githubUrl || "unknown"}`);
|
|
150
|
+
console.log();
|
|
151
|
+
console.log(result.sourceCode);
|
|
152
|
+
} else {
|
|
153
|
+
console.log(JSON.stringify(result, null, 2));
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
console.log(JSON.stringify({results}, null, 2));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
main();
|