dsh-file-history 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. package/lib/index.js +13 -3
  2. package/package.json +8 -2
package/lib/index.js CHANGED
@@ -580,6 +580,8 @@ class Workspace {
580
580
  async maintain() {
581
581
  const entries = this.state.entries
582
582
  const kept = this.options.pruneAfterCheckpoints
583
+ // 0 表示不做自动裁剪,只受 maxEntries 管。
584
+ if (kept <= 0) return
583
585
  // 每条分支各算各的窗口:一条冷掉的分支不该决定另一条能留几轮,反过来,
584
586
  // 别的会话线刚发生的轮次也不能被本支的切点带走。
585
587
  const familyPoints = new Map()
@@ -592,16 +594,24 @@ class Workspace {
592
594
  for (const list of familyPoints.values()) list.sort((left, right) => right.time - left.time)
593
595
  // 切点取这个家族倒数第 N 个检查点:比它更早的轮次快照已经没有对照价值,留着只会把「还能还原去哪」说错。
594
596
  // 检查点只有一类,谁先谁后按时间算,不分是开头、分支还是手动标的。
597
+ const crowded = new Set()
598
+ for (const family of familyPoints.keys()) {
599
+ if (familyPoints.get(family).length >= kept) crowded.add(family)
600
+ }
595
601
  const keep = new Set()
596
602
  const perLine = new Map()
597
603
  for (const entry of entries) {
598
- const list = familyPoints.get(entry.familyRoot || entry.sessionId)
599
- if (list !== undefined && list.length >= kept && entry.time >= list[kept - 1].time) keep.add(entry)
604
+ const family = entry.familyRoot || entry.sessionId
605
+ if (crowded.has(family)) {
606
+ if (entry.time >= familyPoints.get(family)[kept - 1].time) keep.add(entry)
607
+ continue
608
+ }
600
609
  const line = perLine.get(entry.sessionId)
601
610
  if (line === undefined) perLine.set(entry.sessionId, [entry])
602
611
  else line.push(entry)
603
612
  }
604
- // 点数不够 N 个时退回按轮次裁——只有开头一个点的会话不该只能靠 maxEntries 兜底。
613
+ // 检查点不到 N 个的家族才退回按轮次裁——只有开头一个点的会话不该只能靠 maxEntries 兜底。
614
+ // 点够数的家族只认检查点那条线,按轮次再兜一层就等于把刚裁掉的行原样加回来。
605
615
  for (const line of perLine.values()) {
606
616
  const from = Math.max(0, line.length - this.options.keepRecentTurns)
607
617
  for (let i = from; i < line.length; i += 1) keep.add(line[i])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-file-history",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Per-turn file history for DeepSeek Harness: every conversation turn gets a snapshot, a change card in the chat, and one-click rollback of files, conversation, or both.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -47,7 +47,13 @@
47
47
  },
48
48
  "client": {
49
49
  "platform": "web",
50
- "inject": ["@deepseek-ai/dsh-client-locale", "@deepseek-ai/dsh-client-ui-primitives", "@deepseek-ai/dsh-client-ui-slots", "@deepseek-ai/dsh-client-ui-settings", "@deepseek-ai/dsh-client-ui-conversation"]
50
+ "inject": [
51
+ "@deepseek-ai/dsh-client-locale",
52
+ "@deepseek-ai/dsh-client-ui-primitives",
53
+ "@deepseek-ai/dsh-client-ui-slots",
54
+ "@deepseek-ai/dsh-client-ui-settings",
55
+ "@deepseek-ai/dsh-client-ui-conversation"
56
+ ]
51
57
  }
52
58
  }
53
59
  }