@tinyforge/dsh-plugin-manager-wj 0.0.0-stage → 1.2.2

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 CHANGED
@@ -1,3 +1,37 @@
1
- # Temporary Holding Version
1
+ # dsh-plugin-manager-wj
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **WJ Plugin Management** is the Web management layer for DeepSeek Harness's three-layer plugin-management design. It extends the independent WJ bundle and adds a management tab under **Settings → Plugins**.
4
+
5
+ ![Plugin management interface](assets/plugin-management.webp)
6
+
7
+ ## Features
8
+
9
+ - **Harness Core:** consumes the Host's plugin registry, configuration resolver, conflict detector, lifecycle/dependency manager, and settings services.
10
+ - **Management API:** shows plugin state and health findings, configuration provenance, and tool/MCP runtime registrations. It can enable or disable profile-addressable plugins.
11
+ - **Management UI:** filters findings and plugins, edits non-secret scalar settings through the existing schema-backed `configForms`, and previews supported duplicate-registration repairs.
12
+
13
+ Enabling or disabling a plugin writes through the Host's existing profile manager. A change can apply immediately, require a restart, be overridden by a higher-priority layer, or be refused by the Host. Repair previews are short-lived and become invalid when their finding changes. Selecting a low-risk repair with one eligible target executes it automatically; a high-risk repair first shows the exact effect and requires an explicit confirmation click. The current repair action disables the selected plugin involved in a duplicate global tool or MCP registration.
14
+
15
+ Configuration fields are discovered from each Host-provided schema. Secret fields are omitted from the editor, and provenance shows layer names and redacted identities, never values or filesystem paths. The Host remains responsible for schema validation and persistence.
16
+
17
+ ## Requirements and limitations
18
+
19
+ Use a Harness Host that exposes the plugin-management Remote, settings forms, and runtime inventory. Older Hosts may show inventory only or report diagnostics as unavailable; upgrade Harness to use management actions. Only plugins addressable through the active profile can be toggled. The UI does not install/remove packages, edit credentials, or run arbitrary repair commands.
20
+
21
+ ## Install
22
+
23
+ 1. Make this package available to the Harness package resolver, for example from a local checkout or published package.
24
+ 2. Add the `@tinyforge/dsh-plugin-manager-wj` bundle to the target Web profile.
25
+ 3. Open **Settings → Plugins → Plugin management**.
26
+
27
+ `dsh.client` loads the browser client, and `cordis.patch.yml` inserts the bundle into the Host. Remove the bundle from the profile to remove the management tab. Core registry and management services do not depend on this UI bundle.
28
+
29
+ This repository does not publish the package or configure a package registry.
30
+
31
+ ## Development
32
+
33
+ The package is an ES module. `index.js` is the Host entry point and `client.js` contains the browser UI. Localized package metadata is in `locale/`; the UI's full dictionaries are registered in `client.js`. Run `node --test` for the bundle behavior check and `node --check client.js` for a syntax check. Harness API and Host behavior are implemented and tested in the `deepseek-harness` repository.
34
+
35
+ ## License
36
+
37
+ MIT.
package/README.zh.md ADDED
@@ -0,0 +1,37 @@
1
+ # dsh-plugin-manager-wj
2
+
3
+ **WJ 插件管理中心**是 DeepSeek Harness 三层插件管理架构的 Web 管理层,扩展现有独立 WJ bundle,并在 **设置 → 插件** 下添加管理标签页。
4
+
5
+ ![插件管理界面](assets/plugin-management.webp)
6
+
7
+ ## 功能
8
+
9
+ - **Harness Core:**使用 Host 提供的插件注册表、配置解析、冲突检测、生命周期与依赖管理,以及设置服务。
10
+ - **Management API:**查看插件状态、健康诊断、配置来源和工具/MCP 运行时注册;可启停当前 Profile 能寻址的插件。
11
+ - **Management UI:**搜索插件与诊断,通过现有 schema 表单 `configForms` 编辑非密钥标量配置,并预览受支持的重复注册修复。
12
+
13
+ 启停操作通过 Host 现有 Profile 管理器写入。更改可能即时生效、需要重启、被更高优先级配置覆盖,或被 Host 拒绝。修复预览有时效,并会在诊断项变化后失效。用户选择修复后,只有恰好存在一个可操作目标的低风险修复会自动执行;高风险修复先显示具体影响,再要求用户明确确认。当前修复动作是停用参与全局工具名或 MCP 名称冲突的所选插件。
14
+
15
+ 配置字段来自 Host 提供的 schema。编辑器隐藏密钥字段;配置来源只显示层名称和脱敏标识,不暴露值或文件系统路径。schema 校验和持久化由 Host 负责。
16
+
17
+ ## 要求与限制
18
+
19
+ 需要提供插件管理 Remote、设置表单和运行时清单的 Harness Host。较旧 Host 可能只能查看清单,或显示诊断不可用;升级 Harness 后才能执行管理操作。只有当前 Profile 可寻址的插件可以启停。此界面不安装或卸载包、不编辑凭据,也不运行任意修复命令。
20
+
21
+ ## 安装
22
+
23
+ 1. 让 Harness package resolver 能加载本包,例如使用本地检出版本或已发布包。
24
+ 2. 将 `@tinyforge/dsh-plugin-manager-wj` bundle 加入目标 Web profile。
25
+ 3. 打开 **设置 → 插件 → 插件管理**。
26
+
27
+ `dsh.client` 会加载浏览器客户端,`cordis.patch.yml` 会将 bundle 插入 Host。从 profile 移除该 bundle 即可移除管理标签页。Harness 核心注册表和管理服务不依赖此 UI bundle。
28
+
29
+ 本仓库不会自动发布包或配置 package registry。
30
+
31
+ ## 开发
32
+
33
+ 本包使用 ES module。`index.js` 是 Host 入口,`client.js` 是浏览器界面。本地化包元数据位于 `locale/`,界面完整词典在 `client.js` 中注册。运行 `node --test` 检查 bundle 行为,运行 `node --check client.js` 检查语法。Harness API 和 Host 行为在 `deepseek-harness` 仓库实现并测试。
34
+
35
+ ## 许可证
36
+
37
+ MIT。
package/client.js ADDED
@@ -0,0 +1,395 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-plugin-manager-wj',
3
+ factory(require) {
4
+ const React = require('react')
5
+ const h = React.createElement
6
+ const NS = 'settings.pluginManagerWj'
7
+
8
+ function unwrap(result, name) {
9
+ if (!result || result.ok !== true) throw new Error(`${name}: ${result?.error?.message ?? 'unavailable'}`)
10
+ return result.value
11
+ }
12
+
13
+ function atPath(value, path) {
14
+ return path.reduce((current, key) => current == null ? undefined : current[key], value)
15
+ }
16
+
17
+ function hasPath(value, path) {
18
+ if (path.length === 0) return value !== undefined
19
+ const parent = atPath(value, path.slice(0, -1))
20
+ return parent != null && Object.prototype.hasOwnProperty.call(parent, path[path.length - 1])
21
+ }
22
+
23
+ function isPathPrefix(prefix, path) {
24
+ return prefix.length <= path.length && prefix.every((part, index) => part === path[index])
25
+ }
26
+
27
+ function schemaFields(envelope) {
28
+ const refs = envelope?.refs
29
+ const root = refs?.[envelope?.uid]
30
+ if (!root || root.type !== 'object' || !root.dict) return []
31
+ const fields = []
32
+ const visit = (nodeId, path) => {
33
+ const node = refs?.[nodeId]
34
+ if (!node || node.meta?.role === 'secret') return
35
+ if (node.type === 'object' && node.dict) {
36
+ for (const [key, child] of Object.entries(node.dict)) visit(child, [...path, key])
37
+ return
38
+ }
39
+ const options = node.type === 'union'
40
+ ? (node.list ?? []).map(id => refs?.[id]).filter(item => item?.type === 'const').map(item => item.value)
41
+ : []
42
+ if (['string', 'number', 'boolean'].includes(node.type) || options.length > 0) {
43
+ fields.push({ path, node, options })
44
+ }
45
+ }
46
+ for (const [key, child] of Object.entries(root.dict)) visit(child, [key])
47
+ return fields
48
+ }
49
+
50
+ function sourceText(source, t) {
51
+ return source ? `${t(source.layer)} · ${source.identity}` : t('sourceUnknown')
52
+ }
53
+
54
+ const styles = {
55
+ page: { display: 'grid', gap: 20, maxWidth: 1080, color: 'CanvasText' },
56
+ header: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16, flexWrap: 'wrap' },
57
+ eyebrow: { margin: '0 0 5px', color: 'GrayText', fontSize: 12, fontWeight: 650, letterSpacing: '.07em', textTransform: 'uppercase' },
58
+ title: { margin: 0, fontSize: 23, lineHeight: 1.25, fontWeight: 680 },
59
+ description: { margin: '7px 0 0', color: 'GrayText', fontSize: 14, lineHeight: 1.55, maxWidth: 680 },
60
+ stats: { display: 'flex', gap: 8, flexWrap: 'wrap' },
61
+ stat: { display: 'grid', gap: 2, minWidth: 85, padding: '10px 13px', border: '1px solid color-mix(in srgb, CanvasText 12%, Canvas)', borderRadius: 11, background: 'ButtonFace' },
62
+ statValue: { fontSize: 18, fontWeight: 700, fontVariantNumeric: 'tabular-nums' },
63
+ statLabel: { fontSize: 11, color: 'GrayText' },
64
+ toolbar: { display: 'flex', gap: 10, alignItems: 'center', flexWrap: 'wrap', padding: 12, border: '1px solid color-mix(in srgb, CanvasText 12%, Canvas)', borderRadius: 13, background: 'ButtonFace' },
65
+ search: { flex: '1 1 240px', minWidth: 0, height: 38, padding: '0 12px', border: '1px solid color-mix(in srgb, CanvasText 17%, Canvas)', borderRadius: 9, background: 'Canvas', color: 'CanvasText', font: 'inherit' },
66
+ button: { minHeight: 36, padding: '7px 13px', border: '1px solid color-mix(in srgb, CanvasText 18%, Canvas)', borderRadius: 9, background: 'Canvas', color: 'CanvasText', font: 'inherit', fontWeight: 600, cursor: 'pointer' },
67
+ primary: { borderColor: 'color-mix(in srgb, Highlight 45%, Canvas)', background: 'Highlight', color: 'HighlightText' },
68
+ section: { overflow: 'hidden', border: '1px solid color-mix(in srgb, CanvasText 12%, Canvas)', borderRadius: 13, background: 'Canvas' },
69
+ sectionHead: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, padding: '13px 16px', borderBottom: '1px solid color-mix(in srgb, CanvasText 10%, Canvas)', background: 'ButtonFace' },
70
+ sectionTitle: { margin: 0, fontSize: 15, fontWeight: 670 },
71
+ count: { color: 'GrayText', fontSize: 12, fontVariantNumeric: 'tabular-nums' },
72
+ list: { margin: 0, padding: 0, listStyle: 'none' },
73
+ row: { display: 'grid', gap: 10, padding: '14px 16px', borderBottom: '1px solid color-mix(in srgb, CanvasText 9%, Canvas)' },
74
+ rowHead: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 14, flexWrap: 'wrap' },
75
+ rowTitle: { margin: 0, fontSize: 14, fontWeight: 650, overflowWrap: 'anywhere' },
76
+ meta: { display: 'flex', gap: '5px 14px', flexWrap: 'wrap', color: 'GrayText', fontSize: 12, lineHeight: 1.5 },
77
+ badge: { display: 'inline-flex', alignItems: 'center', minHeight: 22, padding: '1px 9px', border: '1px solid color-mix(in srgb, CanvasText 14%, Canvas)', borderRadius: 999, fontSize: 11, fontWeight: 600 },
78
+ warning: { borderColor: 'color-mix(in srgb, #d18a00 35%, Canvas)', background: 'color-mix(in srgb, #d18a00 9%, Canvas)' },
79
+ error: { borderColor: 'color-mix(in srgb, #c43d3d 35%, Canvas)', background: 'color-mix(in srgb, #c43d3d 9%, Canvas)' },
80
+ message: { margin: 0, padding: '16px', color: 'GrayText', fontSize: 13, lineHeight: 1.55 },
81
+ detail: { marginTop: 4, padding: '13px 14px', borderRadius: 10, background: 'color-mix(in srgb, CanvasText 4%, Canvas)' },
82
+ field: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 210px), 1fr))', alignItems: 'center', gap: 10, padding: '9px 0', borderBottom: '1px solid color-mix(in srgb, CanvasText 8%, Canvas)' },
83
+ input: { boxSizing: 'border-box', width: '100%', minWidth: 0, minHeight: 34, padding: '6px 9px', border: '1px solid color-mix(in srgb, CanvasText 16%, Canvas)', borderRadius: 8, background: 'Canvas', color: 'CanvasText', font: 'inherit' },
84
+ muted: { color: 'GrayText', fontSize: 11, lineHeight: 1.4 },
85
+ }
86
+
87
+ function FieldEditor({ field, view, form, provenance, t }) {
88
+ const pathKey = field.path.join('.')
89
+ const current = atPath(view.value, field.path)
90
+ const [draft, setDraft] = React.useState(current == null ? '' : String(current))
91
+ const [dirty, setDirty] = React.useState(false)
92
+ const [notice, setNotice] = React.useState('')
93
+ React.useEffect(() => {
94
+ if (!dirty) setDraft(current == null ? '' : String(current))
95
+ }, [view.revision, current, dirty])
96
+
97
+ const save = async () => {
98
+ let value = draft
99
+ if (field.node.type === 'boolean') value = draft === 'true'
100
+ if (field.node.type === 'number') {
101
+ value = Number(draft)
102
+ if (!draft.trim() || !Number.isFinite(value)) {
103
+ setNotice(t('invalidNumber'))
104
+ return
105
+ }
106
+ }
107
+ if (field.options.length) value = field.options.find(option => String(option) === draft) ?? draft
108
+ try {
109
+ const accepted = await form.mutate([{ op: 'set', path: field.path, value }], view.revision)
110
+ if (accepted) {
111
+ setDirty(false)
112
+ setNotice(t('saved'))
113
+ } else setNotice(t('revisionConflict'))
114
+ } catch (_error) { setNotice(t('saveFailed')) }
115
+ }
116
+ const reset = async () => {
117
+ try {
118
+ const accepted = await form.mutate([{ op: 'unset', path: field.path }], view.revision)
119
+ setNotice(accepted ? t('saved') : t('revisionConflict'))
120
+ if (accepted) setDirty(false)
121
+ } catch (_error) { setNotice(t('saveFailed')) }
122
+ }
123
+ let input
124
+ if (field.node.type === 'boolean') {
125
+ input = h('select', { value: draft, onChange: event => { setDraft(event.target.value); setDirty(true) }, style: styles.input, 'aria-label': pathKey },
126
+ h('option', { value: 'true' }, t('enabled')),
127
+ h('option', { value: 'false' }, t('disabled')))
128
+ } else if (field.options.length) {
129
+ input = h('select', { value: draft, onChange: event => { setDraft(event.target.value); setDirty(true) }, style: styles.input, 'aria-label': pathKey },
130
+ field.options.map(option => h('option', { key: String(option), value: String(option) }, String(option))))
131
+ } else {
132
+ input = h('input', {
133
+ type: field.node.type === 'number' ? 'number' : 'text', value: draft, style: styles.input,
134
+ 'aria-label': pathKey, onChange: event => { setDraft(event.target.value); setDirty(true) },
135
+ })
136
+ }
137
+ const overridden = hasPath(view.user, field.path)
138
+ return h('div', { key: pathKey, style: styles.field },
139
+ h('div', null,
140
+ h('div', { style: { fontSize: 12, fontWeight: 600, overflowWrap: 'anywhere' } }, pathKey),
141
+ h('div', { style: styles.muted }, `${t('source')}: ${sourceText(provenance?.effective, t)}`),
142
+ provenance?.shadowed?.length ? h('div', { style: styles.muted }, `${t('shadowed')}: ${provenance.shadowed.map(source => sourceText(source, t)).join(', ')}`) : null),
143
+ input,
144
+ h('div', { style: { display: 'flex', gap: 6, justifyContent: 'flex-end', flexWrap: 'wrap' } },
145
+ h('button', { type: 'button', style: styles.button, disabled: !dirty || !view.writable, onClick: () => { void save() } }, t('save')),
146
+ overridden ? h('button', { type: 'button', style: styles.button, disabled: !view.writable, onClick: () => { void reset() } }, t('reset')) : null,
147
+ notice ? h('span', { role: 'status', style: styles.muted }, notice) : null))
148
+ }
149
+
150
+ function ConfigSection({ view, forms, provenance, t }) {
151
+ const form = forms.get(view.ns)
152
+ const [version, setVersion] = React.useState(0)
153
+ React.useEffect(() => form.subscribe(() => setVersion(value => value + 1)), [form])
154
+ const state = form.getSnapshot()
155
+ const fields = schemaFields(view.schema).filter(field => !view.secrets?.some(secret =>
156
+ isPathPrefix(field.path, secret.path) || isPathPrefix(secret.path, field.path)))
157
+ return h('details', { style: styles.detail, key: view.ns, 'data-revision': version },
158
+ h('summary', { style: { cursor: 'pointer', fontWeight: 650, fontSize: 13 } }, view.ns),
159
+ state.status === 'loading' ? h('p', { style: styles.message }, t('loadingForm')) : null,
160
+ state.status === 'unavailable' ? h('p', { style: styles.message }, t('formUnavailable')) : null,
161
+ fields.length === 0 ? h('p', { style: styles.message }, t('noSchemaFields')) : null,
162
+ fields.map(field => h(FieldEditor, {
163
+ key: field.path.join('.'), field, view: { ...view, value: state.value ?? view.value, revision: state.revision ?? view.revision, writable: state.writable },
164
+ form, provenance: provenance?.get(view.ns)?.get(field.path.join('.')), t,
165
+ })),
166
+ view.secrets?.length ? h('p', { style: styles.muted }, t('secretsHidden', { count: String(view.secrets.length) })) : null)
167
+ }
168
+
169
+ function InventoryTab({ list, manager, forms, t }) {
170
+ const [state, setState] = React.useState({ kind: 'loading' })
171
+ const [query, setQuery] = React.useState('')
172
+ const [revision, setRevision] = React.useState(0)
173
+ const [busy, setBusy] = React.useState('')
174
+ const [notice, setNotice] = React.useState('')
175
+ const [preview, setPreview] = React.useState(null)
176
+
177
+ React.useEffect(() => {
178
+ let live = true
179
+ Promise.resolve().then(async () => {
180
+ const [inventoryResult, pluginResult, healthResult, settingsResult] = await Promise.allSettled([
181
+ list(), manager?.listPlugins ? manager.listPlugins() : Promise.reject(new Error('unavailable')),
182
+ manager?.getHealthSnapshot ? manager.getHealthSnapshot() : Promise.reject(new Error('unavailable')),
183
+ forms?.describe ? forms.describe().ensure().then(() => forms.describe().getSnapshot()) : Promise.reject(new Error('unavailable')),
184
+ ])
185
+ if (inventoryResult.status !== 'fulfilled') throw inventoryResult.reason
186
+ const inventory = inventoryResult.value
187
+ const plugins = pluginResult.status === 'fulfilled' ? unwrap(pluginResult.value, 'pluginManager.listPlugins') : []
188
+ const health = healthResult.status === 'fulfilled' ? unwrap(healthResult.value, 'pluginManager.getHealthSnapshot') : undefined
189
+ const settings = settingsResult.status === 'fulfilled' ? settingsResult.value.view : undefined
190
+ const provenance = new Map()
191
+ if (settings && manager?.getConfigProvenance) {
192
+ await Promise.all(settings.namespaces.map(async view => {
193
+ const hidden = new Set((view.secrets ?? []).map(secret => secret.path.join('.')))
194
+ const fields = schemaFields(view.schema).map(field => field.path).filter(path => !hidden.has(path.join('.')))
195
+ if (!fields.length) return
196
+ try {
197
+ const result = unwrap(await manager.getConfigProvenance(view.ns, fields), 'pluginManager.getConfigProvenance')
198
+ provenance.set(view.ns, new Map(result.map(item => [item.fieldPath.join('.'), item])))
199
+ } catch (_unavailable) {
200
+ provenance.set(view.ns, new Map())
201
+ }
202
+ }))
203
+ }
204
+ if (live) setState({ kind: 'ready', inventory, plugins, health, settings, provenance })
205
+ }).catch(() => {
206
+ if (live) setState(previous => ({
207
+ kind: 'error',
208
+ snapshot: previous.snapshot ?? (previous.kind === 'ready' ? previous : undefined),
209
+ }))
210
+ })
211
+ return () => { live = false }
212
+ }, [list, manager, forms, revision])
213
+
214
+ const refresh = () => {
215
+ setState(current => ({ kind: 'loading', snapshot: current.snapshot ?? current }))
216
+ setRevision(value => value + 1)
217
+ }
218
+ const current = state.snapshot ?? (state.kind === 'ready' ? state : undefined)
219
+ const inventory = current?.inventory
220
+ const plugins = current?.plugins ?? []
221
+ const health = current?.health
222
+ const settings = current?.settings
223
+ const needle = query.trim().toLocaleLowerCase()
224
+ const matches = values => !needle || values.filter(Boolean).some(value => String(value).toLocaleLowerCase().includes(needle))
225
+ const pluginRows = plugins.filter(row => matches([row.moduleName, row.entryId, row.meta?.title, row.meta?.description]))
226
+ const findings = (health?.findings ?? []).filter(row => matches([row.id, row.code, row.evidence?.name, row.evidence?.serverName, row.evidence?.packageName]))
227
+ const runtimeTools = (inventory?.toolRegistrations ?? []).filter(row => matches([row.name, row.owner?.moduleName, row.owner?.entryId]))
228
+ const runtimeClients = (inventory?.mcpClients ?? []).filter(row => matches([row.serverName, row.state, row.owner?.moduleName, ...(row.toolNames ?? [])]))
229
+
230
+ const toggle = async row => {
231
+ setBusy(row.entryId)
232
+ setNotice('')
233
+ try {
234
+ const result = unwrap(await manager.setPluginEnabled(row.entryId, !row.enabled), 'pluginManager.setPluginEnabled')
235
+ setNotice(result.application === 'applied' ? t('changeApplied') : result.application === 'restart-required' ? t('restartRequired') : result.application === 'overridden' ? t('changeOverridden') : t('changeFailed'))
236
+ refresh()
237
+ } catch (_error) {
238
+ setNotice(t('changeFailed'))
239
+ } finally {
240
+ setBusy('')
241
+ }
242
+ }
243
+
244
+ const makePreview = async (finding, targetEntryId) => {
245
+ setBusy(finding.id)
246
+ setPreview(null)
247
+ try {
248
+ const next = unwrap(await manager.previewRemediation({ findingId: finding.id, targetEntryId }), 'pluginManager.previewRemediation')
249
+ if (next.requiresConfirmation) setPreview(next)
250
+ else {
251
+ const result = unwrap(await manager.applyRemediation(next.previewId, false), 'pluginManager.applyRemediation')
252
+ setNotice(result.application === 'applied' ? t('changeApplied') : result.application === 'restart-required' ? t('restartRequired') : result.application === 'overridden' ? t('changeOverridden') : t('changeFailed'))
253
+ refresh()
254
+ }
255
+ } catch (_error) {
256
+ setNotice(t('previewOrRepairFailed'))
257
+ } finally {
258
+ setBusy('')
259
+ }
260
+ }
261
+
262
+ const applyPreview = async () => {
263
+ if (!preview) return
264
+ setBusy(preview.previewId)
265
+ try {
266
+ const result = unwrap(await manager.applyRemediation(preview.previewId, preview.requiresConfirmation), 'pluginManager.applyRemediation')
267
+ setNotice(result.application === 'applied' ? t('changeApplied') : result.application === 'restart-required' ? t('restartRequired') : result.application === 'overridden' ? t('changeOverridden') : t('changeFailed'))
268
+ setPreview(null)
269
+ refresh()
270
+ } catch (_error) {
271
+ setNotice(t('stalePreview'))
272
+ setPreview(null)
273
+ refresh()
274
+ } finally {
275
+ setBusy('')
276
+ }
277
+ }
278
+
279
+ const section = (id, title, items, render) => h('section', { key: id, style: styles.section, 'aria-labelledby': `${id}-heading` },
280
+ h('div', { style: styles.sectionHead },
281
+ h('h2', { id: `${id}-heading`, style: styles.sectionTitle }, title),
282
+ h('span', { style: styles.count }, `${items.length} ${t('items')}`)),
283
+ items.length ? h('ul', { style: styles.list }, items.map(render)) : h('p', { style: styles.message }, t(needle ? 'noMatches' : 'noRows')))
284
+
285
+ const owner = row => row.owner ? `${row.owner.moduleName} (${row.owner.entryId})` : '—'
286
+ const findingCard = finding => {
287
+ const severe = finding.severity === 'error'
288
+ const affected = finding.affectedEntryIds.map(id => plugins.find(plugin => plugin.entryId === id)?.moduleName ?? id).join(', ')
289
+ return h('li', { key: finding.id, style: styles.row },
290
+ h('div', { style: styles.rowHead },
291
+ h('div', null,
292
+ h('h3', { style: styles.rowTitle }, t(finding.code)),
293
+ h('div', { style: styles.meta }, h('span', null, `${t('severity')}: ${t(finding.severity)}`), affected ? h('span', null, `${t('affected')}: ${affected}`) : null)),
294
+ h('span', { style: { ...styles.badge, ...(severe ? styles.error : styles.warning) } }, t(finding.severity))),
295
+ finding.evidence?.name || finding.evidence?.serverName || finding.evidence?.packageName
296
+ ? h('div', { style: styles.meta }, `${t('evidence')}: ${finding.evidence.name ?? finding.evidence.serverName ?? finding.evidence.packageName}`)
297
+ : null,
298
+ finding.remediationEntryIds.map(id => {
299
+ const target = plugins.find(plugin => plugin.entryId === id)
300
+ if (!target) return null
301
+ return h('button', { key: id, type: 'button', style: styles.button, disabled: busy === finding.id, onClick: () => { void makePreview(finding, id) } }, t('previewRepair', { name: target.moduleName }))
302
+ }))
303
+ }
304
+
305
+ return h('div', { style: styles.page, 'aria-busy': state.kind === 'loading' },
306
+ h('header', { style: styles.header },
307
+ h('div', null,
308
+ h('p', { style: styles.eyebrow }, t('eyebrow')),
309
+ h('h1', { style: styles.title }, t('heading')),
310
+ h('p', { style: styles.description }, t('description'))),
311
+ health ? h('div', { style: styles.stats, 'aria-label': t('summary') },
312
+ [[health.pluginCount, 'plugins'], [health.enabledCount, 'enabled'], [health.findings.length, 'findings']].map(([value, label]) => h('div', { key: label, style: styles.stat }, h('span', { style: styles.statValue }, String(value)), h('span', { style: styles.statLabel }, t(label))))
313
+ ) : null),
314
+ h('div', { style: styles.toolbar },
315
+ h('input', { type: 'search', value: query, 'aria-label': t('search'), placeholder: t('search'), onChange: event => setQuery(event.target.value), style: styles.search }),
316
+ h('button', { type: 'button', onClick: refresh, style: styles.button, disabled: state.kind === 'loading' }, state.kind === 'loading' ? t('loadingShort') : t('refresh'))),
317
+ state.kind === 'loading' && !inventory ? h('p', { role: 'status', style: styles.message }, t('loading')) : null,
318
+ state.kind === 'error' ? h('div', { role: 'alert', style: styles.section }, h('p', { style: styles.message }, t('error')), h('button', { type: 'button', style: styles.button, onClick: refresh }, t('retry'))) : null,
319
+ notice ? h('p', { role: 'status', style: styles.message }, notice) : null,
320
+ !health ? h('p', { role: 'status', style: styles.message }, t('diagnosticsUnavailable')) : null,
321
+ preview ? h('section', { style: { ...styles.section, padding: 16 }, 'aria-label': t('repairPreview') },
322
+ h('h2', { style: styles.sectionTitle }, t('repairPreview')),
323
+ h('p', { style: styles.meta }, `${t('target')}: ${plugins.find(row => row.entryId === preview.targetEntryId)?.moduleName ?? preview.targetEntryId}`),
324
+ h('p', { style: styles.meta }, `${t('effect')}: ${t('disablePlugin')}`),
325
+ h('p', { style: styles.meta }, `${t('risk')}: ${t(preview.risk)} · ${t(preview.reversible ? 'reversible' : 'notReversible')}`),
326
+ h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
327
+ h('button', { type: 'button', style: { ...styles.button, ...styles.primary }, disabled: busy === preview.previewId, onClick: () => { void applyPreview() } }, t(preview.requiresConfirmation ? 'confirmRepair' : 'applyRepair')),
328
+ h('button', { type: 'button', style: styles.button, onClick: () => { setPreview(null) } }, t('cancel')))) : null,
329
+ section('findings', t('findingsTitle'), findings, findingCard),
330
+ section('plugins', t('pluginsTitle'), pluginRows, row => h('li', { key: row.entryId, style: styles.row },
331
+ h('div', { style: styles.rowHead },
332
+ h('div', null,
333
+ h('h3', { style: styles.rowTitle }, row.meta?.title?.en ?? row.meta?.title?.zh ?? row.moduleName),
334
+ h('div', { style: styles.meta }, h('span', null, row.entryId), h('span', null, t(row.fiberPhase ?? 'notRunning')), row.readOnlyReason ? h('span', null, t(row.readOnlyReason)) : null)),
335
+ h('button', {
336
+ type: 'button', style: { ...styles.button, ...(row.enabled ? styles.primary : {}) },
337
+ 'aria-pressed': String(row.enabled), disabled: !manager?.setPluginEnabled || row.readOnlyReason !== undefined || busy === row.entryId,
338
+ onClick: () => { void toggle(row) },
339
+ }, t(row.enabled ? 'disable' : 'enable'))),
340
+ row.diagnostic ? h('p', { style: styles.meta }, t('activationFailed')) : null)),
341
+ settings?.namespaces?.length ? section('configuration', t('configurationTitle'), settings.namespaces, view => h('li', { key: view.ns, style: styles.row },
342
+ h('div', { style: styles.rowTitle }, plugins.find(row => row.entryId === view.ns)?.meta?.title?.en ?? view.ns),
343
+ h(ConfigSection, { view, forms, provenance: current?.provenance, t }))) : null,
344
+ inventory ? h(React.Fragment, null,
345
+ section('tools', t('tools'), runtimeTools, row => h('li', { key: `${row.name}:${row.owner?.entryId ?? ''}`, style: styles.row },
346
+ h('h3', { style: styles.rowTitle }, row.name), h('div', { style: styles.meta }, `${t('owner')}: ${owner(row)} · ${t(row.scope)}`))),
347
+ section('mcp', t('mcp'), runtimeClients, row => h('li', { key: `${row.serverName}:${row.owner?.entryId ?? ''}`, style: styles.row },
348
+ h('h3', { style: styles.rowTitle }, row.serverName), h('div', { style: styles.meta }, `${t('owner')}: ${owner(row)} · ${t(row.state)}`),
349
+ row.toolNames?.length ? h('div', { style: styles.meta }, `${t('toolNames')}: ${row.toolNames.join(', ')}`) : null))) : null)
350
+ }
351
+
352
+ return {
353
+ inject: ['slots', 'locale', 'remote', 'remote.pluginInventory', 'remote.pluginManager', 'configForms'],
354
+ apply(ctx) {
355
+ const zh = {
356
+ tab: '插件管理', search: '搜索插件、诊断、工具或 MCP', refresh: '刷新', loading: '正在读取 Host 状态…', loadingShort: '读取中…',
357
+ eyebrow: '插件健康与管理', heading: '插件管理', description: '查看插件状态与冲突,追踪配置来源,并通过受控操作修复问题。', summary: '当前状态', items: '项',
358
+ error: '无法读取运行时清单。', retry: '重试', noRows: '暂无记录。', noMatches: '没有匹配的记录。', diagnosticsUnavailable: '此 Harness Host 尚未提供诊断接口;当前显示可用的插件和注册清单。',
359
+ findingsTitle: '健康诊断', pluginsTitle: '插件', configurationTitle: '配置管理', plugins: '插件', enabled: '已启用', findings: '发现项', severity: '严重程度', affected: '相关插件', evidence: '证据',
360
+ 'plugin.activation-failed': '插件启动失败', 'tool.duplicate-name': '工具名称重复', 'mcp.connection-failed': 'MCP 连接异常', 'mcp.duplicate-name': 'MCP 名称重复',
361
+ 'bundle.compatibility-rejected': '组合包版本不兼容', 'bundle.dependency-invalid': '所选依赖无效', error: '错误', errorSeverity: '错误', warning: '警告', info: '提示',
362
+ source: '配置来源', shadowed: '被覆盖来源', sourceUnknown: '未知(Host 未提供来源)', bundle: '组合包', profile: 'Profile', home: 'Home', invocation: '本次启动',
363
+ save: '保存', reset: '恢复继承值', saved: '已保存', revisionConflict: '配置已被其他操作修改;草稿仍保留,请刷新后重试。', saveFailed: '保存失败,草稿已保留。', invalidNumber: '请输入有效数字。', loadingForm: '正在载入表单…', formUnavailable: '此配置表单当前不可用。', noSchemaFields: '没有可编辑的 schema 字段。', secretsHidden: '密钥字段已隐藏({count} 项)。',
364
+ previewRepair: '诊断并修复 {name}', repairPreview: '修复预览', target: '目标', effect: '影响', disablePlugin: '关闭插件', risk: '风险', low: '低', high: '高', reversible: '可撤销', notReversible: '不可撤销', applyRepair: '执行修复', confirmRepair: '确认并执行', cancel: '取消', previewOrRepairFailed: '无法预览或执行此修复。', stalePreview: '修复预览已过期或状态已变化,请重新加载后再试。',
365
+ changeApplied: '设置已保存并应用。', restartRequired: '设置已保存;重启后生效。', changeOverridden: '设置已保存,但被更高优先级配置覆盖。', changeFailed: 'Host 未能应用此更改。',
366
+ enable: '启用', disable: '停用', enabledTag: '已启用', disabledTag: '已停用', active: '运行中', failed: '失败', loadingPhase: '加载中', pending: '等待中', unloading: '卸载中', notRunning: '未运行',
367
+ 'management-required': '管理服务受保护', unaddressable: '此条目无法通过当前 Profile 修改', activationFailed: '插件未能完成启动。', owner: '所属插件', tools: '工具注册', mcp: 'MCP 客户端', toolNames: '工具名称', global: '全局', scoped: '作用域', starting: '启动中', connected: '已连接', reconnecting: '正在重连', stopped: '已停止',
368
+ }
369
+ const en = {
370
+ tab: 'Plugin management', search: 'Search plugins, findings, tools or MCP', refresh: 'Refresh', loading: 'Reading Host state…', loadingShort: 'Loading…',
371
+ eyebrow: 'PLUGIN HEALTH AND MANAGEMENT', heading: 'Plugin management', description: 'Review plugin status and conflicts, trace configuration sources, and repair issues through bounded actions.', summary: 'Current status', items: 'items',
372
+ error: 'The runtime inventory could not be read.', retry: 'Retry', noRows: 'No records.', noMatches: 'No matching records.', diagnosticsUnavailable: 'This Harness Host does not expose diagnostics yet. Available plugin and registration inventories are still shown.',
373
+ findingsTitle: 'Health findings', pluginsTitle: 'Plugins', configurationTitle: 'Configuration', plugins: 'plugins', enabled: 'enabled', findings: 'findings', severity: 'Severity', affected: 'Affected plugins', evidence: 'Evidence',
374
+ 'plugin.activation-failed': 'Plugin activation failed', 'tool.duplicate-name': 'Duplicate tool name', 'mcp.connection-failed': 'MCP connection issue', 'mcp.duplicate-name': 'Duplicate MCP name',
375
+ 'bundle.compatibility-rejected': 'Bundle version is incompatible', 'bundle.dependency-invalid': 'Selected dependency is invalid', error: 'Error', errorSeverity: 'Error', warning: 'Warning', info: 'Info',
376
+ source: 'Configuration source', shadowed: 'Shadowed sources', sourceUnknown: 'Unknown (Host did not provide a source)', bundle: 'Bundle', profile: 'Profile', home: 'Home', invocation: 'This launch',
377
+ save: 'Save', reset: 'Reset to inherited value', saved: 'Saved', revisionConflict: 'Configuration changed elsewhere. Your draft is kept; refresh before retrying.', saveFailed: 'Save failed. Your draft is kept.', invalidNumber: 'Enter a valid number.', loadingForm: 'Loading form…', formUnavailable: 'This configuration form is unavailable.', noSchemaFields: 'No editable schema fields.', secretsHidden: '{count} secret fields are hidden.',
378
+ previewRepair: 'Diagnose and repair {name}', repairPreview: 'Repair preview', target: 'Target', effect: 'Effect', disablePlugin: 'Disable plugin', risk: 'Risk', low: 'Low', high: 'High', reversible: 'Reversible', notReversible: 'Not reversible', applyRepair: 'Apply repair', confirmRepair: 'Confirm and apply', cancel: 'Cancel', previewOrRepairFailed: 'Could not preview or apply this repair.', stalePreview: 'The preview expired or state changed. Reload and preview the repair again.',
379
+ changeApplied: 'The change was saved and applied.', restartRequired: 'The change was saved and will apply after restart.', changeOverridden: 'The change was saved but overridden by a higher-priority configuration.', changeFailed: 'The Host could not apply this change.',
380
+ enable: 'Enable', disable: 'Disable', enabledTag: 'Enabled', disabledTag: 'Disabled', active: 'Active', failed: 'Failed', loadingPhase: 'Loading', pending: 'Pending', unloading: 'Unloading', notRunning: 'Not running',
381
+ 'management-required': 'Management service is protected', unaddressable: 'This entry cannot be changed by the current profile', activationFailed: 'The plugin did not finish starting.', owner: 'Owner', tools: 'Tool registrations', mcp: 'MCP clients', toolNames: 'Tool names', global: 'Global', scoped: 'Scoped', starting: 'Starting', connected: 'Connected', reconnecting: 'Reconnecting', stopped: 'Stopped',
382
+ }
383
+ ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'plugin-manager-wj: dictionaries')
384
+ const t = ctx.locale.bind(NS)
385
+ const list = async () => unwrap(await ctx.remote.pluginInventory.list(), 'pluginInventory.list')
386
+ const manager = ctx.remote.pluginManager
387
+ const forms = ctx.get('configForms')
388
+ ctx.slots.inject('settings.plugins.tab', () => ctx.slots.register({
389
+ name: 'settings.plugins.tab', id: 'wj-registration-inventory', order: 20,
390
+ label: () => t('tab'), locale: NS, inject: () => ({ list, manager, forms }),
391
+ }, InventoryTab))
392
+ },
393
+ }
394
+ },
395
+ })
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: plugin-manager-wj
3
+ name: @tinyforge/dsh-plugin-manager-wj
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /** Host half: the inventory page runs in the Web Client. */
2
+ export function apply() {}
package/locale/en.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "meta": {
3
+ "title": "WJ Plugin Management"
4
+ },
5
+ "tab": "Plugin management",
6
+ "search": "Search plugins, findings, tools or MCP",
7
+ "refresh": "Refresh",
8
+ "loading": "Reading runtime registrations…",
9
+ "error": "The registration inventory could not be read.",
10
+ "retry": "Retry",
11
+ "empty": "There are no plugin, tool or MCP records yet.",
12
+ "unsupported": "This Harness Host does not provide plugin management and runtime inventory. Upgrade Harness to manage plugins.",
13
+ "tools": "Tool registrations",
14
+ "mcp": "MCP servers",
15
+ "owner": "Owning plugin",
16
+ "scope": "Scope",
17
+ "global": "Global",
18
+ "scoped": "Agent scope",
19
+ "conditional": "Conditional",
20
+ "unconditional": "Always registered",
21
+ "serverState": "Connection state",
22
+ "toolNames": "Tool names"
23
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "meta": {
3
+ "title": "WJ 插件管理"
4
+ },
5
+ "tab": "插件管理",
6
+ "search": "搜索插件、诊断、工具或 MCP",
7
+ "refresh": "刷新",
8
+ "loading": "正在读取运行时注册…",
9
+ "error": "无法读取注册清单。",
10
+ "retry": "重试",
11
+ "empty": "当前没有插件、工具或 MCP 记录。",
12
+ "unsupported": "当前 Harness Host 未提供插件管理和运行时清单,请升级 Harness 后管理插件。",
13
+ "tools": "工具注册",
14
+ "mcp": "MCP Server",
15
+ "owner": "所属插件",
16
+ "scope": "作用域",
17
+ "global": "全局",
18
+ "scoped": "Agent 作用域",
19
+ "conditional": "条件启用",
20
+ "unconditional": "始终注册",
21
+ "serverState": "连接状态",
22
+ "toolNames": "工具名"
23
+ }
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@tinyforge/dsh-plugin-manager-wj",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.2.2",
4
+ "description": "Three-layer plugin management, health diagnostics, configuration provenance, and tool/MCP inventory for DeepSeek Harness.",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "scripts": { "test": "node --test" },
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./client": "./client.js",
11
+ "./locale/*.json": "./locale/*.json"
12
+ },
13
+ "files": ["index.js", "client.js", "cordis.patch.yml", "locale/*.json", "README.md", "README.zh.md"],
14
+ "dsh": {
15
+ "bundle": { "patch": "./cordis.patch.yml" },
16
+ "client": {
17
+ "platform": "web",
18
+ "inject": [
19
+ "@deepseek-ai/dsh-api-remotes",
20
+ "@deepseek-ai/dsh-client-locale",
21
+ "@deepseek-ai/dsh-client-ui-settings",
22
+ "@deepseek-ai/dsh-client-ui-slots"
23
+ ]
24
+ }
25
+ },
26
+ "peerDependencies": { "@deepseek-ai/cordis": "*" },
27
+ "license": "MIT"
28
+ }