dsh-config-sync-plugin 0.3.61 → 0.3.63
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.en.md +21 -2
- package/README.md +21 -2
- package/client.js +1 -1
- package/index.js +4 -4
- package/package.json +1 -1
- package/runtime/apply.ps1 +29 -25
- package/runtime/dsh-sync-common.ps1 +12 -1
package/README.en.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-config-sync-plugin
|
|
1
|
+
# dsh-config-sync-plugin
|
|
2
2
|
[中文](README.md) | English
|
|
3
3
|
|
|
4
4
|
A DSH plugin: it adds a **"Config Sync"** row to the sidebar (opening a full-page health-check panel), plus a summary row under **Settings → General**. It only **inspects and prepares commands** — the sync actions never run inside the app (except the automatic sync that relaunches the client).
|
|
@@ -19,7 +19,7 @@ The package name is **`dsh-config-sync-plugin`** (the `dsh-config-sync` name on
|
|
|
19
19
|
|
|
20
20
|
| Way | Command / entry | Notes |
|
|
21
21
|
|---|---|---|
|
|
22
|
-
| npm | `npm i dsh-config-sync-plugin` | Use it as a dependency, or add `"dsh-config-sync-plugin": "^0.3.
|
|
22
|
+
| npm | `npm i dsh-config-sync-plugin` | Use it as a dependency, or add `"dsh-config-sync-plugin": "^0.3.63"` to the profile's `package.json` and run `pnpm i`. The name matches the `cordis.patch.yml` insert name and the install folder `dsh-config-sync-plugin-<ver>` |
|
|
23
23
|
| Marketplace | client → Plugins → Discover → “Config Sync” | Installs from the git commit registered in `market-index.json` |
|
|
24
24
|
| Offline tgz | `releases\dsh-config-sync-plugin-<ver>.tgz` | GitHub Release asset for air-gapped machines; the panel's Update button downloads the same file |
|
|
25
25
|
|
|
@@ -589,6 +589,25 @@ The log shows which path ran: `文件比较(快筛):比对 N 个,深哈
|
|
|
589
589
|
|
|
590
590
|
## Test log (2026-11-11, isolated environment)
|
|
591
591
|
|
|
592
|
+
### 2026-11-18: push speed release 0.3.63 (Get-RelPath ~10x faster)
|
|
593
|
+
|
|
594
|
+
The shared `Get-RelPath` used by push and pull ran two `-split` + `Where-Object` per file; on a 49k-file workspace push comparison alone cost 11.7s. Now a `StartsWith` + `Substring` fast path, falling back to the original segment-count logic when case or 8.3 short paths disagree. 49,138 files compared with 0 output differences; microbench 5.08s -> 0.51s (~9.9x). All three `dsh-sync-common.ps1` copies (source / config repo / plugin runtime) updated.
|
|
595
|
+
|
|
596
|
+
### 2026-11-18: pull speed release 0.3.62 (341s → 109s, ~3.1×)
|
|
597
|
+
|
|
598
|
+
One machine had 49,110 files in a workspace and 101,097 orphan files piled up in another workspace slot; "pull" stalled at "workspace restored" for minutes. Segment tracing found four avoidable costs, all in `runtime\apply.ps1`. Behaviour is unchanged (files committed to the repo, config results and decisions are byte-identical); only "how it computes" changed:
|
|
599
|
+
|
|
600
|
+
| Step | Result |
|
|
601
|
+
|---|---|
|
|
602
|
+
| End-to-end | 340.9s → 108.5s (same environment and input, ~3.1×); all functional assertions pass: 5 workspaces restored, 0 writes/updates, 0 backups, 56 session cwd fixes, 24 bundles resolvable, `EXIT=0` |
|
|
603
|
+
| ① Unconditional full backup | It used to back up the whole workspace before restoring each one (49,110 files × 1.99ms ≈ 98s), yet a second pull finds source and target byte-identical and needs 0 backups. Now a single file is backed up only when it is actually about to be overwritten → backups 49,110 → 0 |
|
|
604
|
+
| ② Hash API | `Get-FileHash` measured 0.957ms/file vs streaming .NET `SHA256.ComputeHash` 0.16ms/file (~6×); workspace/session header comparisons switched to streaming SHA256 |
|
|
605
|
+
| ③ zip version regex | The `package.json` path inside a `Compress-Archive` zip uses backslashes, but the version regex only accepted `/`, so the archive version was unreadable and a `git fetch` mtime refresh made every pull think "local plugin has a new version" and re-extract 3 link plugins. Changed to `[\\/]`; now all three consistently report "plugin already present" |
|
|
606
|
+
| ④ **Root cause: O(n²) array append** | The extra-path scan did `$extra = @()` + `$extra += $lf.FullName`; 101,097 orphan files ≈ 5.1 billion array copies, alone costing 264s (the dsh-config-sync slot has only 16 synced files yet took 264s). Replaced with `[System.Collections.Generic.List[string]]::new()` + `$extra.Add(...)` → O(n) |
|
|
607
|
+
| Remaining 108s | Hashing + copying 49,110 files in DSH破甲 takes 71s of real disk I/O; cutting further needs option ③ "git HEAD short-circuit" (high risk, not implemented) |
|
|
608
|
+
| Also fixed | A historical `market-index.json` structure bug (0.3.61 release wrote `plugins` as a mixed object/array) and that entry's `TODO_COMMIT_0361` placeholder commit; 0.3.61's "skip projcache sync" (context-overflow fix) is preserved |
|
|
609
|
+
| Lessons | Timestamp tracing through a PowerShell `ForEach-Object` pipeline gets swallowed by output buffering — write to stderr (`[Console]::Error.WriteLine`) for live traces; a BOM'd UTF-8 script must be read/written only as UTF8 — ISO-8859-1 round-trips force .NET to UTF8-decode then re-encode, turning all Chinese into `?` and dropping the BOM |
|
|
610
|
+
|
|
592
611
|
### 2026-11-15: performance release 0.3.54 (three speedups, behaviour unchanged)
|
|
593
612
|
|
|
594
613
|
| Step | Result |
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# dsh-config-sync-plugin
|
|
2
2
|
中文 | [English](README.en.md)
|
|
3
3
|
|
|
4
4
|
DSH 插件:左侧栏多一行「配置同步」,点开是整页体检面板;「设置 → 通用」另有一行摘要。插件**只做体检 + 备命令**,同步动作在客户端退出后由 `runtime\sync.ps1` 执行(自动同步那一路会自己拉起客户端)。
|
|
@@ -15,7 +15,7 @@ DSH 插件:左侧栏多一行「配置同步」,点开是整页体检面板
|
|
|
15
15
|
|
|
16
16
|
| 方式 | 命令 / 入口 | 说明 |
|
|
17
17
|
|---|---|---|
|
|
18
|
-
| npm | `npm i dsh-config-sync-plugin` | 适合把它当依赖管理,或在 profile 的 `package.json` 里写 `"dsh-config-sync-plugin": "^0.3.
|
|
18
|
+
| npm | `npm i dsh-config-sync-plugin` | 适合把它当依赖管理,或在 profile 的 `package.json` 里写 `"dsh-config-sync-plugin": "^0.3.63"` 后 `pnpm i`;包名与 `cordis.patch.yml` 里注册的名字、插件目录 `dsh-config-sync-plugin-<ver>` 一致 |
|
|
19
19
|
| 插件市场 | 客户端「插件市场 → 发现」搜「配置同步」 | 走 `market-index.json` 登记的 git 提交,版本与 README 对齐 |
|
|
20
20
|
| 离线 tgz | `releases\dsh-config-sync-plugin-<ver>.tgz` | GitHub Release 附件,适合内网机器;面板「更新」按钮下载的也是它 |
|
|
21
21
|
|
|
@@ -565,6 +565,25 @@ pwsh -File sync.ps1 push -ScanHistory
|
|
|
565
565
|
|
|
566
566
|
## 实测记录
|
|
567
567
|
|
|
568
|
+
### 2026-11-18:推送提速发版 0.3.63(Get-RelPath 快 10 倍)
|
|
569
|
+
|
|
570
|
+
推送/拉取共用的 `Get-RelPath` 原来对每个文件做两次 `-split` + `Where-Object`;5 万文件工作区下,推送比对单独占 11.7s。改为 `StartsWith` + `Substring` 快路径,大小写或 8.3 短路径不一致时回退原段数比对逻辑。49138 文件全量比对与老版输出 0 差异,微基准 5.08s → 0.51s(约 9.9 倍)。三处 `dsh-sync-common.ps1`(源码 / 配置仓库 / 插件副本)同步。
|
|
571
|
+
|
|
572
|
+
### 2026-11-18:拉取提速发版 0.3.62(341s → 109s,约 3.1×)
|
|
573
|
+
|
|
574
|
+
一台机器上工作区有 49110 个文件、另一个工作区槽位堆积了 101097 个孤儿文件,点「拉取」时卡在「已还原工作区」好几分钟。逐段打点后定位到 4 个浪费点,全部在 `runtime\apply.ps1`,行为不变(落到仓库的文件、提交内容、配置结果逐字节一致),只改「怎么算」:
|
|
575
|
+
|
|
576
|
+
| 环节 | 结果 |
|
|
577
|
+
|---|---|
|
|
578
|
+
| 端到端总耗时 | 340.9s → 108.5s(同环境同输入,约 3.1×);功能断言全过:5 工作区还原、写入/更新 0、备份 0、会话 cwd 修正 56、bundle 24 项可解析、`EXIT=0` |
|
|
579
|
+
| ① 无条件全量备份 | 原来每个工作区还原前把整个工作区备份一遍(49110 文件 × 1.99ms ≈ 98s),而二次拉取时源与目标内容全一致、实际需备份 0 个。改为「确认某个文件即将被覆盖时才备份这一个」→ 备份 49110 → 0 |
|
|
580
|
+
| ② 哈希 API | `Get-FileHash` 实测 0.957ms/文件,.NET `SHA256.ComputeHash` 流式 0.16ms/文件(约 6×);会话首帧与工作区比对的哈希统一换成流式 SHA256 |
|
|
581
|
+
| ③ zip 版本正则 | 归档内 `package.json` 路径在 `Compress-Archive` 打出的 zip 里是反斜杠,而版本正则只认 `/` → 读不到归档版本、`git fetch` 刷新 mtime 后每轮误判「本地插件有新版本」,反复重解压 3 个 link 插件。改成 `[\\/]` 兼容两种分隔符后,三插件稳定显示「本地插件已存在」 |
|
|
582
|
+
| ④ **真凶:O(n²) 数组追加** | extra 扫描里 `$extra = @()` + `$extra += $lf.FullName`,101097 个孤儿文件约 51 亿次数组拷贝,单独占 264s(dsh-config-sync 槽位仅 16 个同步文件却耗时 264s)。换成 `[System.Collections.Generic.List[string]]::new()` + `$extra.Add(...)` → O(n) |
|
|
583
|
+
| 剩余 108s | DSH破甲 49110 文件的哈希 + 复制 71s 是实打实的磁盘 I/O;再压需要方案③「git HEAD 增量短路」,风险高、默认未做 |
|
|
584
|
+
| 顺手修 | 历史遗留的 `market-index.json` 结构损坏(0.3.61 发版时把 `plugins` 数组写成了对象/数组混合)与该条目 commit 的 `TODO_COMMIT_0361` 占位符,本次一并修正;0.3.61 的「跳过 projcache 同步」(上下文超长修复)保持不变 |
|
|
585
|
+
| 教训 | PowerShell 管道 `ForEach-Object` 打时间戳会被输出缓冲吞掉,实时打点要写 stderr(`[Console]::Error.WriteLine`);带 BOM 的 UTF-8 脚本全程只能用 UTF8 读写,用 ISO-8859-1 读写会把中文 `.NET` 强制 UTF8 解码后再写回全变 `?` 并丢 BOM |
|
|
586
|
+
|
|
568
587
|
### 2026-11-15:性能发版 0.3.54(三处提速,行为不变)
|
|
569
588
|
|
|
570
589
|
| 环节 | 结果 |
|
package/client.js
CHANGED
|
@@ -921,7 +921,7 @@ window.__ModuleLoader__.load({
|
|
|
921
921
|
}
|
|
922
922
|
// 「手动还原」指引里的目标位置:认不出类型时按内容猜不到,索性把三类常见落点都摆出来
|
|
923
923
|
const manualTargets = () => [
|
|
924
|
-
M('插件本体 → 插件安装目录(如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.
|
|
924
|
+
M('插件本体 → 插件安装目录(如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.63)', 'Plugin files → the plugin install folder (e.g. D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.63)'),
|
|
925
925
|
M('会话目录(--xxx--)→ ~\\.dsh\\sessions', 'Session folders (--xxx--) → ~\\.dsh\\sessions'),
|
|
926
926
|
M('配置五件套(package.json / pnpm-lock.yaml / cordis.yml…)→ ~\\.dsh\\profiles\\desktop', 'Config files (package.json / pnpm-lock.yaml / cordis.yml…) → ~\\.dsh\\profiles\\desktop'),
|
|
927
927
|
]
|
package/index.js
CHANGED
|
@@ -976,9 +976,9 @@ async function inspect(config) {
|
|
|
976
976
|
const remoteFiles = remoteProbe ? remoteProbe.files : null
|
|
977
977
|
if (!appRoot) {
|
|
978
978
|
advice.push(t(
|
|
979
|
-
'定位不到客户端根目录:插件不在 <客户端根> 下(如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.
|
|
979
|
+
'定位不到客户端根目录:插件不在 <客户端根> 下(如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.63),'
|
|
980
980
|
+ '或客户端是打包版(resources\\app.asar)而这里没认出来 —— 三份同步脚本会因此生成不了',
|
|
981
|
-
'Cannot locate the client root: the plugin is not under <client root> (e.g. D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.
|
|
981
|
+
'Cannot locate the client root: the plugin is not under <client root> (e.g. D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.63), '
|
|
982
982
|
+ 'or this is a packaged build (resources\\app.asar) that was not recognized — the three sync scripts cannot be generated.',
|
|
983
983
|
))
|
|
984
984
|
}
|
|
@@ -3477,9 +3477,9 @@ async function handlePrepare(req, res, config) {
|
|
|
3477
3477
|
if (!appRoot) {
|
|
3478
3478
|
throw new Error(t(
|
|
3479
3479
|
'定位不到客户端根目录(要能找到 resources\\app\\package.json 或 resources\\app.asar):'
|
|
3480
|
-
+ '请确认插件装在 <客户端根> 下(例如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.
|
|
3480
|
+
+ '请确认插件装在 <客户端根> 下(例如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.63),或在设置里填客户端根 appRoot',
|
|
3481
3481
|
'Cannot locate the client root (needs resources\\app\\package.json or resources\\app.asar): '
|
|
3482
|
-
+ 'make sure the plugin is installed under <client root> (e.g. D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.
|
|
3482
|
+
+ 'make sure the plugin is installed under <client root> (e.g. D:\\DeepSeekHarness\\dsh-config-sync-plugin-0.3.63), or set appRoot in the settings',
|
|
3483
3483
|
))
|
|
3484
3484
|
}
|
|
3485
3485
|
const state = {...await repoState(repo), message}
|
package/package.json
CHANGED
package/runtime/apply.ps1
CHANGED
|
@@ -110,6 +110,13 @@ function Expand-AppRootTree([string]$dir, [string]$rootFwd) {
|
|
|
110
110
|
# 一律 Copy-Item -LiteralPath 原样拷;登记表里的路径占位符在这里展开成本机绝对路径。
|
|
111
111
|
# ($BS / $WorkspaceHomeToken / $wsSkip* / Test-WorkspaceIgnored 都在 dsh-sync-common.ps1 里,两个脚本共用)
|
|
112
112
|
|
|
113
|
+
# 快速 SHA256:复用单个静态实例,比 Get-FileHash cmdlet 快约 6 倍(大批量逐文件比对是拉取主要瓶颈)
|
|
114
|
+
$_dshSha256 = [System.Security.Cryptography.SHA256]::Create()
|
|
115
|
+
function Get-FileHashFast([string]$path) {
|
|
116
|
+
$fs = [System.IO.File]::Open($path, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite)
|
|
117
|
+
try { return [Convert]::ToBase64String($_dshSha256.ComputeHash($fs)) }
|
|
118
|
+
finally { $fs.Dispose() }
|
|
119
|
+
}
|
|
113
120
|
function Sync-WorkspaceApply {
|
|
114
121
|
$wsDir = Join-Path $RepoRoot 'workspace'
|
|
115
122
|
# 登记表 sessionIds 常常滞后于实际会话目录(会话是后来新建的、capture 只抄了当时的快照)。
|
|
@@ -182,23 +189,8 @@ function Sync-WorkspaceApply {
|
|
|
182
189
|
}
|
|
183
190
|
$repoRels[$rel] = $f.FullName
|
|
184
191
|
}
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
# 而且它们本来就不会被覆盖,没有备份价值(真实事故:13.8GB 模型被备份进 ~\.dsh\backups,C 盘直接满)。
|
|
188
|
-
if (Test-Path -LiteralPath $e.LocalPath) {
|
|
189
|
-
$bk = Join-Path $BackupDir ("workspace\" + $e.Slot)
|
|
190
|
-
foreach ($lf in @(Get-ChildItem -LiteralPath $e.LocalPath -Recurse -File -Force -ErrorAction SilentlyContinue)) {
|
|
191
|
-
$rel = Get-RelPath $e.LocalPath $lf.FullName
|
|
192
|
-
if (-not $rel) { continue }
|
|
193
|
-
if (Test-WorkspaceIgnored $rel) { continue }
|
|
194
|
-
if ($lf.Length -gt $wsMaxFileBytes) { continue }
|
|
195
|
-
$bd = Join-Path $bk $rel
|
|
196
|
-
$bdd = Split-Path -Parent $bd
|
|
197
|
-
if (-not (Test-Path -LiteralPath $bdd)) { New-Item -ItemType Directory -Path $bdd -Force | Out-Null }
|
|
198
|
-
Copy-Item -LiteralPath $lf.FullName -Destination $bd -Force
|
|
199
|
-
$nBk++
|
|
200
|
-
}
|
|
201
|
-
}
|
|
192
|
+
# 备份策略:不再无条件全量备份整个工作区(二次拉取 4.9 万文件全量备份白耗 ~100 秒)。
|
|
193
|
+
# 真正的回滚点只在文件「即将被覆盖」时逐个备份,见下方 if ($need) 分支。
|
|
202
194
|
if (-not (Test-Path -LiteralPath $e.LocalPath)) { New-Item -ItemType Directory -Path $e.LocalPath -Force | Out-Null }
|
|
203
195
|
foreach ($rel in @($repoRels.Keys)) {
|
|
204
196
|
$s = $repoRels[$rel]
|
|
@@ -207,14 +199,24 @@ function Sync-WorkspaceApply {
|
|
|
207
199
|
if (-not (Test-Path -LiteralPath $dd)) { New-Item -ItemType Directory -Path $dd -Force | Out-Null }
|
|
208
200
|
$need = $false
|
|
209
201
|
if (-not (Test-Path -LiteralPath $d)) { $need = $true }
|
|
210
|
-
elseif ((Get-
|
|
211
|
-
if ($need) {
|
|
202
|
+
elseif ((Get-FileHashFast $s) -ne (Get-FileHashFast $d)) { $need = $true }
|
|
203
|
+
if ($need) {
|
|
204
|
+
# 仅覆盖前备份这一个文件(目标存在说明是改动而非新增)
|
|
205
|
+
if (Test-Path -LiteralPath $d) {
|
|
206
|
+
$bd = Join-Path (Join-Path $BackupDir ("workspace\" + $e.Slot)) $rel
|
|
207
|
+
$bdd = Split-Path -Parent $bd
|
|
208
|
+
if (-not (Test-Path -LiteralPath $bdd)) { New-Item -ItemType Directory -Path $bdd -Force | Out-Null }
|
|
209
|
+
Copy-Item -LiteralPath $d -Destination $bd -Force
|
|
210
|
+
$nBk++
|
|
211
|
+
}
|
|
212
|
+
Copy-Item -LiteralPath $s -Destination $d -Force; $nAdd++
|
|
213
|
+
}
|
|
212
214
|
}
|
|
213
215
|
# 本机多出的文件:默认不动只提示,加 -PruneWorkspace 才删
|
|
214
|
-
$extra =
|
|
216
|
+
$extra = [System.Collections.Generic.List[string]]::new()
|
|
215
217
|
foreach ($lf in @(Get-ChildItem -LiteralPath $e.LocalPath -Recurse -File -Force -ErrorAction SilentlyContinue)) {
|
|
216
218
|
$rel = Get-RelPath $e.LocalPath $lf.FullName
|
|
217
|
-
if ($rel -and -not $repoRels.ContainsKey($rel) -and -not (Test-WorkspaceIgnored $rel)) { $extra
|
|
219
|
+
if ($rel -and -not $repoRels.ContainsKey($rel) -and -not (Test-WorkspaceIgnored $rel)) { $extra.Add([string]$lf.FullName) }
|
|
218
220
|
}
|
|
219
221
|
if ($extra.Count -gt 0) {
|
|
220
222
|
if ($PruneWorkspace) {
|
|
@@ -575,7 +577,7 @@ function Sync-ConversationApply {
|
|
|
575
577
|
if (-not (Test-Path -LiteralPath $dd)) { New-Item -ItemType Directory -Path $dd -Force | Out-Null }
|
|
576
578
|
$need = $false
|
|
577
579
|
if (-not (Test-Path -LiteralPath $d)) { $need = $true }
|
|
578
|
-
elseif ((Get-
|
|
580
|
+
elseif ((Get-FileHashFast $f.FullName) -ne (Get-FileHashFast $d)) { $need = $true }
|
|
579
581
|
if ($need) {
|
|
580
582
|
# 覆盖前备份本机已有文件
|
|
581
583
|
if (Test-Path -LiteralPath $d) {
|
|
@@ -843,6 +845,8 @@ if ($dropped.Count -gt 0) { Ok "已剔除 $($dropped.Count) 个实验性 bundle
|
|
|
843
845
|
$localPluginMap = [ordered]@{
|
|
844
846
|
'dsh-our-free-model-2.8.0' = 'dsh-our-free-model'
|
|
845
847
|
'dsh-purge-1.4.0' = 'dsh-purge'
|
|
848
|
+
'dsh-config-sync-plugin-0.3.63' = 'dsh-config-sync-plugin'
|
|
849
|
+
'dsh-config-sync-plugin-0.3.62' = 'dsh-config-sync-plugin'
|
|
846
850
|
'dsh-config-sync-plugin-0.3.61' = 'dsh-config-sync-plugin'
|
|
847
851
|
'dsh-config-sync-plugin-0.3.59' = 'dsh-config-sync-plugin'
|
|
848
852
|
'dsh-config-sync-plugin-0.3.58' = 'dsh-config-sync-plugin'
|
|
@@ -1187,8 +1191,8 @@ function Get-ArchivePluginVersion([string]$archPath, [string]$dirName) {
|
|
|
1187
1191
|
try { Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction Stop } catch { }
|
|
1188
1192
|
$zip = [IO.Compression.ZipFile]::OpenRead($archPath)
|
|
1189
1193
|
try {
|
|
1190
|
-
$entry = $zip.Entries | Where-Object { $_.FullName -match ("(
|
|
1191
|
-
if (-not $entry) { $entry = $zip.Entries | Where-Object { $_.FullName -match '^(package
|
|
1194
|
+
$entry = $zip.Entries | Where-Object { $_.FullName -match ("(^|[\\/])" + [regex]::Escape($dirName) + "[\\/]package\.json$") } | Select-Object -First 1
|
|
1195
|
+
if (-not $entry) { $entry = $zip.Entries | Where-Object { $_.FullName -match '^(package[\\/])?package\.json$' } | Select-Object -First 1 }
|
|
1192
1196
|
if (-not $entry) { return $null }
|
|
1193
1197
|
$sr = New-Object IO.StreamReader($entry.Open())
|
|
1194
1198
|
try { return [string](($sr.ReadToEnd()) | ConvertFrom-Json).version } finally { $sr.Dispose() }
|
|
@@ -1461,4 +1465,4 @@ if ($hostAppVersion) { Say "版本:本机 app = $hostAppVersion(仓库契约
|
|
|
1461
1465
|
Say "验证:插件页看 20 项是否齐全、按要求检查 cordis.patch.yml 里的开关是否生效、Skill 列表能列出。"
|
|
1462
1466
|
Say "如需回滚:把 $BackupDir 里的文件拷回原位置(工作区资料在 workspace\ 子目录、登记表备份为 workspace-registry-before.json)。"
|
|
1463
1467
|
|
|
1464
|
-
exit 0
|
|
1468
|
+
exit 0
|
|
@@ -158,7 +158,18 @@ function Get-GitExe {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
# 求 $full 相对 $base 的路径:按路径段数取尾巴,避免 8.3 短路径(ADMINI~1)或大小写差异导致 Substring 算错
|
|
161
|
-
function Get-RelPath([string]$base, [string]$full) {
|
|
161
|
+
function Get-RelPath([string]$base, [string]$full) {
|
|
162
|
+
# Fast path: $full is under $base from the same enumeration (99.9%). Substring avoids two -split + Where-Object.
|
|
163
|
+
if ($full.StartsWith($base, [StringComparison]::OrdinalIgnoreCase)) {
|
|
164
|
+
$tail = $full.Substring($base.Length)
|
|
165
|
+
if ($tail.Length -gt 0 -and ($tail[0] -eq '\' -or $tail[0] -eq '/')) {
|
|
166
|
+
$rel = $tail.TrimStart('\','/')
|
|
167
|
+
if ($rel) { return $rel }
|
|
168
|
+
}
|
|
169
|
+
return $null
|
|
170
|
+
}
|
|
171
|
+
# Fallback: base/full disagree on case or 8.3 short path (ADMINI~1). Count path segments instead.
|
|
172
|
+
$b = @($base -split '\\' | Where-Object { $_ -ne '' })
|
|
162
173
|
$f = @($full -split '\\' | Where-Object { $_ -ne '' })
|
|
163
174
|
if ($f.Count -le $b.Count) { return $null }
|
|
164
175
|
return ($f[$b.Count..($f.Count - 1)] -join '\')
|