@noob-stupid/dsh-plugin-console 0.3.14 → 0.3.16
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/lib/index.js +65 -5
- package/package.json +37 -37
package/lib/index.js
CHANGED
|
@@ -520,6 +520,30 @@ function queuedWrite(fn) {
|
|
|
520
520
|
return run
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
/** 解析 DSH 框架版本号为可比较对象;正式版(无预发布段)视为 rc.∞。 */
|
|
524
|
+
function parseFrameworkVersion(value) {
|
|
525
|
+
const m = String(value ?? '').match(/^(\d+)\.(\d+)\.(\d+)(?:-(?:[a-z]+\.)?(\d+))?$/iu)
|
|
526
|
+
if (!m) return -1
|
|
527
|
+
const [, maj, min, pat, rc] = m
|
|
528
|
+
return {
|
|
529
|
+
maj: Number.parseInt(maj, 10),
|
|
530
|
+
min: Number.parseInt(min, 10),
|
|
531
|
+
pat: Number.parseInt(pat, 10),
|
|
532
|
+
rc: rc === undefined ? Number.POSITIVE_INFINITY : Number.parseInt(rc, 10),
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** 判断 candidate 是否比 current 更新(候选与当前必须是合法版本号,否则视为不可比)。 */
|
|
537
|
+
function isFrameworkVersionNewer(candidate, current) {
|
|
538
|
+
const a = parseFrameworkVersion(candidate)
|
|
539
|
+
const b = parseFrameworkVersion(current)
|
|
540
|
+
if (a === -1 || b === -1) return false
|
|
541
|
+
if (a.maj !== b.maj) return a.maj > b.maj
|
|
542
|
+
if (a.min !== b.min) return a.min > b.min
|
|
543
|
+
if (a.pat !== b.pat) return a.pat > b.pat
|
|
544
|
+
return a.rc > b.rc
|
|
545
|
+
}
|
|
546
|
+
|
|
523
547
|
/** 默认 profile 用户补丁层路径(无 include 条目可推导时的兜底)。 */
|
|
524
548
|
function defaultPatchPath() {
|
|
525
549
|
const home = dshHome()
|
|
@@ -3298,6 +3322,12 @@ async function handle(ctx, req, res) {
|
|
|
3298
3322
|
// 升级完成重启后,框架适配逻辑自动:备份新版本快照 + 重打框架补丁 + 版本提示。
|
|
3299
3323
|
let current = null
|
|
3300
3324
|
let dshDir = null
|
|
3325
|
+
// 面板自报名(自报名一致性校验用):从插件自身 package.json 读,与部署目录比对
|
|
3326
|
+
let selfName = null
|
|
3327
|
+
try {
|
|
3328
|
+
const selfPkg = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'package.json'), 'utf8'))
|
|
3329
|
+
selfName = typeof selfPkg.name === 'string' ? selfPkg.name : null
|
|
3330
|
+
} catch {}
|
|
3301
3331
|
try {
|
|
3302
3332
|
const require = createRequire(ctx.baseUrl ?? 'file:///')
|
|
3303
3333
|
const dshPkgPath = require.resolve('@deepseek-ai/dsh/package.json')
|
|
@@ -3325,10 +3355,11 @@ async function handle(ctx, req, res) {
|
|
|
3325
3355
|
// 网络黑洞/超时:区分「检测失败」与「无更新」,避免误导用户以为已是最新
|
|
3326
3356
|
registryError = error instanceof Error ? error.message : String(error)
|
|
3327
3357
|
}
|
|
3328
|
-
// 升级目标:稳定版 latest 优先;latest
|
|
3329
|
-
|
|
3358
|
+
// 升级目标:稳定版 latest 优先;latest 不高于当前而 next(预发布渠道)确实更新时,目标取 next。
|
|
3359
|
+
// 必须用版本号比较而不是字符串不等(避免 current=0.1.1 稳定版时被 next=0.1.1-rc.3 反向降级)。
|
|
3360
|
+
const target = latest !== null && current !== null && isFrameworkVersionNewer(latest, current)
|
|
3330
3361
|
? latest
|
|
3331
|
-
: (next !== null && current !== null && next
|
|
3362
|
+
: (next !== null && current !== null && isFrameworkVersionNewer(next, current) ? next : null)
|
|
3332
3363
|
const profileDir = dirname(findPatchPath(ctx))
|
|
3333
3364
|
// 1) 升级前打包备份现有配置(patch / profile package.json / 插件清单)
|
|
3334
3365
|
let backupDir = null
|
|
@@ -3577,8 +3608,12 @@ async function handle(ctx, req, res) {
|
|
|
3577
3608
|
` New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null`,
|
|
3578
3609
|
` $tgz = Join-Path $tmpDir 'pkg.tgz'`,
|
|
3579
3610
|
` $encName = $name.Replace('/','%2f')`,
|
|
3580
|
-
` $url = 'https://registry.
|
|
3581
|
-
` curl.exe -s -L -m 60 -o $tgz $url`,
|
|
3611
|
+
` $url = 'https://registry.npmmirror.com/' + $encName + '/-/' + $short + '-' + $refVersion + '.tgz'`,
|
|
3612
|
+
` curl.exe -s -L -m 60 --insecure -o $tgz $url`,
|
|
3613
|
+
` if (-not (Test-Path $tgz) -or (Get-Item $tgz).Length -lt 1000) {`,
|
|
3614
|
+
` $url = 'https://registry.npmjs.org/' + $encName + '/-/' + $short + '-' + $refVersion + '.tgz'`,
|
|
3615
|
+
` curl.exe -s -L -m 60 --insecure -o $tgz $url`,
|
|
3616
|
+
` }`,
|
|
3582
3617
|
` if (-not (Test-Path $tgz) -or (Get-Item $tgz).Length -lt 1000) { Remove-Item $tmpDir -Recurse -Force -ErrorAction SilentlyContinue; continue }`,
|
|
3583
3618
|
` tar -xzf $tgz -C $tmpDir`,
|
|
3584
3619
|
` $ver = (Get-Content (Join-Path $tmpDir 'package\\package.json') -Raw | ConvertFrom-Json).version`,
|
|
@@ -3596,6 +3631,31 @@ async function handle(ctx, req, res) {
|
|
|
3596
3631
|
`}`,
|
|
3597
3632
|
`Verify-DependencyTree '${target}'`,
|
|
3598
3633
|
`Log ('依赖树完整性修复完成(' + $script:treeFixed + ' 个)')`,
|
|
3634
|
+
// 自报名一致性校验(事故教训:面板自身部署名与代码自报名不一致崩溃)——
|
|
3635
|
+
// 曾把 @noob-stupid/dsh-plugin-console 的代码装进 @deepseek-ai/dsh-plugin-console 目录,
|
|
3636
|
+
// 浏览器端报 loaded without registering "@deepseek-ai/dsh-plugin-console"(加载器期望
|
|
3637
|
+
// 目录名 = 包名 = 登记 ID,三者必须一致)。校验面板自身:export const name / client.js
|
|
3638
|
+
// 注册 id 必须与部署目录名一致,不一致则日志告警(升级脚本不自动改名——避免破坏运行时)。
|
|
3639
|
+
`function Verify-SelfNameConsistency($expectedName) {`,
|
|
3640
|
+
` $selfDir = ${ps(dirname(dirname(fileURLToPath(import.meta.url))))}`,
|
|
3641
|
+
` $indexJs = Join-Path $selfDir 'lib\\index.js'`,
|
|
3642
|
+
` $clientJs = Join-Path $selfDir 'lib\\client.js'`,
|
|
3643
|
+
` if (-not (Test-Path $indexJs)) { Log ('自报名校验跳过:index.js 未找到'); return }`,
|
|
3644
|
+
` # 计算部署目录的完整包名(scoped 包为 @scope/name,非 scoped 包为 name)`,
|
|
3645
|
+
` $leaf = Split-Path $selfDir -Leaf`,
|
|
3646
|
+
` $parentLeaf = Split-Path (Split-Path $selfDir -Parent) -Leaf`,
|
|
3647
|
+
` if ($parentLeaf.StartsWith('@')) { $deployName = $parentLeaf + '/' + $leaf } else { $deployName = $leaf }`,
|
|
3648
|
+
` $idx = Get-Content $indexJs -Raw`,
|
|
3649
|
+
` $nameOk = $idx.Contains("export const name = '" + $expectedName + "'")`,
|
|
3650
|
+
` $clientOk = $true`,
|
|
3651
|
+
` if (Test-Path $clientJs) {`,
|
|
3652
|
+
` $cli = Get-Content $clientJs -Raw`,
|
|
3653
|
+
` $clientOk = $cli.Contains('id: "' + $expectedName + '"')`,
|
|
3654
|
+
` }`,
|
|
3655
|
+
` $dirOk = ($deployName -eq $expectedName)`,
|
|
3656
|
+
` if ($nameOk -and $clientOk -and $dirOk) { Log ('自报名一致性 OK:' + $expectedName + ' @ ' + $deployName) } else { Log ('⚠️ 自报名一致性异常:部署目录=' + $deployName + ',期望 ' + $expectedName + '(index=' + $nameOk + ' client=' + $clientOk + ' dir=' + $dirOk + ')——请检查部署目录与包名是否匹配') }`,
|
|
3657
|
+
`}`,
|
|
3658
|
+
`Verify-SelfNameConsistency '${selfName ?? '@noob-stupid/dsh-plugin-console'}'`,
|
|
3599
3659
|
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 }` : '',
|
|
3600
3660
|
"SetState 'relaunching' '升级完成,重启 DSH 服务生效…'",
|
|
3601
3661
|
"Log '重启 DSH 服务生效…'",
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name":
|
|
3
|
-
"version":
|
|
4
|
-
"description":
|
|
5
|
-
"repository":
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"type":
|
|
10
|
-
"main":
|
|
11
|
-
"exports":
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"keywords":
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"dsh":
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"files":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"license":
|
|
2
|
+
"name": "@noob-stupid/dsh-plugin-console",
|
|
3
|
+
"version": "0.3.16",
|
|
4
|
+
"description": "DSH plugin management panel & 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
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Noob-stupid/dsh-plugin-hub"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./lib/index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./lib/index.js",
|
|
13
|
+
"./client": "./lib/client.js",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dsh-plugin",
|
|
18
|
+
"deepseek-harness",
|
|
19
|
+
"plugin-manager"
|
|
20
|
+
],
|
|
21
|
+
"dsh": {
|
|
22
|
+
"bundle": {
|
|
23
|
+
"patch": "./cordis.patch.yml"
|
|
24
|
+
},
|
|
25
|
+
"client": {
|
|
26
|
+
"platform": "web",
|
|
27
|
+
"inject": [
|
|
28
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
29
|
+
"@deepseek-ai/dsh-client-locale",
|
|
30
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"lib",
|
|
36
|
+
"cordis.patch.yml"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT"
|
|
39
39
|
}
|