dsh-session-matrix 0.17.0 → 0.17.1

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/lib/client.js CHANGED
@@ -2641,17 +2641,18 @@ window.__ModuleLoader__.load({
2641
2641
  h('p', { className: 'aw-hsec', key: 'w1' }, T.whyTitle),
2642
2642
  h('div', { className: 'aw-hp', key: 'w2' }, [
2643
2643
  h('div', { key: 'a' },
2644
- '占用率只回答「离压缩点还有多远」;是否值得交接,看的是压缩次数。'
2645
- + '每压缩一次,早期对话就被换成一层摘要,路径、命令、报错最先丢——损失是叠加的。'),
2644
+ 'Agent 干活的时候,上下文会被不断压缩:早期对话换成摘要,路径、命令、报错最先丢。'
2645
+ + '压缩了多少次,面板已经帮你数出来了——就是卡片上的「已压缩 N 次」。'),
2646
2646
  h('div', { key: 'b' },
2647
- '占用率达到临界线,说的是「该收尾当前这一步了」。但一个从未压缩过的新会话第一次到达临界,'
2648
- + '历史是完整的,会话仍然好用——面板只会标「首次接近」,不会推交接。'),
2647
+ '我们调研了 Claude Code 社区的经验:同一个会话压缩到第 2 次,'
2648
+ + '就说明任务已经超过一个会话该装的量;压到 3 次以上,模型开始忘掉早期的要求和约束,'
2649
+ + '硬撑下去会越做越差,甚至反复返工。'),
2649
2650
  h('div', { key: 'c' },
2650
- '已压缩 2 次再达临界,说明任务范围已经超过一个会话该装的量,建议交接;'
2651
- + '压缩 ≥3 次的会话,一过注意线就升级提醒。刚压缩完 10 分钟内摘要最新鲜,提示会自动降半级。'),
2651
+ '所以面板的提示是两条线一起看的:占用率到临界线 = 该收尾当前这一步;'
2652
+ + '压缩过 2 次以上再到临界 = 该交接了,开个新会话接着干。'),
2652
2653
  h('div', { key: 'd' },
2653
- '压缩点本身照搬官方规则:窗口 − 最大输出 − 4K 余量(与 dsh-compaction-basic 一致)。'
2654
- + '1,048,576 的窗口配 256,000 的输出预留,压缩点是 788,480(75.2%)。'),
2654
+ '从没压缩过的新会话第一次到临界线不用慌——历史还完整,继续干活就行。'
2655
+ + '刚压缩完 10 分钟内摘要最新鲜,提示也会自动放宽。'),
2655
2656
  ]),
2656
2657
  // The three lines the panel paints, computed for the session that is
2657
2658
  // about to receive the prompt — a different model means different
package/lib/index.js CHANGED
@@ -218,16 +218,29 @@ function compactPointOf(window, output) {
218
218
  const COMPACTION_FRESH_MS = 10 * 60_000
219
219
 
220
220
  export function countCheckpoints(events) {
221
- let compactions = 0
221
+ let fullCompactions = 0
222
+ let pruneCompactions = 0
222
223
  let lastCompactionAt = null
223
224
  for (const event of events) {
224
- if (event?.type !== 'user/message') continue
225
- if (event.data?.source?.kind !== 'compact-checkpoint') continue
226
- compactions += 1
227
- const time = Number(event.time)
225
+ let kind = null
226
+ let time = Number(event?.time)
227
+ if (event?.type === 'user/message' && event.data?.source?.kind === 'compact-checkpoint') {
228
+ kind = 'full' // full compaction: history rebuilt into a summary
229
+ } else if (event?.type === 'compaction/prune') {
230
+ kind = 'prune' // tool-result pruning: outputs dropped, no checkpoint
231
+ } else {
232
+ continue
233
+ }
234
+ if (kind === 'full') fullCompactions += 1
235
+ else pruneCompactions += 1
228
236
  if (Number.isFinite(time)) lastCompactionAt = Math.max(lastCompactionAt ?? time, time)
229
237
  }
230
- return { compactions, lastCompactionAt }
238
+ return {
239
+ compactions: fullCompactions + pruneCompactions,
240
+ fullCompactions,
241
+ pruneCompactions,
242
+ lastCompactionAt,
243
+ }
231
244
  }
232
245
 
233
246
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-matrix",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "A multi-agent workspace for DeepSeek Harness: run parallel sessions, visualize agent relationships, monitor context usage, and manage task handoffs.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -74,23 +74,35 @@ check('占用低于注意线恒为 ok(新鲜度豁免也不越级)', () => {
74
74
  'low occupancy stays ok even when fresh')
75
75
  })
76
76
 
77
- check('countCheckpoints:从事件流数检查点并取最新时间', () => {
77
+ check('countCheckpoints:全量压缩与剪枝分开计数、总量相加', () => {
78
78
  const events = [
79
79
  { type: 'user/message', time: 100, data: { content: 'hi' } },
80
80
  { type: 'user/message', time: 200, data: { source: { kind: 'compact-checkpoint', compactionId: 'a' } } },
81
81
  { type: 'assistant/message', time: 300, data: { usage: {} } },
82
+ { type: 'compaction/prune', time: 350, data: { shadowedTokenCount: 5000 } },
82
83
  { type: 'user/message', time: 400, data: { source: { kind: 'compact-checkpoint', compactionId: 'b' } } },
84
+ { type: 'compaction/prune', time: 450, data: { shadowedTokenCount: 8000 } },
83
85
  ]
84
- const { compactions, lastCompactionAt } = countCheckpoints(events)
85
- assert(compactions === 2, `expected 2 checkpoints, got ${compactions}`)
86
- assert(lastCompactionAt === 400, `expected last time 400, got ${lastCompactionAt}`)
86
+ const r = countCheckpoints(events)
87
+ assert(r.compactions === 4, `expected total 4, got ${r.compactions}`)
88
+ assert(r.fullCompactions === 2, `expected 2 full, got ${r.fullCompactions}`)
89
+ assert(r.pruneCompactions === 2, `expected 2 prunes, got ${r.pruneCompactions}`)
90
+ assert(r.lastCompactionAt === 450, `expected last time 450, got ${r.lastCompactionAt}`)
87
91
  })
88
- check('countCheckpoints:没有检查点时返回 0 / null', () => {
92
+ check('countCheckpoints:没有压缩动作时返回 0 / null', () => {
89
93
  const { compactions, lastCompactionAt } = countCheckpoints([
90
94
  { type: 'user/message', time: 1, data: {} },
91
95
  ])
92
96
  assert(compactions === 0 && lastCompactionAt === null, 'empty stream must be 0/null')
93
97
  })
98
+ check('countCheckpoints:纯剪枝会话(无全量压缩)也计入', () => {
99
+ const r = countCheckpoints([
100
+ { type: 'compaction/prune', time: 10, data: {} },
101
+ { type: 'compaction/prune', time: 20, data: {} },
102
+ ])
103
+ assert(r.compactions === 2 && r.fullCompactions === 0 && r.pruneCompactions === 2,
104
+ 'prune-only session must count')
105
+ })
94
106
 
95
107
  console.log(`risk-matrix.test.mjs — ${pass.length} passed, ${fail.length} failed`)
96
108
  for (const label of fail) console.log(` ✗ ${label}`)