brs-claude 1.0.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/index.d.ts +2 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/lsp-client.d.ts +37 -0
- package/dist/lsp-client.js +374 -0
- package/dist/lsp-client.js.map +1 -0
- package/dist/tools.d.ts +39 -0
- package/dist/tools.js +211 -0
- package/dist/tools.js.map +1 -0
- package/package.json +32 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
|
+
const lsp_client_js_1 = require("./lsp-client.js");
|
|
8
|
+
const tools_js_1 = require("./tools.js");
|
|
9
|
+
function log(message) {
|
|
10
|
+
process.stderr.write(`[brs-claude] ${message}\n`);
|
|
11
|
+
}
|
|
12
|
+
async function main() {
|
|
13
|
+
log("Starting BrighterScript MCP server...");
|
|
14
|
+
const lspClient = new lsp_client_js_1.LspClient();
|
|
15
|
+
const server = new index_js_1.Server({ name: "brighterscript", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
16
|
+
// List tools handler
|
|
17
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
18
|
+
return { tools: tools_js_1.toolDefinitions };
|
|
19
|
+
});
|
|
20
|
+
// Call tool handler
|
|
21
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
22
|
+
const { name, arguments: args } = request.params;
|
|
23
|
+
const result = await (0, tools_js_1.handleToolCall)(lspClient, name, args || {});
|
|
24
|
+
return { content: [{ type: "text", text: result }] };
|
|
25
|
+
});
|
|
26
|
+
// LSP client starts lazily on first tool call via ensureRunning()
|
|
27
|
+
// Connect MCP server to stdio transport
|
|
28
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
29
|
+
await server.connect(transport);
|
|
30
|
+
log("MCP server connected via stdio");
|
|
31
|
+
// Handle shutdown
|
|
32
|
+
process.on("SIGINT", async () => {
|
|
33
|
+
log("Shutting down...");
|
|
34
|
+
await lspClient.stop();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
});
|
|
37
|
+
process.on("SIGTERM", async () => {
|
|
38
|
+
log("Shutting down...");
|
|
39
|
+
await lspClient.stop();
|
|
40
|
+
process.exit(0);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
main().catch((err) => {
|
|
44
|
+
process.stderr.write(`[brs-claude] Fatal error: ${err}\n`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,wEAAmE;AACnE,wEAAiF;AACjF,iEAG4C;AAC5C,mDAA4C;AAC5C,yCAA6D;AAE7D,SAAS,GAAG,CAAC,OAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,OAAO,IAAI,CAAC,CAAC;AACpD,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,GAAG,CAAC,uCAAuC,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAG,IAAI,yBAAS,EAAE,CAAC;IAElC,MAAM,MAAM,GAAG,IAAI,iBAAM,CACvB,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC5C,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAChC,CAAC;IAEF,qBAAqB;IACrB,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAA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C,6BAA6B,GAAG,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { Hover, Location, LocationLink, Diagnostic } from "vscode-languageserver-protocol";
|
|
3
|
+
export declare class LspClient extends EventEmitter {
|
|
4
|
+
private process;
|
|
5
|
+
private nextId;
|
|
6
|
+
private pendingRequests;
|
|
7
|
+
private buffer;
|
|
8
|
+
private contentLength;
|
|
9
|
+
private initialized;
|
|
10
|
+
private diagnosticsMap;
|
|
11
|
+
private workspaceRoot;
|
|
12
|
+
/**
|
|
13
|
+
* Find the nearest bsconfig.json by walking up from the given file path.
|
|
14
|
+
* Returns the directory containing bsconfig.json, or the file's directory as fallback.
|
|
15
|
+
*/
|
|
16
|
+
static findWorkspaceRoot(filePath: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Ensure the LSP is running with the correct workspace root for the given file.
|
|
19
|
+
* Restarts the LSP if the workspace root has changed.
|
|
20
|
+
*/
|
|
21
|
+
ensureRunning(filePath: string): Promise<void>;
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
private handleData;
|
|
24
|
+
private handleMessage;
|
|
25
|
+
private handleServerRequest;
|
|
26
|
+
private sendMessage;
|
|
27
|
+
private sendRequest;
|
|
28
|
+
private sendNotification;
|
|
29
|
+
private initialize;
|
|
30
|
+
openDocument(filePath: string): Promise<void>;
|
|
31
|
+
getDiagnostics(filePath: string): Promise<Diagnostic[]>;
|
|
32
|
+
getHover(filePath: string, line: number, character: number): Promise<Hover | null>;
|
|
33
|
+
getDefinition(filePath: string, line: number, character: number): Promise<Location | Location[] | LocationLink[] | null>;
|
|
34
|
+
isReady(): boolean;
|
|
35
|
+
private log;
|
|
36
|
+
stop(): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.LspClient = void 0;
|
|
37
|
+
const child_process_1 = require("child_process");
|
|
38
|
+
const events_1 = require("events");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
class LspClient extends events_1.EventEmitter {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.process = null;
|
|
45
|
+
this.nextId = 1;
|
|
46
|
+
this.pendingRequests = new Map();
|
|
47
|
+
this.buffer = "";
|
|
48
|
+
this.contentLength = -1;
|
|
49
|
+
this.initialized = false;
|
|
50
|
+
this.diagnosticsMap = new Map();
|
|
51
|
+
this.workspaceRoot = null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Find the nearest bsconfig.json by walking up from the given file path.
|
|
55
|
+
* Returns the directory containing bsconfig.json, or the file's directory as fallback.
|
|
56
|
+
*/
|
|
57
|
+
static findWorkspaceRoot(filePath) {
|
|
58
|
+
let dir = path.dirname(path.resolve(filePath));
|
|
59
|
+
const root = path.parse(dir).root;
|
|
60
|
+
while (dir !== root) {
|
|
61
|
+
if (fs.existsSync(path.join(dir, "bsconfig.json"))) {
|
|
62
|
+
return dir;
|
|
63
|
+
}
|
|
64
|
+
dir = path.dirname(dir);
|
|
65
|
+
}
|
|
66
|
+
// Fallback: use the file's directory
|
|
67
|
+
return path.dirname(path.resolve(filePath));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Ensure the LSP is running with the correct workspace root for the given file.
|
|
71
|
+
* Restarts the LSP if the workspace root has changed.
|
|
72
|
+
*/
|
|
73
|
+
async ensureRunning(filePath) {
|
|
74
|
+
const newRoot = LspClient.findWorkspaceRoot(filePath);
|
|
75
|
+
if (this.initialized && this.workspaceRoot === newRoot) {
|
|
76
|
+
return; // Already running with correct workspace
|
|
77
|
+
}
|
|
78
|
+
if (this.process) {
|
|
79
|
+
this.log(`Workspace root changed: ${this.workspaceRoot} -> ${newRoot}`);
|
|
80
|
+
await this.stop();
|
|
81
|
+
}
|
|
82
|
+
this.workspaceRoot = newRoot;
|
|
83
|
+
await this.start();
|
|
84
|
+
}
|
|
85
|
+
async start() {
|
|
86
|
+
if (!this.workspaceRoot) {
|
|
87
|
+
throw new Error("Workspace root not set. Call ensureRunning(filePath) instead.");
|
|
88
|
+
}
|
|
89
|
+
this.log(`Starting LSP server with: npx bsc --lsp --stdio`);
|
|
90
|
+
this.log(`Workspace root: ${this.workspaceRoot}`);
|
|
91
|
+
this.process = (0, child_process_1.spawn)("npx", ["bsc", "--lsp", "--stdio"], {
|
|
92
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
93
|
+
cwd: this.workspaceRoot,
|
|
94
|
+
});
|
|
95
|
+
this.process.stderr?.on("data", (data) => {
|
|
96
|
+
this.log(`[bsc stderr] ${data.toString().trim()}`);
|
|
97
|
+
});
|
|
98
|
+
this.process.on("error", (err) => {
|
|
99
|
+
this.log(`LSP process error: ${err.message}`);
|
|
100
|
+
this.emit("error", err);
|
|
101
|
+
});
|
|
102
|
+
this.process.on("exit", (code, signal) => {
|
|
103
|
+
this.log(`LSP process exited: code=${code}, signal=${signal}`);
|
|
104
|
+
this.initialized = false;
|
|
105
|
+
});
|
|
106
|
+
this.process.stdout?.on("data", (data) => {
|
|
107
|
+
this.handleData(data.toString());
|
|
108
|
+
});
|
|
109
|
+
await this.initialize();
|
|
110
|
+
}
|
|
111
|
+
handleData(data) {
|
|
112
|
+
this.buffer += data;
|
|
113
|
+
while (true) {
|
|
114
|
+
if (this.contentLength === -1) {
|
|
115
|
+
const headerEnd = this.buffer.indexOf("\r\n\r\n");
|
|
116
|
+
if (headerEnd === -1)
|
|
117
|
+
return;
|
|
118
|
+
const header = this.buffer.substring(0, headerEnd);
|
|
119
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
120
|
+
if (!match) {
|
|
121
|
+
this.log(`Invalid header: ${header}`);
|
|
122
|
+
this.buffer = this.buffer.substring(headerEnd + 4);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
this.contentLength = parseInt(match[1], 10);
|
|
126
|
+
this.buffer = this.buffer.substring(headerEnd + 4);
|
|
127
|
+
}
|
|
128
|
+
if (this.buffer.length < this.contentLength)
|
|
129
|
+
return;
|
|
130
|
+
const body = this.buffer.substring(0, this.contentLength);
|
|
131
|
+
this.buffer = this.buffer.substring(this.contentLength);
|
|
132
|
+
this.contentLength = -1;
|
|
133
|
+
try {
|
|
134
|
+
const message = JSON.parse(body);
|
|
135
|
+
this.handleMessage(message);
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
this.log(`Failed to parse message: ${err}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
handleMessage(message) {
|
|
143
|
+
// Response to a request we sent
|
|
144
|
+
if (message.id !== undefined && !message.method) {
|
|
145
|
+
const pending = this.pendingRequests.get(message.id);
|
|
146
|
+
if (pending) {
|
|
147
|
+
this.pendingRequests.delete(message.id);
|
|
148
|
+
if (message.error) {
|
|
149
|
+
pending.reject(new Error(`LSP error ${message.error.code}: ${message.error.message}`));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
pending.resolve(message.result);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// Server-initiated request (has both id and method)
|
|
158
|
+
if (message.id !== undefined && message.method) {
|
|
159
|
+
this.handleServerRequest(message);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// Notification from the server
|
|
163
|
+
if (message.method === "textDocument/publishDiagnostics") {
|
|
164
|
+
const params = message.params;
|
|
165
|
+
const uri = params.uri;
|
|
166
|
+
this.diagnosticsMap.set(uri, params.diagnostics);
|
|
167
|
+
this.emit("diagnostics", params);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
handleServerRequest(message) {
|
|
171
|
+
this.log(`Server request: ${message.method} (id=${message.id})`);
|
|
172
|
+
switch (message.method) {
|
|
173
|
+
case "workspace/workspaceFolders": {
|
|
174
|
+
const rootUri = `file://${this.workspaceRoot}`;
|
|
175
|
+
this.sendMessage({
|
|
176
|
+
jsonrpc: "2.0",
|
|
177
|
+
id: message.id,
|
|
178
|
+
result: [{ uri: rootUri, name: path.basename(this.workspaceRoot) }],
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "client/registerCapability": {
|
|
183
|
+
// Accept all dynamic registrations
|
|
184
|
+
this.sendMessage({
|
|
185
|
+
jsonrpc: "2.0",
|
|
186
|
+
id: message.id,
|
|
187
|
+
result: null,
|
|
188
|
+
});
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case "workspace/configuration": {
|
|
192
|
+
// Return empty config for each requested item
|
|
193
|
+
const items = message.params?.items || [];
|
|
194
|
+
this.sendMessage({
|
|
195
|
+
jsonrpc: "2.0",
|
|
196
|
+
id: message.id,
|
|
197
|
+
result: items.map(() => ({})),
|
|
198
|
+
});
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
default: {
|
|
202
|
+
this.log(`Unhandled server request: ${message.method}`);
|
|
203
|
+
this.sendMessage({
|
|
204
|
+
jsonrpc: "2.0",
|
|
205
|
+
id: message.id,
|
|
206
|
+
result: null,
|
|
207
|
+
});
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
sendMessage(message) {
|
|
213
|
+
if (!this.process?.stdin?.writable) {
|
|
214
|
+
throw new Error("LSP process is not running");
|
|
215
|
+
}
|
|
216
|
+
const body = JSON.stringify(message);
|
|
217
|
+
const header = `Content-Length: ${Buffer.byteLength(body)}\r\n\r\n`;
|
|
218
|
+
this.process.stdin.write(header + body);
|
|
219
|
+
}
|
|
220
|
+
sendRequest(method, params) {
|
|
221
|
+
const id = this.nextId++;
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
this.pendingRequests.set(id, { resolve, reject });
|
|
224
|
+
this.sendMessage({
|
|
225
|
+
jsonrpc: "2.0",
|
|
226
|
+
id,
|
|
227
|
+
method,
|
|
228
|
+
params,
|
|
229
|
+
});
|
|
230
|
+
// Timeout after 30 seconds
|
|
231
|
+
setTimeout(() => {
|
|
232
|
+
if (this.pendingRequests.has(id)) {
|
|
233
|
+
this.pendingRequests.delete(id);
|
|
234
|
+
reject(new Error(`LSP request ${method} timed out`));
|
|
235
|
+
}
|
|
236
|
+
}, 30000);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
sendNotification(method, params) {
|
|
240
|
+
this.sendMessage({
|
|
241
|
+
jsonrpc: "2.0",
|
|
242
|
+
method,
|
|
243
|
+
params,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
async initialize() {
|
|
247
|
+
const rootUri = `file://${this.workspaceRoot}`;
|
|
248
|
+
const params = {
|
|
249
|
+
processId: process.pid,
|
|
250
|
+
capabilities: {
|
|
251
|
+
textDocument: {
|
|
252
|
+
synchronization: {
|
|
253
|
+
dynamicRegistration: false,
|
|
254
|
+
willSave: false,
|
|
255
|
+
willSaveWaitUntil: false,
|
|
256
|
+
didSave: true,
|
|
257
|
+
},
|
|
258
|
+
hover: {
|
|
259
|
+
dynamicRegistration: false,
|
|
260
|
+
contentFormat: ["markdown", "plaintext"],
|
|
261
|
+
},
|
|
262
|
+
definition: {
|
|
263
|
+
dynamicRegistration: false,
|
|
264
|
+
},
|
|
265
|
+
publishDiagnostics: {
|
|
266
|
+
relatedInformation: true,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
workspace: {
|
|
270
|
+
workspaceFolders: true,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
rootUri,
|
|
274
|
+
workspaceFolders: [{ uri: rootUri, name: path.basename(this.workspaceRoot) }],
|
|
275
|
+
};
|
|
276
|
+
const result = (await this.sendRequest("initialize", params));
|
|
277
|
+
this.log(`LSP initialized: ${JSON.stringify(result.capabilities?.textDocumentSync)}`);
|
|
278
|
+
this.sendNotification("initialized", {});
|
|
279
|
+
this.initialized = true;
|
|
280
|
+
this.log("LSP client ready");
|
|
281
|
+
}
|
|
282
|
+
async openDocument(filePath) {
|
|
283
|
+
const uri = `file://${path.resolve(filePath)}`;
|
|
284
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
285
|
+
// Determine languageId from extension
|
|
286
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
287
|
+
const languageId = ext === ".bs" ? "brighterscript" : ext === ".brs" ? "brightscript" : "brighterscript";
|
|
288
|
+
const params = {
|
|
289
|
+
textDocument: {
|
|
290
|
+
uri,
|
|
291
|
+
languageId,
|
|
292
|
+
version: 1,
|
|
293
|
+
text: content,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
this.sendNotification("textDocument/didOpen", params);
|
|
297
|
+
}
|
|
298
|
+
async getDiagnostics(filePath) {
|
|
299
|
+
await this.ensureRunning(filePath);
|
|
300
|
+
const uri = `file://${path.resolve(filePath)}`;
|
|
301
|
+
// Open the document to trigger diagnostics
|
|
302
|
+
await this.openDocument(filePath);
|
|
303
|
+
// Wait for diagnostics to arrive
|
|
304
|
+
return new Promise((resolve) => {
|
|
305
|
+
// Check if we already have diagnostics for this file
|
|
306
|
+
const existing = this.diagnosticsMap.get(uri);
|
|
307
|
+
const timeout = setTimeout(() => {
|
|
308
|
+
this.removeListener("diagnostics", handler);
|
|
309
|
+
// Return whatever we have (could be empty)
|
|
310
|
+
resolve(this.diagnosticsMap.get(uri) || []);
|
|
311
|
+
}, 10000);
|
|
312
|
+
const handler = (params) => {
|
|
313
|
+
if (params.uri === uri) {
|
|
314
|
+
clearTimeout(timeout);
|
|
315
|
+
this.removeListener("diagnostics", handler);
|
|
316
|
+
resolve(params.diagnostics);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
this.on("diagnostics", handler);
|
|
320
|
+
// If we already got diagnostics before adding the listener, resolve immediately
|
|
321
|
+
if (existing && existing !== this.diagnosticsMap.get(uri)) {
|
|
322
|
+
clearTimeout(timeout);
|
|
323
|
+
this.removeListener("diagnostics", handler);
|
|
324
|
+
resolve(existing);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
async getHover(filePath, line, character) {
|
|
329
|
+
await this.ensureRunning(filePath);
|
|
330
|
+
const uri = `file://${path.resolve(filePath)}`;
|
|
331
|
+
// Ensure document is open
|
|
332
|
+
await this.openDocument(filePath);
|
|
333
|
+
const params = {
|
|
334
|
+
textDocument: { uri },
|
|
335
|
+
position: { line, character },
|
|
336
|
+
};
|
|
337
|
+
const result = await this.sendRequest("textDocument/hover", params);
|
|
338
|
+
return result || null;
|
|
339
|
+
}
|
|
340
|
+
async getDefinition(filePath, line, character) {
|
|
341
|
+
await this.ensureRunning(filePath);
|
|
342
|
+
const uri = `file://${path.resolve(filePath)}`;
|
|
343
|
+
// Ensure document is open
|
|
344
|
+
await this.openDocument(filePath);
|
|
345
|
+
const params = {
|
|
346
|
+
textDocument: { uri },
|
|
347
|
+
position: { line, character },
|
|
348
|
+
};
|
|
349
|
+
const result = await this.sendRequest("textDocument/definition", params);
|
|
350
|
+
return result || null;
|
|
351
|
+
}
|
|
352
|
+
isReady() {
|
|
353
|
+
return this.initialized;
|
|
354
|
+
}
|
|
355
|
+
log(message) {
|
|
356
|
+
process.stderr.write(`[brs-claude] ${message}\n`);
|
|
357
|
+
}
|
|
358
|
+
async stop() {
|
|
359
|
+
if (this.process) {
|
|
360
|
+
try {
|
|
361
|
+
await this.sendRequest("shutdown", null);
|
|
362
|
+
this.sendNotification("exit", null);
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
// Process may already be dead
|
|
366
|
+
}
|
|
367
|
+
this.process.kill();
|
|
368
|
+
this.process = null;
|
|
369
|
+
this.initialized = false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
exports.LspClient = LspClient;
|
|
374
|
+
//# sourceMappingURL=lsp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lsp-client.js","sourceRoot":"","sources":["../src/lsp-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEO,GAAG,CAAC,OAAe;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,OAAO,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;gBACzC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACtC,CAAC;YAAC,MAAM,CAAC;gBACP,8BAA8B;YAChC,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AA9YD,8BA8YC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LspClient } from "./lsp-client.js";
|
|
2
|
+
export declare const toolDefinitions: ({
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
filePath: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
line?: undefined;
|
|
13
|
+
character?: undefined;
|
|
14
|
+
};
|
|
15
|
+
required: string[];
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object";
|
|
22
|
+
properties: {
|
|
23
|
+
filePath: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
line: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
character: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
required: string[];
|
|
37
|
+
};
|
|
38
|
+
})[];
|
|
39
|
+
export declare function handleToolCall(lspClient: LspClient, toolName: string, args: Record<string, unknown>): Promise<string>;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toolDefinitions = void 0;
|
|
4
|
+
exports.handleToolCall = handleToolCall;
|
|
5
|
+
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
|
|
6
|
+
function severityToString(severity) {
|
|
7
|
+
switch (severity) {
|
|
8
|
+
case vscode_languageserver_protocol_1.DiagnosticSeverity.Error:
|
|
9
|
+
return "error";
|
|
10
|
+
case vscode_languageserver_protocol_1.DiagnosticSeverity.Warning:
|
|
11
|
+
return "warning";
|
|
12
|
+
case vscode_languageserver_protocol_1.DiagnosticSeverity.Information:
|
|
13
|
+
return "info";
|
|
14
|
+
case vscode_languageserver_protocol_1.DiagnosticSeverity.Hint:
|
|
15
|
+
return "hint";
|
|
16
|
+
default:
|
|
17
|
+
return "unknown";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function formatDiagnostics(diagnostics) {
|
|
21
|
+
if (diagnostics.length === 0) {
|
|
22
|
+
return "No diagnostics found. The file appears to be error-free.";
|
|
23
|
+
}
|
|
24
|
+
return diagnostics
|
|
25
|
+
.map((d) => {
|
|
26
|
+
const severity = severityToString(d.severity);
|
|
27
|
+
const line = d.range.start.line + 1; // Convert 0-indexed to 1-indexed
|
|
28
|
+
const col = d.range.start.character + 1;
|
|
29
|
+
const source = d.source ? ` [${d.source}]` : "";
|
|
30
|
+
const code = d.code ? ` (${d.code})` : "";
|
|
31
|
+
return `${severity}${source}${code} at line ${line}, col ${col}: ${d.message}`;
|
|
32
|
+
})
|
|
33
|
+
.join("\n");
|
|
34
|
+
}
|
|
35
|
+
function formatHover(hover) {
|
|
36
|
+
if (!hover) {
|
|
37
|
+
return "No hover information available at this position.";
|
|
38
|
+
}
|
|
39
|
+
const contents = hover.contents;
|
|
40
|
+
if (typeof contents === "string") {
|
|
41
|
+
return contents;
|
|
42
|
+
}
|
|
43
|
+
if (vscode_languageserver_protocol_1.MarkupContent.is(contents)) {
|
|
44
|
+
return contents.value;
|
|
45
|
+
}
|
|
46
|
+
// MarkedString (deprecated but still possible)
|
|
47
|
+
if ("language" in contents && "value" in contents) {
|
|
48
|
+
return `\`\`\`${contents.language}\n${contents.value}\n\`\`\``;
|
|
49
|
+
}
|
|
50
|
+
// Array of MarkedStrings
|
|
51
|
+
if (Array.isArray(contents)) {
|
|
52
|
+
return contents
|
|
53
|
+
.map((c) => {
|
|
54
|
+
if (typeof c === "string")
|
|
55
|
+
return c;
|
|
56
|
+
if ("language" in c && "value" in c)
|
|
57
|
+
return `\`\`\`${c.language}\n${c.value}\n\`\`\``;
|
|
58
|
+
return String(c);
|
|
59
|
+
})
|
|
60
|
+
.join("\n\n");
|
|
61
|
+
}
|
|
62
|
+
return String(contents);
|
|
63
|
+
}
|
|
64
|
+
function uriToPath(uri) {
|
|
65
|
+
return uri.replace(/^file:\/\//, "");
|
|
66
|
+
}
|
|
67
|
+
function formatDefinition(result) {
|
|
68
|
+
if (!result) {
|
|
69
|
+
return "No definition found at this position.";
|
|
70
|
+
}
|
|
71
|
+
const locations = [];
|
|
72
|
+
if (Array.isArray(result)) {
|
|
73
|
+
for (const item of result) {
|
|
74
|
+
if ("targetUri" in item) {
|
|
75
|
+
// LocationLink
|
|
76
|
+
const link = item;
|
|
77
|
+
locations.push({
|
|
78
|
+
uri: link.targetUri,
|
|
79
|
+
line: link.targetRange.start.line + 1,
|
|
80
|
+
character: link.targetRange.start.character + 1,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Location
|
|
85
|
+
const loc = item;
|
|
86
|
+
locations.push({
|
|
87
|
+
uri: loc.uri,
|
|
88
|
+
line: loc.range.start.line + 1,
|
|
89
|
+
character: loc.range.start.character + 1,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Single Location
|
|
96
|
+
locations.push({
|
|
97
|
+
uri: result.uri,
|
|
98
|
+
line: result.range.start.line + 1,
|
|
99
|
+
character: result.range.start.character + 1,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (locations.length === 0) {
|
|
103
|
+
return "No definition found at this position.";
|
|
104
|
+
}
|
|
105
|
+
return locations
|
|
106
|
+
.map((loc) => `${uriToPath(loc.uri)}:${loc.line}:${loc.character}`)
|
|
107
|
+
.join("\n");
|
|
108
|
+
}
|
|
109
|
+
exports.toolDefinitions = [
|
|
110
|
+
{
|
|
111
|
+
name: "brighterscript_diagnostics",
|
|
112
|
+
description: "Get BrighterScript diagnostics (errors, warnings) for a file. Returns compile-time errors and warnings from the BrighterScript compiler.",
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
filePath: {
|
|
117
|
+
type: "string",
|
|
118
|
+
description: "Absolute path to a .bs or .brs file",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
required: ["filePath"],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "brighterscript_hover",
|
|
126
|
+
description: "Get type information and documentation for a symbol at a specific position in a BrighterScript file. Useful for understanding what type a variable or function has.",
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
filePath: {
|
|
131
|
+
type: "string",
|
|
132
|
+
description: "Absolute path to a .bs or .brs file",
|
|
133
|
+
},
|
|
134
|
+
line: {
|
|
135
|
+
type: "number",
|
|
136
|
+
description: "Line number (1-indexed)",
|
|
137
|
+
},
|
|
138
|
+
character: {
|
|
139
|
+
type: "number",
|
|
140
|
+
description: "Column number (1-indexed)",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
required: ["filePath", "line", "character"],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "brighterscript_definition",
|
|
148
|
+
description: "Go to the definition of a symbol at a specific position in a BrighterScript file. Returns the file path and location where the symbol is defined.",
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
filePath: {
|
|
153
|
+
type: "string",
|
|
154
|
+
description: "Absolute path to a .bs or .brs file",
|
|
155
|
+
},
|
|
156
|
+
line: {
|
|
157
|
+
type: "number",
|
|
158
|
+
description: "Line number (1-indexed)",
|
|
159
|
+
},
|
|
160
|
+
character: {
|
|
161
|
+
type: "number",
|
|
162
|
+
description: "Column number (1-indexed)",
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
required: ["filePath", "line", "character"],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
async function handleToolCall(lspClient, toolName, args) {
|
|
170
|
+
switch (toolName) {
|
|
171
|
+
case "brighterscript_diagnostics": {
|
|
172
|
+
const filePath = args.filePath;
|
|
173
|
+
try {
|
|
174
|
+
const diagnostics = await lspClient.getDiagnostics(filePath);
|
|
175
|
+
return formatDiagnostics(diagnostics);
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
return `Error getting diagnostics: ${err}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
case "brighterscript_hover": {
|
|
182
|
+
const filePath = args.filePath;
|
|
183
|
+
// Convert from 1-indexed (user-facing) to 0-indexed (LSP)
|
|
184
|
+
const line = args.line - 1;
|
|
185
|
+
const character = args.character - 1;
|
|
186
|
+
try {
|
|
187
|
+
const hover = await lspClient.getHover(filePath, line, character);
|
|
188
|
+
return formatHover(hover);
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
return `Error getting hover info: ${err}`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
case "brighterscript_definition": {
|
|
195
|
+
const filePath = args.filePath;
|
|
196
|
+
// Convert from 1-indexed (user-facing) to 0-indexed (LSP)
|
|
197
|
+
const line = args.line - 1;
|
|
198
|
+
const character = args.character - 1;
|
|
199
|
+
try {
|
|
200
|
+
const definition = await lspClient.getDefinition(filePath, line, character);
|
|
201
|
+
return formatDefinition(definition);
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
return `Error getting definition: ${err}`;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
default:
|
|
208
|
+
return `Unknown tool: ${toolName}`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":";;;AAgMA,wCAiDC;AAhPD,mFAOwC;AAExC,SAAS,gBAAgB,CAAC,QAA6B;IACrD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,mDAAkB,CAAC,KAAK;YAC3B,OAAO,OAAO,CAAC;QACjB,KAAK,mDAAkB,CAAC,OAAO;YAC7B,OAAO,SAAS,CAAC;QACnB,KAAK,mDAAkB,CAAC,WAAW;YACjC,OAAO,MAAM,CAAC;QAChB,KAAK,mDAAkB,CAAC,IAAI;YAC1B,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAyB;IAClD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,0DAA0D,CAAC;IACpE,CAAC;IAED,OAAO,WAAW;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC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,IAAe,GAAG,CAAC,CAAC;YACvC,MAAM,SAAS,GAAI,IAAI,CAAC,SAAoB,GAAG,CAAC,CAAC;YACjD,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;gBAClE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,6BAA6B,GAAG,EAAE,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,KAAK,2BAA2B,CAAC,CAAC,CAAC;YACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAkB,CAAC;YACzC,0DAA0D;YAC1D,MAAM,IAAI,GAAI,IAAI,CAAC,IAAe,GAAG,CAAC,CAAC;YACvC,MAAM,SAAS,GAAI,IAAI,CAAC,SAAoB,GAAG,CAAC,CAAC;YACjD,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,CAC9C,QAAQ,EACR,IAAI,EACJ,SAAS,CACV,CAAC;gBACF,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACtC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,6BAA6B,GAAG,EAAE,CAAC;YAC5C,CAAC;QACH,CAAC;QAED;YACE,OAAO,iBAAiB,QAAQ,EAAE,CAAC;IACvC,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "brs-claude",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server bridging BrighterScript LSP to Claude Code",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"bin": {
|
|
11
|
+
"brs-claude": "dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"start": "node dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
23
|
+
"brighterscript": "^0.70.3",
|
|
24
|
+
"vscode-jsonrpc": "^8.2.1",
|
|
25
|
+
"vscode-languageserver-protocol": "^3.17.5",
|
|
26
|
+
"zod": "^3.23.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.11.0",
|
|
30
|
+
"typescript": "^5.4.0"
|
|
31
|
+
}
|
|
32
|
+
}
|