dsh-coexist-plugin 0.0.0-stage → 0.1.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/client.js ADDED
@@ -0,0 +1,545 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-coexist-plugin',
3
+ factory: (require) => {
4
+ var module = { exports: {} }
5
+ var exports = module.exports
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
7
+
8
+ const React = require('react')
9
+ const h = React.createElement
10
+ const INJECT = ['slots', 'layout']
11
+ let hostContext = null
12
+
13
+ const CSS = `
14
+ .dsh-coexist-section{max-width:920px;display:flex;flex-direction:column;gap:14px;color:var(--dsw-alias-label-primary)}
15
+ .dsh-coexist-head{display:flex;align-items:baseline;gap:10px}
16
+ .dsh-coexist-title{margin:0;font-size:18px;font-weight:600}
17
+ .dsh-coexist-sub{color:var(--dsw-alias-label-tertiary);font-size:12px}
18
+ .dsh-coexist-card{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:12px 14px;display:flex;flex-direction:column;gap:10px;background:var(--dsw-alias-bg-layer-1)}
19
+ .dsh-coexist-card h3{margin:0;font-size:14px;font-weight:600}
20
+ .dsh-coexist-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
21
+ .dsh-coexist-btn{cursor:pointer;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);border-radius:8px;padding:5px 11px;font-size:12px}
22
+ .dsh-coexist-btn:hover:not(:disabled){border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
23
+ .dsh-coexist-btn.primary{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-overlay)}
24
+ .dsh-coexist-btn.danger:hover:not(:disabled){border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}
25
+ .dsh-coexist-btn:disabled{opacity:.45;cursor:default}
26
+ .dsh-coexist-input{flex:1;min-width:220px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:7px 10px;font-size:13px;outline:none}
27
+ .dsh-coexist-input:focus{border-color:var(--dsw-alias-brand-primary)}
28
+ .dsh-coexist-list{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:6px}
29
+ .dsh-coexist-item{display:flex;align-items:center;gap:8px;padding:7px 9px;border-radius:8px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);font-size:12px}
30
+ .dsh-coexist-item-main{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
31
+ .dsh-coexist-tag{font-size:11px;color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l2);border-radius:999px;padding:1px 8px;white-space:nowrap}
32
+ .dsh-coexist-tag.error{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}
33
+ .dsh-coexist-muted{color:var(--dsw-alias-label-tertiary);font-size:12px}
34
+ .dsh-coexist-msg{font-size:12px;border-radius:8px;padding:7px 10px}
35
+ .dsh-coexist-msg.ok{color:var(--dsw-alias-state-success-primary);background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent)}
36
+ .dsh-coexist-msg.error{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}
37
+ .dsh-coexist-msg.info{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2)}
38
+ .dsh-coexist-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}
39
+ .dsh-coexist-kv{background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:8px 10px}
40
+ .dsh-coexist-kv .k{font-size:11px;color:var(--dsw-alias-label-tertiary)}
41
+ .dsh-coexist-kv .v{font-size:14px;font-weight:600;margin-top:2px}
42
+ .dsh-coexist-select{background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:4px 8px;font-size:12px}
43
+ .dsh-coexist-code{font-family:var(--ds-font-family-code,ui-monospace,Consolas,monospace);font-size:11px;color:var(--dsw-alias-label-secondary);word-break:break-all}
44
+ `
45
+
46
+ async function api(method, body) {
47
+ const res = await fetch('/coexist-api/' + method, {
48
+ method: 'POST',
49
+ headers: { 'Content-Type': 'application/json' },
50
+ body: JSON.stringify(body || {}),
51
+ })
52
+ let payload
53
+ try {
54
+ payload = await res.json()
55
+ } catch {
56
+ throw new Error('HTTP ' + res.status)
57
+ }
58
+ if (!res.ok || payload?.ok === false) {
59
+ throw new Error(payload?.error || ('HTTP ' + res.status))
60
+ }
61
+ return payload
62
+ }
63
+
64
+ function countOf(list) {
65
+ return Array.isArray(list) ? list.length : 0
66
+ }
67
+
68
+ function AliasList({ title, rows }) {
69
+ if (!rows?.length) return null
70
+ return h(
71
+ 'div',
72
+ null,
73
+ h('div', { className: 'dsh-coexist-muted' }, title),
74
+ h(
75
+ 'ul',
76
+ { className: 'dsh-coexist-list' },
77
+ rows.map((row, index) =>
78
+ h(
79
+ 'li',
80
+ { className: 'dsh-coexist-item', key: index },
81
+ h('span', { className: 'dsh-coexist-item-main' }, row.name),
82
+ h('span', { className: 'dsh-coexist-code' }, '→ ' + row.alias),
83
+ ),
84
+ ),
85
+ ),
86
+ )
87
+ }
88
+
89
+ function Section(props) {
90
+ const [status, setStatus] = React.useState(null)
91
+ const [graph, setGraph] = React.useState(null)
92
+ const [plan, setPlan] = React.useState(null)
93
+ const [busy, setBusy] = React.useState('')
94
+ const [message, setMessage] = React.useState(null)
95
+ const [spec, setSpec] = React.useState('')
96
+
97
+ // 市场入口:切到宿主「插件」页并关闭设置覆盖层;宿主没有 layout 服务时回退到目录站。
98
+ const openMarket = () => {
99
+ const layout = hostContext?.layout ?? hostContext?.get?.('layout')
100
+ if (layout && typeof layout.selectPanel === 'function') {
101
+ try {
102
+ layout.selectPanel('plugins')
103
+ if (typeof props?.close === 'function') props.close()
104
+ return
105
+ } catch {
106
+ // 继续走浏览器回退。
107
+ }
108
+ }
109
+ window.open('https://awesome-dsh-plugin.com', '_blank', 'noopener')
110
+ }
111
+
112
+ const notify = (kind, text) => setMessage({ kind, text })
113
+ const fail = (error) => notify('error', String(error?.message || error))
114
+
115
+ const refresh = async () => {
116
+ setBusy('refresh')
117
+ try {
118
+ const next = await api('status')
119
+ setStatus(next)
120
+ setMessage(null)
121
+ } catch (error) {
122
+ fail(error)
123
+ } finally {
124
+ setBusy('')
125
+ }
126
+ }
127
+
128
+ React.useEffect(() => {
129
+ refresh()
130
+ }, [])
131
+
132
+ const runCheck = async () => {
133
+ setBusy('check')
134
+ try {
135
+ const res = await api('check')
136
+ setGraph(res.value)
137
+ const conflicts = countOf(res.value?.conflicts)
138
+ notify('ok', conflicts ? `发现 ${conflicts} 个冲突` : '没有发现冲突')
139
+ } catch (error) {
140
+ fail(error)
141
+ } finally {
142
+ setBusy('')
143
+ }
144
+ }
145
+
146
+ const runPlan = async () => {
147
+ setBusy('plan')
148
+ try {
149
+ const res = await api('plan')
150
+ setPlan(res.value)
151
+ const actions = countOf(res.value?.actions)
152
+ notify(actions ? 'info' : 'ok', actions ? `生成 ${actions} 个修复动作,确认后应用` : '没有需要修复的项')
153
+ } catch (error) {
154
+ fail(error)
155
+ } finally {
156
+ setBusy('')
157
+ }
158
+ }
159
+
160
+ const runApply = async () => {
161
+ if (!plan?.id) return
162
+ setBusy('apply')
163
+ try {
164
+ await api('apply', { planId: plan.id })
165
+ setPlan(null)
166
+ await refresh()
167
+ notify('ok', '修复已应用。重启 DSH 后完全生效。')
168
+ } catch (error) {
169
+ fail(error)
170
+ } finally {
171
+ setBusy('')
172
+ }
173
+ }
174
+
175
+ const runRollback = async (id) => {
176
+ if (!window.confirm('回滚会覆盖当前 profile 配置,继续?')) return
177
+ setBusy('rollback')
178
+ try {
179
+ await api('rollback', { id, reinstall: true })
180
+ await refresh()
181
+ notify('ok', '已回滚,并按 lockfile 重装依赖。重启 DSH 后生效。')
182
+ } catch (error) {
183
+ fail(error)
184
+ } finally {
185
+ setBusy('')
186
+ }
187
+ }
188
+
189
+ const runInstall = async () => {
190
+ const value = spec.trim()
191
+ if (!value) return
192
+ setBusy('install')
193
+ try {
194
+ const res = await api('install', { spec: value })
195
+ setSpec('')
196
+ await refresh()
197
+ notify('ok', `已安装 ${res.value?.plugin?.name || value}@${res.value?.plugin?.version || ''}。重启 DSH 后加载。`)
198
+ } catch (error) {
199
+ fail(error)
200
+ } finally {
201
+ setBusy('')
202
+ }
203
+ }
204
+
205
+ const runUninstall = async (name) => {
206
+ const self = name === 'dsh-coexist-plugin'
207
+ const question = self
208
+ ? '卸载插件共存?设置页会消失,已安装的其他插件不受影响;备份和报告会保留(彻底清理请用 CLI 的 --purge)。继续?'
209
+ : `卸载 ${name}?会移除它的 bundle、依赖、安装目录和分阶段副本。继续?`
210
+ if (!window.confirm(question)) return
211
+ setBusy('uninstall')
212
+ try {
213
+ await api('uninstall', { name })
214
+ await refresh()
215
+ notify('ok', self ? '已卸载插件共存。重启 DSH 后设置页消失。' : `已卸载 ${name}。重启 DSH 后生效。`)
216
+ } catch (error) {
217
+ fail(error)
218
+ } finally {
219
+ setBusy('')
220
+ }
221
+ }
222
+
223
+ const runFreePort = async (port) => {
224
+ if (!window.confirm(`结束占用端口 ${port} 的进程?`)) return
225
+ setBusy('free-port')
226
+ try {
227
+ const res = await api('free-port', { port })
228
+ notify('ok', res.value?.killed?.length ? `已结束进程:${res.value.killed.join(', ')}` : `端口 ${port} 已空闲`)
229
+ } catch (error) {
230
+ fail(error)
231
+ } finally {
232
+ setBusy('')
233
+ }
234
+ }
235
+
236
+ const runPrefer = async (plugin) => {
237
+ if (!plugin) return
238
+ setBusy('prefer')
239
+ try {
240
+ await api('prefer', { plugin })
241
+ await refresh()
242
+ notify('ok', `已把 ${plugin} 排到最前,重启后它保留原名。`)
243
+ } catch (error) {
244
+ fail(error)
245
+ } finally {
246
+ setBusy('')
247
+ }
248
+ }
249
+
250
+ const toggleIsolate = async (checked) => {
251
+ setBusy('config')
252
+ try {
253
+ const res = await api('config', { patch: { serviceIsolate: checked } })
254
+ setStatus((prev) => (prev ? { ...prev, config: res.config } : prev))
255
+ notify('ok', `service 隔离已${checked ? '开启' : '关闭'},重启 DSH 后生效。`)
256
+ } catch (error) {
257
+ fail(error)
258
+ } finally {
259
+ setBusy('')
260
+ }
261
+ }
262
+
263
+ const report = status?.report
264
+ const conflicts = graph?.conflicts ?? report?.serviceConflicts ?? []
265
+ const aliasRows = [
266
+ ...(report?.tools?.aliases ?? []).map((row) => ({ ...row, kind: 'tool' })),
267
+ ...(report?.commands?.aliases ?? []).map((row) => ({ ...row, kind: 'command' })),
268
+ ...(report?.providers?.aliases ?? []).map((row) => ({ ...row, kind: 'provider' })),
269
+ ]
270
+ const graphConflicts = graph?.conflicts ?? []
271
+ const bundleNames = new Set(status?.bundles ?? [])
272
+ const busyOn = (name) => busy === name
273
+
274
+ return h(
275
+ 'div',
276
+ { className: 'dsh-coexist-section' },
277
+ h(
278
+ 'div',
279
+ { className: 'dsh-coexist-head' },
280
+ h('h2', { className: 'dsh-coexist-title' }, '插件共存'),
281
+ h('span', { className: 'dsh-coexist-sub' }, '冲突检测、一键修复、安装与回滚'),
282
+ ),
283
+
284
+ message
285
+ ? h('div', { className: 'dsh-coexist-msg ' + message.kind }, message.text)
286
+ : null,
287
+
288
+ h(
289
+ 'div',
290
+ { className: 'dsh-coexist-card' },
291
+ h('div', { className: 'dsh-coexist-row' },
292
+ h('button', { className: 'dsh-coexist-btn primary', onClick: refresh, disabled: !!busy }, busyOn('refresh') ? '刷新中…' : '刷新状态'),
293
+ h('button', { className: 'dsh-coexist-btn', onClick: runCheck, disabled: !!busy }, busyOn('check') ? '检查中…' : '检查冲突'),
294
+ h('button', { className: 'dsh-coexist-btn', onClick: runPlan, disabled: !!busy }, busyOn('plan') ? '生成中…' : '一键修复'),
295
+ h('button', { className: 'dsh-coexist-btn danger', onClick: () => runRollback(), disabled: !!busy || !status?.backups?.length }, busyOn('rollback') ? '回滚中…' : '回滚最近备份'),
296
+ ),
297
+ status
298
+ ? h(
299
+ 'div',
300
+ { className: 'dsh-coexist-grid' },
301
+ h('div', { className: 'dsh-coexist-kv' }, h('div', { className: 'k' }, 'Profile'), h('div', { className: 'v' }, status.profile)),
302
+ h('div', { className: 'dsh-coexist-kv' }, h('div', { className: 'k' }, '插件'), h('div', { className: 'v' }, String(countOf(status.bundles)))),
303
+ h('div', { className: 'dsh-coexist-kv' }, h('div', { className: 'k' }, '运行期失败'), h('div', { className: 'v' }, String(countOf(report?.failures)))),
304
+ h('div', { className: 'dsh-coexist-kv' }, h('div', { className: 'k' }, '别名'), h('div', { className: 'v' }, String(aliasRows.length))),
305
+ h('div', { className: 'dsh-coexist-kv' }, h('div', { className: 'k' }, '备份'), h('div', { className: 'v' }, String(countOf(status.backups)))),
306
+ )
307
+ : h('div', { className: 'dsh-coexist-muted' }, '正在读取状态…'),
308
+ status?.cli && status.cli.ok === false
309
+ ? h('div', { className: 'dsh-coexist-msg error' }, 'CLI 不可用:' + status.cli.error)
310
+ : null,
311
+ ),
312
+
313
+ plan?.actions?.length
314
+ ? h(
315
+ 'div',
316
+ { className: 'dsh-coexist-card' },
317
+ h('h3', null, `修复计划(${plan.actions.length})`),
318
+ h(
319
+ 'ul',
320
+ { className: 'dsh-coexist-list' },
321
+ plan.actions.map((action, index) =>
322
+ h(
323
+ 'li',
324
+ { className: 'dsh-coexist-item', key: index },
325
+ h('span', { className: 'dsh-coexist-item-main' }, action.kind + (action.owner ? ' · ' + action.owner : '')),
326
+ h('span', { className: 'dsh-coexist-code' }, action.oldPort ? `${action.oldPort} → ${action.newPort}` : action.file || ''),
327
+ ),
328
+ ),
329
+ ),
330
+ h(
331
+ 'div',
332
+ { className: 'dsh-coexist-row' },
333
+ h('button', { className: 'dsh-coexist-btn primary', onClick: runApply, disabled: !!busy }, busyOn('apply') ? '应用中…' : '应用修复'),
334
+ h('button', { className: 'dsh-coexist-btn', onClick: () => setPlan(null), disabled: !!busy }, '取消'),
335
+ ),
336
+ )
337
+ : null,
338
+
339
+ graphConflicts.length
340
+ ? h(
341
+ 'div',
342
+ { className: 'dsh-coexist-card' },
343
+ h('h3', null, '冲突'),
344
+ h(
345
+ 'ul',
346
+ { className: 'dsh-coexist-list' },
347
+ graphConflicts.map((conflict, index) => {
348
+ const type = conflict.resource?.type ?? 'unknown'
349
+ const key = conflict.resource?.key ?? ''
350
+ const owners = conflict.owners ?? []
351
+ const bundleOwners = owners.filter((owner) => bundleNames.has(owner))
352
+ return h(
353
+ 'li',
354
+ { className: 'dsh-coexist-item', key: index },
355
+ h('span', { className: 'dsh-coexist-item-main' }, `${type} · ${key} — ${owners.join(' / ')}`),
356
+ type === 'port'
357
+ ? h('button', { className: 'dsh-coexist-btn', onClick: () => runFreePort(Number(key)), disabled: !!busy || !Number.isInteger(Number(key)) }, '释放端口')
358
+ : null,
359
+ bundleOwners.length > 1
360
+ ? h(
361
+ 'select',
362
+ {
363
+ className: 'dsh-coexist-select',
364
+ defaultValue: '',
365
+ onChange: (event) => runPrefer(event.target.value),
366
+ disabled: !!busy,
367
+ },
368
+ h('option', { value: '' }, '保留原名…'),
369
+ bundleOwners.map((owner) => h('option', { key: owner, value: owner }, owner)),
370
+ )
371
+ : null,
372
+ )
373
+ }),
374
+ ),
375
+ )
376
+ : null,
377
+
378
+ aliasRows.length
379
+ ? h(
380
+ 'div',
381
+ { className: 'dsh-coexist-card' },
382
+ h('h3', null, '当前别名'),
383
+ h(AliasList, { title: '工具', rows: aliasRows.filter((row) => row.kind === 'tool') }),
384
+ h(AliasList, { title: '命令', rows: aliasRows.filter((row) => row.kind === 'command') }),
385
+ h(AliasList, { title: 'Provider', rows: aliasRows.filter((row) => row.kind === 'provider') }),
386
+ )
387
+ : null,
388
+
389
+ report?.failures?.length
390
+ ? h(
391
+ 'div',
392
+ { className: 'dsh-coexist-card' },
393
+ h('h3', null, '运行期失败'),
394
+ h(
395
+ 'ul',
396
+ { className: 'dsh-coexist-list' },
397
+ report.failures.map((failure, index) =>
398
+ h(
399
+ 'li',
400
+ { className: 'dsh-coexist-item', key: index },
401
+ h('span', { className: 'dsh-coexist-tag error' }, failure.kind || 'runtime'),
402
+ h('span', { className: 'dsh-coexist-item-main' }, `${failure.plugin}: ${failure.error}`),
403
+ ),
404
+ ),
405
+ ),
406
+ )
407
+ : null,
408
+
409
+ h(
410
+ 'div',
411
+ { className: 'dsh-coexist-card' },
412
+ h('h3', null, '安装插件'),
413
+ h(
414
+ 'div',
415
+ { className: 'dsh-coexist-row' },
416
+ h('input', {
417
+ className: 'dsh-coexist-input',
418
+ value: spec,
419
+ placeholder: 'npm 包名或本地路径,例如 @scope/dsh-plugin',
420
+ onChange: (event) => setSpec(event.target.value),
421
+ onKeyDown: (event) => {
422
+ if (event.key === 'Enter') runInstall()
423
+ },
424
+ }),
425
+ h('button', { className: 'dsh-coexist-btn primary', onClick: runInstall, disabled: !!busy || !spec.trim() }, busyOn('install') ? '安装中…' : '安装'),
426
+ ),
427
+ h('div', { className: 'dsh-coexist-muted' }, '安装前会做版本检查;失败会自动回滚 package.json 与 lockfile。'),
428
+ ),
429
+
430
+ h(
431
+ 'div',
432
+ { className: 'dsh-coexist-card' },
433
+ h('h3', null, '插件市场'),
434
+ h('div', { className: 'dsh-coexist-muted' }, '在插件页的市场标签中搜索并一键安装;装完回到这里检查冲突。'),
435
+ h(
436
+ 'div',
437
+ { className: 'dsh-coexist-row' },
438
+ h('button', { className: 'dsh-coexist-btn', onClick: openMarket }, '打开插件市场'),
439
+ h(
440
+ 'button',
441
+ { className: 'dsh-coexist-btn', onClick: () => window.open('https://awesome-dsh-plugin.com', '_blank', 'noopener') },
442
+ '在浏览器打开目录',
443
+ ),
444
+ ),
445
+ ),
446
+
447
+ h(
448
+ 'div',
449
+ { className: 'dsh-coexist-card' },
450
+ h('h3', null, '已启用插件'),
451
+ status?.bundles?.length
452
+ ? h(
453
+ 'ul',
454
+ { className: 'dsh-coexist-list' },
455
+ status.bundles.map((name) =>
456
+ h(
457
+ 'li',
458
+ { className: 'dsh-coexist-item', key: name },
459
+ h('span', { className: 'dsh-coexist-item-main' }, name),
460
+ h('button', { className: 'dsh-coexist-btn danger', onClick: () => runUninstall(name), disabled: !!busy }, '卸载'),
461
+ ),
462
+ ),
463
+ )
464
+ : h('div', { className: 'dsh-coexist-muted' }, '没有已启用插件。'),
465
+ h(
466
+ 'div',
467
+ { className: 'dsh-coexist-muted' },
468
+ '从宿主插件页卸载会保留共存备份/报告;需要彻底清理请用这里的「卸载」或 CLI 的 --purge。',
469
+ ),
470
+ ),
471
+
472
+ h(
473
+ 'div',
474
+ { className: 'dsh-coexist-card' },
475
+ h('h3', null, '运行策略'),
476
+ h(
477
+ 'label',
478
+ { className: 'dsh-coexist-row' },
479
+ h('input', {
480
+ type: 'checkbox',
481
+ checked: status?.config?.serviceIsolate === true,
482
+ disabled: !!busy || !status,
483
+ onChange: (event) => toggleIsolate(event.target.checked),
484
+ }),
485
+ h('span', null, 'service 冲突时自动隔离(重启生效)'),
486
+ ),
487
+ h(
488
+ 'div',
489
+ { className: 'dsh-coexist-muted' },
490
+ '两个插件提供同名服务时,让后加载的插件使用自己的副本,避免互相覆盖。默认关闭;只有检查结果里出现 service 冲突时才建议开启,开启后需重启 DSH。',
491
+ ),
492
+ status?.config?.services
493
+ ? h('div', { className: 'dsh-coexist-muted' }, '已配置的服务策略:' + Object.keys(status.config.services).join(', '))
494
+ : null,
495
+ ),
496
+
497
+ status?.backups?.length
498
+ ? h(
499
+ 'div',
500
+ { className: 'dsh-coexist-card' },
501
+ h('h3', null, '备份'),
502
+ h(
503
+ 'ul',
504
+ { className: 'dsh-coexist-list' },
505
+ status.backups.slice(0, 5).map((id) =>
506
+ h(
507
+ 'li',
508
+ { className: 'dsh-coexist-item', key: id },
509
+ h('span', { className: 'dsh-coexist-item-main' }, id),
510
+ h('button', { className: 'dsh-coexist-btn', onClick: () => runRollback(id), disabled: !!busy }, '回滚'),
511
+ ),
512
+ ),
513
+ ),
514
+ )
515
+ : null,
516
+ )
517
+ }
518
+
519
+ function apply(ctx) {
520
+ hostContext = ctx
521
+ const slots = ctx.get('slots')
522
+ if (!slots) return
523
+ const tag = document.createElement('style')
524
+ tag.setAttribute('data-plugin', 'dsh-coexist-plugin')
525
+ tag.textContent = CSS
526
+ document.head.appendChild(tag)
527
+
528
+ slots.inject('settings.section', () =>
529
+ slots.register(
530
+ {
531
+ name: 'settings.section',
532
+ id: 'coexist',
533
+ order: 16,
534
+ label: () => '插件共存',
535
+ },
536
+ Section,
537
+ ),
538
+ )
539
+ }
540
+
541
+ exports.apply = apply
542
+ exports.inject = INJECT
543
+ return module.exports
544
+ },
545
+ })
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "dsh-coexist-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "DSH plugin coexistence: keep plugins that claim the same tool, command, provider or service. · DSH 插件共存:同名工具自动别名、冲突检测与一键修复。",
5
+ "icon": "assets/icon.svg",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./client": "./lib/client.js",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "src",
16
+ "lib",
17
+ "assets",
18
+ "cordis.patch.yml"
19
+ ],
20
+ "engines": {
21
+ "dsh": ">=0.2.0 <0.3.0"
22
+ },
23
+ "keywords": [
24
+ "dsh-plugin",
25
+ "deepseek-harness",
26
+ "compatibility",
27
+ "coexistence"
28
+ ],
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "dsh-coexist-cli": "^0.1.0"
32
+ },
33
+ "dsh": {
34
+ "bundle": {
35
+ "patch": "./cordis.patch.yml"
36
+ },
37
+ "client": {
38
+ "platform": "web",
39
+ "inject": [
40
+ "@deepseek-ai/dsh-client-ui-settings",
41
+ "@deepseek-ai/dsh-client-ui-layout"
42
+ ]
43
+ }
44
+ },
45
+ "peerDependencies": {
46
+ "@deepseek-ai/dsh": ">=0.2.0"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@deepseek-ai/dsh": {
50
+ "optional": true
51
+ }
52
+ }
53
+ }