@atlaskit/ads-mcp 0.9.1 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/helpers/analytics.js +2 -2
- package/dist/cjs/index.js +14 -9
- package/dist/cjs/tools/get-icons/icon-structured-content.codegen.js +2585 -0
- package/dist/cjs/tools/get-icons/index.js +133 -0
- package/dist/cjs/tools/get-tokens/index.js +15 -22
- package/dist/cjs/tools/get-tokens/token-structured-content.codegen.js +2261 -0
- package/dist/es2019/helpers/analytics.js +2 -2
- package/dist/es2019/index.js +13 -9
- package/dist/es2019/tools/analyze-a11y/index.js +1 -1
- package/dist/es2019/tools/get-icons/icon-structured-content.codegen.js +2579 -0
- package/dist/es2019/tools/get-icons/index.js +108 -0
- package/dist/es2019/tools/get-tokens/index.js +7 -22
- package/dist/es2019/tools/get-tokens/token-structured-content.codegen.js +2255 -0
- package/dist/esm/helpers/analytics.js +2 -2
- package/dist/esm/index.js +14 -9
- package/dist/esm/tools/get-icons/icon-structured-content.codegen.js +2579 -0
- package/dist/esm/tools/get-icons/index.js +126 -0
- package/dist/esm/tools/get-tokens/index.js +15 -22
- package/dist/esm/tools/get-tokens/token-structured-content.codegen.js +2255 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/tools/get-icons/icon-structured-content.codegen.d.ts +13 -0
- package/dist/types/tools/get-icons/index.d.ts +35 -0
- package/dist/types/tools/get-tokens/index.d.ts +6 -4
- package/dist/types/tools/get-tokens/token-structured-content.codegen.d.ts +13 -0
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/tools/get-icons/icon-structured-content.codegen.d.ts +13 -0
- package/dist/types-ts4.5/tools/get-icons/index.d.ts +35 -0
- package/dist/types-ts4.5/tools/get-tokens/index.d.ts +6 -4
- package/dist/types-ts4.5/tools/get-tokens/token-structured-content.codegen.d.ts +13 -0
- package/package.json +5 -1
- package/dist/cjs/structured-content/formatters/token.js +0 -11
- package/dist/cjs/structured-content/types.js +0 -1
- package/dist/es2019/structured-content/formatters/token.js +0 -10
- package/dist/es2019/structured-content/types.js +0 -0
- package/dist/esm/structured-content/formatters/token.js +0 -5
- package/dist/esm/structured-content/types.js +0 -0
- package/dist/types/structured-content/formatters/token.d.ts +0 -2
- package/dist/types/structured-content/types.d.ts +0 -20
- package/dist/types-ts4.5/structured-content/formatters/token.d.ts +0 -2
- package/dist/types-ts4.5/structured-content/types.d.ts +0 -20
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import Fuse from 'fuse.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { cleanQuery, zodToJsonSchema } from '../../helpers';
|
|
6
|
+
import { iconStructuredContent } from './icon-structured-content.codegen';
|
|
7
|
+
export var getIconsInputSchema = z.object({
|
|
8
|
+
terms: z.array(z.string()).default([]).describe('An array of search terms to find icons by name, keywords, or categorization, eg. `["search", "folder", "user"]`. If empty or not provided, returns all icons.').optional(),
|
|
9
|
+
limit: z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
10
|
+
exactName: z.boolean().default(false).describe('Enable to explicitly search icons by the exact name match (when you know the name, but need more details)').optional()
|
|
11
|
+
});
|
|
12
|
+
export var listGetIconsTool = {
|
|
13
|
+
name: 'ads_get_icons',
|
|
14
|
+
description: "Get Atlassian Design System icons with optional search functionality.\n\n- If search parameters are provided, searches for icons matching the criteria.\n- If no search parameters are provided, returns all icons.\n\nExample icon usage:\n```tsx\nimport AddIcon from '@atlaskit/icon/core/add';\n<AddIcon label=\"Add work item\" size=\"small\" />\n```",
|
|
15
|
+
annotations: {
|
|
16
|
+
title: 'Get ADS icons',
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
idempotentHint: true,
|
|
20
|
+
openWorldHint: true
|
|
21
|
+
},
|
|
22
|
+
inputSchema: zodToJsonSchema(getIconsInputSchema)
|
|
23
|
+
};
|
|
24
|
+
export var getIconsTool = /*#__PURE__*/function () {
|
|
25
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
|
|
26
|
+
var _params$terms, terms, _params$limit, limit, _params$exactName, exactName, searchTerms, iconDocs, allIconsMarkdown, exactNameMatches, _formattedIcons, fuse, results, uniqueResults, matchedIcons, formattedIcons;
|
|
27
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
_params$terms = params.terms, terms = _params$terms === void 0 ? [] : _params$terms, _params$limit = params.limit, limit = _params$limit === void 0 ? 1 : _params$limit, _params$exactName = params.exactName, exactName = _params$exactName === void 0 ? false : _params$exactName;
|
|
31
|
+
searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
32
|
+
iconDocs = iconStructuredContent.filter(function (icon) {
|
|
33
|
+
return icon.status === 'published';
|
|
34
|
+
}); // If no search terms provided, return all icons formatted as Markdown
|
|
35
|
+
if (!(searchTerms.length === 0)) {
|
|
36
|
+
_context.next = 6;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
allIconsMarkdown = iconDocs.map(function (icon) {
|
|
40
|
+
return icon.content;
|
|
41
|
+
}).join('\n\n');
|
|
42
|
+
return _context.abrupt("return", {
|
|
43
|
+
content: [{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: allIconsMarkdown
|
|
46
|
+
}]
|
|
47
|
+
});
|
|
48
|
+
case 6:
|
|
49
|
+
if (!exactName) {
|
|
50
|
+
_context.next = 10;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
// for each search term, search for the exact match
|
|
54
|
+
exactNameMatches = searchTerms.map(function (term) {
|
|
55
|
+
return iconDocs.find(function (icon) {
|
|
56
|
+
return icon.componentName.toLowerCase() === term.toLowerCase();
|
|
57
|
+
});
|
|
58
|
+
}).filter(function (icon) {
|
|
59
|
+
return icon !== undefined;
|
|
60
|
+
}); // Return exact matches if found, or empty result if exactName is true
|
|
61
|
+
_formattedIcons = exactNameMatches.map(function (icon) {
|
|
62
|
+
return icon.content;
|
|
63
|
+
}).join('\n\n');
|
|
64
|
+
return _context.abrupt("return", {
|
|
65
|
+
content: [{
|
|
66
|
+
type: 'text',
|
|
67
|
+
text: _formattedIcons
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
case 10:
|
|
71
|
+
// use Fuse.js to fuzzy-search for the icons
|
|
72
|
+
fuse = new Fuse(iconDocs, {
|
|
73
|
+
keys: [{
|
|
74
|
+
name: 'componentName',
|
|
75
|
+
weight: 3
|
|
76
|
+
}, {
|
|
77
|
+
name: 'keywords',
|
|
78
|
+
weight: 2
|
|
79
|
+
}, {
|
|
80
|
+
name: 'categorization',
|
|
81
|
+
weight: 1
|
|
82
|
+
}, {
|
|
83
|
+
name: 'usage',
|
|
84
|
+
weight: 1
|
|
85
|
+
}],
|
|
86
|
+
threshold: 0.4
|
|
87
|
+
});
|
|
88
|
+
results = searchTerms.map(function (term) {
|
|
89
|
+
// always search exact match from the icons
|
|
90
|
+
var exactNameMatch = iconDocs.find(function (icon) {
|
|
91
|
+
return icon.componentName.toLowerCase() === term.toLowerCase();
|
|
92
|
+
});
|
|
93
|
+
if (exactNameMatch) {
|
|
94
|
+
return [{
|
|
95
|
+
item: exactNameMatch
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
return fuse.search(term).slice(0, limit);
|
|
99
|
+
}).flat(); // Remove duplicates based on componentName
|
|
100
|
+
uniqueResults = results.filter(function (result, index, arr) {
|
|
101
|
+
return arr.findIndex(function (r) {
|
|
102
|
+
return r.item.componentName === result.item.componentName;
|
|
103
|
+
}) === index;
|
|
104
|
+
});
|
|
105
|
+
matchedIcons = uniqueResults.map(function (result) {
|
|
106
|
+
return result.item;
|
|
107
|
+
});
|
|
108
|
+
formattedIcons = matchedIcons.map(function (icon) {
|
|
109
|
+
return icon.content;
|
|
110
|
+
}).join('\n\n');
|
|
111
|
+
return _context.abrupt("return", {
|
|
112
|
+
content: [{
|
|
113
|
+
type: 'text',
|
|
114
|
+
text: formattedIcons
|
|
115
|
+
}]
|
|
116
|
+
});
|
|
117
|
+
case 16:
|
|
118
|
+
case "end":
|
|
119
|
+
return _context.stop();
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
}));
|
|
123
|
+
return function getIconsTool(_x) {
|
|
124
|
+
return _ref.apply(this, arguments);
|
|
125
|
+
};
|
|
126
|
+
}();
|
|
@@ -2,23 +2,8 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import Fuse from 'fuse.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { zodToJsonSchema } from '
|
|
6
|
-
import {
|
|
7
|
-
import { cleanQuery } from '../../helpers';
|
|
8
|
-
import { tokenToMarkdown } from '../../structured-content/formatters/token';
|
|
9
|
-
// Transform Token[] from token-metadata to TokenSchema[] format
|
|
10
|
-
function transformTokensToSchemas() {
|
|
11
|
-
return tokens.map(function (token) {
|
|
12
|
-
var _token$exampleValue;
|
|
13
|
-
return {
|
|
14
|
-
contentType: 'token',
|
|
15
|
-
name: token.name,
|
|
16
|
-
path: token.path,
|
|
17
|
-
description: token.description,
|
|
18
|
-
exampleValue: String((_token$exampleValue = token.exampleValue) !== null && _token$exampleValue !== void 0 ? _token$exampleValue : '')
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
}
|
|
5
|
+
import { cleanQuery, zodToJsonSchema } from '../../helpers';
|
|
6
|
+
import { tokenStructuredContent } from './token-structured-content.codegen';
|
|
22
7
|
export var getTokensInputSchema = z.object({
|
|
23
8
|
terms: z.array(z.string()).default([]).describe('An array of search terms to find tokens by name or description, eg. `["spacing", "inverted text", "background primary"]`. If empty or not provided, returns all tokens.').optional(),
|
|
24
9
|
limit: z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
@@ -44,12 +29,14 @@ export var getTokensTool = /*#__PURE__*/function () {
|
|
|
44
29
|
case 0:
|
|
45
30
|
_params$terms = params.terms, terms = _params$terms === void 0 ? [] : _params$terms, _params$limit = params.limit, limit = _params$limit === void 0 ? 1 : _params$limit, _params$exactName = params.exactName, exactName = _params$exactName === void 0 ? false : _params$exactName;
|
|
46
31
|
searchTerms = terms.filter(Boolean).map(cleanQuery);
|
|
47
|
-
tokenDocs =
|
|
32
|
+
tokenDocs = tokenStructuredContent; // If no search terms provided, return all tokens formatted as Markdown
|
|
48
33
|
if (!(searchTerms.length === 0)) {
|
|
49
34
|
_context.next = 6;
|
|
50
35
|
break;
|
|
51
36
|
}
|
|
52
|
-
allTokensMarkdown = tokenDocs.map(
|
|
37
|
+
allTokensMarkdown = tokenDocs.map(function (token) {
|
|
38
|
+
return token.content;
|
|
39
|
+
}).join('\n\n');
|
|
53
40
|
return _context.abrupt("return", {
|
|
54
41
|
content: [{
|
|
55
42
|
type: 'text',
|
|
@@ -66,12 +53,16 @@ export var getTokensTool = /*#__PURE__*/function () {
|
|
|
66
53
|
return tokenDocs.find(function (token) {
|
|
67
54
|
return token.name.toLowerCase() === term.toLowerCase();
|
|
68
55
|
});
|
|
69
|
-
}).filter(
|
|
56
|
+
}).filter(function (token) {
|
|
57
|
+
return token !== undefined;
|
|
58
|
+
});
|
|
70
59
|
if (!(exactNameMatches.length > 0)) {
|
|
71
60
|
_context.next = 11;
|
|
72
61
|
break;
|
|
73
62
|
}
|
|
74
|
-
_formattedTokens = exactNameMatches.map(
|
|
63
|
+
_formattedTokens = exactNameMatches.map(function (token) {
|
|
64
|
+
return token.content;
|
|
65
|
+
}).join('\n\n');
|
|
75
66
|
return _context.abrupt("return", {
|
|
76
67
|
content: [{
|
|
77
68
|
type: 'text',
|
|
@@ -104,7 +95,9 @@ export var getTokensTool = /*#__PURE__*/function () {
|
|
|
104
95
|
matchedTokens = uniqueResults.map(function (result) {
|
|
105
96
|
return result.item;
|
|
106
97
|
});
|
|
107
|
-
formattedTokens = matchedTokens.map(
|
|
98
|
+
formattedTokens = matchedTokens.map(function (token) {
|
|
99
|
+
return token.content;
|
|
100
|
+
}).join('\n\n');
|
|
108
101
|
return _context.abrupt("return", {
|
|
109
102
|
content: [{
|
|
110
103
|
type: 'text',
|