@matchkit.io/cli 0.1.2 → 0.1.3
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/dist/commands/pull.js +38 -6
- package/package.json +1 -1
package/dist/commands/pull.js
CHANGED
|
@@ -6,11 +6,41 @@ import { readConfig, configExists, writeConfig, createDefaultConfig } from "../u
|
|
|
6
6
|
import { getApiKey, authFetch, API_BASE_URL } from "../utils/auth.js";
|
|
7
7
|
// Marker used to detect MatchKit-managed AI rules files
|
|
8
8
|
const MATCHKIT_MARKER = "<!-- managed:matchkit -->";
|
|
9
|
+
/**
|
|
10
|
+
* Read registry.json from the extracted skill directory and build
|
|
11
|
+
* a markdown import map table for AI rules files.
|
|
12
|
+
*/
|
|
13
|
+
function buildImportMap(fullSkillDir) {
|
|
14
|
+
const registryPath = join(fullSkillDir, "registry.json");
|
|
15
|
+
if (!existsSync(registryPath))
|
|
16
|
+
return "";
|
|
17
|
+
try {
|
|
18
|
+
const registry = JSON.parse(readFileSync(registryPath, "utf-8"));
|
|
19
|
+
const lines = [];
|
|
20
|
+
for (const comp of registry.components) {
|
|
21
|
+
if (!comp.exportName || !comp.file)
|
|
22
|
+
continue;
|
|
23
|
+
// Skip non-component entries (layouts, patterns)
|
|
24
|
+
if (comp.type === "registry:layout" || comp.type === "registry:pattern")
|
|
25
|
+
continue;
|
|
26
|
+
const file = comp.file.replace(/\.tsx$/, "");
|
|
27
|
+
const exports = Array.isArray(comp.exportName) ? comp.exportName : [comp.exportName];
|
|
28
|
+
const importStr = `{ ${exports.join(", ")} }`;
|
|
29
|
+
lines.push(`| ${comp.name} | \`import ${importStr} from "@/components/ui/${file}"\` |`);
|
|
30
|
+
}
|
|
31
|
+
if (lines.length === 0)
|
|
32
|
+
return "";
|
|
33
|
+
return `\n### Component imports — use these EXACT names:\n\n| Component | Import |\n|-----------|--------|\n${lines.join("\n")}\n`;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
9
39
|
/**
|
|
10
40
|
* Build the content for AI rules files.
|
|
11
41
|
* This is the mandatory instruction set that tells AI tools to use the design system.
|
|
12
42
|
*/
|
|
13
|
-
function buildAiRulesContent(skillDir, theme) {
|
|
43
|
+
function buildAiRulesContent(skillDir, theme, importMap) {
|
|
14
44
|
return `${MATCHKIT_MARKER}
|
|
15
45
|
# MatchKit Design System — ${theme}-ui
|
|
16
46
|
|
|
@@ -54,17 +84,17 @@ A full design system is installed at \`${skillDir}/\`. You MUST use it for ALL U
|
|
|
54
84
|
| \`globals.css\` | Complete Tailwind v4 CSS with all tokens |
|
|
55
85
|
| \`tokens/*.json\` | Design token values |
|
|
56
86
|
| \`patterns/*.md\` | Responsive, dark mode, a11y, composition patterns |
|
|
57
|
-
`;
|
|
87
|
+
${importMap}`;
|
|
58
88
|
}
|
|
59
89
|
/**
|
|
60
90
|
* Build Cursor .mdc format content (has YAML frontmatter with alwaysApply).
|
|
61
91
|
*/
|
|
62
|
-
function buildCursorMdcContent(skillDir, theme) {
|
|
92
|
+
function buildCursorMdcContent(skillDir, theme, importMap) {
|
|
63
93
|
return `---
|
|
64
94
|
description: MatchKit ${theme}-ui design system — mandatory rules for all UI work
|
|
65
95
|
alwaysApply: true
|
|
66
96
|
---
|
|
67
|
-
${buildAiRulesContent(skillDir, theme)}`;
|
|
97
|
+
${buildAiRulesContent(skillDir, theme, importMap)}`;
|
|
68
98
|
}
|
|
69
99
|
/**
|
|
70
100
|
* Write AI rules files to the project root.
|
|
@@ -72,8 +102,10 @@ ${buildAiRulesContent(skillDir, theme)}`;
|
|
|
72
102
|
* Returns the list of files that were written.
|
|
73
103
|
*/
|
|
74
104
|
function writeAiRulesFiles(cwd, skillDir, theme) {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
105
|
+
const fullSkillDir = join(cwd, skillDir);
|
|
106
|
+
const importMap = buildImportMap(fullSkillDir);
|
|
107
|
+
const content = buildAiRulesContent(skillDir, theme, importMap);
|
|
108
|
+
const cursorMdcContent = buildCursorMdcContent(skillDir, theme, importMap);
|
|
77
109
|
const written = [];
|
|
78
110
|
const targets = [
|
|
79
111
|
{ path: "CLAUDE.md", label: "CLAUDE.md", content },
|
package/package.json
CHANGED