@atlaskit/ads-mcp 0.13.8 → 0.14.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 +14 -0
- package/dist/cjs/index.js +6 -0
- 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-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-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-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-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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/ads-mcp
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`9450f7060eda0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9450f7060eda0) -
|
|
8
|
+
Created "lint rule" tool that documents lint rules in ADS MCP. It sources its content from the
|
|
9
|
+
structured docs.
|
|
10
|
+
|
|
11
|
+
## 0.13.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 0.13.8
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var _getAllIcons = require("./tools/get-all-icons");
|
|
|
21
21
|
var _getAllTokens = require("./tools/get-all-tokens");
|
|
22
22
|
var _getComponents = require("./tools/get-components");
|
|
23
23
|
var _getIcons = require("./tools/get-icons");
|
|
24
|
+
var _getLintRules = require("./tools/get-lint-rules");
|
|
24
25
|
var _getTokens = require("./tools/get-tokens");
|
|
25
26
|
var _i18nConversion = require("./tools/i18n-conversion");
|
|
26
27
|
var _migrationGuides = require("./tools/migration-guides");
|
|
@@ -109,6 +110,11 @@ var getToolRegistry = exports.getToolRegistry = function getToolRegistry() {
|
|
|
109
110
|
inputSchema: _getIcons.getIconsInputSchema,
|
|
110
111
|
tool: _getIcons.listGetIconsTool
|
|
111
112
|
};
|
|
113
|
+
baseTools[_getLintRules.listGetLintRulesTool.name] = {
|
|
114
|
+
handler: _getLintRules.getLintRulesTool,
|
|
115
|
+
inputSchema: _getLintRules.getLintRulesInputSchema,
|
|
116
|
+
tool: _getLintRules.listGetLintRulesTool
|
|
117
|
+
};
|
|
112
118
|
} else {
|
|
113
119
|
baseTools[_getAllTokens.listGetAllTokensTool.name] = {
|
|
114
120
|
handler: _getAllTokens.getAllTokensTool,
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.listGetLintRulesTool = exports.getLintRulesTool = exports.getLintRulesInputSchema = 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 _lintRulesStructuredContent = require("./lint-rules-structured-content.codegen");
|
|
14
|
+
var getLintRulesInputSchema = exports.getLintRulesInputSchema = _zod.z.object({
|
|
15
|
+
terms: _zod.z.array(_zod.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(),
|
|
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 lint rules by the exact rule name match (when you know the rule name, but need more details)').optional()
|
|
18
|
+
});
|
|
19
|
+
var listGetLintRulesTool = exports.listGetLintRulesTool = {
|
|
20
|
+
name: 'ads_get_lint_rules',
|
|
21
|
+
description: "Get Atlassian Design System ESLint rule documentation (constellation) with optional search functionality.\n\n- If search parameters are provided, searches for lint rules matching the criteria.\n- If no search parameters are provided, returns all lint rules.\n\nExample: use this tool to look up documentation for rules like icon-label, ensure-proper-xcss-usage, or no-deprecated-apis.",
|
|
22
|
+
annotations: {
|
|
23
|
+
title: 'Get ADS lint rules',
|
|
24
|
+
readOnlyHint: true,
|
|
25
|
+
destructiveHint: false,
|
|
26
|
+
idempotentHint: true,
|
|
27
|
+
openWorldHint: true
|
|
28
|
+
},
|
|
29
|
+
inputSchema: (0, _helpers.zodToJsonSchema)(getLintRulesInputSchema)
|
|
30
|
+
};
|
|
31
|
+
var getLintRulesTool = exports.getLintRulesTool = /*#__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, ruleDocs, allRulesMarkdown, exactNameMatches, _formattedRules, fuse, results, uniqueResults, matchedRules, formattedRules;
|
|
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
|
+
ruleDocs = _lintRulesStructuredContent.lintRulesStructuredContent; // If no search terms provided, return all rules formatted as Markdown
|
|
40
|
+
if (!(searchTerms.length === 0)) {
|
|
41
|
+
_context.next = 6;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
allRulesMarkdown = ruleDocs.map(function (rule) {
|
|
45
|
+
return rule.content;
|
|
46
|
+
}).join('\n\n');
|
|
47
|
+
return _context.abrupt("return", {
|
|
48
|
+
content: [{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: allRulesMarkdown
|
|
51
|
+
}]
|
|
52
|
+
});
|
|
53
|
+
case 6:
|
|
54
|
+
if (!exactName) {
|
|
55
|
+
_context.next = 10;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
exactNameMatches = searchTerms.map(function (term) {
|
|
59
|
+
return ruleDocs.find(function (rule) {
|
|
60
|
+
return rule.ruleName.toLowerCase() === term.toLowerCase();
|
|
61
|
+
});
|
|
62
|
+
}).filter(function (rule) {
|
|
63
|
+
return rule !== undefined;
|
|
64
|
+
});
|
|
65
|
+
_formattedRules = exactNameMatches.map(function (rule) {
|
|
66
|
+
return rule.content;
|
|
67
|
+
}).join('\n\n');
|
|
68
|
+
return _context.abrupt("return", {
|
|
69
|
+
content: [{
|
|
70
|
+
type: 'text',
|
|
71
|
+
text: _formattedRules
|
|
72
|
+
}]
|
|
73
|
+
});
|
|
74
|
+
case 10:
|
|
75
|
+
// use Fuse.js to fuzzy-search for the rules
|
|
76
|
+
fuse = new _fuse.default(ruleDocs, {
|
|
77
|
+
keys: [{
|
|
78
|
+
name: 'ruleName',
|
|
79
|
+
weight: 3
|
|
80
|
+
}, {
|
|
81
|
+
name: 'description',
|
|
82
|
+
weight: 2
|
|
83
|
+
}, {
|
|
84
|
+
name: 'content',
|
|
85
|
+
weight: 1
|
|
86
|
+
}],
|
|
87
|
+
threshold: 0.4
|
|
88
|
+
});
|
|
89
|
+
results = searchTerms.map(function (term) {
|
|
90
|
+
var exactNameMatch = ruleDocs.find(function (rule) {
|
|
91
|
+
return rule.ruleName.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 ruleName
|
|
100
|
+
uniqueResults = results.filter(function (result, index, arr) {
|
|
101
|
+
return arr.findIndex(function (r) {
|
|
102
|
+
return r.item.ruleName === result.item.ruleName;
|
|
103
|
+
}) === index;
|
|
104
|
+
});
|
|
105
|
+
matchedRules = uniqueResults.map(function (result) {
|
|
106
|
+
return result.item;
|
|
107
|
+
});
|
|
108
|
+
formattedRules = matchedRules.map(function (rule) {
|
|
109
|
+
return rule.content;
|
|
110
|
+
}).join('\n\n');
|
|
111
|
+
return _context.abrupt("return", {
|
|
112
|
+
content: [{
|
|
113
|
+
type: 'text',
|
|
114
|
+
text: formattedRules
|
|
115
|
+
}]
|
|
116
|
+
});
|
|
117
|
+
case 16:
|
|
118
|
+
case "end":
|
|
119
|
+
return _context.stop();
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
}));
|
|
123
|
+
return function getLintRulesTool(_x) {
|
|
124
|
+
return _ref.apply(this, arguments);
|
|
125
|
+
};
|
|
126
|
+
}();
|