@zxlll/dsh-integration-env 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +148 -2
- package/client.js +1233 -0
- package/cordis.patch.yml +16 -0
- package/icon.svg +20 -0
- package/index.js +764 -0
- package/lib/kinds.js +209 -0
- package/lib/mysql.js +723 -0
- package/lib/nacos.js +561 -0
- package/lib/probe.js +74 -0
- package/lib/redis.js +317 -0
- package/lib/store.js +729 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +60 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-integration-env 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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,149 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 集成环境(@zxlll/dsh-integration-env)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
给 DSH 加一个右栏「集成环境」面板:把 **Nacos / MySQL / Redis / MongoDB / MQTT** 这些连接实例集中
|
|
4
|
+
配置一次,然后**按会话勾选**本次要用哪些。模型通过工具读取同一份选择,不需要你把连接信息贴进对话里。
|
|
5
|
+
|
|
6
|
+
替代散落在各个 `.mcp.json` 里的 `mcp_server_mysql-*` / `nacos-*`:一个实例一条配置,
|
|
7
|
+
想加几个加几个;加新实例不用改任何 JSON 文件,也不用改 `cordis.patch.yml`。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
从 npm 公共源装进某个 profile(把 `web` 换成你在用的 profile 名):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
dsh plugin --profile web add @zxlll/dsh-integration-env
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
装完重启一次 DSH 进程,右栏就会出现「集成环境」标签页。新的依赖会自动追加到该 profile
|
|
18
|
+
`package.json` 的 `dsh.profile.bundles` 里,不需要手工改配置。
|
|
19
|
+
|
|
20
|
+
在 Web 界面里也可以让 Agent 直接装:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
plugin_manager action=install_bundle target=@zxlll/dsh-integration-env
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
升级 / 卸载同样走 profile 的包管理:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
dsh plugin --profile web update @zxlll/dsh-integration-env
|
|
30
|
+
dsh plugin --profile web remove @zxlll/dsh-integration-env
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
从源码目录(`link:` 本地开发)安装用:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
dsh plugin --profile web add link:/path/to/dsh-integration-env
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 装上之后能看到什么
|
|
40
|
+
|
|
41
|
+
- 右栏多一个「集成环境」标签页(输入框左侧也有一个入口按钮)。
|
|
42
|
+
- 面板里能:新增 / 编辑 / 删除实例,测试连通性,按 kind 筛选。
|
|
43
|
+
- 每个实例左侧有一个勾选框:**勾上就代表"当前会话用这个实例"**。切换会话,勾选互不影响。
|
|
44
|
+
- 「插入上下文」按钮把【集成环境】块写进输入框(不点也可以,模型会用工具自己读你已勾选的)。
|
|
45
|
+
- 模型侧工具:`integration_env_list`、`integration_env_nacos`、`integration_env_mysql`、
|
|
46
|
+
`integration_env_redis`、`integration_env_test`。
|
|
47
|
+
|
|
48
|
+
## 配置存在哪
|
|
49
|
+
|
|
50
|
+
默认 `$DSH_HOME/plugin-data/integration-env/instances.json`(Windows 上通常是
|
|
51
|
+
`C:\Users\<你>\.dsh\plugin-data\integration-env\instances.json`),首次保存时自动创建,权限 600。
|
|
52
|
+
|
|
53
|
+
- 不在 profile 的 `package.json` / `cordis.patch.yml` 里,所以升级或重装插件不会覆盖。
|
|
54
|
+
- 想换位置:在 profile 的 `cordis.patch.yml` 里给 `integration-env` 这行加
|
|
55
|
+
`config: { dataFile: 'D:/somewhere/instances.json' }`。
|
|
56
|
+
- **密码是明文存在这个文件里的**(和 `.mcp.json` 里的 env 一样),别把它提交到 git。
|
|
57
|
+
|
|
58
|
+
## 两种用法
|
|
59
|
+
|
|
60
|
+
**按会话勾选(推荐)**
|
|
61
|
+
|
|
62
|
+
1. 右栏「集成环境」→ 配置好实例。
|
|
63
|
+
2. 每次开新会话,勾上这次要用的实例。
|
|
64
|
+
3. 直接问,例如「示例库里 `parking_order` 最近 10 条数据」——模型会看到本会话启用的实例,
|
|
65
|
+
直接用 `integration_env_mysql` 查,不再反问你库在哪。
|
|
66
|
+
|
|
67
|
+
**插入上下文(更明确)**
|
|
68
|
+
|
|
69
|
+
勾完点「插入上下文」,输入框会出现:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
【集成环境】本会话启用的实例(来自右侧「集成环境」面板)
|
|
73
|
+
- MySQL · 示例库(demo_db):127.0.0.1:32336 / demo_db
|
|
74
|
+
说明:连接信息以插件配置为准……
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
补一句问题就能发。这块内容和模型自己读到的配置是同一份。
|
|
78
|
+
|
|
79
|
+
## 支持的 kind
|
|
80
|
+
|
|
81
|
+
| kind | 配置字段 | 能力 |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| MySQL | host / port / user / password / database / charset / readOnly | 执行 SQL;`readOnly` 默认开,只放行 SELECT/SHOW/DESC/EXPLAIN/WITH |
|
|
84
|
+
| Nacos | baseUrl(含 `/nacos`)/ namespace / group / username / password | 表单编码登录后读配置、命名空间、服务列表、服务实例、集群状态;v1(2.x)与 v3(3.x)路径自动回退 |
|
|
85
|
+
| Redis | host / port / username / password / database / tls / readOnly | 只读命令 INFO / SCAN / GET / TYPE / TTL |
|
|
86
|
+
| MongoDB | uri | v1 只做配置与端口连通探测 |
|
|
87
|
+
| MQTT | host / port / username / password / clientId / tls | v1 只做配置与端口连通探测 |
|
|
88
|
+
|
|
89
|
+
MongoDB / MQTT 的数据面工具是下一步的事:kind 注册表在 `lib/kinds.js`,加一个 kind 就是加一段
|
|
90
|
+
字段描述 + 一个 connector,面板表单会自动长出来(Client 按描述符动态渲染,不写死字段)。
|
|
91
|
+
|
|
92
|
+
## 安全边界
|
|
93
|
+
|
|
94
|
+
- 面板接口只接受同源、本机浏览器请求(走 DSH 的 `connection.requestRejection`)。
|
|
95
|
+
- secret 字段(password)**永远不会**出现在 `catalog` 返回值或任何工具结果里;
|
|
96
|
+
编辑时留空表示保持原密码不变。
|
|
97
|
+
- SQL 默认只读;只有把实例的「只读模式」关掉才能写。
|
|
98
|
+
- 工具结果里不带密码,模型也拿不到。
|
|
99
|
+
|
|
100
|
+
## 开发
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
node --check index.js && node --check client.js
|
|
104
|
+
node check-host.mjs # Host 冒烟:存储 / 脱敏 / 勾选 / 只读拦截 / 实例解析
|
|
105
|
+
node check-client.mjs # Client 冒烟:Loader 契约 / 注册数量 / cleanup
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`npm run check` 一次跑完上面四步。
|
|
109
|
+
|
|
110
|
+
Client 半改动后需要刷新页面;换掉已安装的包版本需要重启 DSH 进程才会加载新的 JS。
|
|
111
|
+
**改了 Host 代码后**:`remove_bundle` 再 `install_bundle` 即可让运行中的进程加载新模块
|
|
112
|
+
(直接改文件不会热更 Host 半)。
|
|
113
|
+
|
|
114
|
+
以 `link:` 方式开发时,profile 直接读本目录的代码,改 Host 半同样需要重启进程。
|
|
115
|
+
|
|
116
|
+
## 发布
|
|
117
|
+
|
|
118
|
+
这个包发布在 `@zxlll` scope 下,`publishConfig.access = public` 已在 `package.json` 声明。
|
|
119
|
+
维护者本地流程:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm run check # 先跑自检:语法 + Host/Client 两套冒烟
|
|
123
|
+
npm publish # 带 2FA 的账号用 npm publish --otp <6 位验证码>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
后续发新版:`npm version patch`(或 `minor` / `major`)再 `npm publish`。
|
|
127
|
+
`files` 白名单只包含运行时需要的文件,`perf/`、`docs/`、`.preview/`、`.probe/` 和两个
|
|
128
|
+
`check-*.mjs` 不会进包(15 个文件、约 55 kB)。
|
|
129
|
+
|
|
130
|
+
## 本机实测记录(2026-11-14)
|
|
131
|
+
|
|
132
|
+
对着用户真实的 `127.0.0.1` 环境跑过,结论如下:
|
|
133
|
+
|
|
134
|
+
- **MySQL**:`127.0.0.1:32336` / `demo_db` → `SELECT VERSION(), DATABASE(), NOW()`
|
|
135
|
+
返回 `8.0.36 / demo_db / 2026-11-14 14:30:20`。协议层(`mysql_native_password` /
|
|
136
|
+
`caching_sha2_password`、RSA 公钥 full auth、文本结果集)跑通真实 MySQL 8。
|
|
137
|
+
只读拦截同样实测:`UPDATE ...` 被拒绝并提示去面板关闭「只读」。
|
|
138
|
+
- **Nacos**:`http://127.0.0.1:31878/nacos`,`admin` 登录成功。
|
|
139
|
+
- 控制台面接口(`/v1/console/*`)返回 `410 Gone`,提示改用 `/v3/console/*`;但该部署的
|
|
140
|
+
`/v3/console/*` 一律 `404`,真正可用的是 **`/v3/admin/*`**。
|
|
141
|
+
(2026-11-23 复测修正:早先记的「控制台 API 在独立 8080 端口」是错的,v3 就在同端口,
|
|
142
|
+
只是前缀是 `admin` 不是 `console`。)插件现在按 v1 → v3 console → v3 admin 依次回退。
|
|
143
|
+
- 数据面接口(`/v1/ns/service/list`、`/v1/cs/configs`)可用;`/v1/ns/catalog/instances` 已 410。
|
|
144
|
+
- 该账号能读配置/服务/实例/服务状态;但 `/v3/admin/core/namespace/list` 返回
|
|
145
|
+
`403 authorization failed` —— `admin` 不是 `globalAdmin`,命名空间列表要管理员账号或授权。
|
|
146
|
+
- **Nacos 3.x 的两个坑(2026-11-23 已修)**:
|
|
147
|
+
- 配置不存在时 v3 返回 **HTTP 200 + `code:20004`**。旧代码不校验 `code`,会把这段错误 JSON
|
|
148
|
+
当成配置正文返回(「假成功」)。现在校验业务码并优先取 `data.content`。
|
|
149
|
+
- 3.x token 登录路径从 `/v1/auth/login` 迁到了 `/v1/auth/users/login`,两个都试。
|