@opensumi/ide-ai-native 3.7.2-next-1740066619.0 → 3.7.2-next-1740323956.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.map +1 -1
- package/lib/browser/ai-core.contribution.js +4 -0
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +6 -0
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +5 -23
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +1 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +8 -1
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +4 -0
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +10 -1
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +2 -2
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -1
- package/lib/browser/components/ChatContext/index.js +18 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -1
- package/lib/browser/components/ChatContext/style.module.less +12 -0
- package/lib/browser/components/ChatEditor.d.ts +1 -0
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +3 -3
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts +1 -0
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js +2 -2
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +6 -8
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts +1 -0
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +25 -7
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/components.module.less +3 -2
- package/lib/browser/context/llm-context.service.d.ts +1 -0
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +24 -18
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +11 -12
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +67 -0
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -0
- package/lib/browser/mcp/base-apply.service.js +290 -0
- package/lib/browser/mcp/base-apply.service.js.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +6 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +2 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +5 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +17 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts +3 -0
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/EditFile.js +101 -0
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts +11 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/SearchResult.js +60 -0
- package/lib/browser/mcp/tools/components/SearchResult.js.map +1 -0
- package/lib/browser/mcp/tools/components/index.module.less +132 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +1 -2
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/{getSelectedText.d.ts → editFile.d.ts} +3 -3
- package/lib/browser/mcp/tools/editFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/editFile.js +95 -0
- package/lib/browser/mcp/tools/editFile.js.map +1 -0
- package/lib/browser/mcp/tools/{findFilesByNameSubstring.d.ts → fileSearch.d.ts} +3 -2
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -0
- package/lib/browser/mcp/tools/fileSearch.js +94 -0
- package/lib/browser/mcp/tools/fileSearch.js.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +1 -2
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +1 -2
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/{getFileTextByPath.d.ts → grepSearch.d.ts} +4 -3
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -0
- package/lib/browser/mcp/tools/grepSearch.js +118 -0
- package/lib/browser/mcp/tools/grepSearch.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts +10 -0
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/EditFile.js +28 -0
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +6 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js +14 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/utils.d.ts +2 -0
- package/lib/browser/mcp/tools/handlers/utils.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/utils.js +7 -0
- package/lib/browser/mcp/tools/handlers/utils.js.map +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +3 -4
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/readFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/readFile.js +3 -4
- package/lib/browser/mcp/tools/readFile.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +1 -2
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +5 -0
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +14 -0
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +5 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +14 -10
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +1 -2
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +1 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +3 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +4 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/mcp-server-manager.d.ts +1 -1
- package/lib/common/mcp-server-manager.d.ts.map +1 -1
- package/lib/common/mcp-server-manager.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +14 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -0
- package/lib/common/prompts/context-prompt-provider.js +38 -0
- package/lib/common/prompts/context-prompt-provider.js.map +1 -0
- package/lib/common/tool-invocation-registry.d.ts +2 -1
- package/lib/common/tool-invocation-registry.d.ts.map +1 -1
- package/lib/common/tool-invocation-registry.js.map +1 -1
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +3 -1
- package/lib/common/utils.js.map +1 -1
- package/lib/node/base-language-model.d.ts +2 -2
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +9 -5
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +5 -2
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +6 -5
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.d.ts +2 -2
- package/lib/node/mcp-server.d.ts.map +1 -1
- package/lib/node/mcp-server.js +2 -1
- package/lib/node/mcp-server.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +1 -1
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +2 -2
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +24 -25
- package/src/browser/ai-core.contribution.ts +4 -0
- package/src/browser/chat/chat-agent.service.ts +7 -0
- package/src/browser/chat/chat-model.ts +0 -2
- package/src/browser/chat/chat-proxy.service.ts +12 -2
- package/src/browser/chat/chat.internal.service.ts +12 -1
- package/src/browser/chat/chat.view.tsx +2 -1
- package/src/browser/components/ChatContext/index.tsx +19 -3
- package/src/browser/components/ChatContext/style.module.less +12 -0
- package/src/browser/components/ChatEditor.tsx +13 -10
- package/src/browser/components/ChatMarkdown.tsx +3 -1
- package/src/browser/components/ChatReply.tsx +8 -15
- package/src/browser/components/ChatToolRender.tsx +36 -17
- package/src/browser/components/components.module.less +3 -2
- package/src/browser/context/llm-context.service.ts +30 -18
- package/src/browser/index.ts +11 -12
- package/src/browser/mcp/base-apply.service.ts +349 -0
- package/src/browser/mcp/mcp-server-proxy.service.ts +4 -2
- package/src/browser/mcp/mcp-server.feature.registry.ts +27 -4
- package/src/browser/mcp/tools/components/EditFile.tsx +144 -0
- package/src/browser/mcp/tools/components/SearchResult.tsx +92 -0
- package/src/browser/mcp/tools/components/index.module.less +132 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +1 -2
- package/src/browser/mcp/tools/editFile.ts +100 -0
- package/src/browser/mcp/tools/fileSearch.ts +99 -0
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -2
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -2
- package/src/browser/mcp/tools/grepSearch.ts +121 -0
- package/src/browser/mcp/tools/handlers/EditFile.ts +21 -0
- package/src/browser/mcp/tools/handlers/ReadFile.ts +19 -1
- package/src/browser/mcp/tools/handlers/utils.ts +3 -0
- package/src/browser/mcp/tools/listDir.ts +3 -4
- package/src/browser/mcp/tools/readFile.ts +3 -4
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -2
- package/src/browser/model/msg-history-manager.ts +19 -0
- package/src/browser/preferences/schema.ts +5 -0
- package/src/browser/types.ts +15 -11
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +4 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +4 -0
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +1 -0
- package/src/common/index.ts +1 -0
- package/src/common/mcp-server-manager.ts +18 -13
- package/src/common/prompts/context-prompt-provider.ts +46 -0
- package/src/common/tool-invocation-registry.ts +122 -124
- package/src/common/utils.ts +2 -0
- package/src/node/base-language-model.ts +20 -6
- package/src/node/mcp/sumi-mcp-server.ts +5 -2
- package/src/node/mcp-server-manager-impl.ts +13 -5
- package/src/node/mcp-server.ts +3 -2
- package/src/node/openai/openai-language-model.ts +2 -2
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +0 -1
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js +0 -92
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +0 -1
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts +0 -8
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getCurrentFilePath.js +0 -49
- package/lib/browser/mcp/tools/getCurrentFilePath.js.map +0 -1
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getFileTextByPath.js +0 -97
- package/lib/browser/mcp/tools/getFileTextByPath.js.map +0 -1
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts +0 -8
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getOpenEditorFileText.js +0 -50
- package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +0 -1
- package/lib/browser/mcp/tools/getSelectedText.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getSelectedText.js +0 -57
- package/lib/browser/mcp/tools/getSelectedText.js.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts +0 -8
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js +0 -79
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts +0 -8
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +0 -84
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +0 -1
- package/src/browser/mcp/tools/findFilesByNameSubstring.ts +0 -93
- package/src/browser/mcp/tools/getCurrentFilePath.ts +0 -49
- package/src/browser/mcp/tools/getFileTextByPath.ts +0 -97
- package/src/browser/mcp/tools/getOpenEditorFileText.ts +0 -50
- package/src/browser/mcp/tools/getSelectedText.ts +0 -57
- package/src/browser/mcp/tools/replaceOpenEditorFile.ts +0 -80
- package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +0 -91
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
.edit-file-tool-header {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
padding: 2px 8px;
|
|
5
|
+
border-bottom: 1px solid var(--vscode-commandCenter-inactiveBorder);
|
|
6
|
+
background-color: var(--design-block-background);
|
|
7
|
+
font-size: 10px;
|
|
8
|
+
margin-bottom: -4px;
|
|
9
|
+
border-radius: 8px 8px 0 0;
|
|
10
|
+
> span {
|
|
11
|
+
margin-right: 4px;
|
|
12
|
+
}
|
|
13
|
+
:global(span.codicon) {
|
|
14
|
+
font-size: 12px;
|
|
15
|
+
}
|
|
16
|
+
:global(.kt-popover-trigger) {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
.edit-file-tool {
|
|
23
|
+
border: 1px solid var(--vscode-commandCenter-inactiveBorder);
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
margin: 8px 0;
|
|
26
|
+
:global(.language-badge) {
|
|
27
|
+
border-top-left-radius: 0;
|
|
28
|
+
}
|
|
29
|
+
pre > code {
|
|
30
|
+
border-radius: 0 0 8px 8px !important;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
.edit-file-tool-iteration-count {
|
|
34
|
+
color: var(--vscode-input-placeholderForeground);
|
|
35
|
+
margin-left: 4px;
|
|
36
|
+
}
|
|
37
|
+
:global(.clickable) {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
}
|
|
40
|
+
.edit-file-tool-diagnostic-errors {
|
|
41
|
+
padding: 8px;
|
|
42
|
+
border: 1px solid var(--vscode-commandCenter-inactiveBorder);
|
|
43
|
+
background-color: var(--design-block-background);
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
margin: 4px 0;
|
|
47
|
+
> div {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
padding: 2px 0;
|
|
51
|
+
}
|
|
52
|
+
:global(.codicon) {
|
|
53
|
+
margin-right: 4px;
|
|
54
|
+
}
|
|
55
|
+
.title {
|
|
56
|
+
margin-bottom: 3px;
|
|
57
|
+
display: inline-block;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
.error,
|
|
61
|
+
.error > span {
|
|
62
|
+
color: var(--debugConsole-errorForeground);
|
|
63
|
+
}
|
|
64
|
+
.warning,
|
|
65
|
+
.warning > span {
|
|
66
|
+
color: var(--debugConsole-warningForeground);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.container {
|
|
70
|
+
border: 1px solid var(--vscode-commandCenter-inactiveBorder);
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
margin: 8px 0;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.header {
|
|
77
|
+
padding: 8px 12px;
|
|
78
|
+
background-color: var(--design-block-background);
|
|
79
|
+
border-bottom: 1px solid var(--vscode-commandCenter-inactiveBorder);
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
gap: 4px;
|
|
84
|
+
color: var(--design-text-foreground);
|
|
85
|
+
font-size: 12px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.fileList {
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: 0;
|
|
91
|
+
list-style: none;
|
|
92
|
+
display: block;
|
|
93
|
+
background-color: var(--design-block-background);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.fileList.collapsed {
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.fileItem {
|
|
101
|
+
padding: 2px 6px;
|
|
102
|
+
font-size: 12px;
|
|
103
|
+
margin: 0px 6px;
|
|
104
|
+
border-radius: 4px;
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
gap: 8px;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
color: var(--design-text-primary);
|
|
110
|
+
&:hover {
|
|
111
|
+
background-color: var(--design-block-background);
|
|
112
|
+
}
|
|
113
|
+
> span {
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
text-overflow: ellipsis;
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.fileIcon {
|
|
121
|
+
color: var(--design-text-secondary);
|
|
122
|
+
font-size: 12px;
|
|
123
|
+
width: 16px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.filePath {
|
|
127
|
+
color: var(--design-text-secondary);
|
|
128
|
+
font-size: 12px;
|
|
129
|
+
margin-left: auto;
|
|
130
|
+
flex-basis: 0px;
|
|
131
|
+
flex-grow: 1;
|
|
132
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired } from '@opensumi/di';
|
|
5
4
|
import { Domain, URI, path } from '@opensumi/ide-core-common';
|
|
@@ -38,7 +37,7 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
|
38
37
|
'"ok" if the file was successfully created and populated, ' +
|
|
39
38
|
'"can\'t find project dir" if the project directory cannot be determined. ' +
|
|
40
39
|
'Note: Creates any necessary parent directories automatically.',
|
|
41
|
-
inputSchema
|
|
40
|
+
inputSchema,
|
|
42
41
|
handler: this.handler.bind(this),
|
|
43
42
|
};
|
|
44
43
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { Autowired } from '@opensumi/di';
|
|
4
|
+
import { Domain } from '@opensumi/ide-core-common';
|
|
5
|
+
|
|
6
|
+
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
7
|
+
|
|
8
|
+
import { EditFileToolComponent } from './components/EditFile';
|
|
9
|
+
import { EditFileHandler } from './handlers/EditFile';
|
|
10
|
+
const inputSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
target_file: z
|
|
13
|
+
.string()
|
|
14
|
+
.describe(
|
|
15
|
+
'The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit',
|
|
16
|
+
),
|
|
17
|
+
instructions: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe(
|
|
21
|
+
'A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit.',
|
|
22
|
+
),
|
|
23
|
+
code_edit: z
|
|
24
|
+
.string()
|
|
25
|
+
.describe(
|
|
26
|
+
"Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`",
|
|
27
|
+
),
|
|
28
|
+
})
|
|
29
|
+
.transform((data) => ({
|
|
30
|
+
targetFile: data.target_file,
|
|
31
|
+
instructions: data.instructions,
|
|
32
|
+
codeEdit: data.code_edit,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
@Domain(MCPServerContribution)
|
|
36
|
+
export class EditFileTool implements MCPServerContribution {
|
|
37
|
+
@Autowired(EditFileHandler)
|
|
38
|
+
private readonly editFileHandler: EditFileHandler;
|
|
39
|
+
|
|
40
|
+
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
41
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
42
|
+
registry.registerToolComponent('edit_file', EditFileToolComponent);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getToolDefinition(): MCPToolDefinition {
|
|
46
|
+
return {
|
|
47
|
+
name: 'edit_file',
|
|
48
|
+
label: 'Edit File',
|
|
49
|
+
description: `Use this tool to propose an edit to an existing file.
|
|
50
|
+
This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
|
|
51
|
+
When writing the edit, you should specify each edit in sequence, with the special comment \`// ... existing code ...\` to represent unchanged code in between edited lines.
|
|
52
|
+
For example:
|
|
53
|
+
\`\`\`
|
|
54
|
+
// ... existing code ...
|
|
55
|
+
FIRST_EDIT
|
|
56
|
+
// ... existing code ...
|
|
57
|
+
SECOND_EDIT
|
|
58
|
+
// ... existing code ...
|
|
59
|
+
THIRD_EDIT
|
|
60
|
+
// ... existing code ...
|
|
61
|
+
\`\`\`
|
|
62
|
+
You should bias towards repeating as few lines of the original file as possible to convey the change.
|
|
63
|
+
But, each edit should contain sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
|
|
64
|
+
DO NOT omit spans of pre-existing code without using the \`// ... existing code ...\` comment to indicate its absence.
|
|
65
|
+
Make sure it is clear what the edit should be.
|
|
66
|
+
You should specify the following arguments before the others: [target_file]`,
|
|
67
|
+
inputSchema,
|
|
68
|
+
handler: this.handler.bind(this),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private async handler(args: z.infer<typeof inputSchema>, logger: MCPLogger) {
|
|
73
|
+
const result = await this.editFileHandler.handler(args.targetFile, args.codeEdit, args.instructions);
|
|
74
|
+
return {
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: 'text',
|
|
78
|
+
// TODO: lint error
|
|
79
|
+
text: result.applyResult
|
|
80
|
+
? `The apply model made the following changes to the file:
|
|
81
|
+
|
|
82
|
+
\`\`\`
|
|
83
|
+
${result.applyResult.diff}
|
|
84
|
+
\`\`\`
|
|
85
|
+
${
|
|
86
|
+
result.applyResult.diagnosticInfos.length > 0
|
|
87
|
+
? `The edit introduced the following new linter errors:
|
|
88
|
+
${result.applyResult.diagnosticInfos
|
|
89
|
+
.map((error) => `Line ${error.startLineNumber}: ${error.message.split('\n')[0]}`)
|
|
90
|
+
.join('\n')}
|
|
91
|
+
|
|
92
|
+
Please fix the linter errors if it is clear how to (or you can easily figure out how to). Do not make uneducated guesses. And do not loop more than 3 times on fixing linter errors on the same file.`
|
|
93
|
+
: ''
|
|
94
|
+
}`
|
|
95
|
+
: 'User cancelled the edit.',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { Autowired } from '@opensumi/di';
|
|
4
|
+
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
5
|
+
import { FileSearchServicePath, IFileSearchService } from '@opensumi/ide-file-search/lib/common';
|
|
6
|
+
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
7
|
+
|
|
8
|
+
import { IChatInternalService } from '../../../common';
|
|
9
|
+
import { ChatInternalService } from '../../chat/chat.internal.service';
|
|
10
|
+
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
11
|
+
|
|
12
|
+
import { FileSearchToolComponent } from './components/SearchResult';
|
|
13
|
+
|
|
14
|
+
const inputSchema = z.object({
|
|
15
|
+
query: z.string().describe('Fuzzy filename to search for'),
|
|
16
|
+
explanation: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const MAX_RESULTS = 10;
|
|
22
|
+
|
|
23
|
+
@Domain(MCPServerContribution)
|
|
24
|
+
export class FileSearchTool implements MCPServerContribution {
|
|
25
|
+
@Autowired(IWorkspaceService)
|
|
26
|
+
private readonly workspaceService: IWorkspaceService;
|
|
27
|
+
|
|
28
|
+
@Autowired(FileSearchServicePath)
|
|
29
|
+
private readonly fileSearchService: IFileSearchService;
|
|
30
|
+
|
|
31
|
+
@Autowired(IChatInternalService)
|
|
32
|
+
private readonly chatInternalService: ChatInternalService;
|
|
33
|
+
|
|
34
|
+
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
35
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
36
|
+
registry.registerToolComponent('file_search', FileSearchToolComponent);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getToolDefinition(): MCPToolDefinition {
|
|
40
|
+
return {
|
|
41
|
+
name: 'file_search',
|
|
42
|
+
label: 'Search Files',
|
|
43
|
+
description:
|
|
44
|
+
"Fast file search based on fuzzy matching against file path. Use if you know part of the file path but don't know where it's located exactly. Response will be capped to 10 results. Make your query more specific if need to filter results further.",
|
|
45
|
+
inputSchema,
|
|
46
|
+
handler: this.handler.bind(this),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
51
|
+
if (!args.query) {
|
|
52
|
+
throw new Error('No fileSearch parameters provided. Need to give a query.');
|
|
53
|
+
}
|
|
54
|
+
// 获取工作区根目录
|
|
55
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
56
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
57
|
+
throw new Error('Cannot determine project directory');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 使用 OpenSumi 的文件搜索 API
|
|
61
|
+
const searchPattern = args.query;
|
|
62
|
+
const searchResults = await this.fileSearchService.find(searchPattern, {
|
|
63
|
+
rootUris: [new URI(workspaceRoots[0].uri).codeUri.fsPath],
|
|
64
|
+
// TODO: 忽略配置
|
|
65
|
+
excludePatterns: ['**/node_modules/**'],
|
|
66
|
+
limit: 100,
|
|
67
|
+
useGitIgnore: true,
|
|
68
|
+
noIgnoreParent: true,
|
|
69
|
+
fuzzyMatch: true,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const files = searchResults.slice(0, MAX_RESULTS).map((file) => {
|
|
73
|
+
const uri = URI.parse(file);
|
|
74
|
+
return uri.codeUri.fsPath;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
78
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
|
|
79
|
+
[args.toolCallId]: {
|
|
80
|
+
files,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
logger.appendLine(`Found ${files.length} files matching "${args.query}"`);
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: 'text',
|
|
90
|
+
text: `${files.join('\n')}\n${
|
|
91
|
+
searchResults.length > MAX_RESULTS
|
|
92
|
+
? `\nFound ${searchResults.length} files matching "${args.query}", only return the first ${MAX_RESULTS} results`
|
|
93
|
+
: ''
|
|
94
|
+
}`,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
5
4
|
|
|
6
5
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
7
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
@@ -47,7 +46,7 @@ export class GetDiagnosticsByPathTool implements MCPServerContribution {
|
|
|
47
46
|
'- "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. ' +
|
|
48
47
|
'- "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. ' +
|
|
49
48
|
'- "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',
|
|
50
|
-
inputSchema
|
|
49
|
+
inputSchema,
|
|
51
50
|
handler: this.handler.bind(this),
|
|
52
51
|
};
|
|
53
52
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
5
4
|
|
|
6
5
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
7
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
@@ -47,7 +46,7 @@ export class GetOpenEditorFileDiagnosticsTool implements MCPServerContribution {
|
|
|
47
46
|
'- "error": Must be fixed immediately as they indicate critical issues that will prevent code from working correctly. ' +
|
|
48
47
|
'- "warning": For user code, preserve unless the warning indicates a clear improvement opportunity. For generated code, optimize to remove warnings. ' +
|
|
49
48
|
'- "information"/"hint": For user code, preserve as they might reflect intentional patterns. For generated code, optimize if it improves code quality without changing functionality.',
|
|
50
|
-
inputSchema
|
|
49
|
+
inputSchema,
|
|
51
50
|
handler: this.handler.bind(this),
|
|
52
51
|
};
|
|
53
52
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { Autowired } from '@opensumi/di';
|
|
4
|
+
import { CancellationToken, Deferred, Domain } from '@opensumi/ide-core-common';
|
|
5
|
+
import { ContentSearchResult, IContentSearchClientService } from '@opensumi/ide-search';
|
|
6
|
+
import { ContentSearchClientService } from '@opensumi/ide-search/lib/browser/search.service';
|
|
7
|
+
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
8
|
+
|
|
9
|
+
import { IChatInternalService } from '../../../common';
|
|
10
|
+
import { ChatInternalService } from '../../chat/chat.internal.service';
|
|
11
|
+
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
12
|
+
|
|
13
|
+
import { GrepSearchToolComponent } from './components/SearchResult';
|
|
14
|
+
|
|
15
|
+
const inputSchema = z.object({
|
|
16
|
+
query: z.string().describe('The regex pattern to search for'),
|
|
17
|
+
case_sensitive: z.boolean().optional().describe('Whether the search should be case sensitive'),
|
|
18
|
+
include_pattern: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),
|
|
22
|
+
exclude_pattern: z.string().optional().describe('Glob pattern for files to exclude'),
|
|
23
|
+
explanation: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const MAX_RESULTS = 50;
|
|
30
|
+
|
|
31
|
+
@Domain(MCPServerContribution)
|
|
32
|
+
export class GrepSearchTool implements MCPServerContribution {
|
|
33
|
+
@Autowired(IWorkspaceService)
|
|
34
|
+
private readonly workspaceService: IWorkspaceService;
|
|
35
|
+
|
|
36
|
+
@Autowired(IContentSearchClientService)
|
|
37
|
+
private readonly searchService: ContentSearchClientService;
|
|
38
|
+
|
|
39
|
+
@Autowired(IChatInternalService)
|
|
40
|
+
private readonly chatInternalService: ChatInternalService;
|
|
41
|
+
|
|
42
|
+
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
43
|
+
registry.registerMCPTool(this.getToolDefinition());
|
|
44
|
+
registry.registerToolComponent('grep_search', GrepSearchToolComponent);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getToolDefinition(): MCPToolDefinition {
|
|
48
|
+
return {
|
|
49
|
+
name: 'grep_search',
|
|
50
|
+
label: 'Search Contents',
|
|
51
|
+
description:
|
|
52
|
+
// TODO: 支持语义化搜索后需要描述清楚优劣势
|
|
53
|
+
'Fast text-based regex search that finds exact pattern matches within files or directories, utilizing the ripgrep command for efficient searching.\nResults will be formatted in the style of ripgrep and can be configured to include line numbers and content.\nTo avoid overwhelming output, the results are capped at 50 matches.\nUse the include or exclude patterns to filter the search scope by file type or specific paths.\n\nThis is best for finding exact text matches or regex patterns.',
|
|
54
|
+
inputSchema,
|
|
55
|
+
handler: this.handler.bind(this),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
60
|
+
if (!args.query) {
|
|
61
|
+
throw new Error('No ripgrep search parameters provided. Need to give at least a query.');
|
|
62
|
+
}
|
|
63
|
+
// 获取工作区根目录
|
|
64
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
65
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
66
|
+
throw new Error('Cannot determine project directory');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 使用 OpenSumi 的文件搜索 API
|
|
70
|
+
const searchPattern = args.query;
|
|
71
|
+
await this.searchService.doSearch(
|
|
72
|
+
searchPattern,
|
|
73
|
+
{
|
|
74
|
+
isMatchCase: !!args.case_sensitive,
|
|
75
|
+
include: args.include_pattern?.split(','),
|
|
76
|
+
exclude: args.exclude_pattern?.split(','),
|
|
77
|
+
maxResults: MAX_RESULTS,
|
|
78
|
+
isUseRegexp: true,
|
|
79
|
+
isToggleOpen: false,
|
|
80
|
+
isDetailOpen: false,
|
|
81
|
+
isWholeWord: false,
|
|
82
|
+
isOnlyOpenEditors: false,
|
|
83
|
+
isIncludeIgnored: false,
|
|
84
|
+
},
|
|
85
|
+
CancellationToken.None,
|
|
86
|
+
);
|
|
87
|
+
const deferred = new Deferred<string>();
|
|
88
|
+
this.searchService.onDidChange(() => {
|
|
89
|
+
if (this.searchService.isSearching) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const results: string[] = [];
|
|
93
|
+
const files: string[] = [];
|
|
94
|
+
for (const [fileUri, result] of this.searchService.searchResults.entries()) {
|
|
95
|
+
results.push(
|
|
96
|
+
`File: ${fileUri}\n${result
|
|
97
|
+
.reduce((acc, r) => {
|
|
98
|
+
if (acc.find((a) => a.line === r.line)) {
|
|
99
|
+
return acc;
|
|
100
|
+
}
|
|
101
|
+
return [...acc, r];
|
|
102
|
+
}, [] as ContentSearchResult[])
|
|
103
|
+
.map((r) => `Line: ${r.line}\nContent: ${r.lineText || r.renderLineText}`)
|
|
104
|
+
.join('\n')}`,
|
|
105
|
+
);
|
|
106
|
+
files.push(fileUri);
|
|
107
|
+
}
|
|
108
|
+
deferred.resolve(results.join('\n\n'));
|
|
109
|
+
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
110
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
|
|
111
|
+
[args.toolCallId]: {
|
|
112
|
+
files,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
const text = await deferred.promise;
|
|
117
|
+
return {
|
|
118
|
+
content: [{ type: 'text', text }],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
|
|
3
|
+
import { BaseApplyService } from '../../base-apply.service';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TODO: 代码块改动版本号,次数,流式工具调用?
|
|
7
|
+
* 基础文件编辑处理类
|
|
8
|
+
* 用于处理代码改动的应用、保存等操作
|
|
9
|
+
*/
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class EditFileHandler {
|
|
12
|
+
@Autowired(BaseApplyService)
|
|
13
|
+
private applyService: BaseApplyService;
|
|
14
|
+
|
|
15
|
+
async handler(relativePath: string, updateContent: string, instructions?: string) {
|
|
16
|
+
// TODO: ignore file
|
|
17
|
+
this.applyService.registerCodeBlock(relativePath, updateContent);
|
|
18
|
+
const blockData = await this.applyService.apply(relativePath, updateContent, instructions);
|
|
19
|
+
return blockData;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -12,6 +12,11 @@ export class FileHandler {
|
|
|
12
12
|
private static readonly MAX_CHARS = 1e5;
|
|
13
13
|
private static readonly NEWLINE = '\n';
|
|
14
14
|
|
|
15
|
+
private fileResultMap: Map<
|
|
16
|
+
string,
|
|
17
|
+
{ content: string; startLineOneIndexed: number; endLineOneIndexedInclusive: number }
|
|
18
|
+
> = new Map();
|
|
19
|
+
|
|
15
20
|
@Autowired(IEditorDocumentModelService)
|
|
16
21
|
protected modelService: IEditorDocumentModelService;
|
|
17
22
|
|
|
@@ -141,7 +146,14 @@ export class FileHandler {
|
|
|
141
146
|
didShortenCharRange = true;
|
|
142
147
|
selectedContent = this.trimContent(selectedContent, FileHandler.MAX_CHARS);
|
|
143
148
|
}
|
|
144
|
-
|
|
149
|
+
// 文件的浏览窗口需要记录,应用的时候需要用
|
|
150
|
+
if (didShortenLineRange) {
|
|
151
|
+
this.fileResultMap.set(fileParams.relativeWorkspacePath, {
|
|
152
|
+
content: selectedContent,
|
|
153
|
+
startLineOneIndexed: adjustedStart,
|
|
154
|
+
endLineOneIndexedInclusive: adjustedEnd,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
145
157
|
return {
|
|
146
158
|
contents: selectedContent,
|
|
147
159
|
didDowngradeToLineRange: shouldForceLimitLines,
|
|
@@ -171,4 +183,10 @@ export class FileHandler {
|
|
|
171
183
|
modelReference?.dispose();
|
|
172
184
|
}
|
|
173
185
|
}
|
|
186
|
+
|
|
187
|
+
getFileReadResult(
|
|
188
|
+
relativeWorkspacePath: string,
|
|
189
|
+
): { content: string; startLineOneIndexed: number; endLineOneIndexedInclusive: number } | undefined {
|
|
190
|
+
return this.fileResultMap.get(relativeWorkspacePath);
|
|
191
|
+
}
|
|
174
192
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired } from '@opensumi/di';
|
|
5
4
|
import { Domain } from '@opensumi/ide-core-common';
|
|
@@ -15,6 +14,7 @@ const inputSchema = z
|
|
|
15
14
|
.describe("Path to list contents of, relative to the workspace root. Ex: './' is the root of the workspace"),
|
|
16
15
|
explanation: z
|
|
17
16
|
.string()
|
|
17
|
+
.optional()
|
|
18
18
|
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
19
19
|
})
|
|
20
20
|
.transform((data) => ({
|
|
@@ -33,16 +33,15 @@ export class ListDirTool implements MCPServerContribution {
|
|
|
33
33
|
getToolDefinition(): MCPToolDefinition {
|
|
34
34
|
return {
|
|
35
35
|
name: 'list_dir',
|
|
36
|
+
label: 'List Directory',
|
|
36
37
|
description:
|
|
37
38
|
'List the contents of a directory. The quick tool to use for discovery, before using more targeted tools like semantic search or file reading. Useful to try to understand the file structure before diving deeper into specific files. Can be used to explore the codebase.',
|
|
38
|
-
inputSchema
|
|
39
|
+
inputSchema,
|
|
39
40
|
handler: this.handler.bind(this),
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
private async handler(args: z.infer<typeof inputSchema>, logger: MCPLogger) {
|
|
44
|
-
// TODO: 应该添加统一的 validate 逻辑
|
|
45
|
-
args = inputSchema.parse(args);
|
|
46
45
|
const result = await this.listDirHandler.handler(args);
|
|
47
46
|
return {
|
|
48
47
|
content: [
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired } from '@opensumi/di';
|
|
5
4
|
import { Domain } from '@opensumi/ide-core-common';
|
|
@@ -16,6 +15,7 @@ const inputSchema = z
|
|
|
16
15
|
end_line_one_indexed_inclusive: z.number().describe('The one-indexed line number to end reading at (inclusive).'),
|
|
17
16
|
explanation: z
|
|
18
17
|
.string()
|
|
18
|
+
.optional()
|
|
19
19
|
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
20
20
|
})
|
|
21
21
|
.transform((data) => ({
|
|
@@ -37,6 +37,7 @@ export class ReadFileTool implements MCPServerContribution {
|
|
|
37
37
|
getToolDefinition(): MCPToolDefinition {
|
|
38
38
|
return {
|
|
39
39
|
name: 'read_file',
|
|
40
|
+
label: 'Read File',
|
|
40
41
|
description: `Read the contents of a file (and the outline).
|
|
41
42
|
|
|
42
43
|
When using this tool to gather information, it's your responsibility to ensure you have the COMPLETE context. Each time you call this command you should:
|
|
@@ -48,14 +49,12 @@ When using this tool to gather information, it's your responsibility to ensure y
|
|
|
48
49
|
If reading a range of lines is not enough, you may choose to read the entire file.
|
|
49
50
|
Reading entire files is often wasteful and slow, especially for large files (i.e. more than a few hundred lines). So you should use this option sparingly.
|
|
50
51
|
Reading the entire file is not allowed in most cases. You are only allowed to read the entire file if it has been edited or manually attached to the conversation by the user.`,
|
|
51
|
-
inputSchema
|
|
52
|
+
inputSchema,
|
|
52
53
|
handler: this.handler.bind(this),
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
private async handler(args: z.infer<typeof inputSchema>, logger: MCPLogger) {
|
|
57
|
-
// TODO: 应该添加统一的 validate 逻辑
|
|
58
|
-
args = inputSchema.parse(args);
|
|
59
58
|
const result = await this.fileHandler.readFile(args);
|
|
60
59
|
return {
|
|
61
60
|
content: [
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired } from '@opensumi/di';
|
|
5
4
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
@@ -48,7 +47,7 @@ export class RunTerminalCommandTool implements MCPServerContribution {
|
|
|
48
47
|
name: 'run_terminal_cmd',
|
|
49
48
|
description:
|
|
50
49
|
"PROPOSE a command to run on behalf of the user.\nIf you have this tool, note that you DO have the ability to run commands directly on the USER's system.\n\nAdhere to these rules:\n1. Based on the contents of the conversation, you will be told if you are in the same shell as a previous step or a new shell.\n2. If in a new shell, you should `cd` to the right directory and do necessary setup in addition to running the command.\n3. If in the same shell, the state will persist, no need to do things like `cd` to the same directory.\n4. For ANY commands that would use a pager, you should append ` | cat` to the command (or whatever is appropriate). You MUST do this for: git, less, head, tail, more, etc.\n5. For commands that are long running/expected to run indefinitely until interruption, please run them in the background. To run jobs in the background, set `is_background` to true rather than changing the details of the command.\n6. Dont include any newlines in the command.",
|
|
51
|
-
inputSchema
|
|
50
|
+
inputSchema,
|
|
52
51
|
handler: this.handler.bind(this),
|
|
53
52
|
};
|
|
54
53
|
}
|