dsh-session-manager 0.4.4 → 0.4.6

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-session-manager",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Session manager for the DeepSeek Harness Web UI: delete sessions, archive sessions, move sessions across workspaces, and migrate a session’s Agent preset. Suggestions are welcome on GitHub. 在 DeepSeek Harness Web 中进行会话管理,包括:删除会话、归档会话、跨工作区移动会话、迁移会话的 Agent 预设。欢迎至GitHub提意见。",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -34,7 +34,9 @@
34
34
  "cordis.patch.yml",
35
35
  "LICENSE",
36
36
  "README.md",
37
- "README.zh.md"
37
+ "README.zh.md",
38
+ "CHANGELOG.md",
39
+ "scripts/heal-v2-sessions.ps1"
38
40
  ],
39
41
  "dsh": {
40
42
  "bundle": {
@@ -0,0 +1,79 @@
1
+ # dsh-session-manager companion script: one-time repair of the DSH
2
+ # 0.1.1-rc.2 v2/v0 filename mismatch. It renames a
3
+ # session.v2.jsonl.zstd whose header says version 0 to session.jsonl.zstd.
4
+ #
5
+ # Run this BEFORE starting DSH. DSH initializes workspace/session state before
6
+ # user plugin apply() runs, so a plugin cannot reliably repair this particular
7
+ # boot-time mismatch after the fact.
8
+
9
+ param(
10
+ [string]$DshHome = $(
11
+ if ([string]::IsNullOrWhiteSpace($env:DSH_HOME)) {
12
+ Join-Path $env:USERPROFILE '.dsh'
13
+ } else {
14
+ $env:DSH_HOME
15
+ }
16
+ )
17
+ )
18
+
19
+ if (-not (Test-Path -LiteralPath $DshHome -PathType Container)) {
20
+ Write-Host "DSH home not found at $DshHome; nothing to do." -ForegroundColor Yellow
21
+ exit 0
22
+ }
23
+
24
+ $sessionsRoot = Join-Path $DshHome 'sessions'
25
+ if (-not (Test-Path -LiteralPath $sessionsRoot -PathType Container)) {
26
+ Write-Host "No sessions directory at $sessionsRoot; nothing to do." -ForegroundColor Yellow
27
+ exit 0
28
+ }
29
+
30
+ $healed = 0
31
+ $skipped = 0
32
+ $errors = 0
33
+
34
+ # The first zstd frame contains the header. Node's one-shot decoder is enough
35
+ # here because we intentionally inspect only that first frame.
36
+ $nodeScript = "const fs = require('node:fs');" +
37
+ "const zlib = require('node:zlib');" +
38
+ "const file = process.argv[1];" +
39
+ "const bytes = fs.readFileSync(file);" +
40
+ "const text = zlib.zstdDecompressSync(bytes).toString('utf8');" +
41
+ "process.stdout.write(text.split('\\n', 1)[0]);"
42
+
43
+ Get-ChildItem -LiteralPath $sessionsRoot -Directory -ErrorAction SilentlyContinue | ForEach-Object {
44
+ Get-ChildItem -LiteralPath $_.FullName -Directory -ErrorAction SilentlyContinue | ForEach-Object {
45
+ $dir = $_.FullName
46
+ $v2 = Join-Path $dir 'session.v2.jsonl.zstd'
47
+ $v0 = Join-Path $dir 'session.jsonl.zstd'
48
+
49
+ if (-not (Test-Path -LiteralPath $v2 -PathType Leaf)) { return }
50
+ if (Test-Path -LiteralPath $v0 -PathType Leaf) {
51
+ $skipped++
52
+ return
53
+ }
54
+
55
+ try {
56
+ $headerJson = & node -e $nodeScript $v2
57
+ if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace(($headerJson -join ''))) {
58
+ throw 'Node zstd decoder failed'
59
+ }
60
+ $header = ($headerJson -join '') | ConvertFrom-Json -ErrorAction Stop
61
+ if ($header.version -ne 0) {
62
+ $skipped++
63
+ return
64
+ }
65
+
66
+ Move-Item -LiteralPath $v2 -Destination $v0 -ErrorAction Stop
67
+ $healed++
68
+ Write-Host "healed: $v2 -> $v0" -ForegroundColor Green
69
+ } catch {
70
+ $errors++
71
+ Write-Host "skipped (read or move failed): $v2 -- $($_.Exception.Message)" -ForegroundColor DarkYellow
72
+ }
73
+ }
74
+ }
75
+
76
+ Write-Host ''
77
+ Write-Host "Healed: $healed"
78
+ Write-Host 'Skipped (v0 sibling already exists, or header is not version 0):' $skipped
79
+ Write-Host "Errors: $errors"