@opensumi/ide-ai-native 3.8.3-next-1741850419.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.
- package/lib/browser/chat/chat-agent.service.d.ts +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +7 -7
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +31 -69
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/{chat-context/context-selector.d.ts → ChatContext/ContextSelector.d.ts} +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
- package/lib/browser/components/{chat-context/context-selector.js → ChatContext/ContextSelector.js} +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
- package/lib/browser/components/{chat-context → ChatContext}/index.js +2 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -0
- package/lib/browser/components/ChatEditor.d.ts +2 -11
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +6 -66
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +15 -15
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts +1 -1
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +2 -8
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/components/change-list.module.less +0 -2
- package/lib/browser/components/chat-history.module.less +16 -33
- package/lib/browser/components/components.module.less +3 -39
- package/lib/browser/context/llm-context.service.d.ts +2 -10
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +2 -71
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +9 -2
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/common/llm-context.d.ts +1 -15
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +2 -12
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +30 -95
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/utils.d.ts +0 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +1 -9
- package/lib/common/utils.js.map +1 -1
- package/lib/node/mcp-server.sse.d.ts.map +1 -1
- package/lib/node/mcp-server.sse.js +2 -2
- package/lib/node/mcp-server.sse.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/chat/chat-agent.service.ts +7 -7
- package/src/browser/chat/chat.view.tsx +24 -81
- package/src/browser/components/{chat-context → ChatContext}/index.tsx +1 -1
- package/src/browser/components/ChatEditor.tsx +9 -126
- package/src/browser/components/ChatHistory.tsx +30 -16
- package/src/browser/components/ChatThinking.tsx +4 -10
- package/src/browser/components/change-list.module.less +0 -2
- package/src/browser/components/chat-history.module.less +16 -33
- package/src/browser/components/components.module.less +3 -39
- package/src/browser/context/llm-context.service.ts +3 -81
- package/src/browser/mcp/base-apply.service.ts +9 -2
- package/src/common/llm-context.ts +1 -16
- package/src/common/prompts/context-prompt-provider.ts +36 -130
- package/src/common/utils.ts +0 -8
- package/src/node/mcp-server.sse.ts +2 -1
- package/lib/browser/components/ChatMentionInput.d.ts +0 -25
- package/lib/browser/components/ChatMentionInput.d.ts.map +0 -1
- package/lib/browser/components/ChatMentionInput.js +0 -229
- package/lib/browser/components/ChatMentionInput.js.map +0 -1
- package/lib/browser/components/chat-context/context-selector.d.ts.map +0 -1
- package/lib/browser/components/chat-context/context-selector.js.map +0 -1
- package/lib/browser/components/chat-context/index.d.ts.map +0 -1
- package/lib/browser/components/chat-context/index.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.d.ts +0 -5
- package/lib/browser/components/mention-input/mention-input.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-input.js +0 -763
- package/lib/browser/components/mention-input/mention-input.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.module.less +0 -333
- package/lib/browser/components/mention-input/mention-item.d.ts +0 -10
- package/lib/browser/components/mention-input/mention-item.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-item.js +0 -16
- package/lib/browser/components/mention-input/mention-item.js.map +0 -1
- package/lib/browser/components/mention-input/mention-panel.d.ts +0 -15
- package/lib/browser/components/mention-input/mention-panel.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-panel.js +0 -49
- package/lib/browser/components/mention-input/mention-panel.js.map +0 -1
- package/lib/browser/components/mention-input/types.d.ts +0 -78
- package/lib/browser/components/mention-input/types.d.ts.map +0 -1
- package/lib/browser/components/mention-input/types.js +0 -16
- package/lib/browser/components/mention-input/types.js.map +0 -1
- package/src/browser/components/ChatMentionInput.tsx +0 -276
- package/src/browser/components/mention-input/mention-input.module.less +0 -333
- package/src/browser/components/mention-input/mention-input.tsx +0 -952
- package/src/browser/components/mention-input/mention-item.tsx +0 -24
- package/src/browser/components/mention-input/mention-panel.tsx +0 -89
- package/src/browser/components/mention-input/types.ts +0 -84
- /package/lib/browser/components/{chat-context → ChatContext}/index.d.ts +0 -0
- /package/lib/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
- /package/src/browser/components/{chat-context/context-selector.tsx → ChatContext/ContextSelector.tsx} +0 -0
- /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(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
240
|
+
style={{ width: '100%', maxWidth: '100%' }}
|
|
229
241
|
value={searchValue}
|
|
230
242
|
onChange={handleSearchChange}
|
|
231
243
|
/>
|
|
232
|
-
<div className={styles
|
|
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
|
|
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
|
|
249
|
-
<div className={styles
|
|
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
|
|
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
|
|
274
|
+
className={styles['dm-chat-history-header-actions-history']}
|
|
263
275
|
title={localize('aiNative.operate.chatHistory.title')}
|
|
264
276
|
>
|
|
265
|
-
<EnhanceIcon
|
|
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
|
|
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
|
|
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 (
|
|
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
|
-
{
|
|
55
|
+
{!children && <Progress loading={true} wrapperClassName={styles.ai_native_progress_wrapper} />}
|
|
62
56
|
</span>
|
|
63
57
|
)}
|
|
64
58
|
{/* {showStop && (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
25
|
+
.dm-chat-history-header-actions {
|
|
26
26
|
display: flex;
|
|
27
27
|
align-items: center;
|
|
28
28
|
font-size: 12px;
|
|
29
29
|
|
|
30
|
-
.
|
|
30
|
+
.dm-chat-history-header-actions-history {
|
|
31
31
|
cursor: pointer;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.
|
|
34
|
+
.dm-chat-history-header-actions-new {
|
|
35
35
|
margin-left: 2px;
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
.
|
|
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
|
-
.
|
|
86
|
+
.dm-chat-history-time {
|
|
104
87
|
opacity: 0.6;
|
|
105
88
|
padding-left: 4px;
|
|
106
89
|
}
|
|
107
90
|
|
|
108
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
115
|
+
.dm-chat-history-item-actions {
|
|
133
116
|
display: none;
|
|
134
117
|
}
|
|
135
118
|
|
|
136
|
-
.
|
|
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
|
-
.
|
|
126
|
+
.dm-chat-history-item-actions {
|
|
144
127
|
display: block;
|
|
145
128
|
}
|
|
146
|
-
.
|
|
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: -
|
|
7
|
+
bottom: -38px;
|
|
8
8
|
padding-top: 12px;
|
|
9
|
-
left: -
|
|
9
|
+
left: -8px;
|
|
10
10
|
width: 105%;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -453,13 +453,7 @@
|
|
|
453
453
|
h3,
|
|
454
454
|
h4,
|
|
455
455
|
h5 {
|
|
456
|
-
color:
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
hr {
|
|
460
|
-
border-bottom: 0;
|
|
461
|
-
opacity: 0.3;
|
|
462
|
-
border-color: var(--descriptionForeground);
|
|
456
|
+
color: #fff;
|
|
463
457
|
}
|
|
464
458
|
|
|
465
459
|
p {
|
|
@@ -525,7 +519,6 @@
|
|
|
525
519
|
display: flex;
|
|
526
520
|
font-size: 11px;
|
|
527
521
|
align-items: center;
|
|
528
|
-
min-width: 150px;
|
|
529
522
|
}
|
|
530
523
|
|
|
531
524
|
.mcp_desc {
|
|
@@ -572,32 +565,3 @@
|
|
|
572
565
|
color: var(--descriptionForeground);
|
|
573
566
|
}
|
|
574
567
|
}
|
|
575
|
-
|
|
576
|
-
.attachment {
|
|
577
|
-
display: inline-flex;
|
|
578
|
-
align-items: center;
|
|
579
|
-
padding: 0 4px;
|
|
580
|
-
margin: 0 2px;
|
|
581
|
-
background: var(--badge-background);
|
|
582
|
-
color: var(--badge-foreground);
|
|
583
|
-
border-radius: 3px;
|
|
584
|
-
vertical-align: middle;
|
|
585
|
-
font-size: 12px;
|
|
586
|
-
cursor: pointer;
|
|
587
|
-
:global {
|
|
588
|
-
.kt-icon {
|
|
589
|
-
font-size: 12px;
|
|
590
|
-
margin-right: 3px;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
&:hover {
|
|
594
|
-
background-color: var(--chat-slashCommandBackground);
|
|
595
|
-
color: var(--chat-slashCommandForeground);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
.attachment_text {
|
|
600
|
-
line-height: 20px;
|
|
601
|
-
vertical-align: middle;
|
|
602
|
-
font-size: 12px;
|
|
603
|
-
}
|
|
@@ -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
|
-
|
|
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():
|
|
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
|
}
|