dsh-tool-manage
by hstar-7
README.md
# @hcstar/dsh-tool-manage
**English** | [简体中文](./README.zh-CN.md)
[](https://github.com/hstar-7/dsh-tool-manage/actions/workflows/ci.yml)
One left-sidebar entry — **Tool manager** — that opens a single panel for everything a Harness
profile can hand to the model: MCP servers, Agent Skills, named variables, per-resource injection,
and the rest of the tool registry.
The plugin is a management surface, not a marketplace. There is no catalog to browse, no install
button and no second copy of your configuration: MCP entries are edited as forms over the same
`mcp-manager` config the settings page writes, and skills are read from and written to the files in
the global skill roots.
## What the panel does
**MCP servers**
- Lists every configured server from the `mcp-manager` row and every server a plugin registered.
- Shows live connection state, tool count and a per-server **Test** (test) action.
- Each row and detail header carries a text glyph: the server name's first character by default,
or a short label/emoji set from the detail header. Glyphs live in `policy.json` `icons` and are
editable by the Agent through `mcp_manage` `set_icon`.
- Edits the transport (`stdio` or HTTP), command, arguments, working directory, environment, URL,
headers, timeouts and reconnect policy as a form; cross-transport fields are cleared on save.
- **Test**, **Restart**, and **Delete** from the header; enable/disable stays on the list switch.
Disabling closes the connection and unregisters its tools; enabling rebuilds it. Edit actions
(Reset/Save) appear only after a change and sit to the left of the persistent actions. Saves go
through the shared settings queue, so the Host validates the entry and rebuilds the connection;
no restart is needed. Plugin-provided entries are read-only and cannot be disabled here.
- Lists the tools each connected server contributes (`mcp__<server>__<tool>`), with parameter
schemas on demand.
- Any entry string can carry `{{name}}` placeholders: the command/args/cwd/url fields and each
environment or header row have a **▾** picker inside the field that inserts one at the text caret;
its menu is as wide as the field. Saving
rewrites every token whose variable exists into `${credential:NAME}`, so the settings file never
holds the secret; unknown tokens are left as literal text.
**Skills**
- Groups skills by root: `DSH 全局` (`$DSH_HOME/skills`, default `~/.dsh/skills`) and
`共享 Agent` (`$DSH_AGENTS_HOME/skills`, default `~/.agents/skills`), plus custom absolute roots
added from the gear button beside **New skill** (stored in
`$DSH_HOME/dsh-tool-manage/skill-roots.json`). Groups collapse; runtime and bundled skills stay
read-only.
- Shows a **Basic info** section at the top and a compact **File directory** dock at the bottom;
the dock's fullscreen button fills the detail area below the title with the complete tree and a
file viewer. `SKILL.md` can be edited raw; other resources stay read-only.
- Saving basic info rewrites only the fields this plugin owns (unknown frontmatter keys survive);
saving raw rewrites the whole `SKILL.md`. Delete sits in the top-right action cluster beside
Reset/Save; the path footer is gone.
- Creates a skill in any writable root; the settings panel edits custom scan directories in place.
**Variables**
- Lists named strings that configuration can reference as `{{name}}`. Each has a label, a
description, a source (`plugin`, `manual`, or `ai`), and two independent permission sets — one for
the person at the panel, one for the Agent.
- Values are **not** stored here: they go to the Harness credential store
(`$DSH_HOME/.credentials.yaml`, mode 0600). A value the human may read appears as plain text in a
multiline field (values can be long or span lines); a value it may not read comes back only as
the provider's mask and the field shows that mask as a placeholder.
- Per actor, **read** decides whether the value is returned, **write** whether the value and
metadata may change, and **delete** removal. Defaults: the human may do all three; the Agent may
write, may not read, may not delete — so it can rotate a secret without seeing it.
- Deleting a variable leaves already-saved `${credential:NAME}` references in place; the server
then fails loudly with "credential not configured" instead of silently using nothing.
- Names are POSIX identifiers because a name doubles as the credential reference; put prose in the
label.
**Other tools**
- Lists every non-MCP tool the Host registry exposes: tools shipped with the base composition and
tools installed plugins register. Nothing needs to be declared for a tool to appear.
- Shows the model-facing name, description, argument JSON Schema, and which live presets can
currently see it.
- Read-only by design: a definition belongs to its plugin or preset composition, so this panel does
not edit it.
## MCP server
The plugin is itself an MCP server. On startup it listens on a random loopback port with the
Streamable HTTP transport and registers that URL with `mcpManager`, so the panel's **MCP servers**
tab lists it beside configured servers with live status, a **Plugin** tag, its tools, **Test**, and
**Restart**. A plugin-provided server is read-only there: the plugin owns its lifetime and
configuration.
Its tools are split by **resource domain**, not by CRUD verb. Each takes an `action` and is called
as `mcp__dsh-tool-manage__<tool>`; each action declares its own required fields in the input schema:
| Tool | Actions |
| ----------------------------------------- | -------------------------------------------------------------------------------------- |
| `mcp__dsh-tool-manage__mcp_manage` | `list` `get` `create` `update` `delete` `test` `restart` `enable` `disable` `set_icon` |
| `mcp__dsh-tool-manage__skill_manage` | `list` `get` `create` `update` `delete` `read_resource` |
| `mcp__dsh-tool-manage__skill_roots` | `list` `set` |
| `mcp__dsh-tool-manage__visibility_manage` | `get` `set_mcp_injection` `set_skill_injection` `remove_injection` |
| `mcp__dsh-tool-manage__catalog` | `tools` `tool` `presets` |
| `mcp__dsh-tool-manage__variable_manage` | `list` `get` `create` `update` `delete` |
The boundaries are deliberate: `mcp_manage` is the only server-config writer; `skill_manage` owns
files and ignores scan-root configuration; `skill_roots` owns only scan directories;
`visibility_manage` patches one policy slice at a time and never edits registry definitions;
`catalog` is strictly read-only; `variable_manage` writes values into the credential store and
metadata into `variables.json`, acting as the `ai` actor. Destructive actions (`mcp_manage delete`,
`skill_manage delete`, `variable_manage delete`) require `confirm: true`.
The tools read and write the same storage as the panel: skills through the same file functions
under the configured skill roots, MCP entries through the `mcp-manager` settings row (the manager
validates the entry and rebuilds the connection, no restart), and the visibility policy through the
same `policy.json` controller. Nothing is duplicated, so a write from either caller is visible to
the other immediately. Plugin-registered MCP servers, runtime skills, and tool definitions stay
read-only.
Reads are bounded: `catalog tools` returns names, descriptions, and visible presets; `catalog tool`
adds one schema. `mcp_manage list` returns statuses and tool names; `mcp_manage get` adds the stored
entry and per-tool schemas. `skill_manage get` returns the full document because editing requires
it; `read_resource` is the only way to read a non-`SKILL.md` file.
MCP and Skill details each carry an **Agent preset injection** card (the same component). Its
master switch is the default rule; each preset row can override it. An injection-off MCP preset
gets a deny mask for every tool under `mcp__<server>__`; an injection-off skill is shadowed by name
for that preset. This is the only narrowing mechanism left: per-preset tool/skill masks were
removed (decision D-013, recorded in the upstream repository). MCP rules live in
`policy.json`'s `mcp` section and Skill rules in `skillInjection` (policy v5), so agents can read
and change them through `visibility_manage` `get` / `set_*`; `mcp_manage set_icon` holds the MCP
glyphs. No second endpoint or store (decision D-011).
The server runs inside the Host rather than as a stdio child so it can use `ctx.settings`,
`ctx.mcpManager`, and the live registry. The endpoint is loopback-only with a random path token. The
tools are ordinary global tools once the MCP client publishes them, so a preset's visibility policy
applies to them too: masking `mcp__dsh-tool-manage__visibility_manage` removes that management surface from
the preset (decision D-010).
## Where the data lives
| Surface | Owner | Written through |
| -------------------- | ----------------------------------------------------- | -------------------------------------------------------------- |
| MCP servers | `mcp-manager` row config | the settings service (`configForms`), with its revision check |
| Skills | `<root>/<name>/SKILL.md` or `<root>/<name>.md` | this plugin's Host routes, direct to disk |
| Skill roots | `$DSH_HOME/dsh-tool-manage/skill-roots.json` | this plugin's Host routes, direct to disk |
| Other tools | Host/plugin tool registry (read-only) | nothing; the panel never writes definitions |
| Variables (metadata) | `$DSH_HOME/dsh-tool-manage/variables.json` | panel `/dsh-tool-manage/variable/*`; Agent `variable_manage` |
| Variable values | Harness credential store (`~/.dsh/.credentials.yaml`) | `ctx.credentials` through the same routes/tools |
| Policy | `$DSH_HOME/dsh-tool-manage/policy.json` (v5) | panel `PUT /dsh-tool-manage/policy`; Agent `visibility_manage` |
The Host exposes a small set of JSON routes, all registered with `auth: 'required'`, so the web server admits them before any handler runs:
| Route | Method | Purpose |
| ---------------------------------- | -------- | -------------------------------------------- |
| `/dsh-tool-manage/skills` | GET | list roots, skills and warnings |
| `/dsh-tool-manage/skill/read` | POST | read one `SKILL.md` and its resources |
| `/dsh-tool-manage/skill/save` | POST | rewrite fields, body, or the whole file |
| `/dsh-tool-manage/skill/create` | POST | create a skill in a writable root |
| `/dsh-tool-manage/skill/delete` | POST | delete a skill or a flat skill file |
| `/dsh-tool-manage/skill/roots` | GET/POST | list or replace custom scan directories |
| `/dsh-tool-manage/skill/resource` | POST | read one resource below a skill directory |
| `/dsh-tool-manage/mcp/tools` | GET | group visible `mcp__*` tools by server |
| `/dsh-tool-manage/tools` | GET | list every non-MCP tool with its schema |
| `/dsh-tool-manage/presets` | GET | list Agent presets and the default one |
| `/dsh-tool-manage/variables` | GET | list variables with values or provider masks |
| `/dsh-tool-manage/variable/save` | POST | save metadata, value, or both |
| `/dsh-tool-manage/variable/delete` | POST | delete metadata and value |
| `/dsh-tool-manage/policy` | GET/PUT | read or replace the visibility document |
Writes are confined to the configured skill roots (built-in and custom). A path is accepted only when it is a skill document
inside the root, the resolved real path stays inside it, and the file is at most 1 MB. Runtime and
bundled skills are never writable.
## Build from source
This repository is self-contained: it vendors the two tsup build presets (`build/`), the
TypeScript config (`tsconfig.json`) and the client-bundle checker
(`scripts/check-client-bundle.mjs`):
```bash
pnpm install
pnpm build # writes lib/index.js and lib/client.js
dsh plugin --profile web add link:$PWD
```
`pnpm test` runs the Node tests against the freshly built `lib/`, then validates the client bundle
contract (module id, `apply` export, platform-only requires, injected style tag).
## Install
```bash
# from a checkout
dsh plugin --profile web add link:/path/to/dsh-tool-manage
# from the packed tarball (any machine running DSH 0.2.x)
dsh plugin --profile web add /path/to/hcstar-dsh-tool-manage-0.1.0.tgz
dsh restart
# from a registry, once published
dsh plugin --profile web add @hcstar/dsh-tool-manage
```
The tarball already contains the built `lib/` halves (`index.js` for the Host and `client.js` for
the browser) plus `cordis.patch.yml` and `icon.svg`; there is no build step on the target machine.
The plugin needs the profile's `settings` and `mcp-manager` rows (both part of a normal Web
profile); the Skills tab works with no extra rows. After installing, restart the Host once so the
new Host row loads, then open **Tool manager** in the left sidebar.
## Theming and small screens
The panel is built only from `--dsw-alias-*` theme tokens, so it follows the light theme, the dark
theme (`body[data-ds-dark-theme]`) and a custom accent color. Button text is always paired with its
own surface token rather than a fixed white — in dark mode the primary fill is near-white, so a
hard-coded white label would disappear.
Below 720px the panel switches to a single scrolling column: the master list is capped at 38vh,
the detail body grows naturally, the save bar sits in normal flow instead of floating over the
form, and the header gains an explicit close button (`layout.selectPanel(null)`). Create and delete
dialogs become bottom sheets with a grab handle, a pinned close button and backdrop dismissal.
## Repository layout
```text
src/host/ Host half: Cordis plugin, HTTP routes, skill files, MCP config,
variables, visibility policy, and model-facing tools
src/client/ Browser half: sidebar entry, management panel, locale dictionaries
src/shared/ Pure contracts and rules imported by both halves
build/ tsup presets for the Host (ESM) and browser (module-loader) halves
scripts/ client-bundle contract checker
test/ Node tests against the built lib/
```
## Development
```bash
pnpm build # tsup -> lib/index.js + lib/client.js
pnpm typecheck # tsc --noEmit
pnpm test # build, then run the Node tests and the bundle-contract check
pnpm verify # build + typecheck + test
```
A browser profile hot-reloads `lib/client.js` on rebuild; Host-side changes need a restart.
## Changelog
See [CHANGELOG.md](./CHANGELOG.md) for the release history. The project follows
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Release
Releases are tag-driven: pushing an annotated `vX.Y.Z` tag runs the **Release** workflow, which
verifies the tree, publishes to npm with OIDC trusted publishing (no stored token), and creates the
GitHub Release.
1. Move the `## [Unreleased]` entries in `CHANGELOG.md` under `## [X.Y.Z] - YYYY-MM-DD`.
2. Bump `version` in `package.json` and run `pnpm verify`.
3. Commit, then tag and push:
```bash
git tag -a vX.Y.Z -m "vX.Y.Z"
git push origin main --follow-tags
```
See [docs/releasing.md](./docs/releasing.md) for the tag rules, the one-time trusted-publishing
bootstrap, and the prerelease (`next`) flow.
## Visibility policy
MCP servers connect once on the Host and every session shares the connection. What changes per
Agent preset is **what the model can see**, and the only narrowing mechanism is per-resource
injection (per-preset tool/skill masks were removed — see
decision D-013):
- **MCP**: each server has `{ default, presets }`. When a preset turns the server off, the Host
denies every current `mcp__<server>__*` tool in that Agent with
`agent.ctx.tools.restrict({ deny })`. The deny list is recomputed from the live registry at Agent
creation, on `agent-preset/selected` (a mid-session switch), on `tools/change`, and on save, so it
never contains an unknown or `run_code` name.
- **Skills**: no deny API exists. The Host registers a same-name shadow inside the Agent's own
scope with `modelInvocable: false` and `userInvocable: false`; the nearest layer wins, so the
skill leaves that Agent's model catalog and its body never enters the context.
- Rules live in `$DSH_HOME/dsh-tool-manage/policy.json` (policy v5; v1/v3/v4 are normalized on read and
an old `presets` mask section is dropped). Injection saves context and call surface, not
processes: connections stay open. "Never start this server for that preset" is a composition
row, not a policy rule.
## License
Released under the [MIT License](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues