@opensumi/ide-ai-native 3.8.3-next-1741848368.0 → 3.8.3-next-1741917543.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 (101) hide show
  1. package/lib/browser/chat/chat-agent.service.d.ts +1 -1
  2. package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
  3. package/lib/browser/chat/chat-agent.service.js +7 -7
  4. package/lib/browser/chat/chat-agent.service.js.map +1 -1
  5. package/lib/browser/chat/chat.view.d.ts.map +1 -1
  6. package/lib/browser/chat/chat.view.js +31 -69
  7. package/lib/browser/chat/chat.view.js.map +1 -1
  8. package/lib/browser/components/{chat-context/context-selector.d.ts → ChatContext/ContextSelector.d.ts} +1 -1
  9. package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
  10. package/lib/browser/components/{chat-context/context-selector.js → ChatContext/ContextSelector.js} +1 -1
  11. package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
  12. package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
  13. package/lib/browser/components/{chat-context → ChatContext}/index.js +2 -2
  14. package/lib/browser/components/ChatContext/index.js.map +1 -0
  15. package/lib/browser/components/ChatEditor.d.ts +2 -11
  16. package/lib/browser/components/ChatEditor.d.ts.map +1 -1
  17. package/lib/browser/components/ChatEditor.js +6 -66
  18. package/lib/browser/components/ChatEditor.js.map +1 -1
  19. package/lib/browser/components/ChatHistory.d.ts.map +1 -1
  20. package/lib/browser/components/ChatHistory.js +15 -15
  21. package/lib/browser/components/ChatHistory.js.map +1 -1
  22. package/lib/browser/components/ChatThinking.d.ts +1 -1
  23. package/lib/browser/components/ChatThinking.d.ts.map +1 -1
  24. package/lib/browser/components/ChatThinking.js +2 -8
  25. package/lib/browser/components/ChatThinking.js.map +1 -1
  26. package/lib/browser/components/change-list.module.less +0 -2
  27. package/lib/browser/components/chat-history.module.less +16 -33
  28. package/lib/browser/components/components.module.less +2 -32
  29. package/lib/browser/context/llm-context.service.d.ts +2 -10
  30. package/lib/browser/context/llm-context.service.d.ts.map +1 -1
  31. package/lib/browser/context/llm-context.service.js +2 -71
  32. package/lib/browser/context/llm-context.service.js.map +1 -1
  33. package/lib/browser/mcp/base-apply.service.d.ts +1 -1
  34. package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
  35. package/lib/browser/mcp/base-apply.service.js +9 -2
  36. package/lib/browser/mcp/base-apply.service.js.map +1 -1
  37. package/lib/common/llm-context.d.ts +1 -15
  38. package/lib/common/llm-context.d.ts.map +1 -1
  39. package/lib/common/llm-context.js.map +1 -1
  40. package/lib/common/prompts/context-prompt-provider.d.ts +2 -12
  41. package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
  42. package/lib/common/prompts/context-prompt-provider.js +30 -95
  43. package/lib/common/prompts/context-prompt-provider.js.map +1 -1
  44. package/lib/common/utils.d.ts +0 -1
  45. package/lib/common/utils.d.ts.map +1 -1
  46. package/lib/common/utils.js +1 -9
  47. package/lib/common/utils.js.map +1 -1
  48. package/lib/node/mcp-server.sse.d.ts.map +1 -1
  49. package/lib/node/mcp-server.sse.js +2 -2
  50. package/lib/node/mcp-server.sse.js.map +1 -1
  51. package/package.json +23 -23
  52. package/src/browser/chat/chat-agent.service.ts +7 -7
  53. package/src/browser/chat/chat.view.tsx +24 -81
  54. package/src/browser/components/{chat-context → ChatContext}/index.tsx +1 -1
  55. package/src/browser/components/ChatEditor.tsx +9 -126
  56. package/src/browser/components/ChatHistory.tsx +30 -16
  57. package/src/browser/components/ChatThinking.tsx +4 -10
  58. package/src/browser/components/change-list.module.less +0 -2
  59. package/src/browser/components/chat-history.module.less +16 -33
  60. package/src/browser/components/components.module.less +2 -32
  61. package/src/browser/context/llm-context.service.ts +3 -81
  62. package/src/browser/mcp/base-apply.service.ts +9 -2
  63. package/src/common/llm-context.ts +1 -16
  64. package/src/common/prompts/context-prompt-provider.ts +36 -130
  65. package/src/common/utils.ts +0 -8
  66. package/src/node/mcp-server.sse.ts +2 -1
  67. package/lib/browser/components/ChatMentionInput.d.ts +0 -25
  68. package/lib/browser/components/ChatMentionInput.d.ts.map +0 -1
  69. package/lib/browser/components/ChatMentionInput.js +0 -229
  70. package/lib/browser/components/ChatMentionInput.js.map +0 -1
  71. package/lib/browser/components/chat-context/context-selector.d.ts.map +0 -1
  72. package/lib/browser/components/chat-context/context-selector.js.map +0 -1
  73. package/lib/browser/components/chat-context/index.d.ts.map +0 -1
  74. package/lib/browser/components/chat-context/index.js.map +0 -1
  75. package/lib/browser/components/mention-input/mention-input.d.ts +0 -5
  76. package/lib/browser/components/mention-input/mention-input.d.ts.map +0 -1
  77. package/lib/browser/components/mention-input/mention-input.js +0 -763
  78. package/lib/browser/components/mention-input/mention-input.js.map +0 -1
  79. package/lib/browser/components/mention-input/mention-input.module.less +0 -333
  80. package/lib/browser/components/mention-input/mention-item.d.ts +0 -10
  81. package/lib/browser/components/mention-input/mention-item.d.ts.map +0 -1
  82. package/lib/browser/components/mention-input/mention-item.js +0 -16
  83. package/lib/browser/components/mention-input/mention-item.js.map +0 -1
  84. package/lib/browser/components/mention-input/mention-panel.d.ts +0 -15
  85. package/lib/browser/components/mention-input/mention-panel.d.ts.map +0 -1
  86. package/lib/browser/components/mention-input/mention-panel.js +0 -49
  87. package/lib/browser/components/mention-input/mention-panel.js.map +0 -1
  88. package/lib/browser/components/mention-input/types.d.ts +0 -78
  89. package/lib/browser/components/mention-input/types.d.ts.map +0 -1
  90. package/lib/browser/components/mention-input/types.js +0 -16
  91. package/lib/browser/components/mention-input/types.js.map +0 -1
  92. package/src/browser/components/ChatMentionInput.tsx +0 -276
  93. package/src/browser/components/mention-input/mention-input.module.less +0 -333
  94. package/src/browser/components/mention-input/mention-input.tsx +0 -952
  95. package/src/browser/components/mention-input/mention-item.tsx +0 -24
  96. package/src/browser/components/mention-input/mention-panel.tsx +0 -89
  97. package/src/browser/components/mention-input/types.ts +0 -84
  98. /package/lib/browser/components/{chat-context → ChatContext}/index.d.ts +0 -0
  99. /package/lib/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
  100. /package/src/browser/components/{chat-context/context-selector.tsx → ChatContext/ContextSelector.tsx} +0 -0
  101. /package/src/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
