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 +9 -8
- package/lib/index.js +19 -6
- package/package.json +1 -1
- package/test/risk-matrix.test.mjs +17 -5
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
|
-
'
|
|
2651
|
-
+ '
|
|
2651
|
+
'所以面板的提示是两条线一起看的:占用率到临界线 = 该收尾当前这一步;'
|
|
2652
|
+
+ '压缩过 2 次以上再到临界 = 该交接了,开个新会话接着干。'),
|
|
2652
2653
|
h('div', { key: 'd' },
|
|
2653
|
-
'
|
|
2654
|
-
+ '
|
|
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
|
|
221
|
+
let fullCompactions = 0
|
|
222
|
+
let pruneCompactions = 0
|
|
222
223
|
let lastCompactionAt = null
|
|
223
224
|
for (const event of events) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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 {
|
|
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.
|
|
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
|
|
85
|
-
assert(compactions ===
|
|
86
|
-
assert(
|
|
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
|
|
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}`)
|