@punica/components-mcp 0.6.0 → 0.8.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/server.mjs CHANGED
@@ -177,7 +177,7 @@ function normalize(declaration, path) {
177
177
  signature: `${m.name}(${(m.parameters || []).map((p) => p.name + (p.optional ? "?" : "")).join(", ")})`,
178
178
  description: m.description
179
179
  })),
180
- events: (d.events || []).filter((e) => e.name).map((e) => ({ name: e.name, description: e.description || "" })),
180
+ events: (d.events || []).filter((e) => e.name).map((e) => ({ name: e.name, detail: e.type?.text || "", description: e.description || "" })),
181
181
  slots: (d.slots || []).map((s) => ({ name: s.name || "", description: s.description || "" })),
182
182
  // Attributes the element reads off its children, as its slot docs say:
183
183
  // "Each may carry `span`".
@@ -251,7 +251,7 @@ function createKnowledge(manifest2) {
251
251
  for (const element of elements.values()) {
252
252
  const tagWords = element.tag.replace(/^punica-/, "").split("-");
253
253
  const text2 = element.description.toLowerCase();
254
- const api = [...element.attributes.map((a) => a.name), ...element.events.map((e) => e.name), ...element.slots.map((s) => s.name)].join(" ");
254
+ const api = [...element.attributes.map((a) => a.name), ...element.events.map((e) => e.name), ...element.slots.map((s) => s.name), ...element.functions.map((f) => f.name.toLowerCase())].join(" ");
255
255
  let score = 0;
256
256
  for (const { word, weight } of words) {
257
257
  let s = 0;
@@ -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), score: score - part - tagWords.length * 0.1 });
268
+ scored.push({ tag: element.tag, description: firstSentence(element.description), functions: element.functions.map((f) => f.name), 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
  }
@@ -290,7 +290,7 @@ function createKnowledge(manifest2) {
290
290
  lines.push("", "### Functions", "", `\`import { ${e.functions.map((f) => f.name).join(", ")} } from '@punica/components';\``);
291
291
  for (const f of e.functions) lines.push("", "```ts", f.signature, "```", "", f.description);
292
292
  }
293
- table("Events", ["Event", "Description"], e.events.map((ev) => [`\`${ev.name}\``, ev.description]));
293
+ table("Events", ["Event", "Detail", "Description"], e.events.map((ev) => [`\`${ev.name}\``, ev.detail ? `\`${ev.detail}\`` : "", ev.description]));
294
294
  table("Slots", ["Slot", "Description"], e.slots.map((s) => [s.name ? `\`${s.name}\`` : "(default)", s.description]));
295
295
  if (!brief) {
296
296
  table("CSS parts", ["Part", "Description"], e.parts.map((p) => [`\`${p.name}\``, p.description]));
@@ -730,7 +730,8 @@ function createPunicaServer({ manifest: manifest2, guide: guide2, version: versi
730
730
  async ({ query, limit }) => {
731
731
  const results = knowledge.search(query, limit || 10);
732
732
  if (!results.length) return text(`Nothing matches "${query}". Elements: ${knowledge.tags.join(", ")}`);
733
- return text(results.map((r) => `${r.tag}: ${r.description}`).join("\n"));
733
+ const also = (r) => r.functions?.length ? ` Script: ${r.functions.map((name) => `\`${name}()\``).join(", ")} from '@punica/components'.` : "";
734
+ return text(results.map((r) => `${r.tag}: ${r.description}${also(r)}`).join("\n"));
734
735
  }
735
736
  );
736
737
  server2.registerTool(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/components-mcp",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "MCP server for @punica/components: find elements, read their API and examples, validate markup.",
5
5
  "keywords": [
6
6
  "mcp",