@spartan-ng/mcp 0.0.1-alpha.707

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.
Files changed (44) hide show
  1. package/README.md +149 -0
  2. package/package.json +40 -0
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +2 -0
  5. package/src/index.js.map +1 -0
  6. package/src/server.d.ts +2 -0
  7. package/src/server.js +32 -0
  8. package/src/server.js.map +1 -0
  9. package/src/tools/analysis.d.ts +2 -0
  10. package/src/tools/analysis.js +269 -0
  11. package/src/tools/analysis.js.map +1 -0
  12. package/src/tools/blocks.d.ts +2 -0
  13. package/src/tools/blocks.js +173 -0
  14. package/src/tools/blocks.js.map +1 -0
  15. package/src/tools/cache-tools.d.ts +2 -0
  16. package/src/tools/cache-tools.js +175 -0
  17. package/src/tools/cache-tools.js.map +1 -0
  18. package/src/tools/cache-warmup.d.ts +40 -0
  19. package/src/tools/cache-warmup.js +156 -0
  20. package/src/tools/cache-warmup.js.map +1 -0
  21. package/src/tools/cache.d.ts +99 -0
  22. package/src/tools/cache.js +361 -0
  23. package/src/tools/cache.js.map +1 -0
  24. package/src/tools/components.d.ts +2 -0
  25. package/src/tools/components.js +126 -0
  26. package/src/tools/components.js.map +1 -0
  27. package/src/tools/docs.d.ts +2 -0
  28. package/src/tools/docs.js +91 -0
  29. package/src/tools/docs.js.map +1 -0
  30. package/src/tools/health.d.ts +2 -0
  31. package/src/tools/health.js +103 -0
  32. package/src/tools/health.js.map +1 -0
  33. package/src/tools/meta.d.ts +2 -0
  34. package/src/tools/meta.js +47 -0
  35. package/src/tools/meta.js.map +1 -0
  36. package/src/tools/prompts.d.ts +2 -0
  37. package/src/tools/prompts.js +299 -0
  38. package/src/tools/prompts.js.map +1 -0
  39. package/src/tools/resources.d.ts +2 -0
  40. package/src/tools/resources.js +178 -0
  41. package/src/tools/resources.js.map +1 -0
  42. package/src/tools/utils.d.ts +84 -0
  43. package/src/tools/utils.js +581 -0
  44. package/src/tools/utils.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # @spartan-ng/mcp
