astro-dev-mcp 0.4.0 → 0.5.6

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.
@@ -2,7 +2,6 @@
2
2
  * UIパターン汎用ジェネレーター
3
3
  * コンテンツデータとUIパターンを受け取り、適切なマークアップを生成
4
4
  */
5
- import { getContainerClass, getButtonClass } from '../utils/astroDevClasses.js';
6
5
  /**
7
6
  * UIパターンに基づいてマークアップを生成
8
7
  */
@@ -27,10 +26,7 @@ export function generateUIPattern(config) {
27
26
  /**
28
27
  * タブUI生成(開発環境のTab.ts連携)
29
28
  */
30
- function generateTabUI(config) {
31
- const { options = {} } = config;
32
- const { useContainer = true } = options;
33
- const containerClass = useContainer ? getContainerClass() : '';
29
+ function generateTabUI(_config) {
34
30
  return `---
35
31
  interface Props {
36
32
  data: {
@@ -46,8 +42,8 @@ const { data } = Astro.props;
46
42
  ---
47
43
 
48
44
  <section class="c_tab">
49
- ${useContainer ? `<div class="${containerClass}">` : ''}
50
- <h2 class="section_ttl">{data.ttl}</h2>
45
+ <div class="contentInner">
46
+ <h2 class="section_ttl" set:html={data.ttl} />
51
47
  <ul class="c_tab_list">
52
48
  {
53
49
  data.items.map((item, i) => (
@@ -57,9 +53,8 @@ const { data } = Astro.props;
57
53
  class={i === 0 ? "-open" : ""}
58
54
  aria-pressed={i === 0 ? "true" : "false"}
59
55
  tabindex={i === 0 ? "-1" : "0"}
60
- >
61
- {item.name}
62
- </button>
56
+ set:html={item.name}
57
+ />
63
58
  </li>
64
59
  ))
65
60
  }
@@ -72,11 +67,11 @@ const { data } = Astro.props;
72
67
  tabindex="-1"
73
68
  >
74
69
  <!-- コンテンツはプロジェクト固有で実装 -->
75
- {item.content}
70
+ <Fragment set:html={item.content} />
76
71
  </div>
77
72
  ))
78
73
  }
79
- ${useContainer ? '</div>' : ''}
74
+ </div>
80
75
  </section>
81
76
  `;
82
77
  }
@@ -84,9 +79,8 @@ const { data } = Astro.props;
84
79
  * アコーディオンUI生成(開発環境のAccordion.ts連携)
85
80
  */
86
81
  function generateAccordionUI(config) {
87
- const { data, options = {} } = config;
88
- const { openFirst = true, useContainer = true } = options;
89
- const containerClass = useContainer ? getContainerClass() : '';
82
+ const { options = {} } = config;
83
+ const { openFirst = true } = options;
90
84
  return `---
91
85
  interface Props {
92
86
  data: {
@@ -102,8 +96,8 @@ const { data } = Astro.props;
102
96
  ---
103
97
 
104
98
  <section class="accordion_section">
105
- ${useContainer ? `<div class="${containerClass}">` : ''}
106
- <h2 class="section_ttl">{data.ttl}</h2>
99
+ <div class="contentInner">
100
+ <h2 class="section_ttl" set:html={data.ttl} />
107
101
  <div class="accordion_list">
108
102
  {
109
103
  data.items.map((item, i) => (
@@ -112,7 +106,7 @@ const { data } = Astro.props;
112
106
  open={${openFirst} && i === 0}
113
107
  >
114
108
  <summary class="c_pull_ttl accordion_item_ttl">
115
- <span class="accordion_item_ttl_text">{item.ttl}</span>
109
+ <span class="accordion_item_ttl_text" set:html={item.ttl} />
116
110
  </summary>
117
111
  <div class="c_pull_content accordion_item_content">
118
112
  <div class="accordion_item_content_text" set:html={item.content} />
@@ -121,7 +115,7 @@ const { data } = Astro.props;
121
115
  ))
122
116
  }
123
117
  </div>
124
- ${useContainer ? '</div>' : ''}
118
+ </div>
125
119
  </section>
126
120
  `;
127
121
  }
@@ -129,12 +123,10 @@ const { data } = Astro.props;
129
123
  * グリッドUI生成
130
124
  */
131
125
  function generateGridUI(config) {
132
- const { data, options = {}, components = [] } = config;
133
- const { columns = 3, gap = '2.4rem', hasImage = true, useContainer = true } = options;
134
- const hasPicture = components.includes('Picture');
135
- const containerClass = useContainer ? getContainerClass() : '';
126
+ const { options = {} } = config;
127
+ const { columns = 3, gap = '2.4rem', hasImage = true } = options;
136
128
  return `---
137
- ${hasPicture ? 'import Picture from "@/components/Picture.astro";' : ''}
129
+ import Picture from "@/components/Picture.astro";
138
130
 
139
131
  interface Props {
140
132
  data: {
@@ -153,8 +145,8 @@ const { data, imgPath = '' } = Astro.props;
153
145
  ---
154
146
 
155
147
  <section class="grid_section">
156
- ${useContainer ? `<div class="${containerClass}">` : ''}
157
- <h2 class="section_ttl">{data.ttl}</h2>
148
+ <div class="contentInner">
149
+ <h2 class="section_ttl" set:html={data.ttl} />
158
150
  <ul class="grid_list" style="display: grid; grid-template-columns: repeat(${columns}, 1fr); gap: ${gap};">
159
151
  {
160
152
  data.items.map((item) => (
@@ -163,20 +155,20 @@ const { data, imgPath = '' } = Astro.props;
163
155
  ? `
164
156
  {item.img && (
165
157
  <div class="grid_item_img">
166
- ${hasPicture ? '<Picture src={imgPath + item.img} alt={item.ttl} sizes={[400, 300]} />' : '<img src={imgPath + item.img} alt={item.ttl} loading="lazy" />'}
158
+ <Picture src={imgPath + item.img} alt={item.ttl} />
167
159
  </div>
168
160
  )}
169
161
  `
170
162
  : ''}
171
163
  <div class="grid_item_body">
172
- <h3 class="grid_item_ttl">{item.ttl}</h3>
173
- {item.desc && <p class="grid_item_desc">{item.desc}</p>}
164
+ <h3 class="grid_item_ttl" set:html={item.ttl} />
165
+ {item.desc && <p class="grid_item_desc" set:html={item.desc} />}
174
166
  </div>
175
167
  </li>
176
168
  ))
177
169
  }
178
170
  </ul>
179
- ${useContainer ? '</div>' : ''}
171
+ </div>
180
172
  </section>
181
173
  `;
182
174
  }
@@ -184,12 +176,10 @@ const { data, imgPath = '' } = Astro.props;
184
176
  * カルーセルUI生成
185
177
  */
186
178
  function generateCarouselUI(config) {
187
- const { data, options = {}, components = [] } = config;
188
- const { autoplay = false, useContainer = true } = options;
189
- const hasPicture = components.includes('Picture');
190
- const containerClass = useContainer ? getContainerClass() : '';
179
+ const { options = {} } = config;
180
+ const { autoplay = false } = options;
191
181
  return `---
192
- ${hasPicture ? 'import Picture from "@/components/Picture.astro";' : ''}
182
+ import Picture from "@/components/Picture.astro";
193
183
 
194
184
  /**
195
185
  * カルーセルセクション
@@ -211,8 +201,8 @@ const { data, imgPath = '' } = Astro.props;
211
201
  ---
212
202
 
213
203
  <section class="carousel_section">
214
- ${useContainer ? `<div class="${containerClass}">` : ''}
215
- <h2 class="section_ttl">{data.ttl}</h2>
204
+ <div class="contentInner">
205
+ <h2 class="section_ttl" set:html={data.ttl} />
216
206
  <div class="swiper carousel_swiper" data-autoplay="${autoplay}">
217
207
  <div class="swiper-wrapper">
218
208
  {
@@ -220,12 +210,12 @@ const { data, imgPath = '' } = Astro.props;
220
210
  <div class="swiper-slide carousel_item">
221
211
  {item.img && (
222
212
  <div class="carousel_item_img">
223
- ${hasPicture ? '<Picture src={imgPath + item.img} alt={item.ttl} sizes={[800, 600]} />' : '<img src={imgPath + item.img} alt={item.ttl} loading="lazy" />'}
213
+ <Picture src={imgPath + item.img} alt={item.ttl} />
224
214
  </div>
225
215
  )}
226
216
  <div class="carousel_item_body">
227
- <h3 class="carousel_item_ttl">{item.ttl}</h3>
228
- {item.desc && <p class="carousel_item_desc">{item.desc}</p>}
217
+ <h3 class="carousel_item_ttl" set:html={item.ttl} />
218
+ {item.desc && <p class="carousel_item_desc" set:html={item.desc} />}
229
219
  </div>
230
220
  </div>
231
221
  ))
@@ -235,17 +225,14 @@ const { data, imgPath = '' } = Astro.props;
235
225
  <div class="swiper-button-prev"></div>
236
226
  <div class="swiper-button-next"></div>
237
227
  </div>
238
- ${useContainer ? '</div>' : ''}
228
+ </div>
239
229
  </section>
240
230
  `;
241
231
  }
242
232
  /**
243
233
  * リストUI生成
244
234
  */
245
- function generateListUI(config) {
246
- const { data, options = {} } = config;
247
- const { useContainer = true } = options;
248
- const containerClass = useContainer ? getContainerClass() : '';
235
+ function generateListUI(_config) {
249
236
  return `---
250
237
  interface Props {
251
238
  data: {
@@ -261,33 +248,28 @@ const { data } = Astro.props;
261
248
  ---
262
249
 
263
250
  <section class="list_section">
264
- ${useContainer ? `<div class="${containerClass}">` : ''}
265
- <h2 class="section_ttl">{data.ttl}</h2>
251
+ <div class="contentInner">
252
+ <h2 class="section_ttl" set:html={data.ttl} />
266
253
  <ul class="list">
267
254
  {
268
255
  data.items.map((item) => (
269
256
  <li class="list_item">
270
- <h3 class="list_item_ttl">{item.ttl}</h3>
271
- {item.desc && <p class="list_item_desc">{item.desc}</p>}
257
+ <h3 class="list_item_ttl" set:html={item.ttl} />
258
+ {item.desc && <p class="list_item_desc" set:html={item.desc} />}
272
259
  </li>
273
260
  ))
274
261
  }
275
262
  </ul>
276
- ${useContainer ? '</div>' : ''}
263
+ </div>
277
264
  </section>
278
265
  `;
279
266
  }
280
267
  /**
281
268
  * モーダルUI生成(開発環境のModal.ts連携)
282
269
  */
283
- function generateModalUI(config) {
284
- const { data, components = [], options = {} } = config;
285
- const hasPicture = components.includes('Picture');
286
- const { useContainer = true, useStandardButton = true } = options;
287
- const containerClass = useContainer ? getContainerClass() : '';
288
- const buttonClass = useStandardButton ? getButtonClass('c_modal_btn modal_card') : 'c_modal_btn modal_card';
270
+ function generateModalUI(_config) {
289
271
  return `---
290
- ${hasPicture ? 'import Picture from "@/components/Picture.astro";' : ''}
272
+ import Picture from "@/components/Picture.astro";
291
273
 
292
274
  /**
293
275
  * モーダルギャラリーセクション
@@ -312,21 +294,21 @@ const { data, imgPath = '' } = Astro.props;
312
294
  ---
313
295
 
314
296
  <section class="modal_section">
315
- ${useContainer ? `<div class="${containerClass}">` : ''}
316
- <h2 class="section_ttl">{data.ttl}</h2>
297
+ <div class="contentInner">
298
+ <h2 class="section_ttl" set:html={data.ttl} />
317
299
  <ul class="modal_list">
318
300
  {
319
301
  data.items.map((item) => (
320
302
  <li class="modal_item">
321
303
  <button
322
304
  type="button"
323
- class="${buttonClass}"
305
+ class="c_modal_btn modal_card"
324
306
  data-src={item.src}
325
307
  data-alt={item.alt}
326
308
  >
327
309
  {item.thumbnail && (
328
310
  <span class="modal_thumbnail">
329
- ${hasPicture ? '<Picture src={imgPath + item.thumbnail} alt={item.alt || item.ttl} sizes={[800, 450]} />' : '<img src={imgPath + item.thumbnail} alt={item.alt || item.ttl} loading="lazy" />'}
311
+ <Picture src={imgPath + item.thumbnail} alt={item.alt || item.ttl} />
330
312
  {item.type === 'video' && (
331
313
  <span class="modal_play_icon">
332
314
  <svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -338,15 +320,15 @@ const { data, imgPath = '' } = Astro.props;
338
320
  </span>
339
321
  )}
340
322
  <span class="modal_body">
341
- <h3 class="modal_ttl">{item.ttl}</h3>
342
- {item.desc && <p class="modal_desc">{item.desc}</p>}
323
+ <h3 class="modal_ttl" set:html={item.ttl} />
324
+ {item.desc && <p class="modal_desc" set:html={item.desc} />}
343
325
  </span>
344
326
  </button>
345
327
  </li>
346
328
  ))
347
329
  }
348
330
  </ul>
349
- ${useContainer ? '</div>' : ''}
331
+ </div>
350
332
  </section>
351
333
  `;
352
334
  }
@@ -1 +1 @@
1
- {"version":3,"file":"uiPatterns.js","sourceRoot":"","sources":["../../src/templates/uiPatterns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AA0BhF;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACxD,QAAQ,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,KAAK,KAAK;YACT,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9B,KAAK,WAAW;YACf,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACpC,KAAK,MAAM;YACV,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;QAC/B,KAAK,UAAU;YACd,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,MAAM;YACV,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;QAC/B,KAAK,OAAO;YACX,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;QAChC;YACC,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;AACF,CAAC;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.js更新統合版)
3
3
  */
4
4
  export declare function generateSection(args: any): Promise<{
5
5
  content: {
@@ -1 +1 @@
1
- {"version":3,"file":"generateSection.d.ts","sourceRoot":"","sources":["../../src/tools/generateSection.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,GAAG;;;;;GAuD9C"}
1
+ {"version":3,"file":"generateSection.d.ts","sourceRoot":"","sources":["../../src/tools/generateSection.ts"],"names":[],"mappings":"AAyCA;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,GAAG;;;;;GAiH9C"}
@@ -1,12 +1,17 @@
1
1
  import { generateSectionTemplate } from '../templates/sectionTemplates.js';
2
2
  import { formatCode } from '../utils/formatter.js';
3
3
  import { parseSectionIntent } from '../utils/promptParser.js';
4
+ import { generateScssPattern } from '../templates/scssPatterns.js';
5
+ import { getRequiredScripts, updateAppJs, needsAppJsUpdate, } from '../editors/appJsEditor.js';
6
+ import { readFileSync, writeFileSync, existsSync } from 'fs';
7
+ import { resolve } from 'path';
4
8
  /**
5
- * セクション生成ツール
9
+ * セクション生成ツール(SCSS生成・app.js更新統合版)
6
10
  */
7
11
  export async function generateSection(args) {
8
- const { prompt, sectionType, uiPattern, pageName, content, components = [], } = args;
12
+ const { prompt, sectionType, uiPattern, pageName, content, components = [], generateScss = true, scssOptions = {}, projectRoot = process.cwd(), } = args;
9
13
  try {
14
+ const updateLogs = [];
10
15
  let finalSectionType;
11
16
  let finalUIPattern;
12
17
  // プロンプトが指定されている場合は解析
@@ -16,7 +21,7 @@ export async function generateSection(args) {
16
21
  finalUIPattern = parsed.uiPattern;
17
22
  // 低信頼度の場合は警告
18
23
  if (parsed.confidence < 0.7) {
19
- console.warn(`⚠️ プロンプト解析の信頼度が低い(${parsed.confidence}): "${prompt}"`);
24
+ updateLogs.push(`⚠️ プロンプト解析の信頼度が低い(${parsed.confidence}): "${prompt}"`);
20
25
  }
21
26
  }
22
27
  else {
@@ -24,7 +29,26 @@ export async function generateSection(args) {
24
29
  finalSectionType = sectionType;
25
30
  finalUIPattern = uiPattern;
26
31
  }
27
- // セクションテンプレート生成
32
+ // 1. app.js の更新(UIパターンにスクリプトが必要な場合)
33
+ if (finalUIPattern) {
34
+ const appJsPath = resolve(projectRoot, 'src/js/app.js');
35
+ if (existsSync(appJsPath)) {
36
+ const originalContent = readFileSync(appJsPath, 'utf-8');
37
+ if (needsAppJsUpdate(originalContent, finalUIPattern)) {
38
+ const requiredScripts = getRequiredScripts(finalUIPattern);
39
+ const updatedContent = updateAppJs(originalContent, requiredScripts);
40
+ writeFileSync(appJsPath, updatedContent, 'utf-8');
41
+ updateLogs.push(`✅ app.js を更新しました(追加: ${requiredScripts.join(', ')})`);
42
+ }
43
+ else {
44
+ updateLogs.push(`ℹ️ app.js は既に必要なスクリプトが登録済みです`);
45
+ }
46
+ }
47
+ else {
48
+ updateLogs.push(`⚠️ app.js が見つかりません: ${appJsPath}`);
49
+ }
50
+ }
51
+ // 2. セクションテンプレート生成
28
52
  const sectionCode = generateSectionTemplate({
29
53
  type: finalSectionType,
30
54
  uiPattern: finalUIPattern,
@@ -33,12 +57,31 @@ export async function generateSection(args) {
33
57
  components,
34
58
  });
35
59
  // コード整形
36
- const formatted = await formatCode(sectionCode, 'astro');
60
+ const formattedAstro = await formatCode(sectionCode, 'astro');
61
+ // 3. SCSS生成(オプション)
62
+ let scssCode = '';
63
+ if (generateScss && finalUIPattern) {
64
+ scssCode = generateScssPattern({
65
+ pattern: finalUIPattern,
66
+ pageName,
67
+ sectionName: finalSectionType,
68
+ options: scssOptions,
69
+ });
70
+ updateLogs.push(`✅ SCSSファイルを生成しました(配置先: src/scss/pages/_${pageName}.scss)`);
71
+ }
72
+ // 結果メッセージの構築
73
+ const updateSection = updateLogs.length > 0
74
+ ? `### プロジェクト更新\n${updateLogs.join('\n')}\n\n`
75
+ : '';
76
+ let resultText = `${updateSection}### セクション生成\n✅ セクション「${finalSectionType}」(UI: ${finalUIPattern || 'デフォルト'})を生成しました\n\n#### Astroコンポーネント\n\`\`\`astro\n${formattedAstro}\n\`\`\`\n\n**配置先**: \`src/pages/_parts/_${pageName}/_${finalSectionType}.astro\``;
77
+ if (scssCode) {
78
+ resultText += `\n\n#### SCSSファイル\n\`\`\`scss\n${scssCode}\n\`\`\`\n\n**配置先**: \`src/scss/pages/_${pageName}.scss\`\n\n**注意**: 既存の \`_${pageName}.scss\` がある場合は、生成されたSCSSを追記してください。`;
79
+ }
37
80
  return {
38
81
  content: [
39
82
  {
40
83
  type: 'text',
41
- text: `✅ セクション「${finalSectionType}」(UI: ${finalUIPattern || 'デフォルト'})を生成しました\n\n\`\`\`astro\n${formatted}\n\`\`\`\n\n### 配置先\n- \`src/pages/_parts/_${pageName}/_${finalSectionType}.astro\``,
84
+ text: resultText,
42
85
  },
43
86
  ],
44
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"generateSection.js","sourceRoot":"","sources":["../../src/tools/generateSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAa9D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAS;IAC9C,MAAM,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,EACP,UAAU,GAAG,EAAE,GACf,GAAG,IAAmB,CAAC;IAExB,IAAI,CAAC;QACJ,IAAI,gBAAwB,CAAC;QAC7B,IAAI,cAAkC,CAAC;QAEvC,qBAAqB;QACrB,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC1C,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC;YACtC,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC;YAElC,aAAa;YACb,IAAI,MAAM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AAG,GAAG,aAAa,wBAAwB,gBAAgB,SAAS,cAAc,IAAI,OAAO,+CAA+C,cAAc,4CAA4C,QAAQ,KAAK,gBAAgB,UAAU,CAAC;QAE5P,IAAI,QAAQ,EAAE,CAAC;YACd,UAAU,IAAI,kCAAkC,QAAQ,0CAA0C,QAAQ,6BAA6B,QAAQ,oCAAoC,CAAC;QACrL,CAAC;QAED,OAAO;YACN,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,UAAU;iBAChB;aACD;SACD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC;IACzC,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-dev-mcp",
3
- "version": "0.4.0",
3
+ "version": "0.5.6",
4
4
  "description": "MCP server for generating Astro components, sections, and pages from design data and content",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "license": "MIT",
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://github.com/YoshiokaY/astro-dev-mcp.git"
34
+ "url": "git+https://github.com/YoshiokaY/astro-dev-mcp.git"
35
35
  },
36
36
  "bugs": {
37
37
  "url": "https://github.com/YoshiokaY/astro-dev-mcp/issues"