dsh-sweeper 1.5.8 → 1.5.10
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 +2 -0
- package/lib/client.js +4 -2
- package/lib/deep.js +27 -8
- package/lib/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -273,6 +273,8 @@ node test/browser/check.mjs # 需要本机有 Chrome/Edge,或 CHROME=<p
|
|
|
273
273
|
|
|
274
274
|
## 边界与自保
|
|
275
275
|
|
|
276
|
+
- **看不到的路径会被点名**:权限不足或文件被占用的路径不能判断,会写成「另有 N 个路径读不到」,不会悄悄少列。
|
|
277
|
+
- **没列出来的对话会说明**:每轮最多分析 24 段,超出的段数会写成「另有 N 段没有列出」,而不是装作全都看过。
|
|
276
278
|
- **读不下去的日志会被点名**:会话日志读到一半失败时会计入「N 段日志读不出来」,而不是悄悄从计划里消失。
|
|
277
279
|
- **失败不会藏在别的页签里**:扫描失败时,四个页签都会看到同一张错误卡与「重试扫描」,不会再出现「等待扫描」却永远等不到的情况。
|
|
278
280
|
- **读不到运行中的对话就不出报告**:列不出「哪些对话正在跑」时扫描直接失败并说明原因,宁可这次不扫,也不把还在用的文件列成候选。
|
package/lib/client.js
CHANGED
|
@@ -851,6 +851,7 @@ window.__ModuleLoader__.load({
|
|
|
851
851
|
hint: (plan.skipped
|
|
852
852
|
? '超过 ' + plan.week + ' 天未使用的 ' + plan.skipped + ' 段对话里没有留下临时产物,所以不用花 token 去问模型。'
|
|
853
853
|
: '超过 ' + plan.week + ' 天未使用、且仍然留有临时产物的对话才会出现在这里。')
|
|
854
|
+
+ (plan.more ? ' 另有 ' + plan.more + ' 段符合条件的对话没有列出(每轮有上限),下一轮「重新估算」会轮到它们。' : '')
|
|
854
855
|
+ ' 可以点「重新估算」再读一次磁盘。',
|
|
855
856
|
}) : null,
|
|
856
857
|
|
|
@@ -858,7 +859,7 @@ window.__ModuleLoader__.load({
|
|
|
858
859
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, padding: '11px 14px', background: T.layer, borderBottom: '1px solid ' + T.border } },
|
|
859
860
|
h('div', { style: { fontSize: 13, fontWeight: 600 } }, job && job.state !== 'running' ? '本次分析' : '待分析对话'),
|
|
860
861
|
h('span', { className: 'sw-num', style: { fontSize: 11, color: T.faint } },
|
|
861
|
-
totalN + ' 段 · ' + (job ? '本次约 ' : '预计约 ') + fmtNum(estimate) + ' tokens' + (plan && plan.skipped ? ' · ' + plan.skipped + ' 段无临时产物已跳过' : '') + (plan && plan.unreadable ? ' · ' + plan.unreadable + ' 段日志读不出来' : '')),
|
|
862
|
+
totalN + ' 段 · ' + (job ? '本次约 ' : '预计约 ') + fmtNum(estimate) + ' tokens' + (plan && plan.skipped ? ' · ' + plan.skipped + ' 段无临时产物已跳过' : '') + (plan && plan.unreadable ? ' · ' + plan.unreadable + ' 段日志读不出来' : '') + (plan && plan.more ? ' · 另有 ' + plan.more + ' 段没有列出(每次最多分析 ' + plan.sessions.length + ' 段)' : '') + (plan && plan.deniedFiles ? ' · ' + plan.deniedFiles + ' 个路径读不到' : '')),
|
|
862
863
|
h('div', { style: { flex: 1 } }),
|
|
863
864
|
running ? h('span', { style: { fontSize: 11.5, color: T.accent } }, finished + ' / ' + totalN) : null,
|
|
864
865
|
),
|
|
@@ -875,7 +876,8 @@ window.__ModuleLoader__.load({
|
|
|
875
876
|
+ (s.candidates ? fmtNum(s.candidates) + ' 个文件' : (s.tools ? '清单为空,模型会自己查看' : '0 个文件'))
|
|
876
877
|
+ (s.tools && s.candidates ? ' · 模型可用工具查看' : '')
|
|
877
878
|
+ (s.truncated ? ' · 日志过长,只读了前面一部分' : '')
|
|
878
|
-
+ (s.hidden ? '(另有 ' + fmtNum(s.hidden) + ' 个没发送给模型)' : '')
|
|
879
|
+
+ (s.hidden ? '(另有 ' + fmtNum(s.hidden) + ' 个没发送给模型)' : '')
|
|
880
|
+
+ (s.denied ? '(另有 ' + fmtNum(s.denied) + ' 个路径读不到,没有检查)' : '')),
|
|
879
881
|
),
|
|
880
882
|
s.error ? h('div', { title: s.error, style: { fontSize: 10.5, color: T.danger, maxWidth: 220, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, s.error) : null,
|
|
881
883
|
s.status === 'done' ? h('span', { className: 'sw-num', style: { fontSize: 11, color: T.faint } }, (s.ms ? (s.ms / 1000).toFixed(1) + 's' : '') + (s.calls ? ' · 工具 ' + s.calls + ' 次' : '') + (s.found ? ' · ' + s.found + ' 项' : '') + (s.cutShort ? ' · 到工具上限,结论可能不全' : '')) : null,
|
package/lib/deep.js
CHANGED
|
@@ -254,10 +254,12 @@ function blockedRoots() {
|
|
|
254
254
|
* trash already holds, or anything we cannot stat is left out entirely — the
|
|
255
255
|
* model never sees it, so it can never vote for it.
|
|
256
256
|
*/
|
|
257
|
-
export function candidatesOf(info, ctx = {}) {
|
|
257
|
+
export function candidatesOf(info, ctx = {}, opts = {}) {
|
|
258
258
|
const seen = new Set()
|
|
259
|
+
const denied = new Set()
|
|
259
260
|
const out = []
|
|
260
261
|
const roots = blockedRoots()
|
|
262
|
+
const stat = opts.stat || statSync
|
|
261
263
|
void ctx
|
|
262
264
|
|
|
263
265
|
const push = (raw, kind, tool, time) => {
|
|
@@ -272,7 +274,16 @@ export function candidatesOf(info, ctx = {}) {
|
|
|
272
274
|
// and the page should show the real casing (Linux/macOS are case sensitive).
|
|
273
275
|
const shown = String(raw || '').replace(/\//g, WIN ? '\\' : '/')
|
|
274
276
|
let st
|
|
275
|
-
try { st =
|
|
277
|
+
try { st = stat(shown) } catch {
|
|
278
|
+
try { st = stat(key) } catch (err) {
|
|
279
|
+
// Gone is fine: the file was deleted after the log was written. A path the
|
|
280
|
+
// file system refuses to look at is not: it stays on disk, this pass cannot
|
|
281
|
+
// judge it, and the page should say so instead of showing a shorter list.
|
|
282
|
+
const code = err && err.code
|
|
283
|
+
if (code === 'EACCES' || code === 'EPERM') denied.add(key)
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
}
|
|
276
287
|
if (!st.isFile()) return
|
|
277
288
|
if (st.size > 50 * 1024 * 1024) return
|
|
278
289
|
out.push({ key, path: shown, kind, tool, time, size: st.size, mtime: st.mtimeMs })
|
|
@@ -285,6 +296,7 @@ export function candidatesOf(info, ctx = {}) {
|
|
|
285
296
|
// "40 of 63 sent" instead of quietly reviewing the first 40 and looking
|
|
286
297
|
// complete. Non-enumerable: the array is serialised into job rows as-is.
|
|
287
298
|
Object.defineProperty(capped, 'hidden', { value: out.length - capped.length, enumerable: false })
|
|
299
|
+
Object.defineProperty(capped, 'denied', { value: denied.size, enumerable: false })
|
|
288
300
|
return capped
|
|
289
301
|
}
|
|
290
302
|
|
|
@@ -477,7 +489,6 @@ export async function planDeep(ctx, opts = {}) {
|
|
|
477
489
|
const sessions = []
|
|
478
490
|
let skipped = 0
|
|
479
491
|
let unreadable = 0
|
|
480
|
-
let totalEstTokens = 0
|
|
481
492
|
for (const snap of list) {
|
|
482
493
|
const id = idOf(snap)
|
|
483
494
|
if (!id || liveIds.has(String(id))) continue
|
|
@@ -489,7 +500,7 @@ export async function planDeep(ctx, opts = {}) {
|
|
|
489
500
|
if (!info.cwd) info.cwd = workspaces.get(String(id)) || ''
|
|
490
501
|
const lastUsed = info.lastTime || info.createdAt
|
|
491
502
|
if (!lastUsed || lastUsed > cutoff) continue
|
|
492
|
-
const candidates = candidatesOf(info, ctx)
|
|
503
|
+
const candidates = candidatesOf(info, ctx, opts)
|
|
493
504
|
// With tools the model can look for artifacts the digest never listed, so a
|
|
494
505
|
// conversation with zero candidates is still worth a pass — that is exactly
|
|
495
506
|
// the case the one-prompt version mistook for "nothing to clean".
|
|
@@ -497,7 +508,6 @@ export async function planDeep(ctx, opts = {}) {
|
|
|
497
508
|
if (!candidates.length && !canLook) { skipped += 1; continue }
|
|
498
509
|
const digest = buildDigest(info, candidates, now, { canLook })
|
|
499
510
|
const estTokens = estimateTokens(digest) + (canLook ? 900 : 0)
|
|
500
|
-
totalEstTokens += estTokens
|
|
501
511
|
sessions.push({
|
|
502
512
|
id, title: info.title || baseOf(info.cwd || '') || id,
|
|
503
513
|
cwd: info.cwd, createdAt: info.createdAt, lastUsedAt: lastUsed,
|
|
@@ -505,15 +515,24 @@ export async function planDeep(ctx, opts = {}) {
|
|
|
505
515
|
toolCalls: info.toolCalls,
|
|
506
516
|
candidates: candidates.length,
|
|
507
517
|
hidden: candidates.hidden || 0,
|
|
518
|
+
denied: candidates.denied || 0,
|
|
508
519
|
truncated: !!info.truncated,
|
|
509
520
|
estTokens,
|
|
510
521
|
_info: info,
|
|
511
522
|
_candidates: candidates,
|
|
512
523
|
})
|
|
513
|
-
if (sessions.length >= (opts.limit || MAX_SESSIONS)) break
|
|
514
524
|
}
|
|
515
|
-
|
|
516
|
-
|
|
525
|
+
// Rank before capping, and say how many were left out. Breaking out of the loop
|
|
526
|
+
// at the limit used to keep whatever the log listing happened to return first,
|
|
527
|
+
// and the page had no way to tell 24 of 24 from 24 of 40.
|
|
528
|
+
sessions.sort((a, b) => b.candidates - a.candidates || b.hidden - a.hidden || b.ageDays - a.ageDays)
|
|
529
|
+
const limit = opts.limit || MAX_SESSIONS
|
|
530
|
+
const more = Math.max(0, sessions.length - limit)
|
|
531
|
+
const kept = sessions.slice(0, limit)
|
|
532
|
+
// Estimate only what will actually be sent: rows the cap dropped cost nothing.
|
|
533
|
+
const totalEstTokens = kept.reduce((n, s) => n + s.estTokens, 0)
|
|
534
|
+
const deniedFiles = kept.reduce((n, s) => n + (s.denied || 0), 0)
|
|
535
|
+
return { sessions: kept, more, deniedFiles, totalEstTokens, concurrency: CONCURRENCY, week, skipped, unreadable }
|
|
517
536
|
}
|
|
518
537
|
|
|
519
538
|
/**
|
package/lib/index.js
CHANGED
|
@@ -197,10 +197,12 @@ export function apply(ctx, config = {}) {
|
|
|
197
197
|
concurrency: plan.concurrency,
|
|
198
198
|
totalEstTokens: plan.totalEstTokens,
|
|
199
199
|
skipped: plan.skipped || 0,
|
|
200
|
+
more: plan.more || 0,
|
|
201
|
+
deniedFiles: plan.deniedFiles || 0,
|
|
200
202
|
unreadable: plan.unreadable || 0,
|
|
201
203
|
sessions: plan.sessions.map((s) => ({
|
|
202
204
|
id: s.id, title: s.title, cwd: s.cwd, ageDays: s.ageDays, toolCalls: s.toolCalls,
|
|
203
|
-
candidates: s.candidates, hidden: s.hidden || 0, estTokens: s.estTokens,
|
|
205
|
+
candidates: s.candidates, hidden: s.hidden || 0, denied: s.denied || 0, estTokens: s.estTokens,
|
|
204
206
|
truncated: !!s.truncated, tools: !!s.cwd,
|
|
205
207
|
})),
|
|
206
208
|
})
|