@opensumi/ide-ai-native 3.8.2-next-1741622293.0 → 3.8.3-next-1741661270.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.
Files changed (165) hide show
  1. package/lib/browser/ai-core.contribution.d.ts.map +1 -1
  2. package/lib/browser/ai-core.contribution.js +20 -0
  3. package/lib/browser/ai-core.contribution.js.map +1 -1
  4. package/lib/browser/chat/chat-manager.service.d.ts +2 -1
  5. package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
  6. package/lib/browser/chat/chat-manager.service.js +26 -7
  7. package/lib/browser/chat/chat-manager.service.js.map +1 -1
  8. package/lib/browser/chat/chat-model.d.ts +3 -3
  9. package/lib/browser/chat/chat-model.d.ts.map +1 -1
  10. package/lib/browser/chat/chat-model.js +22 -9
  11. package/lib/browser/chat/chat-model.js.map +1 -1
  12. package/lib/browser/chat/chat-proxy.service.d.ts +1 -0
  13. package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
  14. package/lib/browser/chat/chat-proxy.service.js +2 -0
  15. package/lib/browser/chat/chat-proxy.service.js.map +1 -1
  16. package/lib/browser/chat/chat.view.d.ts.map +1 -1
  17. package/lib/browser/chat/chat.view.js +61 -5
  18. package/lib/browser/chat/chat.view.js.map +1 -1
  19. package/lib/browser/components/ApplyStatus.d.ts +7 -0
  20. package/lib/browser/components/ApplyStatus.d.ts.map +1 -0
  21. package/lib/browser/components/ApplyStatus.js +32 -0
  22. package/lib/browser/components/ApplyStatus.js.map +1 -0
  23. package/lib/browser/components/ChangeList.d.ts +17 -0
  24. package/lib/browser/components/ChangeList.d.ts.map +1 -0
  25. package/lib/browser/components/ChangeList.js +72 -0
  26. package/lib/browser/components/ChangeList.js.map +1 -0
  27. package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
  28. package/lib/browser/components/ChatToolRender.js +18 -12
  29. package/lib/browser/components/ChatToolRender.js.map +1 -1
  30. package/lib/browser/components/ChatToolRender.module.less +27 -15
  31. package/lib/browser/components/change-list.module.less +126 -0
  32. package/lib/browser/components/chat-history.module.less +1 -1
  33. package/lib/browser/components/components.module.less +14 -0
  34. package/lib/browser/contrib/inline-completions/prompt/matcher.js +2 -2
  35. package/lib/browser/contrib/inline-completions/prompt/similarSnippets.d.ts +1 -1
  36. package/lib/browser/contrib/inline-completions/prompt/similarSnippets.js +2 -2
  37. package/lib/browser/contrib/intelligent-completions/view/default.d.ts.map +1 -1
  38. package/lib/browser/contrib/intelligent-completions/view/default.js.map +1 -1
  39. package/lib/browser/index.d.ts.map +1 -1
  40. package/lib/browser/index.js +4 -4
  41. package/lib/browser/index.js.map +1 -1
  42. package/lib/browser/mcp/base-apply.service.d.ts +14 -6
  43. package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
  44. package/lib/browser/mcp/base-apply.service.js +80 -52
  45. package/lib/browser/mcp/base-apply.service.js.map +1 -1
  46. package/lib/browser/mcp/config/components/mcp-config.view.d.ts.map +1 -1
  47. package/lib/browser/mcp/config/components/mcp-config.view.js +12 -8
  48. package/lib/browser/mcp/config/components/mcp-config.view.js.map +1 -1
  49. package/lib/browser/mcp/config/mcp-config.contribution.js.map +1 -1
  50. package/lib/browser/mcp/mcp-server.feature.registry.js +1 -1
  51. package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
  52. package/lib/browser/mcp/tools/components/EditFile.js +3 -24
  53. package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
  54. package/lib/browser/mcp/tools/components/ExpandableFileList.js +3 -2
  55. package/lib/browser/mcp/tools/components/ExpandableFileList.js.map +1 -1
  56. package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
  57. package/lib/browser/mcp/tools/createNewFileWithText.js +1 -0
  58. package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
  59. package/lib/browser/mcp/tools/editFile.d.ts.map +1 -1
  60. package/lib/browser/mcp/tools/editFile.js +1 -0
  61. package/lib/browser/mcp/tools/editFile.js.map +1 -1
  62. package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
  63. package/lib/browser/mcp/tools/fileSearch.js +1 -0
  64. package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
  65. package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
  66. package/lib/browser/mcp/tools/getDiagnosticsByPath.js +2 -1
  67. package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
  68. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -1
  69. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +2 -0
  70. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
  71. package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
  72. package/lib/browser/mcp/tools/grepSearch.js +1 -0
  73. package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
  74. package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
  75. package/lib/browser/mcp/tools/listDir.js +1 -0
  76. package/lib/browser/mcp/tools/listDir.js.map +1 -1
  77. package/lib/browser/mcp/tools/readFile.d.ts.map +1 -1
  78. package/lib/browser/mcp/tools/readFile.js +1 -0
  79. package/lib/browser/mcp/tools/readFile.js.map +1 -1
  80. package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
  81. package/lib/browser/mcp/tools/runTerminalCmd.js +1 -0
  82. package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
  83. package/lib/browser/model/msg-history-manager.d.ts +0 -2
  84. package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
  85. package/lib/browser/model/msg-history-manager.js +1 -6
  86. package/lib/browser/model/msg-history-manager.js.map +1 -1
  87. package/lib/browser/preferences/schema.d.ts.map +1 -1
  88. package/lib/browser/preferences/schema.js +8 -0
  89. package/lib/browser/preferences/schema.js.map +1 -1
  90. package/lib/browser/types.d.ts +1 -0
  91. package/lib/browser/types.d.ts.map +1 -1
  92. package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts.map +1 -1
  93. package/lib/browser/widget/inline-diff/inline-diff-manager.js +2 -2
  94. package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +1 -1
  95. package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +1 -1
  96. package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
  97. package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
  98. package/lib/browser/widget/inline-diff/inline-diff.service.d.ts +3 -2
  99. package/lib/browser/widget/inline-diff/inline-diff.service.d.ts.map +1 -1
  100. package/lib/browser/widget/inline-diff/inline-diff.service.js.map +1 -1
  101. package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +1 -1
  102. package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
  103. package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
  104. package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +0 -33
  105. package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
  106. package/lib/browser/widget/inline-stream-diff/live-preview.component.js +1 -6
  107. package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
  108. package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
  109. package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +15 -14
  110. package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
  111. package/lib/common/index.d.ts +7 -2
  112. package/lib/common/index.d.ts.map +1 -1
  113. package/lib/common/index.js +3 -2
  114. package/lib/common/index.js.map +1 -1
  115. package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
  116. package/lib/common/prompts/context-prompt-provider.js +2 -4
  117. package/lib/common/prompts/context-prompt-provider.js.map +1 -1
  118. package/lib/common/types.d.ts +33 -0
  119. package/lib/common/types.d.ts.map +1 -1
  120. package/lib/common/types.js +6 -1
  121. package/lib/common/types.js.map +1 -1
  122. package/package.json +23 -23
  123. package/src/browser/ai-core.contribution.ts +28 -0
  124. package/src/browser/chat/chat-manager.service.ts +53 -31
  125. package/src/browser/chat/chat-model.ts +22 -8
  126. package/src/browser/chat/chat-proxy.service.ts +2 -0
  127. package/src/browser/chat/chat.view.tsx +80 -9
  128. package/src/browser/components/ApplyStatus.tsx +44 -0
  129. package/src/browser/components/ChangeList.tsx +131 -0
  130. package/src/browser/components/ChatToolRender.module.less +27 -15
  131. package/src/browser/components/ChatToolRender.tsx +14 -12
  132. package/src/browser/components/change-list.module.less +126 -0
  133. package/src/browser/components/chat-history.module.less +1 -1
  134. package/src/browser/components/components.module.less +14 -0
  135. package/src/browser/contrib/inline-completions/prompt/matcher.ts +2 -2
  136. package/src/browser/contrib/inline-completions/prompt/similarSnippets.ts +2 -2
  137. package/src/browser/contrib/intelligent-completions/view/default.ts +1 -0
  138. package/src/browser/index.ts +5 -4
  139. package/src/browser/mcp/base-apply.service.ts +84 -62
  140. package/src/browser/mcp/config/components/mcp-config.view.tsx +4 -0
  141. package/src/browser/mcp/config/mcp-config.contribution.ts +1 -1
  142. package/src/browser/mcp/mcp-server.feature.registry.ts +1 -1
  143. package/src/browser/mcp/tools/components/EditFile.tsx +3 -37
  144. package/src/browser/mcp/tools/components/ExpandableFileList.tsx +3 -1
  145. package/src/browser/mcp/tools/createNewFileWithText.ts +1 -0
  146. package/src/browser/mcp/tools/editFile.ts +1 -0
  147. package/src/browser/mcp/tools/fileSearch.ts +1 -0
  148. package/src/browser/mcp/tools/getDiagnosticsByPath.ts +2 -1
  149. package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +2 -0
  150. package/src/browser/mcp/tools/grepSearch.ts +1 -0
  151. package/src/browser/mcp/tools/listDir.ts +1 -0
  152. package/src/browser/mcp/tools/readFile.ts +1 -0
  153. package/src/browser/mcp/tools/runTerminalCmd.ts +1 -0
  154. package/src/browser/model/msg-history-manager.ts +1 -8
  155. package/src/browser/preferences/schema.ts +8 -0
  156. package/src/browser/types.ts +1 -0
  157. package/src/browser/widget/inline-diff/inline-diff-manager.tsx +3 -2
  158. package/src/browser/widget/inline-diff/inline-diff.controller.ts +2 -1
  159. package/src/browser/widget/inline-diff/inline-diff.service.ts +3 -2
  160. package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +4 -4
  161. package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +0 -34
  162. package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +8 -9
  163. package/src/common/index.ts +9 -2
  164. package/src/common/prompts/context-prompt-provider.ts +2 -6
  165. package/src/common/types.ts +35 -0
