dsh-agent-control-center 0.2.0 → 0.3.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.
@@ -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.2.0` |
42
+ | 版本 | `0.3.0` |
43
43
  | 兼容声明 | `dsh.compatibility.dsh = ">=0.2.1-rc.1 <0.3.0"`,`engines.dsh` 同区间 |
44
44
 
45
45
  `package.json` 关键字段(照抄,勿改语义):
@@ -245,3 +245,42 @@ curl -s http://127.0.0.1:38080/__agent-control-center/health
245
245
  `/tmp/acc/security.md`;其中 M2 是「查看历史会话指令链」这一功能的固有代价,
246
246
  现在由 `$DSH_HOME` 敏感路径拒绝清单兜底。
247
247
  - 安全审计 H1/H2/M1/M3/L1 已修复并有回归测试。
248
+
249
+ ---
250
+
251
+ # 附:0.3.0 验收补充(2026-11-29)
252
+
253
+ 0.1.0 / 0.2.0 的结论仍然有效。0.3.0 新增两个只读模块(指令预览 J、会话导出 K)与导航分组;本节只记录新增证据。
254
+
255
+ ## 测试
256
+
257
+ - `node --test tests/*.test.mjs` → **332 / 332 pass**(0.2.0 为 309)。
258
+ - 新增:`tests/instruction.test.mjs`(12)、`tests/export.test.mjs`(11);
259
+ `tests/contract.test.mjs` 的模块清单、order 序列与 `overview.summary.short` 计数同步到 11 模块。
260
+ - `scripts/verify.mjs` 的模块表扩充到 11 项(`instruction` / `export` 就绪才显示 ready)。
261
+
262
+ ## 真机(隔离 profile `accverify`,重启后 11 模块实测)
263
+
264
+ | 项 | 结果 |
265
+ |---|---|
266
+ | `/health` | `version 0.3.0`;11 模块:`instruction=FULL(5)`、`export=FULL(4)`,其余与 0.2.0 一致(`recovery=PARTIAL`) |
267
+ | `agents.render` | 346 ms,`exact=true`,76,621 B;两条链均在预算内(用户全局 58,423 B / 项目 17,855 B,maxBytes 65,536) |
268
+ | `instruction.chain` | 581 ms,3 个候选文件;`CLAUDE.md` 与 `AGENTS.md` 内容相同被去重(`dedupedBy` 指向 `AGENTS.md`) |
269
+ | `instruction.preview` | 572 ms,`mode=files`,`exact=true`,76,621 B(与 `agents.render` 逐字节一致) |
270
+ | `instruction.session` | 真实会话取出 **29** 个 `agent-instructions` 块,`exact=true`;首块 31,472 B 且 `baseline=true` |
271
+ | `instruction.compare` | 同一会话:files 76,621 B vs session 57,138 B → `deltaBytes=-19,483`,`sameText=false`,并给出「基线写入后文件变大」等解释 |
272
+ | `export.summary` | 19,345 事件 / 443 用户消息 / 2,470 助手消息 / 2,674 工具调用 / 14 错误;估算 markdown 3,351,935 B、json 5,399,348 B |
273
+ | `export.session` | 6.2 s,输出 262,069 B(默认 256 KiB 上限),`truncated=true`,`omittedEvents=12,623`(按事件边界截断) |
274
+
275
+ ## 浏览器(真实 Chrome headless)
276
+
277
+ - 导航 **11 项**、mid 布局 **2 个组分隔符**、顺序 `Overview, Tools, Sessions, Usage, Agent info, Export | AGENTS.md, Instruction preview, Templates | Diagnostics, Restart & Resume`。
278
+ - `Instruction preview` 页渲染真实数据(57.4 KiB / 64 KiB 预算条、指令链表、`In effect` 徽标),42,427 字符;`Export` 页进入空态(未选会话),340 字符。
279
+ - 两页均 **0 个错误态块**、**0 console/pageerror**。
280
+ - 截图:`/tmp/ux/v3-instruction.png`、`/tmp/ux/v3-overview.png`。
281
+
282
+ ## 未验证 / 已知限制(0.3.0 新增部分)
283
+
284
+ - `instruction.compare` 的 `sameText` 只对「同一 cwd 且两侧都未被截断」有意义;跨 cwd 比较时差异来自不同目录的指令链,页面已用解释文案区分。
285
+ - 会话导出对超大会话(1.9 万事件)耗时 6.2 s,且必然截断;这是只读导出的固有代价,未做流式/分页。
286
+ - 两个新页面只由各自作者做过 mock 与旧实例降级验证,**合并后未做逐项交互回归**(本轮只做了渲染/空态/错误态断言)。
package/docs/07-GUIDE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 用户指南:从「我想做什么」出发
2
2
 
3
- > 适用版本 **0.2.0**,目标宿主 DSH **0.2.2-rc.5**(兼容区间 `>=0.2.1-rc.1 <0.3.0`)。
3
+ > 适用版本 **0.3.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);
@@ -26,7 +26,7 @@
26
26
  DSH Web GUI (browser)
27
27
  ├── Settings dialog
28
28
  │ └── settings.section id=agent-control-center order=200 ← client.js
29
- │ └── 9 pages (client-side secondary navigation)
29
+ │ └── 11 pages (client-side secondary navigation)
30
30
  └── HTTP (same origin)
31
31
  └── /__agent-control-center/health GET
32
32
  └── /__agent-control-center/api POST {method, params}
@@ -42,7 +42,7 @@ DSH Web GUI (browser)
42
42
 
43
43
  ### 2.1 入口 `index.js`
44
44
 
45
- - 导出:`name`、`VERSION`(`0.2.0`,与 `package.json` 同步)、`HTTP_PREFIX`(`/__agent-control-center`)、`inject = []`、`apply(ctx, rawConfig)`。
45
+ - 导出:`name`、`VERSION`(`0.3.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,不做静默兜底);
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.2.0'
18
+ export const VERSION = '0.3.0'
19
19
  /** Browser transport prefix. The client fetches it document-relative. */
