@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.
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Get CSS styles (BEM classes) for HeroUI v3 components.
4
+ *
5
+ * Usage:
6
+ * node get_styles.mjs Button
7
+ * node get_styles.mjs Button Card Chip
8
+ *
9
+ * Output:
10
+ * CSS file content with BEM classes and 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 CSS styles directly from GitHub as fallback.
56
+ */
57
+ async function fetchGithubFallback(component) {
58
+ // Try common patterns for style paths
59
+ const patterns = [
60
+ `packages/styles/src/components/${component.toLowerCase()}.css`,
61
+ `packages/styles/components/${component.toLowerCase()}.css`,
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
+ stylesCode: content,
82
+ };
83
+ }
84
+ } catch {
85
+ continue;
86
+ }
87
+ }
88
+
89
+ return {component, error: `Failed to fetch styles for ${component}`};
90
+ }
91
+
92
+ /**
93
+ * Main function to get CSS styles 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_styles.mjs <Component1> [Component2] ...");
100
+ console.error("Example: node get_styles.mjs Button Card");
101
+ process.exit(1);
102
+ }
103
+
104
+ const components = args;
105
+
106
+ // Try API first
107
+ console.error(`# Fetching styles for: ${components.join(", ")}...`);
108
+ const data = await fetchApi("/v1/components/styles", "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.stylesCode) {
120
+ console.log(`/* File: ${result.filePath || "unknown"} */`);
121
+ console.log(`/* GitHub: ${result.githubUrl || "unknown"} */`);
122
+ console.log();
123
+ console.log(result.stylesCode);
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.stylesCode) {
148
+ console.log(`/* File: ${result.filePath || "unknown"} */`);
149
+ console.log(`/* GitHub: ${result.githubUrl || "unknown"} */`);
150
+ console.log();
151
+ console.log(result.stylesCode);
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();
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Get theme variables and design tokens for HeroUI v3.
4
+ *
5
+ * Usage:
6
+ * node get_theme.mjs
7
+ *
8
+ * Output:
9
+ * Theme variables organized by common/light/dark with oklch color format
10
+ */
11
+
12
+ const API_BASE = process.env.HEROUI_API_BASE || "https://mcp-api.heroui.com";
13
+ const APP_PARAM = "app=react-skills";
14
+
15
+ // Fallback theme reference when API is unavailable
16
+ const FALLBACK_THEME = {
17
+ common: {
18
+ base: [
19
+ {name: "--font-sans", value: "ui-sans-serif, system-ui, sans-serif"},
20
+ {name: "--font-mono", value: "ui-monospace, monospace"},
21
+ {name: "--radius-sm", value: "0.375rem"},
22
+ {name: "--radius-md", value: "0.5rem"},
23
+ {name: "--radius-lg", value: "0.75rem"},
24
+ {name: "--radius-full", value: "9999px"},
25
+ ],
26
+ calculated: [{name: "--spacing-unit", value: "0.25rem"}],
27
+ },
28
+ dark: {
29
+ semantic: [
30
+ {name: "--color-background", value: "oklch(14.5% 0 0)"},
31
+ {name: "--color-foreground", value: "oklch(98.4% 0 0)"},
32
+ {name: "--color-accent", value: "oklch(55.1% 0.228 264.1)"},
33
+ {name: "--color-danger", value: "oklch(63.7% 0.237 25.3)"},
34
+ {name: "--color-success", value: "oklch(76.5% 0.177 163.2)"},
35
+ {name: "--color-warning", value: "oklch(79.5% 0.184 86.0)"},
36
+ ],
37
+ },
38
+ latestVersion: "3.0.0-beta",
39
+ light: {
40
+ semantic: [
41
+ {name: "--color-background", value: "oklch(100% 0 0)"},
42
+ {name: "--color-foreground", value: "oklch(14.5% 0 0)"},
43
+ {name: "--color-accent", value: "oklch(55.1% 0.228 264.1)"},
44
+ {name: "--color-danger", value: "oklch(63.7% 0.237 25.3)"},
45
+ {name: "--color-success", value: "oklch(76.5% 0.177 163.2)"},
46
+ {name: "--color-warning", value: "oklch(79.5% 0.184 86.0)"},
47
+ ],
48
+ },
49
+ note: "This is a fallback. For complete theme variables, ensure the API is accessible.",
50
+ source: "fallback",
51
+ theme: "default",
52
+ };
53
+
54
+ /**
55
+ * Fetch data from HeroUI API with app parameter for analytics.
56
+ */
57
+ async function fetchApi(endpoint) {
58
+ const separator = endpoint.includes("?") ? "&" : "?";
59
+ const url = `${API_BASE}${endpoint}${separator}${APP_PARAM}`;
60
+
61
+ try {
62
+ const response = await fetch(url, {
63
+ headers: {"User-Agent": "HeroUI-Skill/1.0"},
64
+ signal: AbortSignal.timeout(30000),
65
+ });
66
+
67
+ if (!response.ok) {
68
+ console.error(`# API Error: HTTP ${response.status}`);
69
+
70
+ return null;
71
+ }
72
+
73
+ return await response.json();
74
+ } catch (error) {
75
+ console.error(`# API Error: ${error.message}`);
76
+
77
+ return null;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Format theme variables for display.
83
+ */
84
+ function formatVariables(variables) {
85
+ const lines = [];
86
+
87
+ for (const variable of variables) {
88
+ const name = variable.name || "";
89
+ const value = variable.value || "";
90
+ const desc = variable.description || "";
91
+
92
+ if (desc) {
93
+ lines.push(` ${name}: ${value}; /* ${desc} */`);
94
+ } else {
95
+ lines.push(` ${name}: ${value};`);
96
+ }
97
+ }
98
+
99
+ return lines.join("\n");
100
+ }
101
+
102
+ /**
103
+ * Main function to get theme variables.
104
+ */
105
+ async function main() {
106
+ console.error("# Fetching theme variables...");
107
+
108
+ const rawData = await fetchApi("/v1/themes/variables?theme=default");
109
+
110
+ let data;
111
+ let version;
112
+
113
+ if (!rawData) {
114
+ console.error("# API failed, using fallback theme reference...");
115
+ data = FALLBACK_THEME;
116
+ version = FALLBACK_THEME.latestVersion || "unknown";
117
+ } else {
118
+ // Handle API response format: { themes: [...], latestVersion: "..." }
119
+ if (rawData.themes && rawData.themes.length > 0) {
120
+ data = rawData.themes[0]; // Get first theme (default)
121
+ version = rawData.latestVersion || rawData.version || "unknown";
122
+ } else {
123
+ // Direct format
124
+ data = rawData;
125
+ version = rawData.latestVersion || "unknown";
126
+ }
127
+ }
128
+
129
+ // Output as formatted CSS-like structure for readability
130
+ console.log("/* HeroUI v3 Theme Variables */");
131
+ console.log(`/* Theme: ${data.theme || "default"} */`);
132
+ console.log(`/* Version: ${version} */`);
133
+ console.log();
134
+
135
+ // Common variables
136
+ if (data.common) {
137
+ console.log(":root {");
138
+ console.log(" /* Base Variables */");
139
+ if (data.common.base) {
140
+ console.log(formatVariables(data.common.base));
141
+ }
142
+ console.log();
143
+ console.log(" /* Calculated Variables */");
144
+ if (data.common.calculated) {
145
+ console.log(formatVariables(data.common.calculated));
146
+ }
147
+ console.log("}");
148
+ console.log();
149
+ }
150
+
151
+ // Light mode
152
+ if (data.light) {
153
+ console.log(":root, [data-theme='light'] {");
154
+ console.log(" /* Light Mode Semantic Variables */");
155
+ if (data.light.semantic) {
156
+ console.log(formatVariables(data.light.semantic));
157
+ }
158
+ console.log("}");
159
+ console.log();
160
+ }
161
+
162
+ // Dark mode
163
+ if (data.dark) {
164
+ console.log("[data-theme='dark'] {");
165
+ console.log(" /* Dark Mode Semantic Variables */");
166
+ if (data.dark.semantic) {
167
+ console.log(formatVariables(data.dark.semantic));
168
+ }
169
+ console.log("}");
170
+ }
171
+
172
+ // Also output raw JSON to stderr for programmatic use
173
+ console.error("\n# Raw JSON output:");
174
+ console.error(JSON.stringify(rawData || data, null, 2));
175
+ }
176
+
177
+ main();
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * List all available HeroUI v3 components.
4
+ *
5
+ * Usage:
6
+ * node list_components.mjs
7
+ *
8
+ * Output:
9
+ * JSON with components array, latestVersion, and count
10
+ */
11
+
12
+ const API_BASE = process.env.HEROUI_API_BASE || "https://mcp-api.heroui.com";
13
+ const APP_PARAM = "app=react-skills";
14
+ const LLMS_TXT_URL = "https://heroui.com/react/llms.txt";
15
+
16
+ /**
17
+ * Fetch data from HeroUI API with app parameter for analytics.
18
+ */
19
+ async function fetchApi(endpoint) {
20
+ const separator = endpoint.includes("?") ? "&" : "?";
21
+ const url = `${API_BASE}${endpoint}${separator}${APP_PARAM}`;
22
+
23
+ try {
24
+ const response = await fetch(url, {
25
+ headers: {"User-Agent": "HeroUI-Skill/1.0"},
26
+ signal: AbortSignal.timeout(30000),
27
+ });
28
+
29
+ if (!response.ok) {
30
+ console.error(`HTTP Error ${response.status}: ${response.statusText}`);
31
+
32
+ return null;
33
+ }
34
+
35
+ return await response.json();
36
+ } catch (error) {
37
+ console.error(`API Error: ${error.message}`);
38
+
39
+ return null;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Fetch component list from llms.txt fallback URL.
45
+ */
46
+ async function fetchFallback() {
47
+ try {
48
+ const response = await fetch(LLMS_TXT_URL, {
49
+ headers: {"User-Agent": "HeroUI-Skill/1.0"},
50
+ signal: AbortSignal.timeout(30000),
51
+ });
52
+
53
+ if (!response.ok) {
54
+ return null;
55
+ }
56
+
57
+ const content = await response.text();
58
+
59
+ // Parse markdown to extract component names from pattern: - [ComponentName](url)
60
+ // Look for links under the Components section (### Components)
61
+ const components = [];
62
+ let inComponentsSection = false;
63
+
64
+ for (const line of content.split("\n")) {
65
+ // Check if we're entering the Components section (uses ### header)
66
+ if (line.trim() === "### Components") {
67
+ inComponentsSection = true;
68
+ continue;
69
+ }
70
+
71
+ // Check if we're leaving the Components section (another ### header)
72
+ if (inComponentsSection && line.trim().startsWith("### ")) {
73
+ break;
74
+ }
75
+
76
+ // Extract component name from markdown link pattern
77
+ // Match: - [ComponentName](https://www.heroui.com/docs/react/components/component-name)
78
+ // Skip "All Components" which links to /components without a specific component
79
+ if (inComponentsSection) {
80
+ const match = line.match(
81
+ /^\s*-\s*\[([^\]]+)\]\(https:\/\/www\.heroui\.com\/docs\/react\/components\/[a-z]/,
82
+ );
83
+
84
+ if (match) {
85
+ components.push(match[1]);
86
+ }
87
+ }
88
+ }
89
+
90
+ if (components.length > 0) {
91
+ console.error(`# Using fallback: ${LLMS_TXT_URL}`);
92
+
93
+ return {
94
+ components: components.sort(),
95
+ count: components.length,
96
+ latestVersion: "unknown",
97
+ };
98
+ }
99
+
100
+ return null;
101
+ } catch (error) {
102
+ console.error(`Fallback Error: ${error.message}`);
103
+
104
+ return null;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Main function to list all available HeroUI v3 components.
110
+ */
111
+ async function main() {
112
+ let data = await fetchApi("/v1/components");
113
+
114
+ // Check if API returned valid data with components
115
+ if (!data || !data.components || data.components.length === 0) {
116
+ console.error("# API returned no components, trying fallback...");
117
+ data = await fetchFallback();
118
+ }
119
+
120
+ if (!data || !data.components || data.components.length === 0) {
121
+ console.error("Error: Failed to fetch component list from API and fallback");
122
+ process.exit(1);
123
+ }
124
+
125
+ // Output formatted JSON
126
+ console.log(JSON.stringify(data, null, 2));
127
+
128
+ // Print summary to stderr for human readability
129
+ console.error(
130
+ `\n# Found ${data.components.length} components (${data.latestVersion || "unknown"})`,
131
+ );
132
+ }
133
+
134
+ main();
@@ -0,0 +1,12 @@
1
+ # Flow behavior contract
2
+
3
+ Use one contract per independently designed flow. Name the flow, starting route and relevant components. Record approved design decisions in English; keep open questions separate. Preserve existing scenario IDs when editing.
4
+
5
+ | ID | Starting condition | Trigger | Expected result | Side effects / evidence |
6
+ | --- | --- | --- | --- | --- |
7
+
8
+ Include validation, pending, failure, recovery, success and retained data where applicable. Reference shared controls and approved tokens. Add only scenarios grounded in agreed requirements.
9
+
10
+ ## Open questions
11
+
12
+ Record unresolved product decisions here before treating them as acceptance criteria.
@@ -0,0 +1,13 @@
1
+ # ADS project profile
2
+
3
+ <!-- ads-profile: pending -->
4
+
5
+ Installation is complete. Project discovery is pending. Ask the agent to connect ADS using ads-init before recording or reviewing. Replace this starter with verified settings; remove the pending marker after discovery.
6
+
7
+ - **Application:** inspect app roots, manifests, lockfiles, framework and existing UI library.
8
+ - **Run locally:** record verified install, start and test commands with working directories, environment variable names and loopback URL discovery.
9
+ - **Flow mapping:** identify routes, components, services, existing contracts and shared dependencies. For new contracts without an existing convention use docs/ads/flows/<slug>.md.
10
+ - **Recording:** inspect existing tools and synthetic fixtures; select a Git-ignored output path. Record missing dependencies explicitly.
11
+ - **Design tokens:** identify approved theme sources, token validation and build integration; record any gaps.
12
+ - **Review:** identify available checks and evidence of business acceptance; distinguish actual acceptance from controlled responses.
13
+ - **Verification and gaps:** list checks actually run and unresolved decisions. Do not infer approved behavior from implementation.
@@ -0,0 +1,14 @@
1
+ # ADS behavior review
2
+
3
+ Record scope, revision or working tree, application origin and commands actually run. Lead with actionable findings and give an overall Passed, Failed or Unverified verdict.
4
+
5
+ | Component / scenario ID | Verdict | Expected / observed | Evidence / reproduction |
6
+ | --- | --- | --- | --- |
7
+
8
+ ## Design tokens
9
+
10
+ Give a separate token-gate verdict with source references. Report unresolved values by element, state, property and location. Withhold acceptance until mappings are resolved.
11
+
12
+ ## Evidence gaps
13
+
14
+ Passed requires observed evidence for all criteria. Failed requires a reproducible mismatch. Use Unverified for missing evidence. Identify controlled responses and actual service acceptance separately.
@@ -0,0 +1,9 @@
1
+ ## Agentic Design System
2
+
3
+ Use ads-init to discover or refresh this project's settings. Read docs/ads/project.md before recording, review or Figma handoff. If it contains `ads-profile: pending`, complete discovery with ads-init first. Preserve this project's UI stack and team conventions.
4
+
5
+ Maintain the affected flow's English behavior contract and stable scenario IDs when approved behavior changes. Use the approved contract as the baseline for fixes. Use approved design-system tokens for authored visual values, including nested slots and states. Run the project's token check and trace dynamic styles and Figma bindings. For an unresolved mapping, name the element, state, property, value and source; ask the designer which approved token to use and withhold acceptance until resolved.
6
+
7
+ Use ads-record for a separately requested walkthrough; use ads-code-review to verify integrated behavior. Use ads-figma-to-code for supplied Figma designs and ads-code-to-figma for editable Figma components or flows. Run local tools for the user. Recordings use synthetic input. Post results externally only when requested.
8
+
9
+ The installed package version and file hashes are in .ads/install.json. To upgrade the bundle use `npx @skriv/ads@latest update`; reconcile reported local changes before retrying. Use `npx @skriv/ads@latest doctor` to check setup. Templates are in docs/ads/templates/.
package/package.json CHANGED
@@ -1,6 +1,19 @@
1
1
  {
2
2
  "name": "@skriv/ads",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Project-local Agentic Design System skills, onboarding and diagnostics",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "engines": { "node": ">=22" },
8
+ "bin": { "ads": "bin/ads.mjs" },
9
+ "files": ["bin/", "src/", "dist/", "README.md"],
10
+ "publishConfig": { "access": "public" },
11
+ "repository": { "type": "git", "url": "git+https://github.com/skriv/ADS.git", "directory": "packages/ads" },
12
+ "scripts": {
13
+ "build": "node scripts/build.mjs",
14
+ "test": "node --test test/install.test.mjs",
15
+ "check": "npm run build && npm test",
16
+ "prepack": "npm run check",
17
+ "test:packed": "node scripts/test-packed.mjs"
18
+ }
19
+ }
package/src/doctor.mjs ADDED
@@ -0,0 +1,38 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { createRequire } from 'node:module';
5
+ import { hash, readOptional, readState, safePath } from './install.mjs';
6
+
7
+ export function doctor(target) {
8
+ const root = fs.realpathSync(target);
9
+ const checks = [];
10
+ const add = (name, status, detail) => checks.push({ name, status, detail });
11
+ add('Node.js', Number(process.versions.node.split('.')[0]) >= 22 ? 'ok' : 'error', process.version);
12
+ const state = readState(root);
13
+ add('ADS installation', state ? 'ok' : 'error', state ? `${state.package}@${state.version}` : 'Run npx @skriv/ads@latest init');
14
+ if (state) {
15
+ for (const [relative, digest] of Object.entries(state.files)) {
16
+ const bytes = readOptional(safePath(root, relative));
17
+ if (!bytes || hash(bytes) !== digest) add(relative, 'error', bytes ? 'Changed locally; reconcile before update' : 'Missing managed file; run update');
18
+ }
19
+ const instructions = readOptional(safePath(root, 'AGENTS.md'))?.toString() ?? '';
20
+ const block = instructions.match(/<!-- ads-package:begin -->[\s\S]*?<!-- ads-package:end -->/)?.[0];
21
+ const routingValid = block && hash(block) === state.routingHash;
22
+ add('Agent routing', routingValid ? 'ok' : 'error', routingValid ? 'ADS routing block checked' : block ? 'ADS routing block changed locally; reconcile before update' : 'ADS routing block missing');
23
+ }
24
+ const profile = readOptional(safePath(root, 'docs/ads/project.md'))?.toString();
25
+ add('Project discovery', !profile ? 'error' : profile.includes('ads-profile: pending') ? 'warn' : 'ok', !profile || profile.includes('ads-profile: pending') ? 'Ask the agent: Connect ADS to this project' : 'Profile present; agent must verify commands before use');
26
+ for (const [command, args] of [['ffmpeg', ['-version']], ['ffprobe', ['-version']], ['agent-browser', ['--version']]]) {
27
+ // Do not execute project-local npm scripts or auto-install packages during diagnostics.
28
+ const result = spawnSync(command, args, { encoding: 'utf8', timeout: 5000, shell: false });
29
+ add(command, !result.error && result.status === 0 ? 'ok' : 'warn', result.status === 0 ? result.stdout.trim().split('\n')[0] : 'Optional recording tool unavailable; see package setup guide');
30
+ }
31
+ let playwright;
32
+ for (const dir of [root, path.join(root, 'review')]) {
33
+ try { playwright = createRequire(path.join(dir, 'package.json')).resolve('playwright'); break; } catch {}
34
+ }
35
+ add('Playwright', playwright ? 'ok' : 'warn', playwright ? 'Available in project or review dependencies' : 'Use the project browser tooling or install Playwright when needed');
36
+ add('Figma connection', 'info', 'Agent verifies read/write access in the connected Figma tool when requested');
37
+ return { root, healthy: !checks.some(c => c.status === 'error'), checks };
38
+ }