@yigh/dsh-agent-company 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yigh/dsh-agent-company",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "skill/index.js",
6
6
  "icon": "icon.svg",
@@ -6,19 +6,42 @@
6
6
  //
7
7
  // @deepseek-ai/dsh-agent-preset ships inside the DSH installation, not in the
8
8
  // profile's node_modules, so a bare specifier cannot resolve it from here.
9
- // Resolve the entry from the running install root instead — the install root
10
- // comes from DSH_INSTALL_DIR when present, otherwise from the Electron
11
- // executable's location (plugin processes do not inherit DSH_* env vars).
9
+ // Locate the install root cross-platform:
10
+ // - macOS Electron: <app>/Contents/Resources/app.asar (process.resourcesPath)
11
+ // - Windows Electron: <install>/resources/app.asar (process.resourcesPath)
12
+ // - DSH_INSTALL_DIR when provided (points at .../dsh/node_modules/@deepseek-ai/dsh)
13
+ // Deriving resources from dirname(process.execPath) is WRONG on macOS: the
14
+ // executable is in Contents/MacOS while resources live in Contents/Resources.
12
15
 
16
+ import fs from 'node:fs'
13
17
  import path from 'node:path'
18
+ import { pathToFileURL } from 'node:url'
14
19
 
15
- function presetEntry() {
16
- const installDir = process.env.DSH_INSTALL_DIR
17
- || path.join(path.dirname(process.execPath), 'resources', 'app.asar', 'dsh', 'node_modules', '@deepseek-ai', 'dsh')
18
- const base = installDir.replace(/\\/g, '/').replace(/\/$/, '').replace(/\/node_modules\/@deepseek-ai\/dsh$/, '')
19
- return `file:///${base}/node_modules/@deepseek-ai/dsh-agent-preset/lib/index.js`
20
+ const REL = ['app.asar', 'dsh', 'node_modules', '@deepseek-ai', 'dsh-agent-preset', 'lib', 'index.js']
21
+
22
+ function findEntry() {
23
+ const candidates = []
24
+
25
+ // 1) Electron 的 resources 目录(跨平台最可靠)。
26
+ if (process.resourcesPath) candidates.push(path.join(process.resourcesPath, ...REL))
27
+ // 2) DSH_INSTALL_DIR 环境变量:值为 <install>/dsh/node_modules/@deepseek-ai/dsh
28
+ // 向上三级回到 <install> 后拼相对路径。
29
+ if (process.env.DSH_INSTALL_DIR) {
30
+ const root = path.resolve(process.env.DSH_INSTALL_DIR, '..', '..', '..')
31
+ candidates.push(path.join(root, ...REL))
32
+ }
33
+ // 3) execPath 推导(旧逻辑,仅作最后兜底,Windows 正确、macOS 可能失败)。
34
+ candidates.push(path.join(path.dirname(process.execPath), 'resources', ...REL))
35
+
36
+ for (const file of candidates) {
37
+ try {
38
+ if (fs.existsSync(file)) return pathToFileURL(file).href
39
+ } catch { /* 忽略不可访问的候选路径 */ }
40
+ }
41
+ throw new Error('[ai-company] cannot locate @deepseek-ai/dsh-agent-preset; tried: '
42
+ + candidates.join(' | '))
20
43
  }
21
44
 
22
- const official = await import(presetEntry())
45
+ const official = await import(findEntry())
23
46
 
24
47
  export default official.default