dsh-plugin-yapi 0.0.0-stage → 1.4.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/LICENSE +21 -0
- package/README.md +166 -2
- package/bin/yapi-doc.mjs +3 -0
- package/client.js +2464 -0
- package/cordis.patch.yml +9 -0
- package/index.js +554 -0
- package/lib/core.js +434 -0
- package/package.json +66 -4
- package/skills/yapi-doc/SKILL.md +68 -0
- package/skills/yapi-doc/yapi-doc.mjs +863 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-plugin-yapi 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,167 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-yapi
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-plugin-yapi)
|
|
4
|
+
|
|
5
|
+
给 DeepSeek Harness(DSH)左侧加一个 **YAPI** 面板:按文档 ID / 链接打开接口、按路径或标题搜索、多标签切换、字段树、勾选复制。附带一个 `yapi-doc` skill 和零依赖 CLI,AI 或终端可以直接读取 YAPI 文档。
|
|
6
|
+
|
|
7
|
+
> 仓库不包含任何真实 YAPI 地址、账号或密码;安装后在面板或环境变量里配置。
|
|
8
|
+
|
|
9
|
+
## 功能
|
|
10
|
+
|
|
11
|
+
- **打开文档**:输入文档 ID(如 `10001`)或完整链接。
|
|
12
|
+
- **搜索**:按接口路径 / 标题模糊搜索,支持子序列(如 `whlist` 命中 `warehouse/list`)。
|
|
13
|
+
- **多标签**:同时打开多个接口,切换、关闭、全部关闭,刷新后恢复。
|
|
14
|
+
- **字段树**:请求字段 / 返回字段,对象和数组可展开,支持筛选。
|
|
15
|
+
- **复制**:标题栏「复制」→ 勾选要包含的内容 → 一次性复制;Body 可选纯 JSON / 带备注。
|
|
16
|
+
- **账号设置**:面板内填写 YAPI 地址、账号、密码,保存前会真实登录验证。
|
|
17
|
+
- **Skill / CLI**:`yapi-doc` 随插件自动注册,DSH 会话或任意 shell 工具都能直接读文档。
|
|
18
|
+
|
|
19
|
+
## 安装(DSH)
|
|
20
|
+
|
|
21
|
+
要求:DSH 0.2.2+(桌面端或 web profile)、Node 20+、能访问你的 YAPI 服务。
|
|
22
|
+
|
|
23
|
+
先**完全退出 DSH**(桌面端要关闭应用,不是最小化),然后:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
dsh plugin --profile desktop add dsh-plugin-yapi
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- 如果 `dsh` 不在 PATH,macOS 桌面端可以用自带 CLI:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" \
|
|
33
|
+
plugin --profile desktop add github:jinshan3690/dsh-plugin-yapi
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- web profile 把 `--profile desktop` 换成 `--profile web`。
|
|
37
|
+
- 命令会自动把插件加进 profile 的 bundle,并注册插件自带的 `yapi-doc` skill,不需要再复制文件。
|
|
38
|
+
- 安装完成后重新打开 DSH。
|
|
39
|
+
- 如果 npm 暂时不可用,也可以把包名换成 `github:jinshan3690/dsh-plugin-yapi`。
|
|
40
|
+
|
|
41
|
+
## 配置
|
|
42
|
+
|
|
43
|
+
打开 DSH → 左侧 **YAPI** → 右上角 **账号设置**,填写:
|
|
44
|
+
|
|
45
|
+
- YAPI 地址(如 `https://yapi.example.com`,带 `http://` 或 `https://`)
|
|
46
|
+
- 账号 / 密码
|
|
47
|
+
|
|
48
|
+
点「测试并保存」,验证通过后生效。
|
|
49
|
+
|
|
50
|
+
- 账号保存在 `~/.dsh/dsh-plugin-yapi.json`(权限 `0600`),不会进入仓库。
|
|
51
|
+
- 也支持环境变量 `YAPI_BASE_URL` / `YAPI_EMAIL` / `YAPI_PASSWORD`。
|
|
52
|
+
- 搜索需要项目 ID;打开一个文档后会自动跟随该文档所属项目。
|
|
53
|
+
- 插件**没有内置任何 YAPI 地址**,必须自己配置。
|
|
54
|
+
|
|
55
|
+
## 使用
|
|
56
|
+
|
|
57
|
+
- 输入文档 ID 或完整链接 → 直接打开;输入关键字 → 搜索接口,点结果进入新标签。
|
|
58
|
+
- 标签栏可切换、单个关闭、全部关闭;刷新页面后恢复上次的标签。
|
|
59
|
+
- 接口详情里看「请求参数 / 请求字段 / 返回字段 / 说明」;字段树支持搜索和展开。
|
|
60
|
+
- 标题栏 **复制** → 勾选内容 → 复制;「带备注」会在 JSON 字段后追加 `// 字段备注`。
|
|
61
|
+
- 接口路径和完整请求地址只做展示;服务地址可在详情里改(用于不同环境)。
|
|
62
|
+
|
|
63
|
+
## 非 DSH 工具(CLI / Skill)
|
|
64
|
+
|
|
65
|
+
CLI 是零依赖 Node 脚本,不需要 DSH。直接命令行安装:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g dsh-plugin-yapi
|
|
69
|
+
yapi-doc install-skill
|
|
70
|
+
yapi-doc <doc-id>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- `install-skill` 默认把 `SKILL.md` 和 CLI 装到 `~/.agents/skills/yapi-doc`;支持 `SKILL.md` 的 agent 可直接读取。
|
|
74
|
+
- 如果 npm 暂时不可用,也可以 `npm install -g github:jinshan3690/dsh-plugin-yapi`。
|
|
75
|
+
- **一键同步到所有已检测到的工具**:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
yapi-doc sync-skills
|
|
79
|
+
yapi-doc sync-skills --dry-run # 只显示会写到哪些目录
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
会自动检测 Trae、WorkBuddy、Qoder CN、GitHub Copilot、CodeBuddy、Claude Code、Cursor、Gemini CLI、Amp、OpenCode、Codex/通用 Agent Skills、DSH 等目录;`--dir` 可追加自定义目录。同步完重启对应应用。
|
|
83
|
+
|
|
84
|
+
- 也可以单独指定目录:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Trae
|
|
88
|
+
yapi-doc install-skill --dir ~/.trae/skills/yapi-doc
|
|
89
|
+
# WorkBuddy
|
|
90
|
+
yapi-doc install-skill --dir ~/.workbuddy/skills/yapi-doc
|
|
91
|
+
# Qoder / 其他 Agent Skills
|
|
92
|
+
yapi-doc install-skill # ~/.agents/skills/yapi-doc
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> 装完请**完全重启**对应工具。不同工具对 skill 的展示方式不同,可能出现在技能列表里,不一定有 `/yapi-doc` 斜杠命令;没有的话直接运行 `yapi-doc <doc-id>`。
|
|
96
|
+
|
|
97
|
+
- 不想全局安装时:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx -y -p github:jinshan3690/dsh-plugin-yapi yapi-doc install-skill
|
|
101
|
+
node "$HOME/.agents/skills/yapi-doc/yapi-doc.mjs" <doc-id>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- 账号读取 `~/.dsh/dsh-plugin-yapi.json`,或设置环境变量:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
export YAPI_BASE_URL='https://yapi.example.com'
|
|
108
|
+
export YAPI_EMAIL='you@example.com'
|
|
109
|
+
export YAPI_PASSWORD='your-password'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
常用参数:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
yapi-doc --search <keyword> --project <project-id>
|
|
116
|
+
yapi-doc <doc-id> --no-fields # 不输出字段说明,输出最小
|
|
117
|
+
yapi-doc <doc-id> --full # 额外输出返回体示例
|
|
118
|
+
yapi-doc <doc-id> --json # 结构化输出
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- 默认输出 Markdown:标题、方法、路径、项目、请求地址、请求头、参数、请求 Body、请求/返回字段说明。
|
|
122
|
+
- `--no-fields`:不输出字段说明,输出最小。
|
|
123
|
+
- `--full`:额外输出返回体示例(可能很大)。
|
|
124
|
+
- `--json`:输出 `{ ok, data }` 结构化 JSON。
|
|
125
|
+
- `--project <id>`:`--search` 必填。
|
|
126
|
+
|
|
127
|
+
**DSH 用户**不需要上面的 npm 安装:插件已自动注册 skill,CLI 在
|
|
128
|
+
`~/.dsh/profiles/desktop/node_modules/.bin/yapi-doc`。
|
|
129
|
+
|
|
130
|
+
## 更新 / 卸载
|
|
131
|
+
|
|
132
|
+
DSH(先退出):
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
dsh plugin --profile desktop remove dsh-plugin-yapi
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
非 DSH:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npm uninstall -g dsh-plugin-yapi
|
|
142
|
+
rm -rf ~/.agents/skills/yapi-doc # 按实际安装目录删除
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
更新:`npm update -g dsh-plugin-yapi`,DSH 重新执行 `dsh plugin ... add dsh-plugin-yapi` 即可。账号文件 `~/.dsh/dsh-plugin-yapi.json` 会保留,按需手动删除。
|
|
146
|
+
|
|
147
|
+
## 开发
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
node --test test/*.test.mjs
|
|
151
|
+
./package.sh # 生成 dist/*.tar.gz
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## 目录
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
index.js Host 半:登录、文档、搜索、设置、内置 skill 注册
|
|
158
|
+
client.js 客户端半:面板、标签、字段树、复制弹窗
|
|
159
|
+
lib/core.js 解析、URL、Body、搜索排序
|
|
160
|
+
bin/yapi-doc.mjs CLI 启动器
|
|
161
|
+
skills/yapi-doc/ SKILL.md + 零依赖 CLI(含 install-skill)
|
|
162
|
+
test/*.test.mjs 单元测试
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT
|
package/bin/yapi-doc.mjs
ADDED