@atlaskit/ads-mcp 0.13.9 → 0.15.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/CHANGELOG.md +15 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/tools/get-icons/icon-structured-content.codegen.js +3 -2580
- package/dist/cjs/tools/get-lint-rules/index.js +126 -0
- package/dist/cjs/tools/get-lint-rules/lint-rules-structured-content.codegen.js +345 -0
- package/dist/es2019/index.js +6 -0
- package/dist/es2019/tools/get-icons/icon-structured-content.codegen.js +2 -2573
- package/dist/es2019/tools/get-lint-rules/index.js +97 -0
- package/dist/es2019/tools/get-lint-rules/lint-rules-structured-content.codegen.js +339 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/tools/get-icons/icon-structured-content.codegen.js +2 -2573
- package/dist/esm/tools/get-lint-rules/index.js +119 -0
- package/dist/esm/tools/get-lint-rules/lint-rules-structured-content.codegen.js +339 -0
- package/dist/types/tools/get-icons/icon-structured-content.codegen.d.ts +1 -1
- package/dist/types/tools/get-lint-rules/index.d.ts +27 -0
- package/dist/types/tools/get-lint-rules/lint-rules-structured-content.codegen.d.ts +13 -0
- package/dist/types-ts4.5/tools/get-icons/icon-structured-content.codegen.d.ts +1 -1
- package/dist/types-ts4.5/tools/get-lint-rules/index.d.ts +27 -0
- package/dist/types-ts4.5/tools/get-lint-rules/lint-rules-structured-content.codegen.d.ts +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { cleanQuery, zodToJsonSchema } from '../../helpers';
|
|
4
|
+
import { lintRulesStructuredContent } from './lint-rules-structured-content.codegen';
|
|
5
|
+
export const getLintRulesInputSchema = z.object({
|
|
6
|
+
terms: z.array(z.string()).default([]).describe('An array of search terms to find lint rules by name or description, eg. `["icon-label", "xcss", "design token"]`. If empty or not provided, returns all lint rules.').optional(),
|
|
7
|
+
limit: z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
8
|
+
exactName: z.boolean().default(false).describe('Enable to explicitly search lint rules by the exact rule name match (when you know the rule name, but need more details)').optional()
|
|
9
|
+
});
|
|
10
|
+
export const listGetLintRulesTool = {
|
|
11
|
+
name: 'ads_get_lint_rules',
|
|
12
|
+
description: `Get Atlassian Design System ESLint rule documentation (constellation) with optional search functionality.
|
|
13
|
+
|
|
14
|
+
- If search parameters are provided, searches for lint rules matching the criteria.
|
|
15
|
+
- If no search parameters are provided, returns all lint rules.
|
|
16
|
+
|
|
17
|
+
Example: use this tool to look up documentation for rules like icon-label, ensure-proper-xcss-usage, or no-deprecated-apis.`,
|
|
18
|
+
annotations: {
|
|
19
|
+
title: 'Get ADS lint rules',
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
destructiveHint: false,
|
|
22
|
+
idempotentHint: true,
|
|
23
|
+
openWorldHint: true
|
|
24
|
+
},
|
|
25
|
+
inputSchema: zodToJsonSchema(getLintRulesInputSchema)
|
|
26
|
+
};
|
|
27
|
+
export const getLintRulesTool = async params => {
|
|
28
|
+
const {
|
|
29
|
+
terms = [],
|
|
30
|
+
limit = 1,
|
|
31
|
+
exactName = false
|
|
32
|
+
} = params;
|
|
33
|
+
const searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
34
|
+
const ruleDocs = lintRulesStructuredContent;
|
|
35
|
+
|
|
36
|
+
// If no search terms provided, return all rules formatted as Markdown
|
|
37
|
+
if (searchTerms.length === 0) {
|
|
38
|
+
const allRulesMarkdown = ruleDocs.map(rule => rule.content).join('\n\n');
|
|
39
|
+
return {
|
|
40
|
+
content: [{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: allRulesMarkdown
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Search logic (similar to get-icons / get-tokens)
|
|
48
|
+
if (exactName) {
|
|
49
|
+
const exactNameMatches = searchTerms.map(term => {
|
|
50
|
+
return ruleDocs.find(rule => rule.ruleName.toLowerCase() === term.toLowerCase());
|
|
51
|
+
}).filter(rule => rule !== undefined);
|
|
52
|
+
const formattedRules = exactNameMatches.map(rule => rule.content).join('\n\n');
|
|
53
|
+
return {
|
|
54
|
+
content: [{
|
|
55
|
+
type: 'text',
|
|
56
|
+
text: formattedRules
|
|
57
|
+
}]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// use Fuse.js to fuzzy-search for the rules
|
|
62
|
+
const fuse = new Fuse(ruleDocs, {
|
|
63
|
+
keys: [{
|
|
64
|
+
name: 'ruleName',
|
|
65
|
+
weight: 3
|
|
66
|
+
}, {
|
|
67
|
+
name: 'description',
|
|
68
|
+
weight: 2
|
|
69
|
+
}, {
|
|
70
|
+
name: 'content',
|
|
71
|
+
weight: 1
|
|
72
|
+
}],
|
|
73
|
+
threshold: 0.4
|
|
74
|
+
});
|
|
75
|
+
const results = searchTerms.map(term => {
|
|
76
|
+
const exactNameMatch = ruleDocs.find(rule => rule.ruleName.toLowerCase() === term.toLowerCase());
|
|
77
|
+
if (exactNameMatch) {
|
|
78
|
+
return [{
|
|
79
|
+
item: exactNameMatch
|
|
80
|
+
}];
|
|
81
|
+
}
|
|
82
|
+
return fuse.search(term).slice(0, limit);
|
|
83
|
+
}).flat();
|
|
84
|
+
|
|
85
|
+
// Remove duplicates based on ruleName
|
|
86
|
+
const uniqueResults = results.filter((result, index, arr) => {
|
|
87
|
+
return arr.findIndex(r => r.item.ruleName === result.item.ruleName) === index;
|
|
88
|
+
});
|
|
89
|
+
const matchedRules = uniqueResults.map(result => result.item);
|
|
90
|
+
const formattedRules = matchedRules.map(rule => rule.content).join('\n\n');
|
|
91
|
+
return {
|
|
92
|
+
content: [{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: formattedRules
|
|
95
|
+
}]
|
|
96
|
+
};
|
|
97
|
+
};
|