@fragments-sdk/mcp 0.7.0 → 0.7.1
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/bin.js +3 -3
- package/dist/{chunk-LZW5KUXV.js → chunk-HGGAXLRO.js} +505 -297
- package/dist/chunk-HGGAXLRO.js.map +1 -0
- package/dist/{chunk-7GGI7JJE.js → chunk-VV2PJ75X.js} +2 -2
- package/dist/chunk-YSRGQDEB.js +93 -0
- package/dist/chunk-YSRGQDEB.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/rules-CKBRD3UL.js +8 -0
- package/dist/server.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-3IHXJEMM.js +0 -47
- package/dist/chunk-3IHXJEMM.js.map +0 -1
- package/dist/chunk-LZW5KUXV.js.map +0 -1
- package/dist/rules-W47BYPZV.js +0 -8
- /package/dist/{chunk-7GGI7JJE.js.map → chunk-VV2PJ75X.js.map} +0 -0
- /package/dist/{rules-W47BYPZV.js.map → rules-CKBRD3UL.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getGuidanceWhen,
|
|
3
3
|
getGuidanceWhenNot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YSRGQDEB.js";
|
|
5
5
|
|
|
6
6
|
// src/rules.ts
|
|
7
7
|
import { join } from "path";
|
|
@@ -109,4 +109,4 @@ function buildRulesContent(data, brandName) {
|
|
|
109
109
|
export {
|
|
110
110
|
generateRulesFiles
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-VV2PJ75X.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/snapshot-helpers.ts
|
|
2
|
+
function listComponents(snapshot) {
|
|
3
|
+
return Object.values(snapshot.components);
|
|
4
|
+
}
|
|
5
|
+
function componentNames(snapshot) {
|
|
6
|
+
return listComponents(snapshot).map((component) => component.name);
|
|
7
|
+
}
|
|
8
|
+
function listBlocks(snapshot) {
|
|
9
|
+
return Object.values(snapshot.blocks ?? {});
|
|
10
|
+
}
|
|
11
|
+
function findComponentByName(snapshot, name) {
|
|
12
|
+
const query = name.toLowerCase();
|
|
13
|
+
return listComponents(snapshot).find(
|
|
14
|
+
(component) => component.name.toLowerCase() === query
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function normalizeComponentRef(value) {
|
|
18
|
+
return value.trim().toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
function buildCompoundComponent(parent, childName) {
|
|
21
|
+
const child = parent.compoundChildren.find(
|
|
22
|
+
(entry) => normalizeComponentRef(entry.name) === normalizeComponentRef(childName)
|
|
23
|
+
);
|
|
24
|
+
if (!child) return void 0;
|
|
25
|
+
const fullName = child.name.includes(".") ? child.name : `${parent.name}.${child.name}`;
|
|
26
|
+
return {
|
|
27
|
+
...parent,
|
|
28
|
+
id: child.componentId ?? `${parent.id}::${fullName}`,
|
|
29
|
+
name: fullName,
|
|
30
|
+
description: child.description ?? "",
|
|
31
|
+
props: {},
|
|
32
|
+
propsSummary: [],
|
|
33
|
+
examples: [],
|
|
34
|
+
relations: [],
|
|
35
|
+
compoundChildren: [],
|
|
36
|
+
publicRef: child.componentId ?? fullName,
|
|
37
|
+
publicSlug: null,
|
|
38
|
+
parentComponentId: parent.id,
|
|
39
|
+
parentComponentName: parent.name
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function findComponent(snapshot, reference) {
|
|
43
|
+
const query = normalizeComponentRef(reference);
|
|
44
|
+
const components = listComponents(snapshot);
|
|
45
|
+
const exact = components.find((component) => {
|
|
46
|
+
return normalizeComponentRef(component.name) === query || normalizeComponentRef(component.id) === query || normalizeComponentRef(component.publicRef ?? "") === query;
|
|
47
|
+
});
|
|
48
|
+
if (exact) return exact;
|
|
49
|
+
if (reference.includes(".")) {
|
|
50
|
+
const [parentName, ...childParts] = reference.split(".");
|
|
51
|
+
const childName = childParts.join(".");
|
|
52
|
+
const parent = components.find((component) => {
|
|
53
|
+
return normalizeComponentRef(component.name) === normalizeComponentRef(parentName) || normalizeComponentRef(component.publicRef ?? "") === normalizeComponentRef(parentName) || normalizeComponentRef(component.id) === normalizeComponentRef(parentName);
|
|
54
|
+
});
|
|
55
|
+
if (parent) {
|
|
56
|
+
const child = buildCompoundComponent(parent, childName);
|
|
57
|
+
if (child) return child;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
function getGuidanceWhen(component) {
|
|
63
|
+
if (component.guidance.when.length > 0) {
|
|
64
|
+
return component.guidance.when;
|
|
65
|
+
}
|
|
66
|
+
if (component.guidance.usageGuidance) {
|
|
67
|
+
return [component.guidance.usageGuidance];
|
|
68
|
+
}
|
|
69
|
+
if (component.guidance.dos.length > 0) {
|
|
70
|
+
return component.guidance.dos;
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
function getGuidanceWhenNot(component) {
|
|
75
|
+
if (component.guidance.whenNot.length > 0) {
|
|
76
|
+
return component.guidance.whenNot;
|
|
77
|
+
}
|
|
78
|
+
if (component.guidance.donts.length > 0) {
|
|
79
|
+
return component.guidance.donts;
|
|
80
|
+
}
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
listComponents,
|
|
86
|
+
componentNames,
|
|
87
|
+
listBlocks,
|
|
88
|
+
findComponentByName,
|
|
89
|
+
findComponent,
|
|
90
|
+
getGuidanceWhen,
|
|
91
|
+
getGuidanceWhenNot
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=chunk-YSRGQDEB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/snapshot-helpers.ts"],"sourcesContent":["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":";AAMO,SAAS,eACd,UACwB;AACxB,SAAO,OAAO,OAAO,SAAS,UAAU;AAC1C;AAEO,SAAS,eAAe,UAAqD;AAClF,SAAO,eAAe,QAAQ,EAAE,IAAI,CAAC,cAAc,UAAU,IAAI;AACnE;AAEO,SAAS,WAAW,UAAmD;AAC5E,SAAO,OAAO,OAAO,SAAS,UAAU,CAAC,CAAC;AAC5C;AAEO,SAAS,oBACd,UACA,MACkC;AAClC,QAAM,QAAQ,KAAK,YAAY;AAC/B,SAAO,eAAe,QAAQ,EAAE;AAAA,IAC9B,CAAC,cAAc,UAAU,KAAK,YAAY,MAAM;AAAA,EAClD;AACF;AAEA,SAAS,sBAAsB,OAAuB;AACpD,SAAO,MAAM,KAAK,EAAE,YAAY;AAClC;AAEA,SAAS,uBACP,QACA,WACkC;AAClC,QAAM,QAAQ,OAAO,iBAAiB;AAAA,IACpC,CAAC,UAAU,sBAAsB,MAAM,IAAI,MAAM,sBAAsB,SAAS;AAAA,EAClF;AACA,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,WAAW,MAAM,KAAK,SAAS,GAAG,IACpC,MAAM,OACN,GAAG,OAAO,IAAI,IAAI,MAAM,IAAI;AAEhC,SAAO;AAAA,IACL,GAAG;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,SAAS,eAAe;AACpC,WAAO,CAAC,UAAU,SAAS,aAAa;AAAA,EAC1C;AACA,MAAI,UAAU,SAAS,IAAI,SAAS,GAAG;AACrC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,SAAO,CAAC;AACV;AAEO,SAAS,mBAAmB,WAA2C;AAC5E,MAAI,UAAU,SAAS,QAAQ,SAAS,GAAG;AACzC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,MAAI,UAAU,SAAS,MAAM,SAAS,GAAG;AACvC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,SAAO,CAAC;AACV;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
telemetryMiddleware,
|
|
23
23
|
tokensFromCompiledTokenData,
|
|
24
24
|
validateSnapshot
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-HGGAXLRO.js";
|
|
26
26
|
import {
|
|
27
27
|
BRAND
|
|
28
28
|
} from "./chunk-4SVS3AA3.js";
|
|
29
29
|
import {
|
|
30
30
|
generateRulesFiles
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-VV2PJ75X.js";
|
|
32
|
+
import "./chunk-YSRGQDEB.js";
|
|
33
33
|
|
|
34
34
|
// src/adapters/custom-json.ts
|
|
35
35
|
import { readFile } from "fs/promises";
|
package/dist/server.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
createMcpServer,
|
|
3
3
|
createSandboxServer,
|
|
4
4
|
startMcpServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HGGAXLRO.js";
|
|
6
6
|
import "./chunk-4SVS3AA3.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-YSRGQDEB.js";
|
|
8
8
|
export {
|
|
9
9
|
createMcpServer,
|
|
10
10
|
createSandboxServer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragments-sdk/mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"description": "Standalone MCP server for Fragments design system — zero-config component discovery with semantic search",
|
|
6
6
|
"mcpName": "io.github.ConanMcN/fragments-mcp",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
63
63
|
"@orama/orama": "^3.1.18",
|
|
64
64
|
"typescript": "^5.7.2",
|
|
65
|
-
"@fragments-sdk/core": "2.1.0",
|
|
66
65
|
"@fragments-sdk/context": "0.6.1",
|
|
67
|
-
"@fragments-sdk/
|
|
66
|
+
"@fragments-sdk/core": "2.1.0",
|
|
67
|
+
"@fragments-sdk/govern": "0.3.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/node": "^22.0.0",
|
package/dist/chunk-3IHXJEMM.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// src/snapshot-helpers.ts
|
|
2
|
-
function listComponents(snapshot) {
|
|
3
|
-
return Object.values(snapshot.components);
|
|
4
|
-
}
|
|
5
|
-
function componentNames(snapshot) {
|
|
6
|
-
return listComponents(snapshot).map((component) => component.name);
|
|
7
|
-
}
|
|
8
|
-
function listBlocks(snapshot) {
|
|
9
|
-
return Object.values(snapshot.blocks ?? {});
|
|
10
|
-
}
|
|
11
|
-
function findComponentByName(snapshot, name) {
|
|
12
|
-
const query = name.toLowerCase();
|
|
13
|
-
return listComponents(snapshot).find(
|
|
14
|
-
(component) => component.name.toLowerCase() === query
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
function getGuidanceWhen(component) {
|
|
18
|
-
if (component.guidance.when.length > 0) {
|
|
19
|
-
return component.guidance.when;
|
|
20
|
-
}
|
|
21
|
-
if (component.guidance.usageGuidance) {
|
|
22
|
-
return [component.guidance.usageGuidance];
|
|
23
|
-
}
|
|
24
|
-
if (component.guidance.dos.length > 0) {
|
|
25
|
-
return component.guidance.dos;
|
|
26
|
-
}
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
function getGuidanceWhenNot(component) {
|
|
30
|
-
if (component.guidance.whenNot.length > 0) {
|
|
31
|
-
return component.guidance.whenNot;
|
|
32
|
-
}
|
|
33
|
-
if (component.guidance.donts.length > 0) {
|
|
34
|
-
return component.guidance.donts;
|
|
35
|
-
}
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
listComponents,
|
|
41
|
-
componentNames,
|
|
42
|
-
listBlocks,
|
|
43
|
-
findComponentByName,
|
|
44
|
-
getGuidanceWhen,
|
|
45
|
-
getGuidanceWhenNot
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=chunk-3IHXJEMM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/snapshot-helpers.ts"],"sourcesContent":["import type { McpBlock, McpComponent, McpSnapshot } from '@fragments-sdk/core';\n\nexport function listComponents(snapshot: Pick<McpSnapshot, 'components'>): McpComponent[] {\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): McpComponent | undefined {\n const query = name.toLowerCase();\n return listComponents(snapshot).find(\n (component) => component.name.toLowerCase() === query,\n );\n}\n\nexport function getGuidanceWhen(component: McpComponent): 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: McpComponent): 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":";AAEO,SAAS,eAAe,UAA2D;AACxF,SAAO,OAAO,OAAO,SAAS,UAAU;AAC1C;AAEO,SAAS,eAAe,UAAqD;AAClF,SAAO,eAAe,QAAQ,EAAE,IAAI,CAAC,cAAc,UAAU,IAAI;AACnE;AAEO,SAAS,WAAW,UAAmD;AAC5E,SAAO,OAAO,OAAO,SAAS,UAAU,CAAC,CAAC;AAC5C;AAEO,SAAS,oBACd,UACA,MAC0B;AAC1B,QAAM,QAAQ,KAAK,YAAY;AAC/B,SAAO,eAAe,QAAQ,EAAE;AAAA,IAC9B,CAAC,cAAc,UAAU,KAAK,YAAY,MAAM;AAAA,EAClD;AACF;AAEO,SAAS,gBAAgB,WAAmC;AACjE,MAAI,UAAU,SAAS,KAAK,SAAS,GAAG;AACtC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,MAAI,UAAU,SAAS,eAAe;AACpC,WAAO,CAAC,UAAU,SAAS,aAAa;AAAA,EAC1C;AACA,MAAI,UAAU,SAAS,IAAI,SAAS,GAAG;AACrC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,SAAO,CAAC;AACV;AAEO,SAAS,mBAAmB,WAAmC;AACpE,MAAI,UAAU,SAAS,QAAQ,SAAS,GAAG;AACzC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,MAAI,UAAU,SAAS,MAAM,SAAS,GAAG;AACvC,WAAO,UAAU,SAAS;AAAA,EAC5B;AACA,SAAO,CAAC;AACV;","names":[]}
|