mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:00:22 +08:00
fix: 支持 DSH Desktop 解包依赖路径探测
This commit is contained in:
1 parent
852f9d9e39
commit
4d47ce69dc
4 files changed
+36
-6
No files matched your search
@@ -211,9 +211,10 @@ prompt-inject.md 有内容? ──是──> 注入 systemPrompt section
|
||||
按优先级自动定位:
|
||||
|
||||
1. `DSH_BASE` 环境变量 → 插件根
|
||||
2. `npm prefix -g` / `npm config get prefix` → npm 全局目录
|
||||
3. 从全局目录反推 `node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai`
|
||||
4. 递归搜索兜底
|
||||
2. DSH Desktop → `process.resourcesPath/app.asar.unpacked/node_modules/@deepseek-ai`
|
||||
3. `npm prefix -g` / `npm config get prefix` → npm 全局目录
|
||||
4. 从全局目录反推 `node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai`
|
||||
5. 递归搜索兜底
|
||||
|
||||
探测失败提示设置 `DSH_BASE`,不清除、不误伤。
|
||||
|
||||
|
||||
+4
-3
@@ -206,9 +206,10 @@ prompt-inject.md 有内容? ──是──> 注入 systemPrompt section
|
||||
按优先级自动定位:
|
||||
|
||||
1. `DSH_BASE` 环境变量 → 插件根
|
||||
2. `npm prefix -g` / `npm config get prefix` → npm 全局目录
|
||||
3. 从全局目录反推 `node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai`
|
||||
4. 递归搜索兜底
|
||||
2. DSH Desktop → `process.resourcesPath/app.asar.unpacked/node_modules/@deepseek-ai`
|
||||
3. `npm prefix -g` / `npm config get prefix` → npm 全局目录
|
||||
4. 从全局目录反推 `node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai`
|
||||
5. 递归搜索兜底
|
||||
|
||||
探测失败提示设置 `DSH_BASE`,不清除、不误伤。
|
||||
|
||||
|
||||
+25
@@ -61,6 +61,28 @@ export function findShimDir() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位 DSH Desktop 解包后的 @deepseek-ai 依赖目录。
|
||||
* Electron 将 app.asar 中标记为 unpacked 的文件放在相邻目录,补丁应写入该真实路径。
|
||||
*/
|
||||
function findDesktopAiBase() {
|
||||
const candidates = [];
|
||||
if (typeof process.resourcesPath === "string" && process.resourcesPath.trim()) {
|
||||
candidates.push(path.join(process.resourcesPath, "app.asar.unpacked", "node_modules", "@deepseek-ai"));
|
||||
}
|
||||
|
||||
// ELECTRON_RUN_AS_NODE 模式没有稳定的 resourcesPath,按可执行文件位置回推 Contents/Resources。
|
||||
const contentsDir = path.dirname(path.dirname(process.execPath));
|
||||
candidates.push(path.join(contentsDir, "Resources", "app.asar.unpacked", "node_modules", "@deepseek-ai"));
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (fs.existsSync(path.join(candidate, "dsh-agent-instructions", "lib"))) {
|
||||
return path.normalize(candidate);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function findAiBase() {
|
||||
const env = process.env.DSH_BASE;
|
||||
if (env && env.trim()) {
|
||||
@@ -68,6 +90,9 @@ export function findAiBase() {
|
||||
if (fs.existsSync(path.join(p, "dsh-agent-instructions", "lib"))) return p;
|
||||
}
|
||||
|
||||
const desktopBase = findDesktopAiBase();
|
||||
if (desktopBase) return desktopBase;
|
||||
|
||||
const rel = path.join("node_modules", "@deepseek-ai", "dsh", "node_modules", "@deepseek-ai");
|
||||
|
||||
const prefix = findNpmPrefix();
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
"bin": {
|
||||
"dsh-purge": "bin/dsh-purge.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node --test"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"bin",
|
||||
|
||||
Reference in new issue
Block a user