dsh-users-open-source 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KAIROSLLL
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,103 @@
1
+ # dsh-users-open-source
2
+
3
+ DeepSeek Harness 插件「**开源用户**」:本机带宽测速 + 一键打开工作区目录。
4
+
5
+ > 这是 monorepo 里的**主包**。伴生包 `dsh-users-open-source-workspace`(负责"打开工作区目录"那一半)
6
+ > 是本包的 `dependencies`,会随本包一起装上 —— 用户只需要装本包一个名字。
7
+
8
+ ## 功能
9
+
10
+ **设置 → 开源用户**
11
+
12
+ - **打包 / 上传** 两项指标,一颗 **「上传」** 按钮(点一下跑一轮测速);
13
+ - 实时进度条 + 瞬时速率柱状图,测速时柱形图下面会弹出那张图;
14
+ - **自动上传**:每隔一段时间 / 每天某个时刻自动跑(跑在宿主进程里,浏览器关着也照跑);
15
+ - **最近记录**:每条可单独删,也能一键清空;
16
+ - **上传图片**:把测速时弹的那张换成自己的图,也能一键恢复默认;旁边可调"侧栏图片"宽度。
17
+
18
+ **左侧栏「插件」下面多一栏**
19
+
20
+ - 平时显示当前带宽 `↓1.23G ↑0.98G`;没测过时显示 **等待上传**;测速中显示 **开源中**;
21
+ - 测速时在那一栏里接一张图 —— 图是**栏目内容的一部分**(把栏目撑高),不是浮层,不会挡住别的东西。
22
+
23
+ **主面板 `net-speed`**:标题「本机自动开源」,和设置页是同一台仪器。
24
+
25
+ ## 它到底在测什么(重要)
26
+
27
+ 插件在宿主进程里起一个 **只绑定 `127.0.0.1` 的回环测速口**(随机端口),然后自己当客户端压这个口:
28
+
29
+ - **不连接任何外部服务器**:字节只在「本进程 ↔ 本机回环网卡」之间来回;局域网里其它机器也连不上;
30
+ - **不消耗 token**:不注册模型工具、不写系统提示、不发任何模型请求,与 LLM 完全无关;
31
+ - 因此它量的是**本机协议栈 / 回环吞吐上限**(常见几 GB/s),不是运营商带宽 ——
32
+ 想测运营商带宽必须有一个外部对端,那与「不接其他服务器」的要求冲突。
33
+
34
+ 想跑满带宽:把「单次时长」「并发连接」调大,点「上传」。
35
+
36
+ ## 目录结构
37
+
38
+ | 文件 | 作用 |
39
+ | --- | --- |
40
+ | `lib/host.js` | 宿主半边:回环测速口、测速引擎、自动上传调度,以及 `state` / `run` / `cancel` / `config` / `history` / `asset/*` 路由 |
41
+ | `lib/client.js` | 客户端半边:设置页「开源用户」、侧栏那一栏、主面板 |
42
+ | `assets/code-upload.jpg` | 测速时弹的那张默认图(用户可自行上传替换) |
43
+ | `cordis.patch.yml` | 插入两条 loader entry:本包 + 伴生包 |
44
+ | `tests/smoke.mjs` | 自检(`node tests/smoke.mjs`) |
45
+
46
+ ## 安装
47
+
48
+ ```powershell
49
+ # 从 npm(推荐)
50
+ dsh plugin --profile desktop add dsh-users-open-source
51
+
52
+ # 本地开发(不经过 registry)
53
+ dsh plugin --profile desktop add "link:<本仓库>\packages\dsh-users-open-source"
54
+ ```
55
+
56
+ 装完**重启一次 dsh web**。伴生包是本包的 `dependencies`,不需要单独装;
57
+ 两条 loader entry 都由本包的 `cordis.patch.yml` 插入。
58
+
59
+ - 客户端半边 `lib/client.js` 由 dsh-client-hmr 热重载,刷新页面即可;
60
+ - 宿主侧 `lib/host.js` 改动要重启 dsh web(模块进了 ESM 缓存)。
61
+
62
+ ## 配置
63
+
64
+ 存在 `$DSH_HOME/dsh-users-open-source/config.json`,历史在同目录 `history.json`(保留最近 60 条)。
65
+
66
+ | 字段 | 含义 | 边界 |
67
+ | --- | --- | --- |
68
+ | `durationMs` | 单次测速时长 | 500–15000 ms(打包、上传各一次) |
69
+ | `connections` | 并发连接数 | 1–16 |
70
+ | `sidebarImageSize` | 侧栏那张图的宽度 | 60–400 px(默认 120) |
71
+ | `schedule.mode` | `off` / `interval` / `daily` | — |
72
+ | `schedule.intervalMinutes` | interval 模式的间隔 | 1–10080 分钟 |
73
+ | `schedule.dailyTime` | daily 模式的时刻 | `HH:MM` |
74
+
75
+ 用户上传的图存在 `$DSH_HOME/dsh-users-open-source/sidebar-image.<ext>` —— **不动包内文件**,
76
+ 所以升级插件不会覆盖你自己换的图。
77
+
78
+ ## HTTP 接口(同源,浏览器用)
79
+
80
+ ```
81
+ GET /dsh-users-open-source/state 当前状态(running / progress / config / last / history / customImage)
82
+ POST /dsh-users-open-source/run 开始一次测速(后台跑,立即返回;已在跑返回 409)
83
+ POST /dsh-users-open-source/cancel 取消
84
+ POST /dsh-users-open-source/config 保存配置(立刻重排定时器)
85
+ POST /dsh-users-open-source/history 删记录:{action:'clear'} 清空,{action:'delete', at} 删单条
86
+ GET /dsh-users-open-source/asset/image 当前那张图(用户上传的优先,否则包内默认图)
87
+ POST /dsh-users-open-source/asset/image 换图:{type:'image/png', data:'<base64>'}(≤3 MB)
88
+ POST /dsh-users-open-source/asset/image/reset 恢复默认图
89
+ GET /dsh-users-open-source/asset/code-upload.jpg 包内默认图
90
+ ```
91
+
92
+ 「打开工作区目录」的接口 `POST /dsh-users-open-source/open-workspace` 在**伴生包**里。
93
+
94
+ ## 自检
95
+
96
+ ```powershell
97
+ cd packages/dsh-users-open-source
98
+ node tests/smoke.mjs
99
+ ```
100
+
101
+ ## License
102
+
103
+ MIT
Binary file
@@ -0,0 +1,21 @@
1
+ # dsh-users-open-source bundle patch.
2
+ #
3
+ # 标准 DSH bundle 插件。两种安装方式:
4
+ # dsh plugin --profile <profile> add dsh-users-open-source # 从 npm
5
+ # dsh plugin --profile <profile> add "link:<本目录绝对路径>" # 本地开发
6
+ # 装完后由 bundle 层(profile 的 dsh.profile.bundles)插入下面这些 loader 行。
7
+ #
8
+ # ⚠️ 宿主侧(lib/host.js)改动必须重启 dsh web 才生效(模块进了 ESM 缓存);
9
+ # 客户端侧(lib/client.js)由 dsh-client-hmr 热重载。
10
+ #
11
+ # ⚠️ 本包带 dsh.client 半边,**不能**再挂「本包内」的第二个 loader 入口:
12
+ # · name 写包内子路径 → loader 解析不了,entry 报 failed to import;
13
+ # · name 写 file: URL → dsh-client-modules 按「最近的 package.json」判来源包,
14
+ # 会报 `package dsh-users-open-source resolves from multiple active Loader sources` 并启动崩。
15
+ # 「云端备份」那一半因此是**独立的包** dsh-users-open-source-workspace(作为本包
16
+ # 的 dependency 一起装上),由下面第二条 entry 加载。
17
+ - insert:
18
+ - id: dsh-users-open-source
19
+ name: dsh-users-open-source
20
+ - id: dsh-users-open-source-workspace
21
+ name: dsh-users-open-source-workspace