@@ -163,22 +163,25 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
163
163
  (item: IChatHistoryItem) => (
164
164
  <div
165
165
  key={item.id}
166
- className={cls(styles.chat_history_item, item.id === currentId ? styles.chat_history_item_selected : '')}
166
+ className={cls(
167
+ styles['dm-chat-history-item'],
168
+ item.id === currentId ? styles['dm-chat-history-item-selected'] : '',
169
+ )}
167
170
  onClick={() => handleHistoryItemSelect(item)}
168
171
  >
169
- <div className={styles.chat_history_item_content}>
172
+ <div className={styles['dm-chat-history-item-content']}>
170
173
  {item.loading ? (
171
174
  <Loading />
172
175
  ) : (
173
176
  <Icon icon='message' style={{ width: '16px', height: '16px', marginRight: 4 }} />
174
177
  )}
175
178
  {!historyTitleEditable?.[item.id] ? (
176
- <span id={`chat-history-item-title-${item.id}`} className={styles.chat_history_item_title}>
179
+ <span id={`dm-chat-history-item-title-${item.id}`} className={styles['dm-chat-history-item-title']}>
177
180
  {item.title}
178
181
  </span>
179
182
  ) : (
180
183
  <Input
181
- className={styles.chat_history_item_title}
184
+ className={styles['dm-chat-history-item-title']}
182
185
  defaultValue={item.title}
183
186
  ref={inputRef}
184
187
  onPressEnter={(e: any) => {
@@ -188,9 +191,18 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
188
191
  />
189
192
  )}
190
193
  </div>
191
- <div className={styles.chat_history_item_actions}>
194
+ <div className={styles['dm-chat-history-item-actions']}>
195
+ {/* <EditOutlined
196
+ title={localize('aiNative.operate.chatHistory.edit')}
197
+ style={{ marginRight: 8 }}
198
+ onClick={(e) => {
199
+ e.preventDefault();
200
+ e.stopPropagation();
201
+ handleTitleEdit(item);
202
+ }}
203
+ /> */}
192
204
  <EnhanceIcon
193
- className={cls(styles.chat_history_item_actions_delete, getIcon('delete'))}
205
+ className={cls(styles['dm-chat-history-item-actions-delete'], getIcon('delete'))}
194
206
  onClick={(e) => {
195
207
  e.preventDefault();
196
208
  e.stopPropagation();
@@ -225,14 +237,14 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
225
237
  <div>
226
238
  <Input
227
239
  placeholder={localize('aiNative.operate.chatHistory.searchPlaceholder')}
228
- className={styles.chat_history_search}
240
+ style={{ width: '100%', maxWidth: '100%' }}
229
241
  value={searchValue}
230
242
  onChange={handleSearchChange}
231
243
  />
232
- <div className={styles.chat_history_list}>
244
+ <div className={styles['dm-chat-history-list']}>
233
245
  {groupedHistoryList.map((group) => (
234
246
  <div key={group.key} style={{ padding: '4px' }}>
235
- <div className={styles.chat_history_time}>{group.key}</div>
247
+ <div className={styles['dm-chat-history-time']}>{group.key}</div>
236
248
  {group.items.map(renderHistoryItem)}
237
249
  </div>
238
250
  ))}
@@ -245,13 +257,13 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
245
257
  const getPopupContainer = useCallback((triggerNode: HTMLElement) => triggerNode.parentElement!, []);
246
258
 
247
259
  return (
248
- <div className={cls(styles.chat_history_header, className)}>
249
- <div className={styles.chat_history_header_title}>
260
+ <div className={cls(styles['dm-chat-history-header'], className)}>
261
+ <div className={styles['dm-chat-history-header-title']}>
250
262
  <span>{title}</span>
251
263
  </div>
252
- <div className={styles.chat_history_header_actions}>
264
+ <div className={styles['dm-chat-history-header-actions']}>
253
265
  <Popover
254
- id='chat-history-header-actions-history'
266
+ id='dm-chat-history-header-actions-history'
255
267
  content={renderHistory()}
256
268
  trigger={PopoverTriggerType.click}
257
269
  position={PopoverPosition.bottomRight}
@@ -259,10 +271,12 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
259
271
  getPopupContainer={getPopupContainer}
260
272
  >
261
273
  <div
262
- className={styles.chat_history_header_actions_history}
274
+ className={styles['dm-chat-history-header-actions-history']}
263
275
  title={localize('aiNative.operate.chatHistory.title')}
264
276
  >
265
- <EnhanceIcon className={cls(styles.chat_history_header_actions_history, 'codicon codicon-history')} />
277
+ <EnhanceIcon
278
+ className={cls(styles['dm-chat-history-header-actions-history'], 'codicon codicon-history')}
279
+ />
266
280
  </div>
267
281
  </Popover>
268
282
  <Popover
@@ -271,7 +285,7 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
271
285
  title={localize('aiNative.operate.newChat.title')}
272
286
  >
273
287
  <EnhanceIcon
274
- className={cls(styles.chat_history_header_actions_new, getIcon('plus'))}
288
+ className={cls(styles['dm-chat-history-header-actions-new'], getIcon('plus'))}
275
289
  onClick={handleNewChat}
276
290
  />
277
291
  </Popover>
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
 
3
3
  import { useInjectable } from '@opensumi/ide-core-browser';
4
+ import { Icon, getIcon } from '@opensumi/ide-core-browser/lib/components';
4
5
  import { EnhanceIcon, Thumbs } from '@opensumi/ide-core-browser/lib/components/ai-native';
5
6
  import { Progress } from '@opensumi/ide-core-browser/lib/progress/progress-bar';
6
7
  import { ChatRenderRegistryToken, isUndefined, localize } from '@opensumi/ide-core-common';
@@ -12,7 +13,7 @@ import { ChatRenderRegistry } from '../chat/chat.render.registry';
12
13
  import styles from './components.module.less';
13
14
 
14
15
  interface ITinkingProps {
15
- children?: React.ReactNode | string | React.ReactNode[];
16
+ children?: React.ReactNode;
16
17
  hasMessage?: boolean;
17
18
  message?: string;
18
19
  onRegenerate?: () => void;
@@ -31,15 +32,8 @@ export const ChatThinking = (props: ITinkingProps) => {
31
32
  [chatRenderRegistry, chatRenderRegistry.chatThinkingRender],
32
33
  );
33
34
 
34
- const isEmptyChildren = useMemo(() => {
35
- if (Array.isArray(children)) {
36
- return children.length === 0;
37
- }
38
- return !children;
39
- }, [children]);
40
-
41
35
  const renderContent = useCallback(() => {
42
- if (isEmptyChildren) {
36
+ if (!children) {
43
37
  if (CustomThinkingRender) {
44
38
  return <CustomThinkingRender thinkingText={thinkingText} />;
45
39
  }
@@ -58,7 +52,7 @@ export const ChatThinking = (props: ITinkingProps) => {
58
52
  {!CustomThinkingRender && (
59
53
  <span className={styles.progress_bar}>
60
54
  {/* 保持动画效果一致 */}
61
- {isEmptyChildren && <Progress loading={true} wrapperClassName={styles.ai_native_progress_wrapper} />}
55
+ {!children && <Progress loading={true} wrapperClassName={styles.ai_native_progress_wrapper} />}
62
56
  </span>
63
57
  )}
64
58
  {/* {showStop && (
@@ -103,8 +103,6 @@
103
103
  .fileStats {
104
104
  font-size: 12px;
105
105
  display: flex;
106
- flex: 1;
107
- justify-content: flex-end;
108
106
  align-items: center;
109
107
  gap: 4px;
110
108
  }
@@ -1,4 +1,4 @@
1
- .chat_history_header {
1
+ .dm-chat-history-header {
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: space-between;
@@ -8,7 +8,7 @@
8
8
  text-overflow: ellipsis;
9
9
  white-space: nowrap;
10
10
 
11
- .chat_history_header_title {
11
+ .dm-chat-history-header-title {
12
12
  opacity: 0.6;
13
13
  display: flex;
14
14
  align-items: center;
@@ -22,34 +22,22 @@
22
22
  }
23
23
  }
24
24
 
25
- .chat_history_header_actions {
25
+ .dm-chat-history-header-actions {
26
26
  display: flex;
27
27
  align-items: center;
28
28
  font-size: 12px;
29
29
 
30
- .chat_history_header_actions_history {
30
+ .dm-chat-history-header-actions-history {
31
31
  cursor: pointer;
32
32
  }
33
33
 
34
- .chat_history_header_actions_new {
34
+ .dm-chat-history-header-actions-new {
35
35
  margin-left: 2px;
36
36
  cursor: pointer;
37
37
  }
38
38
 
39
- :global {
40
- .kt-popover-title {
41
- margin-bottom: 8px;
42
- }
43
- .kt-popover-content {
44
- background-color: var(--editor-background);
45
- color: var(--editor-foreground);
46
- }
47
- .kt-popover-arrow {
48
- border-bottom-color: var(--editor-background);
49
- }
50
- .kt-popover {
51
- opacity: 1;
52
- }
39
+ .kt-popover-title {
40
+ margin-bottom: 8px;
53
41
  }
54
42
  }
55
43
 
@@ -87,12 +75,7 @@
87
75
  }
88
76
  }
89
77
 
90
- .chat_history_search {
91
- width: 100%;
92
- border-radius: 4px;
93
- }
94
-
95
- .chat_history_list {
78
+ .dm-chat-history-list {
96
79
  overflow: auto;
97
80
  max-height: 400px;
98
81
  width: 300px;
@@ -100,12 +83,12 @@
100
83
  font-size: 13px;
101
84
  }
102
85
 
103
- .chat_history_time {
86
+ .dm-chat-history-time {
104
87
  opacity: 0.6;
105
88
  padding-left: 4px;
106
89
  }
107
90
 
108
- .chat_history_item {
91
+ .dm-chat-history-item {
109
92
  display: flex;
110
93
  align-items: center;
111
94
  justify-content: space-between;
@@ -114,7 +97,7 @@
114
97
  margin-top: 2px;
115
98
  border-radius: 3px;
116
99
 
117
- .chat_history_item_content {
100
+ .dm-chat-history-item-content {
118
101
  display: flex;
119
102
  align-items: center;
120
103
  width: 100%;
@@ -122,28 +105,28 @@
122
105
  height: 24px;
123
106
  }
124
107
 
125
- .chat_history_item_title {
108
+ .dm-chat-history-item-title {
126
109
  overflow: hidden;
127
110
  text-overflow: ellipsis;
128
111
  display: inline-block;
129
112
  white-space: nowrap;
130
113
  }
131
114
 
132
- .chat_history_item_actions {
115
+ .dm-chat-history-item-actions {
133
116
  display: none;
134
117
  }
135
118
 
136
- .chat_history_item_selected {
119
+ .dm-chat-history-item-selected {
137
120
  background: var(--textPreformat-background);
138
121
  }
139
122
 
140
123
  &:hover {
141
124
  background: var(--textPreformat-background);
142
125
 
143
- .chat_history_item_actions {
126
+ .dm-chat-history-item-actions {
144
127
  display: block;
145
128
  }
146
- .chat_history_item_content {
129
+ .dm-chat-history-item-content {
147
130
  max-width: calc(100% - 50px);
148
131
  }
149
132
  }
@@ -4,9 +4,9 @@
4
4
  height: 100%;
5
5
  .stop {
6
6
  position: absolute;
7
- bottom: -15px;
7
+ bottom: -38px;
8
8
  padding-top: 12px;
9
- left: -9px;
9
+ left: -8px;
10
10
  width: 105%;
11
11
  }
12
12
 
@@ -519,7 +519,6 @@
519
519
  display: flex;
520
520
  font-size: 11px;
521
521
  align-items: center;
522
- min-width: 150px;
523
522
  }
524
523
 
525
524
  .mcp_desc {
@@ -566,32 +565,3 @@
566
565
  color: var(--descriptionForeground);
567
566
  }
568
567
  }
569
-
570
- .attachment {
571
- display: inline-flex;
572
- align-items: center;
573
- padding: 0 4px;
574
- margin: 0 2px;
575
- background: var(--badge-background);
576
- color: var(--badge-foreground);
577
- border-radius: 3px;
578
- vertical-align: middle;
579
- font-size: 12px;
580
- cursor: pointer;
581
- :global {
582
- .kt-icon {
583
- font-size: 12px;
584
- margin-right: 3px;
585
- }
586
- }
587
- &:hover {
588
- background-color: var(--chat-slashCommandBackground);
589
- color: var(--chat-slashCommandForeground);
590
- }
591
- }
592
-
593
- .attachment_text {
594
- line-height: 20px;
595
- vertical-align: middle;
596
- font-size: 12px;
597
- }
@@ -10,7 +10,6 @@ import {
10
10
  IEditorDocumentModelService,
11
11
  } from '@opensumi/ide-editor/lib/browser/doc-model/types';
12
12
  import { EditorSelectionChangeEvent } from '@opensumi/ide-editor/lib/browser/types';
13
- import { FileType, IFileServiceClient } from '@opensumi/ide-file-service';
14
13
  import { IMarkerService } from '@opensumi/ide-markers/lib/common/types';
15
14
  import { Range } from '@opensumi/ide-monaco';
16
15
 
@@ -27,18 +26,13 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
27
26
  @Autowired(IMarkerService)
28
27
  protected readonly markerService: IMarkerService;
29
28
 
30
- @Autowired(IFileServiceClient)
31
- protected readonly fileService: IFileServiceClient;
32
-
33
29
  private isAutoCollecting = false;
34
30
 
35
31
  private contextVersion = 0;
36
32
 
37
33
  private readonly maxAttachFilesLimit = 10;
38
- private readonly maxAttachFoldersLimit = 10;
39
34
  private readonly maxViewFilesLimit = 20;
40
- private attachedFiles: FileContext[] = [];
41
- private attachedFolders: FileContext[] = [];
35
+ private readonly attachedFiles: FileContext[] = [];
42
36
  private readonly recentlyViewFiles: FileContext[] = [];
43
37
  private readonly onDidContextFilesChangeEmitter = new Emitter<{
44
38
  viewed: FileContext[];
@@ -59,18 +53,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
59
53
  }
60
54
  }
61
55
 
62
- private addFolderToList(folder: FileContext, list: FileContext[], maxLimit: number) {
63
- const existingIndex = list.findIndex((f) => f.uri.toString() === folder.uri.toString());
64
- if (existingIndex > -1) {
65
- list.splice(existingIndex, 1);
66
- }
67
-
68
- list.push(folder);
69
- if (list.length > maxLimit) {
70
- list.shift();
71
- }
72
- }
73
-
74
56
  addFileToContext(uri: URI, selection?: [number, number], isManual = false): void {
75
57
  if (!uri) {
76
58
  return;
@@ -88,24 +70,12 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
88
70
  this.notifyContextChange();
89
71
  }
90
72
 
91
- addFolderToContext(uri: URI): void {
92
- if (!uri) {
93
- return;
94
- }
95
-
96
- const file = { uri };
97
-
98
- this.addFolderToList(file, this.attachedFolders, this.maxAttachFoldersLimit);
99
- this.notifyContextChange();
100
- }
101
-
102
73
  private notifyContextChange(): void {
103
74
  this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
104
75
  }
105
76
 
106
77
  cleanFileContext() {
107
- this.attachedFiles = [];
108
- this.attachedFolders = [];
78
+ this.attachedFiles.length = 0;
109
79
  this.notifyContextChange();
110
80
  }
111
81
 
@@ -113,7 +83,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
113
83
  return {
114
84
  viewed: this.recentlyViewFiles,
115
85
  attached: this.attachedFiles,
116
- attachedFolders: this.attachedFolders,
117
86
  version: this.contextVersion++,
118
87
  };
119
88
  }
@@ -191,63 +160,16 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
191
160
  this.dispose();
192
161
  }
193
162
 
194
- async serialize(): Promise<SerializedContext> {
163
+ serialize(): SerializedContext {
195
164
  const files = this.getAllContextFiles();
196
165
  const workspaceRoot = URI.file(this.appConfig.workspaceDir);
197
166
 
198
167
  return {
199
168
  recentlyViewFiles: this.serializeRecentlyViewFiles(files.viewed, workspaceRoot),
200
169
  attachedFiles: this.serializeAttachedFiles(files.attached, workspaceRoot),
201
- attachedFolders: await this.serializeAttachedFolders(files.attachedFolders, workspaceRoot),
202
170
  };
203
171
  }
204
172
 
205
- private async serializeAttachedFolders(folders: FileContext[], workspaceRoot: URI): Promise<string[]> {
206
- // 去重
207
- const folderPath = Array.from(new Set(folders.map((folder) => folder.uri.toString())));
208
- return Promise.all(
209
- folderPath.map(async (folder) => {
210
- const folderUri = new URI(folder);
211
- const root = workspaceRoot.relative(folderUri)?.toString() || '/';
212
- return `\`\`\`\n${root}\n${(await this.getPartiaFolderStructure(folderUri.codeUri.fsPath))
213
- .map((line) => `- ${line}`)
214
- .join('\n')}\n\`\`\`\n`;
215
- }),
216
- );
217
- }
218
-
219
- private async getPartiaFolderStructure(folder: string, level = 2): Promise<string[]> {
220
- const result: string[] = [];
221
- const stat = await this.fileService.getFileStat(folder);
222
-
223
- for (const child of stat?.children || []) {
224
- const relativePath = new URI(folder).relative(new URI(child.uri))!.toString();
225
-
226
- if (child.isSymbolicLink) {
227
- // 处理软链接
228
- const target = await this.fileService.getFileStat(child.realUri || child.uri);
229
- if (target) {
230
- result.push(`${relativePath} -> ${target} (symbolic link)`);
231
- } else {
232
- result.push(`${relativePath} (broken symbolic link)`);
233
- }
234
- continue;
235
- }
236
-
237
- if (child.type === FileType.Directory) {
238
- result.push(`${relativePath}/`);
239
- if (level > 1) {
240
- const subDirStructure = await this.getPartiaFolderStructure(child.uri, level - 1);
241
- result.push(...subDirStructure.map((subEntry) => `${relativePath}/${subEntry}`));
242
- }
243
- } else if (child.type === FileType.File) {
244
- result.push(relativePath);
245
- }
246
- }
247
-
248
- return result;
249
- }
250
-
251
173
  private serializeRecentlyViewFiles(files: FileContext[], workspaceRoot: URI): string[] {
252
174
  return files
253
175
  .map((file) => workspaceRoot.relative(file.uri)?.toString() || file.uri.parent.toString())
@@ -247,7 +247,7 @@ export abstract class BaseApplyService extends WithEventBus {
247
247
  originalCode: originalModelRef.instance.getText(),
248
248
  };
249
249
  if (uriCodeBlocks?.length) {
250
- newBlock.version = uriCodeBlocks.length;
250
+ newBlock.version = uriCodeBlocks.length + 1;
251
251
  for (const block of uriCodeBlocks) {
252
252
  // 如果连续的上一个同文件apply结果存在LintError,则iterationCount++
253
253
  if (block.relativePath === relativePath && block.applyResult?.diagnosticInfos?.length) {
@@ -480,7 +480,7 @@ export abstract class BaseApplyService extends WithEventBus {
480
480
  }
481
481
  }
482
482
 
483
- processAll(type: 'accept' | 'reject', uri?: URI): void {
483
+ async processAll(type: 'accept' | 'reject', uri?: URI): Promise<void> {
484
484
  const codeBlocks = uri
485
485
  ? this.getUriCodeBlocks(uri)?.filter((block) => block.status === 'pending')
486
486
  : this.getSessionCodeBlocks().filter((block) => block.status === 'pending');
@@ -498,6 +498,13 @@ export abstract class BaseApplyService extends WithEventBus {
498
498
  acc.push(cur);
499
499
  return acc;
500
500
  }, [] as string[]);
501
+ const openedEditor = this.editorService.getAllOpenedUris();
502
+ const unopenedUris = relativePaths
503
+ .filter((relativePath) => !openedEditor.some((editor) => editor.codeUri.fsPath.endsWith(relativePath)))
504
+ .map((relativePath) => URI.file(path.join(this.appConfig.workspaceDir, relativePath)));
505
+ if (unopenedUris.length) {
506
+ await this.editorService.openUris(unopenedUris);
507
+ }
501
508
  relativePaths.forEach((relativePath) => {
502
509
  this.doProcess(type, relativePath);
503
510
  });
@@ -1,14 +1,8 @@
1
1
  import { Event, URI } from '@opensumi/ide-core-common/lib/utils';
2
2
 
3
3
  export interface LLMContextService {
4
- /**
5
- * 开始自动收集
6
- */
7
4
  startAutoCollection(): void;
8
5
 
9
- /**
10
- * 停止自动收集
11
- */
12
6
  stopAutoCollection(): void;
13
7
 
14
8
  /**
@@ -16,19 +10,11 @@ export interface LLMContextService {
16
10
  */
17
11
  addFileToContext(uri: URI, selection?: [number, number], isManual?: boolean): void;
18
12
 
19
- /**
20
- * 添加文件夹到 context 中
21
- */
22
- addFolderToContext(uri: URI, isManual?: boolean): void;
23
-
24
13
  /**
25
14
  * 清除上下文
26
15
  */
27
16
  cleanFileContext(): void;
28
17
 
29
- /**
30
- * 上下文文件变化事件
31
- */
32
18
  onDidContextFilesChangeEvent: Event<{ viewed: FileContext[]; attached: FileContext[]; version: number }>;
33
19
 
34
20
  /**
@@ -38,7 +24,7 @@ export interface LLMContextService {
38
24
  removeFileFromContext(uri: URI, isManual?: boolean): void;
39
25
 
40
26
  /** 导出为可序列化格式 */
41
- serialize(): Promise<SerializedContext>;
27
+ serialize(): SerializedContext;
42
28
  }
43
29
 
44
30
  export interface FileContext {
@@ -58,5 +44,4 @@ export interface AttachFileContext {
58
44
  export interface SerializedContext {
59
45
  recentlyViewFiles: string[];
60
46
  attachedFiles: Array<AttachFileContext>;
61
- attachedFolders: string[];
62
47
  }