dsh-efm-integration 0.4.1 → 0.4.5
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/README.md +367 -348
- package/README.zh.md +322 -316
- package/client.js +525 -356
- package/lib/lsp-servers/index.d.ts.map +1 -1
- package/lib/lsp-servers/index.js +4 -1
- package/lib/lsp-servers/index.js.map +1 -1
- package/lib/prompt/http.d.ts +36 -0
- package/lib/prompt/http.d.ts.map +1 -0
- package/lib/prompt/http.js +89 -0
- package/lib/prompt/http.js.map +1 -0
- package/lib/prompt/index.d.ts +7 -9
- package/lib/prompt/index.d.ts.map +1 -1
- package/lib/prompt/index.js +206 -51
- package/lib/prompt/index.js.map +1 -1
- package/lib/prompt/pure-mode.d.ts +85 -0
- package/lib/prompt/pure-mode.d.ts.map +1 -0
- package/lib/prompt/pure-mode.js +186 -0
- package/lib/prompt/pure-mode.js.map +1 -0
- package/lib/prompt/store.d.ts +44 -0
- package/lib/prompt/store.d.ts.map +1 -0
- package/lib/prompt/store.js +114 -0
- package/lib/prompt/store.js.map +1 -0
- package/lib/skill-router/index.d.ts.map +1 -1
- package/lib/skill-router/index.js +2 -1
- package/lib/skill-router/index.js.map +1 -1
- package/lib/verification/index.d.ts.map +1 -1
- package/lib/verification/index.js +3 -0
- package/lib/verification/index.js.map +1 -1
- package/package.json +142 -142
package/client.js
CHANGED
|
@@ -1,356 +1,525 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({
|
|
2
|
-
id: 'dsh-efm-integration',
|
|
3
|
-
factory: (require) => {
|
|
4
|
-
const module = { exports: {} }
|
|
5
|
-
const exports = module.exports
|
|
6
|
-
const React = require('react')
|
|
7
|
-
const { useEffect, useState } = React
|
|
8
|
-
const ARCHIVE_PANEL_ID = 'dsh-efm-integration-archive-cleaner'
|
|
9
|
-
const ARCHIVE_ENDPOINT = '/plugins/dsh-efm-integration/archived-sessions'
|
|
10
|
-
const LSP_PANEL_ID = 'dsh-efm-integration-lsp-servers'
|
|
11
|
-
const LSP_ENDPOINT = '/plugins/dsh-efm-integration/lsp-servers'
|
|
12
|
-
const LSP_CONFIRM_VALUE = 'LSP_SERVER_CHANGE'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
React.createElement('
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
React.createElement('
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
React.createElement('
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const [
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
state.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}, state.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
React.createElement('
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}, '
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-efm-integration',
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
const module = { exports: {} }
|
|
5
|
+
const exports = module.exports
|
|
6
|
+
const React = require('react')
|
|
7
|
+
const { useEffect, useState } = React
|
|
8
|
+
const ARCHIVE_PANEL_ID = 'dsh-efm-integration-archive-cleaner'
|
|
9
|
+
const ARCHIVE_ENDPOINT = '/plugins/dsh-efm-integration/archived-sessions'
|
|
10
|
+
const LSP_PANEL_ID = 'dsh-efm-integration-lsp-servers'
|
|
11
|
+
const LSP_ENDPOINT = '/plugins/dsh-efm-integration/lsp-servers'
|
|
12
|
+
const LSP_CONFIRM_VALUE = 'LSP_SERVER_CHANGE'
|
|
13
|
+
const SYSTEM_PROMPT_PANEL_ID = 'dsh-efm-integration-system-prompt'
|
|
14
|
+
const SYSTEM_PROMPT_ENDPOINT = '/plugins/dsh-efm-integration/system-prompt'
|
|
15
|
+
const SYSTEM_PROMPT_CONFIRM_VALUE = 'SYSTEM_PROMPT_CHANGE'
|
|
16
|
+
|
|
17
|
+
// The host renders `main` panels inside a flex column with `overflow: hidden`
|
|
18
|
+
// (ui-layout AppFrame: .centerCol / .mainPanel), so a page must fill the
|
|
19
|
+
// panel and scroll itself; viewport units and host-level scrolling do not
|
|
20
|
+
// exist here.
|
|
21
|
+
const pageStyle = {
|
|
22
|
+
flex: 1,
|
|
23
|
+
minHeight: 0,
|
|
24
|
+
width: '100%',
|
|
25
|
+
overflowY: 'auto',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
alignItems: 'flex-start',
|
|
29
|
+
padding: '32px 24px 56px',
|
|
30
|
+
boxSizing: 'border-box',
|
|
31
|
+
background: 'var(--dsh-color-bg, #111)',
|
|
32
|
+
color: 'var(--dsh-color-text, #eee)',
|
|
33
|
+
}
|
|
34
|
+
const cardStyle = {
|
|
35
|
+
width: '100%',
|
|
36
|
+
maxWidth: '820px',
|
|
37
|
+
border: '1px solid #5554',
|
|
38
|
+
borderRadius: '16px',
|
|
39
|
+
padding: '28px',
|
|
40
|
+
boxSizing: 'border-box',
|
|
41
|
+
}
|
|
42
|
+
const noticeStyle = {
|
|
43
|
+
background: '#7a3d0033', border: '1px solid #e39b4c66', borderRadius: '10px', padding: '12px', marginBottom: '16px',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function lspPost(body) {
|
|
47
|
+
const response = await fetch(LSP_ENDPOINT, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: {
|
|
50
|
+
accept: 'application/json',
|
|
51
|
+
'content-type': 'application/json',
|
|
52
|
+
'x-dsh-efm-integration-confirm': LSP_CONFIRM_VALUE,
|
|
53
|
+
},
|
|
54
|
+
body: JSON.stringify(body),
|
|
55
|
+
})
|
|
56
|
+
const payload = await response.json()
|
|
57
|
+
if (!response.ok) throw new Error(payload.error || '语言服务器操作失败')
|
|
58
|
+
return payload
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function ArchiveCleanerPage() {
|
|
62
|
+
const [state, setState] = useState({ loading: true, count: 0, archivedCount: 0, blocked: [], error: '' })
|
|
63
|
+
const [busy, setBusy] = useState(false)
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const controller = new AbortController()
|
|
67
|
+
fetch(ARCHIVE_ENDPOINT, { signal: controller.signal, headers: { accept: 'application/json' } })
|
|
68
|
+
.then(async response => {
|
|
69
|
+
const body = await response.json()
|
|
70
|
+
if (!response.ok) throw new Error(body.error || '无法读取存档会话')
|
|
71
|
+
setState({ loading: false, count: body.count, archivedCount: body.archivedCount, blocked: body.blocked || [], error: '' })
|
|
72
|
+
})
|
|
73
|
+
.catch(error => {
|
|
74
|
+
if (controller.signal.aborted) return
|
|
75
|
+
setState(current => ({ ...current, loading: false, error: String(error.message || error) }))
|
|
76
|
+
})
|
|
77
|
+
return () => controller.abort()
|
|
78
|
+
}, [])
|
|
79
|
+
|
|
80
|
+
const clear = async () => {
|
|
81
|
+
if (state.count === 0) return
|
|
82
|
+
const confirmed = window.confirm(
|
|
83
|
+
`将永久删除 ${state.count} 个存档会话(含子会话),删除后无法恢复。\n\n共享附件和工作区文件会保留。确定继续吗?`,
|
|
84
|
+
)
|
|
85
|
+
if (!confirmed) return
|
|
86
|
+
setBusy(true)
|
|
87
|
+
setState(current => ({ ...current, error: '' }))
|
|
88
|
+
try {
|
|
89
|
+
const response = await fetch(ARCHIVE_ENDPOINT, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: {
|
|
92
|
+
accept: 'application/json',
|
|
93
|
+
'content-type': 'application/json',
|
|
94
|
+
'x-dsh-efm-integration-confirm': 'DELETE_ALL_ARCHIVED',
|
|
95
|
+
},
|
|
96
|
+
body: '{}',
|
|
97
|
+
})
|
|
98
|
+
const body = await response.json()
|
|
99
|
+
if (!response.ok || (body.failures && body.failures.length > 0)) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
body.error
|
|
102
|
+
|| body.blocked?.map(reason => `暂不能删除:${reason}`).join('\n')
|
|
103
|
+
|| body.failures?.map(failure => `${failure.sessionId}: ${failure.message}`).join('\n')
|
|
104
|
+
|| '删除失败',
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
window.location.reload()
|
|
108
|
+
} catch (error) {
|
|
109
|
+
setBusy(false)
|
|
110
|
+
setState(current => ({ ...current, error: String(error.message || error) }))
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return React.createElement('main', { style: pageStyle }, React.createElement('section', {
|
|
115
|
+
style: { ...cardStyle, maxWidth: '640px' },
|
|
116
|
+
},
|
|
117
|
+
React.createElement('h1', { style: { margin: '0 0 12px', fontSize: '24px' } }, '清空全部存档会话'),
|
|
118
|
+
React.createElement('p', { style: { color: '#aaa', lineHeight: 1.7 } },
|
|
119
|
+
'永久删除所有归档会话及其子 Agent 日志。共享附件和工作区文件不会被删除,操作无法撤销。'),
|
|
120
|
+
React.createElement('p', { style: { fontSize: '18px', fontWeight: 600 } },
|
|
121
|
+
state.loading ? '正在统计…' : `当前共有 ${state.count} 个会话(${state.archivedCount} 个归档根会话)`),
|
|
122
|
+
state.blocked.length > 0 && React.createElement('div', { style: noticeStyle },
|
|
123
|
+
'暂不能删除:', React.createElement('ul', null, state.blocked.map((item, index) => React.createElement('li', { key: index }, item)))),
|
|
124
|
+
state.error && React.createElement('pre', {
|
|
125
|
+
style: { color: '#ff8989', whiteSpace: 'pre-wrap', background: '#f003', padding: '12px', borderRadius: '10px' },
|
|
126
|
+
}, state.error),
|
|
127
|
+
React.createElement('button', {
|
|
128
|
+
type: 'button',
|
|
129
|
+
disabled: busy || state.loading || state.count === 0 || state.blocked.length > 0,
|
|
130
|
+
onClick: clear,
|
|
131
|
+
style: {
|
|
132
|
+
appearance: 'none', border: 0, borderRadius: '10px', background: '#d94747', color: 'white',
|
|
133
|
+
cursor: 'pointer', fontSize: '15px', fontWeight: 600, opacity: busy || state.count === 0 ? 0.45 : 1,
|
|
134
|
+
padding: '12px 18px', marginTop: '10px',
|
|
135
|
+
},
|
|
136
|
+
}, busy ? '正在永久删除…' : '永久删除全部存档会话'),
|
|
137
|
+
))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function LspServersPage() {
|
|
141
|
+
const empty = { loading: true, error: '', presets: [], servers: [], allowCustomServers: false, toolMount: 'lazy', toolMounted: false, restartHint: '' }
|
|
142
|
+
const [state, setState] = useState(empty)
|
|
143
|
+
const [draft, setDraft] = useState({ name: '', command: '', args: '', extensions: '' })
|
|
144
|
+
const [busy, setBusy] = useState(false)
|
|
145
|
+
|
|
146
|
+
const apply = (payload) => setState({
|
|
147
|
+
loading: false,
|
|
148
|
+
error: '',
|
|
149
|
+
presets: payload.presets || [],
|
|
150
|
+
servers: payload.servers || [],
|
|
151
|
+
allowCustomServers: payload.allowCustomServers === true,
|
|
152
|
+
toolMount: payload.toolMount || 'lazy',
|
|
153
|
+
toolMounted: payload.toolMounted === true,
|
|
154
|
+
restartHint: payload.restartHint || '',
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const controller = new AbortController()
|
|
159
|
+
fetch(LSP_ENDPOINT, { signal: controller.signal, headers: { accept: 'application/json' } })
|
|
160
|
+
.then(async response => {
|
|
161
|
+
const body = await response.json()
|
|
162
|
+
if (!response.ok) throw new Error(body.error || '无法读取语言服务器配置')
|
|
163
|
+
apply(body)
|
|
164
|
+
})
|
|
165
|
+
.catch(error => {
|
|
166
|
+
if (controller.signal.aborted) return
|
|
167
|
+
setState(current => ({ ...current, loading: false, error: String(error.message || error) }))
|
|
168
|
+
})
|
|
169
|
+
return () => controller.abort()
|
|
170
|
+
}, [])
|
|
171
|
+
|
|
172
|
+
const run = async (body, confirmText) => {
|
|
173
|
+
if (confirmText && !window.confirm(confirmText)) return
|
|
174
|
+
setBusy(true)
|
|
175
|
+
setState(current => ({ ...current, error: '' }))
|
|
176
|
+
try {
|
|
177
|
+
apply(await lspPost(body))
|
|
178
|
+
} catch (error) {
|
|
179
|
+
setState(current => ({ ...current, error: String(error.message || error) }))
|
|
180
|
+
}
|
|
181
|
+
setBusy(false)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const addCustom = async () => {
|
|
185
|
+
const extensions = {}
|
|
186
|
+
draft.extensions.split(',').map(item => item.trim()).filter(Boolean).forEach((pair) => {
|
|
187
|
+
const [ext, language] = pair.split('=').map(part => (part || '').trim())
|
|
188
|
+
if (ext && language) extensions[ext] = language
|
|
189
|
+
})
|
|
190
|
+
await run({
|
|
191
|
+
action: 'add',
|
|
192
|
+
server: {
|
|
193
|
+
name: draft.name.trim(),
|
|
194
|
+
command: draft.command.trim(),
|
|
195
|
+
args: draft.args.split(/\s+/).filter(Boolean),
|
|
196
|
+
extensions,
|
|
197
|
+
},
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const statusLabel = (status) => status === 'active' ? '已启用' : status === 'disabled' ? '已停用' : '启动失败'
|
|
202
|
+
|
|
203
|
+
return React.createElement('main', { style: pageStyle }, React.createElement('section', { style: cardStyle },
|
|
204
|
+
React.createElement('h1', { style: { margin: '0 0 12px', fontSize: '24px' } }, '语言服务器'),
|
|
205
|
+
React.createElement('p', { style: { color: '#aaa', lineHeight: 1.7 } },
|
|
206
|
+
'为 DSH 的 lsp 工具注册语义导航(定义、引用、实现、悬停)。启用或停用立即生效,无需重启;',
|
|
207
|
+
'语言服务器进程要彻底回收,需要重启 DSH。'),
|
|
208
|
+
state.loading && React.createElement('p', null, '正在读取配置…'),
|
|
209
|
+
React.createElement('p', { style: { fontSize: '15px' } },
|
|
210
|
+
`lsp 工具:${state.toolMounted ? '已挂载' : '未挂载'}(模式:${state.toolMount === 'always' ? '常驻' : '按需'})`),
|
|
211
|
+
state.restartHint && React.createElement('div', { style: noticeStyle }, state.restartHint),
|
|
212
|
+
state.error && React.createElement('pre', {
|
|
213
|
+
style: { color: '#ff8989', whiteSpace: 'pre-wrap', background: '#f003', padding: '12px', borderRadius: '10px' },
|
|
214
|
+
}, state.error),
|
|
215
|
+
|
|
216
|
+
React.createElement('h2', { style: { fontSize: '18px', margin: '20px 0 8px' } }, '内置语言服务器'),
|
|
217
|
+
React.createElement('ul', { style: { listStyle: 'none', padding: 0, margin: 0 } },
|
|
218
|
+
state.presets.map((preset) => React.createElement('li', {
|
|
219
|
+
key: preset.id,
|
|
220
|
+
style: { borderBottom: '1px solid #5553', padding: '12px 0', display: 'flex', gap: '12px', alignItems: 'center' },
|
|
221
|
+
},
|
|
222
|
+
React.createElement('div', { style: { flex: 1 } },
|
|
223
|
+
React.createElement('strong', null, preset.label),
|
|
224
|
+
React.createElement('div', { style: { color: '#999', fontSize: '13px' } },
|
|
225
|
+
Object.keys(preset.extensions || {}).join(' ')),
|
|
226
|
+
React.createElement('div', { style: { fontSize: '13px', color: preset.installed ? '#7fd08a' : '#e0a06b' } },
|
|
227
|
+
preset.installed ? `已找到:${preset.source || preset.command}` : `未安装 · ${preset.installHint}`)),
|
|
228
|
+
React.createElement('button', {
|
|
229
|
+
type: 'button',
|
|
230
|
+
disabled: busy,
|
|
231
|
+
onClick: () => run(preset.enabled
|
|
232
|
+
? { action: 'disable', preset: preset.id, name: preset.name }
|
|
233
|
+
: { action: 'enable', preset: preset.id, name: preset.name }),
|
|
234
|
+
style: {
|
|
235
|
+
appearance: 'none', border: 0, borderRadius: '8px', padding: '8px 14px', cursor: 'pointer',
|
|
236
|
+
background: preset.enabled ? '#5a2626' : '#1f6f43', color: 'white',
|
|
237
|
+
},
|
|
238
|
+
}, preset.enabled ? '停用' : '启用'),
|
|
239
|
+
)),
|
|
240
|
+
),
|
|
241
|
+
|
|
242
|
+
React.createElement('h2', { style: { fontSize: '18px', margin: '20px 0 8px' } }, '已配置条目'),
|
|
243
|
+
state.servers.length === 0
|
|
244
|
+
? React.createElement('p', { style: { color: '#888' } }, '暂无条目。')
|
|
245
|
+
: React.createElement('ul', { style: { listStyle: 'none', padding: 0, margin: 0 } },
|
|
246
|
+
state.servers.map((server) => React.createElement('li', {
|
|
247
|
+
key: server.name,
|
|
248
|
+
style: { borderBottom: '1px solid #5553', padding: '10px 0', display: 'flex', gap: '12px', alignItems: 'center' },
|
|
249
|
+
},
|
|
250
|
+
React.createElement('div', { style: { flex: 1 } },
|
|
251
|
+
React.createElement('strong', null, server.name),
|
|
252
|
+
React.createElement('span', { style: { marginLeft: '8px', fontSize: '13px', color: '#999' } },
|
|
253
|
+
statusLabel(server.status)),
|
|
254
|
+
server.error && React.createElement('div', { style: { fontSize: '13px', color: '#e0a06b' } }, server.error)),
|
|
255
|
+
server.preset === undefined && React.createElement('button', {
|
|
256
|
+
type: 'button',
|
|
257
|
+
disabled: busy,
|
|
258
|
+
onClick: () => run({ action: 'remove', name: server.name }, `删除自定义语言服务器 ${server.name}?`),
|
|
259
|
+
style: {
|
|
260
|
+
appearance: 'none', border: 0, borderRadius: '8px', padding: '8px 14px', cursor: 'pointer',
|
|
261
|
+
background: '#5a2626', color: 'white',
|
|
262
|
+
},
|
|
263
|
+
}, '删除'),
|
|
264
|
+
)),
|
|
265
|
+
),
|
|
266
|
+
|
|
267
|
+
state.allowCustomServers && React.createElement('div', { style: { marginTop: '20px' } },
|
|
268
|
+
React.createElement('h2', { style: { fontSize: '18px', margin: '0 0 8px' } }, '添加自定义语言服务器'),
|
|
269
|
+
React.createElement('p', { style: { color: '#aaa', fontSize: '13px' } },
|
|
270
|
+
'自定义命令会直接启动本机可执行文件,请只添加你信任的程序。'),
|
|
271
|
+
['name', 'command', 'args', 'extensions'].map((field) => React.createElement('label', {
|
|
272
|
+
key: field, style: { display: 'block', marginBottom: '8px' },
|
|
273
|
+
},
|
|
274
|
+
React.createElement('span', { style: { fontSize: '13px', color: '#999' } }, {
|
|
275
|
+
name: '名称(小写字母、数字、连字符)',
|
|
276
|
+
command: '可执行文件(绝对路径或 PATH 名称)',
|
|
277
|
+
args: '参数(空格分隔)',
|
|
278
|
+
extensions: '扩展名映射(例:.ts=typescript,.tsx=typescriptreact)',
|
|
279
|
+
}[field]),
|
|
280
|
+
React.createElement('input', {
|
|
281
|
+
value: draft[field],
|
|
282
|
+
onChange: event => setDraft(current => ({ ...current, [field]: event.target.value })),
|
|
283
|
+
style: { width: '100%', boxSizing: 'border-box', padding: '8px', borderRadius: '8px', border: '1px solid #555' },
|
|
284
|
+
}),
|
|
285
|
+
)),
|
|
286
|
+
React.createElement('button', {
|
|
287
|
+
type: 'button',
|
|
288
|
+
disabled: busy || !draft.name.trim() || !draft.command.trim(),
|
|
289
|
+
onClick: addCustom,
|
|
290
|
+
style: {
|
|
291
|
+
appearance: 'none', border: 0, borderRadius: '8px', padding: '10px 16px', cursor: 'pointer',
|
|
292
|
+
background: '#1f6f43', color: 'white',
|
|
293
|
+
},
|
|
294
|
+
}, '添加并启用'))
|
|
295
|
+
, !state.allowCustomServers && React.createElement('p', {
|
|
296
|
+
style: { color: '#888', fontSize: '13px', marginTop: '16px' },
|
|
297
|
+
}, '自定义命令未启用:如需添加,请在 cordis.patch.yml 的 dsh-efm-integration-lsp-servers 行设置 allowCustomServers: true 并重启 DSH。'),
|
|
298
|
+
|
|
299
|
+
React.createElement('button', {
|
|
300
|
+
type: 'button',
|
|
301
|
+
disabled: busy,
|
|
302
|
+
onClick: () => run({ action: 'restart' }),
|
|
303
|
+
style: {
|
|
304
|
+
appearance: 'none', border: '1px solid #5557', borderRadius: '8px', padding: '10px 16px',
|
|
305
|
+
cursor: 'pointer', background: 'transparent', color: 'inherit', marginTop: '18px',
|
|
306
|
+
},
|
|
307
|
+
}, '查看重启提示'),
|
|
308
|
+
))
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function SystemPromptPage() {
|
|
312
|
+
const initial = {
|
|
313
|
+
loading: true, source: 'default', text: '', length: 0, pureMode: false,
|
|
314
|
+
lockedByConfig: false, maxPromptBytes: 0, error: '',
|
|
315
|
+
presets: [], targetPreset: null, defaultPresetId: '', targetPresetAvailable: true,
|
|
316
|
+
}
|
|
317
|
+
const [state, setState] = useState(initial)
|
|
318
|
+
const [draft, setDraft] = useState('')
|
|
319
|
+
const [draftTarget, setDraftTarget] = useState('all')
|
|
320
|
+
const [busy, setBusy] = useState(false)
|
|
321
|
+
|
|
322
|
+
const apply = (payload) => {
|
|
323
|
+
const target = !payload.targetPreset || payload.targetPreset === 'all' ? 'all' : payload.targetPreset
|
|
324
|
+
setState({
|
|
325
|
+
loading: false,
|
|
326
|
+
source: payload.source || 'default',
|
|
327
|
+
text: payload.text || '',
|
|
328
|
+
length: payload.length || 0,
|
|
329
|
+
pureMode: payload.pureMode === true,
|
|
330
|
+
lockedByConfig: payload.lockedByConfig === true,
|
|
331
|
+
maxPromptBytes: payload.maxPromptBytes || 0,
|
|
332
|
+
error: '',
|
|
333
|
+
presets: Array.isArray(payload.presets) ? payload.presets : [],
|
|
334
|
+
targetPreset: target === 'all' ? null : target,
|
|
335
|
+
defaultPresetId: payload.defaultPresetId || '',
|
|
336
|
+
targetPresetAvailable: payload.targetPresetAvailable !== false,
|
|
337
|
+
})
|
|
338
|
+
if (payload.source !== 'default') setDraft(payload.text || '')
|
|
339
|
+
setDraftTarget(target)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
const controller = new AbortController()
|
|
344
|
+
fetch(SYSTEM_PROMPT_ENDPOINT, { signal: controller.signal, headers: { accept: 'application/json' } })
|
|
345
|
+
.then(async response => {
|
|
346
|
+
const body = await response.json()
|
|
347
|
+
if (!response.ok) throw new Error(body.error || '无法读取系统提示词')
|
|
348
|
+
apply(body)
|
|
349
|
+
})
|
|
350
|
+
.catch(error => {
|
|
351
|
+
if (controller.signal.aborted) return
|
|
352
|
+
setState(current => ({ ...current, loading: false, error: String(error.message || error) }))
|
|
353
|
+
})
|
|
354
|
+
return () => controller.abort()
|
|
355
|
+
}, [])
|
|
356
|
+
|
|
357
|
+
const post = async (body, confirmText) => {
|
|
358
|
+
if (confirmText && !window.confirm(confirmText)) return
|
|
359
|
+
setBusy(true)
|
|
360
|
+
setState(current => ({ ...current, error: '' }))
|
|
361
|
+
try {
|
|
362
|
+
const response = await fetch(SYSTEM_PROMPT_ENDPOINT, {
|
|
363
|
+
method: 'POST',
|
|
364
|
+
headers: {
|
|
365
|
+
accept: 'application/json',
|
|
366
|
+
'content-type': 'application/json',
|
|
367
|
+
'x-dsh-efm-integration-confirm': SYSTEM_PROMPT_CONFIRM_VALUE,
|
|
368
|
+
},
|
|
369
|
+
body: JSON.stringify(body),
|
|
370
|
+
})
|
|
371
|
+
const payload = await response.json()
|
|
372
|
+
if (!response.ok) throw new Error(payload.error || '系统提示词操作失败')
|
|
373
|
+
apply(payload)
|
|
374
|
+
} catch (error) {
|
|
375
|
+
setState(current => ({ ...current, error: String(error.message || error) }))
|
|
376
|
+
}
|
|
377
|
+
setBusy(false)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const sourceLabel = { config: '由 cordis.patch.yml 配置', custom: '自定义(纯净模式)', default: '默认执行契约' }[state.source] || state.source
|
|
381
|
+
const presetOptions = [{ value: 'all', label: '全部预设(保持原有全局行为)' }].concat(
|
|
382
|
+
state.presets.map(preset => ({
|
|
383
|
+
value: preset.id,
|
|
384
|
+
label: `${preset.name || preset.id}${preset.isDefault ? '(默认)' : ''}`,
|
|
385
|
+
})),
|
|
386
|
+
)
|
|
387
|
+
if (state.targetPreset && !state.presets.some(preset => preset.id === state.targetPreset)) {
|
|
388
|
+
presetOptions.push({ value: state.targetPreset, label: `${state.targetPreset}(已失效)` })
|
|
389
|
+
}
|
|
390
|
+
const targetLabel = state.targetPreset === null
|
|
391
|
+
? '全部预设'
|
|
392
|
+
: state.presets.find(preset => preset.id === state.targetPreset)?.name || state.targetPreset
|
|
393
|
+
|
|
394
|
+
return React.createElement('main', { style: pageStyle }, React.createElement('section', { style: cardStyle },
|
|
395
|
+
React.createElement('h1', { style: { margin: '0 0 12px', fontSize: '24px' } }, '系统提示词'),
|
|
396
|
+
React.createElement('p', { style: { color: '#aaa', lineHeight: 1.7 } },
|
|
397
|
+
'填入一段提示词并保存后,模型只会收到这段文字:技能路由、MCP/工具说明、运行时上下文快照都会被去掉,工具调用也会被关闭。可选择只对某个 agent preset 生效,其他预设不受影响;“全部预设”保持原有全局行为。点击“恢复默认”可回到当前执行契约。'),
|
|
398
|
+
state.loading && React.createElement('p', null, '正在读取配置…'),
|
|
399
|
+
!state.loading && React.createElement('p', { style: { fontSize: '15px' } }, `当前来源:${sourceLabel};长度:${state.length} 字节;纯净模式:${state.pureMode ? '开启' : '关闭'};目标预设:${targetLabel}`),
|
|
400
|
+
state.source === 'custom' && !state.targetPresetAvailable && React.createElement('div', { style: noticeStyle },
|
|
401
|
+
'当前目标预设已不在可用列表中,替换暂时不会生效。请重新选择预设,或恢复默认。'),
|
|
402
|
+
React.createElement('label', { style: { display: 'block', marginTop: '12px' } },
|
|
403
|
+
React.createElement('span', { style: { fontSize: '13px', color: '#999' } }, '替换范围(agent preset)'),
|
|
404
|
+
React.createElement('select', {
|
|
405
|
+
value: draftTarget,
|
|
406
|
+
onChange: event => setDraftTarget(event.target.value),
|
|
407
|
+
disabled: busy || state.lockedByConfig,
|
|
408
|
+
style: {
|
|
409
|
+
display: 'block', width: '100%', boxSizing: 'border-box', marginTop: '8px', padding: '10px',
|
|
410
|
+
borderRadius: '10px', border: '1px solid #555', background: '#0003', color: 'inherit',
|
|
411
|
+
},
|
|
412
|
+
}, presetOptions.map(option => React.createElement('option', {
|
|
413
|
+
key: option.value, value: option.value,
|
|
414
|
+
}, option.label)))),
|
|
415
|
+
state.lockedByConfig && React.createElement('div', { style: noticeStyle },
|
|
416
|
+
'cordis.patch.yml 已配置 prompt/promptFile,配置优先;此页面只读。'),
|
|
417
|
+
state.error && React.createElement('pre', {
|
|
418
|
+
style: { color: '#ff8989', whiteSpace: 'pre-wrap', background: '#f003', padding: '12px', borderRadius: '10px' },
|
|
419
|
+
}, state.error),
|
|
420
|
+
React.createElement('label', { style: { display: 'block', marginTop: '16px' } },
|
|
421
|
+
React.createElement('span', { style: { fontSize: '13px', color: '#999' } },
|
|
422
|
+
`自定义提示词(UTF-8,最多 ${state.maxPromptBytes || '—'} 字节,请勿写入密钥)`),
|
|
423
|
+
React.createElement('textarea', {
|
|
424
|
+
value: draft,
|
|
425
|
+
onChange: event => setDraft(event.target.value),
|
|
426
|
+
disabled: busy || state.lockedByConfig,
|
|
427
|
+
rows: 16,
|
|
428
|
+
spellCheck: false,
|
|
429
|
+
style: {
|
|
430
|
+
width: '100%', boxSizing: 'border-box', marginTop: '8px', padding: '12px',
|
|
431
|
+
borderRadius: '10px', border: '1px solid #555', background: '#0003',
|
|
432
|
+
color: 'inherit', fontFamily: 'monospace', fontSize: '13px', lineHeight: 1.5,
|
|
433
|
+
resize: 'vertical',
|
|
434
|
+
},
|
|
435
|
+
})),
|
|
436
|
+
React.createElement('div', { style: { display: 'flex', gap: '12px', marginTop: '16px', flexWrap: 'wrap' } },
|
|
437
|
+
React.createElement('button', {
|
|
438
|
+
type: 'button',
|
|
439
|
+
disabled: busy || state.lockedByConfig || draft.trim().length === 0,
|
|
440
|
+
onClick: () => post({ action: 'save', text: draft, targetPreset: draftTarget }),
|
|
441
|
+
style: {
|
|
442
|
+
appearance: 'none', border: 0, borderRadius: '8px', padding: '10px 16px', cursor: 'pointer',
|
|
443
|
+
background: '#1f6f43', color: 'white', fontWeight: 600,
|
|
444
|
+
},
|
|
445
|
+
}, busy ? '正在保存…' : '保存并启用纯净模式'),
|
|
446
|
+
React.createElement('button', {
|
|
447
|
+
type: 'button',
|
|
448
|
+
disabled: busy || state.lockedByConfig || state.source === 'default',
|
|
449
|
+
onClick: () => post({ action: 'clear' }, '恢复默认执行契约并重新启用工具?'),
|
|
450
|
+
style: {
|
|
451
|
+
appearance: 'none', border: '1px solid #5557', borderRadius: '8px', padding: '10px 16px',
|
|
452
|
+
cursor: 'pointer', background: 'transparent', color: 'inherit',
|
|
453
|
+
},
|
|
454
|
+
}, '恢复默认')),
|
|
455
|
+
))
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function TrashIcon({ size = 16 }) {
|
|
459
|
+
return React.createElement('svg', {
|
|
460
|
+
width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
|
|
461
|
+
stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
462
|
+
'aria-hidden': 'true',
|
|
463
|
+
},
|
|
464
|
+
React.createElement('path', { d: 'M4 7h16M9 7V4h6v3M7 7l1 13h8l1-13M10 11v5M14 11v5' }))
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function CodeIcon({ size = 16 }) {
|
|
468
|
+
return React.createElement('svg', {
|
|
469
|
+
width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
|
|
470
|
+
stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
471
|
+
'aria-hidden': 'true',
|
|
472
|
+
},
|
|
473
|
+
React.createElement('path', { d: 'M9 7l-5 5 5 5M15 7l5 5-5 5' }))
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function DocumentIcon({ size = 16 }) {
|
|
477
|
+
return React.createElement('svg', {
|
|
478
|
+
width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
|
|
479
|
+
stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
480
|
+
'aria-hidden': 'true',
|
|
481
|
+
},
|
|
482
|
+
React.createElement('path', { d: 'M7 3h7l5 5v13H7zM14 3v5h5M10 12h6M10 16h6' }))
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function apply(ctx) {
|
|
486
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
487
|
+
name: 'main',
|
|
488
|
+
key: ARCHIVE_PANEL_ID,
|
|
489
|
+
}, ArchiveCleanerPage))
|
|
490
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
491
|
+
name: 'sidebar.panellist',
|
|
492
|
+
id: ARCHIVE_PANEL_ID,
|
|
493
|
+
order: 20,
|
|
494
|
+
label: '清空全部存档会话',
|
|
495
|
+
}, TrashIcon))
|
|
496
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
497
|
+
name: 'main',
|
|
498
|
+
key: LSP_PANEL_ID,
|
|
499
|
+
}, LspServersPage))
|
|
500
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
501
|
+
name: 'sidebar.panellist',
|
|
502
|
+
id: LSP_PANEL_ID,
|
|
503
|
+
order: 21,
|
|
504
|
+
label: '语言服务器',
|
|
505
|
+
}, CodeIcon))
|
|
506
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
507
|
+
name: 'main',
|
|
508
|
+
key: SYSTEM_PROMPT_PANEL_ID,
|
|
509
|
+
}, SystemPromptPage))
|
|
510
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
511
|
+
name: 'sidebar.panellist',
|
|
512
|
+
id: SYSTEM_PROMPT_PANEL_ID,
|
|
513
|
+
order: 22,
|
|
514
|
+
label: '系统提示词',
|
|
515
|
+
}, DocumentIcon))
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
module.exports = {
|
|
519
|
+
name: 'dsh-efm-integration-archive-cleaner',
|
|
520
|
+
inject: ['slots'],
|
|
521
|
+
apply,
|
|
522
|
+
}
|
|
523
|
+
return module.exports
|
|
524
|
+
},
|
|
525
|
+
})
|