@atlaskit/ads-mcp 0.9.1 → 0.10.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 +7 -0
- 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/index.js +13 -9
- 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/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,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.listGetIconsTool = exports.getIconsTool = exports.getIconsInputSchema = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _fuse = _interopRequireDefault(require("fuse.js"));
|
|
11
|
+
var _zod = require("zod");
|
|
12
|
+
var _helpers = require("../../helpers");
|
|
13
|
+
var _iconStructuredContent = require("./icon-structured-content.codegen");
|
|
14
|
+
var getIconsInputSchema = exports.getIconsInputSchema = _zod.z.object({
|
|
15
|
+
terms: _zod.z.array(_zod.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(),
|
|
16
|
+
limit: _zod.z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
17
|
+
exactName: _zod.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()
|
|
18
|
+
});
|
|
19
|
+
var listGetIconsTool = exports.listGetIconsTool = {
|
|
20
|
+
name: 'ads_get_icons',
|
|
21
|
+
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```",
|
|
22
|
+
annotations: {
|
|
23
|
+
title: 'Get ADS icons',
|
|
24
|
+
readOnlyHint: true,
|
|
25
|
+
destructiveHint: false,
|
|
26
|
+
idempotentHint: true,
|
|
27
|
+
openWorldHint: true
|
|
28
|
+
},
|
|
29
|
+
inputSchema: (0, _helpers.zodToJsonSchema)(getIconsInputSchema)
|
|
30
|
+
};
|
|
31
|
+
var getIconsTool = exports.getIconsTool = /*#__PURE__*/function () {
|
|
32
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params) {
|
|
33
|
+
var _params$terms, terms, _params$limit, limit, _params$exactName, exactName, searchTerms, iconDocs, allIconsMarkdown, exactNameMatches, _formattedIcons, fuse, results, uniqueResults, matchedIcons, formattedIcons;
|
|
34
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
35
|
+
while (1) switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_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;
|
|
38
|
+
searchTerms = terms.filter(Boolean).map(_helpers.cleanQuery);
|
|
39
|
+
iconDocs = _iconStructuredContent.iconStructuredContent.filter(function (icon) {
|
|
40
|
+
return icon.status === 'published';
|
|
41
|
+
}); // If no search terms provided, return all icons formatted as Markdown
|
|
42
|
+
if (!(searchTerms.length === 0)) {
|
|
43
|
+
_context.next = 6;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
allIconsMarkdown = iconDocs.map(function (icon) {
|
|
47
|
+
return icon.content;
|
|
48
|
+
}).join('\n\n');
|
|
49
|
+
return _context.abrupt("return", {
|
|
50
|
+
content: [{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: allIconsMarkdown
|
|
53
|
+
}]
|
|
54
|
+
});
|
|
55
|
+
case 6:
|
|
56
|
+
if (!exactName) {
|
|
57
|
+
_context.next = 10;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
// for each search term, search for the exact match
|
|
61
|
+
exactNameMatches = searchTerms.map(function (term) {
|
|
62
|
+
return iconDocs.find(function (icon) {
|
|
63
|
+
return icon.componentName.toLowerCase() === term.toLowerCase();
|
|
64
|
+
});
|
|
65
|
+
}).filter(function (icon) {
|
|
66
|
+
return icon !== undefined;
|
|
67
|
+
}); // Return exact matches if found, or empty result if exactName is true
|
|
68
|
+
_formattedIcons = exactNameMatches.map(function (icon) {
|
|
69
|
+
return icon.content;
|
|
70
|
+
}).join('\n\n');
|
|
71
|
+
return _context.abrupt("return", {
|
|
72
|
+
content: [{
|
|
73
|
+
type: 'text',
|
|
74
|
+
text: _formattedIcons
|
|
75
|
+
}]
|
|
76
|
+
});
|
|
77
|
+
case 10:
|
|
78
|
+
// use Fuse.js to fuzzy-search for the icons
|
|
79
|
+
fuse = new _fuse.default(iconDocs, {
|
|
80
|
+
keys: [{
|
|
81
|
+
name: 'componentName',
|
|
82
|
+
weight: 3
|
|
83
|
+
}, {
|
|
84
|
+
name: 'keywords',
|
|
85
|
+
weight: 2
|
|
86
|
+
}, {
|
|
87
|
+
name: 'categorization',
|
|
88
|
+
weight: 1
|
|
89
|
+
}, {
|
|
90
|
+
name: 'usage',
|
|
91
|
+
weight: 1
|
|
92
|
+
}],
|
|
93
|
+
threshold: 0.4
|
|
94
|
+
});
|
|
95
|
+
results = searchTerms.map(function (term) {
|
|
96
|
+
// always search exact match from the icons
|
|
97
|
+
var exactNameMatch = iconDocs.find(function (icon) {
|
|
98
|
+
return icon.componentName.toLowerCase() === term.toLowerCase();
|
|
99
|
+
});
|
|
100
|
+
if (exactNameMatch) {
|
|
101
|
+
return [{
|
|
102
|
+
item: exactNameMatch
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
105
|
+
return fuse.search(term).slice(0, limit);
|
|
106
|
+
}).flat(); // Remove duplicates based on componentName
|
|
107
|
+
uniqueResults = results.filter(function (result, index, arr) {
|
|
108
|
+
return arr.findIndex(function (r) {
|
|
109
|
+
return r.item.componentName === result.item.componentName;
|
|
110
|
+
}) === index;
|
|
111
|
+
});
|
|
112
|
+
matchedIcons = uniqueResults.map(function (result) {
|
|
113
|
+
return result.item;
|
|
114
|
+
});
|
|
115
|
+
formattedIcons = matchedIcons.map(function (icon) {
|
|
116
|
+
return icon.content;
|
|
117
|
+
}).join('\n\n');
|
|
118
|
+
return _context.abrupt("return", {
|
|
119
|
+
content: [{
|
|
120
|
+
type: 'text',
|
|
121
|
+
text: formattedIcons
|
|
122
|
+
}]
|
|
123
|
+
});
|
|
124
|
+
case 16:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee);
|
|
129
|
+
}));
|
|
130
|
+
return function getIconsTool(_x) {
|
|
131
|
+
return _ref.apply(this, arguments);
|
|
132
|
+
};
|
|
133
|
+
}();
|
|
@@ -9,23 +9,8 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _fuse = _interopRequireDefault(require("fuse.js"));
|
|
11
11
|
var _zod = require("zod");
|
|
12
|
-
var _zodToJsonSchema = require("zod-to-json-schema");
|
|
13
|
-
var _tokenMetadata = require("@atlaskit/tokens/token-metadata");
|
|
14
12
|
var _helpers = require("../../helpers");
|
|
15
|
-
var
|
|
16
|
-
// Transform Token[] from token-metadata to TokenSchema[] format
|
|
17
|
-
function transformTokensToSchemas() {
|
|
18
|
-
return _tokenMetadata.tokens.map(function (token) {
|
|
19
|
-
var _token$exampleValue;
|
|
20
|
-
return {
|
|
21
|
-
contentType: 'token',
|
|
22
|
-
name: token.name,
|
|
23
|
-
path: token.path,
|
|
24
|
-
description: token.description,
|
|
25
|
-
exampleValue: String((_token$exampleValue = token.exampleValue) !== null && _token$exampleValue !== void 0 ? _token$exampleValue : '')
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
}
|
|
13
|
+
var _tokenStructuredContent = require("./token-structured-content.codegen");
|
|
29
14
|
var getTokensInputSchema = exports.getTokensInputSchema = _zod.z.object({
|
|
30
15
|
terms: _zod.z.array(_zod.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(),
|
|
31
16
|
limit: _zod.z.number().default(1).describe('Maximum number of results per search term in the array (default: 1)').optional(),
|
|
@@ -41,7 +26,7 @@ var listGetTokensTool = exports.listGetTokensTool = {
|
|
|
41
26
|
idempotentHint: true,
|
|
42
27
|
openWorldHint: true
|
|
43
28
|
},
|
|
44
|
-
inputSchema: (0,
|
|
29
|
+
inputSchema: (0, _helpers.zodToJsonSchema)(getTokensInputSchema)
|
|
45
30
|
};
|
|
46
31
|
var getTokensTool = exports.getTokensTool = /*#__PURE__*/function () {
|
|
47
32
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params) {
|
|
@@ -51,12 +36,14 @@ var getTokensTool = exports.getTokensTool = /*#__PURE__*/function () {
|
|
|
51
36
|
case 0:
|
|
52
37
|
_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;
|
|
53
38
|
searchTerms = terms.filter(Boolean).map(_helpers.cleanQuery);
|
|
54
|
-
tokenDocs =
|
|
39
|
+
tokenDocs = _tokenStructuredContent.tokenStructuredContent; // If no search terms provided, return all tokens formatted as Markdown
|
|
55
40
|
if (!(searchTerms.length === 0)) {
|
|
56
41
|
_context.next = 6;
|
|
57
42
|
break;
|
|
58
43
|
}
|
|
59
|
-
allTokensMarkdown = tokenDocs.map(
|
|
44
|
+
allTokensMarkdown = tokenDocs.map(function (token) {
|
|
45
|
+
return token.content;
|
|
46
|
+
}).join('\n\n');
|
|
60
47
|
return _context.abrupt("return", {
|
|
61
48
|
content: [{
|
|
62
49
|
type: 'text',
|
|
@@ -73,12 +60,16 @@ var getTokensTool = exports.getTokensTool = /*#__PURE__*/function () {
|
|
|
73
60
|
return tokenDocs.find(function (token) {
|
|
74
61
|
return token.name.toLowerCase() === term.toLowerCase();
|
|
75
62
|
});
|
|
76
|
-
}).filter(
|
|
63
|
+
}).filter(function (token) {
|
|
64
|
+
return token !== undefined;
|
|
65
|
+
});
|
|
77
66
|
if (!(exactNameMatches.length > 0)) {
|
|
78
67
|
_context.next = 11;
|
|
79
68
|
break;
|
|
80
69
|
}
|
|
81
|
-
_formattedTokens = exactNameMatches.map(
|
|
70
|
+
_formattedTokens = exactNameMatches.map(function (token) {
|
|
71
|
+
return token.content;
|
|
72
|
+
}).join('\n\n');
|
|
82
73
|
return _context.abrupt("return", {
|
|
83
74
|
content: [{
|
|
84
75
|
type: 'text',
|
|
@@ -111,7 +102,9 @@ var getTokensTool = exports.getTokensTool = /*#__PURE__*/function () {
|
|
|
111
102
|
matchedTokens = uniqueResults.map(function (result) {
|
|
112
103
|
return result.item;
|
|
113
104
|
});
|
|
114
|
-
formattedTokens = matchedTokens.map(
|
|
105
|
+
formattedTokens = matchedTokens.map(function (token) {
|
|
106
|
+
return token.content;
|
|
107
|
+
}).join('\n\n');
|
|
115
108
|
return _context.abrupt("return", {
|
|
116
109
|
content: [{
|
|
117
110
|
type: 'text',
|