dsh-dbhub-live 3.1.2 → 4.0.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/AGENTS.md +114 -96
- package/README.en.md +164 -161
- package/README.md +164 -161
- package/doc/REQUIREMENTS.md +59 -65
- package/lib/adhoc.mjs +46 -23
- package/lib/client.js +226 -38
- package/lib/config.mjs +117 -32
- package/lib/i18n.mjs +70 -32
- package/lib/index.mjs +192 -118
- package/lib/mcp.mjs +244 -462
- package/lib/options.mjs +1 -5
- package/lib/runtime.mjs +0 -35
- package/lib/state.mjs +23 -13
- package/lib/tools.mjs +557 -461
- package/package.json +2 -2
- package/test/client-format.test.mjs +9 -1
- package/test/i18n.test.mjs +12 -2
- package/test/init.test.mjs +2 -2
- package/test/options.test.mjs +5 -7
- package/test/resolve-source.test.mjs +82 -0
- package/test/state.test.mjs +5 -5
- package/test/util.test.mjs +123 -95
- package/test/zero-knowledge.test.mjs +79 -0
- package/test/adhoc.test.mjs +0 -29
package/README.en.md
CHANGED
|
@@ -1,162 +1,165 @@
|
|
|
1
|
-
# dsh-dbhub-live
|
|
2
|
-
|
|
3
|
-
[简体中文](README.md) | English
|
|
4
|
-
|
|
5
|
-
> Let [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/DeepSeek-Harness) operate databases directly and safely:
|
|
6
|
-
|
|
7
|
-
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
[](#installation)
|
|
9
|
-
[](https://github.com/bytebase/dbhub)
|
|
10
|
-
[](https://www.npmjs.com/package/dsh-dbhub-live)
|
|
11
|
-
[](https://dsh-plugin.org/plugins/mr-mihu/dsh-dbhub-live)
|
|
12
|
-
|
|
13
|
-
`dsh-dbhub-live` is a DSH plugin built on [DBHub](https://dbhub.ai) (a database MCP server) that lets the model query databases directly:
|
|
14
|
-
|
|
15
|
-
## ✨ Features
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
## Supported Data Sources
|
|
27
|
-
|
|
28
|
-
MySQL · PostgreSQL · MariaDB · SQLite · SQL Server
|
|
29
|
-
|
|
30
|
-
## Requirements
|
|
31
|
-
|
|
32
|
-
- DeepSeek Harness's `dsh` CLI (`dsh web` runs the GUI)
|
|
33
|
-
- Node.js ≥ 18 with `npm` recommended — `dbhub` is auto-installed on first use
|
|
34
|
-
|
|
35
|
-
## Installation
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# Option 1: use a locally installed dsh
|
|
39
|
-
dsh plugin --profile web add dsh-dbhub-live
|
|
40
|
-
|
|
41
|
-
# Option 2: invoke dsh via npx (no global dsh installation required)
|
|
42
|
-
npx @deepseek-ai/dsh plugin --profile web add dsh-dbhub-live
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
- `
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- **
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
# dsh-dbhub-live
|
|
2
|
+
|
|
3
|
+
[简体中文](README.md) | English
|
|
4
|
+
|
|
5
|
+
> Let [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/DeepSeek-Harness) operate databases directly and safely: **zero-knowledge credentials** (passwords never reach the model) + **one-shot process execution** (no resident server — naturally concurrent and multi-instance safe) + workspace × environment connection management + a browser status card.
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](#installation)
|
|
9
|
+
[](https://github.com/bytebase/dbhub)
|
|
10
|
+
[](https://www.npmjs.com/package/dsh-dbhub-live)
|
|
11
|
+
[](https://dsh-plugin.org/plugins/mr-mihu/dsh-dbhub-live)
|
|
12
|
+
|
|
13
|
+
`dsh-dbhub-live` is a DSH plugin built on [DBHub](https://dbhub.ai) (a database MCP server) that lets the model query databases directly: the model only says *which workspace/environment* to query, and the plugin resolves the real connection host-side and executes it — **passwords and DSNs never appear anywhere the model can see**. Every call is an independent throwaway dbhub process, killed right after the call.
|
|
14
|
+
|
|
15
|
+
## ✨ Features
|
|
16
|
+
|
|
17
|
+
- **Zero-knowledge credentials** — the model only ever sees `source` handles and metadata (type / host / port / database); passwords, usernames and full DSNs exist only host-side; entering/changing a password happens **in the UI**, never through the model.
|
|
18
|
+
- **One-shot process execution** — no resident dbhub service: each call spawns an independent process and recycles it when done. A hung/failed query only affects its own call; parallel tasks and multiple DSH instances running at once never interfere (no shared ports, no cross-kills).
|
|
19
|
+
- **Constant 4 tool declarations** — `dbhub_configure` / `dbhub_list_sources` / `dbhub_execute_sql` / `dbhub_search_objects`; more environments never inflate the model context.
|
|
20
|
+
- **Workspace × environment connection management** — one workspace can hold multiple environments (default / prod / dev / test…) distinguished by their `source` value.
|
|
21
|
+
- **Auth-failure loop** — when credentials or connection details are wrong, the tool gives clear guidance; the model steers you to update the password in the UI (it never asks you for it), or you edit it directly in the settings card.
|
|
22
|
+
- **Enable / disable switch** — turning it off makes every dbhub tool return a friendly "plugin disabled" message immediately; no restart needed.
|
|
23
|
+
- **Browser status card** — Settings → Plugins → dsh-dbhub-live shows live: status badge, mode (one-shot), registered tool count, environment count, recent error, plus the enable/disable switch, connection CRUD and connection tests.
|
|
24
|
+
- **Out of the box** — if `dbhub` is missing, the plugin installs it on first use and keeps it updated at your configured interval.
|
|
25
|
+
|
|
26
|
+
## Supported Data Sources
|
|
27
|
+
|
|
28
|
+
MySQL · PostgreSQL · MariaDB · SQLite · SQL Server
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- DeepSeek Harness's `dsh` CLI (`dsh web` runs the GUI)
|
|
33
|
+
- Node.js ≥ 18 with `npm` recommended — `dbhub` is auto-installed on first use
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Option 1: use a locally installed dsh
|
|
39
|
+
dsh plugin --profile web add dsh-dbhub-live
|
|
40
|
+
|
|
41
|
+
# Option 2: invoke dsh via npx (no global dsh installation required)
|
|
42
|
+
npx @deepseek-ai/dsh plugin --profile web add dsh-dbhub-live
|
|
43
|
+
|
|
44
|
+
# Update to a specific version (pin the currently published version so pnpm doesn't skip with "Already up to date")
|
|
45
|
+
dsh plugin --profile web update dsh-dbhub-live@4.0.0
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
After installing, **restart `dsh web`** for it to take effect (you can then see the status card at Settings → Plugins → dsh-dbhub-live).
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
The tools below are invoked automatically by DSH's AI — you don't run them by hand; just state your request in natural language (e.g., "look up the users table"):
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
# 1) If the current workspace has no connection yet, the AI guides configuration (password is entered in the UI, the AI never sees it)
|
|
56
|
+
dbhub_configure
|
|
57
|
+
|
|
58
|
+
# 2) Run a query on a configured connection (source comes from dbhub_list_sources)
|
|
59
|
+
dbhub_execute_sql source=myapp sql="SELECT * FROM users LIMIT 10;"
|
|
60
|
+
|
|
61
|
+
# 3) List registered connections and their source values
|
|
62
|
+
dbhub_list_sources
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Tools
|
|
66
|
+
|
|
67
|
+
| Tool | Description |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `dbhub_configure(workspace?, env?, type?, host?, port?, database?, user?)` | Configure/persist a workspace connection. **Does NOT accept a dsn argument** — the password/DSN is always entered in the UI (never through the model); type/host/port/database/user may be passed as non-sensitive prefills. |
|
|
70
|
+
| `dbhub_list_sources()` | List every connection source (workspace × environment): metadata only (type/host/port/database) + origin badge + the corresponding **source** value. |
|
|
71
|
+
| `dbhub_execute_sql(source, sql)` | Execute SQL on a source; `source` comes from `dbhub_list_sources` (the default environment has no suffix; named environments look like `…_test`). Each call is an independent one-shot connection; multiple statements separated by `;`. |
|
|
72
|
+
| `dbhub_search_objects(source, object_type, ...)` | Search database objects (tables/views/columns/indexes, etc.) on a given source. |
|
|
73
|
+
|
|
74
|
+
> **Security**: the model can never obtain a password through this plugin — results and lists only show metadata like `mysql://host:3306/db`; dbhub's error text is scrubbed before it is returned. On a failing query, follow the hint and update the password in the UI.
|
|
75
|
+
|
|
76
|
+
> Note: `search_objects` works only for SQLite; for MySQL / PostgreSQL etc. use `dbhub_execute_sql` directly (e.g., `SHOW TABLES`).
|
|
77
|
+
|
|
78
|
+
### Configuration Methods
|
|
79
|
+
|
|
80
|
+
1. **Explicit DSN** — enter a full connection string in the UI, e.g. `mysql://user:pass@host:3306/db`.
|
|
81
|
+
2. **Fill in fields** — fill type / host / port / user / password / database name in the UI.
|
|
82
|
+
3. **Authorized scan** — after authorization, scan project config files (`.env`, `application*.yml`, `docker-compose`, `jdbc.properties`, etc.) and list candidates (host/port/database only — passwords are read host-side and never shown) for you to confirm.
|
|
83
|
+
|
|
84
|
+
If a workspace already has `mise env` or `.env` (`DSN` / `DB_*`), the plugin discovers it automatically — no manual configuration needed.
|
|
85
|
+
|
|
86
|
+
## Status Card
|
|
87
|
+
|
|
88
|
+
Settings → Plugins → dsh-dbhub-live: the plugin syncs its state and configuration to the Web settings panel in real time (only visible on the `dsh web` side). The card uses the **single-row collapsible** style (consistent with the other plugin settings cards):
|
|
89
|
+
|
|
90
|
+
> All card copy (name, status, config fields, buttons, connection rows) follows the dsh UI language (Chinese / English — Settings → General → Language); model-facing errors, feedback and the host logs follow it as well.
|
|
91
|
+
|
|
92
|
+
**Collapsed (default)**: one row shows the status badge (🟢 running / ⚪ disabled), environment count, and the **enable/disable switch**.
|
|
93
|
+
|
|
94
|
+
**Expanded** shows three blocks —
|
|
95
|
+
|
|
96
|
+
**Status**:
|
|
97
|
+
|
|
98
|
+
- Mode: one-shot connection (an independent process per call).
|
|
99
|
+
- Tool declarations: `4 (fixed)`; environments: `N · M saved`.
|
|
100
|
+
- Most recent error (shown in red on error).
|
|
101
|
+
|
|
102
|
+
**Configuration** (edit, then click "Save Configuration" to apply immediately and persist):
|
|
103
|
+
|
|
104
|
+
| Parameter | Description | Default |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| Auto-update interval (days) | How often dbhub is auto-updated; `0` disables | `7` |
|
|
107
|
+
|
|
108
|
+
Precedence: **user settings > process environment variables (default seeds) > built-in defaults**. The auto-installed package is not in the UI (controlled separately by the `DSH_DBHUB_PACKAGE` environment variable, default `@bytebase/dbhub`).
|
|
109
|
+
|
|
110
|
+
**Workspace connections**:
|
|
111
|
+
|
|
112
|
+
- Lists every workspace × environment connection: workspace name, environment name, **source value** (what the model passes to `dbhub_execute_sql`, shown in monospace), **connection metadata** (🔒 `mysql://host:3306/db` — no username, no password; passwords never appear on the card), origin badge (`saved` / `auto`) and origin detail (`saved · user` / `saved · scan` / `auto · mise env` / `auto · .env`).
|
|
113
|
+
- `saved`: you configured it (`dbhub_configure` or added in the card).
|
|
114
|
+
- `auto`: not saved, discovered from `mise env` / `.env` — not persisted and follows the source files; if auto-discovery is wrong, use "Edit" to override it with a manual configuration.
|
|
115
|
+
- Each row can be **tested** (connectivity probe, see below), **edited** (override the connection string; an auto item becomes saved) or **deleted** (saved items only).
|
|
116
|
+
- **Connection test**: clicking "Test" makes the Host probe the row's real DSN through a throwaway connection (a one-off dbhub process running `SELECT 1`) and shows success/failure inline. The report is one-shot feedback: never persisted, fades after ~10 s; a failure never marks, restricts or alters the connection, other environments or queries (slow/unreachable databases wait at most ~30 s).
|
|
117
|
+
- **Multiple environments per workspace**: fill "workspace (path or title, empty = default current workspace) + environment name + connection string" in the form and click "Add Connection". The default environment's source has no suffix; named environments look like `<workspace>_<environment>`.
|
|
118
|
+
|
|
119
|
+
## dbhub Environment Variables
|
|
120
|
+
|
|
121
|
+
| Environment variable | Description | Default |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| `DSH_DBHUB_PACKAGE` | npm package name used for auto-install (environment variable only, not exposed in the UI) | `@bytebase/dbhub` |
|
|
124
|
+
| `DSH_DBHUB_UPDATE_DAYS` | Seed for the auto-update interval in days; `0` disables (overridden once saved in the settings card) | `7` |
|
|
125
|
+
|
|
126
|
+
## 🔄 Automatic Installation & Updates
|
|
127
|
+
|
|
128
|
+
- **Auto-install on first use** — when `dbhub` is missing locally, the plugin installs it on the first execution; afterwards it also works offline.
|
|
129
|
+
- **Kept up to date automatically** — silently updates to the latest version in the background (interval under "Status Card → configurable parameters"); on failure the existing version is kept.
|
|
130
|
+
- **Never touches your configuration** — a `dbhub` you installed yourself via PATH / mise is left untouched.
|
|
131
|
+
|
|
132
|
+
> The default update interval can also be seeded by an environment variable, see "Status Card → Configuration"; once saved in the settings card, the saved value wins.
|
|
133
|
+
|
|
134
|
+
## Data Location
|
|
135
|
+
|
|
136
|
+
All configuration and credentials live outside the module directory (unaffected by pnpm packaging); deleting the directory clears everything:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
~/.dsh/storages/dsh-dbhub-live/
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Instances are isolated by `DSH_HOME`; multiple profiles of the same instance share it (same convention as dsh's own `workspace.json`). Workspace connections are stored per "workspace × environment" (`environments.default` is the default environment); legacy v1 single-connection entries migrate automatically at startup. The plugin cleans up and migrates legacy config left by upgrades or manual edits in one pass; it does not crash if the runtime directory is deleted or writes are blocked by the system — it recreates the directory, warns once and keeps running in memory when a write fails. **There is no resident dbhub process and no shared config file**: concurrent instances on the same machine — even sharing one DSH_HOME — do not interfere with each other.
|
|
143
|
+
|
|
144
|
+
## Uninstall
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
dsh plugin --profile web remove dsh-dbhub-live
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Troubleshooting
|
|
151
|
+
|
|
152
|
+
| Symptom | Fix |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| "Cannot locate dbhub" on first use | Make sure npm is present and online; offline, install `dbhub` manually and add it to PATH. |
|
|
155
|
+
| A query to one environment fails with connection refused / auth error | Environments use independent one-shot connections: an unreachable environment only fails that call — other environments and calls keep working. The error carries guidance — for wrong credentials/details, ask the AI to run `dbhub_configure` and enter the password in the UI, or edit it directly in Settings → Plugins → Workspace connections. |
|
|
156
|
+
| Tools say "plugin disabled" | Open Settings → Plugins → dsh-dbhub-live and click "Enable". |
|
|
157
|
+
| Status card not visible | Confirm the plugin is installed and restart `dsh web`; the card only shows in the Web settings panel (`dsh web`) — on terminal environments without the panel, tool usage is unaffected. |
|
|
158
|
+
| No config files found by the scan | `node_modules` / `.git` / `target` / `dist` etc. are skipped by default; use "Enter DSN" or "Fill in fields" instead. |
|
|
159
|
+
| Need a custom dbhub version | Set the `DSH_DBHUB_PACKAGE` environment variable (e.g. `@bytebase/dbhub@1.2.1`) and restart; or delete `~/.dsh/storages/dsh-dbhub-live` and let it reinstall automatically. |
|
|
160
|
+
| Don't want automatic dbhub updates | Set "Auto-update interval (days)" to `0` in the status card and save; or set `DSH_DBHUB_UPDATE_DAYS=0`. |
|
|
161
|
+
| Can't update the password in chat (the model asks you for it) | That is by design — the model must not handle passwords. Ask the AI to run `dbhub_configure` and fill in the password in the UI prompt, or edit it yourself in Settings → Plugins → Workspace connections. |
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
162
165
|
[MIT](./LICENSE)
|