@actioneer/ads-mcp 0.8.0 → 0.8.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/package.json +1 -1
- package/src/tools.mjs +21 -6
package/package.json
CHANGED
package/src/tools.mjs
CHANGED
|
@@ -158,15 +158,30 @@ export function createTools({ manifest }) {
|
|
|
158
158
|
},
|
|
159
159
|
|
|
160
160
|
get_token: (args) => {
|
|
161
|
-
const
|
|
161
|
+
const raw = args.role ?? "";
|
|
162
|
+
const q = String(raw).trim().toLowerCase().replace(/^(bg|text|border|ring)-/, "");
|
|
163
|
+
const tokens = getToken(manifest, raw);
|
|
164
|
+
const scales = getScale(manifest, raw);
|
|
165
|
+
|
|
166
|
+
// Rank exact matches above fuzzy ones, colour first. getToken's fuzzy pass
|
|
167
|
+
// also searches token DESCRIPTIONS, so without this an exact scale key
|
|
168
|
+
// loses to a colour that merely mentions the word: "body" returned
|
|
169
|
+
// --color-success, whose description reads "...does not clear body-text AA".
|
|
170
|
+
const exactToken = tokens.filter((t) => t.role === q);
|
|
171
|
+
if (exactToken.length > 0) return json(exactToken);
|
|
172
|
+
|
|
173
|
+
const exactScale = scales.filter(
|
|
174
|
+
(s) =>
|
|
175
|
+
String(s.key).toLowerCase() === q ||
|
|
176
|
+
`${s.scale}-${String(s.key)}`.toLowerCase() === q ||
|
|
177
|
+
s.scale.toLowerCase() === q
|
|
178
|
+
);
|
|
179
|
+
if (exactScale.length > 0) return json(exactScale);
|
|
180
|
+
|
|
162
181
|
if (tokens.length > 0) return json(tokens);
|
|
163
|
-
// Colour roles miss — try the non-colour scales before giving up, so
|
|
164
|
-
// "shadow-300", "springDialog", "radius" and "body" all resolve. Two
|
|
165
|
-
// principles cite those values; a dead end here makes the rule unusable.
|
|
166
|
-
const scales = getScale(manifest, args.role ?? "");
|
|
167
182
|
if (scales.length > 0) return json(scales);
|
|
168
183
|
return text(
|
|
169
|
-
`No ADS token or scale matches "${
|
|
184
|
+
`No ADS token or scale matches "${raw}". Try a colour role ('brand', ` +
|
|
170
185
|
`'muted-foreground'), a type role ('body'), a radius step ('md'), a shadow ` +
|
|
171
186
|
`('shadow-300'), or a motion preset ('springDialog').`,
|
|
172
187
|
true
|