dsh-dpharness 0.6.7 → 0.6.9
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/lib/changelog.js +18 -0
- package/lib/index.js +146 -3
- package/package.json +1 -1
package/lib/changelog.js
CHANGED
|
@@ -37,6 +37,24 @@ export function npmLatestUrl(pkg) {
|
|
|
37
37
|
* (用户要看的是行为变化,不是我们的 commit 分类)。
|
|
38
38
|
*/
|
|
39
39
|
export const CHANGELOG = [
|
|
40
|
+
{
|
|
41
|
+
version: "0.6.9",
|
|
42
|
+
date: "2026-10-24",
|
|
43
|
+
title: "第三方客户端(DSH Desktop)里的一键安装修好了",
|
|
44
|
+
items: [
|
|
45
|
+
"在 DSH Desktop 里点「一键安装」不再报「找不到 dsh 入口」:它会用该客户端自带的 CLI,并装进你当前正在用的 profile,而不是错装到另一个 profile。",
|
|
46
|
+
"安装环境上报新增「客户端」一项(官方桌面 / 官方 Web / 第三方),用于站点把两个客户端的数据分开统计。仍然是匿名、可整体关闭,不含账号、路径或搜索词。",
|
|
47
|
+
"官方客户端(桌面版与 Web 版)的安装与统计行为不变。",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
version: "0.6.8",
|
|
52
|
+
date: "2026-10-23",
|
|
53
|
+
title: "发布链路迁移到 CI(本次无功能变化)",
|
|
54
|
+
items: [
|
|
55
|
+
"这一版没有功能改动,仅把发版从本机手工发布迁移到 GitHub Actions:以后版本更新不再需要人工授权即可发布,更新更及时。",
|
|
56
|
+
],
|
|
57
|
+
},
|
|
40
58
|
{
|
|
41
59
|
version: "0.6.7",
|
|
42
60
|
date: "2026-10-23",
|
package/lib/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export const name = "dpharness";
|
|
|
48
48
|
/** The dsh web server service used to register HTTP routes. */
|
|
49
49
|
export const inject = ["webServer"];
|
|
50
50
|
|
|
51
|
-
export const VERSION = "0.6.
|
|
51
|
+
export const VERSION = "0.6.9";
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* 本插件在 npm 上的包名 —— 与 dsh 的插件 id(上面的 `name = "dpharness"`)**不是一回事**,
|
|
@@ -89,6 +89,132 @@ const STARTED_AT = Date.now() - Math.round(process.uptime() * 1000);
|
|
|
89
89
|
*/
|
|
90
90
|
const BOOT_ID = randomUUID();
|
|
91
91
|
|
|
92
|
+
/* --------------------------------------------------------- 宿主客户端识别 */
|
|
93
|
+
/**
|
|
94
|
+
* Which client this host runs inside.
|
|
95
|
+
*
|
|
96
|
+
* ⚠️ **`process.versions.electron` cannot answer this.** The official desktop
|
|
97
|
+
* shell and the third-party DSH Desktop (dshdesktop.cn) are *both* Electron
|
|
98
|
+
* shells — the third one boots the official host inside its own main process
|
|
99
|
+
* and does not fork the kernel. Grouping by "is Electron" would silently merge
|
|
100
|
+
* the two clients the dashboard is supposed to tell apart (measured 2026-10-24).
|
|
101
|
+
*
|
|
102
|
+
* The only reliable signal is the host executable's name:
|
|
103
|
+
* · official desktop …/MacOS/DeepSeek Harness (CFBundleIdentifier com.deepseek.dsh)
|
|
104
|
+
* · third-party …/MacOS/DSH Desktop[ Beta] (ai.deepseek.dsh.desktop[.beta])
|
|
105
|
+
* Encoded into telemetry as `c=`:
|
|
106
|
+
* od = official desktop · ow = official web (plain node host)
|
|
107
|
+
* td = third-party desktop · tu = some other Electron shell (unregistered)
|
|
108
|
+
* The site maps od+ow to "official", td to "third-party" and everything else
|
|
109
|
+
* (tu, or a missing key from an older plugin) to "unknown" — never guessed.
|
|
110
|
+
*/
|
|
111
|
+
export function hostClientOf({ execPath = process.execPath, isElectron = typeof process.versions?.electron === "string" } = {}) {
|
|
112
|
+
if (!isElectron) return "ow";
|
|
113
|
+
/* Normalise dashes/underscores so Linux binary names (`dsh-desktop`) match
|
|
114
|
+
the spaced product names macOS and Windows ship. Split on both separators:
|
|
115
|
+
a Windows path handed to this function on darwin still has to yield a name. */
|
|
116
|
+
const name = lastPathSegment(execPath)
|
|
117
|
+
.replace(/\.(exe|app)$/i, "")
|
|
118
|
+
.replace(/[-_]+/g, " ")
|
|
119
|
+
.replace(/\s+/g, " ")
|
|
120
|
+
.trim();
|
|
121
|
+
if (/^deepseek harness$/i.test(name)) return "od";
|
|
122
|
+
if (/^dsh desktop( beta)?$/i.test(name)) return "td";
|
|
123
|
+
return "tu";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Last path segment, tolerant of foreign separators (see hostClientOf). */
|
|
127
|
+
function lastPathSegment(value) {
|
|
128
|
+
const parts = String(value || "").split(/[\\/]/);
|
|
129
|
+
return parts[parts.length - 1] || "";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* 导出仅为可测:测试用它在断言里拼期望值,而不是把 "ow" 写死 ——
|
|
133
|
+
写死会在 Electron 里跑测试时变成假失败。 */
|
|
134
|
+
export const HOST_CLIENT = hostClientOf();
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Electron's `app.getPath('userData')`, derived without an `app` object.
|
|
138
|
+
*
|
|
139
|
+
* A host plugin has no Electron API, but the path is deterministic:
|
|
140
|
+
* macOS `~/Library/Application Support/<productName>`, Windows
|
|
141
|
+
* `%APPDATA%/<productName>`, Linux `$XDG_CONFIG_HOME/<productName>`.
|
|
142
|
+
* Verified on this machine for DSH Desktop 2.0.17:
|
|
143
|
+
* `~/Library/Application Support/DSH Desktop/…`.
|
|
144
|
+
*/
|
|
145
|
+
export function appDataDir(appName, { platform = process.platform, homedir = os.homedir(), env = process.env } = {}) {
|
|
146
|
+
if (platform === "darwin") return path.join(homedir, "Library", "Application Support", appName);
|
|
147
|
+
if (platform === "win32") return path.join(env.APPDATA || path.join(homedir, "AppData", "Roaming"), appName);
|
|
148
|
+
return path.join(env.XDG_CONFIG_HOME || path.join(homedir, ".config"), appName);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Product name of the running shell, i.e. `DSH Desktop`, `DSH Desktop Beta`, `DeepSeek Harness`. */
|
|
152
|
+
export function hostAppName(execPath = process.execPath) {
|
|
153
|
+
return lastPathSegment(execPath).replace(/\.(exe|app)$/i, "");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* CLI wrapper candidates shipped by a third-party Electron shell.
|
|
158
|
+
*
|
|
159
|
+
* Measured 2026-10-24 against DSH Desktop 2.0.17: its CLI is **not** inside the
|
|
160
|
+
* .app bundle. It lives under the user-data directory at
|
|
161
|
+
* `<userData>/cli/<sha256>/bin/dsh`, and the wrapper itself reads
|
|
162
|
+
*
|
|
163
|
+
* DSH_DESKTOP_DEFAULT_PROFILE='desktop' ELECTRON_RUN_AS_NODE=1 exec \
|
|
164
|
+
* '<app>/Contents/MacOS/DSH Desktop' --expose-internals '<app>/Resources/app/lib/desktop-cli.js' "$@"
|
|
165
|
+
*
|
|
166
|
+
* The hash directory changes with every release, so it can only be enumerated —
|
|
167
|
+
* first entry that holds an executable `bin/dsh` wins. The official bundle path
|
|
168
|
+
* (`<Contents>/Resources/runtime/cli/bin/dsh`) does **not** exist there, which is
|
|
169
|
+
* why the previous logic returned null and every install failed with
|
|
170
|
+
* "cannot locate the dsh entry point".
|
|
171
|
+
*/
|
|
172
|
+
export function thirdPartyCliCandidates(userDataDir, { platform = process.platform } = {}) {
|
|
173
|
+
const bin = platform === "win32" ? "dsh.cmd" : "dsh";
|
|
174
|
+
let entries = [];
|
|
175
|
+
try {
|
|
176
|
+
entries = fs.readdirSync(path.join(userDataDir, "cli"), { withFileTypes: true });
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
return entries
|
|
181
|
+
.filter((entry) => entry.isDirectory())
|
|
182
|
+
.map((entry) => path.join(userDataDir, "cli", entry.name, "bin", bin))
|
|
183
|
+
.filter((candidate) => {
|
|
184
|
+
try {
|
|
185
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
186
|
+
return true;
|
|
187
|
+
} catch (error) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Active profile name as recorded by a third-party Electron shell.
|
|
195
|
+
*
|
|
196
|
+
* Such a shell does not put the profile directory into argv (its architecture
|
|
197
|
+
* doc says the name and absolute path come from `desktopProfiles.current` and
|
|
198
|
+
* must not be inferred from argv/settings/URL). Falling back to "web" would then
|
|
199
|
+
* install into a profile the user is not even looking at — a silent wrong
|
|
200
|
+
* target, worse than a loud failure. So read its own selection state
|
|
201
|
+
* (measured shape: `{"version":2,"active":"desktop"}`) and accept the value only
|
|
202
|
+
* when `~/.dsh/profiles/<name>/package.json` really exists on disk.
|
|
203
|
+
* Unreadable ⇒ null ⇒ caller keeps the previous behaviour.
|
|
204
|
+
*/
|
|
205
|
+
export function thirdPartyProfile(execPath = process.execPath, { platform = process.platform, homedir = os.homedir() } = {}) {
|
|
206
|
+
const userData = appDataDir(hostAppName(execPath), { platform, homedir });
|
|
207
|
+
try {
|
|
208
|
+
const raw = fs.readFileSync(path.join(userData, "profile-selection", "state.json"), "utf8");
|
|
209
|
+
const active = JSON.parse(raw)?.active;
|
|
210
|
+
if (typeof active !== "string" || !active) return null;
|
|
211
|
+
if (!fs.statSync(path.join(homedir, ".dsh", "profiles", active, "package.json")).isFile()) return null;
|
|
212
|
+
return active;
|
|
213
|
+
} catch (error) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
92
218
|
/**
|
|
93
219
|
* Profile used for installs.
|
|
94
220
|
*
|
|
@@ -101,7 +227,14 @@ const PROFILE = (() => {
|
|
|
101
227
|
const flag = process.argv.indexOf("--profile");
|
|
102
228
|
if (flag >= 0 && process.argv[flag + 1]) return process.argv[flag + 1];
|
|
103
229
|
if (process.env.DSH_DPHARNESS_PROFILE) return process.env.DSH_DPHARNESS_PROFILE;
|
|
104
|
-
|
|
230
|
+
const fromArgv = profileFromArgv();
|
|
231
|
+
if (fromArgv) return fromArgv;
|
|
232
|
+
/* Third-party Electron shell: ask its own state instead of assuming "web". */
|
|
233
|
+
if (HOST_CLIENT === "td") {
|
|
234
|
+
const fromState = thirdPartyProfile();
|
|
235
|
+
if (fromState) return fromState;
|
|
236
|
+
}
|
|
237
|
+
return "web";
|
|
105
238
|
})();
|
|
106
239
|
|
|
107
240
|
/**
|
|
@@ -233,13 +366,17 @@ function dshInvocation() {
|
|
|
233
366
|
* …/Contents) and `accessSync`-checked before use, so an unexpected layout
|
|
234
367
|
* degrades to the previous behaviour instead of spawning something wrong.
|
|
235
368
|
*/
|
|
236
|
-
export function desktopShellCli(execPath = process.execPath, isElectron = typeof process.versions?.electron === "string") {
|
|
369
|
+
export function desktopShellCli(execPath = process.execPath, isElectron = typeof process.versions?.electron === "string", client = hostClientOf({ execPath, isElectron })) {
|
|
237
370
|
if (!isElectron) return null;
|
|
238
371
|
const contents = path.resolve(path.dirname(execPath), "..");
|
|
239
372
|
const candidates = [
|
|
240
373
|
path.join(contents, "Resources", "runtime", "cli", "bin", "dsh"),
|
|
241
374
|
path.join(contents, "Resources", "runtime", "cli", "bin", "dsh.cmd"),
|
|
242
375
|
];
|
|
376
|
+
/* Third-party shells ship their CLI outside the bundle (see thirdPartyCliCandidates). */
|
|
377
|
+
if (client === "td" || client === "tu") {
|
|
378
|
+
candidates.push(...thirdPartyCliCandidates(appDataDir(hostAppName(execPath))));
|
|
379
|
+
}
|
|
243
380
|
for (const candidate of candidates) {
|
|
244
381
|
try {
|
|
245
382
|
fs.accessSync(candidate, fs.constants.X_OK);
|
|
@@ -1249,6 +1386,12 @@ function buildTrackPayload(input) {
|
|
|
1249
1386
|
// 版本号由 host 统一附加(客户端读不到 package.json)。
|
|
1250
1387
|
// 这是「新埋点覆盖率」的唯一判据:老版本插件永远发不出新事件,
|
|
1251
1388
|
// 看板上的空值既可能是"没人做过"也可能是"老版本没上报",只有版本维能切开。
|
|
1389
|
+
/* 宿主客户端维度(2026-10-24)。位置刻意放在 `v=` **之前**:
|
|
1390
|
+
`v=` 是覆盖率判据,必须留在末尾 —— 截断先吃尾部,把它切掉就等于
|
|
1391
|
+
丢掉"这条是不是老版本发的"这个唯一可信的判断依据。
|
|
1392
|
+
实测 30 天 plugin_hub 的 value 最长 75 字符,加 `:c=td` 后仍远低于站点
|
|
1393
|
+
120 字符上限。 */
|
|
1394
|
+
parts.push("c=" + HOST_CLIENT);
|
|
1252
1395
|
parts.push("v=" + VERSION);
|
|
1253
1396
|
value = parts.join(":").slice(0, 120);
|
|
1254
1397
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dpharness",
|
|
3
3
|
"icon": "./icon.svg",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.9",
|
|
5
5
|
"description": "Curated dpharness.com plugin catalog inside the DeepSeek Harness Web GUI: a conversation-view tab, a sidebar entry and a dismissible site-wide floating panel, offering a searchable full catalog, a monthly by-category shortlist, a daily pick and an update check (this plugin plus every installed plugin) with a red-dot reminder, with one-click install via dshmarket or the dsh CLI. Includes a settings page (General row + Plugins tab) for the widget visibility, the daily pick, the update check and the opt-out telemetry relay covering the full install funnel.",
|
|
6
6
|
"author": "zhanghao3693 <zhanghao3693@qq.com>",
|
|
7
7
|
"repository": {
|