@hcstar/dsh-tool-manage 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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
6
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-12-02
11
+
12
+ ### Added
13
+
14
+ - Standalone repository layout (`src/host`, `src/client`, `src/shared`) with vendored tsup build
15
+ presets and a client-bundle contract checker.
16
+ - A single **Tool manager** panel covering MCP servers, Agent Skills, variables, and the rest of
17
+ the tool registry.
18
+ - Form-based editing of `mcp-manager` entries through the settings service, with live status,
19
+ probe, restart, enable/disable, and per-server glyphs.
20
+ - On-disk Agent Skill discovery, editing, creation, deletion, custom scan roots, and resource
21
+ reading under the built-in and custom skill roots.
22
+ - Named variables with `{{name}}` tokens, credential-store values, and separate human/model
23
+ permissions.
24
+ - An in-Host MCP server exposing `mcp_manage`, `skill_manage`, `skill_roots`,
25
+ `visibility_manage`, `catalog`, and `variable_manage`.
26
+ - Visibility policy v5 with per-server and per-skill Agent-preset injection rules.
27
+ - English and Simplified Chinese documentation, a Keep-a-Changelog release history, and an
28
+ MIT license.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hcstar
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.
package/README.md CHANGED
@@ -1,3 +1,285 @@
1
- # Temporary Holding Version
1
+ # @hcstar/dsh-tool-manage
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.zh-CN.md)
4
+
5
+ [![CI](https://github.com/hstar-7/dsh-tool-manage/actions/workflows/ci.yml/badge.svg)](https://github.com/hstar-7/dsh-tool-manage/actions/workflows/ci.yml)
6
+
7
+ One left-sidebar entry — **Tool manager** — that opens a single panel for everything a Harness
8
+ profile can hand to the model: MCP servers, Agent Skills, named variables, per-resource injection,
9
+ and the rest of the tool registry.
10
+
11
+ The plugin is a management surface, not a marketplace. There is no catalog to browse, no install
12
+ button and no second copy of your configuration: MCP entries are edited as forms over the same
13
+ `mcp-manager` config the settings page writes, and skills are read from and written to the files in
14
+ the global skill roots.
15
+
16
+ ## What the panel does
17
+
18
+ **MCP servers**
19
+
20
+ - Lists every configured server from the `mcp-manager` row and every server a plugin registered.
21
+ - Shows live connection state, tool count and a per-server **Test** (test) action.
22
+ - Each row and detail header carries a text glyph: the server name's first character by default,
23
+ or a short label/emoji set from the detail header. Glyphs live in `policy.json` `icons` and are
24
+ editable by the Agent through `mcp_manage` `set_icon`.
25
+ - Edits the transport (`stdio` or HTTP), command, arguments, working directory, environment, URL,
26
+ headers, timeouts and reconnect policy as a form; cross-transport fields are cleared on save.
27
+ - **Test**, **Restart**, and **Delete** from the header; enable/disable stays on the list switch.
28
+ Disabling closes the connection and unregisters its tools; enabling rebuilds it. Edit actions
29
+ (Reset/Save) appear only after a change and sit to the left of the persistent actions. Saves go
30
+ through the shared settings queue, so the Host validates the entry and rebuilds the connection;
31
+ no restart is needed. Plugin-provided entries are read-only and cannot be disabled here.
32
+ - Lists the tools each connected server contributes (`mcp__<server>__<tool>`), with parameter
33
+ schemas on demand.
34
+ - Any entry string can carry `{{name}}` placeholders: the command/args/cwd/url fields and each
35
+ environment or header row have a **▾** picker inside the field that inserts one at the text caret;
36
+ its menu is as wide as the field. Saving
37
+ rewrites every token whose variable exists into `${credential:NAME}`, so the settings file never
38
+ holds the secret; unknown tokens are left as literal text.
39
+
40
+ **Skills**
41
+
42
+ - Groups skills by root: `DSH 全局` (`$DSH_HOME/skills`, default `~/.dsh/skills`) and
43
+ `共享 Agent` (`$DSH_AGENTS_HOME/skills`, default `~/.agents/skills`), plus custom absolute roots
44
+ added from the gear button beside **New skill** (stored in
45
+ `$DSH_HOME/dsh-tool-manage/skill-roots.json`). Groups collapse; runtime and bundled skills stay
46
+ read-only.
47
+ - Shows a **Basic info** section at the top and a compact **File directory** dock at the bottom;
48
+ the dock's fullscreen button fills the detail area below the title with the complete tree and a
49
+ file viewer. `SKILL.md` can be edited raw; other resources stay read-only.
50
+ - Saving basic info rewrites only the fields this plugin owns (unknown frontmatter keys survive);
51
+ saving raw rewrites the whole `SKILL.md`. Delete sits in the top-right action cluster beside
52
+ Reset/Save; the path footer is gone.
53
+ - Creates a skill in any writable root; the settings panel edits custom scan directories in place.
54
+
55
+ **Variables**
56
+
57
+ - Lists named strings that configuration can reference as `{{name}}`. Each has a label, a
58
+ description, a source (`plugin`, `manual`, or `ai`), and two independent permission sets — one for
59
+ the person at the panel, one for the Agent.
60
+ - Values are **not** stored here: they go to the Harness credential store
61
+ (`$DSH_HOME/.credentials.yaml`, mode 0600). A value the human may read appears as plain text in a
62
+ multiline field (values can be long or span lines); a value it may not read comes back only as
63
+ the provider's mask and the field shows that mask as a placeholder.
64
+ - Per actor, **read** decides whether the value is returned, **write** whether the value and
65
+ metadata may change, and **delete** removal. Defaults: the human may do all three; the Agent may
66
+ write, may not read, may not delete — so it can rotate a secret without seeing it.
67
+ - Deleting a variable leaves already-saved `${credential:NAME}` references in place; the server
68
+ then fails loudly with "credential not configured" instead of silently using nothing.
69
+ - Names are POSIX identifiers because a name doubles as the credential reference; put prose in the
70
+ label.
71
+
72
+ **Other tools**
73
+
74
+ - Lists every non-MCP tool the Host registry exposes: tools shipped with the base composition and
75
+ tools installed plugins register. Nothing needs to be declared for a tool to appear.
76
+ - Shows the model-facing name, description, argument JSON Schema, and which live presets can
77
+ currently see it.
78
+ - Read-only by design: a definition belongs to its plugin or preset composition, so this panel does
79
+ not edit it.
80
+
81
+ ## MCP server
82
+
83
+ The plugin is itself an MCP server. On startup it listens on a random loopback port with the
84
+ Streamable HTTP transport and registers that URL with `mcpManager`, so the panel's **MCP servers**
85
+ tab lists it beside configured servers with live status, a **Plugin** tag, its tools, **Test**, and
86
+ **Restart**. A plugin-provided server is read-only there: the plugin owns its lifetime and
87
+ configuration.
88
+
89
+ Its tools are split by **resource domain**, not by CRUD verb. Each takes an `action` and is called
90
+ as `mcp__dsh-tool-manage__<tool>`; each action declares its own required fields in the input schema:
91
+
92
+ | Tool | Actions |
93
+ | ----------------------------------------- | -------------------------------------------------------------------------------------- |
94
+ | `mcp__dsh-tool-manage__mcp_manage` | `list` `get` `create` `update` `delete` `test` `restart` `enable` `disable` `set_icon` |
95
+ | `mcp__dsh-tool-manage__skill_manage` | `list` `get` `create` `update` `delete` `read_resource` |
96
+ | `mcp__dsh-tool-manage__skill_roots` | `list` `set` |
97
+ | `mcp__dsh-tool-manage__visibility_manage` | `get` `set_mcp_injection` `set_skill_injection` `remove_injection` |
98
+ | `mcp__dsh-tool-manage__catalog` | `tools` `tool` `presets` |
99
+ | `mcp__dsh-tool-manage__variable_manage` | `list` `get` `create` `update` `delete` |
100
+
101
+ The boundaries are deliberate: `mcp_manage` is the only server-config writer; `skill_manage` owns
102
+ files and ignores scan-root configuration; `skill_roots` owns only scan directories;
103
+ `visibility_manage` patches one policy slice at a time and never edits registry definitions;
104
+ `catalog` is strictly read-only; `variable_manage` writes values into the credential store and
105
+ metadata into `variables.json`, acting as the `ai` actor. Destructive actions (`mcp_manage delete`,
106
+ `skill_manage delete`, `variable_manage delete`) require `confirm: true`.
107
+
108
+ The tools read and write the same storage as the panel: skills through the same file functions
109
+ under the configured skill roots, MCP entries through the `mcp-manager` settings row (the manager
110
+ validates the entry and rebuilds the connection, no restart), and the visibility policy through the
111
+ same `policy.json` controller. Nothing is duplicated, so a write from either caller is visible to
112
+ the other immediately. Plugin-registered MCP servers, runtime skills, and tool definitions stay
113
+ read-only.
114
+
115
+ Reads are bounded: `catalog tools` returns names, descriptions, and visible presets; `catalog tool`
116
+ adds one schema. `mcp_manage list` returns statuses and tool names; `mcp_manage get` adds the stored
117
+ entry and per-tool schemas. `skill_manage get` returns the full document because editing requires
118
+ it; `read_resource` is the only way to read a non-`SKILL.md` file.
119
+
120
+ MCP and Skill details each carry an **Agent preset injection** card (the same component). Its
121
+ master switch is the default rule; each preset row can override it. An injection-off MCP preset
122
+ gets a deny mask for every tool under `mcp__<server>__`; an injection-off skill is shadowed by name
123
+ for that preset. This is the only narrowing mechanism left: per-preset tool/skill masks were
124
+ removed (decision D-013, recorded in the upstream repository). MCP rules live in
125
+ `policy.json`'s `mcp` section and Skill rules in `skillInjection` (policy v5), so agents can read
126
+ and change them through `visibility_manage` `get` / `set_*`; `mcp_manage set_icon` holds the MCP
127
+ glyphs. No second endpoint or store (decision D-011).
128
+
129
+ The server runs inside the Host rather than as a stdio child so it can use `ctx.settings`,
130
+ `ctx.mcpManager`, and the live registry. The endpoint is loopback-only with a random path token. The
131
+ tools are ordinary global tools once the MCP client publishes them, so a preset's visibility policy
132
+ applies to them too: masking `mcp__dsh-tool-manage__visibility_manage` removes that management surface from
133
+ the preset (decision D-010).
134
+
135
+ ## Where the data lives
136
+
137
+ | Surface | Owner | Written through |
138
+ | -------------------- | ----------------------------------------------------- | -------------------------------------------------------------- |
139
+ | MCP servers | `mcp-manager` row config | the settings service (`configForms`), with its revision check |
140
+ | Skills | `<root>/<name>/SKILL.md` or `<root>/<name>.md` | this plugin's Host routes, direct to disk |
141
+ | Skill roots | `$DSH_HOME/dsh-tool-manage/skill-roots.json` | this plugin's Host routes, direct to disk |
142
+ | Other tools | Host/plugin tool registry (read-only) | nothing; the panel never writes definitions |
143
+ | Variables (metadata) | `$DSH_HOME/dsh-tool-manage/variables.json` | panel `/dsh-tool-manage/variable/*`; Agent `variable_manage` |
144
+ | Variable values | Harness credential store (`~/.dsh/.credentials.yaml`) | `ctx.credentials` through the same routes/tools |
145
+ | Policy | `$DSH_HOME/dsh-tool-manage/policy.json` (v5) | panel `PUT /dsh-tool-manage/policy`; Agent `visibility_manage` |
146
+
147
+ The Host exposes a small set of JSON routes, all registered with `auth: 'required'`, so the web server admits them before any handler runs:
148
+
149
+ | Route | Method | Purpose |
150
+ | ---------------------------------- | -------- | -------------------------------------------- |
151
+ | `/dsh-tool-manage/skills` | GET | list roots, skills and warnings |
152
+ | `/dsh-tool-manage/skill/read` | POST | read one `SKILL.md` and its resources |
153
+ | `/dsh-tool-manage/skill/save` | POST | rewrite fields, body, or the whole file |
154
+ | `/dsh-tool-manage/skill/create` | POST | create a skill in a writable root |
155
+ | `/dsh-tool-manage/skill/delete` | POST | delete a skill or a flat skill file |
156
+ | `/dsh-tool-manage/skill/roots` | GET/POST | list or replace custom scan directories |
157
+ | `/dsh-tool-manage/skill/resource` | POST | read one resource below a skill directory |
158
+ | `/dsh-tool-manage/mcp/tools` | GET | group visible `mcp__*` tools by server |
159
+ | `/dsh-tool-manage/tools` | GET | list every non-MCP tool with its schema |
160
+ | `/dsh-tool-manage/presets` | GET | list Agent presets and the default one |
161
+ | `/dsh-tool-manage/variables` | GET | list variables with values or provider masks |
162
+ | `/dsh-tool-manage/variable/save` | POST | save metadata, value, or both |
163
+ | `/dsh-tool-manage/variable/delete` | POST | delete metadata and value |
164
+ | `/dsh-tool-manage/policy` | GET/PUT | read or replace the visibility document |
165
+
166
+ Writes are confined to the configured skill roots (built-in and custom). A path is accepted only when it is a skill document
167
+ inside the root, the resolved real path stays inside it, and the file is at most 1 MB. Runtime and
168
+ bundled skills are never writable.
169
+
170
+ ## Build from source
171
+
172
+ This repository is self-contained: it vendors the two tsup build presets (`build/`), the
173
+ TypeScript config (`tsconfig.json`) and the client-bundle checker
174
+ (`scripts/check-client-bundle.mjs`):
175
+
176
+ ```bash
177
+ pnpm install
178
+ pnpm build # writes lib/index.js and lib/client.js
179
+ dsh plugin --profile web add link:$PWD
180
+ ```
181
+
182
+ `pnpm test` runs the Node tests against the freshly built `lib/`, then validates the client bundle
183
+ contract (module id, `apply` export, platform-only requires, injected style tag).
184
+
185
+ ## Install
186
+
187
+ ```bash
188
+ # from a checkout
189
+ dsh plugin --profile web add link:/path/to/dsh-tool-manage
190
+
191
+ # from the packed tarball (any machine running DSH 0.2.x)
192
+ dsh plugin --profile web add /path/to/hcstar-dsh-tool-manage-0.1.0.tgz
193
+ dsh restart
194
+
195
+ # from a registry, once published
196
+ dsh plugin --profile web add @hcstar/dsh-tool-manage
197
+ ```
198
+
199
+ The tarball already contains the built `lib/` halves (`index.js` for the Host and `client.js` for
200
+ the browser) plus `cordis.patch.yml` and `icon.svg`; there is no build step on the target machine.
201
+ The plugin needs the profile's `settings` and `mcp-manager` rows (both part of a normal Web
202
+ profile); the Skills tab works with no extra rows. After installing, restart the Host once so the
203
+ new Host row loads, then open **Tool manager** in the left sidebar.
204
+
205
+ ## Theming and small screens
206
+
207
+ The panel is built only from `--dsw-alias-*` theme tokens, so it follows the light theme, the dark
208
+ theme (`body[data-ds-dark-theme]`) and a custom accent color. Button text is always paired with its
209
+ own surface token rather than a fixed white — in dark mode the primary fill is near-white, so a
210
+ hard-coded white label would disappear.
211
+
212
+ Below 720px the panel switches to a single scrolling column: the master list is capped at 38vh,
213
+ the detail body grows naturally, the save bar sits in normal flow instead of floating over the
214
+ form, and the header gains an explicit close button (`layout.selectPanel(null)`). Create and delete
215
+ dialogs become bottom sheets with a grab handle, a pinned close button and backdrop dismissal.
216
+
217
+ ## Repository layout
218
+
219
+ ```text
220
+ src/host/ Host half: Cordis plugin, HTTP routes, skill files, MCP config,
221
+ variables, visibility policy, and model-facing tools
222
+ src/client/ Browser half: sidebar entry, management panel, locale dictionaries
223
+ src/shared/ Pure contracts and rules imported by both halves
224
+ build/ tsup presets for the Host (ESM) and browser (module-loader) halves
225
+ scripts/ client-bundle contract checker
226
+ test/ Node tests against the built lib/
227
+ ```
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ pnpm build # tsup -> lib/index.js + lib/client.js
233
+ pnpm typecheck # tsc --noEmit
234
+ pnpm test # build, then run the Node tests and the bundle-contract check
235
+ pnpm verify # build + typecheck + test
236
+ ```
237
+
238
+ A browser profile hot-reloads `lib/client.js` on rebuild; Host-side changes need a restart.
239
+
240
+ ## Changelog
241
+
242
+ See [CHANGELOG.md](./CHANGELOG.md) for the release history. The project follows
243
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
244
+
245
+ ## Release
246
+
247
+ Releases are tag-driven: pushing an annotated `vX.Y.Z` tag runs the **Release** workflow, which
248
+ verifies the tree, publishes to npm with OIDC trusted publishing (no stored token), and creates the
249
+ GitHub Release.
250
+
251
+ 1. Move the `## [Unreleased]` entries in `CHANGELOG.md` under `## [X.Y.Z] - YYYY-MM-DD`.
252
+ 2. Bump `version` in `package.json` and run `pnpm verify`.
253
+ 3. Commit, then tag and push:
254
+
255
+ ```bash
256
+ git tag -a vX.Y.Z -m "vX.Y.Z"
257
+ git push origin main --follow-tags
258
+ ```
259
+
260
+ See [docs/releasing.md](./docs/releasing.md) for the tag rules, the one-time trusted-publishing
261
+ bootstrap, and the prerelease (`next`) flow.
262
+
263
+ ## Visibility policy
264
+
265
+ MCP servers connect once on the Host and every session shares the connection. What changes per
266
+ Agent preset is **what the model can see**, and the only narrowing mechanism is per-resource
267
+ injection (per-preset tool/skill masks were removed — see
268
+ decision D-013):
269
+
270
+ - **MCP**: each server has `{ default, presets }`. When a preset turns the server off, the Host
271
+ denies every current `mcp__<server>__*` tool in that Agent with
272
+ `agent.ctx.tools.restrict({ deny })`. The deny list is recomputed from the live registry at Agent
273
+ creation, on `agent-preset/selected` (a mid-session switch), on `tools/change`, and on save, so it
274
+ never contains an unknown or `run_code` name.
275
+ - **Skills**: no deny API exists. The Host registers a same-name shadow inside the Agent's own
276
+ scope with `modelInvocable: false` and `userInvocable: false`; the nearest layer wins, so the
277
+ skill leaves that Agent's model catalog and its body never enters the context.
278
+ - Rules live in `$DSH_HOME/dsh-tool-manage/policy.json` (policy v5; v1/v3/v4 are normalized on read and
279
+ an old `presets` mask section is dropped). Injection saves context and call surface, not
280
+ processes: connections stay open. "Never start this server for that preset" is a composition
281
+ row, not a policy rule.
282
+
283
+ ## License
284
+
285
+ Released under the [MIT License](./LICENSE).
@@ -0,0 +1,255 @@
1
+ # @hcstar/dsh-tool-manage
2
+
3
+ [English](./README.md) | **简体中文**
4
+
5
+ [![CI](https://github.com/hstar-7/dsh-tool-manage/actions/workflows/ci.yml/badge.svg)](https://github.com/hstar-7/dsh-tool-manage/actions/workflows/ci.yml)
6
+
7
+ 左侧栏中的一个入口——**工具管理**——打开一个面板,集中管理 Harness profile 能交给模型的一切:
8
+ MCP 服务、Agent Skills、命名变量、按资源注入,以及工具注册表的其余部分。
9
+
10
+ 这个插件是管理界面,不是应用市场。没有可浏览的目录、没有安装按钮,也不会保存第二份配置:
11
+ MCP 条目以表单形式编辑 settings 页面写入的同一份 `mcp-manager` 配置;Skills 则直接读写全局
12
+ 技能根目录中的文件。
13
+
14
+ ## 面板能力
15
+
16
+ **MCP 服务**
17
+
18
+ - 列出 `mcp-manager` 行中配置的每个服务,以及插件注册的每个服务。
19
+ - 显示实时连接状态、工具数量,以及每个服务的 **测试连接** 操作。
20
+ - 每行和详情标题都带一个文本图标:默认是服务名的首字符,也可以在详情标题中设置短标签或
21
+ emoji。图标保存在 `policy.json` 的 `icons` 中,Agent 可通过 `mcp_manage` 的 `set_icon`
22
+ 编辑。
23
+ - 以表单编辑传输方式(`stdio` 或 HTTP)、命令、参数、工作目录、环境变量、URL、请求头、超时
24
+ 和重连策略;保存时会清空另一种传输方式不使用的字段。
25
+ - 标题栏提供 **测试连接**、**重启** 和 **删除**;启用/禁用保留在列表开关上。禁用会关闭连接并
26
+ 注销其工具;启用会重建连接。编辑操作(重置/保存)只在内容变化后出现,并位于常驻操作左侧。
27
+ 保存经过共享的设置队列,因此 Host 会校验条目并重建连接,无需重启。插件提供的条目只读,
28
+ 不能在此禁用。
29
+ - 列出每个已连接服务贡献的工具(`mcp__<server>__<tool>`),可按需查看参数 schema。
30
+ - 任何条目字符串都可以携带 `{{name}}` 占位符:命令/参数/工作目录/URL 字段,以及每一行环境
31
+ 变量或请求头,都有一个位于输入框内的 **▾** 选择器,在文本光标处插入变量;菜单宽度与输入框
32
+ 一致。保存时,凡是变量存在的 token 都会改写成 `${credential:NAME}`,因此设置文件永远不会
33
+ 保存明文密钥;未知 token 保持为字面文本。
34
+
35
+ **Skills**
36
+
37
+ - 按根目录分组:`DSH 全局`(`$DSH_HOME/skills`,默认 `~/.dsh/skills`)和 `共享 Agent`
38
+ (`$DSH_AGENTS_HOME/skills`,默认 `~/.agents/skills`),以及通过 **新建技能** 旁齿轮按钮
39
+ 添加的自定义绝对根目录(保存在 `$DSH_HOME/dsh-tool-manage/skill-roots.json`)。分组可折叠;
40
+ 运行时技能和内置技能保持只读。
41
+ - 顶部显示 **基本信息**,底部显示紧凑的 **文件目录** 停靠栏;停靠栏的全屏按钮会用完整目录树
42
+ 和文件查看器填满标题下方的详情区域。`SKILL.md` 可以直接编辑原始文本;其他资源保持只读。
43
+ - 保存基本信息只改写本插件拥有的字段(未知 frontmatter 键会保留);保存原始文本会重写整个
44
+ `SKILL.md`。删除按钮位于右上角操作区,与重置/保存并列;路径页脚已移除。
45
+ - 可在任意可写根目录中创建技能;设置面板可就地编辑自定义扫描目录。
46
+
47
+ **变量**
48
+
49
+ - 列出配置中可通过 `{{name}}` 引用的命名字符串。每个变量有标签、描述、来源(`plugin`、
50
+ `manual` 或 `ai`),以及两套独立权限——一套给面板前的人,一套给 Agent。
51
+ - 值**不**保存在这里:它们进入 Harness 凭据存储(`$DSH_HOME/.credentials.yaml`,权限 0600)。
52
+ 人类可读的值以明文显示在多行输入框中(值可能很长或跨行);不可读的值只返回提供方的掩码,
53
+ 输入框把掩码作为占位符显示。
54
+ - 对每个角色,**read** 决定值是否返回,**write** 决定值和元数据是否可改,**delete** 决定是否
55
+ 可删除。默认:人类三项皆可;Agent 可写、不可读、不可删——因此它可以轮换密钥而看不到密钥。
56
+ - 删除变量不会移除已经保存的 `${credential:NAME}` 引用;对应服务随后会以
57
+ “credential not configured” 明确失败,而不是静默使用空值。
58
+ - 变量名是 POSIX 标识符,因为名字同时充当凭据引用;说明性文字请放进标签。
59
+
60
+ **其他工具**
61
+
62
+ - 列出 Host 注册表暴露的每个非 MCP 工具:基础组合内置的工具,以及已安装插件注册的工具。
63
+ 工具无需声明就会出现。
64
+ - 显示模型可见的名称、描述、参数 JSON Schema,以及当前哪些活跃预设能看到它。
65
+ - 设计上只读:定义属于其插件或预设组合,因此面板不编辑它。
66
+
67
+ ## MCP 服务器
68
+
69
+ 插件本身就是一个 MCP 服务器。启动时它在随机回环端口上以 Streamable HTTP 传输监听,并把该 URL
70
+ 注册到 `mcpManager`,因此面板的 **MCP 服务** 标签页会把它列在已配置服务旁边,带实时状态、
71
+ **插件提供** 标记、工具列表、**测试连接** 和 **重启**。插件提供的服务在这里只读:生命周期和
72
+ 配置由插件自己拥有。
73
+
74
+ 它的工具按**资源域**划分,而不是按 CRUD 动词。每个工具接收一个 `action`,调用形式为
75
+ `mcp__dsh-tool-manage__<tool>`;每个 action 在输入 schema 中声明自己的必填字段:
76
+
77
+ | 工具 | Actions |
78
+ | ----------------------------------------- | -------------------------------------------------------------------------------------- |
79
+ | `mcp__dsh-tool-manage__mcp_manage` | `list` `get` `create` `update` `delete` `test` `restart` `enable` `disable` `set_icon` |
80
+ | `mcp__dsh-tool-manage__skill_manage` | `list` `get` `create` `update` `delete` `read_resource` |
81
+ | `mcp__dsh-tool-manage__skill_roots` | `list` `set` |
82
+ | `mcp__dsh-tool-manage__visibility_manage` | `get` `set_mcp_injection` `set_skill_injection` `remove_injection` |
83
+ | `mcp__dsh-tool-manage__catalog` | `tools` `tool` `presets` |
84
+ | `mcp__dsh-tool-manage__variable_manage` | `list` `get` `create` `update` `delete` |
85
+
86
+ 边界是刻意设计的:`mcp_manage` 是唯一的服务配置写入者;`skill_manage` 管理文件,不处理扫描根
87
+ 配置;`skill_roots` 只管理扫描目录;`visibility_manage` 一次只修改一片策略,且从不编辑注册表
88
+ 定义;`catalog` 严格只读;`variable_manage` 以 `ai` 角色把值写入凭据存储、把元数据写入
89
+ `variables.json`。破坏性操作(`mcp_manage delete`、`skill_manage delete`、
90
+ `variable_manage delete`)要求 `confirm: true`。
91
+
92
+ 这些工具与面板读写同一份存储:Skills 通过配置的技能根目录下同一组文件函数;MCP 条目通过
93
+ `mcp-manager` 设置行(管理器校验条目并重建连接,无需重启);可见性策略通过同一个
94
+ `policy.json` 控制器。没有任何复制,因此任一调用方的写入都会立即被另一方看到。插件注册的
95
+ MCP 服务、运行时技能和工具定义保持只读。
96
+
97
+ 读取是有界的:`catalog tools` 返回名称、描述和可见预设;`catalog tool` 额外返回一份 schema。
98
+ `mcp_manage list` 返回状态和工具名;`mcp_manage get` 额外返回已存条目和每个工具的 schema。
99
+ `skill_manage get` 返回完整文档,因为编辑需要它;`read_resource` 是读取非 `SKILL.md` 文件的
100
+ 唯一方式。
101
+
102
+ MCP 和 Skills 详情各带一张 **Agent 预设注入** 卡片(同一个组件)。它的总开关是默认规则;每个
103
+ 预设行可以覆盖。注入关闭的 MCP 预设会得到一条拒绝掩码,覆盖 `mcp__<server>__` 下的所有工具;
104
+ 注入关闭的技能会在该预设中按名称被遮蔽。这是仅存的收窄机制:按预设的工具/技能掩码已被移除
105
+ (决策 D-013,记录在上游仓库)。MCP 规则位于 `policy.json` 的 `mcp` 段,技能规则位于
106
+ `skillInjection`(策略 v5),因此 Agent 可以通过 `visibility_manage` 的 `get` / `set_*` 读取和
107
+ 修改;`mcp_manage set_icon` 保存 MCP 图标。没有第二个端点或存储(决策 D-011)。
108
+
109
+ 服务器运行在 Host 内部,而不是作为 stdio 子进程,因此可以使用 `ctx.settings`、
110
+ `ctx.mcpManager` 和实时注册表。端点是仅回环的,并带随机路径 token。工具一旦被 MCP 客户端发布,
111
+ 就是普通全局工具,因此预设的可见性策略同样作用于它们:遮蔽
112
+ `mcp__dsh-tool-manage__visibility_manage` 就会从该预设移除这个管理入口(决策 D-010)。
113
+
114
+ ## 数据存放位置
115
+
116
+ | 数据面 | 所有者 | 写入方式 |
117
+ | -------------- | ---------------------------------------------- | ------------------------------------------------------------- |
118
+ | MCP 服务 | `mcp-manager` 行配置 | 设置服务(`configForms`),带版本校验 |
119
+ | Skills | `<root>/<name>/SKILL.md` 或 `<root>/<name>.md` | 本插件的 Host 路由,直接写盘 |
120
+ | 技能根目录 | `$DSH_HOME/dsh-tool-manage/skill-roots.json` | 本插件的 Host 路由,直接写盘 |
121
+ | 其他工具 | Host/插件工具注册表(只读) | 无;面板从不写定义 |
122
+ | 变量(元数据) | `$DSH_HOME/dsh-tool-manage/variables.json` | 面板 `/dsh-tool-manage/variable/*`;Agent `variable_manage` |
123
+ | 变量值 | Harness 凭据存储(`~/.dsh/.credentials.yaml`) | `ctx.credentials`,经由同一组路由/工具 |
124
+ | 策略 | `$DSH_HOME/dsh-tool-manage/policy.json`(v5) | 面板 `PUT /dsh-tool-manage/policy`;Agent `visibility_manage` |
125
+
126
+ Host 暴露一小组 JSON 路由,全部以 `auth: 'required'` 注册,因此 Web 服务器会在任何处理函数
127
+ 运行前完成准入:
128
+
129
+ | 路由 | 方法 | 用途 |
130
+ | ---------------------------------- | -------- | ------------------------------ |
131
+ | `/dsh-tool-manage/skills` | GET | 列出根目录、技能和警告 |
132
+ | `/dsh-tool-manage/skill/read` | POST | 读取一个 `SKILL.md` 及其资源 |
133
+ | `/dsh-tool-manage/skill/save` | POST | 改写字段、正文或整个文件 |
134
+ | `/dsh-tool-manage/skill/create` | POST | 在可写根目录中创建技能 |
135
+ | `/dsh-tool-manage/skill/delete` | POST | 删除一个技能或扁平技能文件 |
136
+ | `/dsh-tool-manage/skill/roots` | GET/POST | 列出或替换自定义扫描目录 |
137
+ | `/dsh-tool-manage/skill/resource` | POST | 读取技能目录下的一个资源 |
138
+ | `/dsh-tool-manage/mcp/tools` | GET | 按服务分组可见的 `mcp__*` 工具 |
139
+ | `/dsh-tool-manage/tools` | GET | 列出每个非 MCP 工具及其 schema |
140
+ | `/dsh-tool-manage/presets` | GET | 列出 Agent 预设和默认预设 |
141
+ | `/dsh-tool-manage/variables` | GET | 列出变量及其值或提供方掩码 |
142
+ | `/dsh-tool-manage/variable/save` | POST | 保存元数据、值,或两者 |
143
+ | `/dsh-tool-manage/variable/delete` | POST | 删除元数据和值 |
144
+ | `/dsh-tool-manage/policy` | GET/PUT | 读取或替换可见性文档 |
145
+
146
+ 写入被限制在配置的技能根目录(内置和自定义)内。只有满足以下条件的路径才会被接受:它是根目录
147
+ 内的技能文档,解析后的真实路径仍在根目录内,且文件不超过 1 MB。运行时技能和内置技能永远不可写。
148
+
149
+ ## 从源码构建
150
+
151
+ 本仓库是自包含的:它内置了两套 tsup 构建预设(`build/`)、TypeScript 配置
152
+ (`tsconfig.json`)和客户端 bundle 校验器(`scripts/check-client-bundle.mjs`):
153
+
154
+ ```bash
155
+ pnpm install
156
+ pnpm build # 写出 lib/index.js 和 lib/client.js
157
+ dsh plugin --profile web add link:$PWD
158
+ ```
159
+
160
+ `pnpm test` 会针对刚构建好的 `lib/` 运行 Node 测试,然后校验客户端 bundle 契约(模块 id、
161
+ `apply` 导出、仅平台模块 require、注入的 style 标签)。
162
+
163
+ ## 安装
164
+
165
+ ```bash
166
+ # 从本地 checkout
167
+ dsh plugin --profile web add link:/path/to/dsh-tool-manage
168
+
169
+ # 从打包好的 tarball(任何运行 DSH 0.2.x 的机器)
170
+ dsh plugin --profile web add /path/to/hcstar-dsh-tool-manage-0.1.0.tgz
171
+ dsh restart
172
+
173
+ # 发布到 registry 之后
174
+ dsh plugin --profile web add @hcstar/dsh-tool-manage
175
+ ```
176
+
177
+ tarball 已包含构建好的 `lib/` 两半(Host 的 `index.js` 和浏览器的 `client.js`),以及
178
+ `cordis.patch.yml` 和 `icon.svg`;目标机器上无需构建步骤。插件需要 profile 的 `settings` 和
179
+ `mcp-manager` 行(普通 Web profile 都具备);Skills 标签页无需额外行即可工作。安装后重启 Host
180
+ 一次以加载新的 Host 行,然后在左侧栏打开 **工具管理**。
181
+
182
+ ## 主题与小屏
183
+
184
+ 面板只使用 `--dsw-alias-*` 主题 token,因此能跟随亮色主题、暗色主题(`body[data-ds-dark-theme]`)
185
+ 和自定义强调色。按钮文字始终搭配自己的表面 token,而不是固定白色——暗色模式下主填充接近白色,
186
+ 硬编码的白色文字会消失。
187
+
188
+ 低于 720px 时,面板切换为单列滚动:主列表最高 38vh,详情正文自然增长,保存栏回到正常文档流而
189
+ 不是浮在表单上,标题栏新增显式关闭按钮(`layout.selectPanel(null)`)。创建和删除对话框变成
190
+ 底部抽屉,带抓手、固定的关闭按钮,并支持点击背景关闭。
191
+
192
+ ## 仓库结构
193
+
194
+ ```text
195
+ src/host/ Host 半边:Cordis 插件、HTTP 路由、技能文件、MCP 配置、
196
+ 变量、可见性策略和面向模型的工具
197
+ src/client/ 浏览器半边:侧栏入口、管理面板、语言包
198
+ src/shared/ 两侧共用的纯契约与规则
199
+ build/ Host(ESM)和浏览器(module-loader)两半的 tsup 预设
200
+ scripts/ client bundle 契约校验器
201
+ test/ 针对构建产物 lib/ 的 Node 测试
202
+ ```
203
+
204
+ ## 开发
205
+
206
+ ```bash
207
+ pnpm build # tsup -> lib/index.js + lib/client.js
208
+ pnpm typecheck # tsc --noEmit
209
+ pnpm test # 构建,然后运行 Node 测试和 bundle 契约校验
210
+ pnpm verify # build + typecheck + test
211
+ ```
212
+
213
+ 浏览器 profile 会在重新构建后热重载 `lib/client.js`;Host 侧的改动需要重启。
214
+
215
+ ## 更新日志
216
+
217
+ 发布历史见 [CHANGELOG.md](./CHANGELOG.md)。项目遵循
218
+ [语义化版本](https://semver.org/lang/zh-CN/)。
219
+
220
+ ## 发布
221
+
222
+ 发布由 tag 驱动:推送带注释的 `vX.Y.Z` tag 会触发 **Release** 工作流,校验代码、通过 OIDC
223
+ Trusted Publishing 发布到 npm(不保存长期 token),并创建 GitHub Release。
224
+
225
+ 1. 把 `CHANGELOG.md` 中 `## [Unreleased]` 的内容移到 `## [X.Y.Z] - YYYY-MM-DD` 下。
226
+ 2. 更新 `package.json` 的 `version`,然后运行 `pnpm verify`。
227
+ 3. 提交后创建 tag 并推送:
228
+
229
+ ```bash
230
+ git tag -a vX.Y.Z -m "vX.Y.Z"
231
+ git push origin main --follow-tags
232
+ ```
233
+
234
+ tag 命名规则、Trusted Publishing 的一次性引导和预发布(`next`)流程见
235
+ [docs/releasing.md](./docs/releasing.md)。
236
+
237
+ ## 可见性策略
238
+
239
+ MCP 服务器在 Host 上只连接一次,所有会话共享该连接。按 Agent 预设变化的是**模型能看到什么**,
240
+ 唯一的收窄机制是按资源注入(按预设的工具/技能掩码已被移除——见决策 D-013):
241
+
242
+ - **MCP**:每个服务器有 `{ default, presets }`。当某个预设关闭该服务器时,Host 会用
243
+ `agent.ctx.tools.restrict({ deny })` 拒绝该 Agent 中所有当前 `mcp__<server>__*` 工具。拒绝
244
+ 列表会在 Agent 创建、`agent-preset/selected`(会话中切换)、`tools/change` 和保存时根据实时
245
+ 注册表重新计算,因此永远不会包含未知名称或 `run_code`。
246
+ - **Skills**:不存在 deny API。Host 会在 Agent 自己的作用域内注册一个同名遮蔽,设置
247
+ `modelInvocable: false` 和 `userInvocable: false`;最近一层生效,因此该技能会离开该 Agent 的
248
+ 模型目录,其正文也不会进入上下文。
249
+ - 规则位于 `$DSH_HOME/dsh-tool-manage/policy.json`(策略 v5;v1/v3/v4 读取时会归一化,旧的
250
+ `presets` 掩码段会被丢弃)。注入节省的是上下文和调用面,不是进程:连接保持打开。“永远不要
251
+ 为该预设启动这个服务器”是组合行的问题,不是策略规则。
252
+
253
+ ## 许可证
254
+
255
+ 以 [MIT 许可证](./LICENSE) 发布。
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-tool-manage
3
+ name: '@hcstar/dsh-tool-manage'
package/icon.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
2
+ <path d="M4 7h7.5M17.5 7H20M4 12h2.5M12.5 12H20M4 17h9.5M19.5 17H20" />
3
+ <circle cx="14.5" cy="7" r="3" />
4
+ <circle cx="9.5" cy="12" r="3" />
5
+ <circle cx="16.5" cy="17" r="3" />
6
+ </svg>