@opensumi/ide-ai-native 3.7.2-next-1739859371.0 → 3.7.2-next-1739945875.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/lib/browser/ai-core.contribution.d.ts +3 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +68 -2
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +2 -2
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +16 -5
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +4 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +43 -0
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +29 -2
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.d.ts +12 -0
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
- package/lib/browser/components/ChatContext/ContextSelector.js +113 -0
- package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
- package/lib/browser/components/ChatContext/index.d.ts +4 -0
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
- package/lib/browser/components/ChatContext/index.js +84 -0
- package/lib/browser/components/ChatContext/index.js.map +1 -0
- package/lib/browser/components/ChatContext/style.module.less +189 -0
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +25 -0
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts +6 -0
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -0
- package/lib/browser/components/ChatToolRender.js +53 -0
- package/lib/browser/components/ChatToolRender.js.map +1 -0
- package/lib/browser/components/ChatToolRender.module.less +86 -0
- package/lib/browser/components/components.module.less +32 -31
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.contribution.d.ts +7 -0
- package/lib/browser/context/llm-context.contribution.d.ts.map +1 -0
- package/lib/browser/context/llm-context.contribution.js +21 -0
- package/lib/browser/context/llm-context.contribution.js.map +1 -0
- package/lib/browser/context/llm-context.service.d.ts +24 -0
- package/lib/browser/context/llm-context.service.d.ts.map +1 -0
- package/lib/browser/context/llm-context.service.js +136 -0
- package/lib/browser/context/llm-context.service.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +2 -2
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts +4 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js +7 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts +11 -3
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +56 -3
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +25 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js +56 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +16 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js +53 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -0
- package/lib/browser/mcp/mcp-tools-dialog.module.less +44 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts +8 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.js +16 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.js.map +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +9 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.js +83 -0
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts +9 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js +92 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +1 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts +8 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.js +49 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.js.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts +10 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +119 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -0
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts +9 -0
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getFileTextByPath.js +97 -0
- package/lib/browser/mcp/tools/getFileTextByPath.js.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts +11 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +119 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts +8 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.js +50 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +1 -0
- package/lib/browser/mcp/tools/getSelectedText.d.ts +8 -0
- package/lib/browser/mcp/tools/getSelectedText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getSelectedText.js +57 -0
- package/lib/browser/mcp/tools/getSelectedText.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts +21 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js +112 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +47 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js +147 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts +8 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -0
- package/lib/browser/mcp/tools/listDir.js +65 -0
- package/lib/browser/mcp/tools/listDir.js.map +1 -0
- package/lib/browser/mcp/tools/readFile.d.ts +8 -0
- package/lib/browser/mcp/tools/readFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/readFile.js +82 -0
- package/lib/browser/mcp/tools/readFile.js.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts +8 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js +79 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts +8 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +84 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts +18 -0
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js +96 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -0
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +60 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +64 -3
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +5 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/common/index.d.ts +9 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +37 -0
- package/lib/common/llm-context.d.ts.map +1 -0
- package/lib/common/llm-context.js +5 -0
- package/lib/common/llm-context.js.map +1 -0
- package/lib/common/mcp-server-manager.d.ts +40 -0
- package/lib/common/mcp-server-manager.d.ts.map +1 -0
- package/lib/common/mcp-server-manager.js +6 -0
- package/lib/common/mcp-server-manager.js.map +1 -0
- package/lib/common/tool-invocation-registry.d.ts +91 -0
- package/lib/common/tool-invocation-registry.d.ts.map +1 -0
- package/lib/common/tool-invocation-registry.js +90 -0
- package/lib/common/tool-invocation-registry.js.map +1 -0
- package/lib/common/types.d.ts +17 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +9 -0
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -0
- package/lib/node/anthropic/anthropic-language-model.js +26 -0
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -0
- package/lib/node/base-language-model.d.ts +14 -0
- package/lib/node/base-language-model.d.ts.map +1 -0
- package/lib/node/base-language-model.js +136 -0
- package/lib/node/base-language-model.js.map +1 -0
- package/lib/node/deepseek/deepseek-language-model.d.ts +9 -0
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -0
- package/lib/node/deepseek/deepseek-language-model.js +26 -0
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +19 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +91 -0
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -0
- package/lib/node/mcp/sumi-mcp-server.js +172 -0
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -0
- package/lib/node/mcp-server-manager-impl.d.ts +27 -0
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -0
- package/lib/node/mcp-server-manager-impl.js +127 -0
- package/lib/node/mcp-server-manager-impl.js.map +1 -0
- package/lib/node/mcp-server.d.ts +207 -0
- package/lib/node/mcp-server.d.ts.map +1 -0
- package/lib/node/mcp-server.js +91 -0
- package/lib/node/mcp-server.js.map +1 -0
- package/lib/node/openai/openai-language-model.d.ts +9 -0
- package/lib/node/openai/openai-language-model.d.ts.map +1 -0
- package/lib/node/openai/openai-language-model.js +29 -0
- package/lib/node/openai/openai-language-model.js.map +1 -0
- package/package.json +34 -22
- package/src/browser/ai-core.contribution.ts +77 -1
- package/src/browser/chat/chat-model.ts +24 -6
- package/src/browser/chat/chat-proxy.service.ts +42 -0
- package/src/browser/chat/chat.view.tsx +59 -6
- package/src/browser/components/ChatContext/ContextSelector.tsx +177 -0
- package/src/browser/components/ChatContext/index.tsx +135 -0
- package/src/browser/components/ChatContext/style.module.less +189 -0
- package/src/browser/components/ChatInput.tsx +1 -0
- package/src/browser/components/ChatReply.tsx +32 -0
- package/src/browser/components/ChatToolRender.module.less +86 -0
- package/src/browser/components/ChatToolRender.tsx +77 -0
- package/src/browser/components/components.module.less +32 -31
- package/src/browser/context/llm-context.contribution.ts +14 -0
- package/src/browser/context/llm-context.service.ts +156 -0
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +2 -3
- package/src/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.ts +11 -0
- package/src/browser/index.ts +68 -4
- package/src/browser/mcp/mcp-server-proxy.service.ts +53 -0
- package/src/browser/mcp/mcp-server.feature.registry.ts +54 -0
- package/src/browser/mcp/mcp-tools-dialog.module.less +44 -0
- package/src/browser/mcp/mcp-tools-dialog.view.tsx +24 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +83 -0
- package/src/browser/mcp/tools/findFilesByNameSubstring.ts +93 -0
- package/src/browser/mcp/tools/getCurrentFilePath.ts +49 -0
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +123 -0
- package/src/browser/mcp/tools/getFileTextByPath.ts +97 -0
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +121 -0
- package/src/browser/mcp/tools/getOpenEditorFileText.ts +50 -0
- package/src/browser/mcp/tools/getSelectedText.ts +57 -0
- package/src/browser/mcp/tools/handlers/ListDir.ts +117 -0
- package/src/browser/mcp/tools/handlers/ReadFile.ts +174 -0
- package/src/browser/mcp/tools/listDir.ts +66 -0
- package/src/browser/mcp/tools/readFile.ts +82 -0
- package/src/browser/mcp/tools/replaceOpenEditorFile.ts +80 -0
- package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +91 -0
- package/src/browser/mcp/tools/runTerminalCmd.ts +107 -0
- package/src/browser/preferences/schema.ts +60 -0
- package/src/browser/types.ts +92 -3
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +1 -1
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +1 -1
- package/src/browser/widget/inline-input/inline-input.controller.ts +1 -1
- package/src/common/index.ts +14 -0
- package/src/common/llm-context.ts +41 -0
- package/src/common/mcp-server-manager.ts +46 -0
- package/src/common/tool-invocation-registry.ts +170 -0
- package/src/common/types.ts +22 -0
- package/src/node/anthropic/anthropic-language-model.ts +25 -0
- package/src/node/base-language-model.ts +163 -0
- package/src/node/deepseek/deepseek-language-model.ts +25 -0
- package/src/node/index.ts +21 -0
- package/src/node/mcp/sumi-mcp-server.ts +197 -0
- package/src/node/mcp-server-manager-impl.ts +148 -0
- package/src/node/mcp-server.ts +126 -0
- package/src/node/openai/openai-language-model.ts +25 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
2
|
+
export declare class FindFilesByNameSubstringTool implements MCPServerContribution {
|
|
3
|
+
private readonly workspaceService;
|
|
4
|
+
private readonly fileSearchService;
|
|
5
|
+
registerMCPServer(registry: IMCPServerRegistry): void;
|
|
6
|
+
getToolDefinition(): MCPToolDefinition;
|
|
7
|
+
private handler;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=findFilesByNameSubstring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findFilesByNameSubstring.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/findFilesByNameSubstring.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMtG,qBACa,4BAA6B,YAAW,qBAAqB;IAExE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IAGrD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IAEvD,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAiBxB,OAAO;CA+CtB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindFilesByNameSubstringTool = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
8
|
+
const di_1 = require("@opensumi/di");
|
|
9
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
10
|
+
const common_1 = require("@opensumi/ide-file-search/lib/common");
|
|
11
|
+
const ide_workspace_1 = require("@opensumi/ide-workspace");
|
|
12
|
+
const types_1 = require("../../types");
|
|
13
|
+
const inputSchema = zod_1.z.object({
|
|
14
|
+
nameSubstring: zod_1.z.string().describe('The substring to search for in file names'),
|
|
15
|
+
});
|
|
16
|
+
let FindFilesByNameSubstringTool = class FindFilesByNameSubstringTool {
|
|
17
|
+
registerMCPServer(registry) {
|
|
18
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
19
|
+
}
|
|
20
|
+
getToolDefinition() {
|
|
21
|
+
return {
|
|
22
|
+
name: 'find_files_by_name_substring',
|
|
23
|
+
description: 'Searches for all files in the project whose names contain the specified substring (case-insensitive). ' +
|
|
24
|
+
'Use this tool to locate files when you know part of the filename. ' +
|
|
25
|
+
'Requires a nameSubstring parameter for the search term. ' +
|
|
26
|
+
'Returns a JSON array of objects containing file information: ' +
|
|
27
|
+
'- path: Path relative to project root ' +
|
|
28
|
+
'- name: File name ' +
|
|
29
|
+
'Returns an empty array ([]) if no matching files are found. ' +
|
|
30
|
+
'Note: Only searches through files within the project directory, excluding libraries and external dependencies.',
|
|
31
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
|
|
32
|
+
handler: this.handler.bind(this),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async handler(args, logger) {
|
|
36
|
+
try {
|
|
37
|
+
// 获取工作区根目录
|
|
38
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
39
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
40
|
+
logger.appendLine('Error: Cannot determine project directory');
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: 'text', text: '[]' }],
|
|
43
|
+
isError: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// 使用 OpenSumi 的文件搜索 API
|
|
47
|
+
const searchPattern = `**/*${args.nameSubstring}*`;
|
|
48
|
+
const searchResults = await this.fileSearchService.find(searchPattern, {
|
|
49
|
+
rootUris: [workspaceRoots[0].uri],
|
|
50
|
+
excludePatterns: ['**/node_modules/**'],
|
|
51
|
+
limit: 1000,
|
|
52
|
+
});
|
|
53
|
+
// 转换结果为所需的格式
|
|
54
|
+
const results = searchResults.map((file) => {
|
|
55
|
+
const uri = ide_core_common_1.URI.parse(file);
|
|
56
|
+
const rootUri = ide_core_common_1.URI.parse(workspaceRoots[0].uri);
|
|
57
|
+
const relativePath = path.relative(rootUri.codeUri.fsPath, uri.codeUri.fsPath);
|
|
58
|
+
const fileName = path.basename(uri.codeUri.fsPath);
|
|
59
|
+
return {
|
|
60
|
+
path: relativePath,
|
|
61
|
+
name: fileName,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
// 将结果转换为 JSON 字符串
|
|
65
|
+
const resultJson = JSON.stringify(results, null, 2);
|
|
66
|
+
logger.appendLine(`Found ${results.length} files matching "${args.nameSubstring}"`);
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: 'text', text: resultJson }],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.appendLine(`Error during file search: ${error}`);
|
|
73
|
+
return {
|
|
74
|
+
content: [{ type: 'text', text: '[]' }],
|
|
75
|
+
isError: true,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.FindFilesByNameSubstringTool = FindFilesByNameSubstringTool;
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, di_1.Autowired)(ide_workspace_1.IWorkspaceService),
|
|
83
|
+
tslib_1.__metadata("design:type", Object)
|
|
84
|
+
], FindFilesByNameSubstringTool.prototype, "workspaceService", void 0);
|
|
85
|
+
tslib_1.__decorate([
|
|
86
|
+
(0, di_1.Autowired)(common_1.IFileSearchService),
|
|
87
|
+
tslib_1.__metadata("design:type", Object)
|
|
88
|
+
], FindFilesByNameSubstringTool.prototype, "fileSearchService", void 0);
|
|
89
|
+
exports.FindFilesByNameSubstringTool = FindFilesByNameSubstringTool = tslib_1.__decorate([
|
|
90
|
+
(0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
|
|
91
|
+
], FindFilesByNameSubstringTool);
|
|
92
|
+
//# sourceMappingURL=findFilesByNameSubstring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findFilesByNameSubstring.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/findFilesByNameSubstring.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,6BAAwB;AACxB,2DAAqD;AAErD,qCAAqD;AACrD,+DAAwD;AACxD,iEAA0E;AAC1E,2DAA4D;AAE5D,uCAAsG;AAEtG,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;CAChF,CAAC,CAAC;AAGI,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAOvC,iBAAiB,CAAC,QAA4B;QAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,8BAA8B;YACpC,WAAW,EACT,wGAAwG;gBACxG,oEAAoE;gBACpE,0DAA0D;gBAC1D,+DAA+D;gBAC/D,wCAAwC;gBACxC,oBAAoB;gBACpB,8DAA8D;gBAC9D,gHAAgH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M,CAAC,CAAC;gBAC/E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACnD,OAAO;oBACL,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,QAAQ;iBACf,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,kBAAkB;YAClB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACpD,MAAM,CAAC,UAAU,CAAC,SAAS,OAAO,CAAC,MAAM,oBAAoB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;YAEpF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;aAC9C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,UAAU,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;YACxD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACvC,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA3EY,oEAA4B;AAEtB;IADhB,IAAA,cAAS,EAAC,iCAAiB,CAAC;;sEACwB;AAGpC;IADhB,IAAA,cAAS,EAAC,2BAAkB,CAAC;;uEACyB;uCAL5C,4BAA4B;IADxC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,4BAA4B,CA2ExC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
2
|
+
export declare class GetCurrentFilePathTool implements MCPServerContribution {
|
|
3
|
+
private readonly editorService;
|
|
4
|
+
registerMCPServer(registry: IMCPServerRegistry): void;
|
|
5
|
+
getToolDefinition(): MCPToolDefinition;
|
|
6
|
+
private handler;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=getCurrentFilePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentFilePath.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getCurrentFilePath.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAItG,qBACa,sBAAuB,YAAW,qBAAqB;IAElE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAEvD,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAYxB,OAAO;CAgBtB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetCurrentFilePathTool = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
7
|
+
const di_1 = require("@opensumi/di");
|
|
8
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
9
|
+
const ide_editor_1 = require("@opensumi/ide-editor");
|
|
10
|
+
const types_1 = require("../../types");
|
|
11
|
+
const inputSchema = zod_1.z.object({});
|
|
12
|
+
let GetCurrentFilePathTool = class GetCurrentFilePathTool {
|
|
13
|
+
registerMCPServer(registry) {
|
|
14
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
15
|
+
}
|
|
16
|
+
getToolDefinition() {
|
|
17
|
+
return {
|
|
18
|
+
name: 'get_open_in_editor_file_path',
|
|
19
|
+
description: 'Retrieves the absolute path of the currently active file in the VS Code editor. ' +
|
|
20
|
+
'Use this tool to get the file location for tasks requiring file path information. ' +
|
|
21
|
+
'Returns an empty string if no file is currently open.',
|
|
22
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
|
|
23
|
+
handler: this.handler.bind(this),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async handler(args, logger) {
|
|
27
|
+
const editor = this.editorService.currentEditor;
|
|
28
|
+
if (!editor || !editor.currentUri) {
|
|
29
|
+
logger.appendLine('Error: No active text editor found');
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: 'text', text: '' }],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const path = editor.currentUri.toString();
|
|
35
|
+
logger.appendLine(`Current file path: ${path}`);
|
|
36
|
+
return {
|
|
37
|
+
content: [{ type: 'text', text: path }],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.GetCurrentFilePathTool = GetCurrentFilePathTool;
|
|
42
|
+
tslib_1.__decorate([
|
|
43
|
+
(0, di_1.Autowired)(ide_editor_1.WorkbenchEditorService),
|
|
44
|
+
tslib_1.__metadata("design:type", ide_editor_1.WorkbenchEditorService)
|
|
45
|
+
], GetCurrentFilePathTool.prototype, "editorService", void 0);
|
|
46
|
+
exports.GetCurrentFilePathTool = GetCurrentFilePathTool = tslib_1.__decorate([
|
|
47
|
+
(0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
|
|
48
|
+
], GetCurrentFilePathTool);
|
|
49
|
+
//# sourceMappingURL=getCurrentFilePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentFilePath.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getCurrentFilePath.ts"],"names":[],"mappings":";;;;AAAA,6BAAwB;AACxB,2DAAqD;AAErD,qCAAqD;AACrD,+DAAmD;AACnD,qDAA8D;AAE9D,uCAAsG;AAEtG,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAG1B,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAIjC,iBAAiB,CAAC,QAA4B;QAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,8BAA8B;YACpC,WAAW,EACT,kFAAkF;gBAClF,oFAAoF;gBACpF,uDAAuD;YACzD,WAAW,EAAE,IAAA,oCAAe,EAAC,WAAW,CAAC;YACzC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;SACjC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAiC,EAAE,MAAiB;QACxE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;QAChD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAClC,MAAM,CAAC,UAAU,CAAC,oCAAoC,CAAC,CAAC;YACxD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;aACtC,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,CAAC,UAAU,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;QAEhD,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SACxC,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,wDAAsB;AAEhB;IADhB,IAAA,cAAS,EAAC,mCAAsB,CAAC;sCACF,mCAAsB;6DAAC;iCAF5C,sBAAsB;IADlC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,sBAAsB,CAoClC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
2
|
+
export declare class GetDiagnosticsByPathTool implements MCPServerContribution {
|
|
3
|
+
private readonly workspaceService;
|
|
4
|
+
private readonly markerService;
|
|
5
|
+
registerMCPServer(registry: IMCPServerRegistry): void;
|
|
6
|
+
getToolDefinition(): MCPToolDefinition;
|
|
7
|
+
private handler;
|
|
8
|
+
private getSeverityString;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=getDiagnosticsByPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiagnosticsByPath.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getDiagnosticsByPath.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMtG,qBACa,wBAAyB,YAAW,qBAAqB;IAEpE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IAGrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAE/C,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAyBxB,OAAO;IAsDrB,OAAO,CAAC,iBAAiB;CAc1B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetDiagnosticsByPathTool = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
8
|
+
const di_1 = require("@opensumi/di");
|
|
9
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
10
|
+
const ide_workspace_1 = require("@opensumi/ide-workspace");
|
|
11
|
+
const uri_1 = require("@opensumi/monaco-editor-core/esm/vs/base/common/uri");
|
|
12
|
+
const markers_1 = require("@opensumi/monaco-editor-core/esm/vs/platform/markers/common/markers");
|
|
13
|
+
const types_1 = require("../../types");
|
|
14
|
+
const inputSchema = zod_1.z.object({
|
|
15
|
+
filePathInProject: zod_1.z.string().describe('The relative path to the file to get diagnostics for'),
|
|
16
|
+
});
|
|
17
|
+
let GetDiagnosticsByPathTool = class GetDiagnosticsByPathTool {
|
|
18
|
+
registerMCPServer(registry) {
|
|
19
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
20
|
+
}
|
|
21
|
+
getToolDefinition() {
|
|
22
|
+
return {
|
|
23
|
+
name: 'get_diagnostics_by_path',
|
|
24
|
+
description: 'Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. ' +
|
|
25
|
+
'Use this tool to get information about problems in any project file. ' +
|
|
26
|
+
'IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. ' +
|
|
27
|
+
'Requires a filePathInProject parameter specifying the target file path relative to project root. ' +
|
|
28
|
+
'Returns a JSON-formatted list of diagnostics, where each entry contains: ' +
|
|
29
|
+
'- path: The file path where the diagnostic was found ' +
|
|
30
|
+
'- line: The line number (1-based) of the diagnostic ' +
|
|
31
|
+
'- severity: The severity level ("error", "warning", "information", or "hint") ' +
|
|
32
|
+
'- message: The diagnostic message ' +
|
|
33
|
+
"Returns an empty list ([]) if no diagnostics are found or the file doesn't exist. " +
|
|
34
|
+
'Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. ' +
|
|
35
|
+
'Use this tool in combination with get_open_in_editor_file_diagnostics to verify all affected files after code changes. ' +
|
|
36
|
+
'Diagnostic Severity Handling Guidelines: ' +
|
|
37
|
+
'- "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. ' +
|
|
38
|
+
'- "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. ' +
|
|
39
|
+
'- "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',
|
|
40
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
|
|
41
|
+
handler: this.handler.bind(this),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async handler(args, logger) {
|
|
45
|
+
try {
|
|
46
|
+
// 获取工作区根目录
|
|
47
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
48
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
49
|
+
logger.appendLine('Error: Cannot determine project directory');
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: 'text', text: '[]' }],
|
|
52
|
+
isError: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// 构建完整的文件路径
|
|
56
|
+
const rootUri = ide_core_common_1.URI.parse(workspaceRoots[0].uri);
|
|
57
|
+
const fullPath = path.join(rootUri.codeUri.fsPath, args.filePathInProject);
|
|
58
|
+
const uri = uri_1.URI.file(fullPath);
|
|
59
|
+
// 检查文件是否在项目目录内
|
|
60
|
+
const relativePath = path.relative(rootUri.codeUri.fsPath, fullPath);
|
|
61
|
+
if (relativePath.startsWith('..') || path.isAbsolute(relativePath)) {
|
|
62
|
+
logger.appendLine('Error: File is outside of project scope');
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: 'text', text: '[]' }],
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// 获取文件的诊断信息
|
|
69
|
+
const markers = this.markerService.read({ resource: uri });
|
|
70
|
+
// 转换诊断信息
|
|
71
|
+
const diagnosticInfos = markers.map((marker) => ({
|
|
72
|
+
path: args.filePathInProject,
|
|
73
|
+
line: marker.startLineNumber,
|
|
74
|
+
severity: this.getSeverityString(marker.severity),
|
|
75
|
+
message: marker.message,
|
|
76
|
+
}));
|
|
77
|
+
// 将结果转换为 JSON 字符串
|
|
78
|
+
const resultJson = JSON.stringify(diagnosticInfos, null, 2);
|
|
79
|
+
logger.appendLine(`Found ${diagnosticInfos.length} diagnostics in ${args.filePathInProject}`);
|
|
80
|
+
return {
|
|
81
|
+
content: [{ type: 'text', text: resultJson }],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
logger.appendLine(`Error getting diagnostics: ${error}`);
|
|
86
|
+
return {
|
|
87
|
+
content: [{ type: 'text', text: '[]' }],
|
|
88
|
+
isError: true,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
getSeverityString(severity) {
|
|
93
|
+
switch (severity) {
|
|
94
|
+
case markers_1.MarkerSeverity.Error:
|
|
95
|
+
return 'error';
|
|
96
|
+
case markers_1.MarkerSeverity.Warning:
|
|
97
|
+
return 'warning';
|
|
98
|
+
case markers_1.MarkerSeverity.Info:
|
|
99
|
+
return 'information';
|
|
100
|
+
case markers_1.MarkerSeverity.Hint:
|
|
101
|
+
return 'hint';
|
|
102
|
+
default:
|
|
103
|
+
return 'unknown';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.GetDiagnosticsByPathTool = GetDiagnosticsByPathTool;
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, di_1.Autowired)(ide_workspace_1.IWorkspaceService),
|
|
110
|
+
tslib_1.__metadata("design:type", Object)
|
|
111
|
+
], GetDiagnosticsByPathTool.prototype, "workspaceService", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, di_1.Autowired)(markers_1.IMarkerService),
|
|
114
|
+
tslib_1.__metadata("design:type", Object)
|
|
115
|
+
], GetDiagnosticsByPathTool.prototype, "markerService", void 0);
|
|
116
|
+
exports.GetDiagnosticsByPathTool = GetDiagnosticsByPathTool = tslib_1.__decorate([
|
|
117
|
+
(0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
|
|
118
|
+
], GetDiagnosticsByPathTool);
|
|
119
|
+
//# sourceMappingURL=getDiagnosticsByPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiagnosticsByPath.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getDiagnosticsByPath.ts"],"names":[],"mapp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AkB;YAClB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC5D,MAAM,CAAC,UAAU,CAAC,SAAS,eAAe,CAAC,MAAM,mBAAmB,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;YAE9F,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;aAC9C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,UAAU,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACvC,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,QAAwB;QAChD,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,wBAAc,CAAC,KAAK;gBACvB,OAAO,OAAO,CAAC;YACjB,KAAK,wBAAc,CAAC,OAAO;gBACzB,OAAO,SAAS,CAAC;YACnB,KAAK,wBAAc,CAAC,IAAI;gBACtB,OAAO,aAAa,CAAC;YACvB,KAAK,wBAAc,CAAC,IAAI;gBACtB,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF,CAAA;AAxGY,4DAAwB;AAElB;IADhB,IAAA,cAAS,EAAC,iCAAiB,CAAC;;kEACwB;AAGpC;IADhB,IAAA,cAAS,EAAC,wBAAc,CAAC;;+DACqB;mCALpC,wBAAwB;IADpC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,wBAAwB,CAwGpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
2
|
+
export declare class GetFileTextByPathTool implements MCPServerContribution {
|
|
3
|
+
private readonly workspaceService;
|
|
4
|
+
private readonly fileService;
|
|
5
|
+
registerMCPServer(registry: IMCPServerRegistry): void;
|
|
6
|
+
getToolDefinition(): MCPToolDefinition;
|
|
7
|
+
private handler;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=getFileTextByPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileTextByPath.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getFileTextByPath.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMtG,qBACa,qBAAsB,YAAW,qBAAqB;IAEjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IAGrD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IAEjD,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAiBxB,OAAO;CAmDtB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetFileTextByPathTool = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
8
|
+
const di_1 = require("@opensumi/di");
|
|
9
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
10
|
+
const ide_file_service_1 = require("@opensumi/ide-file-service");
|
|
11
|
+
const ide_workspace_1 = require("@opensumi/ide-workspace");
|
|
12
|
+
const types_1 = require("../../types");
|
|
13
|
+
const inputSchema = zod_1.z.object({
|
|
14
|
+
pathInProject: zod_1.z.string().describe('The file location relative to project root'),
|
|
15
|
+
});
|
|
16
|
+
let GetFileTextByPathTool = class GetFileTextByPathTool {
|
|
17
|
+
registerMCPServer(registry) {
|
|
18
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
19
|
+
}
|
|
20
|
+
getToolDefinition() {
|
|
21
|
+
return {
|
|
22
|
+
name: 'get_file_text_by_path',
|
|
23
|
+
description: 'Retrieves the text content of a file using its path relative to project root. ' +
|
|
24
|
+
"Use this tool to read file contents when you have the file's project-relative path. " +
|
|
25
|
+
'Requires a pathInProject parameter specifying the file location from project root. ' +
|
|
26
|
+
'Returns one of these responses: ' +
|
|
27
|
+
"- The file's content if the file exists and belongs to the project " +
|
|
28
|
+
'- error "project dir not found" if project directory cannot be determined ' +
|
|
29
|
+
'- error "file not found" if the file doesn\'t exist or is outside project scope ' +
|
|
30
|
+
'Note: Automatically refreshes the file system before reading',
|
|
31
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
|
|
32
|
+
handler: this.handler.bind(this),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async handler(args, logger) {
|
|
36
|
+
try {
|
|
37
|
+
// 获取工作区根目录
|
|
38
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
39
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
40
|
+
logger.appendLine('Error: Cannot determine project directory');
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: 'text', text: 'project dir not found' }],
|
|
43
|
+
isError: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// 构建完整的文件路径
|
|
47
|
+
const rootUri = ide_core_common_1.URI.parse(workspaceRoots[0].uri);
|
|
48
|
+
const fullPath = path.join(rootUri.codeUri.fsPath, args.pathInProject);
|
|
49
|
+
const fileUri = ide_core_common_1.URI.file(fullPath);
|
|
50
|
+
// 检查文件是否在项目目录内
|
|
51
|
+
const relativePath = path.relative(rootUri.codeUri.fsPath, fullPath);
|
|
52
|
+
if (relativePath.startsWith('..') || path.isAbsolute(relativePath)) {
|
|
53
|
+
logger.appendLine('Error: File is outside of project scope');
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: 'text', text: 'file not found' }],
|
|
56
|
+
isError: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// 检查文件是否存在并读取内容
|
|
60
|
+
try {
|
|
61
|
+
const result = await this.fileService.readFile(fileUri.toString());
|
|
62
|
+
const content = result.content.toString();
|
|
63
|
+
logger.appendLine(`Successfully read file: ${args.pathInProject}`);
|
|
64
|
+
return {
|
|
65
|
+
content: [{ type: 'text', text: content }],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
logger.appendLine('Error: File does not exist');
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: 'text', text: 'file not found' }],
|
|
72
|
+
isError: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
logger.appendLine(`Error reading file: ${error}`);
|
|
78
|
+
return {
|
|
79
|
+
content: [{ type: 'text', text: 'file not found' }],
|
|
80
|
+
isError: true,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.GetFileTextByPathTool = GetFileTextByPathTool;
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, di_1.Autowired)(ide_workspace_1.IWorkspaceService),
|
|
88
|
+
tslib_1.__metadata("design:type", Object)
|
|
89
|
+
], GetFileTextByPathTool.prototype, "workspaceService", void 0);
|
|
90
|
+
tslib_1.__decorate([
|
|
91
|
+
(0, di_1.Autowired)(ide_file_service_1.IFileServiceClient),
|
|
92
|
+
tslib_1.__metadata("design:type", Object)
|
|
93
|
+
], GetFileTextByPathTool.prototype, "fileService", void 0);
|
|
94
|
+
exports.GetFileTextByPathTool = GetFileTextByPathTool = tslib_1.__decorate([
|
|
95
|
+
(0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
|
|
96
|
+
], GetFileTextByPathTool);
|
|
97
|
+
//# sourceMappingURL=getFileTextByPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileTextByPath.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getFileTextByPath.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,6BAAwB;AACxB,2DAAqD;AAErD,qCAAqD;AACrD,+DAAwD;AACxD,iEAAgE;AAChE,2DAA4D;AAE5D,uCAAsG;AAEtG,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CACjF,CAAC,CAAC;AAGI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAOhC,iBAAiB,CAAC,QAA4B;QAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EACT,gFAAgF;gBAChF,sFAAsF;gBACtF,qFAAqF;gBACrF,kCAAkC;gBAClC,qEAAqE;gBACrE,4EAA4E;gBAC5E,kFAAkF;gBAClF,8DAA8D;YAChE,WAAW,EAAE,IAAA,oCAAe,EAAC,WAAW,CAAC;YACzC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;SACjC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAiC,EAAE,MAAiB;QACxE,IAAI,CAAC;YACH,WAAW;YACX,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC;YAC3D,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,UAAU,CAAC,2CAA2C,CAAC,CAAC;gBAC/D,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,E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KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAC;gBAChD,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;oBACnD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,UAAU,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;YAClD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;gBACnD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA/EY,sDAAqB;AAEf;IADhB,IAAA,cAAS,EAAC,iCAAiB,CAAC;;+DACwB;AAGpC;IADhB,IAAA,cAAS,EAAC,qCAAkB,CAAC;;0DACmB;gCALtC,qBAAqB;IADjC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,qBAAqB,CA+EjC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
2
|
+
export declare class GetOpenEditorFileDiagnosticsTool implements MCPServerContribution {
|
|
3
|
+
private readonly editorService;
|
|
4
|
+
private readonly workspaceService;
|
|
5
|
+
private readonly markerService;
|
|
6
|
+
registerMCPServer(registry: IMCPServerRegistry): void;
|
|
7
|
+
getToolDefinition(): MCPToolDefinition;
|
|
8
|
+
private handler;
|
|
9
|
+
private getSeverityString;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=getOpenEditorFileDiagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOpenEditorFileDiagnostics.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAItG,qBACa,gCAAiC,YAAW,qBAAqB;IAE5E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAGvD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IAGrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAE/C,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAuBxB,OAAO;IAoDrB,OAAO,CAAC,iBAAiB;CAc1B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetOpenEditorFileDiagnosticsTool = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
8
|
+
const di_1 = require("@opensumi/di");
|
|
9
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
10
|
+
const ide_editor_1 = require("@opensumi/ide-editor");
|
|
11
|
+
const ide_workspace_1 = require("@opensumi/ide-workspace");
|
|
12
|
+
const uri_1 = require("@opensumi/monaco-editor-core/esm/vs/base/common/uri");
|
|
13
|
+
const markers_1 = require("@opensumi/monaco-editor-core/esm/vs/platform/markers/common/markers");
|
|
14
|
+
const types_1 = require("../../types");
|
|
15
|
+
const inputSchema = zod_1.z.object({});
|
|
16
|
+
let GetOpenEditorFileDiagnosticsTool = class GetOpenEditorFileDiagnosticsTool {
|
|
17
|
+
registerMCPServer(registry) {
|
|
18
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
19
|
+
}
|
|
20
|
+
getToolDefinition() {
|
|
21
|
+
return {
|
|
22
|
+
name: 'get_open_in_editor_file_diagnostics',
|
|
23
|
+
description: 'Retrieves diagnostic information (errors, warnings, etc.) from the currently active file in VS Code editor. ' +
|
|
24
|
+
'Use this tool to get information about problems in your current file. ' +
|
|
25
|
+
'IMPORTANT: This tool should be called after any code generation or modification operations to verify and fix potential issues. ' +
|
|
26
|
+
'Returns a JSON-formatted list of diagnostics, where each entry contains: ' +
|
|
27
|
+
'- path: The file path where the diagnostic was found ' +
|
|
28
|
+
'- line: The line number (1-based) of the diagnostic ' +
|
|
29
|
+
'- severity: The severity level ("error", "warning", "information", or "hint") ' +
|
|
30
|
+
'- message: The diagnostic message ' +
|
|
31
|
+
'Returns an empty list ([]) if no diagnostics are found or no file is open. ' +
|
|
32
|
+
'Best Practice: Always check diagnostics after code generation to ensure code quality and fix any issues immediately. ' +
|
|
33
|
+
'Diagnostic Severity Handling Guidelines: ' +
|
|
34
|
+
'- "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. ' +
|
|
35
|
+
'- "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. ' +
|
|
36
|
+
'- "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',
|
|
37
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
|
|
38
|
+
handler: this.handler.bind(this),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async handler(args, logger) {
|
|
42
|
+
try {
|
|
43
|
+
// 获取当前活动的编辑器
|
|
44
|
+
const editor = this.editorService.currentEditor;
|
|
45
|
+
if (!editor || !editor.currentUri) {
|
|
46
|
+
logger.appendLine('Error: No active text editor found');
|
|
47
|
+
return {
|
|
48
|
+
content: [{ type: 'text', text: '[]' }],
|
|
49
|
+
isError: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// 获取工作区根目录
|
|
53
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
54
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
55
|
+
logger.appendLine('Error: Cannot determine project directory');
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: 'text', text: '[]' }],
|
|
58
|
+
isError: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// 获取当前文件的诊断信息
|
|
62
|
+
const monacoUri = uri_1.URI.parse(editor.currentUri.toString());
|
|
63
|
+
const markers = this.markerService.read({ resource: monacoUri });
|
|
64
|
+
const rootUri = ide_core_common_1.URI.parse(workspaceRoots[0].uri);
|
|
65
|
+
const relativePath = path.relative(rootUri.codeUri.fsPath, editor.currentUri.codeUri.fsPath);
|
|
66
|
+
// 转换诊断信息
|
|
67
|
+
const diagnosticInfos = markers.map((marker) => ({
|
|
68
|
+
path: relativePath,
|
|
69
|
+
line: marker.startLineNumber,
|
|
70
|
+
severity: this.getSeverityString(marker.severity),
|
|
71
|
+
message: marker.message,
|
|
72
|
+
}));
|
|
73
|
+
// 将结果转换为 JSON 字符串
|
|
74
|
+
const resultJson = JSON.stringify(diagnosticInfos, null, 2);
|
|
75
|
+
logger.appendLine(`Found ${diagnosticInfos.length} diagnostics in current file`);
|
|
76
|
+
return {
|
|
77
|
+
content: [{ type: 'text', text: resultJson }],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
logger.appendLine(`Error getting diagnostics: ${error}`);
|
|
82
|
+
return {
|
|
83
|
+
content: [{ type: 'text', text: '[]' }],
|
|
84
|
+
isError: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
getSeverityString(severity) {
|
|
89
|
+
switch (severity) {
|
|
90
|
+
case markers_1.MarkerSeverity.Error:
|
|
91
|
+
return 'error';
|
|
92
|
+
case markers_1.MarkerSeverity.Warning:
|
|
93
|
+
return 'warning';
|
|
94
|
+
case markers_1.MarkerSeverity.Info:
|
|
95
|
+
return 'information';
|
|
96
|
+
case markers_1.MarkerSeverity.Hint:
|
|
97
|
+
return 'hint';
|
|
98
|
+
default:
|
|
99
|
+
return 'unknown';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
exports.GetOpenEditorFileDiagnosticsTool = GetOpenEditorFileDiagnosticsTool;
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, di_1.Autowired)(ide_editor_1.WorkbenchEditorService),
|
|
106
|
+
tslib_1.__metadata("design:type", ide_editor_1.WorkbenchEditorService)
|
|
107
|
+
], GetOpenEditorFileDiagnosticsTool.prototype, "editorService", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, di_1.Autowired)(ide_workspace_1.IWorkspaceService),
|
|
110
|
+
tslib_1.__metadata("design:type", Object)
|
|
111
|
+
], GetOpenEditorFileDiagnosticsTool.prototype, "workspaceService", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, di_1.Autowired)(markers_1.IMarkerService),
|
|
114
|
+
tslib_1.__metadata("design:type", Object)
|
|
115
|
+
], GetOpenEditorFileDiagnosticsTool.prototype, "markerService", void 0);
|
|
116
|
+
exports.GetOpenEditorFileDiagnosticsTool = GetOpenEditorFileDiagnosticsTool = tslib_1.__decorate([
|
|
117
|
+
(0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
|
|
118
|
+
], GetOpenEditorFileDiagnosticsTool);
|
|
119
|
+
//# sourceMappingURL=getOpenEditorFileDiagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOpenEditorFileDiagnostics.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,6BAAwB;AACxB,2DAAqD;AAErD,qCAAqD;AACrD,+DAAwD;AACxD,qDAA8D;AAC9D,2DAA4D;AAC5D,6EAAuF;AACvF,iGAAqH;AAErH,uCAAsG;AAEtG,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAG1B,IAAM,g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,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACvC,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,QAAwB;QAChD,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,wBAAc,CAAC,KAAK;gBACvB,OAAO,OAAO,CAAC;YACjB,KAAK,wBAAc,CAAC,OAAO;gBACzB,OAAO,SAAS,CAAC;YACnB,KAAK,wBAAc,CAAC,IAAI;gBACtB,OAAO,aAAa,CAAC;YACvB,KAAK,wBAAc,CAAC,IAAI;gBACtB,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF,CAAA;AAvGY,4EAAgC;AAE1B;IADhB,IAAA,cAAS,EAAC,mCAAsB,CAAC;sCACF,mCAAsB;uEAAC;AAGtC;IADhB,IAAA,cAAS,EAAC,iCAAiB,CAAC;;0EACwB;AAGpC;IADhB,IAAA,cAAS,EAAC,wBAAc,CAAC;;uEACqB;2CARpC,gCAAgC;IAD5C,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,gCAAgC,CAuG5C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
2
|
+
export declare class GetOpenEditorFileTextTool implements MCPServerContribution {
|
|
3
|
+
private readonly editorService;
|
|
4
|
+
registerMCPServer(registry: IMCPServerRegistry): void;
|
|
5
|
+
getToolDefinition(): MCPToolDefinition;
|
|
6
|
+
private handler;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=getOpenEditorFileText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOpenEditorFileText.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/getOpenEditorFileText.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAItG,qBACa,yBAA0B,YAAW,qBAAqB;IAErE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAEvD,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAYxB,OAAO;CAiBtB"}
|