semantic-js-mcp 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/.codex-plugin/plugin.json +25 -0
- package/.mcp.json +12 -0
- package/.prettierrc.json +9 -0
- package/CHANGELOG.md +29 -0
- package/CONTRIBUTING.md +64 -0
- package/LICENSE +21 -0
- package/README.md +278 -0
- package/ROADMAP.md +37 -0
- package/SECURITY.md +22 -0
- package/cli.mjs +45 -0
- package/docs/architecture-decisions.md +72 -0
- package/docs/distribution.md +54 -0
- package/lib/doctor.mjs +319 -0
- package/lib/runtime.mjs +69 -0
- package/package.json +70 -0
- package/protocol.mjs +356 -0
- package/scripts/benchmark.mjs +88 -0
- package/scripts/check-protocol-literals.mjs +126 -0
- package/scripts/check-runtime.mjs +32 -0
- package/scripts/ci-smoke.mjs +147 -0
- package/scripts/distribution-policy.mjs +33 -0
- package/scripts/distribution-smoke.mjs +128 -0
- package/scripts/generate-protocol-reference.mjs +154 -0
- package/scripts/semantic-js-mcp-ci.mjs +122 -0
- package/scripts/smoke.mjs +686 -0
- package/scripts/vue-smoke.mjs +82 -0
- package/server.mjs +2702 -0
- package/skills/semantic-navigation/SKILL.md +125 -0
- package/skills/semantic-navigation/agents/openai.yaml +4 -0
- package/skills/semantic-navigation/references/protocol-literals.md +381 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {deepStrictEqual} from "node:assert";
|
|
5
|
+
import {mkdtemp, mkdir, rm, writeFile} from "node:fs/promises";
|
|
6
|
+
import {tmpdir} from "node:os";
|
|
7
|
+
import {fileURLToPath} from "node:url";
|
|
8
|
+
import {Client} from "@modelcontextprotocol/sdk/client/index.js";
|
|
9
|
+
import {StdioClientTransport} from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
10
|
+
import {parse as parseYaml} from "yaml";
|
|
11
|
+
import {DEFINITION_RESOLUTION_METHOD, TOOL} from "../protocol.mjs";
|
|
12
|
+
|
|
13
|
+
const pluginRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
14
|
+
const workspace = await mkdtemp(path.join(tmpdir(), "semantic-js-mcp-vue-smoke-"));
|
|
15
|
+
const src = path.join(workspace, "src");
|
|
16
|
+
const component = path.join(src, "CounterPanel.vue");
|
|
17
|
+
const childComponent = path.join(src, "ChildPanel.vue");
|
|
18
|
+
await mkdir(src, {recursive: true});
|
|
19
|
+
await writeFile(path.join(workspace, "package.json"), JSON.stringify({private: true, type: "module"}));
|
|
20
|
+
await writeFile(
|
|
21
|
+
path.join(workspace, "tsconfig.json"),
|
|
22
|
+
JSON.stringify({
|
|
23
|
+
compilerOptions: {strict: true, target: "ES2022", module: "ESNext", moduleResolution: "Bundler"},
|
|
24
|
+
include: ["src/**/*.vue"],
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
await writeFile(
|
|
28
|
+
childComponent,
|
|
29
|
+
['<script setup lang="ts">', "defineProps<{label: string}>();", "</script>", "<template><span>{{ label }}</span></template>"].join("\n"),
|
|
30
|
+
);
|
|
31
|
+
await writeFile(
|
|
32
|
+
component,
|
|
33
|
+
[
|
|
34
|
+
'<script setup lang="ts">',
|
|
35
|
+
'import ChildPanel from "./ChildPanel.vue";',
|
|
36
|
+
"const count = 0;",
|
|
37
|
+
"function increment(value: number): number {",
|
|
38
|
+
" return value + 1;",
|
|
39
|
+
"}",
|
|
40
|
+
"const nextCount = increment(count);",
|
|
41
|
+
"</script>",
|
|
42
|
+
"<template>",
|
|
43
|
+
' <ChildPanel label="Count" />',
|
|
44
|
+
" <button>{{ nextCount }}</button>",
|
|
45
|
+
"</template>",
|
|
46
|
+
].join("\n"),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const client = new Client({name: "semantic-js-mcp-vue-smoke", version: "1.0.0"});
|
|
50
|
+
const transport = new StdioClientTransport({command: process.execPath, args: [path.join(pluginRoot, "server.mjs")], cwd: pluginRoot});
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
await client.connect(transport);
|
|
54
|
+
const response = await client.callTool({name: "lsp_document_symbols", arguments: {file: component}});
|
|
55
|
+
if (response.isError) throw new Error(response.content?.[0]?.text || "Vue document symbols failed");
|
|
56
|
+
const yaml = response.content?.find((item) => item.type === "text")?.text || "";
|
|
57
|
+
deepStrictEqual(parseYaml(yaml), response.structuredContent, "Vue YAML and structured JSON differ");
|
|
58
|
+
const names = response.structuredContent?.result?.symbols?.map((symbol) => symbol.name) || [];
|
|
59
|
+
if (!names.includes("increment") || !names.includes("nextCount")) {
|
|
60
|
+
throw new Error(`Expected Vue script symbols were not returned: ${names.join(", ")}`);
|
|
61
|
+
}
|
|
62
|
+
const definition = await client.callTool({
|
|
63
|
+
name: TOOL.DEFINITION,
|
|
64
|
+
arguments: {file: component, root: workspace, line: 10, column: 4},
|
|
65
|
+
});
|
|
66
|
+
if (definition.isError) throw new Error(definition.content?.[0]?.text || "Vue template component definition failed");
|
|
67
|
+
const supportedMethods = new Set([
|
|
68
|
+
DEFINITION_RESOLUTION_METHOD.LANGUAGE_SERVER,
|
|
69
|
+
DEFINITION_RESOLUTION_METHOD.TYPESCRIPT_SERVER,
|
|
70
|
+
DEFINITION_RESOLUTION_METHOD.VUE_TEMPLATE_IMPORT_BINDING,
|
|
71
|
+
]);
|
|
72
|
+
if (!supportedMethods.has(definition.structuredContent?.result?.resolutionMethod)) {
|
|
73
|
+
throw new Error(`Vue template component used the wrong resolution method: ${definition.structuredContent?.result?.resolutionMethod}`);
|
|
74
|
+
}
|
|
75
|
+
if (!definition.structuredContent?.result?.definitions?.some((item) => path.basename(item.file) === path.basename(childComponent))) {
|
|
76
|
+
throw new Error("Vue template component did not resolve to the imported SFC");
|
|
77
|
+
}
|
|
78
|
+
console.log(JSON.stringify({vueDocumentSymbols: "ok", vueTemplateComponentDefinition: "ok", yamlRepresentation: "ok"}, null, 2));
|
|
79
|
+
} finally {
|
|
80
|
+
await client.close().catch(() => undefined);
|
|
81
|
+
await rm(workspace, {recursive: true, force: true});
|
|
82
|
+
}
|