@jsswift/knowledge-mcp 0.1.0 → 0.1.2
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 +14 -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
|
}
|
|
@@ -141,8 +153,8 @@ function parseArgs(args) {
|
|
|
141
153
|
var options = parseArgs(process.argv.slice(2));
|
|
142
154
|
var context = options.docs ? { project: options.project, version: "development", docsRoot: options.docs } : await resolveProject(options.project);
|
|
143
155
|
var knowledge = await loadKnowledge(context.docsRoot);
|
|
144
|
-
var server = new McpServer({ name: "jsswift-knowledge", version: "0.1.
|
|
145
|
-
instructions: `Serving JSswift ${context.version} from project ${context.project}. Prefer _.Button for buttons. Use _.Component and _.signal, _.effect, _.computed, _.untracked, _.batch.
|
|
156
|
+
var server = new McpServer({ name: "jsswift-knowledge", version: "0.1.2" }, {
|
|
157
|
+
instructions: `Serving JSswift ${context.version} from project ${context.project}. Prefer _.Button for buttons. Use _.Component and _.signal, _.effect, _.computed, _.untracked, _.batch. 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
158
|
});
|
|
147
159
|
var annotations = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
148
160
|
var jsonResult = (value) => ({ content: [{ type: "text", text: JSON.stringify(value) }], structuredContent: value });
|