purity-mcp 0.0.0-stage → 2.0.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 +252 -2
- package/dist/data/component-catalog.d.ts +3 -0
- package/dist/data/component-catalog.d.ts.map +1 -0
- package/dist/data/component-catalog.js +330 -0
- package/dist/data/component-catalog.js.map +1 -0
- package/dist/data/documentation.d.ts +10 -0
- package/dist/data/documentation.d.ts.map +1 -0
- package/dist/data/documentation.js +617 -0
- package/dist/data/documentation.js.map +1 -0
- package/dist/data/templates.d.ts +11 -0
- package/dist/data/templates.d.ts.map +1 -0
- package/dist/data/templates.js +633 -0
- package/dist/data/templates.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +153 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +3 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +177 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +108 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/components.tool.d.ts +34 -0
- package/dist/tools/components.tool.d.ts.map +1 -0
- package/dist/tools/components.tool.js +41 -0
- package/dist/tools/components.tool.js.map +1 -0
- package/dist/tools/docs.tool.d.ts +44 -0
- package/dist/tools/docs.tool.d.ts.map +1 -0
- package/dist/tools/docs.tool.js +60 -0
- package/dist/tools/docs.tool.js.map +1 -0
- package/dist/tools/inspect.tool.d.ts +9 -0
- package/dist/tools/inspect.tool.d.ts.map +1 -0
- package/dist/tools/inspect.tool.js +204 -0
- package/dist/tools/inspect.tool.js.map +1 -0
- package/dist/tools/scaffold.tool.d.ts +28 -0
- package/dist/tools/scaffold.tool.d.ts.map +1 -0
- package/dist/tools/scaffold.tool.js +56 -0
- package/dist/tools/scaffold.tool.js.map +1 -0
- package/dist/tools/transform.tool.d.ts +9 -0
- package/dist/tools/transform.tool.d.ts.map +1 -0
- package/dist/tools/transform.tool.js +9 -0
- package/dist/tools/transform.tool.js.map +1 -0
- package/dist/tools/validate.tool.d.ts +13 -0
- package/dist/tools/validate.tool.d.ts.map +1 -0
- package/dist/tools/validate.tool.js +53 -0
- package/dist/tools/validate.tool.js.map +1 -0
- package/dist/types.d.ts +105 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/code-analyzer.d.ts +3 -0
- package/dist/utils/code-analyzer.d.ts.map +1 -0
- package/dist/utils/code-analyzer.js +282 -0
- package/dist/utils/code-analyzer.js.map +1 -0
- package/dist/utils/template-converter.d.ts +12 -0
- package/dist/utils/template-converter.d.ts.map +1 -0
- package/dist/utils/template-converter.js +158 -0
- package/dist/utils/template-converter.js.map +1 -0
- package/package.json +45 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Purity Model Context Protocol (MCP) Server
|
|
4
|
+
* Entry point for CLI and standard stdio communication.
|
|
5
|
+
*/
|
|
6
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
|
+
import { createPurityMcpServer } from './server.js';
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
10
|
+
process.stderr.write(`
|
|
11
|
+
Purity MCP Server - Supercharge AI-Assisted Purity Development
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
npx purity-mcp [options]
|
|
15
|
+
node AI/dist/index.js [options]
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
-h, --help Show this help message
|
|
19
|
+
-v, --version Show server version
|
|
20
|
+
|
|
21
|
+
Features:
|
|
22
|
+
• purity_scaffold: Generate components, services, pipes, directives, validators, interceptors, behaviors, pages
|
|
23
|
+
• purity_validate: Deep static analysis of code against Purity & Adwaita rules
|
|
24
|
+
• purity_inspect_project: Scan workspace health and discovered artifacts
|
|
25
|
+
• purity_get_docs: Authoritative framework documentation and runnable examples
|
|
26
|
+
• purity_lookup_component: API signatures and HTML examples for shared UI widgets
|
|
27
|
+
• purity_list_components: Catalog of all reusable UI components
|
|
28
|
+
• purity_transform_template: Convert Angular/Vue/HTML templates into Purity syntax
|
|
29
|
+
• Resources: purity://docs/*, purity://catalog/*, purity://templates/*
|
|
30
|
+
• Prompts: purity-create-component, purity-review-code, purity-migrate-component, purity-debug-reactivity
|
|
31
|
+
|
|
32
|
+
Transport:
|
|
33
|
+
Runs via standard I/O (stdio) JSON-RPC protocol.
|
|
34
|
+
\n`);
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
38
|
+
process.stderr.write(`purity-mcp v1.0.0\n`);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
async function main() {
|
|
42
|
+
const server = createPurityMcpServer();
|
|
43
|
+
const transport = new StdioServerTransport();
|
|
44
|
+
process.stderr.write(`[purity-mcp] Starting Purity MCP Server on stdio transport...\n`);
|
|
45
|
+
process.on('SIGINT', async () => {
|
|
46
|
+
process.stderr.write(`[purity-mcp] Shutting down...\n`);
|
|
47
|
+
await server.close();
|
|
48
|
+
process.exit(0);
|
|
49
|
+
});
|
|
50
|
+
process.on('SIGTERM', async () => {
|
|
51
|
+
process.stderr.write(`[purity-mcp] Terminating...\n`);
|
|
52
|
+
await server.close();
|
|
53
|
+
process.exit(0);
|
|
54
|
+
});
|
|
55
|
+
await server.connect(transport);
|
|
56
|
+
process.stderr.write(`[purity-mcp] Purity MCP Server is running and listening on stdio.\n`);
|
|
57
|
+
}
|
|
58
|
+
main().catch((error) => {
|
|
59
|
+
process.stderr.write(`[purity-mcp] Fatal error: ${error instanceof Error ? error.stack : error}\n`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;GAwBpB,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,qBAAqB,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;IAExF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACxD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACtD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAC;AAC9F,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IACpG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiLvD"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function registerPrompts(server) {
|
|
3
|
+
// Prompt 1: Create Component
|
|
4
|
+
server.prompt('purity-create-component', 'Design and generate an idiomatic Purity Custom Element with signals, template, SCSS, and Vitest test', {
|
|
5
|
+
name: z.string().describe('Name of the component in kebab-case (e.g. "shopping-cart")'),
|
|
6
|
+
description: z.string().describe('What the component should do and its interactive features'),
|
|
7
|
+
hasInputs: z.string().optional().describe('Comma-separated list of inputs/attributes if any'),
|
|
8
|
+
}, async ({ name, description, hasInputs }) => {
|
|
9
|
+
const promptText = `You are designing a high-performance Custom Element for the Purity framework.
|
|
10
|
+
|
|
11
|
+
### Requirements:
|
|
12
|
+
1. Component Name: "${name}"
|
|
13
|
+
2. Description: "${description}"
|
|
14
|
+
${hasInputs ? `3. Inputs/Attributes: ${hasInputs}` : ''}
|
|
15
|
+
|
|
16
|
+
### Mandatory Purity Architectural Rules:
|
|
17
|
+
- Decorated with \`@Component({ selector: '${name}', templateUrl: './${name}.component.html' })\`.
|
|
18
|
+
- Reactive state managed solely via synchronous \`signal()\`, \`computed()\`, and \`effect()\` from \`@purity/core\`.
|
|
19
|
+
- All methods mutate state with \`.set()\` or \`.update()\`.
|
|
20
|
+
- External template inlined synchronously at build time with Vite (\`?raw\`).
|
|
21
|
+
- If iterating arrays, use structural repeater \`for="let item of items"\` or \`virtual-for\` if high volume.
|
|
22
|
+
- If using conditionals, use \`if="expr"\`, \`else-if="expr"\`, \`else\`.
|
|
23
|
+
- All styling must be in \`${name}.component.scss\` and begin with \`@use '@styles' as *;\`.
|
|
24
|
+
- Use Adwaita glassmorphism tokens (\`var(--gnome-surface)\`, \`var(--gnome-card)\`, \`var(--radius-card)\`, etc.).
|
|
25
|
+
- Use KDE Plasma Breeze cursor tokens (\`var(--cursor-pointer)\`, \`var(--cursor-default)\`, etc.).
|
|
26
|
+
- NEVER use inline \`style="..."\` attributes.
|
|
27
|
+
- Provide a colocated Vitest unit test in \`${name}.component.spec.ts\`.
|
|
28
|
+
|
|
29
|
+
Please generate the complete, production-ready code files for:
|
|
30
|
+
1. \`${name}.component.ts\`
|
|
31
|
+
2. \`${name}.component.html\`
|
|
32
|
+
3. \`${name}.component.scss\`
|
|
33
|
+
4. \`${name}.component.spec.ts\``;
|
|
34
|
+
return {
|
|
35
|
+
messages: [
|
|
36
|
+
{
|
|
37
|
+
role: 'user',
|
|
38
|
+
content: {
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: promptText,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
// Prompt 2: Review Code
|
|
47
|
+
server.prompt('purity-review-code', 'Perform a comprehensive 10-point architectural audit of Purity code', {
|
|
48
|
+
code: z.string().describe('The TypeScript, HTML, or SCSS code to audit'),
|
|
49
|
+
fileName: z.string().optional().describe('File name with extension (e.g. "user.component.ts")'),
|
|
50
|
+
}, async ({ code, fileName }) => {
|
|
51
|
+
const promptText = `Perform a strict architectural and quality audit on the following Purity code ${fileName ? `(\`${fileName}\`)` : ''}:
|
|
52
|
+
|
|
53
|
+
\`\`\`
|
|
54
|
+
${code}
|
|
55
|
+
\`\`\`
|
|
56
|
+
|
|
57
|
+
Audit against the 10 Non-Negotiable Purity Framework Rules:
|
|
58
|
+
1. **Reactivity**: Are signals mutated via \`.set()\` or \`.update()\`? (NEVER \`signal = val\` or \`signal.value = val\`).
|
|
59
|
+
2. **Read Syntax**: Are signals invoked as functions in expressions (\`mySignal()\`)?
|
|
60
|
+
3. **No External State**: Zero imports from RxJS, Redux, Zustand, MobX.
|
|
61
|
+
4. **Custom Element Lifecycle**: Does it use \`protected onInit(): void\` and \`onDestroy()\`? (NEVER \`ngOnInit\` or \`componentDidMount\`).
|
|
62
|
+
5. **Path Aliases**: Are imports using \`@purity/*\`, \`@components/*\`, \`@styles\`? (NO \`../\` relative parent traversals).
|
|
63
|
+
6. **No Inline Styles**: Does the template contain any \`style="..."\` attributes? (Strictly forbidden).
|
|
64
|
+
7. **SCSS Architecture**: Does SCSS begin with \`@use '@styles' as *;\`?
|
|
65
|
+
8. **Design System Leakage**: Does the code contain the internal string "GNOME 50"? (Must use "Adwaita" publicly).
|
|
66
|
+
9. **Breeze Cursors & Tokens**: Are KDE Breeze cursor tokens and Adwaita corner radii used?
|
|
67
|
+
10. **Template Directives**: Are repeaters \`for="let item of items"\` and conditionals \`if="expr"\` instead of Angular/Vue directives?
|
|
68
|
+
|
|
69
|
+
Provide a structured report listing:
|
|
70
|
+
- Status (PASS / FAIL)
|
|
71
|
+
- Numerical Score (0 - 100)
|
|
72
|
+
- Violations with line numbers and exact code replacements.`;
|
|
73
|
+
return {
|
|
74
|
+
messages: [
|
|
75
|
+
{
|
|
76
|
+
role: 'user',
|
|
77
|
+
content: {
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: promptText,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
// Prompt 3: Migrate Component
|
|
86
|
+
server.prompt('purity-migrate-component', 'Migrate a component from React, Angular, or Vue into an idiomatic Purity Custom Element', {
|
|
87
|
+
sourceFramework: z.enum(['react', 'angular', 'vue']).describe('Source framework'),
|
|
88
|
+
sourceCode: z.string().describe('Source component code to convert'),
|
|
89
|
+
componentName: z.string().describe('Target Purity component name in kebab-case'),
|
|
90
|
+
}, async ({ sourceFramework, sourceCode, componentName }) => {
|
|
91
|
+
const promptText = `Convert the following ${sourceFramework.toUpperCase()} component into an idiomatic Purity Web Component named \`<${componentName}>\`.
|
|
92
|
+
|
|
93
|
+
### Source Code (${sourceFramework}):
|
|
94
|
+
\`\`\`
|
|
95
|
+
${sourceCode}
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
### Conversion Directives:
|
|
99
|
+
- Convert state hooks / ref / properties to Purity \`signal()\`, \`computed()\`, or \`effect()\`.
|
|
100
|
+
- Separate code into:
|
|
101
|
+
1. \`${componentName}.component.ts\` (\`@Component({ selector: '${componentName}', templateUrl: './${componentName}.component.html' })\`)
|
|
102
|
+
2. \`${componentName}.component.html\` (Purity Handlebars bindings, \`for="let item of items"\`, \`if="expr"\`, slots)
|
|
103
|
+
3. \`${componentName}.component.scss\` (\`@use '@styles' as *;\`, Adwaita glassmorphic styles)
|
|
104
|
+
4. \`${componentName}.component.spec.ts\` (Vitest test verifying mounted Custom Element)
|
|
105
|
+
- Ensure zero external dependencies.`;
|
|
106
|
+
return {
|
|
107
|
+
messages: [
|
|
108
|
+
{
|
|
109
|
+
role: 'user',
|
|
110
|
+
content: {
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: promptText,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
// Prompt 4: Debug Reactivity
|
|
119
|
+
server.prompt('purity-debug-reactivity', 'Diagnose and fix reactivity issues in Purity signals, effects, or repeater bindings', {
|
|
120
|
+
code: z.string().describe('Code containing reactive signals, effects, or templates'),
|
|
121
|
+
issueDescription: z.string().describe('Observed reactivity issue (e.g. effect not triggering, infinite loop, missing update)'),
|
|
122
|
+
}, async ({ code, issueDescription }) => {
|
|
123
|
+
const promptText = `Investigate this reactivity issue in Purity framework code:
|
|
124
|
+
|
|
125
|
+
### Observed Problem:
|
|
126
|
+
${issueDescription}
|
|
127
|
+
|
|
128
|
+
### Code:
|
|
129
|
+
\`\`\`typescript
|
|
130
|
+
${code}
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
### Reactivity Principles in Purity:
|
|
134
|
+
- \`signal()\` reads register dependency in the currently executing \`effect()\` context synchronously.
|
|
135
|
+
- When an effect modifies a signal that it also reads without \`untrack()\`, an infinite loop or duplicate synchronous flush can occur.
|
|
136
|
+
- Child component attributes bound to signals in repeaters must use \`untrack()\` inside side-effects to prevent circular parent cascades.
|
|
137
|
+
- Calling \`.set()\` or \`.update()\` with the same value uses \`Object.is()\` and will intentionally NOT trigger subscribers.
|
|
138
|
+
|
|
139
|
+
Explain the root cause and provide the corrected code snippet.`;
|
|
140
|
+
return {
|
|
141
|
+
messages: [
|
|
142
|
+
{
|
|
143
|
+
role: 'user',
|
|
144
|
+
content: {
|
|
145
|
+
type: 'text',
|
|
146
|
+
text: promptText,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
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aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,6BAA6B;IAC7B,MAAM,CAAC,MAAM,CACX,yBAAyB,EACzB,qFAAqF,EACrF;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yDAAyD,CAAC;QACpF,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uFAAuF,CAAC;KAC/H,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE;QACnC,MAAM,UAAU,GAAG;;;EAGvB,gBAAgB;;;;EAIhB,IAAI;;;;;;;;;+DASyD,CAAC;QAE1D,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,UAAU;qBACjB;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAMtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0MzD"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { DOCUMENTATION } from '../data/documentation.js';
|
|
3
|
+
import { COMPONENT_CATALOG } from '../data/component-catalog.js';
|
|
4
|
+
import { generateScaffoldFiles } from '../data/templates.js';
|
|
5
|
+
export function registerResources(server) {
|
|
6
|
+
// Resource 1: Developer Cheatsheet
|
|
7
|
+
server.resource('purity-cheatsheet', 'purity://docs/cheatsheet', async (uri) => {
|
|
8
|
+
const text = `# Purity Framework - Developer Cheatsheet
|
|
9
|
+
|
|
10
|
+
## 1. Synchronous Signals
|
|
11
|
+
\`\`\`typescript
|
|
12
|
+
import { signal, computed, effect, untrack } from '@purity/core';
|
|
13
|
+
|
|
14
|
+
const count = signal(0);
|
|
15
|
+
const doubled = computed(() => count() * 2);
|
|
16
|
+
|
|
17
|
+
// Read
|
|
18
|
+
console.log(count(), doubled());
|
|
19
|
+
|
|
20
|
+
// Mutate
|
|
21
|
+
count.set(5);
|
|
22
|
+
count.update(n => n + 1);
|
|
23
|
+
|
|
24
|
+
// Effect
|
|
25
|
+
effect(() => console.log('Count:', count()));
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
## 2. Component Structure
|
|
29
|
+
\`\`\`typescript
|
|
30
|
+
import { Component, signal, ViewChild } from '@purity/core';
|
|
31
|
+
|
|
32
|
+
@Component({
|
|
33
|
+
selector: 'my-widget',
|
|
34
|
+
templateUrl: './my-widget.component.html'
|
|
35
|
+
})
|
|
36
|
+
export class MyWidgetComponent {
|
|
37
|
+
title = signal('Widget');
|
|
38
|
+
|
|
39
|
+
protected onInit(): void {}
|
|
40
|
+
protected onDestroy(): void {}
|
|
41
|
+
}
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
## 3. Template Syntax
|
|
45
|
+
\`\`\`html
|
|
46
|
+
<!-- Interpolation -->
|
|
47
|
+
<h1>{{ title() }}</h1>
|
|
48
|
+
|
|
49
|
+
<!-- Structural Conditionals -->
|
|
50
|
+
<div if="isActive()">Active</div>
|
|
51
|
+
<div else-if="isPending()">Pending</div>
|
|
52
|
+
<div else>Inactive</div>
|
|
53
|
+
|
|
54
|
+
<!-- Structural Repeater -->
|
|
55
|
+
<div for="let item, index of items">
|
|
56
|
+
#{{ index + 1 }} {{ item.name }}
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<!-- Virtual Scroll (Massive Datasets) -->
|
|
60
|
+
<div virtual-for="let row of rows; itemHeight: 48; buffer: 8; height: 400px; scrollIndex: jumpSignal">
|
|
61
|
+
{{ row.text }}
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<!-- Slots -->
|
|
65
|
+
<slot name="header"></slot>
|
|
66
|
+
<slot>Default body</slot>
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
## 4. Styling (Adwaita Glassmorphism)
|
|
70
|
+
\`\`\`scss
|
|
71
|
+
@use '@styles' as *;
|
|
72
|
+
|
|
73
|
+
.my-card {
|
|
74
|
+
background: var(--gnome-card);
|
|
75
|
+
backdrop-filter: var(--blur-effect);
|
|
76
|
+
border: 1px solid var(--gnome-border);
|
|
77
|
+
border-radius: var(--radius-card); // 12px
|
|
78
|
+
cursor: var(--cursor-default);
|
|
79
|
+
}
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
## 5. Dependency Injection & HTTP
|
|
83
|
+
\`\`\`typescript
|
|
84
|
+
import { Injectable, inject, HttpClient } from '@purity/core';
|
|
85
|
+
|
|
86
|
+
@Injectable('DataService')
|
|
87
|
+
export class DataService {
|
|
88
|
+
private http = inject(HttpClient);
|
|
89
|
+
getData() { return this.http.get('/api/items'); }
|
|
90
|
+
}
|
|
91
|
+
\`\`\`
|
|
92
|
+
`;
|
|
93
|
+
return {
|
|
94
|
+
contents: [
|
|
95
|
+
{
|
|
96
|
+
uri: uri.href,
|
|
97
|
+
mimeType: 'text/markdown',
|
|
98
|
+
text,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
// Resource 2: Architecture Rules
|
|
104
|
+
server.resource('purity-architecture', 'purity://docs/architecture', async (uri) => {
|
|
105
|
+
const text = DOCUMENTATION.rules.content + '\n\n' + DOCUMENTATION.overview.content;
|
|
106
|
+
return {
|
|
107
|
+
contents: [
|
|
108
|
+
{
|
|
109
|
+
uri: uri.href,
|
|
110
|
+
mimeType: 'text/markdown',
|
|
111
|
+
text,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
// Resource 3: Design System & Cursors
|
|
117
|
+
server.resource('purity-design-system', 'purity://docs/design-system', async (uri) => {
|
|
118
|
+
const text = DOCUMENTATION['design-system'].content + '\n\n' + DOCUMENTATION.cursors.content + '\n\n' + DOCUMENTATION.styling.content;
|
|
119
|
+
return {
|
|
120
|
+
contents: [
|
|
121
|
+
{
|
|
122
|
+
uri: uri.href,
|
|
123
|
+
mimeType: 'text/markdown',
|
|
124
|
+
text,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
// Resource 4: Component Catalog
|
|
130
|
+
server.resource('purity-component-catalog', 'purity://catalog/components', async (uri) => {
|
|
131
|
+
const rows = COMPONENT_CATALOG.map(c => `| \`<${c.selector}>\` | **${c.name}** | \`${c.category}\` | ${c.description} |`);
|
|
132
|
+
const text = `# Purity Framework - Reusable Component Catalog
|
|
133
|
+
|
|
134
|
+
| Tag Selector | Component Class | Category | Description |
|
|
135
|
+
| :--- | :--- | :--- | :--- |
|
|
136
|
+
${rows.join('\n')}
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
Use tool \`purity_lookup_component\` for input signatures, signal types, methods, and full HTML usage examples.
|
|
140
|
+
`;
|
|
141
|
+
return {
|
|
142
|
+
contents: [
|
|
143
|
+
{
|
|
144
|
+
uri: uri.href,
|
|
145
|
+
mimeType: 'text/markdown',
|
|
146
|
+
text,
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
// Resource 5: Dynamic Template Generator (purity://templates/{type})
|
|
152
|
+
server.resource('purity-template', new ResourceTemplate('purity://templates/{type}', { list: undefined }), async (uri, { type }) => {
|
|
153
|
+
const validTypes = [
|
|
154
|
+
'component',
|
|
155
|
+
'service',
|
|
156
|
+
'pipe',
|
|
157
|
+
'directive',
|
|
158
|
+
'validator',
|
|
159
|
+
'interceptor',
|
|
160
|
+
'behavior',
|
|
161
|
+
'page',
|
|
162
|
+
];
|
|
163
|
+
const resolvedType = (validTypes.includes(type) ? type : 'component');
|
|
164
|
+
const { files } = generateScaffoldFiles(resolvedType, `sample-${resolvedType}`);
|
|
165
|
+
const fileSections = files.map(f => `### File: \`${f.filename}\`\n*${f.description}*\n\`\`\`${f.filename.endsWith('.scss') ? 'scss' : f.filename.endsWith('.html') ? 'html' : 'typescript'}\n${f.content}\`\`\``).join('\n\n');
|
|
166
|
+
return {
|
|
167
|
+
contents: [
|
|
168
|
+
{
|
|
169
|
+
uri: uri.href,
|
|
170
|
+
mimeType: 'text/markdown',
|
|
171
|
+
text: `# Starter Template: ${resolvedType}\n\n${fileSections}`,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,mCAAmC;IACnC,MAAM,CAAC,QAAQ,CACb,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,EAAE,GAAG,EAAE,EAAE;QACZ,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFlB,CAAC;QACI,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,QAAQ,EAAE,eAAe;oBACzB,IAAI;iBACL;aACF;SACF,CAAC;IACJ,CAAC,CACF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AC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAepE,wBAAgB,qBAAqB,IAAI,SAAS,CA6IjD"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { scaffoldSchema, handleScaffold } from './tools/scaffold.tool.js';
|
|
3
|
+
import { validateSchema, handleValidate } from './tools/validate.tool.js';
|
|
4
|
+
import { inspectSchema, handleInspect } from './tools/inspect.tool.js';
|
|
5
|
+
import { docsSchema, handleDocs } from './tools/docs.tool.js';
|
|
6
|
+
import { lookupComponentSchema, handleLookupComponent, listComponentsSchema, handleListComponents, } from './tools/components.tool.js';
|
|
7
|
+
import { transformTemplateSchema, handleTransformTemplate } from './tools/transform.tool.js';
|
|
8
|
+
import { registerResources } from './resources/index.js';
|
|
9
|
+
import { registerPrompts } from './prompts/index.js';
|
|
10
|
+
export function createPurityMcpServer() {
|
|
11
|
+
const server = new McpServer({
|
|
12
|
+
name: 'purity-mcp',
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
});
|
|
15
|
+
// Tool 1: purity_scaffold
|
|
16
|
+
server.tool('purity_scaffold', 'Scaffolds production-ready Purity framework artifacts (components, services, pipes, directives, validators, interceptors, behaviors, pages) with 100% adherence to Adwaita design system and Vitest unit tests', scaffoldSchema, async (params) => {
|
|
17
|
+
const result = await handleScaffold(params);
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: 'text',
|
|
22
|
+
text: JSON.stringify(result, null, 2),
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
// Tool 2: purity_validate
|
|
28
|
+
server.tool('purity_validate', 'Audits Purity framework code (TypeScript, HTML, SCSS) against official architectural rules, signal mutation hygiene, path aliases, Adwaita tokens, and foreign framework anti-patterns', validateSchema, async (params) => {
|
|
29
|
+
const result = await handleValidate(params);
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: 'text',
|
|
34
|
+
text: result.formattedReport,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'text',
|
|
38
|
+
text: JSON.stringify(result, null, 2),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
// Tool 3: purity_inspect_project
|
|
44
|
+
server.tool('purity_inspect_project', 'Scans a Purity repository to discover registered components, services, pipes, directives, validators, and evaluates project health, test coverage, and SCSS architecture', inspectSchema, async (params) => {
|
|
45
|
+
const result = await handleInspect(params);
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: JSON.stringify(result, null, 2),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
// Tool 4: purity_get_docs
|
|
56
|
+
server.tool('purity_get_docs', 'Retrieves authoritative documentation, API contracts, rules, and runnable code examples for Purity framework features (signals, components, repeaters, virtual-for, DI, HTTP, Adwaita styling, cursors)', docsSchema, async (params) => {
|
|
57
|
+
const result = await handleDocs(params);
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'text',
|
|
62
|
+
text: result.content || result.summary,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
// Tool 5: purity_lookup_component
|
|
68
|
+
server.tool('purity_lookup_component', 'Looks up reusable UI Web Components and widgets in Purity (switch-button, modal-view, expander, popover, date-time-picker, loader, navigation-menu, profile-avatar, radial-context-menu, analogue-clock) with signatures, methods, signals, and copy-paste examples', lookupComponentSchema, async (params) => {
|
|
69
|
+
const result = await handleLookupComponent(params);
|
|
70
|
+
return {
|
|
71
|
+
content: [
|
|
72
|
+
{
|
|
73
|
+
type: 'text',
|
|
74
|
+
text: JSON.stringify(result, null, 2),
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
// Tool 6: purity_list_components
|
|
80
|
+
server.tool('purity_list_components', 'Lists all available reusable UI Web Components and widgets in the Purity design system categorized by type (core, overlay, form, navigation, widget, layout)', listComponentsSchema, async (params) => {
|
|
81
|
+
const result = await handleListComponents(params);
|
|
82
|
+
return {
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: 'text',
|
|
86
|
+
text: JSON.stringify(result, null, 2),
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
// Tool 7: purity_transform_template
|
|
92
|
+
server.tool('purity_transform_template', 'Converts templates with foreign syntax (Angular *ngFor/*ngIf/(click)/[(ngModel)], Vue v-for/v-if/@click/v-model, inline styles) into idiomatic Purity template syntax with signals and structural repeaters', transformTemplateSchema, async (params) => {
|
|
93
|
+
const result = await handleTransformTemplate(params);
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: JSON.stringify(result, null, 2),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
// Register Resources & Prompts
|
|
104
|
+
registerResources(server);
|
|
105
|
+
registerPrompts(server);
|
|
106
|
+
return server;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA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,iCAAiC;IACjC,MAAM,CAAC,IAAI,CACT,wBAAwB,EACxB,8JAA8J,EAC9J,oBAAoB,EACpB,KAAK,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAClD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;iBACtC;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,oCAAoC;IACpC,MAAM,CAAC,IAAI,CACT,2BAA2B,EAC3B,6MAA6M,EAC7M,uBAAuB,EACvB,KAAK,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;iBACtC;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,+BAA+B;IAC/B,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,eAAe,CAAC,MAAM,CAAC,CAAC;IAExB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ComponentMetadata } from '../types.js';
|
|
3
|
+
export declare const lookupComponentSchema: {
|
|
4
|
+
query: z.ZodString;
|
|
5
|
+
};
|
|
6
|
+
export declare const listComponentsSchema: {
|
|
7
|
+
category: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
all: "all";
|
|
9
|
+
core: "core";
|
|
10
|
+
form: "form";
|
|
11
|
+
layout: "layout";
|
|
12
|
+
navigation: "navigation";
|
|
13
|
+
overlay: "overlay";
|
|
14
|
+
widget: "widget";
|
|
15
|
+
}>>>;
|
|
16
|
+
};
|
|
17
|
+
export declare function handleLookupComponent(params: {
|
|
18
|
+
query: string;
|
|
19
|
+
}): Promise<ComponentMetadata | {
|
|
20
|
+
message: string;
|
|
21
|
+
suggestions: string[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare function handleListComponents(params: {
|
|
24
|
+
category?: string;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
total: number;
|
|
27
|
+
components: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
selector: string;
|
|
30
|
+
category: string;
|
|
31
|
+
description: string;
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=components.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.tool.d.ts","sourceRoot":"","sources":["../../src/tools/components.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,qBAAqB;IAChC,KAAK;CACN,CAAC;AAEF,eAAO,MAAM,oBAAoB;IAC/B,QAAQ;;;;;;;;;CACT,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAyB9I;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ,CAAC,CAeD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { COMPONENT_CATALOG } from '../data/component-catalog.js';
|
|
3
|
+
export const lookupComponentSchema = {
|
|
4
|
+
query: z.string().describe('Component tag name (e.g. "switch-button", "modal-view"), class name, or keyword'),
|
|
5
|
+
};
|
|
6
|
+
export const listComponentsSchema = {
|
|
7
|
+
category: z.enum(['all', 'core', 'overlay', 'form', 'navigation', 'widget', 'layout']).optional().default('all').describe('Filter components by category'),
|
|
8
|
+
};
|
|
9
|
+
export async function handleLookupComponent(params) {
|
|
10
|
+
const q = params.query.toLowerCase().trim();
|
|
11
|
+
// Exact match on selector or name
|
|
12
|
+
const match = COMPONENT_CATALOG.find(c => c.selector.toLowerCase() === q || c.name.toLowerCase() === q || c.name.toLowerCase().replace('component', '') === q);
|
|
13
|
+
if (match) {
|
|
14
|
+
return match;
|
|
15
|
+
}
|
|
16
|
+
// Partial match
|
|
17
|
+
const partials = COMPONENT_CATALOG.filter(c => c.selector.toLowerCase().includes(q) || c.name.toLowerCase().includes(q) || c.description.toLowerCase().includes(q));
|
|
18
|
+
if (partials.length === 1) {
|
|
19
|
+
return partials[0];
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
message: `No exact component found for "${params.query}".`,
|
|
23
|
+
suggestions: COMPONENT_CATALOG.map(c => `<${c.selector}> (${c.name})`),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export async function handleListComponents(params) {
|
|
27
|
+
const cat = params.category || 'all';
|
|
28
|
+
const filtered = cat === 'all'
|
|
29
|
+
? COMPONENT_CATALOG
|
|
30
|
+
: COMPONENT_CATALOG.filter(c => c.category === cat);
|
|
31
|
+
return {
|
|
32
|
+
total: filtered.length,
|
|
33
|
+
components: filtered.map(c => ({
|
|
34
|
+
name: c.name,
|
|
35
|
+
selector: c.selector,
|
|
36
|
+
category: c.category,
|
|
37
|
+
description: c.description,
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=components.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.tool.js","sourceRoot":"","sources":["../../src/tools/components.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iFAAiF,CAAC;CAC9G,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CAC3J,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAyB;IACnE,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAE5C,kCAAkC;IAClC,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAClC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,KAAK,CAAC,CACzH,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB;IAChB,MAAM,QAAQ,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