@noob-stupid/dsh-plugin-console 0.3.12 → 0.3.13

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.
Files changed (2) hide show
  1. package/lib/index.js +53 -0
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -3498,6 +3498,59 @@ async function handle(ctx, req, res) {
3498
3498
  ` if ($code -ne 0) { Log ('(停服后)npmmirror 安装失败(exit=' + $code + '),切换 registry.npmjs.org 重试一次'); $code = Install-Framework 'https://registry.npmjs.org' }`,
3499
3499
  `}`,
3500
3500
  `if ($code -ne 0) { Invoke-Rollback } else { Log '框架本体升级完成' }`,
3501
+ // 重新链接框架配套包(事故教训):pnpm 升级到新版本时 .pnpm 目录重建,
3502
+ // 但顶层 node_modules/@deepseek-ai/* 不会自动切换,仍指向旧版(如 0.1.0-rc.7)——
3503
+ // 导致框架混版本(如 dsh-llm-deepseek 旧版无 vision 模型)、部分功能异常。
3504
+ // 升级成功后:遍历顶层 @deepseek-ai 的 dsh-* 包,读 .pnpm 主目录里的最新版本,
3505
+ // 若与顶层不一致则重建为 Junction(旧版备份 .bak-rc7)。
3506
+ `$relinked = 0`,
3507
+ `function Relink-FrameworkPackages($version) {`,
3508
+ ` # dshDir = .../node_modules/@deepseek-ai/dsh → nodeModules = .../node_modules`,
3509
+ ` $nodeModules = ${ps(dirname(dirname(dshDir)))}`,
3510
+ ` $pnpm = Join-Path $nodeModules '.pnpm'`,
3511
+ ` if (-not (Test-Path $pnpm)) { Log ('重链跳过:.pnpm 目录不存在'); return }`,
3512
+ ` $topPkgs = Get-ChildItem -Path (Join-Path $nodeModules '@deepseek-ai') -Directory | Where-Object { $_.Name -like 'dsh-*' }`,
3513
+ ` # 版本数值比较(修复:字符串比较在版本号位数变化时出错,如 0.1.10 < 0.1.9;PS5.1 兼容,不用三元运算符)`,
3514
+ ` function Compare-Version($a, $b) {`,
3515
+ ` if ($a -eq $b) { return 0 }`,
3516
+ ` $pa = [regex]::Match($a, '^(\d+)\.(\d+)\.(\d+)(?:-(?:[a-z]+\.)?(\d+))?' )`,
3517
+ ` $pb = [regex]::Match($b, '^(\d+)\.(\d+)\.(\d+)(?:-(?:[a-z]+\.)?(\d+))?' )`,
3518
+ ` if (-not $pa.Success -or -not $pb.Success) { return ($a.CompareTo($b)) }`,
3519
+ ` for ($i = 1; $i -le 4; $i++) {`,
3520
+ ` if ($pa.Groups[$i].Success) { $va = [int]$pa.Groups[$i].Value } else { $va = 2147483647 }`,
3521
+ ` if ($pb.Groups[$i].Success) { $vb = [int]$pb.Groups[$i].Value } else { $vb = 2147483647 }`,
3522
+ ` if ($va -ne $vb) { if ($va -lt $vb) { return -1 } else { return 1 } }`,
3523
+ ` }`,
3524
+ ` return 0`,
3525
+ ` }`,
3526
+ ` foreach ($top in $topPkgs) {`,
3527
+ ` $name = $top.Name`,
3528
+ ` $topPkgJson = Join-Path $top.FullName 'package.json'`,
3529
+ ` if (-not (Test-Path $topPkgJson)) { continue }`,
3530
+ ` try { $topVer = (Get-Content $topPkgJson -Raw | ConvertFrom-Json).version } catch { continue }`,
3531
+ ` # 找 .pnpm 里该包的所有主目录(@deepseek-ai+dsh-<name>@<ver>_<hash> 或 @deepseek-ai+dsh-<name>@<ver>-rc.x_<hash>)`,
3532
+ ` $cands = Get-ChildItem -Path $pnpm -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match ('^@deepseek-ai\\\\+dsh-' + [regex]::Escape($name.Substring(4)) + '@') }`,
3533
+ ` $best = $nil; $bestVer = ''`,
3534
+ ` foreach ($c in $cands) {`,
3535
+ ` $inner = Join-Path $c.FullName ('node_modules\\@deepseek-ai\\' + $name)`,
3536
+ ` $pj = Join-Path $inner 'package.json'`,
3537
+ ` if (-not (Test-Path $pj)) { continue }`,
3538
+ ` try { $v = (Get-Content $pj -Raw | ConvertFrom-Json).version } catch { continue }`,
3539
+ ` if ($best -eq $nil -or (Compare-Version $v $bestVer) -gt 0) { $bestVer = $v; $best = $inner }`,
3540
+ ` }`,
3541
+ ` if ($best -eq $nil) { continue }`,
3542
+ ` if ($bestVer -eq $topVer) { continue }`,
3543
+ ` try {`,
3544
+ ` $bak = $top.FullName + '.bak-' + $topVer`,
3545
+ ` if (Test-Path $bak) { Remove-Item $bak -Recurse -Force -ErrorAction SilentlyContinue }`,
3546
+ ` Rename-Item -LiteralPath $top.FullName -NewName ($name + '.bak-' + $topVer) -Force`,
3547
+ ` cmd /c mklink /J "${top.FullName}" "${best}" 2>$null | Out-Null`,
3548
+ ` if (Test-Path (Join-Path $top.FullName 'package.json')) { $script:relinked++; Log ('重链 ' + $name + ': ' + $topVer + ' -> ' + $bestVer) } else { Log ('重链失败:' + $name) }`,
3549
+ ` } catch { Log ('重链异常:' + $name + ' ' + $_.Exception.Message) }`,
3550
+ ` }`,
3551
+ `}`,
3552
+ `Relink-FrameworkPackages '${target}'`,
3553
+ `Log ('重链框架配套包完成(' + $script:relinked + ' 个)')`,
3501
3554
  pkgArgs.length > 0 ? `SetState 'pkg' '更新官方配套包…'\n Log '更新官方配套包…'\n Set-Location -Path ${ps(profileDir2)}\n if (Test-Path ${ps(corepackJs)}) {\n $pp = Start-Process -FilePath ${ps(nodePath)} -ArgumentList @(${ps(corepackJs)}, 'pnpm', 'update', ${pkgArgs.join(', ')}, '--no-optional', '--registry', 'https://registry.npmmirror.com') -PassThru -WindowStyle Hidden\n if (-not $pp.WaitForExit(300000)) { Stop-Process -Id $pp.Id -Force -ErrorAction SilentlyContinue; Log '官方配套包更新超时(5 分钟),已跳过' } else { try { Log ('官方配套包更新结束(exit=' + $pp.ExitCode + ')') } catch { Log '官方配套包更新结束(退出码读取失败)' } }\n }` : '',
3502
3555
  "SetState 'relaunching' '升级完成,重启 DSH 服务生效…'",
3503
3556
  "Log '重启 DSH 服务生效…'",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noob-stupid/dsh-plugin-console",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "DSH plugin management panel \u0026 marketplace: one-click enable/disable, multi-source market (GitHub/Gitee/custom), static-index market (500+ plugins / 300 skills), skills, suites, and one-click framework upgrade.",
5
5
  "repository": {
6
6
  "type": "git",