2
+
3
+ A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that exposes the [Spartan](https://www.spartan.ng) Angular UI ecosystem - documentation, components, and blocks - as tools, resources, and prompts for MCP clients such as Claude Desktop, Cursor, and other AI assistants.
4
+
5
+ The server fetches content live from the public Spartan UI site and caches it on disk per version, so assistants can answer questions about Spartan components with up-to-date API tables and code examples.
6
+
7
+ ## What it provides
8
+
9
+ - **Components** - list components and fetch a component's documentation, with structured Brain API (`Brn*`) / Helm API (`Hlm*`) extraction or raw code blocks.
10
+ - **Blocks** - list and fetch pre-built UI patterns (sidebar, login, signup, calendar) and analyze the components/packages they depend on.
11
+ - **Docs** - fetch official documentation topics (installation, cli, theming, dark-mode, typography, health-checks, update-guide) with optional code/heading/link extraction.
12
+ - **Analysis** - inspect a component's dependencies (npm packages, Angular CDK, peer components, imports) and its accessibility features (ARIA, keyboard, screen reader, WCAG).
13
+ - **Health** - check availability of the Spartan docs site and surface the Spartan CLI health-check commands.
14
+ - **Caching** - version-aware on-disk cache with status, clear, rebuild, switch-version, and list-versions tools.
15
+
16
+ ## Usage
17
+
18
+ ### With `npx` (no install)
19
+
20
+ Configure your MCP client:
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "spartan-ui": {
26
+ "command": "npx",
27
+ "args": ["-y", "@spartan-ng/mcp"]
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ ### Global install
34
+
35
+ ```bash
36
+ npm install -g @spartan-ng/mcp
37
+ ```
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "spartan-ui": {
43
+ "command": "spartan-mcp"
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### Local build
50
+
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "spartan-ui": {
55
+ "command": "node",
56
+ "args": ["/path/to/dist/libs/mcp/src/server.js"]
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ 1. Run `nx build mcp` to compile to `dist/libs/mcp`.
63
+ 2. Point `args` at the built `src/server.js`.
64
+ 3. Restart your MCP client.
65
+
66
+ ## MCP surface
67
+
68
+ ### Tools (17)
69
+
70
+ | Tool | Description |
71
+ | --------------------------------- | ------------------------------------------------------------------------ |
72
+ | `spartan_components_list` | List known components with documentation URLs |
73
+ | `spartan_components_get` | Fetch a component page; `extract: 'code' \| 'api'` |
74
+ | `spartan_components_dependencies` | Analyze a component's dependencies |
75
+ | `spartan_accessibility_check` | Analyze a component's accessibility features |
76
+ | `spartan_blocks_list` | List known blocks |
77
+ | `spartan_blocks_get` | Fetch a block page; `format: 'html' \| 'text'` |
78
+ | `spartan_blocks_dependencies` | Analyze a block's dependencies |
79
+ | `spartan_docs_get` | Fetch a docs topic; `extract: 'none' \| 'code' \| 'headings' \| 'links'` |
80
+ | `spartan_meta` | Topics, components, and blocks for client autocomplete |
81
+ | `spartan_health_check` | Check availability of docs/component pages |
82
+ | `spartan_health_instructions` | Spartan CLI health-check instructions |
83
+ | `spartan_health_command` | Build the exact health-check command (`ng`/`nx`) |
84
+ | `spartan_cache_status` | Current cache version and statistics |
85
+ | `spartan_cache_clear` | Clear the current (or all) cache version(s) |
86
+ | `spartan_cache_rebuild` | Rebuild the cache from the live site |
87
+ | `spartan_cache_switch_version` | Switch the active cache version |
88
+ | `spartan_cache_list_versions` | List cached versions |
89
+
90
+ ### Resources (4)
91
+
92
+ - `spartan://components/list`
93
+ - `spartan://component/{name}/api`
94
+ - `spartan://component/{name}/examples`
95
+ - `spartan://component/{name}/full`
96
+
97
+ ### Prompts (5)
98
+
99
+ - `spartan-get-started`
100
+ - `spartan-compare-apis`
101
+ - `spartan-implement-feature`
102
+ - `spartan-troubleshoot`
103
+ - `spartan-list-components`
104
+
105
+ ## Example tool calls
106
+
107
+ ```json
108
+ // List all known components
109
+ { "tool": "spartan_components_list" }
110
+
111
+ // Fetch the accordion's structured API data
112
+ { "tool": "spartan_components_get", "name": "accordion", "extract": "api" }
113
+
114
+ // Fetch a docs topic and extract its headings
115
+ { "tool": "spartan_docs_get", "topic": "cli", "extract": "headings" }
116
+
117
+ // Fetch a block as plain text
118
+ { "tool": "spartan_blocks_get", "name": "sidebar", "format": "text" }
119
+
120
+ // Analyze a component's dependencies
121
+ { "tool": "spartan_components_dependencies", "componentName": "dialog" }
122
+
123
+ // Check docs-site availability
124
+ { "tool": "spartan_health_check", "topics": ["installation", "cli"] }
125
+ ```
126
+
127
+ ## Configuration
128
+
129
+ Environment variables:
130
+
131
+ | Variable | Default | Description |
132
+ | ------------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------- |
133
+ | `SPARTAN_MCP_CACHE_DIR` | `$XDG_CACHE_HOME/spartan-mcp` or `~/.cache/spartan-mcp` | Directory for the on-disk version cache. Override to use a custom location. |
134
+ | `SPARTAN_CACHE_TTL_MS` | `300000` (5 min) | TTL for the in-memory fetch cache. |
135
+ | `SPARTAN_CACHE_TTL_HOURS` | `24` | TTL for on-disk cached entries before they are considered stale. |
136
+
137
+ ## Notes
138
+
139
+ - **Data source**: all content is fetched from public pages at [spartan.ng](https://www.spartan.ng); responses include source URLs.
140
+ - **Input validation**: all tool inputs are validated with Zod schemas.
141
+ - **Versions**: cached data is stored per Spartan UI version under `cache/{version}/`; pass `spartanVersion` to component/block/docs tools or use `spartan_cache_switch_version`.
142
+
143
+ ## Development
144
+
145
+ This library was generated with [Nx](https://nx.dev).
146
+
147
+ - Build: `nx build mcp`
148
+ - Test: `nx test mcp`
149
+ - Lint: `nx lint mcp`
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@spartan-ng/mcp",
3
+ "version": "0.0.1-alpha.707",
4
+ "description": "Model Context Protocol server exposing Spartan Angular UI documentation, components, and blocks as AI-consumable tools.",
5
+ "keywords": [
6
+ "mcp",
7
+ "model-context-protocol",
8
+ "spartan",
9
+ "angular",
10
+ "ui",
11
+ "spartan-ui",
12
+ "spartan-blocks",
13
+ "components",
14
+ "documentation"
15
+ ],
16
+ "homepage": "https://spartan.ng",
17
+ "bugs": {
18
+ "url": "https://github.com/spartan-ng/spartan/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/spartan-ng/spartan.git"
23
+ },
24
+ "license": "MIT",
25
+ "type": "module",
26
+ "main": "./src/index.js",
27
+ "types": "./src/index.d.ts",
28
+ "bin": {
29
+ "spartan-mcp": "./src/server.js"
30
+ },
31
+ "dependencies": {
32
+ "@modelcontextprotocol/sdk": "^1.29.0",
33
+ "tslib": "~2.8.1",
34
+ "zod": "^3.25.76"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "module": "./src/index.js"
40
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './tools/utils.js';
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './tools/utils.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/mcp/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/src/server.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { registerAnalysisTools } from './tools/analysis.js';
5
+ import { registerBlockTools } from './tools/blocks.js';
6
+ import { registerCacheTools } from './tools/cache-tools.js';
7
+ import { registerComponentTools } from './tools/components.js';
8
+ import { registerDocsTools } from './tools/docs.js';
9
+ import { registerHealthTools } from './tools/health.js';
10
+ import { registerMetaTools } from './tools/meta.js';
11
+ import { registerPromptHandlers } from './tools/prompts.js';
12
+ import { registerResourceHandlers } from './tools/resources.js';
13
+ const server = new McpServer({
14
+ name: 'spartan-ui',
15
+ version: '0.0.1',
16
+ description: 'MCP server exposing Spartan Angular UI documentation, component tools, and blocks.',
17
+ });
18
+ // Register tool modules
19
+ registerComponentTools(server);
20
+ registerDocsTools(server);
21
+ registerHealthTools(server);
22
+ registerMetaTools(server);
23
+ registerAnalysisTools(server);
24
+ registerCacheTools(server);
25
+ registerBlockTools(server);
26
+ // Register resource handlers
27
+ registerResourceHandlers(server);
28
+ // Register prompt handlers
29
+ registerPromptHandlers(server);
30
+ const transport = new StdioServerTransport();
31
+ await server.connect(transport);
32
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../libs/mcp/src/server.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC5B,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,oFAAoF;CACjG,CAAC,CAAC;AAEH,wBAAwB;AACxB,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC/B,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC1B,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC5B,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC1B,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC9B,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC3B,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAE3B,6BAA6B;AAC7B,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAEjC,2BAA2B;AAC3B,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAE/B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAnalysisTools(server: McpServer): void;
@@ -0,0 +1,269 @@
1
+ import { z } from 'zod';
2
+ import { KNOWN_COMPONENTS, SPARTAN_COMPONENTS_BASE, fetchContent, htmlToText } from './utils.js';
3
+ export function registerAnalysisTools(server) {
4
+ server.registerTool('spartan_components_dependencies', {
5
+ title: 'Show component dependencies',
6
+ description: 'Analyze what other components, packages, or dependencies a Spartan UI component requires. ' +
7
+ 'Includes Angular CDK dependencies, peer components, and installation requirements.',
8
+ inputSchema: {
9
+ componentName: z
10
+ .string()
11
+ .min(1, 'componentName is required')
12
+ .describe("Spartan component name (e.g., 'calendar', 'dialog')"),
13
+ includeTransitive: z
14
+ .boolean()
15
+ .default(false)
16
+ .describe('Include transitive dependencies (dependencies of dependencies)'),
17
+ },
18
+ }, async (args) => {
19
+ const componentName = String(args.componentName || '')
20
+ .trim()
21
+ .toLowerCase();
22
+ if (!KNOWN_COMPONENTS.includes(componentName)) {
23
+ throw new Error(`Unknown component: ${componentName}. Available: ${KNOWN_COMPONENTS.join(', ')}`);
24
+ }
25
+ const dependencies = await analyzeComponentDependencies(componentName, args.includeTransitive);
26
+ return {
27
+ content: [
28
+ {
29
+ type: 'text',
30
+ text: JSON.stringify({
31
+ component: componentName,
32
+ dependencies,
33
+ processingInstructions: 'Present dependencies with installation commands, import statements, and setup instructions. Group by type (npm packages, Angular CDK, peer components).',
34
+ }, null, 2),
35
+ },
36
+ ],
37
+ };
38
+ });
39
+ server.registerTool('spartan_accessibility_check', {
40
+ title: 'Check component accessibility features',
41
+ description: 'Analyze accessibility features, ARIA support, keyboard navigation, and screen reader compatibility ' +
42
+ 'for a Spartan UI component. Provides accessibility best practices and implementation guidance.',
43
+ inputSchema: {
44
+ componentName: z.string().min(1, 'componentName is required').describe('Spartan component name'),
45
+ checkType: z
46
+ .enum(['overview', 'aria', 'keyboard', 'screenreader', 'wcag', 'all'])
47
+ .default('all')
48
+ .describe("Type of accessibility check: specific area or 'all' for comprehensive analysis"),
49
+ },
50
+ }, async (args) => {
51
+ const componentName = String(args.componentName || '')
52
+ .trim()
53
+ .toLowerCase();
54
+ if (!KNOWN_COMPONENTS.includes(componentName)) {
55
+ throw new Error(`Unknown component: ${componentName}`);
56
+ }
57
+ const accessibility = await analyzeAccessibility(componentName, args.checkType);
58
+ return {
59
+ content: [
60
+ {
61
+ type: 'text',
62
+ text: JSON.stringify({
63
+ component: componentName,
64
+ checkType: args.checkType,
65
+ accessibility,
66
+ processingInstructions: 'Present accessibility information with actionable recommendations, code examples, and compliance notes for WCAG guidelines.',
67
+ }, null, 2),
68
+ },
69
+ ],
70
+ };
71
+ });
72
+ }
73
+ async function analyzeComponentDependencies(componentName, includeTransitive) {
74
+ try {
75
+ const url = `${SPARTAN_COMPONENTS_BASE}/${componentName}`;
76
+ const html = await fetchContent(url, 'html', false);
77
+ const text = htmlToText(html);
78
+ const dependencies = {
79
+ npm: [],
80
+ angularCdk: [],
81
+ peerComponents: [],
82
+ imports: [],
83
+ setup: [],
84
+ };
85
+ const npmRegex = /npm\s+install\s+([^\n]+)/gi;
86
+ let match;
87
+ while ((match = npmRegex.exec(text)) !== null) {
88
+ const packages = match[1]
89
+ .split(/\s+/)
90
+ .filter((pkg) => pkg.length > 0 && !pkg.startsWith('-'))
91
+ .map((pkg) => pkg.replace(/[,;]$/, ''));
92
+ dependencies.npm.push(...packages);
93
+ }
94
+ const cdkComponents = [
95
+ '@angular/cdk/a11y',
96
+ '@angular/cdk/dialog',
97
+ '@angular/cdk/overlay',
98
+ '@angular/cdk/portal',
99
+ '@angular/cdk/scrolling',
100
+ '@angular/cdk/table',
101
+ ];
102
+ for (const cdkComponent of cdkComponents) {
103
+ if (text.includes(cdkComponent)) {
104
+ dependencies.angularCdk.push(cdkComponent);
105
+ }
106
+ }
107
+ const importRegex = /import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/gi;
108
+ match = null;
109
+ while ((match = importRegex.exec(text)) !== null) {
110
+ dependencies.imports.push({
111
+ items: match[1].trim(),
112
+ from: match[2].trim(),
113
+ });
114
+ }
115
+ // Derive peer components from Spartan import paths only. Matching against the
116
+ // full page text would match the docs navigation sidebar, which lists every
117
+ // component on every page and would over-report dependencies.
118
+ const importedComponents = new Set(dependencies.imports
119
+ .map(({ from }) => /@spartan-ng\/(?:brain|helm)\/([\w-]+)/.exec(from)?.[1])
120
+ .filter((name) => Boolean(name)));
121
+ for (const otherComponent of KNOWN_COMPONENTS) {
122
+ if (otherComponent !== componentName && importedComponents.has(otherComponent)) {
123
+ dependencies.peerComponents.push(otherComponent);
124
+ }
125
+ }
126
+ dependencies.setup = generateSetupInstructions(componentName, dependencies);
127
+ if (includeTransitive) {
128
+ dependencies.transitive = await getTransitiveDependencies(dependencies.peerComponents);
129
+ }
130
+ return dependencies;
131
+ }
132
+ catch (error) {
133
+ console.error(`Error analyzing dependencies for ${componentName}:`, error);
134
+ return {
135
+ npm: [],
136
+ angularCdk: [],
137
+ peerComponents: [],
138
+ imports: [],
139
+ setup: [`Failed to analyze dependencies: ${error.message}`],
140
+ };
141
+ }
142
+ }
143
+ async function analyzeAccessibility(componentName, checkType) {
144
+ try {
145
+ const url = `${SPARTAN_COMPONENTS_BASE}/${componentName}`;
146
+ const html = await fetchContent(url, 'html', false);
147
+ const text = htmlToText(html);
148
+ const accessibility = {
149
+ overview: {},
150
+ aria: {},
151
+ keyboard: {},
152
+ screenreader: {},
153
+ wcag: {},
154
+ };
155
+ const recommendations = [];
156
+ if (checkType === 'all' || checkType === 'aria' || checkType === 'overview') {
157
+ accessibility.aria = analyzeAriaSupport(text);
158
+ }
159
+ if (checkType === 'all' || checkType === 'keyboard' || checkType === 'overview') {
160
+ accessibility.keyboard = analyzeKeyboardSupport(text);
161
+ }
162
+ if (checkType === 'all' || checkType === 'screenreader' || checkType === 'overview') {
163
+ accessibility.screenreader = analyzeScreenReaderSupport(text);
164
+ }
165
+ if (checkType === 'all' || checkType === 'wcag') {
166
+ accessibility.wcag = analyzeWcagCompliance(text);
167
+ }
168
+ recommendations.push(`Test ${componentName} with screen readers like NVDA or JAWS`);
169
+ recommendations.push('Verify keyboard navigation works without mouse');
170
+ recommendations.push('Check color contrast meets WCAG AA standards');
171
+ recommendations.push('Ensure focus indicators are visible and clear');
172
+ if (checkType === 'all' || checkType === 'overview') {
173
+ const hasAria = Object.keys(accessibility.aria).length > 0;
174
+ const hasKeyboard = Object.keys(accessibility.keyboard).length > 0;
175
+ const hasScreenReader = Object.keys(accessibility.screenreader).length > 0;
176
+ let score = 0;
177
+ if (hasAria)
178
+ score += 33;
179
+ if (hasKeyboard)
180
+ score += 33;
181
+ if (hasScreenReader)
182
+ score += 34;
183
+ accessibility.overview = {
184
+ score: `${score}%`,
185
+ 'ARIA Support': hasAria ? 'Yes' : 'Limited',
186
+ 'Keyboard Navigation': hasKeyboard ? 'Yes' : 'Limited',
187
+ 'Screen Reader': hasScreenReader ? 'Yes' : 'Limited',
188
+ };
189
+ }
190
+ return { ...accessibility, recommendations };
191
+ }
192
+ catch (error) {
193
+ console.error(`Error analyzing accessibility for ${componentName}:`, error);
194
+ return {
195
+ overview: {},
196
+ aria: {},
197
+ keyboard: {},
198
+ screenreader: {},
199
+ wcag: {},
200
+ recommendations: [`Failed to analyze accessibility: ${error.message}`],
201
+ };
202
+ }
203
+ }
204
+ function generateSetupInstructions(componentName, dependencies) {
205
+ const instructions = [];
206
+ if (dependencies.npm.length > 0) {
207
+ instructions.push(`Install dependencies: npm install ${dependencies.npm.join(' ')}`);
208
+ }
209
+ instructions.push(`Install Spartan UI component: npx ng g @spartan-ng/cli:ui ${componentName}`);
210
+ if (dependencies.imports.length > 0) {
211
+ instructions.push('Add imports to your component:');
212
+ dependencies.imports.forEach((imp) => {
213
+ instructions.push(` import { ${imp.items} } from '${imp.from}';`);
214
+ });
215
+ }
216
+ return instructions;
217
+ }
218
+ async function getTransitiveDependencies(peerComponents) {
219
+ const transitive = [];
220
+ for (const component of peerComponents.slice(0, 3)) {
221
+ try {
222
+ const deps = await analyzeComponentDependencies(component, false);
223
+ transitive.push({ component, dependencies: deps.peerComponents });
224
+ }
225
+ catch (error) {
226
+ console.warn(`Failed to get transitive dependencies for ${component}:`, error.message);
227
+ }
228
+ }
229
+ return transitive;
230
+ }
231
+ function analyzeAriaSupport(text) {
232
+ const features = {};
233
+ for (const attr of ['aria-label', 'aria-describedby', 'aria-expanded', 'aria-selected', 'role']) {
234
+ if (text.includes(attr))
235
+ features[attr] = `${attr} support detected`;
236
+ }
237
+ return features;
238
+ }
239
+ function analyzeKeyboardSupport(text) {
240
+ const features = {};
241
+ // Match whole words so the docs nav (which lists the "tabs" component on every
242
+ // page) doesn't falsely flag Tab-key support for unrelated components.
243
+ for (const term of ['keyboard', 'focus', 'tab', 'enter', 'space', 'arrow keys']) {
244
+ if (new RegExp(`\\b${term}\\b`, 'i').test(text))
245
+ features[term] = `${term} navigation supported`;
246
+ }
247
+ return features;
248
+ }
249
+ function analyzeScreenReaderSupport(text) {
250
+ const features = {};
251
+ const lower = text.toLowerCase();
252
+ if (lower.includes('screen reader'))
253
+ features.general = 'Screen reader support mentioned';
254
+ if (lower.includes('announcements'))
255
+ features.announcements = 'Screen reader announcements supported';
256
+ return features;
257
+ }
258
+ function analyzeWcagCompliance(text) {
259
+ const features = {};
260
+ const lower = text.toLowerCase();
261
+ if (lower.includes('wcag'))
262
+ features.compliance = 'WCAG compliance mentioned';
263
+ for (const criteria of ['contrast', 'focus visible', 'keyboard accessible']) {
264
+ if (lower.includes(criteria))
265
+ features[criteria] = `${criteria} support detected`;
266
+ }
267
+ return features;
268
+ }
269
+ //# sourceMappingURL=analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../../../../libs/mcp/src/tools/analysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjG,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CAClB,iCAAiC,EACjC;QACC,KAAK,EAAE,6BAA6B;QACpC,WAAW,EACV,4FAA4F;YAC5F,oFAAoF;QACrF,WAAW,EAAE;YACZ,aAAa,EAAE,CAAC;iBACd,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;iBACnC,QAAQ,CAAC,qDAAqD,CAAC;YACjE,iBAAiB,EAAE,CAAC;iBAClB,OAAO,EAAE;iBACT,OAAO,CAAC,KAAK,CAAC;iBACd,QAAQ,CAAC,gEAAgE,CAAC;SAC5E;KACD,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACd,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC;aACpD,IAAI,EAAE;aACN,WAAW,EAAE,CAAC;QAChB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,sBAAsB,aAAa,gBAAgB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAA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