20
20
  export const HTTP_PREFIX = '/__agent-control-center'
21
21
 
@@ -56,6 +56,8 @@ const MODULE_MANIFEST = Object.freeze([
56
56
  { id: 'templates', load: () => import('./lib/modules/g-templates.js') },
57
57
  { id: 'overview', load: () => import('./lib/modules/h-overview.js') },
58
58
  { id: 'recovery', load: () => import('./lib/modules/i-recovery.js') },
59
+ { id: 'instruction', load: () => import('./lib/modules/j-instruction.js') },
60
+ { id: 'export', load: () => import('./lib/modules/k-export.js') },
59
61
  ])
60
62
 
61
63
  /**
@@ -1344,6 +1344,95 @@ export default function createModule(core) {
1344
1344
  * @param {unknown} params
1345
1345
  * @returns {Promise<Record<string, any>>}
1346
1346
  */
1347
+ /**
1348
+ * Reassemble the model-facing instruction text from the files on the chain's
1349
+ * effective set, using the host's own frame, intro and budget decisions
1350
+ * (`dsh-agent-instructions/src/render.ts:255-330`). Read-only: nothing is
1351
+ * written, and `exact` states whether every chain stayed inside its budget
1352
+ * (the host then emits the same bytes from the same files).
1353
+ * @param {{ cwd?: string }} input
1354
+ * @returns {Promise<Record<string, any>>}
1355
+ */
1356
+ async function renderMethod(input) {
1357
+ const resolved = await resolveCwd(input?.cwd)
1358
+ const chainData = await discover({ cwd: resolved.cwd, session: resolved.session })
1359
+ const maxBytes = chainData.config.maxBytes
1360
+ if (maxBytes === null || !(maxBytes > 0) || !Number.isFinite(maxBytes)) {
1361
+ return {
1362
+ available: false,
1363
+ reason: '未读到宿主的指令预算(maxBytes),无法判断哪些文件会进入模型',
1364
+ hint: '检查宿主 configEditor 的 agent-instructions 配置;只读项',
1365
+ cwd: chainData.cwd,
1366
+ projectRoot: chainData.projectRoot,
1367
+ budget: { maxBytes: null, source: chainData.config.maxBytesSource },
1368
+ }
1369
+ }
1370
+ /** @param {string} kind @returns {Array<{ displayPath: string, content: string }>} */
1371
+ const chainFiles = (kind) => chainData.items
1372
+ .filter((item) => item.readable && !item.tooLarge && !item.deduped
1373
+ && (kind === 'global'
1374
+ ? item.source === 'user-global' || item.source === 'agents-home'
1375
+ : item.source === 'project' || item.source === 'project-local'))
1376
+ .map((item) => ({ displayPath: item.displayPath, content: String(item.text ?? '') }))
1377
+ /**
1378
+ * Drop what the chain's budget omits and shorten what it truncates.
1379
+ * @param {Array<{ displayPath: string, content: string }>} files
1380
+ * @param {Record<string, any>} budget
1381
+ */
1382
+ function applyBudget(files, budget) {
1383
+ const omitted = new Set(budget.omitted ?? [])
1384
+ const truncatedEntries = new Map((budget.truncated ?? []).map((entry) => [entry.displayPath, entry]))
1385
+ /** @type {Array<{ displayPath: string, content: string }>} */
1386
+ const kept = []
1387
+ for (const file of files) {
1388
+ if (omitted.has(file.displayPath)) continue
1389
+ const cut = truncatedEntries.get(file.displayPath)
1390
+ kept.push(cut === undefined ? file : { displayPath: file.displayPath, content: truncateUtf8(file.content, cut.includedBytes) })
1391
+ }
1392
+ return kept
1393
+ }
1394
+ const included = [
1395
+ ...applyBudget(chainFiles('global'), chainData.chains.userGlobal),
1396
+ ...applyBudget(chainFiles('project'), chainData.chains.project),
1397
+ ]
1398
+ const omitted = [...(chainData.chains.userGlobal.omitted ?? []), ...(chainData.chains.project.omitted ?? [])]
1399
+ const truncated = [...(chainData.chains.userGlobal.truncated ?? []), ...(chainData.chains.project.truncated ?? [])]
1400
+ const exact = omitted.length === 0 && truncated.length === 0
1401
+ const intro = exact ? AGENT_INSTRUCTIONS_INTRO : COMPACT_AGENT_INSTRUCTIONS_INTRO
1402
+ const text = buildInstructionText(included, maxBytes, omitted, truncated, intro)
1403
+ return {
1404
+ available: true,
1405
+ mode: 'files',
1406
+ exact,
1407
+ cwd: chainData.cwd,
1408
+ projectRoot: chainData.projectRoot,
1409
+ text,
1410
+ bytes: byteLength(text),
1411
+ intro,
1412
+ budget: {
1413
+ maxBytes,
1414
+ source: chainData.config.maxBytesSource,
1415
+ userGlobal: {
1416
+ bytes: chainData.chains.userGlobal.bytes,
1417
+ renderedBytes: chainData.chains.userGlobal.renderedBytes,
1418
+ fits: chainData.chains.userGlobal.fits,
1419
+ },
1420
+ project: {
1421
+ bytes: chainData.chains.project.bytes,
1422
+ renderedBytes: chainData.chains.project.renderedBytes,
1423
+ fits: chainData.chains.project.fits,
1424
+ },
1425
+ },
1426
+ sections: included.map((file) => ({ displayPath: file.displayPath, bytes: byteLength(file.content) })),
1427
+ omitted,
1428
+ truncated,
1429
+ warnings: chainData.warnings ?? [],
1430
+ note: exact
1431
+ ? '两条链都在预算内:文本由这些文件按宿主格式重新组合,宿主注入的字节应与此相同;会话精确视图可逐一比对。'
1432
+ : '存在省略或截断:这是按预算规则重组的近似文本,宿主实际注入可能有所不同;请以会话精确视图为准。',
1433
+ }
1434
+ }
1435
+
1347
1436
  async function filesMethod(params) {
1348
1437
  const p = util.paramsObject(params)
1349
1438
  const requested = optionalStr(p, 'cwd', 4096)
@@ -1696,6 +1785,7 @@ export default function createModule(core) {
1696
1785
  },
1697
1786
  methods: {
1698
1787
  'agents.files': async (params) => filesMethod(params),
1788
+ 'agents.render': async (params) => renderMethod(util.paramsObject(params)),
1699
1789
  'agents.list': async (params) => filesMethod(params),
1700
1790
  'agents.read': async (params) => readMethod(params),
1701
1791
  'agents.save': async (params, context) => saveMethod(params, context),