@lism-css/mcp 0.24.0 → 0.27.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/dist/data/docs-index.json +279 -139
- package/dist/data/guides/SKILL.md +87 -114
- package/dist/data/guides/antipatterns-layout.md +39 -40
- package/dist/data/guides/antipatterns.md +16 -12
- package/dist/data/guides/base-styles.md +1 -1
- package/dist/data/guides/components-core.md +9 -8
- package/dist/data/guides/components-ui.md +82 -35
- package/dist/data/guides/css-rules.md +103 -97
- package/dist/data/guides/customize.md +12 -26
- package/dist/data/guides/naming.md +8 -24
- package/dist/data/guides/property-class/all-props.md +25 -23
- package/dist/data/guides/property-class/bd.md +4 -1
- package/dist/data/guides/property-class.md +2 -1
- package/dist/data/guides/references/authoring.md +40 -52
- package/dist/data/guides/references/page-sections.md +5 -5
- package/dist/data/guides/references/verification.md +6 -4
- package/dist/data/guides/responsive.md +4 -24
- package/dist/data/guides/set-class.md +1 -1
- package/dist/data/guides/tokens.md +44 -18
- package/dist/data/guides/trait-class/has--transition.md +17 -2
- package/dist/data/guides/trait-class.md +2 -13
- package/dist/data/meta.js +2 -2
- package/dist/lib/markdown-utils.d.ts +3 -22
- package/dist/lib/markdown-utils.js +7 -30
- package/dist/lib/search.d.ts +1 -4
- package/dist/lib/search.js +17 -36
- package/dist/tools/convert-css.js +8 -25
- package/dist/tools/get-guide.js +2 -2
- package/package.json +5 -5
|
@@ -3,7 +3,6 @@ import { loadPropsMarkdown } from '../lib/load-markdown.js';
|
|
|
3
3
|
import { parsePropRows } from '../lib/markdown-utils.js';
|
|
4
4
|
import { MetaInfoSchema } from '../lib/schemas.js';
|
|
5
5
|
import { success, error, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
6
|
-
/** 変換結果の1行 */
|
|
7
6
|
const ConversionEntrySchema = z.object({
|
|
8
7
|
css: z.string(),
|
|
9
8
|
lismProp: z.string().nullable(),
|
|
@@ -12,7 +11,6 @@ const ConversionEntrySchema = z.object({
|
|
|
12
11
|
confidence: z.enum(['exact', 'approximate', 'unmapped']),
|
|
13
12
|
note: z.string(),
|
|
14
13
|
});
|
|
15
|
-
/** コンポーネント提案 */
|
|
16
14
|
const ComponentSuggestionSchema = z.object({
|
|
17
15
|
name: z.string(),
|
|
18
16
|
reason: z.string(),
|
|
@@ -21,7 +19,6 @@ const ComponentSuggestionSchema = z.object({
|
|
|
21
19
|
// ----------------------------------------------------------------
|
|
22
20
|
// CSS パース
|
|
23
21
|
// ----------------------------------------------------------------
|
|
24
|
-
/** @ルール(@media 等)が含まれていないか検査する */
|
|
25
22
|
function detectAtRules(cssText) {
|
|
26
23
|
const atRuleMatch = cssText.match(/^@(\w[\w-]*)/m);
|
|
27
24
|
if (atRuleMatch) {
|
|
@@ -29,16 +26,12 @@ function detectAtRules(cssText) {
|
|
|
29
26
|
}
|
|
30
27
|
return null;
|
|
31
28
|
}
|
|
32
|
-
/**
|
|
33
|
-
* CSS テキストから宣言を抽出する。
|
|
34
|
-
* `;` で分割する際に `url()` 等の括弧内の `;` を無視する。
|
|
35
|
-
*/
|
|
29
|
+
/** CSSテキストから宣言を抽出する。url()などの括弧内にある`;`は区切りとみなさない。 */
|
|
36
30
|
function parseCssDeclarations(cssText) {
|
|
37
|
-
//
|
|
31
|
+
// コメントとセレクタの外枠を取り除く。
|
|
38
32
|
let cleaned = cssText.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
39
|
-
// セレクタ + ブレースを除去(裸の宣言リストも受け付ける)
|
|
40
33
|
cleaned = cleaned.replace(/[^{}]*\{/g, '').replace(/\}/g, '');
|
|
41
|
-
//
|
|
34
|
+
// 括弧の深さを追いながら宣言単位に分ける。
|
|
42
35
|
const segments = [];
|
|
43
36
|
let current = '';
|
|
44
37
|
let parenDepth = 0;
|
|
@@ -72,12 +65,10 @@ function parseCssDeclarations(cssText) {
|
|
|
72
65
|
}
|
|
73
66
|
return declarations;
|
|
74
67
|
}
|
|
75
|
-
/** プリセット値列から値を抽出する(例: "-fz:base, -fz:5xl" → ["base", "5xl"]) */
|
|
76
68
|
function extractPresetValues(presetColumn, propName) {
|
|
77
69
|
if (!presetColumn || presetColumn === '—' || presetColumn === '-')
|
|
78
70
|
return [];
|
|
79
71
|
const values = [];
|
|
80
|
-
// -{prop}:{value} パターンを全て抽出
|
|
81
72
|
const escaped = propName.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
82
73
|
const regex = new RegExp(`-${escaped}:([^,\\s\`〜]+)`, 'g');
|
|
83
74
|
let match;
|
|
@@ -98,7 +89,6 @@ function buildCssPropertyMap(mappings) {
|
|
|
98
89
|
const map = new Map();
|
|
99
90
|
for (const mapping of mappings) {
|
|
100
91
|
const normalized = mapping.cssProperty.toLowerCase();
|
|
101
|
-
// CSS カスタムプロパティ形式はスキップ("--hl" 等)
|
|
102
92
|
if (!normalized.startsWith('(class:')) {
|
|
103
93
|
map.set(normalized, mapping);
|
|
104
94
|
}
|
|
@@ -108,7 +98,6 @@ function buildCssPropertyMap(mappings) {
|
|
|
108
98
|
// ----------------------------------------------------------------
|
|
109
99
|
// 値のマッピング
|
|
110
100
|
// ----------------------------------------------------------------
|
|
111
|
-
/** よくある CSS 値 → Lism トークン値の変換テーブル */
|
|
112
101
|
const VALUE_ALIASES = {
|
|
113
102
|
'space-between': 'between',
|
|
114
103
|
currentcolor: 'current',
|
|
@@ -119,10 +108,8 @@ function suggestValue(mapping, cssValue) {
|
|
|
119
108
|
const tokens = mapping.presetValues;
|
|
120
109
|
if (tokens.length === 0)
|
|
121
110
|
return null;
|
|
122
|
-
// 直接一致
|
|
123
111
|
if (tokens.includes(cssValue))
|
|
124
112
|
return cssValue;
|
|
125
|
-
// エイリアス変換後に一致
|
|
126
113
|
const aliased = VALUE_ALIASES[cssValue.toLowerCase()];
|
|
127
114
|
if (aliased && tokens.includes(aliased))
|
|
128
115
|
return aliased;
|
|
@@ -131,12 +118,12 @@ function suggestValue(mapping, cssValue) {
|
|
|
131
118
|
// ----------------------------------------------------------------
|
|
132
119
|
// コンポーネント検出
|
|
133
120
|
// ----------------------------------------------------------------
|
|
121
|
+
/** display関連の宣言から利用できるLismレイアウトコンポーネントを提案する。 */
|
|
134
122
|
function detectComponent(declarations) {
|
|
135
123
|
const propMap = new Map(declarations.map((d) => [d.property, d.value.toLowerCase()]));
|
|
136
124
|
const display = propMap.get('display');
|
|
137
125
|
const flexDirection = propMap.get('flex-direction');
|
|
138
126
|
const placeItems = propMap.get('place-items');
|
|
139
|
-
// Stack: flex + column
|
|
140
127
|
if (display === 'flex' && (flexDirection === 'column' || flexDirection === 'column-reverse')) {
|
|
141
128
|
return {
|
|
142
129
|
name: 'Stack',
|
|
@@ -144,7 +131,6 @@ function detectComponent(declarations) {
|
|
|
144
131
|
implicitCss: ['display: flex', 'flex-direction: column'],
|
|
145
132
|
};
|
|
146
133
|
}
|
|
147
|
-
// Center: grid + place-items: center
|
|
148
134
|
if (display === 'grid' && placeItems === 'center') {
|
|
149
135
|
return {
|
|
150
136
|
name: 'Center',
|
|
@@ -152,7 +138,6 @@ function detectComponent(declarations) {
|
|
|
152
138
|
implicitCss: ['display: grid', 'place-items: center'],
|
|
153
139
|
};
|
|
154
140
|
}
|
|
155
|
-
// Flex
|
|
156
141
|
if (display === 'flex') {
|
|
157
142
|
return {
|
|
158
143
|
name: 'Flex',
|
|
@@ -160,7 +145,6 @@ function detectComponent(declarations) {
|
|
|
160
145
|
implicitCss: ['display: flex'],
|
|
161
146
|
};
|
|
162
147
|
}
|
|
163
|
-
// Grid
|
|
164
148
|
if (display === 'grid') {
|
|
165
149
|
return {
|
|
166
150
|
name: 'Grid',
|
|
@@ -177,6 +161,7 @@ function findCategory(mappings, propName) {
|
|
|
177
161
|
const found = mappings.find((m) => m.prop === propName);
|
|
178
162
|
return found?.sectionName ?? 'unknown';
|
|
179
163
|
}
|
|
164
|
+
/** 変換結果からJSX使用例を組み立てる。 */
|
|
180
165
|
function buildExample(conversions, component) {
|
|
181
166
|
const tagName = component?.name ?? 'Lism';
|
|
182
167
|
const implicitCssSet = new Set(component?.implicitCss.map((c) => c.split(':')[0].trim()) ?? []);
|
|
@@ -188,7 +173,7 @@ function buildExample(conversions, component) {
|
|
|
188
173
|
styles.push(conv.css);
|
|
189
174
|
continue;
|
|
190
175
|
}
|
|
191
|
-
//
|
|
176
|
+
// コンポーネントが暗黙に持つCSSは重複出力しない。
|
|
192
177
|
if (implicitCssSet.has(cssProp))
|
|
193
178
|
continue;
|
|
194
179
|
if (conv.suggestedValue != null) {
|
|
@@ -232,7 +217,6 @@ export function registerConvertCss(server) {
|
|
|
232
217
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
233
218
|
}, ({ css }) => {
|
|
234
219
|
try {
|
|
235
|
-
// @ ルール検出
|
|
236
220
|
const atRuleError = detectAtRules(css);
|
|
237
221
|
if (atRuleError) {
|
|
238
222
|
return error(atRuleError);
|
|
@@ -244,7 +228,7 @@ export function registerConvertCss(server) {
|
|
|
244
228
|
if (declarations.length === 0) {
|
|
245
229
|
return error('No CSS declarations found. Provide CSS in "property: value;" format.');
|
|
246
230
|
}
|
|
247
|
-
//
|
|
231
|
+
// 各宣言をLism Propと候補値へ変換する。
|
|
248
232
|
const conversions = declarations.map((decl) => {
|
|
249
233
|
const mapping = cssPropertyMap.get(decl.property);
|
|
250
234
|
if (!mapping) {
|
|
@@ -272,9 +256,8 @@ export function registerConvertCss(server) {
|
|
|
272
256
|
: `Use as a custom value (category: ${category})`,
|
|
273
257
|
};
|
|
274
258
|
});
|
|
275
|
-
//
|
|
259
|
+
// 変換結果からコンポーネント候補と使用例を組み立てる。
|
|
276
260
|
const suggestedComponent = detectComponent(declarations);
|
|
277
|
-
// 使用例
|
|
278
261
|
const example = buildExample(conversions, suggestedComponent);
|
|
279
262
|
return success({
|
|
280
263
|
conversions,
|
package/dist/tools/get-guide.js
CHANGED
|
@@ -22,14 +22,14 @@ const GUIDE_TOPICS = {
|
|
|
22
22
|
'set-class': { files: ['set-class.md'], label: 'Set classes (set--plain, set--bxsh, set--hov, etc.)' },
|
|
23
23
|
'primitive-class': {
|
|
24
24
|
files: ['primitive-class.md'],
|
|
25
|
-
label: 'Primitive class prefixes (
|
|
25
|
+
label: 'Primitive class prefixes (l--, a--), with column-layout primitive selection guide',
|
|
26
26
|
},
|
|
27
27
|
'trait-class': {
|
|
28
28
|
files: ['trait-class.md'],
|
|
29
29
|
label: 'Trait classes (is--, has--): declarative role/feature classes in the lism-trait layer',
|
|
30
30
|
},
|
|
31
31
|
'utility-class': { files: ['utility-class.md'], label: 'Utility classes (u--trim, u--cbox, etc.)' },
|
|
32
|
-
'css-rules': { files: ['css-rules.md'], label: 'CSS methodology, layer structure, naming conventions' },
|
|
32
|
+
'css-rules': { files: ['css-rules.md'], label: 'CSS methodology, layer structure, Block Class (b--) / Custom Class (c--), naming conventions' },
|
|
33
33
|
naming: {
|
|
34
34
|
files: ['naming.md'],
|
|
35
35
|
label: 'Naming conventions: CSS variable / class naming rules, {prop} and {value} abbreviation rules',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lism-css/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "MCP server for lism-css documentation and API reference.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"bin"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
27
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
28
28
|
"zod": "^3.25.76"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^25.
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"vitest": "^4.1.
|
|
31
|
+
"@types/node": "^25.9.4",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"vitest": "^4.1.10"
|
|
34
34
|
},
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"engines": {
|