dsh-agent-control-center 0.0.0-stage → 0.1.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +32 -0
  3. package/README.md +120 -2
  4. package/README.zh.md +94 -0
  5. package/client.js +7253 -0
  6. package/cordis.patch.yml +25 -0
  7. package/docs/00-PACKAGE-VERIFICATION.md +88 -0
  8. package/docs/01-CONTRACT.md +380 -0
  9. package/docs/02-REFERENCE-PROVENANCE.md +53 -0
  10. package/docs/04-MODULE-AUTHORING.md +159 -0
  11. package/docs/05-ACCEPTANCE-EVIDENCE.md +205 -0
  12. package/docs/DETAIL.en.md +49 -0
  13. package/docs/DETAIL.zh.md +42 -0
  14. package/icon.svg +6 -0
  15. package/index.js +138 -0
  16. package/lib/core/atomic.js +191 -0
  17. package/lib/core/caps.js +100 -0
  18. package/lib/core/diff.js +258 -0
  19. package/lib/core/errors.js +66 -0
  20. package/lib/core/http.js +252 -0
  21. package/lib/core/index.js +111 -0
  22. package/lib/core/markdown-checks.js +672 -0
  23. package/lib/core/paths.js +124 -0
  24. package/lib/core/registry.js +209 -0
  25. package/lib/core/store.js +362 -0
  26. package/lib/core/usage-ledger.js +659 -0
  27. package/lib/core/util.js +178 -0
  28. package/lib/modules/a-agents.js +1700 -0
  29. package/lib/modules/b-tools.js +1071 -0
  30. package/lib/modules/c-sessions.js +1428 -0
  31. package/lib/modules/d-usage.js +998 -0
  32. package/lib/modules/e-meta.js +1417 -0
  33. package/lib/modules/f-diagnostics.js +1369 -0
  34. package/lib/modules/g-templates.js +886 -0
  35. package/lib/modules/h-overview.js +220 -0
  36. package/lib/modules/i-recovery.js +800 -0
  37. package/locale/en.json +7 -0
  38. package/locale/zh.json +7 -0
  39. package/package.json +89 -4
  40. package/scripts/build-client.mjs +186 -0
  41. package/scripts/verify.mjs +155 -0
  42. package/src/client/app.js +286 -0
  43. package/src/client/i18n/agents.js +258 -0
  44. package/src/client/i18n/common.js +69 -0
  45. package/src/client/i18n/diagnostics.js +282 -0
  46. package/src/client/i18n/meta.js +256 -0
  47. package/src/client/i18n/overview.js +52 -0
  48. package/src/client/i18n/recovery.js +187 -0
  49. package/src/client/i18n/sessions.js +308 -0
  50. package/src/client/i18n/templates.js +200 -0
  51. package/src/client/i18n/tools.js +230 -0
  52. package/src/client/i18n/usage.js +152 -0
  53. package/src/client/kernel.js +453 -0
  54. package/src/client/pages/agents.js +795 -0
  55. package/src/client/pages/diagnostics.js +283 -0
  56. package/src/client/pages/meta.js +553 -0
  57. package/src/client/pages/overview.js +113 -0
  58. package/src/client/pages/recovery.js +293 -0
  59. package/src/client/pages/sessions.js +873 -0
  60. package/src/client/pages/templates.js +726 -0
  61. package/src/client/pages/tools.js +369 -0
  62. package/src/client/pages/usage.js +442 -0
  63. package/templates/agents-md-minimal.json +39 -0
  64. package/templates/agents-md-skeleton.json +64 -0
  65. package/templates/convention-code-style.json +54 -0
  66. package/templates/diagnostics-checklist.json +39 -0
  67. package/templates/persona-reviewer.json +46 -0
  68. package/templates/tooling-shell-guard.json +46 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,60 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-11-28
