dsh-dpharness 0.6.8 → 0.6.10

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 CHANGED
@@ -37,6 +37,25 @@ export function npmLatestUrl(pkg) {
37
37
  * (用户要看的是行为变化,不是我们的 commit 分类)。
38
38
  */
39
39
  export const CHANGELOG = [
40
+ {
41
+ version: "0.6.10",
42
+ date: "2026-10-27",
43
+ title: "「今日推荐」点开分享后,卡片不再被撑破",
44
+ items: [
45
+ "侧栏今日推荐卡里点「分享」:按钮不再溢出卡片右边界,「复制命令」也不会被挤到下一行。收起留在原位,复制链接 / 复制文案 / 说明图各占一格。",
46
+ "窗口拉窄成单列时,命令条改成真正的一行排开,不再出现半屏宽的按钮。",
47
+ ],
48
+ },
49
+ {
50
+ version: "0.6.9",
51
+ date: "2026-10-24",
52
+ title: "第三方客户端(DSH Desktop)里的一键安装修好了",
53
+ items: [
54
+ "在 DSH Desktop 里点「一键安装」不再报「找不到 dsh 入口」:它会用该客户端自带的 CLI,并装进你当前正在用的 profile,而不是错装到另一个 profile。",
55
+ "安装环境上报新增「客户端」一项(官方桌面 / 官方 Web / 第三方),用于站点把两个客户端的数据分开统计。仍然是匿名、可整体关闭,不含账号、路径或搜索词。",
56
+ "官方客户端(桌面版与 Web 版)的安装与统计行为不变。",
57
+ ],
58
+ },
40
59
  {
41
60
  version: "0.6.8",
42
61
  date: "2026-10-23",
package/lib/client.js CHANGED
@@ -331,10 +331,26 @@ window.__ModuleLoader__.load({
331
331
  ".dph_cardFav{border-left:3px solid var(--dsw-alias-state-business-primary);padding-left:11px}",
332
332
  /* 选中卡里的主按钮改回白底:浅蓝底 + 蓝描边按钮叠在一起会糊成一片 */
333
333
  ".dph_cardOn .dph_btnPrimary{background:var(--dsw-alias-bg-layer-1)}",
334
- /* 右栏命令条是两列网格:命令跨两列,复制/分享各占一格(展开态自然排成 2×2) */
334
+ /* 右栏命令条是两列网格:命令跨两列,复制/分享各占一格 */
335
335
  ".dph_cmdbarCol .dph_cmdbarCode{grid-column:1/-1;font-size:11.5px}",
336
336
  ".dph_cmdbarCol .dph_shareWrap,.dph_cmdbarCol .dph_shareWrap .dph_btn{width:100%}",
337
337
  ".dph_cmdbarCol .dph_shareWrap .dph_btn{height:28px;padding:0 6px;font-size:11.5px}",
338
+ /* 侧栏窄格里的分享展开态(2026-10-27 真机截图:「今日推荐」点开分享后 UI 错乱):
339
+ 原先 4 个动作一起塞进命令条的一个 1fr 单元格,nowrap 按钮的 min-content 把
340
+ 轨道撑开 ⇒ 命令条溢出卡片右边界、「复制命令」被挤到下一行、说明图单独漂在底部。
341
+ 现在收起留在原格(与复制命令同排),三个动作跨满整行按 2 列排,说明图独占末行。
342
+ ⚠️ 只在 .dph_shareWrapStack(stack=true 的唯一调用点:今日推荐侧栏卡)生效,
343
+ 浮窗 372px 与宽命令条 700px 的既有排布不受影响 —— 那两处实测本来就是通的。 */
344
+ ".dph_cmdbarCol .dph_shareToggle{width:100%}",
345
+ ".dph_cmdbarCol .dph_shareWrapStack{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;gap:6px;width:100%}",
346
+ ".dph_cmdbarCol .dph_shareWrapStack .dph_shareCard{grid-column:1/-1}",
347
+ /* 窄屏(<900px)时 .dph_rail 变 display:contents,今日推荐卡横跨整行 —— 212px 那一套
348
+ 「命令跨两列 + 复制/分享各占一格」的 2 列网格在这里会变成两颗 500px 的巨型按钮。
349
+ 媒体查询里原本写的 flex-direction:row 对 grid 元素无效(那时候还没改成 grid),
350
+ 这里把它落实成真正的横排:命令弹性收窄,动作按内容宽,放不下就整组换行。
351
+ 顺带收掉同断点的 .dph_instRow .dph_btn min-width:50% —— 那是给 212px 侧栏量的,
352
+ 整行卡片里会把「安装」按钮拉成半屏宽。 */
353
+ "@media (max-width:900px){.dph_cmdbarCol{display:flex;flex-wrap:wrap;align-items:center}.dph_cmdbarCol .dph_cmdbarCode{flex:1;min-width:0}.dph_cmdbarCol .dph_shareWrap{width:auto}.dph_cmdbarCol .dph_shareWrap .dph_btn{width:auto;padding:0 12px;font-size:12px}.dph_cmdbarCol .dph_shareToggle{width:auto;padding:0 12px;font-size:12px}.dph_cmdbarCol .dph_shareWrapStack{display:inline-flex;flex-wrap:wrap;gap:4px;width:auto}.dph_cmdbarCol .dph_shareWrapStack .dph_btn{width:auto;padding:0 12px;font-size:12px}.dph_railCard .dph_instRow .dph_btn{min-width:0}}",
338
354
  /* 响应式(2026-10-21):主列单栏时宽卡也拆单列,操作轨道转横排成一条动作行 */
339
355
  "@media (max-width:900px){.dph_cardLg{grid-template-columns:minmax(0,1fr);gap:10px}.dph_opRail{flex-direction:row;flex-wrap:wrap;margin-top:2px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2)}.dph_opRail .dph_btn{flex:1 1 0;min-width:0}.dph_rail{position:static}}",
340
356
  ].join("");
@@ -3356,6 +3372,12 @@ window.__ModuleLoader__.load({
3356
3372
  const item = props.item || {};
3357
3373
  const fullName = typeof item.fullName === "string" ? item.fullName : "";
3358
3374
  const scope = props.scope || "";
3375
+ /* stack(2026-10-27)只换「动作怎么摆」,不动任何行为:
3376
+ 212px 侧栏的命令条是 2 列 grid,展开后 4 个动作挤在同一个单元格里会撑破轨道
3377
+ (真机截图:按钮溢出卡片右边界、复制命令被挤到下一行)。
3378
+ stack=true 时收起留在原格,另外三个动作作为一整块跨满行 —— 见 CSS 注释。
3379
+ 其余调用点(浮窗 372px / 宽命令条 700px / 窄卡行内)不传,排布与原来逐像素一致。 */
3380
+ const stack = !!props.stack;
3359
3381
  const [open, setOpen] = react.useState(false);
3360
3382
  const [done, setDone] = react.useState("");
3361
3383
  /* 没有 owner/repo 就拼不出详情页(站点 /plugin/<owner>/<repo> 需要两段)——
@@ -3370,7 +3392,7 @@ window.__ModuleLoader__.load({
3370
3392
  track("plugin_hub", { action: kind === "link" ? "share_link" : "share_text", scope });
3371
3393
  });
3372
3394
  const toggle = h("button", {
3373
- className: "dph_btn" + (open ? " dph_btnPrimary" : ""),
3395
+ className: "dph_btn" + (stack ? " dph_shareToggle" : "") + (open ? " dph_btnPrimary" : ""),
3374
3396
  key: "toggle",
3375
3397
  type: "button",
3376
3398
  title: open ? t("share.closeHint") : t("share.toggle"),
@@ -3384,8 +3406,7 @@ window.__ModuleLoader__.load({
3384
3406
  400px 浮窗里多一个按钮就多占一行,而这两个本来就是同一个开关。 */
3385
3407
  }, open ? t("share.collapse") : t("share.action"));
3386
3408
  if (!open) return h("span", { className: "dph_shareWrap", key: "share" }, [toggle]);
3387
- return h("span", { className: "dph_shareWrap dph_shareWrapOpen", key: "share" }, [
3388
- toggle,
3409
+ const acts = [
3389
3410
  h("button", {
3390
3411
  className: "dph_btn dph_btnSm",
3391
3412
  key: "link",
@@ -3401,7 +3422,7 @@ window.__ModuleLoader__.load({
3401
3422
  onClick: () => copy("text", shareTextOf(item)),
3402
3423
  }, done === "text" ? t("action.copied") : t("share.text")),
3403
3424
  h("a", {
3404
- className: "dph_btn dph_btnSm",
3425
+ className: "dph_btn dph_btnSm" + (stack ? " dph_shareCard" : ""),
3405
3426
  key: "card",
3406
3427
  href: shareCardOf(fullName),
3407
3428
  target: "_blank",
@@ -3409,7 +3430,16 @@ window.__ModuleLoader__.load({
3409
3430
  title: t("share.cardHint"),
3410
3431
  onClick: () => track("plugin_hub", { action: "share_card", scope }),
3411
3432
  }, t("share.card")),
3412
- ]);
3433
+ ];
3434
+ if (stack) {
3435
+ /* Fragment 不产生盒子:两个子项直接成为命令条 grid 的项 ——
3436
+ 收起落在「复制命令」右边那一格,动作块因 grid-column:1/-1 自动落到下一行。 */
3437
+ return h(react.Fragment, { key: "share" }, [
3438
+ toggle,
3439
+ h("span", { className: "dph_shareWrap dph_shareWrapOpen dph_shareWrapStack", key: "acts" }, acts),
3440
+ ]);
3441
+ }
3442
+ return h("span", { className: "dph_shareWrap dph_shareWrapOpen", key: "share" }, [toggle].concat(acts));
3413
3443
  }
3414
3444
 
3415
3445
  /**
@@ -4895,8 +4925,10 @@ window.__ModuleLoader__.load({
4895
4925
  }),
4896
4926
  }, copiedCmd === item.cmd ? t("action.copied") : t("action.copy")),
4897
4927
  /* 侧栏这条命令条是**自建**的(不走 renderCard),所以分享要单独接一次。
4898
- 2026-10-21 首版漏了这一处:用户在真机截图里发现"今日推荐卡没有分享"。 */
4899
- h(ShareUnit, { item: item, scope: "rail", key: "share" }),
4928
+ 2026-10-21 首版漏了这一处:用户在真机截图里发现"今日推荐卡没有分享"。
4929
+ stack=true(2026-10-27):这个格子只有 88px,展开的四个动作放不下 ——
4930
+ 改成"收起留在原格 + 三个动作跨满行",否则会撑破卡片。 */
4931
+ h(ShareUnit, { item: item, scope: "rail", stack: true, key: "share" }),
4900
4932
  ])
4901
4933
  : null,
4902
4934
  item.reason ? h("p", { className: "dph_railWhy", key: "why" }, t("daily.why") + ":" + item.reason) : null,
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.8";
51
+ export const VERSION = "0.6.10";
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
- return profileFromArgv() || "web";
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.8",
4
+ "version": "0.6.10",
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": {