devclean-cache 0.0.0-stage → 0.5.0

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/dist/cli.js ADDED
@@ -0,0 +1,447 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+ import readline from "node:readline/promises";
5
+ import { writeFile } from "node:fs/promises";
6
+ import { renderHtmlReport } from "./report-html.js";
7
+ import { selectItems } from "./tui.js";
8
+ import { scanAll, totalOf } from "./scan.js";
9
+ import { dirSize, findProjectArtifacts, pathExists } from "./util/fs.js";
10
+ import { createPalette, renderTable, renderSummary, renderJson, removeFooter } from "./report.js";
11
+ import { cleanItems } from "./clean.js";
12
+ import { ADAPTERS, detectEnv } from "./adapters.js";
13
+ import { loadConfig } from "./config.js";
14
+ import { formatBytes, formatCount } from "./util/format.js";
15
+ const VERSION = "0.5.0";
16
+ const COMMANDS = new Set(["scan", "clean", "projects", "report", "config", "help"]);
17
+ const VALUE_FLAGS = new Set(["only", "top", "depth", "out"]);
18
+ function parseArgs(argv) {
19
+ const flags = {};
20
+ const positionals = [];
21
+ let command = "";
22
+ for (let i = 0; i < argv.length; i += 1) {
23
+ const arg = argv[i];
24
+ if (arg === "-h") {
25
+ flags.help = true;
26
+ continue;
27
+ }
28
+ if (arg === "-v") {
29
+ flags.version = true;
30
+ continue;
31
+ }
32
+ if (arg === "-i") {
33
+ flags.interactive = true;
34
+ continue;
35
+ }
36
+ if (arg.startsWith("--")) {
37
+ const body = arg.slice(2);
38
+ const eq = body.indexOf("=");
39
+ if (eq >= 0) {
40
+ flags[body.slice(0, eq)] = body.slice(eq + 1);
41
+ }
42
+ else if (VALUE_FLAGS.has(body)) {
43
+ flags[body] = argv[i + 1] ?? "";
44
+ i += 1;
45
+ }
46
+ else {
47
+ flags[body] = true;
48
+ }
49
+ continue;
50
+ }
51
+ if (!command && COMMANDS.has(arg)) {
52
+ command = arg;
53
+ }
54
+ else {
55
+ positionals.push(arg);
56
+ }
57
+ }
58
+ return { command: command || "scan", positionals, flags };
59
+ }
60
+ function helpText(p) {
61
+ const lines = [
62
+ p.bold("devclean " + VERSION) + p.dim(" - find and reclaim the gigabytes your dev tools are hoarding"),
63
+ "",
64
+ p.bold("Usage"),
65
+ " devclean scan the caches your dev tools left behind",
66
+ " devclean clean delete low and medium risk caches",
67
+ " devclean clean -i pick caches interactively",
68
+ " devclean projects [dir] find node_modules, .venv, __pycache__, target",
69
+ " devclean report write a shareable HTML report of the scan",
70
+ " devclean config show the config file (ignore lists, custom caches)",
71
+ " devclean clean --all include local LLM weights (high risk)",
72
+ "",
73
+ p.bold("Options"),
74
+ " --json print machine-readable JSON",
75
+ " --only <ids> comma separated adapter ids (npm,pip,cargo,...)",
76
+ " --top <n> show only the n largest entries",
77
+ " --all include high risk caches when cleaning",
78
+ " -i, --interactive pick caches to delete in a list",
79
+ " --yes skip the confirmation prompt",
80
+ " --dry-run show what would be deleted, delete nothing",
81
+ " --depth <n> projects: maximum directory depth (default 6)",
82
+ " --out <file> report: output path (default devclean-report.html)",
83
+ " --open report: open the file after writing it",
84
+ " --no-color disable ANSI colors",
85
+ " -h, --help show this help",
86
+ " -v, --version show the version",
87
+ "",
88
+ p.dim("Docs: https://github.com/shisilang684/devclean"),
89
+ ];
90
+ return lines.join("\n");
91
+ }
92
+ function fail(message) {
93
+ process.stderr.write("devclean: " + message + "\n");
94
+ process.exit(1);
95
+ }
96
+ function progressReporter(p, enabled) {
97
+ if (!enabled) {
98
+ return { start: () => { }, done: () => { }, finish: () => { } };
99
+ }
100
+ let last = "";
101
+ return {
102
+ start(label) {
103
+ last = label;
104
+ process.stderr.write("\r" + p.dim(" scanning " + label + "...").padEnd(78));
105
+ },
106
+ done(_label, size) {
107
+ process.stderr.write("\r" + p.dim(" scanned " + last + ": " + size).padEnd(78));
108
+ },
109
+ finish() {
110
+ process.stderr.write("\r" + " ".repeat(78) + "\r");
111
+ },
112
+ };
113
+ }
114
+ async function confirm(question) {
115
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
116
+ try {
117
+ const answer = (await rl.question(question)).trim().toLowerCase();
118
+ return answer === "y" || answer === "yes";
119
+ }
120
+ finally {
121
+ rl.close();
122
+ }
123
+ }
124
+ function parseOnly(flags) {
125
+ const raw = flags.only;
126
+ if (typeof raw !== "string" || raw.length === 0)
127
+ return undefined;
128
+ return raw.split(",").map((s) => s.trim()).filter(Boolean);
129
+ }
130
+ function editDistance(a, b) {
131
+ const rows = a.length + 1;
132
+ const cols = b.length + 1;
133
+ let previous = Array.from({ length: cols }, (_, i) => i);
134
+ for (let i = 1; i < rows; i += 1) {
135
+ const current = [i];
136
+ for (let j = 1; j < cols; j += 1) {
137
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
138
+ }
139
+ previous = current;
140
+ }
141
+ return previous[cols - 1];
142
+ }
143
+ function closestId(id, ids) {
144
+ let best;
145
+ let bestScore = Number.POSITIVE_INFINITY;
146
+ for (const candidate of ids) {
147
+ const score = editDistance(id, candidate);
148
+ if (score < bestScore) {
149
+ bestScore = score;
150
+ best = candidate;
151
+ }
152
+ }
153
+ return bestScore <= Math.max(1, Math.floor(id.length / 3)) ? best : undefined;
154
+ }
155
+ /** Warn about --only ids that match no adapter or custom cache. */
156
+ async function warnUnknownOnly(parsed, p) {
157
+ const only = parseOnly(parsed.flags);
158
+ if (!only || only.length === 0)
159
+ return;
160
+ const config = await loadConfig(detectEnv());
161
+ const known = [...ADAPTERS.map((adapter) => adapter.id), ...config.extra.map((extra) => extra.id)];
162
+ const unknown = only.filter((id) => !known.includes(id));
163
+ if (unknown.length === 0)
164
+ return;
165
+ for (const id of unknown) {
166
+ const hint = closestId(id, known);
167
+ process.stderr.write(p.yellow('warning: unknown cache id "' + id + '"') +
168
+ (hint ? p.dim(' - did you mean "' + hint + '"?') : "") +
169
+ "\n");
170
+ }
171
+ if (unknown.length === only.length) {
172
+ process.stderr.write(p.dim("known ids: " + known.join(", ")) + "\n");
173
+ }
174
+ }
175
+ async function commandScan(parsed, p) {
176
+ const only = parseOnly(parsed.flags);
177
+ await warnUnknownOnly(parsed, p);
178
+ const json = Boolean(parsed.flags.json);
179
+ const progress = progressReporter(p, !json && Boolean(process.stderr.isTTY));
180
+ const started = Date.now();
181
+ const { items } = await scanAll({
182
+ only,
183
+ onScanStart: (candidate) => progress.start(candidate.name),
184
+ onScanDone: (item) => progress.done(item.name, formatBytes(item.bytes)),
185
+ });
186
+ progress.finish();
187
+ const elapsed = ((Date.now() - started) / 1000).toFixed(1);
188
+ const topRaw = parsed.flags.top;
189
+ const top = typeof topRaw === "string" ? Number.parseInt(topRaw, 10) : 0;
190
+ const shown = top > 0 ? items.slice(0, top) : items;
191
+ if (json) {
192
+ process.stdout.write(renderJson(shown, VERSION) + "\n");
193
+ return;
194
+ }
195
+ if (shown.length === 0) {
196
+ const message = only && only.length > 0
197
+ ? "No caches matched --only " + only.join(",") + "."
198
+ : "No dev caches found on this machine.";
199
+ process.stdout.write(p.green(message) + "\n");
200
+ return;
201
+ }
202
+ process.stdout.write(renderTable(shown, { palette: p }) + "\n\n");
203
+ process.stdout.write(renderSummary(shown, p) + p.dim(" (" + elapsed + "s)") + "\n");
204
+ const footer = removeFooter(shown);
205
+ if (footer)
206
+ process.stdout.write(p.cyan(footer) + "\n");
207
+ }
208
+ async function commandClean(parsed, p) {
209
+ await warnUnknownOnly(parsed, p);
210
+ const includeHigh = Boolean(parsed.flags.all);
211
+ const json = Boolean(parsed.flags.json);
212
+ const progress = progressReporter(p, !json && Boolean(process.stderr.isTTY));
213
+ const { items: all, candidates } = await scanAll({
214
+ only: parseOnly(parsed.flags),
215
+ onScanStart: (candidate) => progress.start(candidate.name),
216
+ onScanDone: (item) => progress.done(item.name, formatBytes(item.bytes)),
217
+ });
218
+ progress.finish();
219
+ let targets = all.filter((item) => includeHigh || item.risk !== "high");
220
+ if (targets.length === 0) {
221
+ process.stdout.write(p.green("Nothing to clean.") + "\n");
222
+ return;
223
+ }
224
+ let picked = false;
225
+ if (!json && (parsed.flags.interactive || parsed.flags.i) && process.stdin.isTTY && process.stdout.isTTY) {
226
+ picked = true;
227
+ const chosen = await selectItems(all, { palette: p });
228
+ if (!chosen) {
229
+ process.stdout.write("Aborted.\n");
230
+ return;
231
+ }
232
+ if (chosen.length === 0) {
233
+ process.stdout.write(p.dim("Nothing selected.") + "\n");
234
+ return;
235
+ }
236
+ targets = chosen;
237
+ }
238
+ const total = totalOf(targets);
239
+ if (json) {
240
+ process.stdout.write(renderJson(targets, VERSION) + "\n");
241
+ if (!parsed.flags.yes)
242
+ return;
243
+ }
244
+ else {
245
+ process.stdout.write(renderTable(targets, { palette: p }) + "\n\n");
246
+ process.stdout.write(renderSummary(targets, p) + "\n");
247
+ }
248
+ if (parsed.flags["dry-run"]) {
249
+ process.stdout.write(p.yellow("Dry run - nothing was deleted.") + "\n");
250
+ return;
251
+ }
252
+ if (!parsed.flags.yes && !picked) {
253
+ if (!process.stdin.isTTY) {
254
+ fail("refusing to delete without --yes (stdin is not a TTY)");
255
+ }
256
+ const ok = await confirm(p.bold("Delete " + formatCount(total.files) + " files (" + formatBytes(total.bytes) + ")? ") + p.dim("[y/N] "));
257
+ if (!ok) {
258
+ process.stdout.write("Aborted.\n");
259
+ return;
260
+ }
261
+ }
262
+ const known = new Set();
263
+ for (const candidate of candidates) {
264
+ const resolved = path.resolve(candidate.path);
265
+ known.add(process.platform === "win32" ? resolved.toLowerCase() : resolved);
266
+ }
267
+ const { freed, outcomes } = await cleanItems(targets, known);
268
+ const failures = outcomes.filter((outcome) => !outcome.ok);
269
+ for (const outcome of failures) {
270
+ process.stderr.write(p.red(" failed: " + outcome.item.path + " - " + (outcome.error ?? "unknown")) + "\n");
271
+ }
272
+ process.stdout.write("\n" + p.green(p.bold("Reclaimed " + formatBytes(freed))) + "\n");
273
+ }
274
+ async function mapLimit(items, limit, fn) {
275
+ const results = new Array(items.length);
276
+ let next = 0;
277
+ const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
278
+ while (true) {
279
+ const index = next;
280
+ next += 1;
281
+ if (index >= items.length)
282
+ return;
283
+ results[index] = await fn(items[index]);
284
+ }
285
+ });
286
+ await Promise.all(workers);
287
+ return results;
288
+ }
289
+ async function commandProjects(parsed, p) {
290
+ const root = path.resolve(parsed.positionals[0] ?? process.cwd());
291
+ const depthRaw = parsed.flags.depth;
292
+ const depth = typeof depthRaw === "string" ? Number.parseInt(depthRaw, 10) : 6;
293
+ const json = Boolean(parsed.flags.json);
294
+ const wanted = new Set(parsed.positionals.slice(1));
295
+ if (process.stderr.isTTY && !json)
296
+ process.stderr.write(p.dim(" scanning " + root + "...") + "\n");
297
+ let hits = await findProjectArtifacts(root, Number.isFinite(depth) ? depth : 6);
298
+ if (wanted.size > 0)
299
+ hits = hits.filter((hit) => wanted.has(hit.name));
300
+ const measured = await mapLimit(hits, 4, async (hit) => {
301
+ const size = await dirSize(hit.path);
302
+ return { ...hit, bytes: size.bytes, files: size.files };
303
+ });
304
+ measured.sort((a, b) => b.bytes - a.bytes);
305
+ const items = measured.map((hit) => ({
306
+ id: "project",
307
+ name: hit.name,
308
+ path: hit.path,
309
+ risk: "low",
310
+ note: "Project artifact - reinstall with your package manager.",
311
+ bytes: hit.bytes,
312
+ files: hit.files,
313
+ errors: 0,
314
+ }));
315
+ const topRaw = parsed.flags.top;
316
+ const top = typeof topRaw === "string" ? Number.parseInt(topRaw, 10) : 0;
317
+ const shown = top > 0 ? items.slice(0, top) : items;
318
+ if (json) {
319
+ process.stdout.write(renderJson(shown, VERSION) + "\n");
320
+ return;
321
+ }
322
+ if (shown.length === 0) {
323
+ process.stdout.write(p.green("No project artifacts found under " + root) + "\n");
324
+ return;
325
+ }
326
+ process.stdout.write(renderTable(shown, { palette: p }) + "\n\n");
327
+ process.stdout.write(renderSummary(shown, p) + "\n");
328
+ if (!parsed.flags.clean) {
329
+ process.stdout.write(p.dim("Add --clean to delete these, e.g. devclean projects " + root + " --clean") + "\n");
330
+ return;
331
+ }
332
+ if (parsed.flags["dry-run"]) {
333
+ process.stdout.write(p.yellow("Dry run - nothing was deleted.") + "\n");
334
+ return;
335
+ }
336
+ if (!parsed.flags.yes) {
337
+ if (!process.stdin.isTTY)
338
+ fail("refusing to delete without --yes (stdin is not a TTY)");
339
+ const total = totalOf(shown);
340
+ const ok = await confirm(p.bold("Delete " + formatCount(total.files) + " files (" + formatBytes(total.bytes) + ")? ") + p.dim("[y/N] "));
341
+ if (!ok) {
342
+ process.stdout.write("Aborted.\n");
343
+ return;
344
+ }
345
+ }
346
+ const { freed } = await cleanItems(shown, new Set());
347
+ process.stdout.write("\n" + p.green(p.bold("Reclaimed " + formatBytes(freed))) + "\n");
348
+ }
349
+ async function commandReport(parsed, p) {
350
+ const json = Boolean(parsed.flags.json);
351
+ const progress = progressReporter(p, !json && Boolean(process.stderr.isTTY));
352
+ const { items } = await scanAll({
353
+ only: parseOnly(parsed.flags),
354
+ onScanStart: (candidate) => progress.start(candidate.name),
355
+ onScanDone: (item) => progress.done(item.name, formatBytes(item.bytes)),
356
+ });
357
+ progress.finish();
358
+ if (items.length === 0) {
359
+ process.stdout.write(p.green("Nothing to report - no dev caches found.") + "\n");
360
+ return;
361
+ }
362
+ const outRaw = parsed.flags.out;
363
+ const out = path.resolve(typeof outRaw === "string" && outRaw.length > 0 ? outRaw : "devclean-report.html");
364
+ const html = renderHtmlReport(items, { version: VERSION });
365
+ await writeFile(out, html, "utf8");
366
+ const total = totalOf(items);
367
+ process.stdout.write(p.green("Wrote " + out) + p.dim(" (" + formatBytes(Buffer.byteLength(html)) + ", " + formatCount(total.files) + " files scanned)") + "\n");
368
+ if (parsed.flags.open) {
369
+ const { spawn } = await import("node:child_process");
370
+ const command = process.platform === "win32" ? "cmd" : process.platform === "darwin" ? "open" : "xdg-open";
371
+ const args = process.platform === "win32" ? ["/c", "start", "", out] : [out];
372
+ const child = spawn(command, args, { detached: true, stdio: "ignore" });
373
+ child.unref();
374
+ }
375
+ }
376
+ async function commandConfig(parsed, p) {
377
+ const env = detectEnv();
378
+ const config = await loadConfig(env);
379
+ const exists = await pathExists(config.sourcePath);
380
+ if (parsed.flags.json) {
381
+ process.stdout.write(JSON.stringify({ path: config.sourcePath, exists, ignore: config.ignore, extra: config.extra, warnings: config.warnings }, null, 2) + "\n");
382
+ return;
383
+ }
384
+ process.stdout.write(p.bold("Config") + "\n " + config.sourcePath + "\n\n");
385
+ for (const warning of config.warnings)
386
+ process.stdout.write(p.yellow("warning: " + warning) + "\n");
387
+ if (!exists) {
388
+ process.stdout.write(p.dim("No config file yet. Create one to ignore caches or add your own:") + "\n\n");
389
+ process.stdout.write([
390
+ "{",
391
+ ' "ignore": ["maven"],',
392
+ ' "extra": [',
393
+ ' { "name": "Bazel cache", "path": "~/.cache/bazel", "risk": "medium" }',
394
+ " ]",
395
+ "}",
396
+ "",
397
+ ].join("\n"));
398
+ return;
399
+ }
400
+ if (config.ignore.length === 0)
401
+ process.stdout.write("ignore: none\n");
402
+ else
403
+ process.stdout.write("ignore: " + config.ignore.join(", ") + "\n");
404
+ if (config.extra.length === 0)
405
+ process.stdout.write("extra: none\n");
406
+ else {
407
+ process.stdout.write("extra:\n");
408
+ for (const item of config.extra) {
409
+ process.stdout.write(" " + item.name + " " + item.risk + " " + item.path + "\n");
410
+ }
411
+ }
412
+ }
413
+ async function main() {
414
+ const parsed = parseArgs(process.argv.slice(2));
415
+ const colorEnabled = Boolean(process.stdout.isTTY) && !parsed.flags["no-color"] && !process.env.NO_COLOR;
416
+ const p = createPalette(colorEnabled);
417
+ if (parsed.flags.version) {
418
+ process.stdout.write(VERSION + "\n");
419
+ return;
420
+ }
421
+ if (parsed.flags.help || parsed.command === "help") {
422
+ process.stdout.write(helpText(p) + "\n");
423
+ return;
424
+ }
425
+ if (parsed.command === "clean") {
426
+ await commandClean(parsed, p);
427
+ return;
428
+ }
429
+ if (parsed.command === "report") {
430
+ await commandReport(parsed, p);
431
+ return;
432
+ }
433
+ if (parsed.command === "projects") {
434
+ await commandProjects(parsed, p);
435
+ return;
436
+ }
437
+ if (parsed.command === "config") {
438
+ await commandConfig(parsed, p);
439
+ return;
440
+ }
441
+ await commandScan(parsed, p);
442
+ }
443
+ main().catch((error) => {
444
+ const message = error instanceof Error ? error.message : String(error);
445
+ process.stderr.write("devclean: " + message + "\n");
446
+ process.exit(1);
447
+ });
@@ -0,0 +1,24 @@
1
+ import type { Env, Risk } from "./adapters.js";
2
+ export interface ExtraCache {
3
+ id: string;
4
+ name: string;
5
+ path: string;
6
+ risk: Risk;
7
+ note: string;
8
+ }
9
+ export interface DevcleanConfig {
10
+ /** Path the config was loaded from (whether or not it exists). */
11
+ sourcePath: string;
12
+ /** Adapter ids or absolute paths that should never be reported. */
13
+ ignore: string[];
14
+ /** User-defined caches that are not built into devclean. */
15
+ extra: ExtraCache[];
16
+ /** Non-fatal problems found while parsing. */
17
+ warnings: string[];
18
+ }
19
+ export declare function configPath(env: Env): string;
20
+ /**
21
+ * Read the optional user config. A missing file is not an error; a malformed
22
+ * one is reported through warnings and ignored rather than crashing a scan.
23
+ */
24
+ export declare function loadConfig(env: Env): Promise<DevcleanConfig>;
package/dist/config.js ADDED
@@ -0,0 +1,109 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ export function configPath(env) {
4
+ const override = env.vars.DEVCLEAN_CONFIG;
5
+ if (override)
6
+ return path.resolve(override);
7
+ if (env.platform === "win32")
8
+ return path.join(env.appData, "devclean", "config.json");
9
+ if (env.platform === "darwin") {
10
+ return path.join(env.home, "Library", "Application Support", "devclean", "config.json");
11
+ }
12
+ const xdg = env.vars.XDG_CONFIG_HOME || path.join(env.home, ".config");
13
+ return path.join(xdg, "devclean", "config.json");
14
+ }
15
+ function slug(value) {
16
+ const cleaned = value
17
+ .toLowerCase()
18
+ .replace(/[^a-z0-9]+/g, "-")
19
+ .replace(/^-+|-+$/g, "");
20
+ return cleaned || "custom";
21
+ }
22
+ function expandHome(value, env) {
23
+ if (value === "~")
24
+ return env.home;
25
+ if (value.startsWith("~/") || value.startsWith("~\\"))
26
+ return path.join(env.home, value.slice(2));
27
+ return value;
28
+ }
29
+ function isRisk(value) {
30
+ return value === "low" || value === "medium" || value === "high";
31
+ }
32
+ /**
33
+ * Read the optional user config. A missing file is not an error; a malformed
34
+ * one is reported through warnings and ignored rather than crashing a scan.
35
+ */
36
+ export async function loadConfig(env) {
37
+ const sourcePath = configPath(env);
38
+ const config = { sourcePath, ignore: [], extra: [], warnings: [] };
39
+ let raw;
40
+ try {
41
+ raw = await fs.readFile(sourcePath, "utf8");
42
+ }
43
+ catch {
44
+ return config;
45
+ }
46
+ let parsed;
47
+ try {
48
+ parsed = JSON.parse(raw);
49
+ }
50
+ catch (error) {
51
+ config.warnings.push("config is not valid JSON: " + (error instanceof Error ? error.message : String(error)));
52
+ return config;
53
+ }
54
+ if (!parsed || typeof parsed !== "object") {
55
+ config.warnings.push("config must be a JSON object");
56
+ return config;
57
+ }
58
+ const record = parsed;
59
+ if (Array.isArray(record.ignore)) {
60
+ for (const entry of record.ignore) {
61
+ if (typeof entry === "string" && entry.trim().length > 0)
62
+ config.ignore.push(entry.trim());
63
+ else
64
+ config.warnings.push("ignore entries must be non-empty strings");
65
+ }
66
+ }
67
+ else if (record.ignore !== undefined) {
68
+ config.warnings.push("ignore must be an array of adapter ids or paths");
69
+ }
70
+ if (Array.isArray(record.extra)) {
71
+ const used = new Set();
72
+ record.extra.forEach((entry, index) => {
73
+ if (!entry || typeof entry !== "object") {
74
+ config.warnings.push("extra[" + index + "] must be an object");
75
+ return;
76
+ }
77
+ const item = entry;
78
+ if (typeof item.name !== "string" || item.name.trim().length === 0) {
79
+ config.warnings.push("extra[" + index + "] needs a name");
80
+ return;
81
+ }
82
+ if (typeof item.path !== "string" || item.path.trim().length === 0) {
83
+ config.warnings.push("extra[" + index + "] needs a path");
84
+ return;
85
+ }
86
+ const base = typeof item.id === "string" && item.id.trim().length > 0 ? slug(item.id) : slug(item.name);
87
+ let id = base;
88
+ for (let n = 2; used.has(id); n += 1)
89
+ id = base + "-" + n;
90
+ used.add(id);
91
+ config.extra.push({
92
+ id,
93
+ name: item.name.trim(),
94
+ path: path.resolve(expandHome(item.path, env)),
95
+ risk: isRisk(item.risk) ? item.risk : "medium",
96
+ note: typeof item.note === "string" && item.note.trim().length > 0
97
+ ? item.note.trim()
98
+ : "Custom cache from your devclean config.",
99
+ });
100
+ if (item.risk !== undefined && !isRisk(item.risk)) {
101
+ config.warnings.push('extra[' + index + '].risk must be "low", "medium" or "high"');
102
+ }
103
+ });
104
+ }
105
+ else if (record.extra !== undefined) {
106
+ config.warnings.push("extra must be an array of { name, path, risk } objects");
107
+ }
108
+ return config;
109
+ }
@@ -0,0 +1,10 @@
1
+ export { ADAPTERS, adapterById, detectEnv } from "./adapters.js";
2
+ export type { Adapter, CacheCandidate, Env, Risk } from "./adapters.js";
3
+ export { discover, scanAll, scanCandidates, totalOf } from "./scan.js";
4
+ export type { ScanItem, ScanOptions } from "./scan.js";
5
+ export { cleanItems, isSafeTarget } from "./clean.js";
6
+ export { createPalette, renderJson, renderSummary, renderTable } from "./report.js";
7
+ export { dirSize, findProjectArtifacts } from "./util/fs.js";
8
+ export { formatBytes, formatCount, percent } from "./util/format.js";
9
+ export { configPath, loadConfig } from "./config.js";
10
+ export type { DevcleanConfig, ExtraCache } from "./config.js";
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { ADAPTERS, adapterById, detectEnv } from "./adapters.js";
2
+ export { discover, scanAll, scanCandidates, totalOf } from "./scan.js";
3
+ export { cleanItems, isSafeTarget } from "./clean.js";
4
+ export { createPalette, renderJson, renderSummary, renderTable } from "./report.js";
5
+ export { dirSize, findProjectArtifacts } from "./util/fs.js";
6
+ export { formatBytes, formatCount, percent } from "./util/format.js";
7
+ export { configPath, loadConfig } from "./config.js";
@@ -0,0 +1,7 @@
1
+ import type { ScanItem } from "./scan.js";
2
+ export interface HtmlReportOptions {
3
+ version: string;
4
+ generatedAt?: Date;
5
+ title?: string;
6
+ }
7
+ export declare function renderHtmlReport(items: ScanItem[], options: HtmlReportOptions): string;