dsh-config-sync-plugin 0.3.68 → 0.3.70

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 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.68"` 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>` |
22
+ | npm | `npm i dsh-config-sync-plugin` | Use it as a dependency, or add `"dsh-config-sync-plugin": "^0.3.70"` 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
 
@@ -100,21 +100,6 @@ Real output of the isolated pull (`pull_rc=0`):
100
100
  | workspace files arrived but custom keys in `~\.dsh\settings.json` did not | plugin configs are a **whitelist** (13 files), `settings.json` is never copied whole | check whether the config belongs to that whitelist |
101
101
 
102
102
 
103
- ## Install
104
-
105
- The plugin is a standard DSH bundle; install it into the current profile:
106
-
107
- ```sh
108
- # Install from this repo's release package (no build needed: host, client and runtime scripts are already inside)
109
- dsh plugin add https://raw.githubusercontent.com/QcWyGm/dsh-config-sync-plugin/main/releases/dsh-config-sync-plugin-<version>.tgz # latest on the Releases page
110
- ```
111
-
112
- Or add this repo's index under the official **Plugins → Discover → Index sources** (see "Using this repo as a market index source" below). **The third-party market plugin dshmarket does not read that index** — see that section for why.
113
-
114
- After installing, point it at your own config repo (common paths are auto-detected by default). The **Plugin update** card asks for a manifest URL and token only when needed — **this repo is public, so updates work without a token**.
115
-
116
- `apply.ps1` does three things on install: it unpacks `local-plugins\dsh-config-sync-plugin-<version>.tgz` into `<AppRoot>\dsh-config-sync-plugin-0.1.0`, adds a `link:` dependency and a `dsh.profile.bundles` entry to `package.json`, and a `config-sync` line to `cordis.patch.yml`.
117
-
118
103
  ## Contents
119
104
 
120
105
  | Path | Purpose |