@@ -71,7 +71,9 @@ const ExpandableFileList: React.FC<ExpandableFileListProps> = ({
71
71
 
72
72
  useEffect(() => {
73
73
  const toDispose = chatService.sessionModel.history.onMessageAdditionalChange((additional) => {
74
- setFileList(additional[toolCallId]?.files || []);
74
+ if (additional[toolCallId]) {
75
+ setFileList(additional[toolCallId].files || []);
76
+ }
75
77
  });
76
78
  return () => {
77
79
  toDispose.dispose();
@@ -35,6 +35,7 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
35
35
  return {
36
36
  name: 'create_new_file_with_text',
37
37
  label: 'Create File',
38
+ order: 7,
38
39
  description:
39
40
  'Creates a new file at the specified path within the project directory and populates it with the provided text. ' +
40
41
  'Use this tool to generate new files in your project structure. ' +
@@ -46,6 +46,7 @@ export class EditFileTool implements MCPServerContribution {
46
46
  return {
47
47
  name: 'edit_file',
48
48
  label: 'Edit File',
49
+ order: 5,
49
50
  description: `Use this tool to propose an edit to an existing file.
50
51
  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
52
  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.
@@ -41,6 +41,7 @@ export class FileSearchTool implements MCPServerContribution {
41
41
  return {
42
42
  name: 'file_search',
43
43
  label: 'Search Files',
44
+ order: 6,
44
45
  description:
45
46
  "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.",
46
47
  inputSchema,
@@ -29,7 +29,8 @@ export class GetDiagnosticsByPathTool implements MCPServerContribution {
29
29
  getToolDefinition(): MCPToolDefinition {
30
30
  return {
31
31
  name: 'get_diagnostics_by_path',
32
- label: 'Get Diagnostics',
32
+ label: 'Get Diagnostics By Path',
33
+ order: 9,
33
34
  description:
34
35
  'Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. ' +
35
36
  'Use this tool to get information about problems in any project file. ' +
@@ -31,6 +31,8 @@ export class GetOpenEditorFileDiagnosticsTool implements MCPServerContribution {
31
31
  getToolDefinition(): MCPToolDefinition {
32
32
  return {
33
33
  name: 'get_open_in_editor_file_diagnostics',
34
+ label: 'Get Current Editor Diagnostics',
35
+ order: 8,
34
36
  description:
35
37
  'Retrieves diagnostic information (errors, warnings, etc.) from the currently active file in VS Code editor. ' +
36
38
  'Use this tool to get information about problems in your current file. ' +
@@ -48,6 +48,7 @@ export class GrepSearchTool implements MCPServerContribution {
48
48
  return {
49
49
  name: 'grep_search',
50
50
  label: 'Search Contents',
51
+ order: 4,
51
52
  description:
52
53
  // TODO: 支持语义化搜索后需要描述清楚优劣势
53
54
  '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.',
@@ -41,6 +41,7 @@ export class ListDirTool implements MCPServerContribution {
41
41
  return {
42
42
  name: 'list_dir',
43
43
  label: 'List Directory',
44
+ order: 3,
44
45
  description:
45
46
  '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.',
46
47
  inputSchema,
@@ -38,6 +38,7 @@ export class ReadFileTool implements MCPServerContribution {
38
38
  return {
39
39
  name: 'read_file',
40
40
  label: 'Read File',
41
+ order: 1,
41
42
  description: `Read the contents of a file (and the outline).
42
43
 
43
44
  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:
@@ -33,6 +33,7 @@ export class RunTerminalCommandTool implements MCPServerContribution {
33
33
  return {
34
34
  name: 'run_terminal_cmd',
35
35
  label: 'Run Command',
36
+ order: 2,
36
37
  description:
37
38
  "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.",
38
39
  inputSchema,
@@ -29,7 +29,6 @@ export class MsgHistoryManager extends Disposable {
29
29
  public clearMessages() {
30
30
  this.messageMap.clear();
31
31
  this.messageAdditionalMap.clear();
32
- this.startIndex = 0;
33
32
  }
34
33
 
35
34
  private doAddMessage(message: IExcludeMessage): string {
@@ -53,19 +52,13 @@ export class MsgHistoryManager extends Disposable {
53
52
  return Array.from(this.messageMap.values()).sort((a, b) => a.order - b.order);
54
53
  }
55
54
 
56
- private startIndex = 0;
57
-
58
- public get slicedMessageCount(): number {
59
- return this.startIndex;
60
- }
61
-
62
55
  public get lastMessageId(): string | undefined {
63
56
  const list = this.messageList;
64
57
  return list[list.length - 1]?.id;
65
58
  }
66
59
 
67
60
  public getMessages(): IHistoryChatMessage[] {
68
- return this.messageList.slice(this.startIndex);
61
+ return this.messageList;
69
62
  }
70
63
 
71
64
  public addUserMessage(
@@ -97,6 +97,14 @@ export const aiNativePreferenceSchema: PreferenceSchema = {
97
97
  default: '',
98
98
  description: localize('preference.ai.native.openai.baseURL.description'),
99
99
  },
100
+ [AINativeSettingSectionsId.ContextWindow]: {
101
+ type: 'number',
102
+ description: localize('preference.ai.native.contextWindow.description'),
103
+ },
104
+ [AINativeSettingSectionsId.MaxTokens]: {
105
+ type: 'number',
106
+ description: localize('preference.ai.native.maxTokens.description'),
107
+ },
100
108
  [AINativeSettingSectionsId.MCPServers]: {
101
109
  type: 'array',
102
110
  default: [],
@@ -350,6 +350,7 @@ export interface MCPLogger {
350
350
  export interface MCPToolDefinition {
351
351
  name: string;
352
352
  label?: string;
353
+ order?: number;
353
354
  description: string;
354
355
  inputSchema: ZodSchema<any>; // JSON Schema
355
356
  handler: (
@@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import { Icon, Popover } from '@opensumi/ide-components';
4
4
  import { AppConfig, IDisposable, URI, localize, path, useInjectable } from '@opensumi/ide-core-browser';
5
5
  import { IResource, WorkbenchEditorService } from '@opensumi/ide-editor';
6
+ import { Path } from '@opensumi/ide-utils/lib/path';
6
7
 
7
8
  import { BaseApplyService } from '../../mcp/base-apply.service';
8
9
 
@@ -113,13 +114,13 @@ export const InlineDiffManager: React.FC<{ resource: IResource }> = (props) => {
113
114
  <div className={styles.mid}>
114
115
  <IconWithPopover
115
116
  icon='codicon codicon-check'
116
- onClick={() => applyService.processAll(props.resource.uri, 'accept')}
117
+ onClick={() => applyService.processAll('accept', props.resource.uri)}
117
118
  content={localize('aiNative.inlineDiff.acceptAll')}
118
119
  id='inline-diff-manager-accept-all'
119
120
  />
120
121
  <IconWithPopover
121
122
  icon='codicon codicon-close'
122
- onClick={() => applyService.processAll(props.resource.uri, 'reject')}
123
+ onClick={() => applyService.processAll('reject', props.resource.uri)}
123
124
  content={localize('aiNative.inlineDiff.rejectAll')}
124
125
  id='inline-diff-manager-reject-all'
125
126
  />
@@ -23,7 +23,6 @@ import {
23
23
  import { BaseAIMonacoEditorController } from '../../contrib/base';
24
24
  import { EInlineDiffPreviewMode } from '../../preferences/schema';
25
25
  import { InlineChatController } from '../inline-chat/inline-chat-controller';
26
- import { EResultKind } from '../inline-chat/inline-chat.service';
27
26
  import { BaseInlineStreamDiffHandler } from '../inline-stream-diff/inline-stream-diff.handler';
28
27
 
29
28
  import {
@@ -34,6 +33,8 @@ import {
34
33
  } from './inline-diff-previewer';
35
34
  import { InlineDiffWidget } from './inline-diff-widget';
36
35
 
36
+ import type { EResultKind } from '../inline-chat/inline-chat.service';
37
+
37
38
  type IInlineDiffPreviewer = BaseInlineDiffPreviewer<InlineDiffWidget | BaseInlineStreamDiffHandler>;
38
39
 
39
40
  export class InlineDiffController extends BaseAIMonacoEditorController {
@@ -1,10 +1,11 @@
1
1
  import { Injectable } from '@opensumi/di';
2
2
  import { Emitter } from '@opensumi/ide-utils';
3
3
 
4
- import { IPartialEditEvent } from '../inline-stream-diff/live-preview.component';
4
+ import type { IInlineDiffService } from '../../../common/index';
5
+ import type { IPartialEditEvent } from '../../../common/types';
5
6
 
6
7
  @Injectable()
7
- export class InlineDiffService {
8
+ export class InlineDiffService implements IInlineDiffService {
8
9
  /**
9
10
  * Used in `codeblitz`, do not remove it.
10
11
  */
@@ -11,13 +11,13 @@ import { IModelService } from '@opensumi/monaco-editor-core/esm/vs/editor/common
11
11
  import { LineTokens } from '@opensumi/monaco-editor-core/esm/vs/editor/common/tokens/lineTokens';
12
12
  import { UndoRedoGroup } from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
13
13
 
14
- import { IDecorationSerializableState } from '../../model/enhanceDecorationsCollection';
15
- import { IDiffPreviewerOptions, IInlineDiffPreviewerNode } from '../inline-diff/inline-diff-previewer';
16
-
17
14
  import { InlineStreamDiffComputer } from './inline-stream-diff-computer';
18
- import { IRemovedWidgetState } from './live-preview.component';
19
15
  import { LivePreviewDiffDecorationModel } from './live-preview.decoration';
20
16
 
17
+ import type { IRemovedWidgetState } from './live-preview.component';
18
+ import type { IDecorationSerializableState } from '../../model/enhanceDecorationsCollection';
19
+ import type { IDiffPreviewerOptions, IInlineDiffPreviewerNode } from '../inline-diff/inline-diff-previewer';
20
+
21
21
  interface IRangeChangeData {
22
22
  removedTextLines: string[];
23
23
  removedLinesOriginalRange: LineRange;
@@ -46,40 +46,6 @@ export interface IRemovedWidgetState {
46
46
  position: IPosition;
47
47
  }
48
48
 
49
- export enum EPartialEdit {
50
- accept = 'accept',
51
- discard = 'discard',
52
- }
53
-
54
- export interface IPartialEditEvent {
55
- uri: URI;
56
- /**
57
- * 总 diff 数
58
- */
59
- totalPartialEditCount: number;
60
- /**
61
- * 已处理的个数
62
- */
63
- resolvedPartialEditCount: number;
64
- /**
65
- * 已添加行数
66
- */
67
- totalAddedLinesCount: number;
68
- /**
69
- * 已采纳的个数
70
- */
71
- acceptPartialEditCount: number;
72
- /**
73
- * 已删除行数
74
- */
75
- totalDeletedLinesCount: number;
76
- currentPartialEdit: {
77
- type: EPartialEdit;
78
- addedLinesCount: number;
79
- deletedLinesCount: number;
80
- };
81
- }
82
-
83
49
  export interface ITextLinesTokens {
84
50
  text: string;
85
51
  lineTokens: LineTokens;
@@ -19,9 +19,10 @@ import { LineRange } from '@opensumi/monaco-editor-core/esm/vs/editor/common/cor
19
19
  import { ModelDecorationOptions } from '@opensumi/monaco-editor-core/esm/vs/editor/common/model/textModel';
20
20
  import { IUndoRedoService, UndoRedoGroup } from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
21
21
 
22
+ import { IInlineDiffService, InlineDiffServiceToken } from '../../../common';
23
+ import { EPartialEdit, IPartialEditEvent } from '../../../common/types';
22
24
  import { AINativeContextKey } from '../../ai-core.contextkeys';
23
25
  import { IDecorationSerializableState, IEnhanceModelDeltaDecoration } from '../../model/enhanceDecorationsCollection';
24
- import { InlineDiffService } from '../inline-diff';
25
26
 
26
27
  import styles from './inline-stream-diff.module.less';
27
28
  import { InlineStreamDiffService } from './inline-stream-diff.service';
@@ -31,8 +32,6 @@ import {
31
32
  ActiveLineDecoration,
32
33
  AddedRangeDecoration,
33
34
  AddedRangeDecorationsCollection,
34
- EPartialEdit,
35
- IPartialEditEvent,
36
35
  IPartialEditWidgetOptions,
37
36
  IRemovedWidgetState,
38
37
  IRemovedZoneWidgetOptions,
@@ -66,8 +65,8 @@ export class LivePreviewDiffDecorationModel extends Disposable {
66
65
  @Autowired(InlineStreamDiffService)
67
66
  private readonly inlineStreamDiffService: InlineStreamDiffService;
68
67
 
69
- @Autowired(InlineDiffService)
70
- private readonly inlineDiffService: InlineDiffService;
68
+ @Autowired(InlineDiffServiceToken)
69
+ private readonly inlineDiffService: IInlineDiffService;
71
70
 
72
71
  @Autowired(IMessageService)
73
72
  private readonly messageService: IMessageService;
@@ -537,15 +536,15 @@ export class LivePreviewDiffDecorationModel extends Disposable {
537
536
  }
538
537
 
539
538
  public acceptUnProcessed(): void {
540
- const showingWidgets = this.partialEditWidgetList.filter((widget) => !widget.isHidden);
541
- showingWidgets.forEach((widget) => {
539
+ const pendingWidgets = this.partialEditWidgetList.filter((widget) => widget.isPending);
540
+ pendingWidgets.forEach((widget) => {
542
541
  this.handlePartialEditAction(EPartialEdit.accept, widget, false);
543
542
  });
544
543
  }
545
544
 
546
545
  public discardUnProcessed(): void {
547
- const showingWidgets = this.partialEditWidgetList.filter((widget) => !widget.isHidden);
548
- showingWidgets.forEach((widget) => {
546
+ const pendingWidgets = this.partialEditWidgetList.filter((widget) => widget.isPending);
547
+ pendingWidgets.forEach((widget) => {
549
548
  this.handlePartialEditAction(EPartialEdit.discard, widget, false);
550
549
  });
551
550
  }
@@ -16,7 +16,7 @@ import { DESIGN_MENUBAR_CONTAINER_VIEW_ID } from '@opensumi/ide-design/lib/commo
16
16
  import { IPosition, ITextModel, InlineCompletionContext } from '@opensumi/ide-monaco/lib/common';
17
17
 
18
18
  import { MCPServerDescription } from './mcp-server-manager';
19
- import { MCPTool } from './types';
19
+ import { IPartialEditEvent, MCPTool } from './types';
20
20
 
21
21
  import type { CoreMessage } from 'ai';
22
22
 
@@ -37,7 +37,7 @@ export const AI_CHAT_LOGO_AVATAR_ID = 'AI-Chat-Logo-Avatar';
37
37
  export const AI_MENU_BAR_DEBUG_TOOLBAR = 'AI_MENU_BAR_DEBUG_TOOLBAR';
38
38
 
39
39
  // 内置 MCP 服务器名称
40
- export const BUILTIN_MCP_SERVER_NAME = 'sumi-builtin';
40
+ export const BUILTIN_MCP_SERVER_NAME = 'builtin';
41
41
 
42
42
  /**
43
43
  * @deprecated Use {@link DESIGN_MENUBAR_CONTAINER_VIEW_ID} instead
@@ -309,3 +309,10 @@ export interface IAIInlineCompletionsProvider {
309
309
  ): Promise<T>;
310
310
  setVisibleCompletion(arg0: boolean): void;
311
311
  }
312
+
313
+ export interface IInlineDiffService {
314
+ onPartialEdit: Event<IPartialEditEvent>;
315
+ firePartialEdit(event: IPartialEditEvent): void;
316
+ }
317
+
318
+ export const InlineDiffServiceToken = Symbol('InlineDiffService');
@@ -42,15 +42,11 @@ ${context.recentlyViewFiles.map((file, idx) => ` ${idx + 1}: ${file}`).join('
42
42
  `,
43
43
  )}
44
44
  </attached_files>
45
- ${
46
- currentModel
47
- ? `<current_opened_file>
45
+ ${currentModel ? `<current_opened_file>
48
46
  \`\`\`${currentModel.languageId} ${currentModel.uri.toString()}
49
47
  ${currentModel.getText()}
50
48
  \`\`\`
51
- </current_opened_file>`
52
- : ''
53
- }
49
+ </current_opened_file>` : ''}
54
50
  </additional_data>
55
51
  <user_query>
56
52
  ${userMessage}
@@ -1,4 +1,5 @@
1
1
  import { IMarker } from '@opensumi/ide-core-browser';
2
+ import { Uri } from '@opensumi/monaco-editor-core';
2
3
 
3
4
  export enum NearestCodeBlockType {
4
5
  Block = 'block',
@@ -83,3 +84,37 @@ export interface CodeBlockData {
83
84
  }
84
85
 
85
86
  export type CodeBlockStatus = 'generating' | 'pending' | 'success' | 'rejected' | 'failed' | 'cancelled';
87
+
88
+ export enum EPartialEdit {
89
+ accept = 'accept',
90
+ discard = 'discard',
91
+ }
92
+
93
+ export interface IPartialEditEvent {
94
+ uri: Uri;
95
+ /**
96
+ * 总 diff 数
97
+ */
98
+ totalPartialEditCount: number;
99
+ /**
100
+ * 已处理的个数
101
+ */
102
+ resolvedPartialEditCount: number;
103
+ /**
104
+ * 已添加行数
105
+ */
106
+ totalAddedLinesCount: number;
107
+ /**
108
+ * 已采纳的个数
109
+ */
110
+ acceptPartialEditCount: number;
111
+ /**
112
+ * 已删除行数
113
+ */
114
+ totalDeletedLinesCount: number;
115
+ currentPartialEdit: {
116
+ type: EPartialEdit;
117
+ addedLinesCount: number;
118
+ deletedLinesCount: number;
119
+ };
120
+ }