dsh-dpharness 0.3.5

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhanghao (https://dpharness.com)
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 ADDED
@@ -0,0 +1,100 @@
1
+ # dsh-dpharness(严选插件)
2
+
3
+ 在 DeepSeek Harness(dsh)里浏览、搜索 [dpharness.com](https://dpharness.com) 的 dsh 插件目录,
4
+ **并可直接一键安装**。
5
+
6
+ ## 三个入口
7
+
8
+ | 入口 | 位置 | 说明 |
9
+ |---|---|---|
10
+ | 页签「严选插件」 | 会话视图区 | 完整页:搜索 + 排序 + 批量浏览 |
11
+ | 左下入口 | 侧边栏底部(`sidebar.footer.action`) | 点击展开全站浮窗 |
12
+ | 全站浮窗 | 右下角(`shell.overlay`,跨路由含首页) | 随手查:随时搜、随时装 |
13
+
14
+ ## 卡片显示什么
15
+
16
+ 按「汉化优先」组织,缺汉化时明确标注而不是假装有:
17
+
18
+ 1. **中文名**(`nameZh`)— 站点已汉化
19
+ 2. **中文分类** + 可信度徽章(`tier` / `dshCompat` / `verify` / `tested` / `risk`)
20
+ 3. **卖点行**(强调)— 取站点 `tagline`,经严格过滤;不合格就不显示
21
+ 4. **汉化正文** — 站点 `descriptionZh`;没有则显示英文原文并标「未汉化」
22
+ 5. **安装按钮** + 可复制的 `dsh plugin --profile web add <包名>`
23
+
24
+ > ⚠️ 上游 `tagline` 实测约一半不可用(英文原文 / 被截断 / 甚至 `安装&nbsp;`、README 目录导航)。
25
+ > 本插件用 `pickZh()` 过滤:切段逐段找中文、中文字符 ≥ 6、段长 ≥ 8、丢弃英文导航词开头。
26
+ > 覆盖面见 `test-local.mjs` 里那些用真实样本写的用例。
27
+
28
+ ## 一键安装怎么工作
29
+
30
+ **两条路径,安全优先:**
31
+
32
+ 1. **优先复用 dshmarket 的同源 HTTP 路由**(`POST /dsh-market/install`)——
33
+ 免重启热挂载、可回滚、带供应链校验。代价:它只接受自己 curated registry(awesome 目录)里的 URL。
34
+ 2. **不在目录里 / 未装 dshmarket 时**降级到本插件自己的 spawn:
35
+ `dsh plugin --profile web add <包名>`(**改 profile,装完需重启 dsh 生效**)。
36
+
37
+ 细节与安全约束:
38
+
39
+ - **命令来源与站点同口径**(`lib/installCmd.ts` 的 `resolveInstallTarget`):
40
+ 只有 `installCheck.status === "pass"` 时才用 npm 包名,否则退回 `owner/repo` **走 GitHub 源安装**,
41
+ 并在卡片上标注来源(与站点详情页用词一致)。**不会出现"什么都不给"的情况。**
42
+ - 一键安装按钮**只在站点已验证时**出现(未验证/警告都按保守处理,只给可复制的命令)。
43
+ - 只有站点给出 `installCheck.status === "pass"` 的条目才显示安装按钮
44
+ (校验未过时 npm 上的同名包**可能属于别人**)。
45
+ - 安装前有二次确认,展示将要执行的包名。
46
+ - dshmarket 返回 **409**(有 agent 正在运行)时**不降级**,直接报错 —— 避免和正在工作的 agent 抢插件文件。
47
+ - 目标包名过字符白名单校验;子进程环境会剥掉宿主的 safe-delete shim(否则 pnpm 清理临时文件被拦)。
48
+ - 失败时展示 pnpm 的错误码行(如 `[ERR_PNPM_FETCH_404] …`),而不是一堆进度日志。
49
+
50
+ ## HTTP 路由(host 侧)
51
+
52
+ | 路由 | 说明 |
53
+ |---|---|
54
+ | `GET /api/dpharness/search?q=&take=&sort=stars` | 目录查询,字段裁剪后返回,按 `q+take+sort` 缓存 5 分钟 |
55
+ | `POST /api/dpharness/event` | 埋点代理 → `dpharness.com/api/track/event` |
56
+ | `POST /api/dpharness/install` | `{ pkg }`,spawn `dsh plugin add`;返回 202 + 任务启动 |
57
+ | `GET /api/dpharness/install` | 安装任务进度与结果 |
58
+ | `GET /api/dpharness/meta` | 版本、profile、路由清单、缓存与安装状态 |
59
+
60
+ ## 隐私
61
+
62
+ - **不采集搜索关键词原文**,只上报动作、关键词长度与命中数。
63
+ - 复制/安装命令的上报口径与站点一致(`copy_install` 的 value 为整条命令),
64
+ 来源靠 `path=/dsh-plugin` 区分。
65
+ - 浮窗与页签底部都有**匿名统计开关**,可随时关闭。
66
+ - 埋点经本地 host 转发(站点端点不带 CORS 头),失败静默忽略,绝不影响操作。
67
+
68
+ ## 安装本插件
69
+
70
+ ```bash
71
+ dsh plugin --profile web add dsh-dpharness@<版本>
72
+ ```
73
+
74
+ > `--profile web` 是 dsh CLI 的**必需参数**,省略会直接报
75
+ > `required option '--profile <name>' not specified`。
76
+ > 任何来源给出的 `dsh plugin add <owner/repo>` 都不可用。
77
+
78
+ 本机安装(开发用):`bash install.sh`,然后重启 dsh
79
+ (侧边栏「重启」按钮,或 `pkill -9 -f "bin/dsh web"` 让 launchd 拉起)。
80
+
81
+ ## 卸载
82
+
83
+ 从 `~/.dsh/profiles/web/cordis.patch.yml` 删掉含 `id: dpharness` 的 `insert` 块,然后:
84
+
85
+ ```bash
86
+ rm -rf ~/.dsh/profiles/web/node_modules/dsh-dpharness
87
+ ```
88
+
89
+ ## 开发自检
90
+
91
+ ```bash
92
+ cd .dev && npm install react@19 react-dom@19 && cd ..
93
+ node test-local.mjs # host 侧真打上游 + client 侧 SSR + pickZh 判据(真实样本)
94
+ ```
95
+
96
+ > 不要用 `~/.dsh/profiles/node_modules/react` 做测试依赖:那两个软链在 0.1.5 升级后已悬空(实测)。
97
+
98
+ ## License
99
+
100
+ MIT
@@ -0,0 +1,10 @@
1
+ # dsh bundle patch: inserts this plugin into a profile's layer stack.
2
+ #
3
+ # 这个文件是「命令安装能否生效」的关键:`dsh plugin add` 只有在包的 package.json
4
+ # 声明了 `dsh.bundle.patch` 时,才会把本插件并入 profile 的 layer 栈;
5
+ # 否则它只被当成一个普通依赖装进去,**进程不会加载它**,用户会看到"装成功但没反应"。
6
+ #
7
+ # id 必须与 host/lib 里的插件名一致(host 侧 `export const name = "dpharness"`)。
8
+ - insert:
9
+ - id: dpharness
10
+ name: dsh-dpharness