@jsswift/knowledge-mcp 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/server.mjs +23 -3
  2. package/package.json +1 -1
package/dist/server.mjs CHANGED
@@ -65,6 +65,18 @@ async function loadKnowledge(root = defaultRoot) {
65
65
  const block = text.match(/```json\s*([\s\S]*?)```/);
66
66
  if (!block) throw new Error(`Missing component metadata: ${entry.path}`);
67
67
  const metadata = JSON.parse(block[1]);
68
+ if (metadata.commonProps) {
69
+ const shared = metadata.commonProps;
70
+ if (!Array.isArray(shared.keys) || shared.keys.some((key) => typeof key !== "string") || !entries.has(`guide:${String(shared.path).replace(/\.md$/, "")}`)) {
71
+ throw new Error(`Invalid common props reference: ${entry.path}`);
72
+ }
73
+ const sharedText = await readFile(await safePath(shared.path), "utf8");
74
+ const sharedBlock = sharedText.match(/```json\s*([\s\S]*?)```/);
75
+ const sharedMetadata = sharedBlock ? JSON.parse(sharedBlock[1]) : null;
76
+ if (shared.keys.some((key) => !Object.hasOwn(sharedMetadata?.props ?? {}, key) || Object.hasOwn(metadata.props ?? {}, key))) {
77
+ throw new Error(`Invalid inherited property: ${entry.path}`);
78
+ }
79
+ }
68
80
  if (!metadata.signature?.startsWith(`_.${entry.title}(`) || !entry.keywords.includes(`_.${entry.title}`) || entry.keywords.some((word) => word.startsWith("JSswift."))) {
69
81
  throw new Error(`Noncanonical application API: ${entry.path}; use _.${entry.title}`);
70
82
  }
@@ -73,7 +85,15 @@ async function loadKnowledge(root = defaultRoot) {
73
85
  }
74
86
  }
75
87
  }
76
- const files = (await readdir(path.join(docsRoot, "components"))).filter((name) => name.endsWith(".md") && name !== "README.md");
88
+ const aliases = map.documentAliases ?? {};
89
+ for (const [alias, target] of Object.entries(aliases)) {
90
+ if (!alias.endsWith(".md") || !map.components.some((component) => component.path === target)) {
91
+ throw new Error("Invalid documentation alias");
92
+ }
93
+ await safePath(alias);
94
+ await safePath(target);
95
+ }
96
+ const files = (await readdir(path.join(docsRoot, "components"))).filter((name) => name.endsWith(".md") && name !== "README.md" && !Object.hasOwn(aliases, `components/${name}`));
77
97
  const indexed = new Set(map.components.map((component) => component.path));
78
98
  if (files.length !== indexed.size || files.some((name) => !indexed.has(`components/${name}`))) {
79
99
  throw new Error("Component map coverage mismatch; run npm run knowledge:refresh");
@@ -141,8 +161,8 @@ function parseArgs(args) {
141
161
  var options = parseArgs(process.argv.slice(2));
142
162
  var context = options.docs ? { project: options.project, version: "development", docsRoot: options.docs } : await resolveProject(options.project);
143
163
  var knowledge = await loadKnowledge(context.docsRoot);
144
- var server = new McpServer({ name: "jsswift-knowledge", version: "0.1.1" }, {
145
- instructions: `Serving JSswift ${context.version} from project ${context.project}. Prefer _.Button for buttons. Use _.Component and _.signal, _.effect, _.computed, _.untracked, _.batch. Search for the feature and read selected contracts before coding. JSswift includes component CSS; read application-rules and prefer documented styling props and theme variables before custom overrides. Fonts and the Tabler catalog are optional; read getting-started for imports. This server covers application development only.`
164
+ var server = new McpServer({ name: "jsswift-knowledge", version: "0.1.2" }, {
165
+ instructions: `Serving JSswift ${context.version} from project ${context.project}. Prefer _.Button for buttons. Use _.Component; prefer _.rod for bidirectional field models and _.useForm for structured forms. Signals remain supported for getter/setter state. Start with guide:AI for a basic page and its supported examples. Search and read component contracts only for additional APIs; read guide:ui/common-props once when styling. JSswift includes component CSS; read application-rules and prefer documented styling props and theme variables before custom overrides. Fonts and the Tabler catalog are optional; read getting-started for imports. This server covers application development only.`
146
166
  });
147
167
  var annotations = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
148
168
  var jsonResult = (value) => ({ content: [{ type: "text", text: JSON.stringify(value) }], structuredContent: value });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsswift/knowledge-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Read-only MCP for the installed JSswift version's documentation",
5
5
  "type": "module",
6
6
  "engines": {