@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.
- package/README.md +149 -0
- package/package.json +40 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -0
- package/src/server.d.ts +2 -0
- package/src/server.js +32 -0
- package/src/server.js.map +1 -0
- package/src/tools/analysis.d.ts +2 -0
- package/src/tools/analysis.js +269 -0
- package/src/tools/analysis.js.map +1 -0
- package/src/tools/blocks.d.ts +2 -0
- package/src/tools/blocks.js +173 -0
- package/src/tools/blocks.js.map +1 -0
- package/src/tools/cache-tools.d.ts +2 -0
- package/src/tools/cache-tools.js +175 -0
- package/src/tools/cache-tools.js.map +1 -0
- package/src/tools/cache-warmup.d.ts +40 -0
- package/src/tools/cache-warmup.js +156 -0
- package/src/tools/cache-warmup.js.map +1 -0
- package/src/tools/cache.d.ts +99 -0
- package/src/tools/cache.js +361 -0
- package/src/tools/cache.js.map +1 -0
- package/src/tools/components.d.ts +2 -0
- package/src/tools/components.js +126 -0
- package/src/tools/components.js.map +1 -0
- package/src/tools/docs.d.ts +2 -0
- package/src/tools/docs.js +91 -0
- package/src/tools/docs.js.map +1 -0
- package/src/tools/health.d.ts +2 -0
- package/src/tools/health.js +103 -0
- package/src/tools/health.js.map +1 -0
- package/src/tools/meta.d.ts +2 -0
- package/src/tools/meta.js +47 -0
- package/src/tools/meta.js.map +1 -0
- package/src/tools/prompts.d.ts +2 -0
- package/src/tools/prompts.js +299 -0
- package/src/tools/prompts.js.map +1 -0
- package/src/tools/resources.d.ts +2 -0
- package/src/tools/resources.js +178 -0
- package/src/tools/resources.js.map +1 -0
- package/src/tools/utils.d.ts +84 -0
- package/src/tools/utils.js +581 -0
- package/src/tools/utils.js.map +1 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { cacheManager } from './cache.js';
|
|
3
|
+
import { SPARTAN_DOCS_BASE, extractCodeBlocks, extractHeadings, extractLinks, fetchContent } from './utils.js';
|
|
4
|
+
export function registerDocsTools(server) {
|
|
5
|
+
server.registerTool('spartan_docs_get', {
|
|
6
|
+
title: 'Get a Spartan docs section',
|
|
7
|
+
description: 'Fetch an official Spartan documentation section by topic (installation, cli, theming, dark-mode, typography, health-checks, update-guide).',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
topic: z
|
|
10
|
+
.enum([
|
|
11
|
+
'installation',
|
|
12
|
+
'cli',
|
|
13
|
+
'theming',
|
|
14
|
+
'dark-mode',
|
|
15
|
+
'typography',
|
|
16
|
+
'health-checks',
|
|
17
|
+
'update-guide',
|
|
18
|
+
'analog-dark-mode',
|
|
19
|
+
])
|
|
20
|
+
.describe("Documentation topic to fetch. Includes 'analog-dark-mode' external article."),
|
|
21
|
+
format: z.enum(['html', 'text']).default('html').describe('Return format: raw HTML or plain text.'),
|
|
22
|
+
extract: z
|
|
23
|
+
.enum(['none', 'code', 'headings', 'links'])
|
|
24
|
+
.default('code')
|
|
25
|
+
.describe('Optional extraction: code blocks, headings, or links.'),
|
|
26
|
+
noCache: z.boolean().default(false).describe('Bypass cache when true.'),
|
|
27
|
+
spartanVersion: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Spartan UI version to use for caching (e.g., '1.2.3'). If not provided, defaults to 'latest'."),
|
|
31
|
+
},
|
|
32
|
+
}, async (args) => {
|
|
33
|
+
const topic = args.topic;
|
|
34
|
+
const format = args.format === 'text' ? 'text' : 'html';
|
|
35
|
+
const extract = args.extract || 'none';
|
|
36
|
+
const noCache = Boolean(args.noCache);
|
|
37
|
+
await cacheManager.initialize(args.spartanVersion);
|
|
38
|
+
const url = topic === 'analog-dark-mode'
|
|
39
|
+
? 'https://dev.to/this-is-angular/dark-mode-with-analog-tailwind-4049'
|
|
40
|
+
: `${SPARTAN_DOCS_BASE}/${encodeURIComponent(topic)}`;
|
|
41
|
+
let content;
|
|
42
|
+
let cacheInfo = '';
|
|
43
|
+
const cacheKey = `${topic}__${format}`;
|
|
44
|
+
if (!noCache && topic !== 'analog-dark-mode') {
|
|
45
|
+
const cached = await cacheManager.getDocs(cacheKey);
|
|
46
|
+
if (cached.cached && !cached.stale) {
|
|
47
|
+
content = cached.data;
|
|
48
|
+
cacheInfo = `\n[CACHED DATA - Version: ${cached.version}, Cached at: ${cached.cachedAt}]`;
|
|
49
|
+
}
|
|
50
|
+
else if (cached.cached && cached.stale) {
|
|
51
|
+
content = await fetchContent(url, format, true);
|
|
52
|
+
await cacheManager.setDocs(cacheKey, content);
|
|
53
|
+
cacheInfo = `\n[CACHE REFRESHED - Version: ${cacheManager.currentVersion}]`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
content = await fetchContent(url, format, true);
|
|
57
|
+
await cacheManager.setDocs(cacheKey, content);
|
|
58
|
+
cacheInfo = `\n[NEWLY CACHED - Version: ${cacheManager.currentVersion}]`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
content = await fetchContent(url, format, noCache);
|
|
63
|
+
cacheInfo = noCache ? '\n[LIVE FETCH - Cache bypassed]' : '';
|
|
64
|
+
}
|
|
65
|
+
if (extract === 'none' || format === 'text') {
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: 'text', text: `${content}${cacheInfo}\n\nSource: ${url}` }],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const html = content;
|
|
71
|
+
let extracted;
|
|
72
|
+
if (extract === 'code')
|
|
73
|
+
extracted = extractCodeBlocks(html);
|
|
74
|
+
else if (extract === 'headings')
|
|
75
|
+
extracted = extractHeadings(html);
|
|
76
|
+
else if (extract === 'links')
|
|
77
|
+
extracted = extractLinks(html);
|
|
78
|
+
else
|
|
79
|
+
extracted = [];
|
|
80
|
+
const payload = {
|
|
81
|
+
url,
|
|
82
|
+
extract,
|
|
83
|
+
count: Array.isArray(extracted) ? extracted.length : 0,
|
|
84
|
+
data: extracted,
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../../../libs/mcp/src/tools/docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/G,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAClD,MAAM,CAAC,YAAY,CAClB,kBAAkB,EAClB;QACC,KAAK,EAAE,4BAA4B;QACnC,WAAW,EACV,4IAA4I;QAC7I,WAAW,EAAE;YACZ,KAAK,EAAE,CAAC;iBACN,IAAI,CAAC;gBACL,cAAc;gBACd,KAAK;gBACL,SAAS;gBACT,WAAW;gBACX,YAAY;gBACZ,eAAe;gBACf,cAAc;gBACd,kBAAkB;aAClB,CAAC;iBACD,QAAQ,CAAC,6EAA6E,CAAC;YACzF,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,wCAAwC,CAAC;YACnG,OAAO,EAAE,CAAC;iBACR,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;iBAC3C,OAAO,CAAC,MAAM,CAAC;iBACf,QAAQ,CAAC,uDAAuD,CAAC;YACnE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,yBAAyB,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AO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACtD,IAAI,EAAE,SAAS;SACf,CAAC;QACF,OAAO;YACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACnE,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SPARTAN_COMPONENTS_BASE, SPARTAN_DOCS_BASE } from './utils.js';
|
|
3
|
+
export function registerHealthTools(server) {
|
|
4
|
+
server.registerTool('spartan_health_check', {
|
|
5
|
+
title: 'Spartan pages availability check',
|
|
6
|
+
description: 'Check availability and response times for selected Spartan docs and component pages. This validates the docs site, not your local workspace health check.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
topics: z
|
|
9
|
+
.array(z.enum(['installation', 'cli', 'theming', 'dark-mode', 'typography', 'health-checks', 'update-guide']))
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Docs topics to check; defaults to a standard set.'),
|
|
12
|
+
components: z
|
|
13
|
+
.array(z.string())
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('Component names to check; defaults to a small representative set.'),
|
|
16
|
+
},
|
|
17
|
+
}, async (args) => {
|
|
18
|
+
const topics = args.topics && Array.isArray(args.topics)
|
|
19
|
+
? args.topics
|
|
20
|
+
: ['installation', 'cli', 'theming', 'dark-mode', 'typography', 'health-checks', 'update-guide'];
|
|
21
|
+
const components = args.components && Array.isArray(args.components)
|
|
22
|
+
? args.components
|
|
23
|
+
: ['accordion', 'button', 'table', 'form-field'];
|
|
24
|
+
const checks = [];
|
|
25
|
+
const checkUrl = async (label, url) => {
|
|
26
|
+
const start = Date.now();
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
29
|
+
try {
|
|
30
|
+
const res = await fetch(url, {
|
|
31
|
+
headers: { 'User-Agent': 'spartan-mcp/1.0' },
|
|
32
|
+
signal: controller.signal,
|
|
33
|
+
});
|
|
34
|
+
checks.push({ label, url, ok: res.ok, status: res.status, ms: Date.now() - start });
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
checks.push({
|
|
38
|
+
label,
|
|
39
|
+
url,
|
|
40
|
+
ok: false,
|
|
41
|
+
status: 0,
|
|
42
|
+
ms: Date.now() - start,
|
|
43
|
+
error: String(err),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
clearTimeout(timeout);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
for (const t of topics) {
|
|
51
|
+
await checkUrl(`doc:${t}`, `${SPARTAN_DOCS_BASE}/${encodeURIComponent(t)}`);
|
|
52
|
+
}
|
|
53
|
+
for (const c of components) {
|
|
54
|
+
await checkUrl(`component:${c}`, `${SPARTAN_COMPONENTS_BASE}/${encodeURIComponent(c)}`);
|
|
55
|
+
}
|
|
56
|
+
const summary = {
|
|
57
|
+
timestamp: new Date().toISOString(),
|
|
58
|
+
totals: {
|
|
59
|
+
count: checks.length,
|
|
60
|
+
ok: checks.filter((x) => x.ok).length,
|
|
61
|
+
fail: checks.filter((x) => !x.ok).length,
|
|
62
|
+
},
|
|
63
|
+
checks,
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }],
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
server.registerTool('spartan_health_instructions', {
|
|
70
|
+
title: 'Spartan CLI health check instructions',
|
|
71
|
+
description: 'Return official instructions and commands for running the Spartan CLI health check in Angular CLI or Nx workspaces.',
|
|
72
|
+
inputSchema: {},
|
|
73
|
+
}, async () => {
|
|
74
|
+
const payload = {
|
|
75
|
+
summary: 'Run the Spartan CLI health check to scan your project and auto-fix common issues. Use Angular CLI or Nx commands in your project root.',
|
|
76
|
+
prerequisites: [
|
|
77
|
+
'Install Spartan CLI as a dev dependency: npm i -D @spartan-ng/cli',
|
|
78
|
+
'Ensure your workspace uses Angular CLI or Nx',
|
|
79
|
+
],
|
|
80
|
+
angular_cli_command: 'ng g @spartan-ng/cli:healthcheck',
|
|
81
|
+
nx_command: 'nx g @spartan-ng/cli:healthcheck',
|
|
82
|
+
source: `${SPARTAN_DOCS_BASE}/health-checks`,
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
server.registerTool('spartan_health_command', {
|
|
89
|
+
title: 'Build Spartan health check command',
|
|
90
|
+
description: 'Return the exact command to run the Spartan health check for Angular CLI or Nx. Optionally append --dry-run.',
|
|
91
|
+
inputSchema: {
|
|
92
|
+
tool: z.enum(['ng', 'nx']).describe('Which toolchain to use: Angular CLI (ng) or Nx (nx).'),
|
|
93
|
+
dryRun: z.boolean().default(false).describe('Append --dry-run to preview changes.'),
|
|
94
|
+
},
|
|
95
|
+
}, async (args) => {
|
|
96
|
+
const tool = args.tool;
|
|
97
|
+
const dryRun = Boolean(args.dryRun);
|
|
98
|
+
const base = tool === 'ng' ? 'npx ng g @spartan-ng/cli:healthcheck' : 'npx nx g @spartan-ng/cli:healthcheck';
|
|
99
|
+
const command = dryRun ? `${base} --dry-run` : base;
|
|
100
|
+
return { content: [{ type: 'text', text: command }] };
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../../../libs/mcp/src/tools/health.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,YAAY,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CAAC,CAAC,CAAC,QAAQ,CAAC,sDAAsD,CAAC;YAC3F,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;SACnF;KACD,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,IAAmB,CAAC;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,sCAAsC,CAAC;QAC7G,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;QACpD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACvD,CAAC,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DOCUMENTATION_TOPICS, KNOWN_BLOCKS, KNOWN_COMPONENTS, SPARTAN_BLOCKS_BASE, SPARTAN_COMPONENTS_BASE, SPARTAN_DOCS_BASE, } from './utils.js';
|
|
2
|
+
export function registerMetaTools(server) {
|
|
3
|
+
server.registerTool('spartan_meta', {
|
|
4
|
+
title: 'Spartan metadata',
|
|
5
|
+
description: 'Return known docs topics, components, and blocks for client autocomplete.',
|
|
6
|
+
inputSchema: {},
|
|
7
|
+
}, async () => {
|
|
8
|
+
const responseData = {
|
|
9
|
+
topics: [...DOCUMENTATION_TOPICS, 'analog-dark-mode'].map((t) => ({
|
|
10
|
+
topic: t,
|
|
11
|
+
url: t === 'analog-dark-mode'
|
|
12
|
+
? 'https://dev.to/this-is-angular/dark-mode-with-analog-tailwind-4049'
|
|
13
|
+
: `${SPARTAN_DOCS_BASE}/${t}`,
|
|
14
|
+
})),
|
|
15
|
+
components: KNOWN_COMPONENTS.map((n) => ({
|
|
16
|
+
name: n,
|
|
17
|
+
url: `${SPARTAN_COMPONENTS_BASE}/${n}`,
|
|
18
|
+
})),
|
|
19
|
+
blocks: KNOWN_BLOCKS.map((n) => ({
|
|
20
|
+
name: n,
|
|
21
|
+
url: `${SPARTAN_BLOCKS_BASE}/${n}`,
|
|
22
|
+
})),
|
|
23
|
+
usage: {
|
|
24
|
+
spartan_docs_get: 'Fetch documentation topics',
|
|
25
|
+
spartan_components_get: "Fetch component APIs with extract='api' for structured data",
|
|
26
|
+
spartan_components_list: 'List all available components',
|
|
27
|
+
spartan_blocks_list: 'List all available blocks',
|
|
28
|
+
spartan_blocks_get: 'Fetch block documentation and code',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const responseText = JSON.stringify(responseData, null, 2) +
|
|
32
|
+
'\n\nPROCESSING INSTRUCTIONS:\n' +
|
|
33
|
+
'- Use this metadata to understand available topics, components, and blocks\n' +
|
|
34
|
+
"- Always fetch component documentation with extract='api' for structured API data\n" +
|
|
35
|
+
'- Include code examples and usage patterns in your responses\n' +
|
|
36
|
+
'- Blocks are pre-built UI patterns composed of multiple components';
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: 'text',
|
|
41
|
+
text: responseText,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../../../libs/mcp/src/tools/meta.ts"],"names":[],"mappings":"AACA,OAAO,EACN,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAClD,MAAM,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CAAC,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { KNOWN_COMPONENTS, SPARTAN_COMPONENTS_BASE, extractAPIInfo, extractCodeBlocks, fetchContent } from './utils.js';
|
|
3
|
+
export function registerPromptHandlers(server) {
|
|
4
|
+
server.prompt('spartan-get-started', 'Get started with a Spartan UI component', {
|
|
5
|
+
componentName: z.string().describe("Name of the Spartan UI component (e.g., 'button', 'calendar')"),
|
|
6
|
+
variant: z.enum(['brain', 'helm']).optional().describe("Which API to use: 'brain' (unstyled) or 'helm' (styled)"),
|
|
7
|
+
}, async (args) => {
|
|
8
|
+
const componentName = args.componentName.toLowerCase();
|
|
9
|
+
const variant = args.variant?.toLowerCase() || 'helm';
|
|
10
|
+
if (!KNOWN_COMPONENTS.includes(componentName)) {
|
|
11
|
+
throw new Error(`Unknown component: ${componentName}. Available: ${KNOWN_COMPONENTS.slice(0, 5).join(', ')}...`);
|
|
12
|
+
}
|
|
13
|
+
const componentUrl = `${SPARTAN_COMPONENTS_BASE}/${componentName}`;
|
|
14
|
+
const html = await fetchContent(componentUrl, 'html', false);
|
|
15
|
+
const apiData = extractAPIInfo(html);
|
|
16
|
+
const codeBlocks = extractCodeBlocks(html);
|
|
17
|
+
const relevantAPI = variant === 'brain' ? apiData.brainAPI : apiData.helmAPI;
|
|
18
|
+
const firstExample = codeBlocks[0]?.code || 'No examples available';
|
|
19
|
+
return {
|
|
20
|
+
messages: [
|
|
21
|
+
{
|
|
22
|
+
role: 'user',
|
|
23
|
+
content: {
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: `Help me get started with the Spartan UI ${componentName} component using the ${variant.toUpperCase()} API.`,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
role: 'assistant',
|
|
30
|
+
content: {
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: `# Getting Started with Spartan UI ${componentName.toUpperCase()}
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
The **${componentName}** component is available at: ${componentUrl}
|
|
36
|
+
|
|
37
|
+
## ${variant.toUpperCase()} API
|
|
38
|
+
${relevantAPI.length > 0
|
|
39
|
+
? `This component has ${relevantAPI.length} ${variant} API component(s):
|
|
40
|
+
|
|
41
|
+
${relevantAPI
|
|
42
|
+
.map((comp, i) => `### ${i + 1}. ${comp.name}
|
|
43
|
+
${comp.selector ? `**Selector**: \`${comp.selector}\`` : ''}
|
|
44
|
+
|
|
45
|
+
**Inputs**:
|
|
46
|
+
${comp.inputs.map((input) => `- \`${input.prop}\`: ${input.type}${input.default !== '-' ? ` (default: ${input.default})` : ''}`).join('\n')}
|
|
47
|
+
|
|
48
|
+
${comp.outputs.length > 0 ? `**Outputs**:\n${comp.outputs.map((output) => `- \`${output.prop}\`: ${output.type}`).join('\n')}` : ''}
|
|
49
|
+
`)
|
|
50
|
+
.join('\n')}`
|
|
51
|
+
: `No ${variant} API components found.`}
|
|
52
|
+
|
|
53
|
+
## Quick Start Example
|
|
54
|
+
|
|
55
|
+
\`\`\`typescript
|
|
56
|
+
${firstExample}
|
|
57
|
+
\`\`\`
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
\`\`\`bash
|
|
62
|
+
npm install @spartan-ng/${variant === 'brain' ? 'brain' : 'helm'}/${componentName}
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
## Next Steps
|
|
66
|
+
1. Import the component in your Angular module/component
|
|
67
|
+
2. Use the selector in your template
|
|
68
|
+
3. Configure inputs as needed
|
|
69
|
+
4. Check the documentation for more examples: ${componentUrl}
|
|
70
|
+
`,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
server.prompt('spartan-compare-apis', 'Compare Brain API vs Helm API for a component', {
|
|
77
|
+
componentName: z.string().describe('Name of the Spartan UI component to compare'),
|
|
78
|
+
}, async (args) => {
|
|
79
|
+
const componentName = args.componentName.toLowerCase();
|
|
80
|
+
if (!KNOWN_COMPONENTS.includes(componentName)) {
|
|
81
|
+
throw new Error(`Unknown component: ${componentName}`);
|
|
82
|
+
}
|
|
83
|
+
const componentUrl = `${SPARTAN_COMPONENTS_BASE}/${componentName}`;
|
|
84
|
+
const html = await fetchContent(componentUrl, 'html', false);
|
|
85
|
+
const apiData = extractAPIInfo(html);
|
|
86
|
+
return {
|
|
87
|
+
messages: [
|
|
88
|
+
{
|
|
89
|
+
role: 'user',
|
|
90
|
+
content: {
|
|
91
|
+
type: 'text',
|
|
92
|
+
text: `Compare the Brain API and Helm API for the ${componentName} component. When should I use each?`,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
role: 'assistant',
|
|
97
|
+
content: {
|
|
98
|
+
type: 'text',
|
|
99
|
+
text: `# Brain API vs Helm API: ${componentName.toUpperCase()}
|
|
100
|
+
|
|
101
|
+
## Brain API (Unstyled, Accessible Primitives)
|
|
102
|
+
${apiData.brainAPI.length > 0 ? `Available Components: ${apiData.brainAPI.length}` : 'No Brain API components available.'}
|
|
103
|
+
|
|
104
|
+
## Helm API (Pre-styled Components)
|
|
105
|
+
${apiData.helmAPI.length > 0 ? `Available Components: ${apiData.helmAPI.length}` : 'No Helm API components available.'}
|
|
106
|
+
|
|
107
|
+
## Summary
|
|
108
|
+
| Aspect | Brain API | Helm API |
|
|
109
|
+
|--------|-----------|----------|
|
|
110
|
+
| Styling | Unstyled | Tailwind CSS |
|
|
111
|
+
| Complexity | Higher | Lower |
|
|
112
|
+
| Flexibility | Maximum | Moderate |
|
|
113
|
+
| Components | ${apiData.brainAPI.length} | ${apiData.helmAPI.length} |
|
|
114
|
+
|
|
115
|
+
More details: ${componentUrl}
|
|
116
|
+
`,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
server.prompt('spartan-implement-feature', 'Get help implementing a specific feature with a Spartan UI component', {
|
|
123
|
+
componentName: z.string().describe('Spartan UI component to use'),
|
|
124
|
+
feature: z.string().describe("Feature to implement (e.g., 'form validation', 'multi-select', 'date range')"),
|
|
125
|
+
framework: z.string().optional().describe("Framework context (e.g., 'standalone', 'NgModule', 'with Signals')"),
|
|
126
|
+
}, async (args) => {
|
|
127
|
+
const componentName = args.componentName.toLowerCase();
|
|
128
|
+
const feature = args.feature;
|
|
129
|
+
const framework = args.framework || 'standalone';
|
|
130
|
+
if (!KNOWN_COMPONENTS.includes(componentName)) {
|
|
131
|
+
throw new Error(`Unknown component: ${componentName}`);
|
|
132
|
+
}
|
|
133
|
+
const componentUrl = `${SPARTAN_COMPONENTS_BASE}/${componentName}`;
|
|
134
|
+
const html = await fetchContent(componentUrl, 'html', false);
|
|
135
|
+
const apiData = extractAPIInfo(html);
|
|
136
|
+
const codeBlocks = extractCodeBlocks(html);
|
|
137
|
+
return {
|
|
138
|
+
messages: [
|
|
139
|
+
{
|
|
140
|
+
role: 'user',
|
|
141
|
+
content: {
|
|
142
|
+
type: 'text',
|
|
143
|
+
text: `I want to implement ${feature} using the Spartan UI ${componentName} component in a ${framework} Angular application. Can you help me?`,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
role: 'assistant',
|
|
148
|
+
content: {
|
|
149
|
+
type: 'text',
|
|
150
|
+
text: `# Implementing "${feature}" with Spartan UI ${componentName}
|
|
151
|
+
|
|
152
|
+
## Component Overview
|
|
153
|
+
**Documentation**: ${componentUrl}
|
|
154
|
+
**Available APIs**: ${apiData.brainAPI.length} Brain + ${apiData.helmAPI.length} Helm
|
|
155
|
+
|
|
156
|
+
## Example Implementation (${framework})
|
|
157
|
+
|
|
158
|
+
\`\`\`typescript
|
|
159
|
+
${codeBlocks[0]?.code || `// Basic example for ${componentName}`}
|
|
160
|
+
\`\`\`
|
|
161
|
+
|
|
162
|
+
Need more help? Check the full documentation: ${componentUrl}
|
|
163
|
+
`,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
server.prompt('spartan-troubleshoot', 'Get help troubleshooting issues with a Spartan UI component', {
|
|
170
|
+
componentName: z.string().describe("Component you're having issues with"),
|
|
171
|
+
issue: z.string().describe('Description of the problem'),
|
|
172
|
+
}, async (args) => {
|
|
173
|
+
const componentName = args.componentName.toLowerCase();
|
|
174
|
+
const issue = args.issue;
|
|
175
|
+
if (!KNOWN_COMPONENTS.includes(componentName)) {
|
|
176
|
+
throw new Error(`Unknown component: ${componentName}`);
|
|
177
|
+
}
|
|
178
|
+
const componentUrl = `${SPARTAN_COMPONENTS_BASE}/${componentName}`;
|
|
179
|
+
return {
|
|
180
|
+
messages: [
|
|
181
|
+
{
|
|
182
|
+
role: 'user',
|
|
183
|
+
content: {
|
|
184
|
+
type: 'text',
|
|
185
|
+
text: `I'm having trouble with the Spartan UI ${componentName} component. Issue: ${issue}`,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
role: 'assistant',
|
|
190
|
+
content: {
|
|
191
|
+
type: 'text',
|
|
192
|
+
text: `# Troubleshooting Spartan UI ${componentName.toUpperCase()}
|
|
193
|
+
|
|
194
|
+
## Your Issue
|
|
195
|
+
> ${issue}
|
|
196
|
+
|
|
197
|
+
## Common Issues & Solutions
|
|
198
|
+
|
|
199
|
+
### 1. Check Imports
|
|
200
|
+
\`\`\`typescript
|
|
201
|
+
import { Hlm${componentName.charAt(0).toUpperCase() + componentName.slice(1)}Imports } from '@spartan-ng/helm/${componentName}';
|
|
202
|
+
import { Brn${componentName.charAt(0).toUpperCase() + componentName.slice(1)}Imports } from '@spartan-ng/brain/${componentName}';
|
|
203
|
+
\`\`\`
|
|
204
|
+
|
|
205
|
+
### 2. Verify Dependencies
|
|
206
|
+
\`\`\`bash
|
|
207
|
+
npm install @spartan-ng/helm/${componentName}
|
|
208
|
+
npm install @angular/cdk
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
### 3. Check Angular Version
|
|
212
|
+
Spartan UI requires Angular 17+ with standalone components support.
|
|
213
|
+
|
|
214
|
+
## Next Steps
|
|
215
|
+
1. Compare your code with examples: ${componentUrl}
|
|
216
|
+
2. Check browser console for errors
|
|
217
|
+
3. Verify all imports are correct
|
|
218
|
+
|
|
219
|
+
Still stuck? Provide more details about your setup and error messages.
|
|
220
|
+
`,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
server.prompt('spartan-list-components', 'List all available Spartan UI components with their categories', async () => {
|
|
227
|
+
const categories = {
|
|
228
|
+
'Form Controls': [
|
|
229
|
+
'autocomplete',
|
|
230
|
+
'button',
|
|
231
|
+
'button-group',
|
|
232
|
+
'checkbox',
|
|
233
|
+
'field',
|
|
234
|
+
'input',
|
|
235
|
+
'input-group',
|
|
236
|
+
'input-otp',
|
|
237
|
+
'item',
|
|
238
|
+
'label',
|
|
239
|
+
'native-select',
|
|
240
|
+
'radio-group',
|
|
241
|
+
'select',
|
|
242
|
+
'switch',
|
|
243
|
+
'textarea',
|
|
244
|
+
'toggle',
|
|
245
|
+
'toggle-group',
|
|
246
|
+
'slider',
|
|
247
|
+
],
|
|
248
|
+
'Data Display': ['table', 'card', 'badge', 'avatar', 'separator', 'progress', 'skeleton', 'spinner'],
|
|
249
|
+
Navigation: ['breadcrumb', 'menubar', 'pagination', 'tabs', 'command'],
|
|
250
|
+
Feedback: ['alert', 'alert-dialog', 'dialog', 'sonner', 'tooltip', 'hover-card'],
|
|
251
|
+
Overlay: ['popover', 'dropdown-menu', 'context-menu', 'sheet'],
|
|
252
|
+
Layout: ['aspect-ratio', 'scroll-area', 'collapsible', 'accordion', 'carousel', 'resizable', 'sidebar'],
|
|
253
|
+
'Date & Time': ['calendar', 'date-picker'],
|
|
254
|
+
Advanced: ['data-table', 'form-field', 'combobox', 'icon', 'navigation-menu'],
|
|
255
|
+
Utility: ['empty', 'kbd'],
|
|
256
|
+
};
|
|
257
|
+
const categorized = new Set(Object.values(categories).flat());
|
|
258
|
+
const additional = KNOWN_COMPONENTS.filter((component) => !categorized.has(component));
|
|
259
|
+
if (additional.length > 0) {
|
|
260
|
+
categories['Additional Components'] = additional;
|
|
261
|
+
}
|
|
262
|
+
const categorizedList = Object.entries(categories)
|
|
263
|
+
.map(([category, components]) => {
|
|
264
|
+
const available = components.filter((c) => KNOWN_COMPONENTS.includes(c));
|
|
265
|
+
return `## ${category} (${available.length})\n${available.map((c) => `- **${c}**: \`spartan://component/${c}/api\``).join('\n')}`;
|
|
266
|
+
})
|
|
267
|
+
.join('\n\n');
|
|
268
|
+
return {
|
|
269
|
+
messages: [
|
|
270
|
+
{
|
|
271
|
+
role: 'user',
|
|
272
|
+
content: {
|
|
273
|
+
type: 'text',
|
|
274
|
+
text: 'Show me all available Spartan UI components organized by category.',
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
role: 'assistant',
|
|
279
|
+
content: {
|
|
280
|
+
type: 'text',
|
|
281
|
+
text: `# Spartan UI Component Library
|
|
282
|
+
|
|
283
|
+
**Total Components**: ${KNOWN_COMPONENTS.length}
|
|
284
|
+
**Documentation**: https://www.spartan.ng
|
|
285
|
+
|
|
286
|
+
${categorizedList}
|
|
287
|
+
|
|
288
|
+
## How to Use
|
|
289
|
+
1. Pick a component from above
|
|
290
|
+
2. Use the prompt: \`spartan-get-started\` with the component name
|
|
291
|
+
3. Or access directly: \`spartan://component/<name>/api\`
|
|
292
|
+
`,
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../../../libs/mcp/src/tools/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAA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