dsh-sweeper 1.5.9 → 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 CHANGED
@@ -273,6 +273,7 @@ node test/browser/check.mjs # 需要本机有 Chrome/Edge,或 CHROME=<p
273
273
 
274
274
  ## 边界与自保
275
275
 
276
+ - **看不到的路径会被点名**:权限不足或文件被占用的路径不能判断,会写成「另有 N 个路径读不到」,不会悄悄少列。
276
277
  - **没列出来的对话会说明**:每轮最多分析 24 段,超出的段数会写成「另有 N 段没有列出」,而不是装作全都看过。
277
278
  - **读不下去的日志会被点名**:会话日志读到一半失败时会计入「N 段日志读不出来」,而不是悄悄从计划里消失。
278
279
  - **失败不会藏在别的页签里**:扫描失败时,四个页签都会看到同一张错误卡与「重试扫描」,不会再出现「等待扫描」却永远等不到的情况。
package/lib/client.js CHANGED
@@ -859,7 +859,7 @@ window.__ModuleLoader__.load({
859
859
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, padding: '11px 14px', background: T.layer, borderBottom: '1px solid ' + T.border } },
860
860
  h('div', { style: { fontSize: 13, fontWeight: 600 } }, job && job.state !== 'running' ? '本次分析' : '待分析对话'),
861
861
  h('span', { className: 'sw-num', style: { fontSize: 11, color: T.faint } },
862
- totalN + ' 段 · ' + (job ? '本次约 ' : '预计约 ') + fmtNum(estimate) + ' tokens' + (plan && plan.skipped ? ' · ' + plan.skipped + ' 段无临时产物已跳过' : '') + (plan && plan.unreadable ? ' · ' + plan.unreadable + ' 段日志读不出来' : '') + (plan && plan.more ? ' · 另有 ' + plan.more + ' 段没有列出(每次最多分析 ' + plan.sessions.length + ' 段)' : '')),
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 + ' 个路径读不到' : '')),
863
863
  h('div', { style: { flex: 1 } }),
864
864
  running ? h('span', { style: { fontSize: 11.5, color: T.accent } }, finished + ' / ' + totalN) : null,
865
865
  ),
@@ -876,7 +876,8 @@ window.__ModuleLoader__.load({
876
876
  + (s.candidates ? fmtNum(s.candidates) + ' 个文件' : (s.tools ? '清单为空,模型会自己查看' : '0 个文件'))
877
877
  + (s.tools && s.candidates ? ' · 模型可用工具查看' : '')
878
878
  + (s.truncated ? ' · 日志过长,只读了前面一部分' : '')
879
- + (s.hidden ? '(另有 ' + fmtNum(s.hidden) + ' 个没发送给模型)' : '')),
879
+ + (s.hidden ? '(另有 ' + fmtNum(s.hidden) + ' 个没发送给模型)' : '')
880
+ + (s.denied ? '(另有 ' + fmtNum(s.denied) + ' 个路径读不到,没有检查)' : '')),
880
881
  ),
881
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,
882
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 = statSync(shown) } catch { try { st = statSync(key) } catch { return } }
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
 
@@ -488,7 +500,7 @@ export async function planDeep(ctx, opts = {}) {
488
500
  if (!info.cwd) info.cwd = workspaces.get(String(id)) || ''
489
501
  const lastUsed = info.lastTime || info.createdAt
490
502
  if (!lastUsed || lastUsed > cutoff) continue
491
- const candidates = candidatesOf(info, ctx)
503
+ const candidates = candidatesOf(info, ctx, opts)
492
504
  // With tools the model can look for artifacts the digest never listed, so a
493
505
  // conversation with zero candidates is still worth a pass — that is exactly
494
506
  // the case the one-prompt version mistook for "nothing to clean".
@@ -503,6 +515,7 @@ export async function planDeep(ctx, opts = {}) {
503
515
  toolCalls: info.toolCalls,
504
516
  candidates: candidates.length,
505
517
  hidden: candidates.hidden || 0,
518
+ denied: candidates.denied || 0,
506
519
  truncated: !!info.truncated,
507
520
  estTokens,
508
521
  _info: info,
@@ -518,7 +531,8 @@ export async function planDeep(ctx, opts = {}) {
518
531
  const kept = sessions.slice(0, limit)
519
532
  // Estimate only what will actually be sent: rows the cap dropped cost nothing.
520
533
  const totalEstTokens = kept.reduce((n, s) => n + s.estTokens, 0)
521
- return { sessions: kept, more, totalEstTokens, concurrency: CONCURRENCY, week, skipped, unreadable }
534
+ const deniedFiles = kept.reduce((n, s) => n + (s.denied || 0), 0)
535
+ return { sessions: kept, more, deniedFiles, totalEstTokens, concurrency: CONCURRENCY, week, skipped, unreadable }
522
536
  }
523
537
 
524
538
  /**
package/lib/index.js CHANGED
@@ -198,10 +198,11 @@ export function apply(ctx, config = {}) {
198
198
  totalEstTokens: plan.totalEstTokens,
199
199
  skipped: plan.skipped || 0,
200
200
  more: plan.more || 0,
201
+ deniedFiles: plan.deniedFiles || 0,
201
202
  unreadable: plan.unreadable || 0,
202
203
  sessions: plan.sessions.map((s) => ({
203
204
  id: s.id, title: s.title, cwd: s.cwd, ageDays: s.ageDays, toolCalls: s.toolCalls,
204
- 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,
205
206
  truncated: !!s.truncated, tools: !!s.cwd,
206
207
  })),
207
208
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sweeper",
3
- "version": "1.5.9",
3
+ "version": "1.5.10",
4
4
  "type": "module",
5
5
  "description": "清理对话留下的临时文件与垃圾,释放磁盘空间;只报告,清理进回收站可恢复 (cleanup junk files conversations leave on disk, free up space)",
6
6
  "keywords": [