@likec4/language-server 1.37.0 → 1.38.1
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/LikeC4LanguageServices.d.ts +8 -4
- package/dist/LikeC4LanguageServices.js +12 -2
- package/dist/Rpc.js +2 -2
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/bundled.mjs +4259 -3106
- package/dist/empty.d.ts +2 -0
- package/dist/empty.js +1 -0
- package/dist/filesystem/ChokidarWatcher.d.ts +14 -0
- package/dist/filesystem/ChokidarWatcher.js +64 -0
- package/dist/filesystem/FileSystemWatcher.d.ts +19 -0
- package/dist/filesystem/FileSystemWatcher.js +11 -0
- package/dist/filesystem/LikeC4FileSystem.d.ts +5 -0
- package/dist/filesystem/LikeC4FileSystem.js +56 -0
- package/dist/filesystem/index.d.ts +20 -0
- package/dist/filesystem/index.js +16 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.js +23 -10
- package/dist/mcp/{sseserver/MCPServerFactory.d.ts → MCPServerFactory.d.ts} +1 -1
- package/dist/mcp/MCPServerFactory.js +69 -0
- package/dist/mcp/NoopLikeC4MCPServer.d.ts +4 -10
- package/dist/mcp/NoopLikeC4MCPServer.js +5 -10
- package/dist/mcp/interfaces.d.ts +7 -5
- package/dist/mcp/interfaces.js +4 -0
- package/dist/mcp/server/StdioLikeC4MCPServer.d.ts +16 -0
- package/dist/mcp/server/StdioLikeC4MCPServer.js +43 -0
- package/dist/mcp/{sseserver/MCPServer.d.ts → server/StreamableLikeC4MCPServer.d.ts} +3 -2
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +156 -0
- package/dist/mcp/server/WithMCPServer.d.ts +2 -0
- package/dist/mcp/server/WithMCPServer.js +57 -0
- package/dist/mcp/tools/_common.d.ts +24 -5
- package/dist/mcp/tools/_common.js +31 -3
- package/dist/mcp/tools/find-relationships.d.ts +13 -0
- package/dist/mcp/tools/find-relationships.js +151 -0
- package/dist/mcp/tools/list-projects.js +40 -12
- package/dist/mcp/tools/open-view.d.ts +4 -3
- package/dist/mcp/tools/open-view.js +37 -14
- package/dist/mcp/tools/{read-project-elements.d.ts → read-deployment.d.ts} +6 -3
- package/dist/mcp/tools/read-deployment.js +130 -0
- package/dist/mcp/tools/read-element.d.ts +4 -3
- package/dist/mcp/tools/read-element.js +114 -51
- package/dist/mcp/tools/read-project-summary.d.ts +3 -2
- package/dist/mcp/tools/read-project-summary.js +139 -32
- package/dist/mcp/tools/read-view.d.ts +4 -3
- package/dist/mcp/tools/read-view.js +146 -105
- package/dist/mcp/tools/search-element.js +81 -30
- package/dist/mcp/utils.js +7 -4
- package/dist/model/builder/MergedSpecification.d.ts +1 -1
- package/dist/model/builder/buildModel.d.ts +1 -1
- package/dist/module.d.ts +9 -9
- package/dist/module.js +24 -29
- package/dist/protocol.d.ts +1 -1
- package/dist/protocol.js +1 -1
- package/dist/test/testServices.js +3 -2
- package/dist/workspace/LangiumDocuments.d.ts +4 -1
- package/dist/workspace/LangiumDocuments.js +15 -0
- package/dist/workspace/ProjectsManager.d.ts +1 -1
- package/dist/workspace/ProjectsManager.js +18 -19
- package/dist/workspace/WorkspaceManager.d.ts +9 -2
- package/dist/workspace/WorkspaceManager.js +30 -39
- package/package.json +16 -12
- package/dist/LikeC4FileSystem.d.ts +0 -14
- package/dist/LikeC4FileSystem.js +0 -39
- package/dist/mcp/sseserver/MCPServer.js +0 -80
- package/dist/mcp/sseserver/MCPServerFactory.js +0 -50
- package/dist/mcp/sseserver/WithMCPServer.d.ts +0 -9
- package/dist/mcp/sseserver/WithMCPServer.js +0 -53
- package/dist/mcp/tools/read-project-elements.js +0 -93
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LikeC4Services } from '../../module';
|
|
2
|
-
import type { LikeC4MCPServer } from '../interfaces';
|
|
3
|
-
import { LikeC4MCPServerFactory } from './MCPServerFactory';
|
|
4
|
-
export declare const WithMCPServer: {
|
|
5
|
-
mcp: {
|
|
6
|
-
Server(services: LikeC4Services): LikeC4MCPServer;
|
|
7
|
-
ServerFactory(services: LikeC4Services): LikeC4MCPServerFactory;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { loggable } from "@likec4/log";
|
|
2
|
-
import { isError } from "remeda";
|
|
3
|
-
import { logger } from "../../logger.js";
|
|
4
|
-
import { SSELikeC4MCPServer } from "./MCPServer.js";
|
|
5
|
-
import { LikeC4MCPServerFactory } from "./MCPServerFactory.js";
|
|
6
|
-
export const WithMCPServer = {
|
|
7
|
-
mcp: {
|
|
8
|
-
Server(services) {
|
|
9
|
-
logger.debug("Creating SSELikeC4MCPServer");
|
|
10
|
-
const server = new SSELikeC4MCPServer(services);
|
|
11
|
-
const langId = services.LanguageMetaData.languageId;
|
|
12
|
-
const connection = services.shared.lsp.Connection;
|
|
13
|
-
services.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate((update) => {
|
|
14
|
-
if (update.section !== langId) {
|
|
15
|
-
logger.warn("Unexpected configuration update: {update}", { update });
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
logger.debug("Configuration update: {update}", { update });
|
|
19
|
-
const {
|
|
20
|
-
enabled = false,
|
|
21
|
-
port = 33335
|
|
22
|
-
} = update.configuration.mcp;
|
|
23
|
-
if (!enabled) {
|
|
24
|
-
server.stop();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
Promise.resolve().then(() => server.start(port)).then(() => {
|
|
28
|
-
connection?.telemetry?.logEvent({
|
|
29
|
-
eventName: "mcp-server-started",
|
|
30
|
-
mcpPort: port
|
|
31
|
-
});
|
|
32
|
-
}).catch((err) => {
|
|
33
|
-
const message = isError(err) ? err.message : void 0;
|
|
34
|
-
connection?.telemetry?.logEvent({
|
|
35
|
-
eventName: "mcp-server-start-failed",
|
|
36
|
-
mcpPort: port,
|
|
37
|
-
...message && { message }
|
|
38
|
-
});
|
|
39
|
-
logger.error("Failed to start LikeC4 MCP Server", { err });
|
|
40
|
-
if (connection) {
|
|
41
|
-
connection.window.showErrorMessage(`LikeC4: Failed to start MCP Server
|
|
42
|
-
|
|
43
|
-
${loggable(err)}`);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
return server;
|
|
48
|
-
},
|
|
49
|
-
ServerFactory(services) {
|
|
50
|
-
return new LikeC4MCPServerFactory(services);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { invariant } from "@likec4/core";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { safeCall } from "../../utils/index.js";
|
|
4
|
-
import { ProjectsManager } from "../../workspace/index.js";
|
|
5
|
-
import { likec4Tool } from "../utils.js";
|
|
6
|
-
import { locationSchema } from "./_common.js";
|
|
7
|
-
const elementSchema = z.array(
|
|
8
|
-
z.discriminatedUnion("type", [
|
|
9
|
-
z.object({
|
|
10
|
-
type: z.literal("logical"),
|
|
11
|
-
id: z.string().describe("Element ID (FQN)"),
|
|
12
|
-
kind: z.string(),
|
|
13
|
-
title: z.string(),
|
|
14
|
-
description: z.string().nullish(),
|
|
15
|
-
technology: z.string().nullish(),
|
|
16
|
-
shape: z.string(),
|
|
17
|
-
tags: z.array(z.string()),
|
|
18
|
-
defaultView: z.string().nullish().describe("Name of the default view of this element"),
|
|
19
|
-
sourceLocation: locationSchema.nullish()
|
|
20
|
-
}),
|
|
21
|
-
z.object({
|
|
22
|
-
type: z.literal("deployment-node"),
|
|
23
|
-
id: z.string().describe("Deployment ID (FQN)"),
|
|
24
|
-
kind: z.string(),
|
|
25
|
-
title: z.string(),
|
|
26
|
-
description: z.string().nullish(),
|
|
27
|
-
technology: z.string().nullish(),
|
|
28
|
-
shape: z.string(),
|
|
29
|
-
tags: z.array(z.string()),
|
|
30
|
-
defaultView: z.string().nullish().describe("Name of the default view of this element"),
|
|
31
|
-
sourceLocation: locationSchema.nullish()
|
|
32
|
-
})
|
|
33
|
-
])
|
|
34
|
-
);
|
|
35
|
-
export const readProjectElements = likec4Tool({
|
|
36
|
-
name: "read-project-elements",
|
|
37
|
-
annotations: {
|
|
38
|
-
readOnlyHint: true
|
|
39
|
-
},
|
|
40
|
-
description: `
|
|
41
|
-
Returns array of all elements in the project:
|
|
42
|
-
- type (logical or deployment-node)
|
|
43
|
-
- id (FQN)
|
|
44
|
-
- kind
|
|
45
|
-
- title, description and technology
|
|
46
|
-
- shape
|
|
47
|
-
- assigned tags
|
|
48
|
-
- name of the default view of this element if any (applies to logical elements only)
|
|
49
|
-
- source location (where the element is defined, if running in the editor)
|
|
50
|
-
`,
|
|
51
|
-
inputSchema: {
|
|
52
|
-
project: z.string().optional().describe('Project name (optional, will use "default" if not specified)')
|
|
53
|
-
},
|
|
54
|
-
outputSchema: {
|
|
55
|
-
elements: elementSchema
|
|
56
|
-
}
|
|
57
|
-
}, async (languageServices, args) => {
|
|
58
|
-
const projectId = args.project ?? ProjectsManager.DefaultProjectId;
|
|
59
|
-
const project = languageServices.projects().find((p) => p.id === projectId);
|
|
60
|
-
invariant(project, `Project "${projectId}" not found`);
|
|
61
|
-
const model = await languageServices.computedModel(project.id);
|
|
62
|
-
const elements = [];
|
|
63
|
-
for (const el of model.elements()) {
|
|
64
|
-
elements.push({
|
|
65
|
-
type: "logical",
|
|
66
|
-
id: el.id,
|
|
67
|
-
title: el.title,
|
|
68
|
-
description: el.description.text,
|
|
69
|
-
technology: el.technology,
|
|
70
|
-
kind: el.kind,
|
|
71
|
-
tags: [...el.tags],
|
|
72
|
-
shape: el.shape,
|
|
73
|
-
defaultView: el.defaultView?.id,
|
|
74
|
-
sourceLocation: safeCall(() => languageServices.locate({ element: el.id, projectId }))
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
for (const el of model.deployment.nodes()) {
|
|
78
|
-
elements.push({
|
|
79
|
-
type: "deployment-node",
|
|
80
|
-
id: el.id,
|
|
81
|
-
title: el.title,
|
|
82
|
-
description: el.description.text,
|
|
83
|
-
technology: el.technology,
|
|
84
|
-
kind: el.kind,
|
|
85
|
-
tags: [...el.tags],
|
|
86
|
-
shape: el.shape,
|
|
87
|
-
sourceLocation: safeCall(() => languageServices.locate({ deployment: el.id, projectId }))
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
elements
|
|
92
|
-
};
|
|
93
|
-
});
|