@pkkkkh/dsh-restart 0.2.6 → 0.2.8

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/README.md CHANGED
@@ -173,7 +173,7 @@ EBUSY: resource busy or locked —— 是**启动脚本那一侧独占了该文
173
173
 
174
174
  实测结果(2026-11-16 18:40 重启):
175
175
 
176
- - [watchdog] started pid=3048 via D:/DSH/resources/runtime/primary-runtime/dependencies/node/bin/node.exe
176
+ - [watchdog] started pid=3048 via <DSH 安装目录>/resources/runtime/primary-runtime/dependencies/node/bin/node.exe
177
177
  - [boot] /restart command registered
178
178
  - restart_status:当前进程 pid=10688 vs 上次排程 pid=26456 → 判定:进程已更替 ✅
179
179
  - 心跳每 5 秒刷新;重启播报正常发出
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@
24
24
  import { spawn } from "node:child_process";
25
25
  import { appendFileSync, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
26
26
  import { readFile } from "node:fs/promises";
27
- import { dirname } from "node:path";
27
+ import { dirname, join } from "node:path";
28
28
  import z from "@deepseek-ai/schemastery";
29
29
  import { defineTool } from "@deepseek-ai/dsh-tools";
30
30
  import { fileURLToPath } from "node:url";
@@ -372,8 +372,9 @@ export function apply(ctx, config) {
372
372
  configured,
373
373
  process.env.DSH_NODE || "",
374
374
  process.env.DSH_RUNTIME ? process.env.DSH_RUNTIME + "/dependencies/node/bin/node.exe" : "",
375
- "D:/DSH/resources/runtime/primary-runtime/dependencies/node/bin/node.exe",
376
- DSH_HOME_DEFAULT + "/dsh-runtimes/dsh-primary-runtime/dependencies/node/bin/node.exe",
375
+ // 不写死安装路径:跟着当前 Electron 的 execPath 推导,再退回 DSH_HOME 下的运行时目录
376
+ (() => { try { return join(dirname(process.execPath), "resources", "runtime", "primary-runtime", "dependencies", "node", "bin", "node.exe"); } catch { return ""; } })(),
377
+ process.env.DSH_HOME ? join(process.env.DSH_HOME, "dsh-runtimes", "dsh-primary-runtime", "dependencies", "node", "bin", "node.exe") : "",
377
378
  ].filter(Boolean);
378
379
  for (const candidate of candidates) {
379
380
  try { if (existsSync(candidate)) return { path: candidate, electron: false }; } catch { /* next */ }
@@ -477,6 +478,13 @@ export function apply(ctx, config) {
477
478
  return { ok: false, text: "重启没有排上 ❌\n原因:找不到日志目录 " + dirname(logFile) };
478
479
  }
479
480
 
481
+ // 公开版不写死 exe 路径:把当前 app 的可执行文件记下来,start 半段脚本会优先读它。
482
+ try {
483
+ const stateDir = PLUGIN_ROOT + "/.state";
484
+ mkdirSync(stateDir, { recursive: true });
485
+ writeFileSync(stateDir + "/app-exe.txt", process.execPath, "utf8");
486
+ } catch { /* 记不下来就让 start 脚本走候选探测 */ }
487
+
480
488
  const result = await runProcess(powershell,
481
489
  buildArmArgs({ script, killSeconds: timings.killSeconds, startSeconds: timings.startSeconds, startScript, watchSeconds }),
482
490
  20000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkkkkh/dsh-restart",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Safe self-restart for DeepSeek Harness: arms a scheduled kill + start pair through the vetted restart scripts so an IM/Web session can restart the app itself.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -35,6 +35,7 @@
35
35
  "files": [
36
36
  "lib",
37
37
  "scripts",
38
+ "NOTICE.md",
38
39
  "cordis.patch.yml",
39
40
  "README.md",
40
41
  "LICENSE"
@@ -42,4 +43,4 @@
42
43
  "publishConfig": {
43
44
  "access": "public"
44
45
  }
45
- }
46
+ }
@@ -16,11 +16,28 @@
16
16
  # Exit codes: 0 = process up and survived the confirmation window; 1 = gave up.
17
17
  # ASCII only: PowerShell 5.1 misreads BOM-less UTF-8.
18
18
 
19
+ param([string]$Exe = "")
20
+
19
21
  $ErrorActionPreference = "Continue"
20
- $exe = "D:\DSH\DeepSeek Harness.exe"
21
22
 
22
- if (-not (Test-Path -LiteralPath $exe)) {
23
- " START: exe not found: $exe"
23
+ # Do not hardcode an install path: -Exe > DSH_APP_EXE > <plugin>\.state\app-exe.txt > common install dirs
24
+ $candidates = New-Object System.Collections.ArrayList
25
+ if ($Exe) { [void]$candidates.Add($Exe) }
26
+ if ($env:DSH_APP_EXE) { [void]$candidates.Add($env:DSH_APP_EXE) }
27
+ $stateFile = Join-Path (Split-Path -Parent $PSScriptRoot) ".state\app-exe.txt"
28
+ if (Test-Path -LiteralPath $stateFile) {
29
+ $fromState = Get-Content -LiteralPath $stateFile -TotalCount 1
30
+ if ($fromState) { [void]$candidates.Add($fromState.Trim()) }
31
+ }
32
+ foreach ($base in @($env:ProgramFiles, ${env:ProgramFiles(x86)}, (Join-Path $env:LOCALAPPDATA "Programs"))) {
33
+ if ($base) { [void]$candidates.Add((Join-Path $base "DeepSeek Harness\DeepSeek Harness.exe")) }
34
+ }
35
+ $exe = $null
36
+ foreach ($c in $candidates) {
37
+ if ($c -and (Test-Path -LiteralPath $c)) { $exe = $c; break }
38
+ }
39
+ if (-not $exe) {
40
+ " START: DSH exe not found; pass -Exe, set DSH_APP_EXE, or write .state\app-exe.txt"
24
41
  exit 1
25
42
  }
26
43