dsh-agent-control-center 0.4.1 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 — 2026-11-29
4
+
5
+ Closes the last gap in the v0.4 objective: the health module can now compare what
6
+ a profile declares with what the Loader is actually running.
7
+
8
+ ### Added
9
+
10
+ - **`health.drift()`** — declared-vs-running comparison built only from host
11
+ services: `pluginManager.listPlugins()` (enablement, fiber phase, startup
12
+ diagnostics), `configEditor.entries()` (which rows this profile's patch owns),
13
+ and `pluginManager.listBundles()` (bundles the profile asks for but the
14
+ installation cannot provide). Bundle inspection is opt-in (`includeBundles: true`)
15
+ because it walks every install location and costs seconds; the page turns it into
16
+ an explicit button.
17
+ * The patch file itself is never parsed: it may contain plugin secrets and the
18
+ read fence refuses it. The response states that instead of implying YAML was
19
+ read.
20
+ * `include:` entry-id prefixes are normalized before comparing with profile ids,
21
+ so a row is not reported as drift merely because the Loader and the patch name
22
+ it differently.
23
+ * Rows provided by a bundle or by the installation itself are counted
24
+ (`inProfileRows`) and explained in a note — they are normal, not drift.
25
+ * Drift kinds: `enabled-not-running`, `disabled-but-running`, `startup-failed`
26
+ (the only one that ranks `error`), `declared-not-installed`.
27
+ - **Health page drift block** with four tiles (plugin rows / addressable /
28
+ profile-owned / drift items), per-drift kind + detail + suggested action, a
29
+ bundle-check trigger, and the mandatory "the patch file is not parsed" note.
30
+ - `health.summary()` folds the drift counts in and ranks a failed plugin above
31
+ every warning.
32
+
33
+ ### Live findings on the acceptance profile
34
+
35
+ 225 plugin rows, 222 owned by the profile patch, 3 provided by bundles/installation;
36
+ with the bundle check enabled, two real drifts: `@deepseek-ai/dsh-subagent-claude-code`
37
+ and `@deepseek-ai/dsh-subagent-codex` are declared in the profile while the
38
+ installation reports `availability: missing`.
39
+
40
+ ### Tests
41
+
42
+ - 373 behaviour tests (365 → 373): eight for drift (clean profile, three drift
43
+ kinds, bundle accounting, `include:` normalization, missing services, throwing
44
+ manager). All green.
45
+
3
46
  ## 0.4.1 — 2026-11-29
4
47
 
5
48
  Compatibility release: DSH moved to `0.2.3-alpha.3` and renamed two host APIs the
package/README.md CHANGED
@@ -25,7 +25,7 @@ Screenshots live in `docs/assets/` and are excluded from the npm tarball.*
25
25
  ## Pages and status
26
26
 
27
27
  Runtime state comes from `GET /__agent-control-center/health`; the table records
28
- what the 0.4.1 acceptance run actually proved (details and evidence levels in
28
+ what the 0.5.0 acceptance run actually proved (details and evidence levels in
29
29
  [docs/05-ACCEPTANCE-EVIDENCE.md](docs/05-ACCEPTANCE-EVIDENCE.md)).
30
30
 
31
31
  | Page | What it gives you | State | Why / data source |
@@ -60,7 +60,7 @@ dsh plugin --profile web add dsh-agent-control-center
60
60
 
61
61
  # 2) from a packed tarball
62
62
  npm pack
63
- dsh plugin --profile web add ./dsh-agent-control-center-0.4.1.tgz
63
+ dsh plugin --profile web add ./dsh-agent-control-center-0.5.0.tgz
64
64
 
65
65
  # 3) from a local checkout
66
66
  dsh plugin --profile web add /absolute/path/to/dsh-agent-control-center
@@ -71,7 +71,7 @@ Then restart the Web GUI (the Host half mounts its HTTP route at boot) and open
71
71
 
72
72
  ```bash
73
73
  curl -s http://127.0.0.1:<gui-port>/__agent-control-center/health
74
- # → {"ok":true,"value":{"version":"0.4.1", …, "modules":[ … 12 entries … ]}}
74
+ # → {"ok":true,"value":{"version":"0.5.0", …, "modules":[ … 12 entries … ]}}
75
75
  ```
76
76
 
77
77
  Uninstall with `dsh plugin --profile web remove dsh-agent-control-center`.
@@ -230,7 +230,7 @@ version cannot land.
230
230
 
231
231
  | Item | Value |
232
232
  |---|---|
233
- | Plugin version | `0.4.1` |
233
+ | Plugin version | `0.5.0` |
234
234
  | DSH range | `>=0.2.1-rc.1 <0.3.0` (`engines.dsh` and `dsh.compatibility.dsh`) |
235
235
  | Verified against | DSH `0.2.2-rc.5` (web profile), Node `v24.22.2`, Linux x86_64 |
236
236
  | Node | `>=22.19` (CI: 22 and 24) |
package/README.zh.md CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## 页面与状态
19
19
 
20
- 运行期状态来自 `GET /__agent-control-center/health`;下表记录 0.4.1 验收实际证明了什么
20
+ 运行期状态来自 `GET /__agent-control-center/health`;下表记录 0.5.0 验收实际证明了什么
21
21
  (逐条证据与等级见 [docs/05-ACCEPTANCE-EVIDENCE.md](docs/05-ACCEPTANCE-EVIDENCE.md))。
22
22
 
23
23
  | 页面 | 提供什么 | 状态 | 依据 / 数据来源 |
@@ -49,7 +49,7 @@ dsh plugin --profile web add dsh-agent-control-center
49
49
 
50
50
  # 2) 从打包产物安装
51
51
  npm pack
52
- dsh plugin --profile web add ./dsh-agent-control-center-0.4.1.tgz
52
+ dsh plugin --profile web add ./dsh-agent-control-center-0.5.0.tgz
53
53
 
54
54
  # 3) 从本地 checkout 安装
55
55
  dsh plugin --profile web add /绝对路径/dsh-agent-control-center
@@ -60,7 +60,7 @@ dsh plugin --profile web add /绝对路径/dsh-agent-control-center
60
60
 
61
61
  ```bash
62
62
  curl -s http://127.0.0.1:<GUI端口>/__agent-control-center/health
63
- # → {"ok":true,"value":{"version":"0.4.1", …, "modules":[ … 12 项 … ]}}
63
+ # → {"ok":true,"value":{"version":"0.5.0", …, "modules":[ … 12 项 … ]}}
64
64
  ```
65
65
 
66
66
  卸载:`dsh plugin --profile web remove dsh-agent-control-center`。
@@ -174,7 +174,7 @@ node scripts/release.mjs patch|minor|major [--dry-run] [--notes "text"]
174
174
 
175
175
  | 项 | 值 |
176
176
  |---|---|
177
- | 插件版本 | `0.4.1` |
177
+ | 插件版本 | `0.5.0` |
178
178
  | 宿主区间 | `>=0.2.1-rc.1 <0.3.0`(`engines.dsh` 与 `dsh.compatibility.dsh`) |
179
179
  | 验证环境 | DSH `0.2.2-rc.5`(web profile)、Node `v24.22.2`、Linux x86_64 |
180
180
  | Node | `>=22.19`(CI:22 与 24) |
package/client.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // Generated by scripts/build-client.mjs from src/client/ — do not edit.
2
- // DSH client module: dsh-agent-control-center@0.4.1 (13 i18n fragments, 12 pages)
2
+ // DSH client module: dsh-agent-control-center@0.5.0 (13 i18n fragments, 12 pages)
3
3
  window.__ModuleLoader__.load({
4
4
  id: "dsh-agent-control-center",
5
5
  factory(require) {
6
6
  'use strict'
7
7
  const React = require('react')
8
8
  const h = React.createElement
9
- const ACC_VERSION = "0.4.1"
9
+ const ACC_VERSION = "0.5.0"
10
10
  /* ---- kernel.js ---- */
11
11
  /* ---------------------------------------------------------------------------
12
12
  * ACC kernel — shared runtime attached to every page script.
@@ -1789,6 +1789,34 @@ ACC.addI18n({
1789
1789
  'health.refresh.plugins': '刷新插件清单',
1790
1790
  'health.refresh.settings': '刷新设置命名空间',
1791
1791
  'health.refresh.sections': '刷新分区扫描结果',
1792
+ 'health.driftTitle': '声明与运行时(漂移)',
1793
+ 'health.driftSubtitle': 'profile 声明的插件行与 Loader 实际运行状态;不解析 patch 文件本身',
1794
+ 'health.driftTileRows': '插件行',
1795
+ 'health.driftTileMounted': 'profile 可寻址',
1796
+ 'health.driftTileInProfile': 'profile 管辖',
1797
+ 'health.driftTileCount': '漂移项',
1798
+ 'health.driftClean': '无漂移',
1799
+ 'health.driftFound': '有漂移',
1800
+ 'health.driftSelf': '本插件行',
1801
+ 'health.driftSelfEnabled': '启用',
1802
+ 'health.driftYes': '是',
1803
+ 'health.driftEmpty': '声明的插件行都在运行状态,未发现漂移。',
1804
+ 'health.driftCheckBundles': '检查 bundle 安装状态',
1805
+ 'health.driftCheckBundlesHint': '会读取每个安装位置,通常需要数秒',
1806
+ 'health.driftNotes': '说明',
1807
+ 'health.driftKindLabel': '类型',
1808
+ 'health.driftKindUnknown': '未知漂移类型',
1809
+ 'health.driftKind.startup-failed': '启动失败',
1810
+ 'health.driftKind.enabled-not-running': '已启用但未运行',
1811
+ 'health.driftKind.disabled-but-running': '已停用但仍在运行',
1812
+ 'health.driftKind.addressable-not-in-profile': '可寻址但不在 profile',
1813
+ 'health.driftKind.declared-not-installed': '声明未安装',
1814
+ 'health.driftAction.startup-failed': '修好该插件的配置或依赖,然后在 DSH 原生插件页重载',
1815
+ 'health.driftAction.enabled-not-running': '确认该模块是否加载失败(看 Diagnostics),必要时重载 profile',
1816
+ 'health.driftAction.disabled-but-running': '重载 profile 才会真正卸载该行',
1817
+ 'health.driftAction.addressable-not-in-profile': '确认该行来自哪一层 patch(bundle/内置/include)',
1818
+ 'health.driftAction.declared-not-installed': '重新安装该 bundle,或从 profile 移除该行',
1819
+ 'health.refresh.drift': '刷新漂移对比',
1792
1820
  'health.refresh.compat': '刷新兼容性结论',
1793
1821
  'health.refresh.host': '刷新宿主通道',
1794
1822
 
@@ -1915,6 +1943,34 @@ ACC.addI18n({
1915
1943
  'health.refresh.plugins': 'Refresh plugin inventory',
1916
1944
  'health.refresh.settings': 'Refresh settings namespaces',
1917
1945
  'health.refresh.sections': 'Refresh section scan',
1946
+ 'health.driftTitle': 'Declared vs running (drift)',
1947
+ 'health.driftSubtitle': 'Plugin rows the profile declares against what the Loader actually runs; the patch file itself is not parsed',
1948
+ 'health.driftTileRows': 'Plugin rows',
1949
+ 'health.driftTileMounted': 'Addressable',
1950
+ 'health.driftTileInProfile': 'Profile-owned',
1951
+ 'health.driftTileCount': 'Drift items',
1952
+ 'health.driftClean': 'No drift',
1953
+ 'health.driftFound': 'Drift found',
1954
+ 'health.driftSelf': 'This plugin row',
1955
+ 'health.driftSelfEnabled': 'Enabled',
1956
+ 'health.driftYes': 'yes',
1957
+ 'health.driftEmpty': 'Every declared plugin row matches its running state.',
1958
+ 'health.driftCheckBundles': 'Check bundle installation',
1959
+ 'health.driftCheckBundlesHint': 'Reads every install location; usually takes seconds',
1960
+ 'health.driftNotes': 'Notes',
1961
+ 'health.driftKindLabel': 'Kind',
1962
+ 'health.driftKindUnknown': 'Unknown drift kind',
1963
+ 'health.driftKind.startup-failed': 'Startup failed',
1964
+ 'health.driftKind.enabled-not-running': 'Enabled but not running',
1965
+ 'health.driftKind.disabled-but-running': 'Disabled but still running',
1966
+ 'health.driftKind.addressable-not-in-profile': 'Addressable outside the profile',
1967
+ 'health.driftKind.declared-not-installed': 'Declared but not installed',
1968
+ 'health.driftAction.startup-failed': 'Fix that plugin configuration or dependency, then reload it from the native plugin page',
1969
+ 'health.driftAction.enabled-not-running': 'Check whether the module failed to load (Diagnostics) and reload the profile',
1970
+ 'health.driftAction.disabled-but-running': 'Reloading the profile is what actually unloads this row',
1971
+ 'health.driftAction.addressable-not-in-profile': 'Check which patch layer provides this row (bundle, built-in, include)',
1972
+ 'health.driftAction.declared-not-installed': 'Reinstall that bundle or remove the row from the profile',
1973
+ 'health.refresh.drift': 'Refresh drift comparison',
1918
1974
  'health.refresh.compat': 'Refresh compatibility verdict',
1919
1975
  'health.refresh.host': 'Refresh host channel',
1920
1976
 
@@ -6511,6 +6567,7 @@ ACC.l10n = (function createL10n() {
6511
6567
  const STACK_STYLE = { display: 'flex', flexDirection: 'column', gap: '8px' }
6512
6568
  const COLUMN_STYLE = { display: 'flex', flexDirection: 'column', gap: '2px' }
6513
6569
  const SMALL_STYLE = { fontSize: '11px' }
6570
+ const FLEX_WRAP_STYLE = { display: 'flex', flexWrap: 'wrap', gap: '8px' }
6514
6571
  const BREAK_STYLE = { wordBreak: 'break-word' }
6515
6572
  const EMPTY_VALUE = '—'
6516
6573
 
@@ -6519,6 +6576,9 @@ ACC.l10n = (function createL10n() {
6519
6576
  /** Anomaly kind → shared tone; `unaddressable` rows are usable, only uneditable. */
6520
6577
  const ANOMALY_TONE = { 'duplicate-module': 'warn', unaddressable: 'warn' }
6521
6578
  /** Summary section id → navigation copy. */
6579
+
6580
+ /** Drift kinds carry their own tone: a startup failure is red, the rest amber. */
6581
+ const DRIFT_TONE = { 'startup-failed': 'danger', 'enabled-not-running': 'warn', 'disabled-but-running': 'warn', 'addressable-not-in-profile': 'warn', 'declared-not-installed': 'warn' }
6522
6582
  const BLOCK_KEYS = {
6523
6583
  plugins: 'health.block.plugins',
6524
6584
  settings: 'health.block.settings',
@@ -6584,6 +6644,26 @@ ACC.l10n = (function createL10n() {
6584
6644
  return t('health.anomalyActionGeneric')
6585
6645
  }
6586
6646
 
6647
+ /** @param {string} kind @param {Function} t @returns {string} */
6648
+ function driftKindLabel(kind, t) {
6649
+ if (kind === 'startup-failed') return t('health.driftKind.startup-failed')
6650
+ if (kind === 'enabled-not-running') return t('health.driftKind.enabled-not-running')
6651
+ if (kind === 'disabled-but-running') return t('health.driftKind.disabled-but-running')
6652
+ if (kind === 'addressable-not-in-profile') return t('health.driftKind.addressable-not-in-profile')
6653
+ if (kind === 'declared-not-installed') return t('health.driftKind.declared-not-installed')
6654
+ return t('health.driftKindUnknown')
6655
+ }
6656
+
6657
+ /** @param {string} kind @param {Function} t @returns {string} */
6658
+ function driftAction(kind, t) {
6659
+ if (kind === 'startup-failed') return t('health.driftAction.startup-failed')
6660
+ if (kind === 'enabled-not-running') return t('health.driftAction.enabled-not-running')
6661
+ if (kind === 'disabled-but-running') return t('health.driftAction.disabled-but-running')
6662
+ if (kind === 'addressable-not-in-profile') return t('health.driftAction.addressable-not-in-profile')
6663
+ if (kind === 'declared-not-installed') return t('health.driftAction.declared-not-installed')
6664
+ return t('health.anomalyActionGeneric')
6665
+ }
6666
+
6587
6667
  /** @param {string} kind @param {Function} t @returns {string} */
6588
6668
  function conflictKindLabel(kind, t) {
6589
6669
  return kind === 'duplicate-id' ? t('health.conflictKind.duplicate-id') : t('health.conflictKindUnknown')
@@ -6844,6 +6924,128 @@ ACC.l10n = (function createL10n() {
6844
6924
  )
6845
6925
  }
6846
6926
 
6927
+ /** @param {{ t: Function, drift: any }} props */
6928
+ function DriftNotice(props) {
6929
+ const t = props.t
6930
+ const drift = isRecord(props.drift) ? props.drift : {}
6931
+ const kind = textOf(drift.kind)
6932
+ return h(
6933
+ C.Notice,
6934
+ { tone: DRIFT_TONE[kind] || 'warn' },
6935
+ h(
6936
+ 'div',
6937
+ { style: { ...COLUMN_STYLE, gap: '3px' } },
6938
+ h('span', null, h('strong', null, `${t('health.driftKindLabel')}: ${driftKindLabel(kind, t)}${kind.length > 0 ? ` · ${kind}` : ''}`)),
6939
+ textOf(drift.detail).length > 0 ? h('div', { style: BREAK_STYLE }, textOf(drift.detail)) : null,
6940
+ h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.anomalySuggestion')}: ${driftAction(kind, t)}`),
6941
+ ),
6942
+ )
6943
+ }
6944
+
6945
+ /** @param {{ t: Function, data: any, onDeep?: Function, loading?: boolean }} props */
6946
+ function DriftBody(props) {
6947
+ const t = props.t
6948
+ const data = isRecord(props.data) ? props.data : {}
6949
+ const drifts = Array.isArray(data.drifts) ? data.drifts : []
6950
+ const notes = Array.isArray(data.notes) ? data.notes : []
6951
+ const rows = typeof data.rows === 'number' ? data.rows : (Array.isArray(data.rows) ? data.rows.length : null)
6952
+ const mounted = typeof data.mountedRows === 'number' ? data.mountedRows : null
6953
+ const inProfile = typeof data.inProfileRows === 'number' ? data.inProfileRows : null
6954
+ const self = isRecord(data.self) ? data.self : null
6955
+ const source = textOf(data.source)
6956
+ return h(
6957
+ 'div',
6958
+ { style: STACK_STYLE },
6959
+ h(
6960
+ 'div',
6961
+ { className: 'acc-row', style: FLEX_WRAP_STYLE },
6962
+ h(StatusTile, { label: t('health.driftTileRows'), value: countText(rows) }),
6963
+ h(StatusTile, { label: t('health.driftTileMounted'), value: countText(mounted) }),
6964
+ h(StatusTile, { label: t('health.driftTileInProfile'), value: countText(inProfile) }),
6965
+ h(StatusTile, {
6966
+ label: t('health.driftTileCount'),
6967
+ value: countText(drifts.length),
6968
+ hint: drifts.length === 0 ? h(C.Badge, { tone: 'success' }, t('health.driftClean')) : h(C.Badge, { tone: 'warn' }, t('health.driftFound')),
6969
+ }),
6970
+ ),
6971
+ self === null
6972
+ ? null
6973
+ : h(
6974
+ 'div',
6975
+ { className: 'acc-muted', style: SMALL_STYLE },
6976
+ `${t('health.driftSelf')}: ${textOf(self.entryId) || EMPTY_VALUE} · ${t('health.driftSelfEnabled')} ${self.enabled === true ? t('health.yes') : self.enabled === false ? t('health.no') : EMPTY_VALUE} · ${textOf(self.fiberPhase) || EMPTY_VALUE}`,
6977
+ ),
6978
+ h(
6979
+ 'div',
6980
+ { className: 'acc-row' },
6981
+ h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.source')}:`),
6982
+ h(C.Mono, { text: source.length > 0 ? source : EMPTY_VALUE }),
6983
+ ),
6984
+ drifts.length === 0
6985
+ ? h(C.Notice, { tone: 'success' }, t('health.driftEmpty'))
6986
+ : h(
6987
+ 'div',
6988
+ { style: STACK_STYLE },
6989
+ drifts.map((drift, index) => h(DriftNotice, { key: `drift-${index}`, t, drift })),
6990
+ ),
6991
+ props.onDeep === undefined || data.bundlesChecked === true
6992
+ ? null
6993
+ : h(
6994
+ 'div',
6995
+ { className: 'acc-row', style: { justifyContent: 'flex-start' } },
6996
+ h(
6997
+ C.Btn,
6998
+ { tone: 'ghost', onClick: props.onDeep, disabled: props.loading === true, title: t('health.driftCheckBundlesHint') },
6999
+ props.loading === true ? t('health.refreshing') : t('health.driftCheckBundles'),
7000
+ ),
7001
+ h('span', { className: 'acc-muted', style: SMALL_STYLE }, t('health.driftCheckBundlesHint')),
7002
+ ),
7003
+ notes.length === 0
7004
+ ? null
7005
+ : h(
7006
+ 'div',
7007
+ { style: STACK_STYLE },
7008
+ h('div', { className: 'acc-section-title' }, t('health.driftNotes')),
7009
+ notes.map((note, index) =>
7010
+ h('div', { key: `note-${index}`, className: 'acc-muted', style: { ...SMALL_STYLE, ...BREAK_STYLE } }, String(note)),
7011
+ ),
7012
+ ),
7013
+ h(NoteLine, { t, text: data.note }),
7014
+ )
7015
+ }
7016
+
7017
+ /** @param {{ t: Function, gate: any, onGateRefresh: Function }} props */
7018
+ function DriftCard(props) {
7019
+ const t = props.t
7020
+ const gate = isRecord(props.gate) ? props.gate : {}
7021
+ const blocked = gate.available === false
7022
+ // Bundle inspection reads every install location and costs seconds, so it
7023
+ // is a deliberate extra step, not part of the first read.
7024
+ const [deep, setDeep] = ACC.useState(false)
7025
+ const state = ACC.useAsync(
7026
+ blocked
7027
+ ? gatedLoader(gate)
7028
+ : (context) => ACC.api('health.drift', deep ? { includeBundles: true } : {}, context),
7029
+ [deep],
7030
+ )
7031
+ return h(
7032
+ BlockCard,
7033
+ {
7034
+ t,
7035
+ title: t('health.driftTitle'),
7036
+ subtitle: t('health.driftSubtitle'),
7037
+ loading: state.status === 'loading',
7038
+ onRefresh: blocked ? props.onGateRefresh : state.reload,
7039
+ refreshLabel: t('health.refresh.drift'),
7040
+ },
7041
+ h(BlockContent, {
7042
+ t,
7043
+ state,
7044
+ render: (data) => h(DriftBody, { t, data, onDeep: () => setDeep(true), loading: state.status === 'loading' }),
7045
+ }),
7046
+ )
7047
+ }
7048
+
6847
7049
  /** @param {{ t: Function, anomaly: any }} props */
6848
7050
  function AnomalyNotice(props) {
6849
7051
  const t = props.t
@@ -7305,6 +7507,7 @@ ACC.l10n = (function createL10n() {
7305
7507
  h(PluginsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
7306
7508
  h(SettingsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
7307
7509
  h(SectionsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
7510
+ h(DriftCard, { t, gate: gateView, onGateRefresh: gate.reload }),
7308
7511
  h(CompatCard, { t, gate: gateView, onGateRefresh: gate.reload }),
7309
7512
  )
7310
7513
  }
@@ -39,7 +39,7 @@ dsh-agent-control-center/
39
39
  | HTTP 前缀 | `/__agent-control-center`(GET `/health`,POST `/api`) |
40
40
  | 自有存储 | `$DSH_HOME/dsh-agent-control-center/` |
41
41
  | locale 命名空间 | `acc` |
42
- | 版本 | `0.4.1` |
42
+ | 版本 | `0.5.0` |
43
43
  | 兼容声明 | `dsh.compatibility.dsh = ">=0.2.1-rc.1 <0.3.0"`,`engines.dsh` 同区间 |
44
44
 
45
45
  `package.json` 关键字段(照抄,勿改语义):
@@ -363,3 +363,32 @@ curl -s http://127.0.0.1:38080/__agent-control-center/health
363
363
 
364
364
  - **Tools 首屏仍 5.5 s(冷)**:历史折叠默认扫 25 个会话、5 s 时间预算;热读 11 ms。下一步计划把历史统计拆成首屏后加载(页面先出注册表,历史徽标随后填充),而不是降低默认扫描上限。
365
365
  - `tools.schemas()` 在 0.2.3 不再公开,因此 `schemaProjection` 诊断项在新宿主上恒为 `available:false`(已标注原因,不影响工具清单与 schema 详情)。
366
+
367
+ ---
368
+
369
+ # 附:0.5.0 验收补充(2026-11-29,宿主 0.2.3-alpha.3)
370
+
371
+ 0.5.0 补齐 v0.4 目标的最后一项:**声明与运行时的漂移对比**。
372
+
373
+ ## 测试
374
+
375
+ - `node --test tests/*.test.mjs` → **373 / 373 pass**(0.4.1 为 365)。
376
+ - 新增 8 个 `health.drift` 用例:干净 profile、三种漂移类型、bundle 记账、
377
+ `include:` 前缀归一、服务缺失降级、manager 抛错兜底。
378
+ - 说明:整套测试在极端 CPU 争用下(同时构建客户端 + 跑浏览器)曾出现 1–2 个
379
+ 瞬时失败,随后连续 3 次全量重跑(每次约 2.8–3.0 s)均 373/373 通过。
380
+
381
+ ## 真机(隔离 profile `accverify`)
382
+
383
+ | 项 | 结果 |
384
+ |---|---|
385
+ | `health.drift`(默认,不查 bundle) | 225 行 / 222 行受 profile 管辖 / 3 行由 bundle 或安装自带 / 0 漂移;`self: {entryId:'include:agent-control-center', profileId:'agent-control-center', inProfile:true, enabled:true, fiberPhase:'active'}` |
386
+ | `health.drift({includeBundles:true})` | 6.6 s,新增 **2 条真实漂移**:`@deepseek-ai/dsh-subagent-claude-code`、`@deepseek-ai/dsh-subagent-codex` 在 profile 中声明但 `availability:'missing'` |
387
+ | `health.summary` | `drift:{rows:225, mounted:222, count:2}`;`worst:{severity:'warn',id:'plugins'}`;`compat:full` |
388
+
389
+ ## 未验证 / 已知限制
390
+
391
+ - 漂移对比**不解析 `cordis.patch.yml`**:该文件可能含插件密钥,围栏按设计拒绝。因此
392
+ 「声明」一侧来自 `pluginManager` 与 `configEditor` 的投影,无法覆盖「patch 里写了但
393
+ Loader 从未见过」的行(两类服务都看不到它们)。
394
+ - bundle 检查单次 6.6 s,因此默认关闭;页面用按钮显式触发。
package/docs/07-GUIDE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 用户指南:从「我想做什么」出发
2
2
 
3
- > 适用版本 **0.4.1**,目标宿主 DSH **0.2.2-rc.5**(兼容区间 `>=0.2.1-rc.1 <0.3.0`)。
3
+ > 适用版本 **0.5.0**,目标宿主 DSH **0.2.2-rc.5**(兼容区间 `>=0.2.1-rc.1 <0.3.0`)。
4
4
  > 本文按**任务**组织,只描述本插件在真实界面上能做什么、失败时看到什么、提示是什么意思。
5
5
  > 安装、权限边界、配置字段和刻意限制见 [README.zh.md](../README.zh.md);
6
6
  > 内部实现(模块、请求流、存储、扩展点)见 [09-ARCHITECTURE.md](09-ARCHITECTURE.md);
@@ -42,7 +42,7 @@ DSH Web GUI (browser)
42
42
 
43
43
  ### 2.1 入口 `index.js`
44
44
 
45
- - 导出:`name`、`VERSION`(`0.4.1`,与 `package.json` 同步)、`HTTP_PREFIX`(`/__agent-control-center`)、`inject = []`、`apply(ctx, rawConfig)`。
45
+ - 导出:`name`、`VERSION`(`0.5.0`,与 `package.json` 同步)、`HTTP_PREFIX`(`/__agent-control-center`)、`inject = []`、`apply(ctx, rawConfig)`。
46
46
  - `inject = []` 是硬约束:**任何宿主服务缺失都不阻止插件激活**,只让对应模块降级为 PARTIAL/BLOCKED。
47
47
  - 启动序列(`apply`):
48
48
  1. `normalizeConfig(rawConfig)`:未知字段/类型错误/越界 → **加载期直接抛错**(fail loud,不做静默兜底);
@@ -24,13 +24,30 @@
24
24
 
25
25
  **局限必须记住**:静态扫描只覆盖构建产物里的字面量,运行时动态生成 id 的插件会漏检;本插件自己的 bundle 若以 `link:` 安装在 `$DSH_HOME` 之外(被路径围栏拒绝读取),则改用插件内常量 `agent-control-center` 补一行并标 `scanned:false`。
26
26
 
27
+ ## 声明 vs 运行时(漂移)
28
+
29
+ `health.drift()` 比较 **profile 声明的插件行** 与 **Loader 实际运行状态**,证据来自两个宿主服务:
30
+
31
+ | 证据 | 服务 | 能证明什么 |
32
+ |---|---|---|
33
+ | 每行是否启用、运行时相位、启动错误 | `pluginManager.listPlugins()` | 声明为启用却不在 `active`、声明停用却仍在跑、启动失败 |
34
+ | 哪些行能被 profile patch 寻址 | `configEditor.entries()` | 行是否受本 profile 的 patch 管辖(`include:` 前缀会被归一) |
35
+ | 声明了但装不上的 bundle | `pluginManager.listBundles()` | `availability:'missing'` 的 bundle |
36
+
37
+ **不解析 `cordis.patch.yml`**:该文件可能含插件密钥,路径围栏按设计拒绝读取。因此「声明」一侧取自上面两个服务的投影,响应里的 `note` 明说这一点,不会假装读到了 YAML。
38
+
39
+ 漂移类型:`enabled-not-running`、`disabled-but-running`、`startup-failed`(唯一映射到 `error` 级)、`declared-not-installed`。bundle 检查需要显式 `includeBundles:true`(读取每个安装位置要数秒,页面把它做成一个按钮)。
40
+
41
+ 真机(0.2.3-alpha.3,2026-11-29):225 行 / 222 行受 profile 管辖 / 3 行由 bundle 或安装自带提供;开启 bundle 检查后发现 **2 条真实漂移**:`@deepseek-ai/dsh-subagent-claude-code` 与 `@deepseek-ai/dsh-subagent-codex` 声明在 profile 里但安装目录中不存在(`availability=missing`)。
42
+
27
43
  ## API
28
44
 
29
45
  - `health.plugins()` → `{available, source:'pluginManager', items:[{entryId,moduleName,patchId,readOnlyReason}], anomalies:[{kind,detail}]}`
30
46
  - `health.settings()` → `{available, namespaces:[{ns,revision,autoGenerate,hasValue,secretKeys}], own:{ns:'acc',declared,enabled}, redactionVerified, note}`
31
47
  - `health.sections()` → `{available, method:'static-scan', scanned:{packages,files}, sections:[{id,owner,file}], conflicts:[{kind,id,owners,suggestion}], own, note}`
32
48
  - `health.compat()` → `{available, level, version, readOnly, reasons, source}`
33
- - `health.summary()` → `{generatedAt, plugins:{total,anomalies}, settings:{...}, sections:{count,conflicts}, compat:{level,readOnly}, worst:{severity,id}}`
49
+ - `health.drift()` → `{available, rows:[{entryId,moduleName,enabled,fiberPhase,addressable,inProfile}], mountedRows, inProfileRows, bundlesChecked, self, drifts:[{kind,id,detail,suggestion}], notes, note}`
50
+ - `health.summary()` → `{generatedAt, plugins:{total,anomalies}, settings:{...}, sections:{count,conflicts}, drift:{rows,mounted,count}, compat:{level,readOnly}, worst:{severity,id}}`
34
51
 
35
52
  ## 真机观察(accverify,2026-11-29,12 模块)
36
53
 
package/index.js CHANGED
@@ -15,7 +15,7 @@ import { createRegistry } from './lib/core/registry.js'
15
15
 
16
16
  export const name = 'dsh-agent-control-center'
17
17
  /** Plugin version, mirrored in package.json. */
18
- export const VERSION = '0.4.1'
18
+ export const VERSION = '0.5.0'
19
19
  /** Browser transport prefix. The client fetches it document-relative. */
20
20
  export const HTTP_PREFIX = '/__agent-control-center'
21
21
 
@@ -764,6 +764,14 @@ export default function createModule(core) {
764
764
  return Array.isArray(value.conflicts) && value.conflicts.length > 0 ? 'warn' : 'ok'
765
765
  }
766
766
 
767
+ /** @param {Record<string, any>} value @returns {'ok' | 'warn' | 'error'} */
768
+ function driftSeverity(value) {
769
+ if (value.available !== true) return 'warn'
770
+ const drifts = Array.isArray(value.drifts) ? value.drifts : []
771
+ if (drifts.some((drift) => drift.kind === 'startup-failed')) return 'error'
772
+ return drifts.length > 0 ? 'warn' : 'ok'
773
+ }
774
+
767
775
  /** @param {Record<string, any>} value @returns {'ok' | 'warn' | 'error'} */
768
776
  function compatSeverity(value) {
769
777
  if (value.available !== true) return 'error'
@@ -791,13 +799,178 @@ export default function createModule(core) {
791
799
  return worst
792
800
  }
793
801
 
802
+ /**
803
+ * Compare what the profile declares with what the Loader is running. Two
804
+ * host services carry that evidence: `pluginManager` knows each row's
805
+ * effective enablement and fiber phase, `configEditor` knows which rows are
806
+ * addressable through the profile patch. Reading the patch file itself is
807
+ * refused by the path fence, so this answer never claims to have parsed it.
808
+ *
809
+ * @param {Record<string, unknown>} params
810
+ * @returns {Promise<Record<string, unknown>>}
811
+ */
812
+ async function driftMethod(params) {
813
+ assertParams(params)
814
+ // `listBundles()` walks every install location and costs seconds on a large
815
+ // profile, so the bundle half is opt-in and the page asks for it on demand.
816
+ const includeBundles = util.boolParam(isPlainObject(params) ? params : {}, 'includeBundles', false)
817
+ const manager = service('pluginManager')
818
+ const editor = service('configEditor')
819
+ const notes = []
820
+ /** @type {Array<{ entryId: string, moduleName: string, enabled: boolean | null, fiberPhase: string | null, addressable: boolean, inProfile: boolean | null }>} */
821
+ /** @type {Map<string, string>} entryId → the id a profile patch would use */
822
+ const profileIdsOf = new Map()
823
+ const rows = []
824
+ /** @type {Array<{ kind: string, id: string, detail: string, suggestion: string }>} */
825
+ const drifts = []
826
+
827
+ if (manager === undefined || manager === null || typeof manager.listPlugins !== 'function') {
828
+ notes.push('宿主未提供 pluginManager.listPlugins:无法比较声明与运行时')
829
+ } else {
830
+ let listed
831
+ try {
832
+ listed = await manager.listPlugins()
833
+ } catch (error) {
834
+ notes.push(`pluginManager.listPlugins 失败:${util.redact(errorMessage(error), 120)}`)
835
+ listed = null
836
+ }
837
+ if (Array.isArray(listed)) {
838
+ for (const row of listed.slice(0, MAX_PLUGIN_ITEMS)) {
839
+ if (!isPlainObject(row)) continue
840
+ const entryId = util.redact(typeof row.entryId === 'string' ? row.entryId : '', 160)
841
+ const moduleName = util.redact(typeof row.moduleName === 'string' ? row.moduleName : '', 160)
842
+ const enabled = typeof row.enabled === 'boolean' ? row.enabled : null
843
+ const fiberPhase = typeof row.fiberPhase === 'string' ? row.fiberPhase : null
844
+ const addressable = typeof row.patchId === 'string' && row.patchId.length > 0
845
+ // Loader entry ids carry an `include:` prefix; profile patch ids do not.
846
+ const profileId = entryId.startsWith('include:') ? entryId.slice('include:'.length) : entryId
847
+ rows.push({ entryId, moduleName, enabled, fiberPhase, addressable, inProfile: null })
848
+ profileIdsOf.set(entryId, profileId)
849
+ const diagnostic = typeof row.diagnostic === 'string' && row.diagnostic.length > 0
850
+ ? util.redact(row.diagnostic, 300)
851
+ : null
852
+ if (diagnostic !== null && drifts.length < MAX_ANOMALIES) {
853
+ drifts.push({
854
+ kind: 'startup-failed',
855
+ id: entryId || moduleName,
856
+ detail: `插件行 ${moduleName || entryId} 启动失败:${diagnostic}`,
857
+ suggestion: '修好该插件的配置或依赖后重载 profile;本页只读,不会替你重启或改写行',
858
+ })
859
+ }
860
+ if (enabled === true && fiberPhase !== null && fiberPhase !== 'active' && drifts.length < MAX_ANOMALIES) {
861
+ drifts.push({
862
+ kind: 'enabled-not-running',
863
+ id: entryId || moduleName,
864
+ detail: `插件行 ${moduleName || entryId} 声明为启用但运行时相位是 ${fiberPhase}`,
865
+ suggestion: '确认该模块是否加载失败(见 diagnostics 行),必要时在 DSH 原生插件页重载',
866
+ })
867
+ }
868
+ if (enabled === false && fiberPhase === 'active' && drifts.length < MAX_ANOMALIES) {
869
+ drifts.push({
870
+ kind: 'disabled-but-running',
871
+ id: entryId || moduleName,
872
+ detail: `插件行 ${moduleName || entryId} 声明为停用但运行时仍在 active`,
873
+ suggestion: '该行多半是在本次会话启动后才被停用;重载 profile 才会真正卸载',
874
+ })
875
+ }
876
+ }
877
+ } else if (listed !== null) {
878
+ notes.push('pluginManager.listPlugins 的返回值不是数组')
879
+ }
880
+ }
881
+
882
+ /** @type {Set<string>} */
883
+ const mountedIds = new Set()
884
+ if (editor === undefined || editor === null || typeof editor.entries !== 'function') {
885
+ notes.push('宿主未提供 configEditor.entries:无法确认哪些行能通过 profile patch 寻址')
886
+ } else {
887
+ try {
888
+ const entries = editor.entries()
889
+ for (const entry of (Array.isArray(entries) ? entries : []).slice(0, MAX_PLUGIN_ITEMS)) {
890
+ const id = isPlainObject(entry) && isPlainObject(entry.options) && typeof entry.options.id === 'string'
891
+ ? entry.options.id
892
+ : null
893
+ if (id !== null) mountedIds.add(util.redact(id, 160))
894
+ }
895
+ } catch (error) {
896
+ notes.push(`configEditor.entries 失败:${util.redact(errorMessage(error), 120)}`)
897
+ }
898
+ }
899
+
900
+ /**
901
+ * Rows provided by a bundle or by the installation itself are addressable
902
+ * through the plugin manager but not owned by this profile's patch. That is
903
+ * normal, not drift: it is reported as a count so nobody reads the rows
904
+ * list as "profile rows".
905
+ */
906
+ if (mountedIds.size > 0 && rows.length > 0) {
907
+ let inProfile = 0
908
+ for (const row of rows) {
909
+ const profileId = profileIdsOf.get(row.entryId) ?? row.entryId
910
+ const owned = mountedIds.has(profileId)
911
+ row.inProfile = owned
912
+ if (owned) inProfile += 1
913
+ }
914
+ const outside = rows.length - inProfile
915
+ if (outside > 0) {
916
+ notes.push(`${outside} 行由 bundle 或安装自带的 patch 提供,不受本 profile 的 patch 管辖;调整它们要用 DSH 原生插件页`)
917
+ }
918
+ }
919
+
920
+ // A bundle the profile asks for but the installation cannot provide.
921
+ if (includeBundles !== true) {
922
+ notes.push('未检查 bundle 安装状态:`includeBundles: true` 会读取每个安装位置,通常需要数秒')
923
+ } else if (manager !== undefined && manager !== null && typeof manager.listBundles === 'function') {
924
+ try {
925
+ const bundles = await manager.listBundles()
926
+ for (const bundle of (Array.isArray(bundles) ? bundles : []).slice(0, MAX_PLUGIN_ITEMS)) {
927
+ if (!isPlainObject(bundle) || bundle.availability !== 'missing') continue
928
+ if (drifts.length >= MAX_ANOMALIES) break
929
+ const name = util.redact(typeof bundle.name === 'string' ? bundle.name : '', 160)
930
+ drifts.push({
931
+ kind: 'declared-not-installed',
932
+ id: name,
933
+ detail: `profile 声明了 bundle ${name},但安装目录里找不到它(availability=missing)`,
934
+ suggestion: '重新安装该 bundle,或从 profile 里移除这一行',
935
+ })
936
+ }
937
+ } catch (error) {
938
+ notes.push(`pluginManager.listBundles 失败:${util.redact(errorMessage(error), 120)}`)
939
+ }
940
+ }
941
+
942
+ const self = rows.find((row) => row.moduleName === 'dsh-agent-control-center')
943
+ return {
944
+ available: rows.length > 0 || mountedIds.size > 0,
945
+ source: 'pluginManager.listPlugins + pluginManager.listBundles + configEditor.entries',
946
+ rows,
947
+ mountedRows: mountedIds.size,
948
+ inProfileRows: rows.filter((row) => row.inProfile === true).length,
949
+ bundlesChecked: includeBundles === true,
950
+ self: self === undefined
951
+ ? null
952
+ : {
953
+ entryId: self.entryId,
954
+ profileId: profileIdsOf.get(self.entryId) ?? self.entryId,
955
+ enabled: self.enabled,
956
+ fiberPhase: self.fiberPhase,
957
+ addressable: self.addressable,
958
+ inProfile: self.inProfile,
959
+ },
960
+ drifts,
961
+ notes,
962
+ note: '只读比较:不解析 profile patch 文件(该文件可能含插件密钥,路径围栏按设计拒绝读取),因此「声明」一侧取自 pluginManager 的清单与寻址结果,本页不声称读到了 YAML 内容。',
963
+ }
964
+ }
965
+
794
966
  /** @returns {Promise<Record<string, unknown>>} */
795
967
  async function summaryMethod(params) {
796
968
  assertParams(params)
797
- const [plugins, settings, sections, compat] = await Promise.all([
969
+ const [plugins, settings, sections, drift, compat] = await Promise.all([
798
970
  safeProbe(() => pluginsMethod()),
799
971
  safeProbe(() => settingsMethod()),
800
972
  safeProbe(() => sectionsMethod()),
973
+ safeProbe(() => driftMethod()),
801
974
  safeProbe(() => compatMethod()),
802
975
  ])
803
976
  const own = ownRow()
@@ -805,6 +978,7 @@ export default function createModule(core) {
805
978
  { id: 'plugins', severity: pluginsSeverity(plugins) },
806
979
  { id: 'settings', severity: settingsSeverity(settings) },
807
980
  { id: 'sections', severity: sectionsSeverity(sections) },
981
+ { id: 'drift', severity: driftSeverity(drift) },
808
982
  { id: 'compat', severity: compatSeverity(compat) },
809
983
  ])
810
984
  return {
@@ -822,6 +996,11 @@ export default function createModule(core) {
822
996
  count: sections.available === true && Array.isArray(sections.sections) ? sections.sections.length : null,
823
997
  conflicts: sections.available === true && Array.isArray(sections.conflicts) ? sections.conflicts.length : null,
824
998
  },
999
+ drift: {
1000
+ rows: Array.isArray(drift.rows) ? drift.rows.length : null,
1001
+ mounted: typeof drift.mountedRows === 'number' ? drift.mountedRows : null,
1002
+ count: Array.isArray(drift.drifts) ? drift.drifts.length : null,
1003
+ },
825
1004
  compat: {
826
1005
  level: compat.available === true && typeof compat.level === 'string' ? compat.level : null,
827
1006
  readOnly: compat.available === true ? compat.readOnly === true : null,
@@ -853,6 +1032,8 @@ export default function createModule(core) {
853
1032
  'health.settings': (params) => settingsMethod(params),
854
1033
  /** Static scan of client bundles for literal `settings.section` registrations. */
855
1034
  'health.sections': (params) => sectionsMethod(params),
1035
+ /** Declared-vs-running comparison across pluginManager and configEditor. */
1036
+ 'health.drift': (params) => driftMethod(params),
856
1037
  /** Compatibility verdict, preferring `core.compatibility.current()`. */
857
1038
  'health.compat': (params) => compatMethod(params),
858
1039
  /** One concurrent aggregate over the four probes, plus the worst section. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-control-center",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "DSH Agent Control Center: AGENTS.md editing with backups, tool inventory, sessions, real token usage, agent metadata, diagnostics and templates in one settings page.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,6 +57,34 @@ ACC.addI18n({
57
57
  'health.refresh.plugins': '刷新插件清单',
58
58
  'health.refresh.settings': '刷新设置命名空间',
59
59
  'health.refresh.sections': '刷新分区扫描结果',
60
+ 'health.driftTitle': '声明与运行时(漂移)',
61
+ 'health.driftSubtitle': 'profile 声明的插件行与 Loader 实际运行状态;不解析 patch 文件本身',
62
+ 'health.driftTileRows': '插件行',
63
+ 'health.driftTileMounted': 'profile 可寻址',
64
+ 'health.driftTileInProfile': 'profile 管辖',
65
+ 'health.driftTileCount': '漂移项',
66
+ 'health.driftClean': '无漂移',
67
+ 'health.driftFound': '有漂移',
68
+ 'health.driftSelf': '本插件行',
69
+ 'health.driftSelfEnabled': '启用',
70
+ 'health.driftYes': '是',
71
+ 'health.driftEmpty': '声明的插件行都在运行状态,未发现漂移。',
72
+ 'health.driftCheckBundles': '检查 bundle 安装状态',
73
+ 'health.driftCheckBundlesHint': '会读取每个安装位置,通常需要数秒',
74
+ 'health.driftNotes': '说明',
75
+ 'health.driftKindLabel': '类型',
76
+ 'health.driftKindUnknown': '未知漂移类型',
77
+ 'health.driftKind.startup-failed': '启动失败',
78
+ 'health.driftKind.enabled-not-running': '已启用但未运行',
79
+ 'health.driftKind.disabled-but-running': '已停用但仍在运行',
80
+ 'health.driftKind.addressable-not-in-profile': '可寻址但不在 profile',
81
+ 'health.driftKind.declared-not-installed': '声明未安装',
82
+ 'health.driftAction.startup-failed': '修好该插件的配置或依赖,然后在 DSH 原生插件页重载',
83
+ 'health.driftAction.enabled-not-running': '确认该模块是否加载失败(看 Diagnostics),必要时重载 profile',
84
+ 'health.driftAction.disabled-but-running': '重载 profile 才会真正卸载该行',
85
+ 'health.driftAction.addressable-not-in-profile': '确认该行来自哪一层 patch(bundle/内置/include)',
86
+ 'health.driftAction.declared-not-installed': '重新安装该 bundle,或从 profile 移除该行',
87
+ 'health.refresh.drift': '刷新漂移对比',
60
88
  'health.refresh.compat': '刷新兼容性结论',
61
89
  'health.refresh.host': '刷新宿主通道',
62
90
 
@@ -183,6 +211,34 @@ ACC.addI18n({
183
211
  'health.refresh.plugins': 'Refresh plugin inventory',
184
212
  'health.refresh.settings': 'Refresh settings namespaces',
185
213
  'health.refresh.sections': 'Refresh section scan',
214
+ 'health.driftTitle': 'Declared vs running (drift)',
215
+ 'health.driftSubtitle': 'Plugin rows the profile declares against what the Loader actually runs; the patch file itself is not parsed',
216
+ 'health.driftTileRows': 'Plugin rows',
217
+ 'health.driftTileMounted': 'Addressable',
218
+ 'health.driftTileInProfile': 'Profile-owned',
219
+ 'health.driftTileCount': 'Drift items',
220
+ 'health.driftClean': 'No drift',
221
+ 'health.driftFound': 'Drift found',
222
+ 'health.driftSelf': 'This plugin row',
223
+ 'health.driftSelfEnabled': 'Enabled',
224
+ 'health.driftYes': 'yes',
225
+ 'health.driftEmpty': 'Every declared plugin row matches its running state.',
226
+ 'health.driftCheckBundles': 'Check bundle installation',
227
+ 'health.driftCheckBundlesHint': 'Reads every install location; usually takes seconds',
228
+ 'health.driftNotes': 'Notes',
229
+ 'health.driftKindLabel': 'Kind',
230
+ 'health.driftKindUnknown': 'Unknown drift kind',
231
+ 'health.driftKind.startup-failed': 'Startup failed',
232
+ 'health.driftKind.enabled-not-running': 'Enabled but not running',
233
+ 'health.driftKind.disabled-but-running': 'Disabled but still running',
234
+ 'health.driftKind.addressable-not-in-profile': 'Addressable outside the profile',
235
+ 'health.driftKind.declared-not-installed': 'Declared but not installed',
236
+ 'health.driftAction.startup-failed': 'Fix that plugin configuration or dependency, then reload it from the native plugin page',
237
+ 'health.driftAction.enabled-not-running': 'Check whether the module failed to load (Diagnostics) and reload the profile',
238
+ 'health.driftAction.disabled-but-running': 'Reloading the profile is what actually unloads this row',
239
+ 'health.driftAction.addressable-not-in-profile': 'Check which patch layer provides this row (bundle, built-in, include)',
240
+ 'health.driftAction.declared-not-installed': 'Reinstall that bundle or remove the row from the profile',
241
+ 'health.refresh.drift': 'Refresh drift comparison',
186
242
  'health.refresh.compat': 'Refresh compatibility verdict',
187
243
  'health.refresh.host': 'Refresh host channel',
188
244
 
@@ -22,6 +22,7 @@
22
22
  const STACK_STYLE = { display: 'flex', flexDirection: 'column', gap: '8px' }
23
23
  const COLUMN_STYLE = { display: 'flex', flexDirection: 'column', gap: '2px' }
24
24
  const SMALL_STYLE = { fontSize: '11px' }
25
+ const FLEX_WRAP_STYLE = { display: 'flex', flexWrap: 'wrap', gap: '8px' }
25
26
  const BREAK_STYLE = { wordBreak: 'break-word' }
26
27
  const EMPTY_VALUE = '—'
27
28
 
@@ -30,6 +31,9 @@
30
31
  /** Anomaly kind → shared tone; `unaddressable` rows are usable, only uneditable. */
31
32
  const ANOMALY_TONE = { 'duplicate-module': 'warn', unaddressable: 'warn' }
32
33
  /** Summary section id → navigation copy. */
34
+
35
+ /** Drift kinds carry their own tone: a startup failure is red, the rest amber. */
36
+ const DRIFT_TONE = { 'startup-failed': 'danger', 'enabled-not-running': 'warn', 'disabled-but-running': 'warn', 'addressable-not-in-profile': 'warn', 'declared-not-installed': 'warn' }
33
37
  const BLOCK_KEYS = {
34
38
  plugins: 'health.block.plugins',
35
39
  settings: 'health.block.settings',
@@ -95,6 +99,26 @@
95
99
  return t('health.anomalyActionGeneric')
96
100
  }
97
101
 
102
+ /** @param {string} kind @param {Function} t @returns {string} */
103
+ function driftKindLabel(kind, t) {
104
+ if (kind === 'startup-failed') return t('health.driftKind.startup-failed')
105
+ if (kind === 'enabled-not-running') return t('health.driftKind.enabled-not-running')
106
+ if (kind === 'disabled-but-running') return t('health.driftKind.disabled-but-running')
107
+ if (kind === 'addressable-not-in-profile') return t('health.driftKind.addressable-not-in-profile')
108
+ if (kind === 'declared-not-installed') return t('health.driftKind.declared-not-installed')
109
+ return t('health.driftKindUnknown')
110
+ }
111
+
112
+ /** @param {string} kind @param {Function} t @returns {string} */
113
+ function driftAction(kind, t) {
114
+ if (kind === 'startup-failed') return t('health.driftAction.startup-failed')
115
+ if (kind === 'enabled-not-running') return t('health.driftAction.enabled-not-running')
116
+ if (kind === 'disabled-but-running') return t('health.driftAction.disabled-but-running')
117
+ if (kind === 'addressable-not-in-profile') return t('health.driftAction.addressable-not-in-profile')
118
+ if (kind === 'declared-not-installed') return t('health.driftAction.declared-not-installed')
119
+ return t('health.anomalyActionGeneric')
120
+ }
121
+
98
122
  /** @param {string} kind @param {Function} t @returns {string} */
99
123
  function conflictKindLabel(kind, t) {
100
124
  return kind === 'duplicate-id' ? t('health.conflictKind.duplicate-id') : t('health.conflictKindUnknown')
@@ -355,6 +379,128 @@
355
379
  )
356
380
  }
357
381
 
382
+ /** @param {{ t: Function, drift: any }} props */
383
+ function DriftNotice(props) {
384
+ const t = props.t
385
+ const drift = isRecord(props.drift) ? props.drift : {}
386
+ const kind = textOf(drift.kind)
387
+ return h(
388
+ C.Notice,
389
+ { tone: DRIFT_TONE[kind] || 'warn' },
390
+ h(
391
+ 'div',
392
+ { style: { ...COLUMN_STYLE, gap: '3px' } },
393
+ h('span', null, h('strong', null, `${t('health.driftKindLabel')}: ${driftKindLabel(kind, t)}${kind.length > 0 ? ` · ${kind}` : ''}`)),
394
+ textOf(drift.detail).length > 0 ? h('div', { style: BREAK_STYLE }, textOf(drift.detail)) : null,
395
+ h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.anomalySuggestion')}: ${driftAction(kind, t)}`),
396
+ ),
397
+ )
398
+ }
399
+
400
+ /** @param {{ t: Function, data: any, onDeep?: Function, loading?: boolean }} props */
401
+ function DriftBody(props) {
402
+ const t = props.t
403
+ const data = isRecord(props.data) ? props.data : {}
404
+ const drifts = Array.isArray(data.drifts) ? data.drifts : []
405
+ const notes = Array.isArray(data.notes) ? data.notes : []
406
+ const rows = typeof data.rows === 'number' ? data.rows : (Array.isArray(data.rows) ? data.rows.length : null)
407
+ const mounted = typeof data.mountedRows === 'number' ? data.mountedRows : null
408
+ const inProfile = typeof data.inProfileRows === 'number' ? data.inProfileRows : null
409
+ const self = isRecord(data.self) ? data.self : null
410
+ const source = textOf(data.source)
411
+ return h(
412
+ 'div',
413
+ { style: STACK_STYLE },
414
+ h(
415
+ 'div',
416
+ { className: 'acc-row', style: FLEX_WRAP_STYLE },
417
+ h(StatusTile, { label: t('health.driftTileRows'), value: countText(rows) }),
418
+ h(StatusTile, { label: t('health.driftTileMounted'), value: countText(mounted) }),
419
+ h(StatusTile, { label: t('health.driftTileInProfile'), value: countText(inProfile) }),
420
+ h(StatusTile, {
421
+ label: t('health.driftTileCount'),
422
+ value: countText(drifts.length),
423
+ hint: drifts.length === 0 ? h(C.Badge, { tone: 'success' }, t('health.driftClean')) : h(C.Badge, { tone: 'warn' }, t('health.driftFound')),
424
+ }),
425
+ ),
426
+ self === null
427
+ ? null
428
+ : h(
429
+ 'div',
430
+ { className: 'acc-muted', style: SMALL_STYLE },
431
+ `${t('health.driftSelf')}: ${textOf(self.entryId) || EMPTY_VALUE} · ${t('health.driftSelfEnabled')} ${self.enabled === true ? t('health.yes') : self.enabled === false ? t('health.no') : EMPTY_VALUE} · ${textOf(self.fiberPhase) || EMPTY_VALUE}`,
432
+ ),
433
+ h(
434
+ 'div',
435
+ { className: 'acc-row' },
436
+ h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.source')}:`),
437
+ h(C.Mono, { text: source.length > 0 ? source : EMPTY_VALUE }),
438
+ ),
439
+ drifts.length === 0
440
+ ? h(C.Notice, { tone: 'success' }, t('health.driftEmpty'))
441
+ : h(
442
+ 'div',
443
+ { style: STACK_STYLE },
444
+ drifts.map((drift, index) => h(DriftNotice, { key: `drift-${index}`, t, drift })),
445
+ ),
446
+ props.onDeep === undefined || data.bundlesChecked === true
447
+ ? null
448
+ : h(
449
+ 'div',
450
+ { className: 'acc-row', style: { justifyContent: 'flex-start' } },
451
+ h(
452
+ C.Btn,
453
+ { tone: 'ghost', onClick: props.onDeep, disabled: props.loading === true, title: t('health.driftCheckBundlesHint') },
454
+ props.loading === true ? t('health.refreshing') : t('health.driftCheckBundles'),
455
+ ),
456
+ h('span', { className: 'acc-muted', style: SMALL_STYLE }, t('health.driftCheckBundlesHint')),
457
+ ),
458
+ notes.length === 0
459
+ ? null
460
+ : h(
461
+ 'div',
462
+ { style: STACK_STYLE },
463
+ h('div', { className: 'acc-section-title' }, t('health.driftNotes')),
464
+ notes.map((note, index) =>
465
+ h('div', { key: `note-${index}`, className: 'acc-muted', style: { ...SMALL_STYLE, ...BREAK_STYLE } }, String(note)),
466
+ ),
467
+ ),
468
+ h(NoteLine, { t, text: data.note }),
469
+ )
470
+ }
471
+
472
+ /** @param {{ t: Function, gate: any, onGateRefresh: Function }} props */
473
+ function DriftCard(props) {
474
+ const t = props.t
475
+ const gate = isRecord(props.gate) ? props.gate : {}
476
+ const blocked = gate.available === false
477
+ // Bundle inspection reads every install location and costs seconds, so it
478
+ // is a deliberate extra step, not part of the first read.
479
+ const [deep, setDeep] = ACC.useState(false)
480
+ const state = ACC.useAsync(
481
+ blocked
482
+ ? gatedLoader(gate)
483
+ : (context) => ACC.api('health.drift', deep ? { includeBundles: true } : {}, context),
484
+ [deep],
485
+ )
486
+ return h(
487
+ BlockCard,
488
+ {
489
+ t,
490
+ title: t('health.driftTitle'),
491
+ subtitle: t('health.driftSubtitle'),
492
+ loading: state.status === 'loading',
493
+ onRefresh: blocked ? props.onGateRefresh : state.reload,
494
+ refreshLabel: t('health.refresh.drift'),
495
+ },
496
+ h(BlockContent, {
497
+ t,
498
+ state,
499
+ render: (data) => h(DriftBody, { t, data, onDeep: () => setDeep(true), loading: state.status === 'loading' }),
500
+ }),
501
+ )
502
+ }
503
+
358
504
  /** @param {{ t: Function, anomaly: any }} props */
359
505
  function AnomalyNotice(props) {
360
506
  const t = props.t
@@ -816,6 +962,7 @@
816
962
  h(PluginsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
817
963
  h(SettingsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
818
964
  h(SectionsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
965
+ h(DriftCard, { t, gate: gateView, onGateRefresh: gate.reload }),
819
966
  h(CompatCard, { t, gate: gateView, onGateRefresh: gate.reload }),
820
967
  )
821
968
  }