@fragments-sdk/mcp 0.10.1 → 1.0.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 +34 -84
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +7 -153
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +1484 -0
- package/dist/index.js +1214 -207
- package/dist/index.js.map +1 -1
- package/package.json +9 -33
- package/dist/chunk-7D4SUZUM.js +0 -38
- package/dist/chunk-7D4SUZUM.js.map +0 -1
- package/dist/chunk-KGFM5SCE.js +0 -4263
- package/dist/chunk-KGFM5SCE.js.map +0 -1
- package/dist/chunk-VRPDT3Y6.js +0 -52
- package/dist/chunk-VRPDT3Y6.js.map +0 -1
- package/dist/chunk-WDQPNHZ2.js +0 -143
- package/dist/chunk-WDQPNHZ2.js.map +0 -1
- package/dist/dist-LVC53MY5.js +0 -61000
- package/dist/dist-LVC53MY5.js.map +0 -1
- package/dist/init.js +0 -175
- package/dist/init.js.map +0 -1
- package/dist/rules-JUZ3RABB.js +0 -8
- package/dist/rules-JUZ3RABB.js.map +0 -1
- package/dist/sass.node-4XJK6YBF-CPK77BO6.js +0 -130797
- package/dist/sass.node-4XJK6YBF-CPK77BO6.js.map +0 -1
- package/dist/server.js +0 -12
- package/dist/server.js.map +0 -1
package/dist/chunk-VRPDT3Y6.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// ../extract/dist/chunk-Z7EY4VHE.js
|
|
2
|
-
import { createRequire as __banner_createRequire } from "module";
|
|
3
|
-
var require2 = __banner_createRequire(import.meta.url);
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __require = /* @__PURE__ */ ((x) => typeof require2 !== "undefined" ? require2 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
-
get: (a, b) => (typeof require2 !== "undefined" ? require2 : a)[b]
|
|
12
|
-
}) : x)(function(x) {
|
|
13
|
-
if (typeof require2 !== "undefined") return require2.apply(this, arguments);
|
|
14
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
-
});
|
|
16
|
-
var __esm = (fn, res) => function __init() {
|
|
17
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
-
};
|
|
19
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
20
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
21
|
-
};
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
-
mod
|
|
41
|
-
));
|
|
42
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
__require,
|
|
46
|
-
__esm,
|
|
47
|
-
__commonJS,
|
|
48
|
-
__export,
|
|
49
|
-
__toESM,
|
|
50
|
-
__toCommonJS
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=chunk-VRPDT3Y6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../extract/dist/chunk-Z7EY4VHE.js"],"sourcesContent":["import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __require = /* @__PURE__ */ ((x) => typeof require !== \"undefined\" ? require : typeof Proxy !== \"undefined\" ? new Proxy(x, {\n get: (a, b) => (typeof require !== \"undefined\" ? require : a)[b]\n}) : x)(function(x) {\n if (typeof require !== \"undefined\") return require.apply(this, arguments);\n throw Error('Dynamic require of \"' + x + '\" is not supported');\n});\nvar __esm = (fn, res) => function __init() {\n return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;\n};\nvar __commonJS = (cb, mod) => function __require2() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n};\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\nexport {\n __require,\n __esm,\n __commonJS,\n __export,\n __toESM,\n __toCommonJS\n};\n//# sourceMappingURL=chunk-Z7EY4VHE.js.map"],"mappings":";AAAA,SAAS,iBAAiB,8BAA8B;AAAU,IAAMA,WAAU,uBAAuB,YAAY,GAAG;AACxH,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAA6B,kBAAC,MAAM,OAAOA,aAAY,cAAcA,WAAU,OAAO,UAAU,cAAc,IAAI,MAAM,GAAG;AAAA,EAC7H,KAAK,CAAC,GAAG,OAAO,OAAOA,aAAY,cAAcA,WAAU,GAAG,CAAC;AACjE,CAAC,IAAI,GAAG,SAAS,GAAG;AAClB,MAAI,OAAOA,aAAY,YAAa,QAAOA,SAAQ,MAAM,MAAM,SAAS;AACxE,QAAM,MAAM,yBAAyB,IAAI,oBAAoB;AAC/D,CAAC;AACD,IAAI,QAAQ,CAAC,IAAI,QAAQ,SAAS,SAAS;AACzC,SAAO,OAAO,OAAO,GAAG,GAAG,kBAAkB,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI;AAClE;AACA,IAAI,aAAa,CAAC,IAAI,QAAQ,SAAS,aAAa;AAClD,SAAO,QAAQ,GAAG,GAAG,kBAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,GAAG,IAAI;AAC7F;AACA,IAAI,WAAW,CAAC,QAAQ,QAAQ;AAC9B,WAAS,QAAQ;AACf,cAAU,QAAQ,MAAM,EAAE,KAAK,IAAI,IAAI,GAAG,YAAY,KAAK,CAAC;AAChE;AACA,IAAI,cAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC5C,MAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;AAClE,aAAS,OAAO,kBAAkB,IAAI;AACpC,UAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ;AACzC,kBAAU,IAAI,KAAK,EAAE,KAAK,MAAM,KAAK,GAAG,GAAG,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK,WAAW,CAAC;AAAA,EACvH;AACA,SAAO;AACT;AACA,IAAI,UAAU,CAAC,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW,EAAE,OAAO,KAAK,YAAY,KAAK,CAAC,IAAI;AAAA,EACzG;AACF;AACA,IAAI,eAAe,CAAC,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;","names":["require"]}
|
package/dist/chunk-WDQPNHZ2.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// src/rules.ts
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
4
|
-
|
|
5
|
-
// src/snapshot-helpers.ts
|
|
6
|
-
function getGuidanceWhen(component) {
|
|
7
|
-
if (component.guidance.when.length > 0) {
|
|
8
|
-
return component.guidance.when;
|
|
9
|
-
}
|
|
10
|
-
if (component.guidance.usageGuidance) {
|
|
11
|
-
return [component.guidance.usageGuidance];
|
|
12
|
-
}
|
|
13
|
-
if (component.guidance.dos.length > 0) {
|
|
14
|
-
return component.guidance.dos;
|
|
15
|
-
}
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
function getGuidanceWhenNot(component) {
|
|
19
|
-
if (component.guidance.whenNot.length > 0) {
|
|
20
|
-
return component.guidance.whenNot;
|
|
21
|
-
}
|
|
22
|
-
if (component.guidance.donts.length > 0) {
|
|
23
|
-
return component.guidance.donts;
|
|
24
|
-
}
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/rules.ts
|
|
29
|
-
function generateRulesFiles(options) {
|
|
30
|
-
const { data, brandName, outputDir, formats, force = false } = options;
|
|
31
|
-
const content = buildRulesContent(data, brandName);
|
|
32
|
-
const files = [];
|
|
33
|
-
for (const format of formats) {
|
|
34
|
-
let filePath;
|
|
35
|
-
let fileContent;
|
|
36
|
-
switch (format) {
|
|
37
|
-
case "cursor":
|
|
38
|
-
filePath = join(outputDir, ".cursorrules");
|
|
39
|
-
fileContent = content;
|
|
40
|
-
break;
|
|
41
|
-
case "claude":
|
|
42
|
-
filePath = join(outputDir, "CLAUDE.md");
|
|
43
|
-
fileContent = `# CLAUDE.md
|
|
44
|
-
|
|
45
|
-
This file provides guidance to Claude Code when working with code in this repository.
|
|
46
|
-
|
|
47
|
-
${content}`;
|
|
48
|
-
break;
|
|
49
|
-
case "copilot": {
|
|
50
|
-
const dir = join(outputDir, ".github");
|
|
51
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
52
|
-
filePath = join(dir, "copilot-instructions.md");
|
|
53
|
-
fileContent = content;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (!force && existsSync(filePath)) {
|
|
58
|
-
console.error(` Skipped ${filePath} (already exists, use --force to overwrite)`);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
writeFileSync(filePath, fileContent, "utf-8");
|
|
62
|
-
files.push(filePath);
|
|
63
|
-
}
|
|
64
|
-
return files;
|
|
65
|
-
}
|
|
66
|
-
function buildRulesContent(data, brandName) {
|
|
67
|
-
const sections = [];
|
|
68
|
-
sections.push(`# ${brandName} Design System Rules
|
|
69
|
-
`);
|
|
70
|
-
sections.push(`Always use ${brandName} components and design tokens when building UI. Do not use raw HTML elements, Tailwind classes, or hardcoded CSS values when a design system component or token exists.
|
|
71
|
-
`);
|
|
72
|
-
sections.push("## Agent Validation Loop\n");
|
|
73
|
-
sections.push("After generating or editing JSX, component props, class names, or CSS, call the Fragments MCP `govern` tool with the candidate UI spec before treating the work as complete.");
|
|
74
|
-
sections.push("If `govern` returns violations or a `nextAction` that asks for revision, call `validate_and_fix` with the same spec, apply any deterministic repair it returns, then call `govern` again.");
|
|
75
|
-
sections.push("Before writing a hardcoded CSS value, call `tokens.suggest` with the CSS property and value. Use the returned `cssValue` when a recommendation is present; keep the raw value only when the tool returns `noSuggestion: true`.\n");
|
|
76
|
-
sections.push("Example loop:");
|
|
77
|
-
sections.push("```text");
|
|
78
|
-
sections.push("1. Draft the UI spec for the component or screen.");
|
|
79
|
-
sections.push("2. govern({ spec })");
|
|
80
|
-
sections.push("3. If it fails: validate_and_fix({ spec, applyFixes: true })");
|
|
81
|
-
sections.push("4. Re-run govern({ spec: fixedSpec }) before finalizing.");
|
|
82
|
-
sections.push("```\n");
|
|
83
|
-
const components = Object.values(data.components);
|
|
84
|
-
if (components.length > 0) {
|
|
85
|
-
sections.push("## Components\n");
|
|
86
|
-
const byCategory = /* @__PURE__ */ new Map();
|
|
87
|
-
for (const c of components) {
|
|
88
|
-
const cat = c.category || "uncategorized";
|
|
89
|
-
if (!byCategory.has(cat)) byCategory.set(cat, []);
|
|
90
|
-
byCategory.get(cat).push(c.name);
|
|
91
|
-
}
|
|
92
|
-
for (const [cat, names] of byCategory) {
|
|
93
|
-
sections.push(`### ${cat}
|
|
94
|
-
`);
|
|
95
|
-
sections.push(names.map((n) => `- ${n}`).join("\n"));
|
|
96
|
-
sections.push("");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (data.defaultPackageName) {
|
|
100
|
-
sections.push("## Imports\n");
|
|
101
|
-
sections.push(`Import components from \`${data.defaultPackageName}\`:
|
|
102
|
-
`);
|
|
103
|
-
sections.push("```typescript");
|
|
104
|
-
const exampleNames = components.slice(0, 3).map((c) => c.name);
|
|
105
|
-
sections.push(`import { ${exampleNames.join(", ")} } from '${data.defaultPackageName}';`);
|
|
106
|
-
sections.push("```\n");
|
|
107
|
-
}
|
|
108
|
-
if (data.tokens && data.tokens.total > 0) {
|
|
109
|
-
sections.push("## Design Tokens\n");
|
|
110
|
-
sections.push(`Prefix: \`${data.tokens.prefix}\`. Use \`var(--token-name)\` in CSS/styles.
|
|
111
|
-
`);
|
|
112
|
-
sections.push("Available categories:");
|
|
113
|
-
for (const [cat, tokens] of Object.entries(data.tokens.categories)) {
|
|
114
|
-
sections.push(`- **${cat}** (${tokens.length} tokens)`);
|
|
115
|
-
}
|
|
116
|
-
sections.push("");
|
|
117
|
-
}
|
|
118
|
-
const allDos = [];
|
|
119
|
-
const allDonts = [];
|
|
120
|
-
for (const c of components) {
|
|
121
|
-
allDos.push(...getGuidanceWhen(c).slice(0, 1).map((w) => `${c.name}: ${w}`));
|
|
122
|
-
allDonts.push(...getGuidanceWhenNot(c).slice(0, 1).map((w) => `${c.name}: ${w}`));
|
|
123
|
-
}
|
|
124
|
-
if (allDos.length > 0 || allDonts.length > 0) {
|
|
125
|
-
sections.push("## Usage Guidelines\n");
|
|
126
|
-
if (allDos.length > 0) {
|
|
127
|
-
sections.push("**Do:**");
|
|
128
|
-
sections.push(allDos.slice(0, 10).map((d) => `- ${d}`).join("\n"));
|
|
129
|
-
sections.push("");
|
|
130
|
-
}
|
|
131
|
-
if (allDonts.length > 0) {
|
|
132
|
-
sections.push("**Don't:**");
|
|
133
|
-
sections.push(allDonts.slice(0, 10).map((d) => `- ${d}`).join("\n"));
|
|
134
|
-
sections.push("");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return sections.join("\n");
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export {
|
|
141
|
-
generateRulesFiles
|
|
142
|
-
};
|
|
143
|
-
//# sourceMappingURL=chunk-WDQPNHZ2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rules.ts","../src/snapshot-helpers.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { writeFileSync, mkdirSync, existsSync } from 'node:fs';\nimport type { McpComponent } from '@fragments-sdk/core';\nimport type { DesignSystemData } from './types.js';\nimport { getGuidanceWhen, getGuidanceWhenNot } from './snapshot-helpers.js';\n\nexport type RulesFormat = 'cursor' | 'claude' | 'copilot';\n\nexport interface RulesGeneratorOptions {\n data: DesignSystemData;\n brandName: string;\n outputDir: string;\n formats: RulesFormat[];\n /** Overwrite existing files (default: false — skip and warn) */\n force?: boolean;\n}\n\n/**\n * Generate IDE rules files from design system data.\n * Returns list of files written. Skips existing files unless force is true.\n */\nexport function generateRulesFiles(options: RulesGeneratorOptions): string[] {\n const { data, brandName, outputDir, formats, force = false } = options;\n const content = buildRulesContent(data, brandName);\n const files: string[] = [];\n\n for (const format of formats) {\n let filePath: string;\n let fileContent: string;\n\n switch (format) {\n case 'cursor':\n filePath = join(outputDir, '.cursorrules');\n fileContent = content;\n break;\n case 'claude':\n filePath = join(outputDir, 'CLAUDE.md');\n fileContent = `# CLAUDE.md\\n\\nThis file provides guidance to Claude Code when working with code in this repository.\\n\\n${content}`;\n break;\n case 'copilot': {\n const dir = join(outputDir, '.github');\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n filePath = join(dir, 'copilot-instructions.md');\n fileContent = content;\n break;\n }\n }\n\n if (!force && existsSync(filePath)) {\n console.error(` Skipped ${filePath} (already exists, use --force to overwrite)`);\n continue;\n }\n\n writeFileSync(filePath, fileContent, 'utf-8');\n files.push(filePath);\n }\n\n return files;\n}\n\nfunction buildRulesContent(data: DesignSystemData, brandName: string): string {\n const sections: string[] = [];\n\n // Header\n sections.push(`# ${brandName} Design System Rules\\n`);\n sections.push(`Always use ${brandName} components and design tokens when building UI. Do not use raw HTML elements, Tailwind classes, or hardcoded CSS values when a design system component or token exists.\\n`);\n\n sections.push('## Agent Validation Loop\\n');\n sections.push('After generating or editing JSX, component props, class names, or CSS, call the Fragments MCP `govern` tool with the candidate UI spec before treating the work as complete.');\n sections.push('If `govern` returns violations or a `nextAction` that asks for revision, call `validate_and_fix` with the same spec, apply any deterministic repair it returns, then call `govern` again.');\n sections.push('Before writing a hardcoded CSS value, call `tokens.suggest` with the CSS property and value. Use the returned `cssValue` when a recommendation is present; keep the raw value only when the tool returns `noSuggestion: true`.\\n');\n sections.push('Example loop:');\n sections.push('```text');\n sections.push('1. Draft the UI spec for the component or screen.');\n sections.push('2. govern({ spec })');\n sections.push('3. If it fails: validate_and_fix({ spec, applyFixes: true })');\n sections.push('4. Re-run govern({ spec: fixedSpec }) before finalizing.');\n sections.push('```\\n');\n\n // Component inventory\n const components: McpComponent[] = Object.values(data.components);\n if (components.length > 0) {\n sections.push('## Components\\n');\n const byCategory = new Map<string, string[]>();\n for (const c of components) {\n const cat = c.category || 'uncategorized';\n if (!byCategory.has(cat)) byCategory.set(cat, []);\n byCategory.get(cat)!.push(c.name);\n }\n for (const [cat, names] of byCategory) {\n sections.push(`### ${cat}\\n`);\n sections.push(names.map(n => `- ${n}`).join('\\n'));\n sections.push('');\n }\n }\n\n // Import pattern\n if (data.defaultPackageName) {\n sections.push('## Imports\\n');\n sections.push(`Import components from \\`${data.defaultPackageName}\\`:\\n`);\n sections.push('```typescript');\n const exampleNames = components.slice(0, 3).map(c => c.name);\n sections.push(`import { ${exampleNames.join(', ')} } from '${data.defaultPackageName}';`);\n sections.push('```\\n');\n }\n\n // Tokens\n if (data.tokens && data.tokens.total > 0) {\n sections.push('## Design Tokens\\n');\n sections.push(`Prefix: \\`${data.tokens.prefix}\\`. Use \\`var(--token-name)\\` in CSS/styles.\\n`);\n sections.push('Available categories:');\n for (const [cat, tokens] of Object.entries(data.tokens.categories) as Array<\n [string, typeof data.tokens.categories[string]]\n >) {\n sections.push(`- **${cat}** (${tokens.length} tokens)`);\n }\n sections.push('');\n }\n\n // Usage guidelines (aggregated from all components)\n const allDos: string[] = [];\n const allDonts: string[] = [];\n for (const c of components) {\n allDos.push(...getGuidanceWhen(c).slice(0, 1).map(w => `${c.name}: ${w}`));\n allDonts.push(...getGuidanceWhenNot(c).slice(0, 1).map(w => `${c.name}: ${w}`));\n }\n if (allDos.length > 0 || allDonts.length > 0) {\n sections.push('## Usage Guidelines\\n');\n if (allDos.length > 0) {\n sections.push('**Do:**');\n sections.push(allDos.slice(0, 10).map(d => `- ${d}`).join('\\n'));\n sections.push('');\n }\n if (allDonts.length > 0) {\n sections.push('**Don\\'t:**');\n sections.push(allDonts.slice(0, 10).map(d => `- ${d}`).join('\\n'));\n sections.push('');\n }\n }\n\n return sections.join('\\n');\n}\n","import type { McpBlock, McpComponent, McpSnapshot } from '@fragments-sdk/core';\n\nexport type ResolvedMcpComponent = McpComponent & {\n isCanonical?: boolean;\n};\n\nexport function listComponents(\n snapshot: Pick<McpSnapshot, 'components'>,\n): ResolvedMcpComponent[] {\n return Object.values(snapshot.components);\n}\n\nexport function componentNames(snapshot: Pick<McpSnapshot, 'components'>): string[] {\n return listComponents(snapshot).map((component) => component.name);\n}\n\nexport function listBlocks(snapshot: Pick<McpSnapshot, 'blocks'>): McpBlock[] {\n return Object.values(snapshot.blocks ?? {});\n}\n\nexport function findComponentByName(\n snapshot: Pick<McpSnapshot, 'components'>,\n name: string,\n): ResolvedMcpComponent | undefined {\n const query = name.toLowerCase();\n return listComponents(snapshot).find(\n (component) => component.name.toLowerCase() === query,\n );\n}\n\nfunction normalizeComponentRef(value: string): string {\n return value.trim().toLowerCase();\n}\n\nfunction buildCompoundComponent(\n parent: ResolvedMcpComponent,\n childName: string,\n): ResolvedMcpComponent | undefined {\n const child = parent.compoundChildren.find(\n (entry) => normalizeComponentRef(entry.name) === normalizeComponentRef(childName),\n );\n if (!child) return undefined;\n\n const fullName = child.name.includes('.')\n ? child.name\n : `${parent.name}.${child.name}`;\n\n return {\n ...parent,\n id: child.componentId ?? `${parent.id}::${fullName}`,\n name: fullName,\n description: child.description ?? '',\n props: {},\n propsSummary: [],\n examples: [],\n relations: [],\n compoundChildren: [],\n publicRef: child.componentId ?? fullName,\n publicSlug: null,\n parentComponentId: parent.id,\n parentComponentName: parent.name,\n };\n}\n\nexport function findComponent(\n snapshot: Pick<McpSnapshot, 'components'>,\n reference: string,\n): ResolvedMcpComponent | undefined {\n const query = normalizeComponentRef(reference);\n const components = listComponents(snapshot);\n\n const exact = components.find((component) => {\n return (\n normalizeComponentRef(component.name) === query ||\n normalizeComponentRef(component.id) === query ||\n normalizeComponentRef(component.publicRef ?? '') === query\n );\n });\n if (exact) return exact;\n\n if (reference.includes('.')) {\n const [parentName, ...childParts] = reference.split('.');\n const childName = childParts.join('.');\n const parent = components.find((component) => {\n return (\n normalizeComponentRef(component.name) === normalizeComponentRef(parentName) ||\n normalizeComponentRef(component.publicRef ?? '') ===\n normalizeComponentRef(parentName) ||\n normalizeComponentRef(component.id) === normalizeComponentRef(parentName)\n );\n });\n\n if (parent) {\n const child = buildCompoundComponent(parent, childName);\n if (child) return child;\n }\n }\n\n return undefined;\n}\n\nexport function getGuidanceWhen(component: ResolvedMcpComponent): string[] {\n if (component.guidance.when.length > 0) {\n return component.guidance.when;\n }\n if (component.guidance.usageGuidance) {\n return [component.guidance.usageGuidance];\n }\n if (component.guidance.dos.length > 0) {\n return component.guidance.dos;\n }\n return [];\n}\n\nexport function getGuidanceWhenNot(component: ResolvedMcpComponent): string[] {\n if (component.guidance.whenNot.length > 0) {\n return component.guidance.whenNot;\n }\n if (component.guidance.donts.length > 0) {\n return component.guidance.donts;\n }\n return [];\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,e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