dsh-agent-control-center 0.4.1 → 0.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/CHANGELOG.md +80 -0
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/client.js +226 -5
- package/docs/01-CONTRACT.md +1 -1
- package/docs/05-ACCEPTANCE-EVIDENCE.md +71 -0
- package/docs/07-GUIDE.md +1 -1
- package/docs/09-ARCHITECTURE.md +1 -1
- package/docs/12-PLUGIN-HEALTH.md +18 -1
- package/docs/14-INTERACTION-REGRESSION-0.5.0.md +79 -0
- package/docs/15-WRITE-REGRESSION.md +43 -0
- package/docs/16-TOOLS-FIRST-PAINT.md +36 -0
- package/index.js +1 -1
- package/lib/modules/l-health.js +182 -1
- package/package.json +1 -1
- package/scripts/interaction-regression.py +278 -0
- package/scripts/write-regression.py +107 -0
- package/src/client/i18n/health.js +56 -0
- package/src/client/i18n/tools.js +2 -0
- package/src/client/pages/health.js +147 -0
- package/src/client/pages/tools.js +19 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# 逐页交互回归(12 页,v0.5.0,宿主 0.2.3-alpha.3)
|
|
2
|
+
|
|
3
|
+
> 真实 Chrome headless,隔离 profile `accverify`,2026-11-29。脚本逐页执行真实交互并断言页面结果;每个断言记录实际数值。
|
|
4
|
+
|
|
5
|
+
## 结果:24 / 24 通过
|
|
6
|
+
|
|
7
|
+
| 页面 | 交互 | 结果 | 实际 |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| Overview | stat tiles render | PASS | 6 tiles |
|
|
10
|
+
| Overview | stat tile navigates | PASS | sessions |
|
|
11
|
+
| AGENTS.md | chain renders | PASS | 1405 chars |
|
|
12
|
+
| AGENTS.md | row selection | PASS | 3 rows |
|
|
13
|
+
| Tools | search narrows | PASS | |
|
|
14
|
+
| Tools | row expands | PASS | 1 open |
|
|
15
|
+
| Tools | Esc collapses row | PASS | |
|
|
16
|
+
| Tools | Esc keeps Settings | PASS | |
|
|
17
|
+
| Sessions | archived tab | PASS | |
|
|
18
|
+
| Sessions | select shows toolbar | PASS | |
|
|
19
|
+
| Usage | date switch re-renders | PASS | |
|
|
20
|
+
| Agent info | presets view | PASS | |
|
|
21
|
+
| Agent info | export view | PASS | |
|
|
22
|
+
| Instruction | session selector | PASS | 51 options |
|
|
23
|
+
| Instruction | session view renders | PASS | |
|
|
24
|
+
| Templates | detail opens | PASS | 1882 -> 1882, dialogs=1 |
|
|
25
|
+
| Diagnostics | filter applied | PASS | |
|
|
26
|
+
| Health | drift tiles | PASS | |
|
|
27
|
+
| Health | drift counts | PASS | |
|
|
28
|
+
| Health | bundle check result | PASS | TY REASONS
|
|
29
|
+
The compatibility layer reported no reasons
|
|
30
|
+
No reasons usually means the current host version passed validation; still check readOnly before writing. |
|
|
31
|
+
| Export | session selected | PASS | |
|
|
32
|
+
| Export | preview produced | PASS | 3433 chars |
|
|
33
|
+
| Restart | scan runs | PASS | 931 chars |
|
|
34
|
+
| global | console errors | PASS | [] |
|
|
35
|
+
|
|
36
|
+
## 首屏耗时(同一会话,暖缓存)
|
|
37
|
+
|
|
38
|
+
| 页面 | 耗时 | 文本字符 |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| Overview | 4 ms | 1740 |
|
|
41
|
+
| AGENTS.md | 1080 ms | 1405 |
|
|
42
|
+
| Tools | 5561 ms | 4114 |
|
|
43
|
+
| Sessions | 517 ms | 6573 |
|
|
44
|
+
| Usage | 27 ms | 2606 |
|
|
45
|
+
| Agent info | 508 ms | 1313 |
|
|
46
|
+
| Instruction preview | 1032 ms | 60442 |
|
|
47
|
+
| Templates | 8 ms | 1882 |
|
|
48
|
+
| Diagnostics | 1532 ms | 9907 |
|
|
49
|
+
| Health check | 1544 ms | 23903 |
|
|
50
|
+
| Export | 519 ms | 3434 |
|
|
51
|
+
| Restart & Resume | 6 ms | 931 |
|
|
52
|
+
|
|
53
|
+
## 覆盖的交互
|
|
54
|
+
|
|
55
|
+
- **Overview**:6 张指标卡渲染;点击一张跳转到对应页(实测跳到 sessions)。
|
|
56
|
+
- **AGENTS.md**:指令链渲染(3 个候选文件);点击文件行选中。
|
|
57
|
+
- **Tools**:搜索框收窄结果;展开行;Esc 收起行**且设置面板不关闭**(v0.4.1 修复项回归通过)。
|
|
58
|
+
- **Sessions**:归档/全部 tab 切换;勾选行出现「已选」工具条。
|
|
59
|
+
- **Usage**:日期控件切换后重新渲染。
|
|
60
|
+
- **Agent info**:Presets 视图;Export 视图(`exportedAt`/声明不含密钥)。
|
|
61
|
+
- **Instruction preview**:By session 视图、51 个会话选项、指令块视图渲染。
|
|
62
|
+
- **Templates**:点击模板打开详情(宿主模态框,`dialogs=1`)。
|
|
63
|
+
- **Diagnostics**:Warning 过滤器生效。
|
|
64
|
+
- **Health check**:漂移块四宫格(225 行 / 222 可寻址 / 222 profile 管辖 / 0 漂移);点「检查 bundle 安装状态」后出现 **2 条真实漂移**(`Declared but not installed`)。
|
|
65
|
+
- **Export**:选择会话、生成预览(3,433 字符)。
|
|
66
|
+
- **Restart & Resume**:扫描按钮执行。
|
|
67
|
+
- **全局**:0 console error / 0 pageerror。
|
|
68
|
+
|
|
69
|
+
## 在这轮发现并修掉的真问题
|
|
70
|
+
|
|
71
|
+
| 来源 | 问题 | 处理 |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| 浏览器验收 | 体检页新加的漂移块引用了未定义的 `FLEX_WRAP_STYLE`,整个设置面板白屏 | 补上常量;单测与 i18n 校验都没发现,只有真实浏览器能抓到 |
|
|
74
|
+
| 交互回归脚本 | 5 条「失败」全部是脚本自身断言问题(如浅层渲染的 `No drift` 被当成深层结果、模板详情在宿主模态框内) | 修正断言;修正后 24/24 |
|
|
75
|
+
|
|
76
|
+
## 已知未覆盖
|
|
77
|
+
|
|
78
|
+
- Tools 首屏 5.5 s(冷历史扫描,25 会话 / 5 s 预算);热读 11 ms。下一轮计划把历史统计从首屏拆出。
|
|
79
|
+
- 编辑器写路径(AGENTS.md 保存、模板应用、恢复)本轮仍未在浏览器里做端到端写测试,只做了只读交互;写路径的证据来自单元测试与 0.2.x 的真机保存记录。
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 写路径回归(保存 / 备份 / 乐观并发 / 恢复)
|
|
2
|
+
|
|
3
|
+
> 脚本:`scripts/write-regression.py`(真实 HTTP + 真实文件,需要运行中的实例与一个会话工作目录)。
|
|
4
|
+
> 只读的交互回归见 `scripts/interaction-regression.py` 与 `docs/14-INTERACTION-REGRESSION-0.5.0.md`。
|
|
5
|
+
|
|
6
|
+
## 为什么写路径必须单独测
|
|
7
|
+
|
|
8
|
+
只读页面的 bug 最多让人看到错数字;写路径的 bug 会**改掉用户的指令文件**。所以这里不看文案,只验字节:
|
|
9
|
+
|
|
10
|
+
1. 保存前文件 sha256 → 保存后的磁盘内容必须**逐字节**等于提交内容;
|
|
11
|
+
2. 保存必须**先**把旧内容写进备份,备份名要能在随后的 `agents.backups` 里读到;
|
|
12
|
+
3. 用**过期 hash** 再保存必须被拒绝,且磁盘不能被覆盖(乐观并发的核心保证);
|
|
13
|
+
4. 用最新备份恢复后,文件必须回到原始字节;
|
|
14
|
+
5. 恢复本身也要留下自己的备份(不然后悔两步就无从回溯)。
|
|
15
|
+
|
|
16
|
+
## 结果(2026-11-29,accverify,宿主 0.2.3-alpha.3)
|
|
17
|
+
|
|
18
|
+
`11 / 11` 通过,目标文件 17,855 字节:
|
|
19
|
+
|
|
20
|
+
| 步骤 | 结果 |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `agents.summary` | 可用,`cwd=/home/ova/dsh` |
|
|
23
|
+
| `agents.backups` 初读 | 3 条既有备份 |
|
|
24
|
+
| `agents.save`(带正确 `expectedHash`) | 接受,返回 `hash=55f68dd2…`、`backup=2026-11-29T13-56-36-663Z.md` |
|
|
25
|
+
| 磁盘内容与提交内容 | 逐字节一致 |
|
|
26
|
+
| 备份数量 | 3 → 4 |
|
|
27
|
+
| `agents.save`(**过期** `expectedHash`) | `conflict`:`expected=4c5ad6e8… actual=55f68dd2…`,提示「磁盘未被覆盖」 |
|
|
28
|
+
| `agents.restore`(最新备份) | 接受,并生成自己的备份 |
|
|
29
|
+
| 恢复后的磁盘内容 | **17,855 字节,sha256 回到 `4c5ad6e8…`** |
|
|
30
|
+
|
|
31
|
+
收尾检查:仓库 `git status AGENTS.md` 干净、sha256 与测试前一致;全部测试备份落在插件自己的存储目录(`~/.dsh/dsh-agent-control-center/backups/`),没有散落到别处。
|
|
32
|
+
|
|
33
|
+
## 已知约束(务必先读)
|
|
34
|
+
|
|
35
|
+
- **目标必须是会话工作目录内的既有指令文件**。插件按宿主会话 cwd 授权写入;`/tmp` 下的 fixture 不是任何会话的 cwd 时会被 `forbidden`(这是 0.2.x 起就有的边界,不是本轮新增)。
|
|
36
|
+
- 脚本拒绝在不存在的文件上运行(保存管线也只更新既有文件),所以它永远不可能「创建」一个指令文件。
|
|
37
|
+
- 脚本会把原始字节存到 `--out/original.bak`;若中途被杀,用这份文件手工还原,并核对 sha256。
|
|
38
|
+
|
|
39
|
+
## 尚未覆盖:UI 端写路径
|
|
40
|
+
|
|
41
|
+
尝试过用浏览器驱动编辑器保存(填 `textarea` → 点 Save → 校验磁盘),结果只 5/8:编辑区显示的是**组装后的视图**(实测 41,104 字符),与文件原文(17,855 字节)不是同一份字节,脚本按原文 hash 去比对自然失败;同一轮还留下了一处 28 字节的标记,已用安全副本还原并核对 sha256。
|
|
42
|
+
|
|
43
|
+
结论:**浏览器写路径尚未被可靠覆盖**。下一步要么先弄清编辑器展示的到底是哪一份内容(组装视图 or 原文),要么把 UI 保存改成走「原文编辑器」再测。在此之前的写路径证据只有上面这份 API 级 E2E + 单元测试。
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Tools 页首屏:从 5.5 s 降到 90 ms
|
|
2
|
+
|
|
3
|
+
## 问题
|
|
4
|
+
|
|
5
|
+
Tools 页首屏要等 `tools.list` 完成,而该调用把两件成本完全不同的事绑在一起:
|
|
6
|
+
|
|
7
|
+
| 部分 | 成本 | 说明 |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| 注册表视图 | ~150 ms | `tools.getAll()` + agents/presets 视图,纯内存 |
|
|
10
|
+
| 历史调用统计 | 3.9–5.4 s(冷) | 扫 25 个会话的 `tool/call`、`tool/result`,受 5 s 时间预算约束 |
|
|
11
|
+
|
|
12
|
+
用户看到的却是「整页 Loading 5.5 秒」,尽管列表 150 ms 就能画出来。
|
|
13
|
+
|
|
14
|
+
## 改法
|
|
15
|
+
|
|
16
|
+
页面发**两个并行请求**,各自渲染:
|
|
17
|
+
|
|
18
|
+
1. `tools.list({ includeHistory: false })` → 注册表 + 三层状态(注册/可见/可调用);一到就画。
|
|
19
|
+
2. `tools.list({ includeHistory: true })` → 历史徽标、错误分布、会话计数;到了再替换内容。
|
|
20
|
+
|
|
21
|
+
未到达时页面显示一条说明(`tools.historyLoading`),而不是把整页按住。两个请求共享服务端的注册表缓存,历史折叠还有 60 s 记忆化(v0.4.1 起),所以第二个请求基本不重复扫描。
|
|
22
|
+
|
|
23
|
+
## 实测(accverify,12 模块,357 个会话)
|
|
24
|
+
|
|
25
|
+
| 指标 | 改前 | 改后 |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| 首屏(出现工具行) | 5,561 ms(接受脚本) / 4,125 ms(MutationObserver) | **90 ms** |
|
|
28
|
+
| 历史块填充 | 同首屏 | 3,970 ms(不阻塞) |
|
|
29
|
+
|
|
30
|
+
测量方式:`MutationObserver` 记录 `data-acc-page="tools"` 后第一次出现工具行按钮的时间戳,避开了轮询脚本自身的往返开销(此前用 100 ms 轮询测出的 4.1 s 主要是测量误差)。
|
|
31
|
+
|
|
32
|
+
## 保留的契约
|
|
33
|
+
|
|
34
|
+
- 首屏请求**完全不读会话**:新增单测 `tools.list: the registry view answers without reading sessions at all` 让 `listSessions` 直接抛错、并断言 `readSession` 零调用。
|
|
35
|
+
- 历史不可用时(`includeHistory:false` 或没有 `sessionQuery`)行状态显示 `unavailable`/`unknown`,绝不显示 0。
|
|
36
|
+
- 刷新按钮会同时重取两份数据(`refresh:true` 绕过缓存与历史记忆化)。
|
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.
|
|
18
|
+
export const VERSION = '0.6.0'
|
|
19
19
|
/** Browser transport prefix. The client fetches it document-relative. */
|
|
20
20
|
export const HTTP_PREFIX = '/__agent-control-center'
|
|
21
21
|
|
package/lib/modules/l-health.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.6.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",
|