@tinyforge/dsh-plugin-manager-wj 1.5.0 → 1.6.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/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  - **Switchable views:** one tab strip switches between plugin health, configuration, the skill catalog, and tool registration ownership. A visited view stays mounted, so a configuration draft and the search term survive switching.
12
12
  - **Harness Core:** consumes the Host's plugin registry, configuration resolver, conflict detector, lifecycle/dependency manager, and settings services.
13
13
  - **Management API:** shows plugin state, derived activation findings, configuration provenance, and tool runtime registrations. It can enable or disable profile-addressable plugins.
14
- - **Management UI:** filters the active view, edits non-secret scalar settings through the existing schema-backed `configForms`, and reports each tool's scope with its owner (an MCP server, or the plugin package the Host half matched).
14
+ - **Management UI:** filters the active view, edits non-secret scalar settings through the existing schema-backed `configForms`, and reports each tool's scope with its owner (an MCP server, or the plugin package the Host half matched). Plugin rows show the package's localized title and introduction; a Loader-internal entry that carries no package metadata states that instead of leaving a blank line.
15
15
 
16
16
  ### Views
17
17
 
@@ -55,11 +55,11 @@ npm install @tinyforge/dsh-plugin-manager-wj
55
55
  ## Release
56
56
 
57
57
  ```sh
58
- npm test # node --test: 27 checks (views, tool ownership, Host route, inject contract, module id, patch shape)
58
+ npm test # node --test: 30 checks (views, tool ownership, Host route, inject contract, module id, patch shape)
59
59
  npm publish --access public # writes to registry.npmjs.org
60
60
  ```
61
61
 
62
- The package name is scoped, so publishing a new version needs maintainer access to the `@tinyforge` npm scope. Tag the published commit (`git tag v1.5.0 && git push --tags`) so the GitHub history matches the registry.
62
+ The package name is scoped, so publishing a new version needs maintainer access to the `@tinyforge` npm scope. Tag the published commit (`git tag v1.6.0 && git push --tags`) so the GitHub history matches the registry.
63
63
 
64
64
  ## Development
65
65
 
package/README.zh.md CHANGED
@@ -11,7 +11,7 @@
11
11
  - **可切换视图:**一条标签栏在插件健康、配置、Skill 目录与工具注册归属之间切换。已访问过的视图保持挂载,因此切换时配置草稿和搜索词都不会丢失。
12
12
  - **Harness Core:**使用 Host 提供的插件注册表、配置解析、冲突检测、生命周期与依赖管理,以及设置服务。
13
13
  - **Management API:**查看插件状态、激活诊断、配置来源和工具运行时注册;可启停当前 Profile 能寻址的插件。
14
- - **Management UI:**按视图过滤,通过现有 schema 表单 `configForms` 编辑非密钥标量配置;工具视图给出每个工具的作用域与归属(MCP 服务器或推断出的插件包)。
14
+ - **Management UI:**按视图过滤,通过现有 schema 表单 `configForms` 编辑非密钥标量配置;工具视图给出每个工具的作用域与归属(MCP 服务器或推断出的插件包)。插件行显示包本地化的标题与说明;Loader 内部条目若没有包元数据,会明确写出这一点,而不是留空。
15
15
 
16
16
  ### 视图
17
17
 
@@ -55,11 +55,11 @@ npm install @tinyforge/dsh-plugin-manager-wj
55
55
  ## 发布
56
56
 
57
57
  ```sh
58
- npm test # node --test:27 项检查(视图、工具归属、Host 路由、inject 契约、模块 id、patch 结构)
58
+ npm test # node --test:30 项检查(视图、工具归属、Host 路由、inject 契约、模块 id、patch 结构)
59
59
  npm publish --access public # 发布到 registry.npmjs.org
60
60
  ```
61
61
 
62
- 包名带 scope,发布新版本需要 `@tinyforge` npm scope 的维护者权限。发布后给对应提交打 tag(`git tag v1.5.0 && git push --tags`),让 GitHub 历史与 registry 版本对应。
62
+ 包名带 scope,发布新版本需要 `@tinyforge` npm scope 的维护者权限。发布后给对应提交打 tag(`git tag v1.6.0 && git push --tags`),让 GitHub 历史与 registry 版本对应。
63
63
 