@@ -587,168 +572,20 @@ The log shows which path ran: `文件比较(快筛):比对 N 个,深哈
587
572
  - `node tools\clientcheck.mjs`: runs the client half with a fake `__ModuleLoader__` and a react stand-in, asserting the module loads, all three `apply()` registrations succeed (sidebar row and main with matching id/key), `inject` returns a disposer, and the component renders without throwing when data is empty. It validates the contract and structure; the UI still needs a restart and a look.
588
573
  - `pwsh -File tools\pack-plugin.ps1`: packs the tgz and writes the sha256 back into `version.json`. **PowerShell 7 is required** (the script is UTF-8 without a BOM, and 5.1 reads the Chinese text as GBK and fails).
589
574
 
590
- ## Test log (2026-11-11, isolated environment)
591
-
592
- ### 2026-11-18: isolated B-machine fresh-pull regression (workspaces / session membership / context overflow)
593
-
594
- A clean isolated B machine (approot / dshome / wshome + bundled node runner) simulated a "fresh machine first pull": `sessions`, `storages/workspace.json` and `session_projcache` were wiped first, then the config repo's latest `apply.ps1` ran a full restore. Every check passed:
595
-
596
- | Check | Result |
597
- |---|---|
598
- | apply run | `EXIT=0`, 73 s (pull speedup active; was 340 s) |
599
- | Workspace mount | all 5 workspaces restored, paths all point at this machine's `_iso_b\approot\*`, registry merged by ID ✅ |
600
- | Session membership | workspace registry holds 71 sessionIds; sessions directories yield 73 — only 2 missing (ghost workspace + forward-confirm special session, expected exceptions) ✅ |
601
- | projcache | absent on B (**FILES=0**) — the repo does carry the over-window sessions' projcache, but it is not synced ✅ |
602
- | Session cwd | 64 sessions, 63 first-frame cwd correct; the single exception is the forward-confirm passthrough session ✅ |
603
- | bundle | all 24 entries resolve; the 3 link plugins report "already present locally" and are not re-extracted ✅ |
604
-
605
- **Context-overflow loop closed**: the three sessions that used to blow the window with A-machine token metering are now correctly filed — `session-58db748a` (1,553,981 tokens) -> DSH破甲, `session-bbf3e5c9` (1,080,398) -> SquadLink, `session-a1061521` (1,001,058) -> dsh-config-sync. With no projcache on B, DSH rebuilds token metering from the session logs using B's actual model config on startup and triggers compaction, instead of pushing A's stale over-window cache straight to the provider.
606
-
607
- Benign warnings (confirmed in the log): `--D-DeepSeekHarness-comfyUI--` / `--dsh-im-forward-confirm--` map to no workspace (special session dirs); `-SkipInstall` skipped 21 registry plugins (isolated offline run — without the flag on a networked machine they install); `dsh-config-sync-0.1.0` / `extra/manifest.json` have no archive/definition and are skipped; the `dsh-config-sync` slot has extra local leftovers (removed only with `-PruneWorkspace`).
608
-
609
- ### 2026-11-19: release 0.3.68 (session projection-cache guard, fixes agent-busy session creation)
610
-
611
- **Problem**: DSH's "new session" does not always create one. The client first looks for a **blank session** in the workspace to reuse (`client-ui-workspace/createInWorkspace()` → `sessions.ids.find(summary.blank && …)` → `createNamed({ sessionId: blank })`), and `summary.blank` comes from `record.rows.sessionListMetadata.val.blank` in the projection cache `session_projcache\sessions\<id>.json`.
612
-
613
- That cache can be a half-written artifact: a session creation once wrote `blank:true / seq:-1`, the log afterwards kept appending (`turn/start`, `user/message`), but the cache never advanced. The list therefore still treats the session as blank, the UI picks it for reuse, and the host throws:
614
-
615
- ```
616
- session/agent-busy: session "<id>" is owned by subagent routing
617
- ```
618
-
619
- Session creation fails outright and refreshing does not help (the same cache keeps being reused). Cross-machine sync amplifies it: machine A's stale cache is pulled into machine B, which then hits the same wall.
575
+ ## Test log
620
576
 
621
- **Fix**: three layers, none of which touch the log or the workspace registry — pure cache-file operations.
622
-
623
- | Layer | Trigger | Action |
577
+ | Date | Version | Summary |
624
578
  |---|---|---|
625
- | Client | `sessions.create` hits `agent-busy` | Wraps `sessions.create`: extracts the colliding `sessionId`, reports it to the host, drops the stale `sessionId` and **retries once**. Zero overhead on the normal path |
626
- | Host | Receives the client report | **Moves** `<DshHome>/storages/session_projcache/sessions/<id>.json` to `<DshHome>/logs/session-cache-guard-backup/` (move only, never delete) so DSH rebuilds the cache from the full log and `blank` becomes `false` |
627
- | Timer | Every 3 minutes | Proactively sweeps the same class of stale cache. All four conditions must hold (miss rather than mis-delete): (1) cache parses and `blank===true`; (2) a matching `session.v*.jsonl.zstd` exists; (3) the log really has `turn/start` or `user/message`; (4) the log's last event `seq` > the cache's max recorded `seq` |
628
-
629
- New route `/config-sync/cache-guard`: `GET` is a read-only scan; `POST` accepts `scan` / `sweep` / `clear` / `busy`. A `cacheGuard` switch was added to settings, **on by default**; when off, neither the timer nor the client `agent-busy` report does anything.
630
-
631
- Implementation: `runtime/tools/session-cache-guard.mjs` (`scanSessionCaches` / `clearSessionCaches` / `runGuard` / `indexSessionLogs`); the client half lives in the `0.3.68:会话缓存守卫` block of `client.js`.
632
-
633
- **Manual fallback**: the "Session cache guard" card in the panel scans on demand, shows each candidate with its evidence, and lets you pick what to clear. Cache files are only ever backed up, never deleted — a wrong clear is reversible from `<DshHome>/logs/session-cache-guard-backup/`.
634
-
635
-
636
- ### 2026-11-19: release 0.3.67 (seq reconciliation guard for session logs)
637
-
638
- **Problem**: when two machines each append to the same session, sync used a whole-file copy. Whichever side pushed last overwrote the other side's tail, the event stream developed a `seq` jump, and DSH refused to open the session: `stored session ... is corrupt: corrupt session log: invalid committed event at line N: released v2 row N has seq gap (expected X, got Y)`.
639
-
640
- **Fix**: `capture.ps1` (push side) and `apply.ps1` (pull side) no longer `Copy-Item -Force` a `session*.jsonl.zstd`; they hand it to the new seq guard:
641
-
642
- | Case | Action |
643
- |---|---|
644
- | Target is newer or identical | keep target, write nothing |
645
- | Source is a strict superset | copy source over target |
646
- | Each side has exclusive events | merge by `seq`; both sides' events survive |
647
- | Target itself has a hole the source can fill | repair then write (`merge` — rescues an already-damaged session) |
648
- | Hole cannot be filled (events really lost) | **leave the file untouched**, record `failed` in `sync-notices.json`, flag for manual handling |
649
-
650
- Implementation: `tools/session-log-lib.mjs` (multi-frame zstd decoding, byte-prefix compare, seq merge) + `tools/session-log-guard.mjs` (`check` / `decide` / `merge` / `batch`; batch mode is what the ps1 scripts call, and results go through a temp JSON file rather than stdout because Electron is a GUI subsystem). A full 11MB session parses in ~0.6s, fast enough for the sync hot path.
651
-
652
- **Two extras**:
653
- - `.gitattributes` now marks `conversations/sessions/**/*.zstd binary` and `workspace/** -text`, so Windows `core.autocrlf` or git line-ending normalisation cannot corrupt the binary logs again;
654
- - `capture.ps1` hoists the tree-compare helpers above their first use: they were defined after the call site, so `-WorkspaceOnly` hit `Test-TreeFileChanged is not recognized` in the session mirror loop.
655
-
656
- Diagnostic: `node tools/check-session-log.mjs <log>` or `<logA> <logB>` prints self-consistency (rows / seq range / gaps) and the relation between two files (`identical` / `prefix` / `superset` / `fork`).
657
-
658
- ### 2026-11-19: release 0.3.66 (.gitattributes silences LF/CRLF warnings)
659
- - **Cross-platform line ending noise**: on Windows `core.autocrlf=true` converts LF in `session_projcache/*.json` to CRLF, causing Git to warn "LF will be replaced by CRLF" on push. Added `.gitattributes` marking that directory as binary (`binary`) and all other text files as `eol=lf`, eliminating the warning class entirely.
660
- - Pure config change; no sync logic, behavior, or data changes.
661
- ### 2026-11-18: release 0.3.65 (refresh button feedback)
662
- - **Top "Re-check"**: now always shows a clear toast after a click, whether or not data changed - success shows "Re-checked, data is up to date (time)", failure shows the reason, reusing the 5-second auto-dismiss notice. Previously, when the state was already current the page looked unchanged and users thought the click did nothing.
663
- - **Card "Refresh" buttons**: the five refresh buttons (sync conflicts, plugin data, sync content, feedback, settings summary row) now switch their label to "Refreshing..." and disable while running, then return to "Refresh". Three of them (sync conflicts / sync content / feedback) had `load()` functions that never drove `busy` (label never changed) - fixed by adding `setBusy`; the top bar's "Checking..." and the local-path "Reading..." stay as they were.
664
- - `node --check` and the client self-check all pass; front-end interaction only, no behaviour or data changes.
665
- ### 2026-11-18: release 0.3.64 (backup restore fix + failure summary + auto-close)
666
-
667
- - **Backup restore bug fixed**: `apply.ps1` backed up plugin settings by filename only (e.g. `workspace.json`), and `restore.ps1` dumped them all into `~\.dsh` root, so `storages\workspace.json`, `our-free-model\settings.json`, `redteam\preset-declare.json` never returned to their original directories. Backup now writes `__backup_manifest.json` mapping backup filename -> original path relative to DshHome, and restore writes each file back in place; old snapshots without the manifest fall back to root with a clear warning. Isolated regression: 5 profile files + 3 settings restored in place, zero stray root files, point-in-time rollback moved new files and wrote its manifest — all pass.
668
- - **Failure summary**: on push/pull failure, `post-exit.ps1` now adds `Show-FailureSummary`, extracting `[X]` error lines with detail and recent `[!]` warnings from the run log and printing them together at the end — no more digging through logs.
669
- - **Auto-close**: after push/pull/update/restore, the window closes automatically 6 minutes after showing results; no more "press any key" (which hangs under remote desktop / unfocused windows). You can also click the × button to close early.
670
- - **Boundary**: workspace/conversations/skills/presets/plugin-data backed up before apply are data directories, not part of "config restore" rollback (they have their own sync/session paths; folding them in would add path mapping and heavy directory walking).
671
-
672
- ### 2026-11-18: push speed release 0.3.63 (Get-RelPath ~10x faster)
673
-
674
- 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.
675
-
676
- ### 2026-11-18: pull speed release 0.3.62 (341s → 109s, ~3.1×)
677
-
678
- 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:
679
-
680
- | Step | Result |
681
- |---|---|
682
- | 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` |
683
- | ① 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 |
684
- | ② 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 |
685
- | ③ 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" |
686
- | ④ **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) |
687
- | 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) |
688
- | 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 |
689
- | 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 |
690
-
691
- ### 2026-11-15: performance release 0.3.54 (three speedups, behaviour unchanged)
692
-
693
- | Step | Result |
694
- |---|---|
695
- | Size baseline | config repo 50,817 files / 398.7 MB (workspace 50,377 / 358.4 MB, `.git` 315 / 223.3 MB, 16 commits); `.dsh` 48,168 files; largest file `workspace\SquadLink\reversing\scripts\pe-analyst\out\insns.tsv` at 44.7 MB |
696
- | Synthetic same-size repo | 50,889 files / 416.4 MB (built in 136 s); first `git add -A` 92.0 s, empty re-run 0.30 s; `status --porcelain` 0.31 s, `ls-files --stage` 0.14–0.40 s |
697
- | Biggest push-side waste | `git ls-tree -r -l HEAD` = 19.98 / 21.4 / 23.16 s; alternatives measured: `rev-list --objects` 0.15 s, `cat-file --batch-all-objects --batch-check` 0.21 s, `diff-tree -r -l HEAD~1 HEAD` 0.12 s (none equals "total history size", so caching won over swapping the command) |
698
- | Hash cost | `Get-FileHash` 1.20 ms per file (600 files 0.72 s); .NET streaming SHA256 1.05 ms — only 1.1× faster, the bottleneck is per-file open/read of small random files |
699
- | Fast-path write-off | cmdlet style (per-file `Test-Path` + `Get-Item`) **37.78 s**; two `Get-ChildItem` passes + in-memory dictionary **3.91 s**; hashing only the few mismatches took 0.09 s and matched 0 files |
700
- | Network round trip | real Gitee `git ls-remote --heads origin` 0.90 / 0.97 / 0.96 s → dropping one fetch in a pull saves about 1 s |
701
- | Read-only walks | 48,168 files in `.dsh` enumerated in 6.85 s; 50,377 in the repo workspace in 2.17 s; single-file stat 0.73 ms |
702
- | Isolated end-to-end | fake `.dsh` + fake client root + local bare remote, 300-file workspace: push#1 exit 0 (full scan, `oversized: 0`), push#2 **3.23 s** (scan skipped), push#3 `-DeepVerify` exit 0 with "深哈希 300", pull exit 0 with `Fast-forward` and the remote's new file present |
703
- | Fixed along the way | `Get-OversizedHistory` returned `,$res` for an empty result, so the caller's `@()` saw Count 1 and an empty repo reported "1 oversized file in history (0.0 MB)" with a blank path. Changed to `return $res`; the cache now records `oversized: 0` |
704
- | Test lesson | an end-to-end run must fake the AppRoot (`Resolve-DshAppRoot` accepts `resources\app\package.json` or `resources\app.asar`); pointing it at the real `D:\DeepSeekHarness` lets `apply` overwrite the real mnemon, recoverable only from its automatic backup |
705
-
706
-
707
- A fake cloud bare repo + fake client root + a standalone `.dsh` holding only `profiles\desktop`; the plugin was installed from tgz and the main machine's directories were never touched.
708
-
709
- | Step | Result |
710
- |---|---|
711
- | Install the plugin, open the panel | all three routes registered; with nothing configured `repo.path` is empty rather than silently falling back, and push is blocked with 400 |
712
- | Configure repo / cloud | 200, the path lands in the local `.dsh\dsh-config-sync.json`; no origin → `git remote add` |
713
- | Generate all three scripts | written into the new machine's repo root, `-AppRoot` pointing at that machine's client root, with `--yes` and `y/N` guards |
714
- | First pull | upstream added first → `Already up to date` → backed up 11 files, laid down 436 → `pnpm install` 21 plugins → all 25 bundles resolvable |
715
- | Workspace / sessions | materials land in the fake client root; registry paths expand to machine paths; an empty workspace is created as an empty directory; session directory names match the machine recomputation character for character, and header `cwd` is rewritten by `fix-session-cwd.mjs` |
716
- | Push / restore | pushed to the fake cloud; restore prints a `-DryRun` plan, `--yes` takes a `manual-<timestamp>` safety copy then writes back, and the test marker really disappears |
717
- | Post-exit sync | all five `post-exit.ps1` exit codes (0/2/3/4/5) reproduced |
718
- | Local to-push | real machine: `git status` clean, two sessions in `~\.dsh\sessions` newer than the last sync, badge turns orange "To push", `local.pending = 15` (including the five profile files apply had just rewritten) |
719
- | Confirm → exit + visible window + relaunch | real machine `{"action":"pull-now"}`: `DSH 7→0` in 5 s; +10 s a PowerShell window titled "拉取" appears (no window while queued); after the pull it relaunches `0→4→7` |
720
- | Close → push + visible window + relaunch | real machine with `autoPush` on: queued as a hidden process → after closing, 7 processes with `hwnd=0` would not exit → forced cleanup after 16 s → window "推送" → push succeeds → automatic relaunch |
721
- | Mutual exclusion | the startup push and a manual pull hit together: the latter ended the former's not-yet-started waiting process and re-queued; no parallel run |
722
- | Empty-folder semantics (0.3.26) | isolated run: all eight `repoPhase` shapes classified correctly (including an 8.3 short-name path); `sync.ps1 push` on an empty folder is refused (exit 1, no `.git` created); `pull` in the same folder runs `init → fetch → checkout main` by itself, with `apply.ps1` in place from the bundled runtime |
723
-
724
- **Sync boundary**: workspace materials and sessions travel along, but the **default workspace (`default-workspace`) is not synced** (its directory name is encoded from each machine's `WorkspaceHome`, so the target cannot recognise it and just leaves an empty workspace with "empty history"); `models/`, `*.whl`, `*.safetensors` and any file over 100 MB stay out of the repo either. See sections 4 and 5 of the config repo's root `README.md`.
725
-
726
- The six issues found in the previous review round (git identity, cross-machine session directories overwriting each other, hard-coded `origin/main`, the finishing message, duplicated logic, dead code) are **all fixed and verified**; the mapping table is in section 12 of the config repo's root `README.md`.
727
- ### 2026-11-14: two machines, from scratch (isolated)
728
-
729
- A bare remote (`git init --bare -b main`), two fake client roots (`A\app`, `B\app`) and their own `.dsh` folders. Nothing on the main machine was touched; the run can be repeated.
730
-
731
- | Step | Result |
732
- |---|---|
733
- | A: first push | skeleton written (6 runtime scripts + `tools\fix-session-cwd.mjs` + version contract); capture produced 8 changes; 15 files committed and pushed to the bare `main` (`push_rc=0`) |
734
- | Placeholders on the repo side | `workspace\workspace-registry.json` stores `{{APP_ROOT}}/workspace/SquadLink` |
735
- | B: first pull, client never launched | `[X] target profile does not exist` (`pull_rc=1`) — **install the client and launch it once first** |
736
- | B: pull after creating the profile | `pull_rc=0`: workspace restored to `B\app\workspace\SquadLink` (byte-exact), registry merged into B's `storages\workspace.json` (path is the B path), 1 bundle resolvable |
737
- | No Node runner | log says `no usable built-in runtime`; session cwd stays untouched (session list would be empty); adding a usable `node.exe` made the fix take effect |
738
- | `settings.json` semantics | custom keys in `~\.dsh\settings.json` are **not** synced (whitelist of 13 files only) |
739
- | **Two bugs found by this run** | ① `fix-session-cwd.mjs` compared `next.length === text.length` to mean "nothing changed" — with equal-length paths on two machines (`D:\...` vs `E:\...`) it always misjudged, reporting `projAlreadyOk=1` while the file still pointed at the source machine; changed to `next === text`. ② step 4 of `apply.ps1` only checked `$cwdMap`, so when the repo had projcache but no sessions the whole block (including the projcache fix) was skipped; changed to `$cwdMap.Count -gt 0 -or $projMap.Count -gt 0`. After both fixes: `projFixed=1` and the cwd points at the local machine |
740
-
741
- ### 2026-11-14 (b): a 4-byte leftover in the session log, session creation returns 500
742
-
743
- After one sync, "new session" popped `新建会话失败:gateway/internal: failed to create session: SessionQueryError: stored session "…" is corrupt … invalid frame magic at byte 186`: one historical session log was corrupt, which made the whole session store fail validation — so even a brand-new session could not be created.
744
-
745
- | Step | Result |
746
- |---|---|
747
- | The file | `~\.dsh\sessions\--D-DeepSeekHarness-DSH~7834~7532--\session-58db748a…\session.v4.jsonl.zstd`, 423 bytes, mtime from the 11-13 sync, not from that day |
748
- | Byte layout | the zstd magic `28 b5 2f fd` sits at 0 / 190 / 343; DSH thinks the first frame ends at **186**, bytes 186..189 are garbage, and the real second frame starts at 190 |
749
- | Root cause | the first frame decompresses to 210 bytes (header line + trailing newline); the binary search returns 186 while the real frame end is 190 because the first frame carries a 4-byte content checksum and the decoder succeeds on the truncated prefix. `rest = buf.subarray(186)` therefore treated the old checksum as body text, leaving 186..189 permanently in the file |
750
- | Blast radius | 17 `session.v4.jsonl.zstd` under `~\.dsh\sessions` scanned: one genuinely broken; one false positive that turned out to be a **healthy 5-frame file with checksums** (magic at 0/197/380/479/559) and was restored byte-exact from backup |
751
- | Data repair | backup to `~\.dsh\backups\session-corrupt-<stamp>` → drop the 4-byte hole (423 → 419) → rescan bad=0; header cwd kept, second frame (269 bytes) decodes |
752
- | Code repair | `firstFrameEnd` adds 4 bytes per FHD bit2 and then corrects against the next frame magic; the first frame is rebuilt from the **whole decompressed text** with only the cwd value replaced (it used to recompress just the header line, dropping any trailing lines); **self-check before writing**; leftover tails in old broken files are dropped |
753
- | Isolated check | real checksum multi-frame sample: structure intact after the cwd rewrite (magic 0/169/352/451/531 all decode); idempotent rerun `alreadyOk=1`; a file with the hole repaired in one pass (402 bytes, magic 0/169/322) |
754
- | Takeaway | session logs can only "lose content", never "hold wrong content", so deleting the hole is safer than recompressing; the helper now prefers to skip and report rather than write a broken next frame |
579
+ | 2026-11-19 | 0.3.69 | Carry billion-context compaction state across machines (bili-state.mjs); two new notice kinds (plugin-missing / context-state) |
580
+ | 2026-11-19 | 0.3.68 | Session projection-cache guard (fixes agent-busy session creation) |
581
+ | 2026-11-19 | 0.3.67 | Session log seq reconciliation guard (merge by seq, no more whole-file overwrite) |
582
+ | 2026-11-19 | 0.3.66 | .gitattributes silences LF/CRLF warnings |
583
+ | 2026-11-18 | 0.3.65 | Refresh button feedback (text changes to "Refreshing…") |
584
+ | 2026-11-18 | 0.3.64 | Backup restore fix (write back to original location) + failure summary + auto-close |
585
+ | 2026-11-18 | 0.3.63 | Push speed: Get-RelPath ~10x faster |
586
+ | 2026-11-18 | 0.3.62 | Pull speed: 341s → 109s (3.1×) |
587
+ | 2026-11-15 | 0.3.54 | Three speedups (fast-screen / history cache / single fetch), zero behaviour change |
588
+ | 2026-11-14 | — | Two machines from scratch (isolated); session log first-frame 4-byte leftover fix |
589
+ | 2026-11-11 | — | Single-machine isolated end-to-end (install → pull → push → restore) |
590
+
591
+ Detailed test data is in each version's Release Notes.
package/README.md CHANGED
@@ -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.68"` 后 `pnpm i`;包名与 `cordis.patch.yml` 里注册的名字、插件目录 `dsh-config-sync-plugin-<ver>` 一致 |
18
+ | npm | `npm i dsh-config-sync-plugin` | 适合把它当依赖管理,或在 profile 的 `package.json` 里写 `"dsh-config-sync-plugin": "^0.3.70"` 后 `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
 
@@ -111,16 +111,7 @@ pwsh -File runtime\sync.ps1 pull `
111
111
 
112
112
  ---
113
113
 
114
- ## 安装
115
-
116
- ```sh
117
- # 版本号换成 Releases 页里最新的那个
118
- dsh plugin add https://raw.githubusercontent.com/QcWyGm/dsh-config-sync-plugin/main/releases/dsh-config-sync-plugin-<版本>.tgz
119
- ```
120
-
121
- 或在 DSH「插件 → 发现 → 索引源」里添加本仓库索引(见「作为插件市场的索引源」)。第三方市场 **dshmarket 不读这份索引**,原因见同一节。
122
114
 
123
- `apply.ps1` 落地时做三件事:`local-plugins\dsh-config-sync-plugin-<版本>.tgz` 解压到 `<AppRoot>\dsh-config-sync-plugin-0.1.0`;`package.json` 加一条 `link:` 依赖与一条 `dsh.profile.bundles`;`cordis.patch.yml` 加 `config-sync` 行。
124
115
 
125
116
  ## 包含什么
126
117
 
@@ -143,16 +134,16 @@ dsh plugin add https://raw.githubusercontent.com/QcWyGm/dsh-config-sync-plugin/m
143
134
 
144
135
  ## 面板显示什么
145
136
 
146
- 布局是「一行状态 + 一行指标 + 分区卡片」,从上往下读:
137
+ 从上往下:
147
138
 
148
139
  - **标题行**:`配置同步 本机 [一致/待推送/待拉取/有问题] 云端 [一致/不一致/待拉取]`。本机徽标看配置齐不齐、依赖缺不缺、有无未提交/未推送;云端**全自动**(打开面板查一次、之后每 2 分钟复查),没有手动按钮。右上角「重新检测」与「本机路径」按钮。
149
140
  - **元信息行**:`app 版本 / Electron 版本 · 分支 @ 短 HEAD`。
150
141
  - **指标条**:`本机 / 契约`、`bundle`、`依赖`、`备份快照`、`上次同步`(后面 `(+N)` 表示之后又写入了几个文件)。有事才在下面出现「待办」。
151
142
  - **分区**:概览 → 本机路径(**默认整块不显示**,点标题行「本机路径」按钮展开,有待处理项时按钮变橙带数量)→ 同步冲突(真有冲突时才出现)→ 同步目标 → 自动化与插件更新 → 退出后执行 → 还原备份 → 同步内容 → 问题反馈。
152
143
 
153
- **统一交互**:「本机路径 / 本机仓库 / 云端仓库 / 自动同步 / 插件更新 / 同步内容」都是**先只读、点「修改」才解锁**,改完「保存」,「取消」丢弃本次改动。只有"没配过"的卡(没设仓库、没设远端)强制停在编辑态且不给「取消」。
144
+ **统一交互**:所有卡片**先只读,点「修改」才解锁**,改完「保存」生效,「取消」丢弃。没配过的卡强制停在编辑态。
154
145
 
155
- **「待推送」不只看 git**:`git status` 干净时新会话/新资料可能还躺在 `~\.dsh` 里没 capture。`sync.ps1` push/pull 成功后会写 `~\.dsh\config-sync-state.json`(`lastSyncAt`/`mode`/`head`);`status` 的 `local` 段 stat `sessions`、`skills`、`.agent-presets`、`mnemon`、profile 五文件、登记的工作区目录,mtime 晚于 `lastSyncAt` 的计入 `local.pending`,徽标转橙。只看 mtime、不读内容;上限 20000 文件 / 1.5 秒。
146
+ **「待推送」不只看 git**:`git status` 干净时新会话/新资料可能还在 `~\.dsh` 里没 capture。`status` 按 mtime 比对 `sessions`、`skills`、`.agent-presets`、`mnemon`、profile 文件、工作区目录,晚于上次同步的计入待推送。只看 mtime,上限 20000 文件 / 1.5 秒。
156
147
 
157
148
  **「待拉取」= 本机仓库还是空目录**(不报异常,橙色徽标 + 「执行拉取会从云端拉到这里」)。
158
149
 
@@ -519,7 +510,7 @@ node ~\.dsh\.dsh-plugin-market\market-core.mjs catalog --profile desktop
519
510
 
520
511
  ## 生成器里已经堵掉的坑
521
512
 
522
- 都是**在新机器上真跑一遍**才暴露的:
513
+ 新机器真跑一遍才暴露的坑:
523
514
 
524
515
  | 坑 | 处理 |
525
516
  |---|---|
@@ -565,161 +556,18 @@ pwsh -File sync.ps1 push -ScanHistory
565
556
 
566
557
  ## 实测记录
567
558
 
568
- ### 2026-11-18:隔离环境 B 机全新拉取回归(工作区 / 会话归属 / 上下文超长)
569
-
570
- 用干净的隔离 B 机(approot / dshome / wshome + 内置 node 执行器)模拟「全新机器首次拉取」:先清掉 `sessions`、`storages/workspace.json`、`session_projcache`,再用配置仓库最新 `apply.ps1` 跑完整还原。结果逐项核对通过:
571
-
572
- | 验证项 | 结果 |
573
- |---|---|
574
- | apply 执行 | `EXIT=0`,73 秒(拉取提速生效,之前 340s) |
575
- | 工作区挂载 | 5 个工作区全部还原,path 均指向本机 `_iso_b\approot\*`,登记表按 ID 合并 ✅ |
576
- | 会话归属 | 工作区登记表 sessionIds 共 71 个;sessions 目录反推 73 个,只差 2 个(幽灵工作区 + forward-confirm 特殊会话,正常例外)✅ |
577
- | projcache | B 机 **不存在**(FILES=0)——仓库里明明有超窗会话的 projcache,但未同步过来 ✅ |
578
- | 会话 cwd | 64 个会话,63 个首帧 cwd 正确;唯一 1 个是 forward-confirm passthrough(正常例外)✅ |
579
- | bundle | 24 项全部可解析;3 个 link 插件显示「本地插件已存在」,不再反复解压 ✅ |
580
-
581
- **上下文超长闭环**:之前因 A 机 token 计量缓存超窗的 3 个会话,现在都正确归到对应工作区——`session-58db748a`(1,553,981 tokens)→ DSH破甲、`session-bbf3e5c9`(1,080,398)→ SquadLink、`session-a1061521`(1,001,058)→ dsh-config-sync。同时 B 机 projcache 为空,DSH 启动时会从会话日志按 B 机实际模型配置重建 token 计量并触发 compaction,不会再把 A 机超窗缓存直接怼给 provider。
582
-
583
- 非故障警告(日志已确认无害):`--D-DeepSeekHarness-comfyUI--` / `--dsh-im-forward-confirm--` 找不到对应工作区(特殊会话目录);`-SkipInstall` 跳过 21 个 registry 插件(隔离环境离线,真机有网时不加即补齐);`dsh-config-sync-0.1.0` / `extra/manifest.json` 无归档正常跳过;`dsh-config-sync` 槽位有本机多出的残留文件(加 `-PruneWorkspace` 才删)。
584
-
585
- ### 2026-11-19:发版 0.3.68(会话投影缓存守卫,治 agent-busy 建会话失败)
586
-
587
- **问题**:DSH 的「新建会话」并不每次都真建——客户端会先在工作区里找一条**空白会话**复用(`client-ui-workspace/createInWorkspace()` → `sessions.ids.find(summary.blank && …)` → `createNamed({ sessionId: blank })`)。而 `summary.blank` 来自投影缓存 `session_projcache\sessions\<id>.json` 里的 `record.rows.sessionListMetadata.val.blank`。
588
-
589
- 缓存是「写一半就停」的产物:某次建会话时写出了 `blank:true / seq:-1`,之后日志继续追加(有了 `turn/start`、`user/message`),缓存却没跟着推进。于是列表仍把这条会话当空白,UI 挑它复用,宿主抛:
590
-
591
- ```
592
- session/agent-busy: session "<id>" is owned by subagent routing
593
- ```
594
-
595
- 新建会话直接失败,且刷不回来(缓存一直被复用)。跨机同步会放大这个问题——A 机的陈旧缓存被 pull 到 B 机,B 机同样中招。
596
-
597
- **修复**:三层,都不碰日志、不碰工作区登记,只做缓存文件操作。
598
-
599
- | 层 | 触发 | 动作 |
559
+ | 日期 | 版本 | 要点 |
600
560
  |---|---|---|
601
- | 客户端 | `sessions.create` 撞上 `agent-busy` | 包一层 `sessions.create`:捞出撞车的 `sessionId` 报给宿主,去掉旧 `sessionId` 后**重试一次**。正常路径零开销 |
602
- | 宿主 | 收到客户端上报 | 把 `<DshHome>/storages/session_projcache/sessions/<id>.json` **挪到** `<DshHome>/logs/session-cache-guard-backup/`(只挪不删),DSH 下次读列表时按完整日志重建缓存,`blank` 自然变 `false` |
603
- | 定时 | 每 3 分钟 | 主动扫同类陈旧缓存,条件四重全中才算(宁可漏判不可误删):①缓存能解析且 `blank===true` ②能找到对应 `session.v*.jsonl.zstd` ③日志里确有 `turn/start` 或 `user/message` ④日志末事件 `seq` > 缓存记录的最大 `seq` |
604
-
605
- 新增路由 `/config-sync/cache-guard`:`GET` 只读扫描;`POST` 支持 `scan` / `sweep` / `clear` / `busy`。设置里新增 `cacheGuard` 开关,**默认开**;关掉后既不定时扫描,也不理会客户端的 `agent-busy` 上报。
606
-
607
- 实现:`runtime/tools/session-cache-guard.mjs`(`scanSessionCaches` / `clearSessionCaches` / `runGuard` / `indexSessionLogs`),客户端半身在 `client.js` 的 `0.3.68:会话缓存守卫` 段。
608
-
609
- **手动兜底**:面板「会话缓存守卫」卡可以直接扫一遍、看到候选与判定依据,再决定清哪几条;缓存永远只备份不删除,清错了从 `<DshHome>/logs/session-cache-guard-backup/` 拷回去就行。
610
-
611
-
612
- ### 2026-11-19:发版 0.3.67(会话日志 seq 对账护栏)
613
-
614
- **问题**:两台机器各自往同一个会话写事件时,同步是「整文件覆盖」。谁后 push 谁的内容顶掉对方的后半段,事件流出现 `seq` 跳号,DSH 启动直接报 `stored session ... is corrupt: corrupt session log: invalid committed event at line N: released v2 row N has seq gap (expected X, got Y)`,该会话再也打不开。
615
-
616
- **修复**:`capture.ps1`(推送侧)与 `apply.ps1`(拉取侧)遇到 `session*.jsonl.zstd` 不再 `Copy-Item -Force`,改为交给新加的 seq 护栏:
617
-
618
- | 情形 | 处理 |
619
- |---|---|
620
- | 目标更全 / 完全相同 | 保留目标,什么都不写 |
621
- | 源是目标的严格超集 | 用源覆盖目标 |
622
- | 两边各有独占事件 | 按 `seq` 求并集写入,两边事件全保住 |
623
- | 目标自身断档、源能补齐 | 先补齐再写(`merge`,可救回已被覆盖坏的会话) |
624
- | 洞补不回来(事件确实丢了) | **保持原样不覆盖**,记 `sync-notices.json` 的 `failed` 并提示需人工处理 |
625
-
626
- 护栏实现:`tools/session-log-lib.mjs`(多帧 zstd 逐帧解、字节前缀比较、按 seq 合并)+ `tools/session-log-guard.mjs`(`check` / `decide` / `merge` / `batch` CLI,批量模式给 ps1 调用,结果走临时 JSON 文件而不是 stdout——Electron 是 GUI 子系统)。11MB 会话全量解析 ~0.6s,可进同步热路径。
627
-
628
- **顺带两处**:
629
- - `.gitattributes` 补 `conversations/sessions/**/*.zstd binary` 与 `workspace/** -text`,避免 Windows `core.autocrlf` 或 git 的行尾归一再次写坏二进制日志;
630
- - `capture.ps1` 把「大目录文件比较」几个辅助函数上移到脚本前部——它们原先定义在调用点之后,`-WorkspaceOnly` 跑到会话镜像循环会报 `Test-TreeFileChanged is not recognized`。
631
-
632
- 诊断工具:`node tools/check-session-log.mjs <日志>` 或 `<日志A> <日志B>`,输出自洽性(行数/seq 范围/gaps)与两份的关系(`identical` / `prefix` / `superset` / `fork`)。
633
-
634
- ### 2026-11-19:发版 0.3.66(.gitattributes 消除 LF/CRLF 警告)
635
- - **跨平台行尾噪音**:Windows 上 `core.autocrlf=true` 会把仓库里 LF 写入的 `session_projcache/*.json` 自动转成 CRLF,推送时 Git 报 "LF will be replaced by CRLF" 警告。新增 `.gitattributes` 将该目录标记为二进制(`binary`),其余文本文件统一 `eol=lf`,彻底消除该类警告。
636
- - 纯配置项改动,不改变任何同步逻辑、行为与数据。
637
- ### 2026-11-18:发版 0.3.65(刷新按钮反馈)
638
- - **顶部「重新检测」**:点击后无论数据是否变化都给明确 toast 反馈——成功显示「已重新检测,数据已是最新(时间)」,失败显示具体原因,复用 5 秒自动消失的提示条。此前状态本就是最新时页面看起来毫无变化,用户会以为没点上。
639
- - **卡片「刷新」按钮**:同步冲突、插件数据、同步内容、问题反馈、设置摘要行五处刷新按钮,点击后文字变「刷新中…」并禁用,结束恢复「刷新」。其中同步冲突 / 同步内容 / 问题反馈三处原来的 `load()` 根本没驱动 `busy`(按钮文字永远不变),本次补齐 `setBusy`;顶部与本机路径的「检测中…/读取中…」保持不变。
640
- - `node --check` 与客户端半身自检全过,纯前端交互修复,行为与数据不变。
641
- ### 2026-11-18:发版 0.3.64(还原备份修复 + 失败原因集中展示 + 自动关窗)
642
-
643
- - **还原备份 bug 修复**:`apply.ps1` 备份插件设置时只留文件名(如 `workspace.json`),`restore.ps1` 还原时全堆到 `~\.dsh` 根目录,`storages\workspace.json`、`our-free-model\settings.json`、`redteam\preset-declare.json` 等回不到原位。现在备份时写一份 `__backup_manifest.json` 记录「备份文件名 → 相对 DshHome 的原路径」,还原按清单写回原位;无清单的老快照退化为写回根目录并明确告警。隔离回归:profile 5 文件 + settings 3 文件原位还原、根目录零残留、时点回退移走新增文件并写 rollback 清单,全部通过。
644
- - **失败原因集中展示**:推送/拉取失败时,`post-exit.ps1` 收尾新增 `Show-FailureSummary`,从执行日志抽取 `[X]` 错误行及后续详情、最近的 `[!]` 警告,红/黄集中打印在末尾,不用再翻日志找原因。
645
- - **自动关窗**:推送/拉取/更新/还原脚本结束后,展示结果 6 分钟后自动退出关窗,不再要求「按任意键」(远程桌面/无焦点时 `ReadKey` 会一直卡住);也可直接点右上角 × 提前关闭。
646
- - **边界说明**:`apply` 拉取前备份的 workspace/conversations/skills/presets/plugin-data 属数据目录,不纳入「配置还原」回退范围(有各自的同步/会话路径,强塞会引入路径映射与大目录遍历开销)。
647
-
648
- ### 2026-11-18:推送提速发版 0.3.63(Get-RelPath 快 10 倍)
649
-
650
- 推送/拉取共用的 `Get-RelPath` 原来对每个文件做两次 `-split` + `Where-Object`;5 万文件工作区下,推送比对单独占 11.7s。改为 `StartsWith` + `Substring` 快路径,大小写或 8.3 短路径不一致时回退原段数比对逻辑。49138 文件全量比对与老版输出 0 差异,微基准 5.08s → 0.51s(约 9.9 倍)。三处 `dsh-sync-common.ps1`(源码 / 配置仓库 / 插件副本)同步。
651
-
652
- ### 2026-11-18:拉取提速发版 0.3.62(341s → 109s,约 3.1×)
653
-
654
- 一台机器上工作区有 49110 个文件、另一个工作区槽位堆积了 101097 个孤儿文件,点「拉取」时卡在「已还原工作区」好几分钟。逐段打点后定位到 4 个浪费点,全部在 `runtime\apply.ps1`,行为不变(落到仓库的文件、提交内容、配置结果逐字节一致),只改「怎么算」:
655
-
656
- | 环节 | 结果 |
657
- |---|---|
658
- | 端到端总耗时 | 340.9s → 108.5s(同环境同输入,约 3.1×);功能断言全过:5 工作区还原、写入/更新 0、备份 0、会话 cwd 修正 56、bundle 24 项可解析、`EXIT=0` |
659
- | ① 无条件全量备份 | 原来每个工作区还原前把整个工作区备份一遍(49110 文件 × 1.99ms ≈ 98s),而二次拉取时源与目标内容全一致、实际需备份 0 个。改为「确认某个文件即将被覆盖时才备份这一个」→ 备份 49110 → 0 |
660
- | ② 哈希 API | `Get-FileHash` 实测 0.957ms/文件,.NET `SHA256.ComputeHash` 流式 0.16ms/文件(约 6×);会话首帧与工作区比对的哈希统一换成流式 SHA256 |
661
- | ③ zip 版本正则 | 归档内 `package.json` 路径在 `Compress-Archive` 打出的 zip 里是反斜杠,而版本正则只认 `/` → 读不到归档版本、`git fetch` 刷新 mtime 后每轮误判「本地插件有新版本」,反复重解压 3 个 link 插件。改成 `[\\/]` 兼容两种分隔符后,三插件稳定显示「本地插件已存在」 |
662
- | ④ **真凶: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) |
663
- | 剩余 108s | DSH破甲 49110 文件的哈希 + 复制 71s 是实打实的磁盘 I/O;再压需要方案③「git HEAD 增量短路」,风险高、默认未做 |
664
- | 顺手修 | 历史遗留的 `market-index.json` 结构损坏(0.3.61 发版时把 `plugins` 数组写成了对象/数组混合)与该条目 commit 的 `TODO_COMMIT_0361` 占位符,本次一并修正;0.3.61 的「跳过 projcache 同步」(上下文超长修复)保持不变 |
665
- | 教训 | PowerShell 管道 `ForEach-Object` 打时间戳会被输出缓冲吞掉,实时打点要写 stderr(`[Console]::Error.WriteLine`);带 BOM 的 UTF-8 脚本全程只能用 UTF8 读写,用 ISO-8859-1 读写会把中文 `.NET` 强制 UTF8 解码后再写回全变 `?` 并丢 BOM |
666
-
667
- ### 2026-11-15:性能发版 0.3.54(三处提速,行为不变)
668
-
669
- | 环节 | 结果 |
670
- |---|---|
671
- | 规模基线 | 配置仓库 50817 文件 / 398.7MB(workspace 50377 / 358.4MB,`.git` 315 / 223.3MB,16 个提交);`.dsh` 48168 文件;最大单文件 `workspace\SquadLink\reversing\scripts\pe-analyst\out\insns.tsv` 44.7MB |
672
- | 同规模假仓库 | 50889 文件 / 416.4MB(生成 136s);`git add -A` 首跑 92.0s、空跑 0.30s;`status --porcelain` 0.31s、`ls-files --stage` 0.14–0.40s |
673
- | 推送侧最大浪费 | `git ls-tree -r -l HEAD` = 19.98 / 21.4 / 23.16s;替代测速:`rev-list --objects` 0.15s、`cat-file --batch-all-objects --batch-check` 0.21s、`diff-tree -r -l HEAD~1 HEAD` 0.12s(都不等价于「全量历史体积」判定,所以最终选缓存而非替换命令) |
674
- | 哈希成本 | `Get-FileHash` 单文件 1.20ms(600 文件 0.72s);.NET 流式 SHA256 1.05ms,只快 1.1×——瓶颈是每文件 open/read 与随机小文件,换 API 没用 |
675
- | 快筛写法对比 | cmdlet 式(逐文件 `Test-Path` + `Get-Item`)**37.78s**;两次 `Get-ChildItem` + 内存字典 **3.91s**;后者只对 size/mtime 不一致者算哈希,实测 0 个需算(0.09s) |
676
- | 网络往返 | 真实 Gitee `git ls-remote --heads origin` 三次 0.90 / 0.97 / 0.96s → 拉取省掉一次 fetch 约省 1s |
677
- | 只读遍历 | `.dsh` 48168 文件枚举 6.85s;仓库 workspace 50377 文件枚举 2.17s;单文件 stat 0.73ms |
678
- | 隔离端到端 | 假 `.dsh` + 假客户端根 + 本地 bare 远端、300 文件工作区:push#1 退出 0(全量扫、`oversized: 0`)、push#2 **3.23s**(跳过扫描)、push#3 `-DeepVerify` 退出 0 且「深哈希 300」、pull 退出 0 且 `Fast-forward`、远端新增文件到位 |
679
- | 顺手修掉 | `Get-OversizedHistory` 空结果写成 `return ,$res`,调用方 `@()` 之后 Count 变 1 → 空仓库误报「历史里有 1 个超限文件(0.0 MB)」且路径为空。改成 `return $res`,复测缓存 `oversized: 0` |
680
- | 测试教训 | 端到端必须造假 AppRoot(`Resolve-DshAppRoot` 认 `resources\app\package.json` 或 `resources\app.asar`);把真实 `D:\DeepSeekHarness` 传进去会被 `apply` 覆盖真实 mnemon,只能靠它的自动备份还原 |
681
-
682
- ### 2026-11-14(二):会话日志首帧 4 字节残留,新建会话 500
683
-
684
- 同步过一次之后,客户端点「新会话」直接弹 `新建会话失败:gateway/internal: failed to create session: SessionQueryError: stored session "…" is corrupt … invalid frame magic at byte 186`——一个历史会话的日志坏了,整个会话库的校验跟着失败,所以连新会话都建不出来。
685
-
686
- | 环节 | 结果 |
687
- |---|---|
688
- | 现场 | `~\.dsh\sessions\--D-DeepSeekHarness-DSH~7834~7532--\session-58db748a…\session.v4.jsonl.zstd`,423 字节,mtime 是 11-13 那次同步,不是当天 |
689
- | 字节解剖 | zstd 帧头 `28 b5 2f fd` 出现在 0 / 190 / 343;DSH 认为首帧止于 **186**,186..189 是 4 字节垃圾,真正的第 2 帧起点在 190 |
690
- | 根因 | 首帧解压是 210 字节(header 行 + 结尾换行),二分得到的「最小可解前缀」= 186,而帧尾实际是 190:DSH 首帧带 4 字节 content checksum,解压器对缺这 4 字节的前缀同样返回成功。`rest = buf.subarray(186)` 于是把旧 checksum 当正文,写回后 186..189 永久残留 |
691
- | 影响面 | 扫 `~\.dsh\sessions` 下 17 个 `session.v4.jsonl.zstd`:真正的坏文件 1 个(带空洞);另 1 个被判误报,复核是**带 checksum 的正常 5 帧文件**(帧头 0/197/380/479/559),已按备份原样还原 |
692
- | 数据修复 | 备份到 `~\.dsh\backups\session-corrupt-<stamp>` → 删掉 4 字节空洞(423 → 419)→ 复扫 bad=0;首帧 cwd 保留、第 2 帧(269 字节)可解 |
693
- | 代码修复 | `firstFrameEnd` 按 FHD bit2 补 4 字节并以「下一帧帧头」校正;首帧改为**整段解压文本替换 cwd 后重压**(原来只重压 header 一行,首帧有追加行会丢);**先自检后落盘**;遇到历史残留尾巴自动丢掉 |
694
- | 隔离验证 | 用真实 checksum 多帧样本改 cwd:帧结构完整(0/169/352/451/531 全可解);幂等复跑 `alreadyOk=1`;喂入带空洞的坏文件一次修好(402 字节,帧头 0/169/322) |
695
- | 结论 | 会话日志只会「缺内容」不会「内容错」,所以删空洞比重新压缩安全;helper 现在宁可跳过报错也不写坏后续帧 |
696
-
697
- ### 2026-11-14:两台机器从零跑通(隔离环境)
698
-
699
- 假云端裸仓库(`git init --bare -b main`)+ 两套假客户端根(`A\app`、`B\app`)+ 各自独立 `.dsh`。全程不碰主力机目录,可反复重跑。
700
-
701
- | 步骤 | 结果 |
702
- |---|---|
703
- | A 机首次推送 | 自动写 6 个执行体 + `tools\fix-session-cwd.mjs` + 版本契约;capture 抓到 8 处变更;提交 15 文件、推到 bare 的 `main`(`push_rc=0`) |
704
- | 仓库侧占位符化 | `workspace\workspace-registry.json` 的 path 写成 `{{APP_ROOT}}/workspace/SquadLink` |
705
- | B 机首次拉取(未装客户端) | `[X] 目标 profile 不存在` 退出(`pull_rc=1`)——**新机器必须先装并启动一次客户端** |
706
- | B 机补 profile 后拉取 | `pull_rc=0`:工作区还原到 `B\app\workspace\SquadLink`(字节保真)、登记表合并成 B 的 `storages\workspace.json`(path 是 B 路径)、bundle 1 项可解析 |
707
- | 无 Node 执行器时 | 日志 `本机没有可用的内置运行时`,会话 cwd 不改写(会话列表会是空的);补一个可用 `node.exe` 后修复生效 |
708
- | settings 语义 | `~\.dsh\settings.json` 里的自定义键**不同步**(白名单制,只搬那 13 个文件) |
709
- | **顺手抓到两个 bug** | ①`fix-session-cwd.mjs` 用 `next.length === text.length` 判"内容没变"——两台机器路径等长时(`D:\...` ↔ `E:\...`)必然误判,表里返回 `projAlreadyOk=1` 而文件里 cwd 仍指源机;改成 `next === text`。②`apply.ps1` 第 4 步只按 `$cwdMap` 判断,仓库里只有 projcache、没有 sessions 时整段跳过,projcache 修复永远不执行;改成 `$cwdMap.Count -gt 0 -or $projMap.Count -gt 0`。两处修完:`projFixed=1`、拉取后 cwd 正确指向本机 |
710
-
711
- ### 2026-11-11:单机隔离环境(装插件 → 拉取 → 推送 → 还原)
712
-
713
- | 步骤 | 结果 |
714
- |---|---|
715
- | 装插件、开面板 | 三道路由都注册;未配置时 `repo.path` 为空不静默回退,推送被 400 拦 |
716
- | 配仓库 / 云端 | 200,路径落进本机 `.dsh\dsh-config-sync.json`;无 origin → `git remote add` |
717
- | 生成三份脚本 | 落在仓库根,`-AppRoot` 指向该机客户端根,带 `--yes` 与 `y/N` 守卫 |
718
- | 首次拉取 | 首次补 upstream → `Already up to date` → 备份 11 文件、铺 436 个 → `pnpm install` 21 个插件 → 25 个 bundle 全部可解析 |
719
- | 工作区 / 会话 | 资料落在假客户端根;登记表路径展开成本机路径;空工作区补建成空目录;会话目录名按本机路径重算的编码逐字一致 |
720
- | 推送 / 还原 | 推到假云端;还原先 `-DryRun` 出计划,`--yes` 后自保 `manual-<时间戳>` 再写回 |
721
- | 退出后同步 | `post-exit.ps1` 五个退出码(0/2/3/4/5)全部复现 |
722
- | 空目录语义 | `repoPhase` 八种形态判定全对(含 8.3 短名路径);空目录跑 `push` 被拦(退出码 1、未生成 `.git`),跑 `pull` 自动 `init → fetch → checkout main` |
723
-
724
- 真机部分另记两条:`{"action":"pull-now"}` 时 `DSH 7→0` 用 5 秒、+10 秒出现可见窗口、拉完自动 `0→4→7`;开 `autoPush` 后点关闭,7 个进程 `hwnd=0` 不退,16 秒后强制收尾并推送成功。
725
-
561
+ | 2026-11-19 | 0.3.69 | 跨机搬运 billion-context 压缩状态(bili-state.mjs);同步清单新增 plugin-missing / context-state 两类提示 |
562
+ | 2026-11-19 | 0.3.68 | 会话投影缓存守卫,治 agent-busy 建会话失败 |
563
+ | 2026-11-19 | 0.3.67 | 会话日志 seq 对账护栏(跨机写同一会话按 seq 求并集,不再整文件覆盖);.gitattributes 钉 binary;capture hoist |
564
+ | 2026-11-19 | 0.3.66 | .gitattributes 消除 LF/CRLF 警告 |
565
+ | 2026-11-18 | 0.3.65 | 刷新按钮反馈(文字变「刷新中…」) |
566
+ | 2026-11-18 | 0.3.64 | 还原备份修复(写回原位)+ 失败原因集中展示 + 6 分钟自动关窗 |
567
+ | 2026-11-18 | 0.3.63 | 推送提速:Get-RelPath 快 10 倍 |
568
+ | 2026-11-18 | 0.3.62 | 拉取提速:341s → 109s(3.1×) |
569
+ | 2026-11-15 | 0.3.54 | 三处提速(快筛/历史缓存/单次 fetch),行为不变 |
570
+ | 2026-11-14 | — | 两台机器从零跑通(隔离环境);会话日志首帧 4 字节残留修复 |
571
+ | 2026-11-11 | — | 单机隔离环境全链路验证(装插件 → 拉取 → 推送 → 还原) |
572
+
573
+ 详细测试数据见对应版本的 Release Notes。