dsh-profile-config-sync 0.6.45 → 0.6.47

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": "dsh-profile-config-sync",
3
- "version": "0.6.45",
3
+ "version": "0.6.47",
4
4
  "type": "module",
5
5
  "description": "DeepSeek Harness 客户端的多端配置备份、同步与还原插件:把本机配置按 12 组内容抓取成 Git 仓库快照(profile、全局提示、Skills、Agent 预设、插件设置与工作流、插件数据、工作区、会话记录等),可推送到 GitHub / Gitee / GitLab 或上传 WebDAV;换机重装后一条命令拉回并铺开,误改可选档回滚。同步动作在客户端退出后执行(PowerShell on Windows,Node 引擎 on macOS / Linux),面板与文案跟随客户端语言。",
6
6
  "main": "./index.js",
@@ -17,7 +17,8 @@
17
17
  "README.en.md",
18
18
  "LICENSE",
19
19
  "runtime",
20
- "docs/*.md"
20
+ "docs/*.md",
21
+ "release-notes.json"
21
22
  ],
22
23
  "keywords": [
23
24
  "dsh",
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": "0.6.47",
3
+ "releasedAt": "2026-11-27",
4
+ "notes": "0.6.47:按你的要求,插件更新只查 npm,不再查 GitHub。① 版本判定改用 npm 的 dist-tags.latest;下载地址与校验值取该版本单版本文档里的 dist.tarball / dist.integrity / dist.shasum;发布说明从 npm 包内的 version.json 读(已加进 files)。GitHub 的 raw / API / gh-proxy / ghfast 四条清单源整体退休——那套代码连同「更新清单 / 更新令牌」两个设置项一起撤了。② 插件改为在线安装:市场索引的 source 从 git 改成 npm,profile 里也从 registry 装而不是本地 tgz。顺带修掉两个真 bug:(a) 旧实现「清单记 pnpm pack 的 sha256、npm 当兜底下载源」在校验那步必然失败——实测 npm pack 产物与 registry 上的 tarball 逐字节一致,但与 pnpm pack 的资产不同;现在校验值取自 registry 自己,权威值与被校验物同源。(b) 市场索引的 publishTimestamp 写的是毫秒而非 Unix 秒,DSH 的 parseMarketIndex 会直接拒掉整个索引,也就是说插件市场里此前根本读不出这个插件。",
5
+ "notesEn": "0.6.47: as requested, the plugin now checks npm only and never GitHub. (1) The version comes from npm's dist-tags.latest; the download URL and checksums come from that version's document (dist.tarball / dist.integrity / dist.shasum); release notes come from version.json inside the npm package (now listed in files). The four GitHub manifest sources (raw / API / gh-proxy / ghfast) are retired, together with the \"update manifest\" and \"update token\" settings. (2) The plugin is installed from the registry: the market index source changed from git to npm, and the profile installs from the registry i…"
6
+ }
@@ -19,6 +19,9 @@ param(
19
19
  [Parameter(Mandatory = $true)][string]$PluginDir,
20
20
  [string]$Version = '',
21
21
  [string]$Sha256 = '',
22
+ # 0.6.47:npm registry 的权威校验值(integrity = SRI sha512-base64,sha1 = dist.shasum)
23
+ [string]$Integrity = '',
24
+ [string]$Sha1 = '',
22
25
  # 候选下载地址,用 | 分隔
23
26
  [string]$TgzUrls = '',
24
27
  # 已经下好的本地包(有就不用下载)
@@ -195,7 +198,63 @@ if ($TgzFile -and (Test-Path -LiteralPath $TgzFile)) {
195
198
  }
196
199
  }
197
200
 
