dsh-pick 0.4.2 → 0.4.4

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 AIcivilization
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,5 +1,10 @@
1
1
  # dsh-pick
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/dsh-pick.svg?style=flat-square)](https://www.npmjs.com/package/dsh-pick)
4
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-pick.svg?style=flat-square)](https://www.npmjs.com/package/dsh-pick)
5
+ [![license](https://img.shields.io/npm/l/dsh-pick.svg?style=flat-square)](LICENSE)
6
+ [![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/plugins/aicivilization/dsh-pick)
7
+
3
8
  **帮你在 DSH 生态里选对插件。**
4
9
 
5
10
  说需求 → 找候选 → 多维比较 → 出结论。下载量只是证据,判断才算数。
@@ -10,6 +15,21 @@
10
15
 
11
16
  ---
12
17
 
18
+ ## 安装
19
+
20
+ ```sh
21
+ dsh plugin --profile web add dsh-pick # DSH 插件(推荐)
22
+ npm i -g dsh-pick # 命令行 / 独立网页
23
+ dsh plugin --profile web add github:AIcivilization/dsh-pick # 源码安装
24
+ ```
25
+
26
+ - **能力分类**:工具与能力(插件选购顾问)
27
+ - **运行要求**:Node.js ≥ 20;DSH web profile(右侧栏面板 + 设置页)
28
+ - **许可证**:[MIT](LICENSE)
29
+ - **数据边界**:只读公开的 npm API 和本仓库的每日目录,不外传任何数据
30
+
31
+ ---
32
+
13
33
  ## 为什么需要它
14
34
 
15
35
  npm 官网和各类 stat 站能看数字,但看数字回答不了「我该装哪个」。
@@ -200,4 +220,13 @@ npm run release -- patch -m "改了什么" --dry-run # 演练:只检查、
200
220
 
201
221
  ## 许可
202
222
 
203
- MIT
223
+ [MIT](LICENSE) · Copyright © 2026 AIcivilization
224
+
225
+ ---
226
+
227
+ ## 收录渠道
228
+
229
+ - [DSH Plugin Hub(dsh-plugin.org 社区插件市场)](https://dsh-plugin.org/plugins/aicivilization/dsh-pick)
230
+ - [awesome-dsh-plugin 精选列表](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
231
+ - dsh-plugin-shop 插件商店(每日自动收录)
232
+ - 52DSH / tuofangzhe 插件目录(证据分级收录)
package/lib/remote.js CHANGED
@@ -7,7 +7,7 @@
7
7
  //
8
8
  // 镜像按顺序试:jsDelivr 国内一般能直连;raw.githubusercontent.com 兜底。
9
9
 
10
- import { mkdir, readFile, rename, writeFile } from 'node:fs/promises'
10
+ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'
11
11
  import { dirname, join } from 'node:path'
12
12
  import { cachePath, dshHome, loadCatalog, newerCatalog, reloadCatalog } from './engine.js'
13
13
 
@@ -30,11 +30,30 @@ async function readState(env) {
30
30
  }
31
31
  }
32
32
 
33
- async function writeAtomic(file, text) {
33
+ // Windows 上目标文件被别的进程短暂打开(杀毒软件扫描、DSH 正在读)时,替换会报这几种错;
34
+ // 等一下通常就好了
35
+ const BUSY = new Set(['EPERM', 'EBUSY', 'EACCES'])
36
+
37
+ /**
38
+ * 先写临时文件再改名替换:替换是原子的,读的一方要么看到旧文件、要么看到完整的新文件。
39
+ * 被占用就退避重试几次;最后还是不行,删掉临时文件、把错抛出去(这一轮不换,下一轮再试)
40
+ */
41
+ export async function writeAtomic(file, text, { tries = 5, wait = 150, renameImpl = rename } = {}) {
34
42
  await mkdir(dirname(file), { recursive: true })
35
43
  const tmp = `${file}.${process.pid}.tmp`
36
44
  await writeFile(tmp, text, 'utf8')
37
- await rename(tmp, file)
45
+ for (let i = 1; ; i++) {
46
+ try {
47
+ await renameImpl(tmp, file)
48
+ return
49
+ } catch (e) {
50
+ if (!BUSY.has(e && e.code) || i >= tries) {
51
+ await rm(tmp, { force: true }).catch(() => {})
52
+ throw e
53
+ }
54
+ await new Promise(r => setTimeout(r, wait * 2 ** (i - 1)))
55
+ }
56
+ }
38
57
  }
39
58
 
40
59
  async function getJson(fetchImpl, url, timeoutMs) {
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "dsh-pick",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "帮你在 DSH 生态里选对插件:说需求 → 找候选 → 多维比较 → 出结论。下载量是证据,AI 是推理。",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/AIcivilization/dsh-pick.git"
8
+ },
9
+ "homepage": "https://github.com/AIcivilization/dsh-pick#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/AIcivilization/dsh-pick/issues"
12
+ },
5
13
  "type": "module",
6
14
  "main": "./plugin/index.js",
7
15
  "exports": {
@@ -30,7 +38,8 @@
30
38
  "plugin",
31
39
  "web",
32
40
  "data",
33
- "README.md"
41
+ "README.md",
42
+ "LICENSE"
34
43
  ],
35
44
  "keywords": [
36
45
  "dsh-plugin",
package/plugin/index.js CHANGED
@@ -108,9 +108,15 @@ function managerCode(result) {
108
108
  * 官方桌面版(0.2.1-rc.2 实测)的插件管理器不能在运行中升级已装的插件:installBundle 一律答
109
109
  * already-installed(插件市场的「更新」也栽在这里)。只能退出 DSH、在终端用 dsh plugin 装
110
110
  */
111
- const ALREADY_INSTALLED_HINT =
112
- '这个版本的 DSH 不能在运行中升级已装的插件。请完全退出 DSH(Mac 上按 Cmd+Q,不是关窗口),' +
113
- '在终端执行下面的命令,再重新打开 DSH。如果提示版本太新(发布不满 1 天),过一天再执行。'
111
+ export function alreadyInstalledHint(platform = process.platform) {
112
+ // 「完全退出」各系统做法不一样:关窗口不算,DSH 还在后台跑
113
+ const quit = platform === 'darwin' ? '按 Cmd+Q,不是关窗口'
114
+ : platform === 'win32' ? '在任务栏右下角的托盘图标上右键 → 退出,不是关窗口'
115
+ : '关掉所有窗口,并确认 DSH 进程已经结束'
116
+ const terminal = platform === 'win32' ? 'PowerShell 或命令提示符' : '终端'
117
+ return `这个版本的 DSH 不能在运行中升级已装的插件。请完全退出 DSH(${quit}),` +
118
+ `在${terminal}里执行下面的命令,再重新打开 DSH。如果提示版本太新(发布不满 1 天),过一天再执行。`
119
+ }
114
120
 
115
121
  function managerError(result) {
116
122
  if (!(result && (result.application === 'failed' || result.application === 'cancelled' || result.error))) return ''
@@ -315,12 +321,12 @@ export function apply(ctx) {
315
321
  }
316
322
  try {
317
323
  const result = await pluginManager.installBundle(`${PACKAGE}@${latest}`, { enabled: true })
318
- if (managerCode(result) === 'already-installed') return sendJson(res, 200, { ok: false, message: ALREADY_INSTALLED_HINT, command })
324
+ if (managerCode(result) === 'already-installed') return sendJson(res, 200, { ok: false, message: alreadyInstalledHint(), command })
319
325
  const err = managerError(result)
320
326
  if (err) return sendJson(res, 200, { ok: false, message: `更新失败(${err})`, command })
321
327
  return sendJson(res, 200, { ok: true, version: latest })
322
328
  } catch (e) {
323
- if (e && e.code === 'already-installed') return sendJson(res, 200, { ok: false, message: ALREADY_INSTALLED_HINT, command })
329
+ if (e && e.code === 'already-installed') return sendJson(res, 200, { ok: false, message: alreadyInstalledHint(), command })
324
330
  return sendJson(res, 200, { ok: false, message: `更新失败:${e.message}`, command })
325
331
  }
326
332
  },