64
64
  ## 开发
65
65
 
package/client.js CHANGED
@@ -16,6 +16,9 @@ window.__ModuleLoader__.load({
16
16
  // The Host half serves the tool registry on the shared authenticated `/api` channel; the
17
17
  // official Remote table carries no tool namespace, so this route is the only way in.
18
18
  const TOOL_INVENTORY_URL = '/api/wj/tool-inventory'
19
+ // The Host may answer slowly (its snapshot scans package sources), but a read that never settles
20
+ // must surface as a retryable failure instead of a spinner that never ends.
21
+ const TOOL_INVENTORY_TIMEOUT_MS = 20_000
19
22
 
20
23
  function unwrap(result, name) {
21
24
  if (!result || result.ok !== true) throw new Error(`${name}: ${result?.error?.message ?? 'unavailable'}`)
@@ -63,6 +66,20 @@ window.__ModuleLoader__.load({
63
66
  return source ? `${t(source.layer)} · ${source.identity}` : t('sourceUnknown')
64
67
  }
65
68
 
69
+ // `LocalizedText` is a plain string or a map keyed by lowercase locale id with an English
70
+ // fallback. The locale service resolves the current UI language; this reader keeps titles and
71
+ // descriptions readable where that service is absent, and never renders an object.
72
+ function localized(value) {
73
+ if (typeof value === 'string') return value
74
+ if (value !== null && typeof value === 'object') {
75
+ const english = value.en
76
+ if (typeof english === 'string') return english
77
+ const first = Object.values(value).find(entry => typeof entry === 'string')
78
+ return typeof first === 'string' ? first : undefined
79
+ }
80
+ return undefined
81
+ }
82
+
66
83
  // The official Host projects the Loader, not a health model: a failed fiber plus its diagnostic
67
84
  // is the whole of what it still reports, and it is exactly what this page diagnoses.
68
85
  function findingsOf(entries) {
@@ -137,6 +154,7 @@ window.__ModuleLoader__.load({
137
154
  row: { display: 'grid', gap: 10, padding: '14px 16px', borderBottom: '1px solid color-mix(in srgb, CanvasText 9%, Canvas)' },
138
155
  rowHead: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 14, flexWrap: 'wrap' },
139
156
  rowTitle: { margin: 0, fontSize: 14, fontWeight: 650, overflowWrap: 'anywhere' },
157
+ rowDescription: { margin: '3px 0 0', color: 'GrayText', fontSize: 12, lineHeight: 1.5, display: '-webkit-box', WebkitLineClamp: 3, WebkitBoxOrient: 'vertical', overflow: 'hidden' },
140
158
  meta: { display: 'flex', gap: '5px 14px', flexWrap: 'wrap', color: 'GrayText', fontSize: 12, lineHeight: 1.5 },
141
159
  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 },
142
160
  warning: { borderColor: 'color-mix(in srgb, #d18a00 35%, Canvas)', background: 'color-mix(in srgb, #d18a00 9%, Canvas)' },
@@ -266,8 +284,17 @@ window.__ModuleLoader__.load({
266
284
  }, h('span', null, item.label), item.count === undefined ? null : h('span', { style: styles.tabCount }, String(item.count)))))
267
285
  }
268
286
 
269
- function PluginsPanel({ pluginRows, findings, plugins, query, busy, canManage, onToggle, t }) {
270
- const name = row => row.meta?.title?.en ?? row.meta?.title?.zh ?? row.moduleName
287
+ function PluginsPanel({ pluginRows, findings, plugins, query, busy, canManage, onToggle, resolve, t }) {
288
+ // A row's display title and introduction are package metadata, not the module specifier.
289
+ // The Host localizes both; a Loader-internal entry that carries no package metadata says so
290
+ // instead of leaving the line empty, so a short technical name is never mistaken for a bug.
291
+ const name = row => resolve(row.meta?.title) || row.moduleName
292
+ const description = row => {
293
+ const declared = resolve(row.meta?.description)
294
+ if (declared) return declared
295
+ if (row.meta?.error) return resolve(row.meta.error) || row.meta.error
296
+ return row.meta === undefined ? t('pluginNoMeta') : t('pluginNoDescription')
297
+ }
271
298
  const severity = value => t(SEVERITY_KEY[value] ?? 'severityInfo')
272
299
  return h('div', { style: styles.page },
273
300
  h('p', { style: styles.description }, t('pluginsIntro')),
@@ -291,6 +318,7 @@ window.__ModuleLoader__.load({
291
318
  h('div', { style: styles.rowHead },
292
319
  h('div', null,
293
320
  h('h3', { style: styles.rowTitle }, name(row)),
321
+ h('p', { style: styles.rowDescription }, description(row)),
294
322
  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)),
295
323
  h('button', {
296
324
  type: 'button', style: { ...styles.button, ...(row.enabled ? styles.primary : {}) },
@@ -373,7 +401,7 @@ window.__ModuleLoader__.load({
373
401
  row.description ? h('p', { style: styles.muted }, row.description) : null))) : null))
374
402
  }
375
403
 
376
- function ManagerPage({ list, manager, forms, loadSkills, loadTools, readSessionId, watchSessions, t }) {
404
+ function ManagerPage({ list, manager, forms, loadSkills, loadTools, readSessionId, watchSessions, resolveText, t }) {
377
405
  const initialTab = readStoredTab()
378
406
  const [tab, setTab] = React.useState(initialTab)
379
407
  const [visited, setVisited] = React.useState([initialTab])
@@ -461,17 +489,29 @@ window.__ModuleLoader__.load({
461
489
 
462
490
  // The tool registry is session-wide Host state and the route scans package sources once, so
463
491
  // it loads when the view is first opened, and again only when the page is refreshed.
492
+ //
493
+ // The loaded revision is held in a ref rather than in this effect's dependencies. A dependency
494
+ // on `tools` re-ran this effect right after it set the loading state; React then disposed the
495
+ // first run, its cleanup flipped `live` off, and the read that finally arrived was dropped —
496
+ // the view stayed on "loading" forever in the browser (the deferred test runtime happened to
497
+ // resolve the read before the cleanup, which is why it never showed).
498
+ const loadedToolsRevision = React.useRef(undefined)
464
499
  React.useEffect(() => {
465
500
  if (tab !== 'tools' || typeof loadTools !== 'function') return undefined
466
- if (tools.kind !== 'idle' && tools.revision === revision) return undefined
501
+ if (loadedToolsRevision.current === revision) return undefined
467
502
  let live = true
468
503
  setTools({ kind: 'loading', revision })
469
504
  Promise.resolve()
470
505
  .then(() => loadTools())
471
- .then(result => { if (live) setTools({ ...result, revision }) })
506
+ .then(result => {
507
+ if (!live) return
508
+ // Only a completed read is worth remembering; a failed one retries when the view reopens.
509
+ if (result?.kind === 'ready') loadedToolsRevision.current = revision
510
+ setTools({ ...result, revision })
511
+ })
472
512
  .catch(() => { if (live) setTools({ kind: 'error', revision }) })
473
513
  return () => { live = false }
474
- }, [loadTools, tab, revision, tools.kind, tools.revision])
514
+ }, [loadTools, tab, revision])
475
515
 
476
516
  const refresh = () => {
477
517
  setState(current => ({ kind: 'loading', snapshot: current.snapshot }))
@@ -513,7 +553,17 @@ window.__ModuleLoader__.load({
513
553
  const settings = current?.settings
514
554
  const needle = query.trim().toLocaleLowerCase()
515
555
  const matches = values => !needle || values.filter(Boolean).some(value => String(value).toLocaleLowerCase().includes(needle))
516
- const pluginRows = plugins.filter(row => matches([row.moduleName, row.entryId, row.meta?.title?.en, row.meta?.title?.zh, row.meta?.description]))
556
+ // The locale service picks the current UI language for package titles and introductions;
557
+ // without it, `localized` keeps the declared English fallback.
558
+ const resolve = value => {
559
+ if (value === undefined || value === null) return undefined
560
+ let text
561
+ try { text = typeof resolveText === 'function' ? resolveText(value) : undefined } catch (_error) { text = undefined }
562
+ return typeof text === 'string' && text !== '' ? text : localized(value)
563
+ }
564
+ const pluginTitle = row => resolve(row.meta?.title) || row.moduleName
565
+ const pluginDescription = row => resolve(row.meta?.description) || row.meta?.error
566
+ const pluginRows = plugins.filter(row => matches([row.moduleName, row.entryId, pluginTitle(row), pluginDescription(row)]))
517
567
  const findings = (health?.findings ?? []).filter(row => matches([row.id, row.code, row.evidence?.name, row.evidence?.detail]))
518
568
  // Legacy Hosts answered the inventory with registrations of their own; a Host served by this
519
569
  // package answers the `/api` route instead, so either source fills the same rows.
@@ -569,7 +619,7 @@ window.__ModuleLoader__.load({
569
619
  notice ? h('p', { role: 'status', style: styles.message }, notice) : null,
570
620
  panel('plugins', h(PluginsPanel, {
571
621
  pluginRows, findings, plugins, query: needle, busy, canManage,
572
- onToggle: toggle, t,
622
+ onToggle: toggle, resolve, t,
573
623
  })),
574
624
  panel('config', h(ConfigPanel, { settings, settingsReady: settings !== undefined, plugins, forms, provenance: current?.provenance, t })),
575
625
  panel('skill', h(SkillPanel, { skills, needle, onRetry: refresh, t })),
@@ -588,6 +638,7 @@ window.__ModuleLoader__.load({
588
638
  eyebrow: '插件健康与管理', heading: '插件管理', description: '查看插件状态与冲突,追踪配置来源,浏览 Skill 目录与工具注册归属,并通过受控操作修复问题。', summary: '当前状态', items: '项',
589
639
  viewsLabel: '管理视图', 'tabs.plugins': '插件', 'tabs.config': '配置', 'tabs.skill': 'Skill', 'tabs.tools': '工具',
590
640
  pluginsIntro: '实时插件清单、健康诊断与启停操作。只列出当前 Profile 可寻址的插件。',
641
+ pluginNoDescription: '该包未声明说明。', pluginNoMeta: 'Loader 内部条目,无包元数据。',
591
642
  configIntro: '按 Host schema 编辑非密钥配置,并查看每个字段的有效来源与被覆盖层。',
592
643
  skillIntro: '当前会话可用的 Skill 目录,按会话工作目录解析,并随会话切换自动刷新;模型可调用与仅用户可调用的条目分开标记。',
593
644
  toolsIntro: '运行时工具注册清单,以及每个工具由哪个插件提供、作用于哪个范围。',
@@ -614,6 +665,7 @@ window.__ModuleLoader__.load({
614
665
  eyebrow: 'PLUGIN HEALTH AND MANAGEMENT', heading: 'Plugin management', description: 'Review plugin status and conflicts, trace configuration sources, browse the skill catalog and tool ownership, and repair issues through bounded actions.', summary: 'Current status', items: 'items',
615
666
  viewsLabel: 'Management views', 'tabs.plugins': 'Plugins', 'tabs.config': 'Configuration', 'tabs.skill': 'Skills', 'tabs.tools': 'Tools',
616
667
  pluginsIntro: 'Live plugin inventory, health findings and enable/disable actions. Only plugins addressable by the active profile are listed.',
668
+ pluginNoDescription: 'The package declares no description.', pluginNoMeta: 'Loader-internal entry; no package metadata.',
617
669
  configIntro: 'Edit non-secret settings through the Host schema and see each field’s effective source and shadowed layers.',
618
670
  skillIntro: 'Skills available to the current session, resolved from its working directory and reloaded automatically when the session changes; model-invocable and user-only entries are marked separately.',
619
671
  toolsIntro: 'Runtime tool registrations, with the plugin that provides each tool and the scope it applies to.',
@@ -654,11 +706,21 @@ window.__ModuleLoader__.load({
654
706
  // `ctx.remote` carries no tool namespace and a Client plugin cannot add one.
655
707
  const loadTools = async () => {
656
708
  if (typeof fetch !== 'function') return { kind: 'unavailable' }
709
+ const controller = typeof AbortController === 'function' ? new AbortController() : undefined
710
+ const timer = controller !== undefined && typeof setTimeout === 'function'
711
+ ? setTimeout(() => { try { controller.abort() } catch (_error) { /* already settled */ } }, TOOL_INVENTORY_TIMEOUT_MS)
712
+ : undefined
657
713
  let response
658
714
  try {
659
- response = await fetch(TOOL_INVENTORY_URL, { credentials: 'same-origin', headers: { accept: 'application/json' } })
715
+ response = await fetch(TOOL_INVENTORY_URL, {
716
+ credentials: 'same-origin',
717
+ headers: { accept: 'application/json' },
718
+ ...(controller === undefined ? {} : { signal: controller.signal }),
719
+ })
660
720
  } catch (_error) {
661
721
  return { kind: 'error' }
722
+ } finally {
723
+ if (timer !== undefined) clearTimeout(timer)
662
724
  }
663
725
  if (!response || response.ok !== true) return { kind: 'unavailable' }
664
726
  try {
@@ -716,12 +778,19 @@ window.__ModuleLoader__.load({
716
778
  }
717
779
  }
718
780
 
781
+ // Package titles and introductions are `LocalizedText`; the locale service resolves the
782
+ // current UI language, and the page falls back to the declared English text without it.
783
+ const localeService = ctx.locale ?? service('locale')
784
+ const resolveText = typeof localeService?.resolveText === 'function'
785
+ ? text => localeService.resolveText(text)
786
+ : undefined
787
+
719
788
  // No `mcpClientStatus/list` probe lives here: the MCP settings bundle owns MCP server state
720
789
  // and its page, and reading that remote from two pages is what made the two views conflict.
721
790
  ctx.slots.inject('plugins.tab', () => ctx.slots.register({
722
791
  name: 'plugins.tab', id: 'wj-registration-inventory', order: 20,
723
792
  label: () => t('tab'), locale: NS,
724
- inject: () => ({ list, manager: namespace('pluginManager'), forms, loadSkills, loadTools, readSessionId: activeSessionId, watchSessions }),
793
+ inject: () => ({ list, manager: namespace('pluginManager'), forms, loadSkills, loadTools, readSessionId: activeSessionId, watchSessions, resolveText }),
725
794
  }, ManagerPage))
726
795
  },
727
796
  }
package/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  * MCP tool names (their names carry the server) and falls back to a package-source scan, which is
14
14
  * marked `inferred` so the page never presents a guess as a Host fact.
15
15
  */
16
- import { readFileSync } from 'node:fs'
16
+ import { readFileSync, statSync } from 'node:fs'
17
17
  import { dirname, isAbsolute, join } from 'node:path'
18
18
 
19
19
  /** Absolute path below the shared `/api` channel. */
@@ -196,6 +196,7 @@ export function readPackageSources(ctx, options = {}) {
196
196
  const packages = optional(ctx, 'pluginPackages')
197
197
  const entries = typeof loader?.entries === 'function' ? loader.entries() : []
198
198
  const readFile = options.readFile ?? readFileSync
199
+ const statFile = options.statFile ?? statSync
199
200
  const maxFiles = options.maxFiles ?? FILE_BUDGET
200
201
  const maxBytes = options.maxBytes ?? TOTAL_LIMIT_BYTES
201
202
 
@@ -219,6 +220,10 @@ export function readPackageSources(ctx, options = {}) {
219
220
  const manifest = JSON.parse(readFile(manifestPath, 'utf8'))
220
221
  const main = typeof manifest?.main === 'string' && manifest.main.length > 0 ? manifest.main : 'index.js'
221
222
  const file = isAbsolute(main) ? main : join(dirname(manifestPath), main)
223
+ // A bundle above the limit is discarded after the read anyway; some plugin entry bundles are
224
+ // tens of megabytes, and reading one only to drop it blocks the Host for no result.
225
+ const size = statFile(file)?.size
226
+ if (typeof size === 'number' && size > FILE_LIMIT_BYTES) continue
222
227
  const text = readFile(file, 'utf8')
223
228
  if (typeof text !== 'string' || text.length === 0 || text.length > FILE_LIMIT_BYTES) continue
224
229
  files += 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinyforge/dsh-plugin-manager-wj",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Switchable plugin, configuration, skill and tool-ownership views with health diagnostics, configuration provenance, and tool inventory for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "index.js",