4
+
5
+ First release, verified against DSH `0.2.2-rc.5` (web profile).
6
+
7
+ ### Added
8
+
9
+ - One settings entry ("Agent Control Center") with nine internal pages and a
10
+ responsive narrow-screen layout.
11
+ - **Overview**: environment facts, capability presence, module states, real
12
+ counts, internal navigation shortcuts.
13
+ - **AGENTS.md**: instruction-chain discovery (user global / project chain /
14
+ `CLAUDE.md` / `*.local.md`, dedup and budget per host rules), byte-exact read
15
+ (hash, bytes, EOL, BOM, trailing newline), version-guarded save with mandatory
16
+ pre-write backup and read-back verification, backup list/restore, unified
17
+ diff, 11 deterministic checks (empty file, BOM, mixed EOL, unclosed fence,
18
+ heading jumps, duplicate headings, empty sections, duplicated rules,
19
+ suspected conflicting rules, over budget, missing local references), audit
20
+ trail.
21
+ - **Tools**: read-only inventory with three states (registered / visible to an
22
+ agent / called in history), error clusters and recent failures from session
23
+ events; never executes a tool to probe it.
24
+ - **Sessions**: list, title/id search with documented full-text fallback, group
25
+ by workspace or flat, batched archive/unarchive with per-item results and
26
+ retry of failures, expandable detail (turns, steps, messages, tool calls,
27
+ tool distribution, attachments, produced files, web fetches, lineage) with
28
+ response caps, pagination. Session deletion is intentionally absent because
29
+ the host exposes no public API; the page says so.
30
+ - **Usage**: idempotent ledger keyed by `sessionId + seq` with per-session
31
+ cursors, cold-start replay, live event increment, manual recompute, local-day
32
+ pruning, six headline cells, 30-day provider/model CSS bar chart, date picker,
33
+ explicit calibration notes, explicit "statistics start" notice when history
34
+ cannot be replayed.
35
+ - **Agent info**: live agents, presets, default model, redacted export,
36
+ field-level diff, import preview; import applies only to plugin-owned state.
37
+ - **Diagnostics**: 22 probes across ten groups with status/evidence/impact/action,
38
+ Markdown and JSON export, safe repairs limited to the plugin's own storage,
39
+ post-repair re-check.
40
+ - **Templates**: six bundled templates in five categories, source and rendered
41
+ preview, variable fill with unresolved-variable reporting, line-level diff,
42
+ apply through the AGENTS.md save pipeline, user template CRUD with import /
43
+ export and executable-content rejection.
44
+ - **Restart & Resume**: read-only detection of interrupted sessions from event
45
+ semantics (synthetic `TOOL_NOT_STARTED` / `TOOL_OUTCOME_UNKNOWN` results,
46
+ unclosed tail turns) with evidence; no automatic resume, no message injection,
47
+ no log appends.
48
+ - Loopback- and same-origin-fenced HTTP transport with a JSON envelope, method
49
+ whitelist, 1 MiB body cap, explicit status codes, serialized storage writes,
50
+ atomic documents with corruption quarantine and version migration, and an
51
+ append-only audit that never stores contents or credentials.
52
+
53
+ ### Known limits
54
+
55
+ - Session deletion is unavailable (host API absent) and the page hides it.
56
+ - Full-text session search works only when the deployment enables the index;
57
+ otherwise title/id substring matching is used and labelled.
58
+ - Usage cost estimation and provider balance/plan are not implemented (no
59
+ trustworthy price list or currency).
60
+ - No AI analysis entry point is shipped; the plugin never calls a model.
package/LICENSE ADDED
@@ -0,0 +1,32 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DSH Agent Control Center contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Third-party acknowledgements
26
+
27
+ The behaviour specification for the "sessions" page was modelled on
28
+ `dsh-archived-sessions` (MIT, Copyright (c) 2026 Zephyr-vibe), and the behaviour
29
+ specification for the "usage" page was modelled on `@linxin666/dsh-usage`
30
+ (Apache-2.0, linxin666 / zhu1090093659/dsh-web). This plugin is an independent
31
+ implementation: no source code from either project is copied, neither project
32
+ is required at runtime, and neither project's storage is read or written.
package/README.md CHANGED
@@ -1,3 +1,121 @@
1
- # Temporary Holding Version
1
+ # dsh-agent-control-center
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [English](README.md) | [中文](README.zh.md)
4
+
5
+ One control centre for a DeepSeek Harness profile: edit and back up `AGENTS.md`,
6
+ inspect tools, browse and archive sessions, read real token usage, export agent
7
+ metadata, run diagnostics, and apply templates — all from one settings page,
8
+ with no fake data and no writes outside the plugin's own directory.
9
+
10
+ Target: DSH `>=0.2.1-rc.1 <0.3.0` (`peerDependencies`: `@deepseek-ai/cordis`).
11
+ Developed and verified against DSH **0.2.2-rc.5**.
12
+
13
+ ## Install
14
+
15
+ Use the host's official plugin entry (never hand-edit the profile):
16
+
17
+ ```bash
18
+ # from npm
19
+ dsh plugin --profile web add dsh-agent-control-center
20
+
21
+ # or from a checkout / tarball
22
+ dsh plugin --profile web add /absolute/path/to/dsh-agent-control-center
23
+ npm pack && dsh plugin --profile web add ./dsh-agent-control-center-0.1.0.tgz
24
+ ```
25
+
26
+ Then restart the Web GUI (the Host half mounts an HTTP channel at boot) and open
27
+ **Settings → Agent Control Center**. Uninstall with
28
+ `dsh plugin --profile web remove dsh-agent-control-center`.
29
+
30
+ ## What it does
31
+
32
+ | Page | Capability | Data source |
33
+ |---|---|---|
34
+ | Overview | environment, module states, real counts, shortcuts | host services + sibling module summaries |
35
+ | AGENTS.md | discover the instruction chain, read bytes/hash/EOL/BOM, edit with optimistic locking, back up, restore, diff, 11 deterministic checks, budget | `dsh-agent-instructions` rules + host `fs` with version guard |
36
+ | Tools | read-only inventory with three states (registered / visible to an agent / called in history), error clusters, recent failures | `ctx.tools` + session event history |
37
+ | Sessions | list, search (title + id), group by workspace, archive/unarchive in batches, expandable detail with real activity statistics and lineage | `sessionQuery`, `workspaceRegistry`, `sessionPersistence` |
38
+ | Agent info | live agents, presets, default model, redacted export, field-level diff, import preview | `agents`, `agentPresets`, `agentDefaultModel` |
39
+ | Usage | real token accounting (input / cache read / cache write / output / calls), local-day trend, provider/model split, date picker, retention | session events `assistant/message.usage`, idempotent ledger |
40
+ | Diagnostics | 22 probes across host identity, capabilities, presets, instructions, tools, sessions, usage, configuration, storage, permissions; Markdown/JSON export; safe repairs only | host services + plugin storage |
41
+ | Templates | built-in AGENTS.md / convention / persona / tooling / diagnostics templates, source+render preview, variable fill, diff-before-apply, user templates | bundled JSON + plugin storage, applied through the AGENTS.md save pipeline |
42
+ | Restart & Resume | read-only detection of interrupted sessions (unclosed turns, unknown tool outcomes) with evidence; never resumes anything | `sessionQuery` + `dsh-session` repair semantics |
43
+
44
+ ## Deliberate limits
45
+
46
+ - **No session deletion.** DSH 0.2.2-rc.5 exposes no public session-delete API;
47
+ the page hides it and says so. Archiving is the supported action.
48
+ - **No automatic resume.** The Restart & Resume page only reports candidates and
49
+ tells you to continue in the host's own session UI. Nothing is injected or
50
+ appended.
51
+ - **No cost estimation / provider balance.** No trustworthy price list or
52
+ currency is available, so no money is displayed.
53
+ - **Full-text search may be disabled.** When the deployment configures the
54
+ session-query index with `openAt: never`, the page falls back to title/id
55
+ substring matching and labels the degradation.
56
+ - **No `settings`/`credentials` writes.** Agent-info import only writes the
57
+ plugin's own state; host configuration is reported as unavailable rather than
58
+ improvised.
59
+ - **AGENTS.md editing only touches discovered chain files.** New files are not
60
+ created; writes are version-guarded and backed up first.
61
+
62
+ ## Storage and residue
63
+
64
+ Everything lives under `$DSH_HOME/dsh-agent-control-center/`
65
+ (overridable with the row's `storageDir` config):
66
+
67
+ ```
68
+ state.json settings + ignored issues + import records
69
+ usage-ledger.json idempotent token ledger (version + per-session cursor)
70
+ backups/<file-key>/ pre-write copies of every instruction-file save (*.md + *.meta.json)
71
+ templates/ user templates
72
+ audit.jsonl append-only audit (never file contents, never credentials)
73
+ cache/ tmp/ derived data; safe to delete
74
+ ```
75
+
76
+ Uninstalling the plugin leaves this directory untouched. Delete it manually to
77
+ remove all plugin data; the host's own sessions, configuration, and other
78
+ plugins' storage are never written.
79
+
80
+ The plugin writes outside its directory only when you explicitly save an
81
+ instruction file (the original content is backed up first), and it always goes
82
+ through the host `fs` service with the caller's sandbox policy and version
83
+ guard.
84
+
85
+ ## Configuration
86
+
87
+ Row `agent-control-center` in `cordis.patch.yml`:
88
+
89
+ | Field | Default | Meaning |
90
+ |---|---|---|
91
+ | `enabled` | `true` | turn the whole plugin off (no channel, no storage) |
92
+ | `storageDir` | `""` | absolute storage root; empty means `$DSH_HOME/dsh-agent-control-center` |
93
+ | `exposeDelete` | `false` | reserved; deletion stays hidden while the host has no API |
94
+ | `maxBackups` | `20` | pre-write backups kept per instruction file |
95
+ | `usageRetentionDays` | `180` | local-day retention of the ledger (7–730) |
96
+ | `usageReplaySessions` | `200` | sessions replayed on cold start |
97
+ | `usageReplayDays` | `30` | days replayed on cold start |
98
+ | `aiAnalysisEnabled` | `false` | reserved; the AI entry point is not shipped (no model calls from the plugin) |
99
+
100
+ Dangerous behaviour is off by default: no deletion, no resume, no subprocesses,
101
+ no outbound network requests from the plugin.
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ node scripts/build-client.mjs # concatenates src/client into client.js + self-checks
107
+ node --test tests/*.test.mjs # 153 behaviour tests
108
+ node scripts/verify.mjs # contract gate: files, forbidden patterns, i18n parity
109
+ ```
110
+
111
+ The client half is hand-written lazy-CJS (`window.__ModuleLoader__.load`) with no
112
+ bundler; only `react` and the host UI primitives are required from the client
113
+ module table. Host code is plain ESM under `lib/`.
114
+
115
+ ## Attribution
116
+
117
+ Behaviour specifications were modelled on `dsh-archived-sessions` (MIT,
118
+ Zephyr-vibe) and `@linxin666/dsh-usage` (Apache-2.0, linxin666). This is an
119
+ independent implementation: no copied source, no runtime dependency, no access
120
+ to their storage. See [LICENSE](LICENSE) and
121
+ [docs/02-REFERENCE-PROVENANCE.md](docs/02-REFERENCE-PROVENANCE.md).
package/README.zh.md ADDED
@@ -0,0 +1,94 @@
1
+ # dsh-agent-control-center
2
+
3
+ [English](README.md) | [中文](README.zh.md)
4
+
5
+ DeepSeek Harness(DSH)profile 的统一控制台:在一个设置页里编辑并备份 `AGENTS.md`、查看工具、浏览与归档会话、读取真实 token 用量、导出 Agent 元信息、跑系统诊断、应用模板。
6
+
7
+ 目标宿主:DSH `>=0.2.1-rc.1 <0.3.0`(`peerDependencies`:`@deepseek-ai/cordis`)。开发与验证版本:**0.2.2-rc.5**。
8
+
9
+ ## 安装
10
+
11
+ 只用宿主官方插件入口(不要手改 profile):
12
+
13
+ ```bash
14
+ # 从 npm 安装
15
+ dsh plugin --profile web add dsh-agent-control-center
16
+
17
+ # 或本地目录 / 打包安装
18
+ dsh plugin --profile web add /绝对路径/dsh-agent-control-center
19
+ npm pack && dsh plugin --profile web add ./dsh-agent-control-center-0.1.0.tgz
20
+ ```
21
+
22
+ 重启 Web GUI(Host 半区在启动时挂载 HTTP 通道),打开 **设置 → Agent 控制台**。
23
+ 卸载:`dsh plugin --profile web remove dsh-agent-control-center`。
24
+
25
+ ## 功能
26
+
27
+ | 页面 | 能力 | 数据来源 |
28
+ |---|---|---|
29
+ | 总览 | 环境、模块状态、真实计数、页内快捷入口 | 宿主服务 + 兄弟模块摘要 |
30
+ | AGENTS.md | 发现指令链、读取字节/hash/换行/BOM、乐观锁编辑、备份、恢复、差异、11 条确定性校验、预算 | `dsh-agent-instructions` 规则 + 宿主 `fs`(版本守卫) |
31
+ | 工具 | 只读清单 + 三层状态(已注册/对 Agent 可见/历史调用过)+ 错误聚类 + 最近失败 | `ctx.tools` + 会话事件历史 |
32
+ | 会话 | 列表、搜索(标题+ID)、按工作区分组、批量归档/取消归档、行内详情(真实活动统计与谱系) | `sessionQuery`、`workspaceRegistry`、`sessionPersistence` |
33
+ | Agent 信息 | 活跃 Agent、预设、默认模型、脱敏导出、字段级 diff、导入预览 | `agents`、`agentPresets`、`agentDefaultModel` |
34
+ | 使用统计 | 真实 token 口径(输入/缓存读/缓存写/输出/调用次数)、本地日趋势、provider/model 分布、日期选择、保留期 | 会话事件 `assistant/message.usage` + 幂等台账 |
35
+ | 诊断 | 22 项检查(宿主身份/能力/预设/指令链/工具/会话/用量/配置/存储/权限)、Markdown/JSON 导出、仅安全修复 | 宿主服务 + 自有存储 |
36
+ | 模板 | 内置 AGENTS.md/约定/人格/工具配置/诊断清单模板、源码+渲染预览、变量填充、应用前 diff、用户模板 | 随包 JSON + 自有存储(经 AGENTS.md 保存管线应用) |
37
+ | 重启恢复 | 只读检测中断会话(未闭合 turn、结果未知的工具调用)并给证据;**绝不自动继续** | `sessionQuery` + `dsh-session` 修复语义 |
38
+
39
+ ## 有意的限制
40
+
41
+ - **不提供删除会话**:DSH 0.2.2-rc.5 没有公开的会话删除 API,页面隐藏删除并明确说明;归档才是受支持的动作。
42
+ - **不自动续跑**:恢复页只列候选并提示到宿主原生会话界面继续,不注入消息、不追加事件。
43
+ - **不估算费用/不查余额**:没有可信价目与币种,因此不显示金额。
44
+ - **全文搜索可能被禁用**:部署把会话索引配成 `openAt: never` 时,降级为标题/ID 子串并标注。
45
+ - **不写宿主 `settings`/`credentials`**:Agent 信息导入只写自有 state;宿主配置无公开安全写路径时明确报 `not_supported`。
46
+ - **AGENTS.md 只改已发现的链上文件**:不新建文件;写入带版本守卫且先备份。
47
+
48
+ ## 存储与残留
49
+
50
+ 全部在 `$DSH_HOME/dsh-agent-control-center/`(可用 row 的 `storageDir` 覆盖):
51
+
52
+ ```
53
+ state.json 设置 + 忽略项 + 导入记录
54
+ usage-ledger.json 幂等台账(version + 每会话游标)
55
+ backups/<file-key>/ 每次保存前的原文件副本(*.md + *.meta.json)
56
+ templates/ 用户模板
57
+ audit.jsonl 追加式审计(不含文件正文、不含凭据)
58
+ cache/ tmp/ 派生数据,可安全删除
59
+ ```
60
+
61
+ 卸载插件**不会**删除该目录;需要时手动清理。宿主的会话、配置、其它插件存储一律不写。
62
+
63
+ 插件只在用户显式保存指令文件时写到自己的目录之外(写前先备份),且始终经宿主 `fs` 服务、带调用方沙箱策略与版本守卫。
64
+
65
+ ## 配置
66
+
67
+ `cordis.patch.yml` 中 row `agent-control-center`:
68
+
69
+ | 字段 | 默认 | 含义 |
70
+ |---|---|---|
71
+ | `enabled` | `true` | 关闭整个插件(不建通道、不写存储) |
72
+ | `storageDir` | `""` | 绝对存储根;空 = `$DSH_HOME/dsh-agent-control-center` |
73
+ | `exposeDelete` | `false` | 保留位;宿主无删除 API 期间删除始终隐藏 |
74
+ | `maxBackups` | `20` | 每个指令文件保留的备份数 |
75
+ | `usageRetentionDays` | `180` | 台账本地日保留期(7–730) |
76
+ | `usageReplaySessions` | `200` | 冷启动回放的会话数上限 |
77
+ | `usageReplayDays` | `30` | 冷启动回放的天数上限 |
78
+ | `aiAnalysisEnabled` | `false` | 保留位;不随包提供 AI 入口(插件自身不发起模型调用) |
79
+
80
+ 危险行为默认关闭:不删除、不续跑、不起子进程、插件自身不出网。
81
+
82
+ ## 开发
83
+
84
+ ```bash
85
+ node scripts/build-client.mjs # 拼接 src/client 生成 client.js 并自检
86
+ node --test tests/*.test.mjs # 153 条行为测试
87
+ node scripts/verify.mjs # 契约门禁:文件、禁用项、i18n 对齐
88
+ ```
89
+
90
+ 客户端为手写 lazy-CJS(`window.__ModuleLoader__.load`),无打包器;只从客户端模块表 `require('react')` 与宿主 UI 原语。Host 为 `lib/` 下纯 ESM。
91
+
92
+ ## 致谢与来源
93
+
94
+ 行为规格参考了 `dsh-archived-sessions`(MIT,Zephyr-vibe)与 `@linxin666/dsh-usage`(Apache-2.0,linxin666);实现为独立重写,未复制其代码、运行时不依赖、不读写其存储。见 [LICENSE](LICENSE) 与 [docs/02-REFERENCE-PROVENANCE.md](docs/02-REFERENCE-PROVENANCE.md)。