dsh-sweeper 1.5.11 → 1.5.13
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 +5 -0
- package/lib/client.js +26 -2
- package/lib/fs-tools.js +26 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
清理对话留下的临时文件、缓存与垃圾,释放磁盘空间(常被叫作「清理内存」,实际清理的是磁盘上的文件,不动进程内存)。
|
|
7
7
|
静态扫描历史会话里的工具产物,分两档展示;你自己勾选,点「清理选中」批量移到插件回收站,可随时恢复。
|
|
8
8
|
|
|
9
|
+
## 反馈
|
|
10
|
+
|
|
11
|
+
设置页右上角有「★ 点个 star」,页面底部有「反馈问题或建议」,都会跳到 GitHub。装完之后遇到任何不对的地方,直接开 issue 就行——比起下载数,我更想知道它在哪里判断错了。
|
|
12
|
+
|
|
9
13
|
## 截图
|
|
10
14
|
|
|
11
15
|
三张都是真实数据(46 个会话、16,400 次工具调用,模型 `deepseek-v4.1-flash` 的真实回答),不是设计稿。
|
|
@@ -274,6 +278,7 @@ node test/browser/check.mjs # 需要本机有 Chrome/Edge,或 CHROME=<p
|
|
|
274
278
|
## 边界与自保
|
|
275
279
|
|
|
276
280
|
- **工具的遍历上限会说出来**:模型自己找文件时走到 400 个条目上限会收到一句「只看了前 400 个」,不会把「没扫完」当成「没有」。
|
|
281
|
+
- **不敢跟的链接、读不到的条目会被数出来**:`list_dir` / `find_files` 遇到符号链接(可能指向工作目录之外)和权限不足的条目时不再静默跳过,而是写「N 个链接未跟随」「N 个条目读不出来」,免得少列几行就被当成「这里就这些」。
|
|
277
282
|
- **看不到的路径会被点名**:权限不足或文件被占用的路径不能判断,会写成「另有 N 个路径读不到」,不会悄悄少列。
|
|
278
283
|
- **没列出来的对话会说明**:每轮最多分析 24 段,超出的段数会写成「另有 N 段没有列出」,而不是装作全都看过。
|
|
279
284
|
- **读不下去的日志会被点名**:会话日志读到一半失败时会计入「N 段日志读不出来」,而不是悄悄从计划里消失。
|
package/lib/client.js
CHANGED
|
@@ -6,7 +6,10 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
const { useState, useEffect, useMemo, useRef, useCallback } = React
|
|
7
7
|
|
|
8
8
|
const API = '/plugins/dsh-sweeper'
|
|
9
|
-
const
|
|
9
|
+
const REPO_URL = 'https://github.com/Dushiqi1987/dsh-sweeper'
|
|
10
|
+
const ISSUE_URL = 'https://github.com/Dushiqi1987/dsh-sweeper/issues/new'
|
|
11
|
+
|
|
12
|
+
const STYLE_ID = 'dsh-sweeper-style'
|
|
10
13
|
|
|
11
14
|
// ── theme ───────────────────────────────────────────────────────────────
|
|
12
15
|
// Everything is expressed with host tokens so light/dark both work; the
|
|
@@ -1490,7 +1493,7 @@ window.__ModuleLoader__.load({
|
|
|
1490
1493
|
|
|
1491
1494
|
return h('div', { className: 'sw-root', style: { padding: '16px 18px 96px', maxWidth: 1000 } },
|
|
1492
1495
|
// header
|
|
1493
|
-
h('div', { style: { display: 'flex', alignItems: 'center', gap:
|
|
1496
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
|
|
1494
1497
|
h('div', {
|
|
1495
1498
|
style: {
|
|
1496
1499
|
width: 40, height: 40, borderRadius: 12, display: 'grid', placeItems: 'center', flex: 'none',
|
|
@@ -1510,6 +1513,15 @@ window.__ModuleLoader__.load({
|
|
|
1510
1513
|
disabled: scanning,
|
|
1511
1514
|
}),
|
|
1512
1515
|
report ? h(Btn, { label: '导出', icon: h(Icon, { name: 'download', size: 14 }), onClick: exportJSON, disabled: scanning }) : null,
|
|
1516
|
+
h('a', {
|
|
1517
|
+
href: REPO_URL, target: '_blank', rel: 'noreferrer noopener',
|
|
1518
|
+
title: '到 GitHub 给这个插件点个 star',
|
|
1519
|
+
style: {
|
|
1520
|
+
display: 'inline-flex', alignItems: 'center', gap: 6, height: 30, padding: '0 11px',
|
|
1521
|
+
borderRadius: 8, border: '1px solid ' + T.border, color: T.text, textDecoration: 'none',
|
|
1522
|
+
fontSize: 12.5, whiteSpace: 'nowrap',
|
|
1523
|
+
},
|
|
1524
|
+
}, h('span', { style: { color: T.warn } }, '★'), '点个 star'),
|
|
1513
1525
|
),
|
|
1514
1526
|
|
|
1515
1527
|
// stats
|
|
@@ -1619,6 +1631,18 @@ window.__ModuleLoader__.load({
|
|
|
1619
1631
|
onRefresh: loadTrash,
|
|
1620
1632
|
}) : null,
|
|
1621
1633
|
|
|
1634
|
+
h('div', {
|
|
1635
|
+
style: {
|
|
1636
|
+
display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap',
|
|
1637
|
+
marginTop: 18, fontSize: 11.5, color: T.faint,
|
|
1638
|
+
},
|
|
1639
|
+
},
|
|
1640
|
+
h('span', null, '如果它帮你省了一点清理的时间,'),
|
|
1641
|
+
h('a', { href: REPO_URL, target: '_blank', rel: 'noreferrer noopener', style: { color: T.accent, textDecoration: 'none' } }, '给作者点个 star 支持一下'),
|
|
1642
|
+
h('span', { style: { opacity: .5 } }, '·'),
|
|
1643
|
+
h('a', { href: ISSUE_URL, target: '_blank', rel: 'noreferrer noopener', style: { color: T.accent, textDecoration: 'none' } }, '反馈问题或建议'),
|
|
1644
|
+
),
|
|
1645
|
+
|
|
1622
1646
|
// selection bar
|
|
1623
1647
|
tab === 'report' && chosen.length ? h('div', {
|
|
1624
1648
|
style: {
|
package/lib/fs-tools.js
CHANGED
|
@@ -37,6 +37,9 @@ function day(ms) {
|
|
|
37
37
|
export function makeFsTools(opts) {
|
|
38
38
|
const roots = (opts.roots || []).filter((root) => typeof root === 'string' && root.length > 0).map((root) => normKey(root))
|
|
39
39
|
const deny = (opts.deny || []).filter((root) => typeof root === 'string' && root.length > 0).map((root) => normKey(root))
|
|
40
|
+
// Tests inject a stat that fails, so the "could not read this entry" path is
|
|
41
|
+
// exercised on a machine where every file happens to be readable.
|
|
42
|
+
const lstatOf = typeof opts.lstat === 'function' ? opts.lstat : fs.lstatSync
|
|
40
43
|
|
|
41
44
|
/** Resolve and authorise one path, or explain why not. */
|
|
42
45
|
function allow(raw) {
|
|
@@ -77,17 +80,25 @@ export function makeFsTools(opts) {
|
|
|
77
80
|
if (!st.isDirectory()) throw new Error('not a directory: ' + input.path)
|
|
78
81
|
const limit = Math.max(1, Math.min(MAX_ENTRIES, Number(input.limit) || MAX_ENTRIES))
|
|
79
82
|
const rows = []
|
|
83
|
+
let links = 0
|
|
84
|
+
let unreadable = 0
|
|
80
85
|
for (const name of fs.readdirSync(ok.real)) {
|
|
81
86
|
let item
|
|
82
|
-
try { item =
|
|
83
|
-
if (item.isSymbolicLink()) continue
|
|
87
|
+
try { item = lstatOf(path.join(ok.real, name)) } catch { unreadable += 1; continue }
|
|
88
|
+
if (item.isSymbolicLink()) { links += 1; continue }
|
|
84
89
|
rows.push({ name, size: item.isDirectory() ? -1 : item.size, dir: item.isDirectory(), mtime: item.mtimeMs })
|
|
85
90
|
}
|
|
86
91
|
rows.sort((a, b) => (b.size - a.size) || a.name.localeCompare(b.name))
|
|
87
92
|
const total = rows.length
|
|
88
93
|
const shown = rows.slice(0, limit)
|
|
89
94
|
const lines = shown.map((row) => (row.dir ? ' dir ' : human(row.size).padStart(9)) + ' ' + day(row.mtime) + ' ' + row.name)
|
|
90
|
-
|
|
95
|
+
// Skipping is fine; skipping silently is not. A listing that hides entries
|
|
96
|
+
// reads as "that is everything in here".
|
|
97
|
+
const notes = []
|
|
98
|
+
if (total > shown.length) notes.push('… ' + (total - shown.length) + ' more entries not shown')
|
|
99
|
+
if (links) notes.push('… ' + links + ' symbolic link' + (links === 1 ? '' : 's') + ' not followed')
|
|
100
|
+
if (unreadable) notes.push('… ' + unreadable + ' entr' + (unreadable === 1 ? 'y' : 'ies') + ' could not be read')
|
|
101
|
+
return ok.real + '\n' + lines.join('\n') + (notes.length ? '\n' + notes.join('\n') : '')
|
|
91
102
|
},
|
|
92
103
|
}
|
|
93
104
|
|
|
@@ -144,18 +155,20 @@ export function makeFsTools(opts) {
|
|
|
144
155
|
const found = []
|
|
145
156
|
let walked = 0
|
|
146
157
|
let capped = false
|
|
158
|
+
let links = 0
|
|
159
|
+
let unreadable = 0
|
|
147
160
|
const walk = (dir, level) => {
|
|
148
161
|
if (level > depth) return
|
|
149
162
|
if (walked > MAX_WALK) { capped = true; return }
|
|
150
163
|
let names
|
|
151
|
-
try { names = fs.readdirSync(dir) } catch { return }
|
|
164
|
+
try { names = fs.readdirSync(dir) } catch { unreadable += 1; return }
|
|
152
165
|
for (const name of names) {
|
|
153
166
|
walked += 1
|
|
154
167
|
if (walked > MAX_WALK) { capped = true; return }
|
|
155
168
|
const full = path.join(dir, name)
|
|
156
169
|
let st
|
|
157
|
-
try { st =
|
|
158
|
-
if (st.isSymbolicLink()) continue
|
|
170
|
+
try { st = lstatOf(full) } catch { unreadable += 1; continue }
|
|
171
|
+
if (st.isSymbolicLink()) { links += 1; continue }
|
|
159
172
|
if (st.isDirectory()) {
|
|
160
173
|
if (SKIP.has(name.toLowerCase())) continue
|
|
161
174
|
walk(full, level + 1)
|
|
@@ -175,12 +188,17 @@ export function makeFsTools(opts) {
|
|
|
175
188
|
const cappedNote = capped
|
|
176
189
|
? '\n… walked only the first ' + MAX_WALK + ' entries (cap); narrow the path or lower depth to see the rest'
|
|
177
190
|
: ''
|
|
191
|
+
const skippedNote = [
|
|
192
|
+
links ? '… ' + links + ' symbolic link' + (links === 1 ? '' : 's') + ' not followed' : '',
|
|
193
|
+
unreadable ? '… ' + unreadable + ' entr' + (unreadable === 1 ? 'y' : 'ies') + ' could not be read' : '',
|
|
194
|
+
].filter(Boolean).join('\n')
|
|
195
|
+
const extra = cappedNote + (skippedNote ? '\n' + skippedNote : '')
|
|
178
196
|
if (shown.length === 0) {
|
|
179
|
-
return ok.real + '\n' + (capped ? 'capped before any match' : 'no file matched') +
|
|
197
|
+
return ok.real + '\n' + (capped ? 'capped before any match' : 'no file matched') + extra
|
|
180
198
|
}
|
|
181
199
|
return ok.real + '\n' + shown.map((row) => human(row.size).padStart(9) + ' ' + day(row.mtime) + ' ' + row.full).join('\n')
|
|
182
200
|
+ (found.length > shown.length ? '\n… ' + (found.length - shown.length) + ' more matches not shown' : '')
|
|
183
|
-
+
|
|
201
|
+
+ extra
|
|
184
202
|
},
|
|
185
203
|
}
|
|
186
204
|
|