dsh-session-matrix 0.17.0 → 0.17.2
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.md +1 -1
- package/lib/client.js +18 -12
- package/lib/index.js +23 -8
- package/package.json +1 -1
- package/test/risk-matrix.test.mjs +17 -5
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ DSH 每次压缩都会在会话里留下一个检查点(`compact-checkpoint`
|
|
|
161
161
|
| V4.1 Flash `deepseek-flash`(旧名 `deepseek-v4-flash`) | 0.02 | 1 | 4 |
|
|
162
162
|
| V4 Pro `deepseek-v4-pro` | 0.15 | 4.5 | 13.5 |
|
|
163
163
|
|
|
164
|
-
峰时(北京时间工作日 09:00–12:00、14:00–18:00
|
|
164
|
+
峰时(北京时间工作日 09:00–12:00、14:00–18:00)**×2**。法定节假日暂未建模,仍按工作日峰时计——见下方 Requirements 说明。
|
|
165
165
|
`contextTimeline.cost` 已按峰谷分桶,直接分桶计算,不做时间推断。
|
|
166
166
|
非 `deepseek` provider 回退 models.dev 美元价,按 `1 CNY = 0.15 USD` 折算。
|
|
167
167
|
|
package/lib/client.js
CHANGED
|
@@ -2046,8 +2046,12 @@ window.__ModuleLoader__.load({
|
|
|
2046
2046
|
const EMPTY_PANES = [null, null, null, null]
|
|
2047
2047
|
|
|
2048
2048
|
function WorkspaceView({
|
|
2049
|
-
sessions, projects, filter, setFilter, panes, setPanes, onOpenNative, railW, onRailW, kit, th, flashId,
|
|
2049
|
+
sessions, allSessions, projects, filter, setFilter, panes, setPanes, onOpenNative, railW, onRailW, kit, th, flashId,
|
|
2050
2050
|
}) {
|
|
2051
|
+
// Pane pruning must judge against EVERY live session, not the filtered
|
|
2052
|
+
// view: pruning on the filtered list would close a pane whenever its
|
|
2053
|
+
// session merely fell outside the current search/scope.
|
|
2054
|
+
const knownSessions = allSessions ?? sessions
|
|
2051
2055
|
const openIds = new Set(panes.filter(Boolean))
|
|
2052
2056
|
const full = panes.length >= MAX_PANES
|
|
2053
2057
|
|
|
@@ -2169,13 +2173,13 @@ window.__ModuleLoader__.load({
|
|
|
2169
2173
|
// forever. Clear those ids once the list has loaded; never prune while
|
|
2170
2174
|
// the list is empty (that is a failed poll, not an empty workspace).
|
|
2171
2175
|
React.useEffect(() => {
|
|
2172
|
-
if (!
|
|
2173
|
-
const known = new Set(
|
|
2176
|
+
if (!knownSessions.length) return
|
|
2177
|
+
const known = new Set(knownSessions.map(s => s.id))
|
|
2174
2178
|
setPanes(prev => {
|
|
2175
2179
|
const next = prev.map(v => (v && !known.has(v) ? null : v))
|
|
2176
2180
|
return next.some((v, i) => v !== prev[i]) ? next : prev
|
|
2177
2181
|
})
|
|
2178
|
-
}, [
|
|
2182
|
+
}, [knownSessions, setPanes])
|
|
2179
2183
|
const expanded = React.useMemo(() => new Set(expandedIds), [expandedIds])
|
|
2180
2184
|
// A subagent opened in a pane must be visible even while collapsed.
|
|
2181
2185
|
const forced = new Set()
|
|
@@ -2641,17 +2645,18 @@ window.__ModuleLoader__.load({
|
|
|
2641
2645
|
h('p', { className: 'aw-hsec', key: 'w1' }, T.whyTitle),
|
|
2642
2646
|
h('div', { className: 'aw-hp', key: 'w2' }, [
|
|
2643
2647
|
h('div', { key: 'a' },
|
|
2644
|
-
'
|
|
2645
|
-
+ '
|
|
2648
|
+
'Agent 干活的时候,上下文会被不断压缩:早期对话换成摘要,路径、命令、报错最先丢。'
|
|
2649
|
+
+ '压缩了多少次,面板已经帮你数出来了——就是卡片上的「已压缩 N 次」。'),
|
|
2646
2650
|
h('div', { key: 'b' },
|
|
2647
|
-
'
|
|
2648
|
-
+ '
|
|
2651
|
+
'我们调研了 Claude Code 社区的经验:同一个会话压缩到第 2 次,'
|
|
2652
|
+
+ '就说明任务已经超过一个会话该装的量;压到 3 次以上,模型开始忘掉早期的要求和约束,'
|
|
2653
|
+
+ '硬撑下去会越做越差,甚至反复返工。'),
|
|
2649
2654
|
h('div', { key: 'c' },
|
|
2650
|
-
'
|
|
2651
|
-
+ '
|
|
2655
|
+
'所以面板的提示是两条线一起看的:占用率到临界线 = 该收尾当前这一步;'
|
|
2656
|
+
+ '压缩过 2 次以上再到临界 = 该交接了,开个新会话接着干。'),
|
|
2652
2657
|
h('div', { key: 'd' },
|
|
2653
|
-
'
|
|
2654
|
-
+ '
|
|
2658
|
+
'从没压缩过的新会话第一次到临界线不用慌——历史还完整,继续干活就行。'
|
|
2659
|
+
+ '刚压缩完 10 分钟内摘要最新鲜,提示也会自动放宽。'),
|
|
2655
2660
|
]),
|
|
2656
2661
|
// The three lines the panel paints, computed for the session that is
|
|
2657
2662
|
// about to receive the prompt — a different model means different
|
|
@@ -3262,6 +3267,7 @@ window.__ModuleLoader__.load({
|
|
|
3262
3267
|
? h(WorkspaceView, {
|
|
3263
3268
|
key: 'ws',
|
|
3264
3269
|
sessions: filtered,
|
|
3270
|
+
allSessions,
|
|
3265
3271
|
projects,
|
|
3266
3272
|
filter,
|
|
3267
3273
|
setFilter,
|
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
|
/**
|
|
@@ -269,8 +282,10 @@ export function riskLevel(ratio, point, cfg, stats) {
|
|
|
269
282
|
if (firstApproach) level = 'warn'
|
|
270
283
|
else if (typeof count === 'number' && count >= 3 && level === 'warn') level = 'crit'
|
|
271
284
|
|
|
272
|
-
|
|
273
|
-
|
|
285
|
+
// A timestamp in the future (clock skew between machines) must not keep the
|
|
286
|
+
// freshness exemption alive until the clock catches up.
|
|
287
|
+
const sinceLast = stats?.lastCompactionAt != null ? Date.now() - stats.lastCompactionAt : null
|
|
288
|
+
const fresh = sinceLast != null && sinceLast >= 0 && sinceLast < COMPACTION_FRESH_MS
|
|
274
289
|
if (fresh) level = level === 'crit' ? 'warn' : level === 'warn' ? 'ok' : level
|
|
275
290
|
return level
|
|
276
291
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-matrix",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
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}`)
|