198
- if ($Sha256) {
201
+ # ---------- 校验安装包 ----------
202
+ # 0.6.47 起权威校验值来自 npm registry 自己的 dist.integrity(SRI,sha512-base64)/ dist.shasum(sha1),
203
+ # 与被校验物同源。旧路径用打包时的 sha256 —— npm tarball 与 GitHub release 资产不是同一份字节流,
204
+ # 那个校验对 npm 下载必然失败。优先 integrity,其次 sha1,最后 sha256(兼容老路径)。
205
+ if ($Integrity) {
206
+ $algo = ''
207
+ $expectedB64 = ''
208
+ foreach ($part in ($Integrity -split '\s+' | Where-Object { $_ })) {
209
+ $dash = $part.IndexOf('-')
210
+ if ($dash -le 0) { continue }
211
+ $a = $part.Substring(0, $dash).ToLower()
212
+ if ($a -notin @('sha256', 'sha384', 'sha512')) { continue }
213
+ $algo = $a
214
+ $expectedB64 = $part.Substring($dash + 1)
215
+ break
216
+ }
217
+ if (-not $algo) {
218
+ EmitResult $false '更新源给的 integrity 格式无法解析' ''
219
+ }
220
+ $sha = switch ($algo) {
221
+ 'sha256' { [System.Security.Cryptography.SHA256]::Create() }
222
+ 'sha384' { [System.Security.Cryptography.SHA384]::Create() }
223
+ 'sha512' { [System.Security.Cryptography.SHA512]::Create() }
224
+ }
225
+ $gotB64 = ''
226
+ try {
227
+ $fs = [System.IO.File]::OpenRead($pkgPath)
228
+ try {
229
+ $sha.TransformBlock($fs, 0, $fs.Length, $null, 0) | Out-Null
230
+ $sha.TransformFinalBlock([byte[]]::new(0), 0, 0) | Out-Null
231
+ $gotB64 = [Convert]::ToBase64String($sha.Hash)
232
+ } finally { $fs.Dispose() }
233
+ } catch {
234
+ EmitResult $false ('本机 PowerShell 无法计算安装包 ' + $algo) ''
235
+ }
236
+ Log ("integrity({0}):{1}" -f $algo, $gotB64)
237
+ if ($gotB64 -ne $expectedB64) {
238
+ Log 'integrity 与更新源不一致,放弃安装'
239
+ Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
240
+ EmitResult $false '安装包 integrity 校验不通过(没下载全或被改动)' ''
241
+ }
242
+ Log 'integrity 校验通过'
243
+ } elseif ($Sha1) {
244
+ $hash = ''
245
+ try { $hash = [string]((Get-FileHash -LiteralPath $pkgPath -Algorithm SHA1).Hash) } catch { $hash = '' }
246
+ $hash = $hash.Trim().ToLower()
247
+ Log ("sha1:{0}" -f $(if ($hash) { $hash } else { '(算不出来)' }))
248
+ if (-not $hash) {
249
+ EmitResult $false '本机 PowerShell 无法计算安装包 sha1' ''
250
+ }
251
+ if ($hash -ne $Sha1.ToLower()) {
252
+ Log 'sha1 与更新源不一致,放弃安装'
253
+ Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
254
+ EmitResult $false '安装包 sha1 校验不通过(没下载全或被改动)' ''
255
+ }
256
+ Log 'sha1 校验通过'
257
+ } elseif ($Sha256) {
199
258
  $hash = ''
200
259
  try { $hash = [string]((Get-FileHash -LiteralPath $pkgPath -Algorithm SHA256).Hash) } catch { $hash = '' }
201
260
  $hash = $hash.Trim().ToLower()
@@ -43,6 +43,12 @@ param(
43
43
  [string]$UpdateVersion = '',
44
44
  [string]$UpdateTgz = '',
45
45
  [string]$UpdateSha256 = '',
46
+ # 0.6.47:npm registry 给的权威校验值。integrity 是 SRI(sha512-base64),shasum 是 sha1 十六进制。
47
+ # 更新源改成 npm 之后,校验值必须与被校验物同源 —— npm 的 tarball 与 GitHub release 资产
48
+ # 不是同一份字节流(实测 npm pack 与 registry 上的 tarball 逐字节一致,但与 pnpm pack 的不同),
49
+ # 所以旧的「用打包时的 sha256 校验 npm 下载」必然失败。
50
+ [string]$UpdateIntegrity = '',
51
+ [string]$UpdateSha1 = '',
46
52
  # 仓库是私有库时必须带的只读令牌(Gitee 私人令牌);留空就按匿名方式下载
47
53
  [string]$UpdateToken = '',
48
54
  # 结果展示窗口的停留秒数(默认 360 = 6 分钟)。自动化验收传小值,避免每套夹具干等 6 分钟。
@@ -117,6 +123,8 @@ if ($Phase -eq 'wait') {
117
123
  if ($UpdateVersion) { $relay += @('-UpdateVersion', $UpdateVersion) }
118
124
  if ($UpdateTgz) { $relay += @('-UpdateTgz', $UpdateTgz) }
119
125
  if ($UpdateSha256) { $relay += @('-UpdateSha256', $UpdateSha256) }
126
+ if ($UpdateIntegrity) { $relay += @('-UpdateIntegrity', $UpdateIntegrity) }
127
+ if ($UpdateSha1) { $relay += @('-UpdateSha1', $UpdateSha1) }
120
128
  if ($UpdateToken) { $relay += @('-UpdateToken', $UpdateToken) }
121
129
  # PowerShell 5.1 的 Start-Process -ArgumentList 会直接用空格拼接数组元素,不会自动给含空格的路径加引号;
122
130
  # AppRoot(例如 ...\DeepSeek Harness)带空格时直接参数绑定失败退出。这里显式按 Windows argv 规则加引号。
@@ -699,7 +707,74 @@ if ($Mode -eq 'update') {
699
707
  Log ("已下载 {0:N0} 字节:{1}" -f (Get-Item -LiteralPath $tmp).Length, $tmp)
700
708
  }
701
709
 
702
- if ($UpdateSha256) {
710
+ # ---------- 校验安装包 ----------
711
+ # 0.6.47 起权威校验值来自 npm registry 自己的 dist.integrity(SRI,sha512-base64)/ dist.shasum(sha1)。
712
+ # 优先用 integrity,其次 sha1,最后才是旧的 sha256(兼容老路径)。
713
+ # 三个都没有时**跳过校验**并如实记下 —— 不能在校验没做时假装通过。
714
+ $verifiedBy = ''
715
+ if ($UpdateIntegrity) {
716
+ $algo = ''
717
+ $expectedB64 = ''
718
+ foreach ($part in ($UpdateIntegrity -split '\s+' | Where-Object { $_ })) {
719
+ $dash = $part.IndexOf('-')
720
+ if ($dash -le 0) { continue }
721
+ $a = $part.Substring(0, $dash).ToLower()
722
+ if ($a -notin @('sha256', 'sha384', 'sha512')) { continue }
723
+ $algo = $a
724
+ $expectedB64 = $part.Substring($dash + 1)
725
+ break
726
+ }
727
+ if (-not $algo) {
728
+ $msg = '插件更新失败:更新源给的 integrity 格式无法解析'
729
+ Log $msg
730
+ Write-Result $false 7 $msg $false
731
+ Finish 7 '更新失败:integrity 格式不对'
732
+ }
733
+ $sha = switch ($algo) {
734
+ 'sha256' { [System.Security.Cryptography.SHA256]::Create() }
735
+ 'sha384' { [System.Security.Cryptography.SHA384]::Create() }
736
+ 'sha512' { [System.Security.Cryptography.SHA512]::Create() }
737
+ }
738
+ $gotB64 = ''
739
+ try {
740
+ $fs = [System.IO.File]::OpenRead($tmp)
741
+ try {
742
+ $ms = New-Object System.IO.MemoryStream
743
+ $sha.TransformBlock($fs, 0, $fs.Length, $null, 0) | Out-Null
744
+ $sha.TransformFinalBlock([byte[]]::new(0), 0, 0) | Out-Null
745
+ $gotB64 = [Convert]::ToBase64String($sha.Hash)
746
+ } finally { $fs.Dispose() }
747
+ } catch {
748
+ $msg = '插件更新失败:本机 PowerShell 无法计算安装包 ' + $algo + '(Get-FileHash 不可用且 .NET 回退也失败)'
749
+ Log $msg
750
+ Write-Result $false 7 $msg $false
751
+ Finish 7 '更新失败:无法校验安装包'
752
+ }
753
+ Log ("integrity({0}):{1}" -f $algo, $gotB64)
754
+ if ($gotB64 -ne $expectedB64) {
755
+ Write-Result $false 7 '插件更新失败:安装包 integrity 校验不通过(可能没下载全或被改动)' $false
756
+ Finish 7 '更新失败:integrity 不符'
757
+ }
758
+ Log 'integrity 校验通过'
759
+ $verifiedBy = 'integrity'
760
+ } elseif ($UpdateSha1) {
761
+ $hash = ''
762
+ try { $hash = [string]((Get-FileHash -LiteralPath $tmp -Algorithm SHA1).Hash) } catch { $hash = '' }
763
+ $hash = $hash.Trim().ToLower()
764
+ Log ("sha1:{0}" -f $(if ($hash) { $hash } else { '(算不出来)' }))
765
+ if (-not $hash) {
766
+ $msg = '插件更新失败:本机 PowerShell 无法计算安装包 sha1'
767
+ Log $msg
768
+ Write-Result $false 7 $msg $false
769
+ Finish 7 '更新失败:无法校验安装包'
770
+ }
771
+ if ($hash -ne $UpdateSha1.ToLower()) {
772
+ Write-Result $false 7 '插件更新失败:安装包 sha1 校验不通过(可能没下载全或被改动)' $false
773
+ Finish 7 '更新失败:sha1 不符'
774
+ }
775
+ Log 'sha1 校验通过'
776
+ $verifiedBy = 'shasum'
777
+ } elseif ($UpdateSha256) {
703
778
  $hash = ''
704
779
  try { $hash = [string]((Get-FileHash -LiteralPath $tmp -Algorithm SHA256).Hash) } catch { $hash = '' }
705
780
  $hash = $hash.Trim().ToLower()
@@ -716,6 +791,10 @@ if ($Mode -eq 'update') {
716
791
  Finish 7 '更新失败:sha256 不符'
717
792
  }
718
793
  Log 'sha256 校验通过'
794
+ $verifiedBy = 'sha256'
795
+ } else {
796
+ Log '注意:更新源没有给任何校验值,本次未做完整性校验'
797
+ $verifiedBy = 'none'
719
798
  }
720
799
 
721
800
  $stage = Join-Path $env:TEMP ("dsh-plugin-stage-" + $stamp)