@punica/components-mcp 0.8.0 → 0.9.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/bundled.json CHANGED
@@ -1 +1 @@
1
- {"version":"2.6.0"}
1
+ {"version":"2.6.1"}
package/dist/server.mjs CHANGED
@@ -265,7 +265,7 @@ function createKnowledge(manifest2) {
265
265
  const typed = new Set(words.filter((w) => w.weight === 1).map((w) => w.word.replace(/s$/, "")));
266
266
  if (tagWords.every((t) => typed.has(t.replace(/s$/, "")))) score += 5 * tagWords.length;
267
267
  const part = /^(?:the |one |a |an )?[^.]*?\b(?:of|in|for|inside) (?:a|an|the) `punica-/i.test(firstSentence(element.description)) ? 4 : 0;
268
- scored.push({ tag: element.tag, description: firstSentence(element.description), functions: element.functions.map((f) => f.name), score: score - part - tagWords.length * 0.1 });
268
+ scored.push({ tag: element.tag, description: firstSentence(element.description), functions: element.functions.map((f) => f.name), signatures: element.functions.map((f) => f.signature), score: score - part - tagWords.length * 0.1 });
269
269
  }
270
270
  return scored.sort((a, b) => b.score - a.score).slice(0, limit);
271
271
  }
@@ -291,6 +291,7 @@ function createKnowledge(manifest2) {
291
291
  for (const f of e.functions) lines.push("", "```ts", f.signature, "```", "", f.description);
292
292
  }
293
293
  table("Events", ["Event", "Detail", "Description"], e.events.map((ev) => [`\`${ev.name}\``, ev.detail ? `\`${ev.detail}\`` : "", ev.description]));
294
+ lines.push("", "### In React (JSX)", "", ...jsx(e));
294
295
  table("Slots", ["Slot", "Description"], e.slots.map((s) => [s.name ? `\`${s.name}\`` : "(default)", s.description]));
295
296
  if (!brief) {
296
297
  table("CSS parts", ["Part", "Description"], e.parts.map((p) => [`\`${p.name}\``, p.description]));
@@ -306,6 +307,22 @@ function createKnowledge(manifest2) {
306
307
  }
307
308
  return { elements, tags, allEvents, icons: icons2, list, get, search, legacy, formatMarkdown };
308
309
  }
310
+ function jsx(e) {
311
+ const out = [
312
+ "`import type {} from '@punica/components/react';` once, in the entry file, types every punica-* tag in JSX (React 18 and 19)."
313
+ ];
314
+ const dashed = e.attributes.find((a) => a.name.includes("-"));
315
+ const spelled = dashed ? ` (\`${dashed.name}\` or, in React 19, \`${dashed.name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())}\`)` : "";
316
+ out.push(`Attributes are props under their own name${spelled}; \`class\` works as well as \`className\`.`);
317
+ const ev = e.events.find((x) => x.detail) || e.events[0];
318
+ if (ev) {
319
+ const read = ev.detail ? /\bvalue\??:/.test(ev.detail) ? "setValue(event.detail.value)" : "handle(event.detail)" : "handle(event)";
320
+ out.push(
321
+ `Events are \`on\` + the event name, the handler typed with the detail: \`<${e.tag} on${ev.name}={(event) => ${read}} />\`${ev.detail ? `, \`event\` a \`CustomEvent<${ev.detail}>\`` : ""}. \`onChange\`/\`onInput\` never fire. React 18 does not wire custom events: listen through a ref.`
322
+ );
323
+ }
324
+ return [out.join(" ")];
325
+ }
309
326
  function normalizeTag(tag) {
310
327
  const t = String(tag).trim().toLowerCase().replace(/^<|\/?>$/g, "");
311
328
  return t.startsWith("punica-") ? t : `punica-${t}`;
@@ -730,7 +747,7 @@ function createPunicaServer({ manifest: manifest2, guide: guide2, version: versi
730
747
  async ({ query, limit }) => {
731
748
  const results = knowledge.search(query, limit || 10);
732
749
  if (!results.length) return text(`Nothing matches "${query}". Elements: ${knowledge.tags.join(", ")}`);
733
- const also = (r) => r.functions?.length ? ` Script: ${r.functions.map((name) => `\`${name}()\``).join(", ")} from '@punica/components'.` : "";
750
+ const also = (r) => r.signatures?.length ? ` Script: \`import { ${r.functions.join(", ")} } from '@punica/components'\`; ${r.signatures.map((s) => `\`${s}\``).join("; ")}.` : "";
734
751
  return text(results.map((r) => `${r.tag}: ${r.description}${also(r)}`).join("\n"));
735
752
  }
736
753
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/components-mcp",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "MCP server for @punica/components: find elements, read their API and examples, validate markup.",
5
5
  "keywords": [
6
6
  "mcp",