dir-analysis-tool 3.5.6 → 3.5.8

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
@@ -298,15 +298,17 @@ dat watch . -j -o report.json # keep report.json up to date
298
298
  ```
299
299
 
300
300
  - **Output.** Without `-o`, each report goes to stdout: pretty reports replace the previous one on a terminal (`--no-clear` keeps them), and JSON reports are printed one per line (NDJSON). With `-o`, the file is rewritten with the latest report on each change, in either format. The report file counts in the analysis like any other file, but writing it never starts a new scan, even inside the watched folder.
301
- - **`--poll`.** A new report is printed only when it would differ from the previous one, for any reason: a size, a date, a stale or empty file, a duplicate.
301
+ - **Only what changed is read again.** After the first scan, `watch` keeps what each folder contributes (its totals, file types and extensions, its largest files, and its entries in the reports you asked for) and re-reads only the folders a change touched, so a saved file shows up in milliseconds however large the tree is. Every report is still exactly what a full scan would print. With `-d`, only files that changed are hashed again. A full scan happens anyway when a change touches more than 1,000 paths or a tenth of the folders, when a `.gitignore` changes with `-g`, after the watched directory comes back, and at least every 10 minutes while changes keep coming, because file watching can miss events without saying so. With `-L` or a relative date (`--stale 1y`, `--newer-than 30d`), every report is a full scan.
302
+ - **Memory.** The per-folder state takes about 2 KiB per folder, more for folders with many large files in view, and `-d` keeps one record per candidate file. A full scan of the same tree needs neither between reports.
303
+ - **`--poll`.** Polling has no events to go on, so each poll is a full scan, and a new report is printed only when it would differ from the previous one, for any reason: a size, a date, a stale or empty file, a duplicate.
302
304
  - **A missing root.** A directory that doesn't exist (or isn't a directory) when `watch` starts is an error: one message, exit code `1`. If the watched directory is deleted later, `watch` says so once and waits; when it comes back, it reports again and resumes watching, on every platform and with `--poll`.
303
305
  - **Stopping.** Ctrl+C stops `watch` with exit code `130`, as for every command. It also stops on its own, with exit code `0`, when the reader of its output goes away (`dat watch --json | head -1`).
304
306
 
305
- | Option | Description |
306
- | ------------------ | ---------------------------------------------------------- |
307
- | `--debounce <ms>` | Wait this long after the last change. Default `300`. |
308
- | `--poll <seconds>` | Re-scan on an interval instead of using filesystem events. |
309
- | `--no-clear` | Keep earlier reports instead of clearing the screen. |
307
+ | Option | Description |
308
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------- |
309
+ | `--debounce <ms>` | Wait this long after the last change. Default `300`. |
310
+ | `--poll <seconds>` | Re-scan this many seconds after each scan ends, instead of using filesystem events, so scans never run back to back. |
311
+ | `--no-clear` | Keep earlier reports instead of clearing the screen. |
310
312
 
311
313
  All scan, report, and output options are accepted too (`pretty` and `json` formats).
312
314
 
@@ -534,6 +536,7 @@ Then ask in your own words, for example "why is this repo so big?" or "fail CI i
534
536
  2. Files over 256 KiB are compared by a SHA-256 sample of their first and last 64 KiB.
535
537
  3. Remaining candidates are hashed in full: small files in a single read, large files streamed through reusable buffers. A stage with 4,096 files or more is hashed by up to four worker threads (no more than the CPU cores less one), each with one reusable buffer, so SHA-256 runs in parallel; the results are the same as on the main thread. Each size group is finished as soon as its last file is hashed, so intermediate hash maps are retained only for groups in flight; candidates and results still use memory proportional to their count.
536
538
  - **Comparing contents.** `dat compare --content` reads each pair of same-size files side by side, in 256 KiB chunks through a fixed set of reusable buffers, and stops at the first byte that differs. No hash is computed, and the comparison itself uses a fixed amount of memory however large the files are.
539
+ - **Watching.** `dat watch` keeps a collector per folder and builds each report by merging them with the same code a full scan uses, so the two can't drift apart. A change re-reads the folders it touched and scans any new subfolder; hard links are counted once, under the link whose path sorts first.
537
540
  - **Disk usage.** Sizes are apparent sizes (file lengths). `On disk` is the space allocated in blocks, which is what `du` reports.
538
541
  - **Determinism.** Results are sorted by size and then by path, so the same tree always produces the same output, whatever order the filesystem returned it in. Equal sizes are ordered by comparing paths where they first differ, without building them, so deep trees full of same-size files rank them as fast as shallow ones.
539
542
 
@@ -546,7 +549,7 @@ Then ask in your own words, for example "why is this repo so big?" or "fail CI i
546
549
  | Scan and find duplicates | 2.64 s | **1.20 s** | |
547
550
  | Peak heap while finding duplicates | 118 MB | **45 MB** | |
548
551
 
549
- On a synthetic tree of 1,000,000 files, v3.1 scans in 8.9 s where `du -s` takes 13 s. On a 500-level chain of folders holding 2,000 files of one size, 3.5.5 scans in 44 ms where 3.5.4 took 90 ms (Linux in Docker on the same M4, median of nine), the same as with the largest-files list turned off. In a 93,000-file, 1.7 GiB project folder where 92% of the files share their size with another, 3.5.6 finds duplicates in 0.91 s where 3.5.5 took 2.2 s (Linux in Docker), and in 1.22 s where it took 1.50 s on macOS, where file-system calls are the limit; `dat compare --content` of that folder against a copy takes 3.5 s where it took 6.0 s (Linux). Compared with v2.0.7 on a 140,237-file tree, v3 scans about 3× faster and finds duplicates about 4× faster, with identical results. Run `pnpm bench` (or `pnpm bench <directory>`) to measure on your machine.
552
+ On a synthetic tree of 1,000,000 files, v3.1 scans in 8.9 s where `du -s` takes 13 s. On a 500-level chain of folders holding 2,000 files of one size, 3.5.5 scans in 44 ms where 3.5.4 took 90 ms (Linux in Docker on the same M4, median of nine), the same as with the largest-files list turned off. In a 93,000-file, 1.7 GiB project folder where 92% of the files share their size with another, 3.5.6 finds duplicates in 0.91 s where 3.5.5 took 2.2 s (Linux in Docker), and in 1.22 s where it took 1.50 s on macOS, where file-system calls are the limit; `dat compare --content` of that folder against a copy takes 3.5 s where it took 6.0 s (Linux). In 300,000 files, `dat watch` prints the report for a saved file 11–20 ms after the write, where re-scanning the tree took 1.2–1.4 s (Linux in Docker). Compared with v2.0.7 on a 140,237-file tree, v3 scans about 3× faster and finds duplicates about 4× faster, with identical results. Run `pnpm bench` (or `pnpm bench <directory>`) to measure on your machine.
550
553
 
551
554
  The benchmark script reports scan and duplicate timings plus process peak RSS (not JavaScript heap). Results vary with storage, cache state, tree shape, and Node.js version. `du` measures allocated disk space and does not produce the same reports.
552
555
 
@@ -594,7 +597,7 @@ v3 is a rewrite with a new output format. Most commands keep working unchanged.
594
597
 
595
598
  **Why does the total differ from `du`?** `du` reports blocks allocated on disk, while the headline size is the sum of file lengths. The `On disk` line matches `du`. Also check what was skipped: `.git` and `node_modules` are excluded by default (`--all` includes them), and hard-linked data is counted once, as `du` does. `dat explain` lists everything a scan skipped and why.
596
599
 
597
- **Is it safe to run on a huge directory?** Yes. The default scan keeps bounded top-N file lists, but folder metadata, hard-link tracking, and symlink tracking still require memory. Duplicate detection, directory comparisons, and optional file lists use additional memory (duplicate detection on thousands of files also starts up to four worker threads, a fixed few megabytes each), filesystem concurrency is bounded, and unreadable paths are reported rather than fatal. Press Ctrl+C at any time.
600
+ **Is it safe to run on a huge directory?** Yes. The default scan keeps bounded top-N file lists, but folder metadata, hard-link tracking, and symlink tracking still require memory. Duplicate detection, directory comparisons, and optional file lists use additional memory (duplicate detection on thousands of files also starts up to four worker threads, a fixed few megabytes each, and `dat watch` keeps about 2 KiB per folder between reports), filesystem concurrency is bounded, and unreadable paths are reported rather than fatal. Press Ctrl+C at any time.
598
601
 
599
602
  **Does it modify anything?** `dat` reads the scanned files. It writes report files when requested, and `dat init` writes a configuration file.
600
603
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as errorCode, C as MAX_EXPLAIN_LIMIT, D as outsideRootError, E as isOutside, F as listDirectories, G as formatBytes, J as VERSION, K as parseSize, L as Excluder, M as analyze, O as compare, P as assertDirectory, Q as DatError, R as joinRelative, T as explainSkips, U as formatBudgetActual, W as parseBudget, X as parsePointInTime, Z as AbortError, a as renderComparisonCsv, c as renderAnalysis, d as escapeControlInLines, et as errorMessage, f as formatCount, h as supportsColor, i as renderAnalysisCsv, k as compactAnalysis, l as renderComparison, m as createStyle, n as renderSkipsExplanation, o as renderAnalysisMarkdown, p as stringifyJson, r as renderAnalysisHtml, s as renderComparisonMarkdown, t as renderPathExplanation, u as escapeControl, v as loadConfig, w as explainPath } from "./shared-bXznpAvJ.js";
2
+ import { A as CANDIDATE_DIGESTS, B as resolveScan, C as MAX_EXPLAIN_LIMIT, D as outsideRootError, E as isOutside, F as createProgressReporter, G as diskBytesOf, H as Excluder, I as resolveFeatures, J as rollUp, K as passesFilters, O as compare, P as analyze, R as assertDirectory, T as explainSkips, U as Scanner, W as compareRelativePaths, X as comparePaths, Y as scanError, Z as joinRelative, a as renderComparisonCsv, at as parseSize, c as renderAnalysis, d as escapeControlInLines, dt as DatError, f as formatCount, ft as errorCode, h as supportsColor, i as renderAnalysisCsv, it as formatBytes, j as Collector, k as compactAnalysis, l as renderComparison, lt as parsePointInTime, m as createStyle, n as renderSkipsExplanation, nt as formatBudgetActual, o as renderAnalysisMarkdown, p as stringifyJson, pt as errorMessage, q as relativePathOf, r as renderAnalysisHtml, rt as parseBudget, s as renderComparisonMarkdown, st as VERSION, t as renderPathExplanation, tt as evaluateBudgets, u as escapeControl, ut as AbortError, v as loadConfig, w as explainPath, z as listDirectories } from "./shared-BCvVJ4Tm.js";
3
3
  import { constants, existsSync, watch } from "node:fs";
4
4
  import { access, mkdir, realpath, stat, writeFile } from "node:fs/promises";
5
5
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -926,10 +926,10 @@ function registerAnalyze(program, ctx) {
926
926
  reportBudgets(ctx, result, display);
927
927
  });
928
928
  }
929
- async function runAnalysis(ctx, target, options, display) {
929
+ async function runAnalysis(ctx, target, options, display, analyzer = analyze) {
930
930
  const progress = new ProgressLine(ctx.io.stderr, display.progress && ctx.io.stderr.isTTY === true, ctx.err, display.units);
931
931
  try {
932
- return await analyze(target, {
932
+ return await analyzer(target, {
933
933
  ...options,
934
934
  signal: ctx.io.signal,
935
935
  ...progress.enabled ? { onProgress: (p) => progress.analysis(p) } : {}
@@ -1366,6 +1366,417 @@ function validateWith(value, parse) {
1366
1366
  async function isFile(path) {
1367
1367
  return stat(path).then((stats) => !stats.isDirectory(), () => false);
1368
1368
  }
1369
+ const MIN_DIRTY_FOLDERS = 32;
1370
+ /**
1371
+ * An analysis kept up to date folder by folder, for `dat watch`.
1372
+ *
1373
+ * Each folder keeps what its own entries contribute: totals, file types and
1374
+ * extensions, its own top files and the entries of opt-in reports, through a
1375
+ * {@link Collector} of its own. A change re-reads only the folders it touched
1376
+ * (and scans new subfolders), then every report is built by merging the
1377
+ * folders' collectors with the same code `analyze` uses, so it is what a full
1378
+ * scan would report. Memory grows with the folders, not the files, except for
1379
+ * duplicate candidates, which `-d` keeps per file as it always does.
1380
+ *
1381
+ * Options it cannot follow incrementally make {@link LiveAnalysis.create}
1382
+ * return null: following symlinks (folders are then identified across the
1383
+ * tree) and relative dates, whose cutoffs move between reports.
1384
+ */
1385
+ var LiveAnalysis = class LiveAnalysis {
1386
+ #options;
1387
+ #scan;
1388
+ #features;
1389
+ #folders = /* @__PURE__ */ new Map();
1390
+ #stamps;
1391
+ constructor(options, scan, features) {
1392
+ this.#options = options;
1393
+ this.#scan = scan;
1394
+ this.#features = features;
1395
+ this.#stamps = features.duplicates;
1396
+ }
1397
+ /** Scans `path` in full, or returns null when the options rule out incremental updates. */
1398
+ static async create(path, options = {}) {
1399
+ if (options.followSymlinks) return null;
1400
+ const now = Date.now();
1401
+ const scan = await resolveScan(path, options, now);
1402
+ const features = resolveFeatures(options, now);
1403
+ const later = now + 3456e7;
1404
+ const moved = await resolveScan(path, options, later);
1405
+ if (moved.settings.modifiedAfter !== scan.settings.modifiedAfter || moved.settings.modifiedBefore !== scan.settings.modifiedBefore || resolveFeatures(options, later).staleBefore !== features.staleBefore) return null;
1406
+ const { onProgress, ...kept } = options;
1407
+ const live = new LiveAnalysis(kept, scan, features);
1408
+ return {
1409
+ live,
1410
+ update: await live.rescan(onProgress)
1411
+ };
1412
+ }
1413
+ /** Root-relative paths of every folder the analysis entered, the root as `''`. */
1414
+ get directories() {
1415
+ return [...this.#folders.keys()];
1416
+ }
1417
+ /** Scans everything again, reporting progress like `analyze` when asked to. */
1418
+ async rescan(onProgress) {
1419
+ const started = performance.now();
1420
+ const startedAt = Date.now();
1421
+ this.#folders.clear();
1422
+ let scanned = null;
1423
+ const progress = createProgressReporter(onProgress, this.#options.progressInterval, () => ({
1424
+ phase: "scan",
1425
+ files: scanned?.counters.files ?? 0,
1426
+ directories: scanned?.counters.directories ?? 0,
1427
+ bytes: scanned?.counters.bytes ?? 0,
1428
+ errors: scanned?.counters.errors ?? 0
1429
+ }));
1430
+ try {
1431
+ await this.#scanTree("", null, null, 0, (scanner) => scanned = scanner);
1432
+ progress.flush();
1433
+ } finally {
1434
+ progress.stop();
1435
+ }
1436
+ return {
1437
+ result: await this.#build(startedAt, started),
1438
+ mode: "full",
1439
+ folders: this.#folders.size
1440
+ };
1441
+ }
1442
+ /**
1443
+ * Updates the analysis after changes at `paths` (root-relative, `/`
1444
+ * separators, as a watcher reports them: the entry that changed, or a
1445
+ * folder whose contents did). Falls back to a full scan when that is
1446
+ * cheaper or when a change can affect folders it does not name.
1447
+ */
1448
+ async update(paths) {
1449
+ const started = performance.now();
1450
+ const startedAt = Date.now();
1451
+ const changed = [...new Set(paths)];
1452
+ if (changed.length > 1e3 || !this.#folders.has("")) return this.rescan();
1453
+ if (this.#scan.options.excluder.gitignore && changed.some(isIgnoreFile)) return this.rescan();
1454
+ const named = new Set(changed);
1455
+ const dirty = /* @__PURE__ */ new Set();
1456
+ for (const path of changed) {
1457
+ const folder = this.#folders.get(path);
1458
+ if (folder) dirty.add(folder);
1459
+ let parent = parentOf(path);
1460
+ while (parent !== null && !this.#folders.has(parent)) parent = parentOf(parent);
1461
+ if (parent !== null) dirty.add(this.#folders.get(parent));
1462
+ }
1463
+ if (dirty.size > Math.max(MIN_DIRTY_FOLDERS, this.#folders.size * .1)) return this.rescan();
1464
+ const queue = [...dirty].sort((a, b) => a.depth - b.depth);
1465
+ let folders = 0;
1466
+ while (queue.length > 0) {
1467
+ const folder = queue.shift();
1468
+ if (this.#folders.get(folder.rel) !== folder) continue;
1469
+ folders += await this.#relist(folder, queue, named);
1470
+ }
1471
+ return {
1472
+ result: await this.#build(startedAt, started),
1473
+ mode: "incremental",
1474
+ folders
1475
+ };
1476
+ }
1477
+ /** Re-reads one folder's own entries; removes vanished subfolders and scans new ones. */
1478
+ async #relist(folder, queue, named) {
1479
+ const subfolders = /* @__PURE__ */ new Map();
1480
+ const fresh = await this.#scanFolder(folder, subfolders);
1481
+ if (this.#stamps) keepDigests(folder, fresh, named);
1482
+ if (fresh.node.entries === -1 && folder.parent && isGone(fresh.errors ?? [])) {
1483
+ if (!queue.includes(folder.parent)) queue.unshift(folder.parent);
1484
+ return 1;
1485
+ }
1486
+ Object.assign(folder, {
1487
+ ...fresh,
1488
+ children: folder.children
1489
+ });
1490
+ let read = 1;
1491
+ for (const [name, child] of folder.children ?? []) if (!subfolders.has(name)) this.#remove(child);
1492
+ for (const [name, chain] of subfolders) {
1493
+ if (folder.children?.has(name)) continue;
1494
+ const rel = folder.rel ? `${folder.rel}/${name}` : name;
1495
+ read += await this.#scanTree(rel, folder, chain, folder.depth + 1);
1496
+ }
1497
+ return read;
1498
+ }
1499
+ #remove(folder) {
1500
+ for (const child of folder.children?.values() ?? []) this.#remove(child);
1501
+ this.#folders.delete(folder.rel);
1502
+ const siblings = folder.parent?.children;
1503
+ siblings?.delete(basename(folder.rel));
1504
+ if (siblings?.size === 0) folder.parent.children = null;
1505
+ }
1506
+ /** Scans a folder and everything below it, adding a record for each folder. */
1507
+ async #scanTree(rel, parent, chain, depth, onScanner) {
1508
+ const local = [];
1509
+ const scanner = this.#scanner(rel, chain === null ? void 0 : {
1510
+ rel,
1511
+ chain,
1512
+ depth,
1513
+ shallow: false
1514
+ }, {
1515
+ directory: (index, node, inherited) => {
1516
+ const up = node.parent >= 0 ? local[node.parent] : parent;
1517
+ const folderRel = up && index > 0 ? join$1(up.rel, node.name) : rel;
1518
+ const folder = this.#newFolder(folderRel, up, node, inherited);
1519
+ local[index] = folder;
1520
+ this.#folders.set(folderRel, folder);
1521
+ if (up) (up.children ??= /* @__PURE__ */ new Map()).set(basename(folderRel), folder);
1522
+ },
1523
+ folderOf: (index) => local[index]
1524
+ });
1525
+ onScanner?.(scanner);
1526
+ await scanner.run();
1527
+ return local.length;
1528
+ }
1529
+ /** Reads only `folder`'s own entries, into a fresh record; subfolders go to `subfolders`. */
1530
+ async #scanFolder(folder, subfolders) {
1531
+ let fresh = null;
1532
+ await this.#scanner(folder.rel, {
1533
+ rel: folder.rel,
1534
+ chain: folder.chain,
1535
+ depth: folder.depth,
1536
+ shallow: true
1537
+ }, {
1538
+ directory: (_index, node, inherited) => {
1539
+ fresh = this.#newFolder(folder.rel, folder.parent, node, inherited);
1540
+ },
1541
+ folderOf: () => fresh,
1542
+ subfolder: (name, chain) => subfolders.set(name, chain)
1543
+ }).run();
1544
+ return fresh;
1545
+ }
1546
+ #scanner(rel, start, route) {
1547
+ const base = this.#scan.options;
1548
+ return new Scanner({
1549
+ ...base,
1550
+ root: joinRelative(base.root, rel),
1551
+ start,
1552
+ signal: this.#options.signal,
1553
+ onSkip: (event) => {
1554
+ const folder = route.folderOf(event.dir);
1555
+ if (event.kind === "excluded") folder.excluded++;
1556
+ else if (event.kind === "filtered") folder.filtered++;
1557
+ else if (event.kind === "symlink") folder.symlinks++;
1558
+ },
1559
+ onLinkedFile: (dir, name, stats, key) => {
1560
+ (route.folderOf(dir).links ??= []).push({
1561
+ name,
1562
+ stats,
1563
+ key
1564
+ });
1565
+ },
1566
+ onError: (dir, detail) => {
1567
+ const folder = route.folderOf(dir);
1568
+ const path = join$1(rel, detail.path === "." ? "" : detail.path) || ".";
1569
+ addError(folder, {
1570
+ ...detail,
1571
+ path
1572
+ });
1573
+ }
1574
+ }, {
1575
+ directory: route.directory,
1576
+ file: (dir, name, stats) => route.folderOf(dir).collector.file(0, name, stats),
1577
+ ...route.subfolder ? { subfolder: (_parent, name, chain) => route.subfolder(name, chain) } : {}
1578
+ });
1579
+ }
1580
+ #newFolder(rel, parent, node, chain) {
1581
+ const collector = new Collector(this.#features, this.#stamps);
1582
+ collector.attach(new FolderView(node));
1583
+ return {
1584
+ rel,
1585
+ parent,
1586
+ depth: node.depth,
1587
+ chain,
1588
+ node,
1589
+ collector,
1590
+ excluded: 0,
1591
+ filtered: 0,
1592
+ symlinks: 0,
1593
+ errorCount: 0,
1594
+ errors: null,
1595
+ links: null,
1596
+ children: null
1597
+ };
1598
+ }
1599
+ /** Merges every folder into one report, the way `analyze` builds it from one scan. */
1600
+ async #build(startedAt, started) {
1601
+ const features = this.#features;
1602
+ const tree = new MergedTree(this.#scan.options.root);
1603
+ const collector = new Collector(features, this.#stamps);
1604
+ collector.attach(tree);
1605
+ const index = /* @__PURE__ */ new Map();
1606
+ const errors = [];
1607
+ const visit = (folder, parent) => {
1608
+ const node = folder.node;
1609
+ const i = tree.dirs.push({
1610
+ name: folder.parent ? basename(folder.rel) : "",
1611
+ parent,
1612
+ depth: folder.depth,
1613
+ entries: node.entries,
1614
+ ownFiles: node.ownFiles,
1615
+ ownBytes: node.ownBytes,
1616
+ ownDiskBytes: node.ownDiskBytes,
1617
+ files: 0,
1618
+ bytes: 0,
1619
+ diskBytes: 0,
1620
+ largestChild: 0
1621
+ }) - 1;
1622
+ index.set(folder, i);
1623
+ const c = tree.counters;
1624
+ c.directories++;
1625
+ c.files += node.ownFiles;
1626
+ c.bytes += node.ownBytes;
1627
+ c.diskBytes += node.ownDiskBytes;
1628
+ c.excluded += folder.excluded;
1629
+ c.filtered += folder.filtered;
1630
+ c.symlinks += folder.symlinks;
1631
+ c.errors += folder.errorCount;
1632
+ if (folder.errors) errors.push(...folder.errors);
1633
+ collector.directory(i, tree.dirs[i]);
1634
+ collector.absorb(folder.collector, i);
1635
+ for (const child of folder.children?.values() ?? []) visit(child, i);
1636
+ };
1637
+ visit(this.#folders.get(""), -1);
1638
+ this.#countLinks(tree, collector, index);
1639
+ errors.sort((a, b) => comparePaths(a.path, b.path));
1640
+ tree.errors.push(...errors.slice(0, 100));
1641
+ rollUp(tree.dirs);
1642
+ let duplicates;
1643
+ if (features.duplicates) duplicates = await collector.findDuplicates(tree, this.#scan.options.concurrency, this.#options.signal, () => {}, CANDIDATE_DIGESTS);
1644
+ const result = collector.build(tree, {
1645
+ root: this.#scan.options.root,
1646
+ startedAt,
1647
+ settings: this.#scan.settings,
1648
+ duplicates
1649
+ });
1650
+ if (features.budgets.length > 0) result.budgets = evaluateBudgets(features.budgets, result);
1651
+ result.durationMs = Math.round(performance.now() - started);
1652
+ return result;
1653
+ }
1654
+ /**
1655
+ * Counts each set of hard links once, under the link whose path sorts
1656
+ * first, so the choice never depends on which link a scan reached first.
1657
+ */
1658
+ #countLinks(tree, collector, index) {
1659
+ const byKey = /* @__PURE__ */ new Map();
1660
+ for (const folder of this.#folders.values()) for (const file of folder.links ?? []) {
1661
+ const links = byKey.get(file.key);
1662
+ if (links) links.push({
1663
+ folder,
1664
+ file
1665
+ });
1666
+ else byKey.set(file.key, [{
1667
+ folder,
1668
+ file
1669
+ }]);
1670
+ }
1671
+ const options = this.#scan.options;
1672
+ for (const links of byKey.values()) {
1673
+ tree.counters.hardlinks += links.length - 1;
1674
+ const { folder, file } = links.reduce((a, b) => comparePaths(join$1(a.folder.rel, a.file.name), join$1(b.folder.rel, b.file.name)) <= 0 ? a : b);
1675
+ if (!passesFilters(options, file.stats)) {
1676
+ tree.counters.filtered++;
1677
+ continue;
1678
+ }
1679
+ const dir = index.get(folder);
1680
+ const node = tree.dirs[dir];
1681
+ const diskBytes = diskBytesOf(file.stats);
1682
+ node.ownFiles++;
1683
+ node.ownBytes += file.stats.size;
1684
+ node.ownDiskBytes += diskBytes;
1685
+ tree.counters.files++;
1686
+ tree.counters.bytes += file.stats.size;
1687
+ tree.counters.diskBytes += diskBytes;
1688
+ collector.file(dir, file.name, file.stats);
1689
+ }
1690
+ }
1691
+ };
1692
+ /** The merged folders of a live analysis, as one scan's tree for {@link Collector.build}. */
1693
+ var MergedTree = class {
1694
+ dirs = [];
1695
+ errors = [];
1696
+ counters = emptyCounters();
1697
+ #root;
1698
+ constructor(root) {
1699
+ this.#root = root;
1700
+ }
1701
+ relativePath(dir, name) {
1702
+ return relativePathOf(this.dirs, dir, name);
1703
+ }
1704
+ absolutePath(dir, name) {
1705
+ return joinRelative(this.#root, this.relativePath(dir, name));
1706
+ }
1707
+ compareRelative(dirA, nameA, dirB, nameB) {
1708
+ return compareRelativePaths(this.dirs, dirA, nameA, dirB, nameB);
1709
+ }
1710
+ recordError(path, error) {
1711
+ this.counters.errors++;
1712
+ if (this.errors.length < 100) this.errors.push(scanError(path, error));
1713
+ }
1714
+ };
1715
+ /** One folder seen as a whole tree, for that folder's own collector. */
1716
+ var FolderView = class {
1717
+ dirs;
1718
+ constructor(node) {
1719
+ this.dirs = [node];
1720
+ }
1721
+ /** Within one folder, paths differ only by name. */
1722
+ compareRelative(_dirA, nameA, _dirB, nameB) {
1723
+ return comparePaths(nameA ?? "", nameB ?? "");
1724
+ }
1725
+ };
1726
+ /**
1727
+ * Moves digests from a folder's old candidates to the new ones for files that
1728
+ * kept their size, timestamps and identity and that no event named, so only
1729
+ * files that changed are read again.
1730
+ */
1731
+ function keepDigests(old, fresh, named) {
1732
+ const before = /* @__PURE__ */ new Map();
1733
+ for (const candidate of old.collector.candidates()) if (candidate.digests) before.set(candidate.name, candidate);
1734
+ if (before.size === 0) return;
1735
+ for (const candidate of fresh.collector.candidates()) {
1736
+ const previous = before.get(candidate.name);
1737
+ const digests = previous?.digests;
1738
+ if (previous && digests && previous.bytes === candidate.bytes && previous.mtimeMs === candidate.mtimeMs && previous.ctimeMs === candidate.ctimeMs && previous.ino === candidate.ino && previous.dev === candidate.dev && !named.has(join$1(old.rel, candidate.name))) candidate.digests = digests;
1739
+ }
1740
+ }
1741
+ function emptyCounters() {
1742
+ return {
1743
+ files: 0,
1744
+ bytes: 0,
1745
+ diskBytes: 0,
1746
+ directories: 0,
1747
+ symlinks: 0,
1748
+ hardlinks: 0,
1749
+ excluded: 0,
1750
+ filtered: 0,
1751
+ errors: 0
1752
+ };
1753
+ }
1754
+ /** Adds an error to a folder, keeping only the {@link MAX_ERROR_DETAILS} first by path. */
1755
+ function addError(folder, detail) {
1756
+ folder.errorCount++;
1757
+ const errors = folder.errors ??= [];
1758
+ errors.push(detail);
1759
+ if (errors.length > 100) {
1760
+ errors.sort((a, b) => comparePaths(a.path, b.path));
1761
+ errors.pop();
1762
+ }
1763
+ }
1764
+ function isGone(errors) {
1765
+ return errors.some((e) => e.code === "ENOENT" || e.code === "ENOTDIR");
1766
+ }
1767
+ function isIgnoreFile(path) {
1768
+ return path === ".gitignore" || path.endsWith("/.gitignore");
1769
+ }
1770
+ function join$1(dir, name) {
1771
+ if (!dir) return name;
1772
+ return name ? `${dir}/${name}` : dir;
1773
+ }
1774
+ /** The folder a root-relative path is in: `''` for the root's entries, null for the root. */
1775
+ function parentOf(path) {
1776
+ if (path === "") return null;
1777
+ const slash = path.lastIndexOf("/");
1778
+ return slash < 0 ? "" : path.slice(0, slash);
1779
+ }
1369
1780
  // src/cli/watcher.ts
1370
1781
  /**
1371
1782
  * Watches a directory tree with the platform's native facility.
@@ -1436,6 +1847,15 @@ var TreeWatcher = class {
1436
1847
  };
1437
1848
  // src/cli/commands/watch.ts
1438
1849
  const CLEAR_SCREEN = "\x1B[2J\x1B[3J\x1B[H";
1850
+ /**
1851
+ * Events can be lost without a word (a full kernel queue, a sleeping laptop), so while changes keep
1852
+ * coming, a report is a full scan again at least this often.
1853
+ */
1854
+ const FULL_SCAN_EVERY_MS = 6e5;
1855
+ /** Whether the next report must come from a full scan instead of the changed folders. */
1856
+ function needsFullScan(lastFullScan, now) {
1857
+ return now - lastFullScan >= FULL_SCAN_EVERY_MS;
1858
+ }
1439
1859
  const EXAMPLES = `
1440
1860
  Examples:
1441
1861
  $ dat watch re-analyze the current directory on every change
@@ -1449,7 +1869,7 @@ function registerWatch(program, ctx) {
1449
1869
  addScanOptions(command);
1450
1870
  addReportOptions(command);
1451
1871
  addOutputOptions(command, ["pretty", "json"]);
1452
- command.addOption(new Option("--debounce <ms>", "wait this long after the last change (default: 300)").argParser(integer(0)).helpGroup("Watch options:")).addOption(new Option("--poll <seconds>", "re-scan on an interval instead of using filesystem events").argParser(integer(1)).helpGroup("Watch options:")).addOption(new Option("--no-clear", "keep previous reports instead of clearing the screen").helpGroup("Watch options:"));
1872
+ command.addOption(new Option("--debounce <ms>", "wait this long after the last change (default: 300)").argParser(integer(0)).helpGroup("Watch options:")).addOption(new Option("--poll <seconds>", "re-scan this many seconds after each scan ends, instead of using filesystem events").argParser(integer(1)).helpGroup("Watch options:")).addOption(new Option("--no-clear", "keep previous reports instead of clearing the screen").helpGroup("Watch options:"));
1453
1873
  command.addHelpText("after", EXAMPLES);
1454
1874
  command.action(async (directory, _options, cmd) => {
1455
1875
  const cli = explicitOptions(cmd);
@@ -1477,6 +1897,10 @@ function registerWatch(program, ctx) {
1477
1897
  let polling = pollSeconds !== void 0;
1478
1898
  let rootGone = false;
1479
1899
  let rootCheck = null;
1900
+ let incremental = pollSeconds === void 0;
1901
+ let live = null;
1902
+ let lastFullScan = 0;
1903
+ const changed = /* @__PURE__ */ new Set();
1480
1904
  const excluder = new Excluder({
1481
1905
  patterns: options.exclude ?? [],
1482
1906
  defaultExcludes: options.defaultExcludes ?? true
@@ -1502,20 +1926,39 @@ function registerWatch(program, ctx) {
1502
1926
  const readerGone = () => ctx.stdoutClosed;
1503
1927
  let watcher = null;
1504
1928
  let poller = null;
1929
+ let finished = false;
1930
+ /** The run in progress, so a poll can wait for it before counting its idle time. */
1931
+ let active = Promise.resolve();
1505
1932
  const closeWatcher = () => {
1506
1933
  watcher?.close();
1507
1934
  watcher = null;
1508
1935
  };
1509
- const schedule = () => {
1936
+ const schedule = (path) => {
1510
1937
  changes++;
1938
+ if (path !== void 0) changed.add(path);
1511
1939
  if (timer) clearTimeout(timer);
1512
1940
  timer = setTimeout(() => void run(), debounce);
1513
1941
  };
1942
+ const startLive = async (path, settings) => {
1943
+ const created = await LiveAnalysis.create(path, settings);
1944
+ if (!created) {
1945
+ incremental = false;
1946
+ return analyze(path, settings);
1947
+ }
1948
+ live = created.live;
1949
+ return created.update.result;
1950
+ };
1514
1951
  const startPolling = (seconds) => {
1515
1952
  polling = true;
1953
+ incremental = false;
1954
+ live = null;
1516
1955
  if (rootCheck) clearInterval(rootCheck);
1517
1956
  rootCheck = null;
1518
- poller = setInterval(() => void run(), seconds * 1e3);
1957
+ const tick = async () => {
1958
+ await run();
1959
+ if (!finished && !signal?.aborted) poller = setTimeout(() => void tick(), seconds * 1e3);
1960
+ };
1961
+ poller = setTimeout(() => void tick(), seconds * 1e3);
1519
1962
  };
1520
1963
  const markRootGone = () => {
1521
1964
  if (rootGone) return;
@@ -1544,7 +1987,7 @@ function registerWatch(program, ctx) {
1544
1987
  const created = new TreeWatcher({
1545
1988
  root: target,
1546
1989
  isIgnored: (rel) => ownFiles.has(rel) || excluder.isPathExcluded(rel),
1547
- onChange: schedule,
1990
+ onChange: (path) => schedule(path),
1548
1991
  onError: (error) => void watchFailed(created, error)
1549
1992
  });
1550
1993
  watcher = created;
@@ -1553,7 +1996,7 @@ function registerWatch(program, ctx) {
1553
1996
  return;
1554
1997
  }
1555
1998
  }
1556
- if (watcher && !watcher.recursive) watcher.sync(await listDirectories(target, options));
1999
+ if (watcher && !watcher.recursive) watcher.sync(live ? live.directories : await listDirectories(target, options));
1557
2000
  };
1558
2001
  const scan = async () => {
1559
2002
  if (!await isDirectory(target)) {
@@ -1563,12 +2006,22 @@ function registerWatch(program, ctx) {
1563
2006
  if (rootGone) {
1564
2007
  rootGone = false;
1565
2008
  changes++;
2009
+ live = null;
1566
2010
  }
2011
+ const paths = [...changed];
2012
+ changed.clear();
1567
2013
  try {
2014
+ if (incremental && live && !needsFullScan(lastFullScan, Date.now())) {
2015
+ const update = await live.update(paths);
2016
+ if (update.mode === "full") lastFullScan = Date.now();
2017
+ return update.result;
2018
+ }
2019
+ lastFullScan = Date.now();
2020
+ if (incremental && live) return (await live.rescan()).result;
1568
2021
  return await runAnalysis(ctx, target, options, {
1569
2022
  ...display,
1570
2023
  progress: display.progress && previous === null
1571
- });
2024
+ }, incremental ? startLive : void 0);
1572
2025
  } catch (error) {
1573
2026
  if (!(error instanceof AbortError) && !await isDirectory(target)) {
1574
2027
  markRootGone();
@@ -1577,11 +2030,15 @@ function registerWatch(program, ctx) {
1577
2030
  throw error;
1578
2031
  }
1579
2032
  };
1580
- const run = async (initial = false) => {
2033
+ const run = (initial = false) => {
1581
2034
  if (running) {
1582
2035
  pending = true;
1583
- return;
2036
+ return active;
1584
2037
  }
2038
+ active = runLoop(initial);
2039
+ return active;
2040
+ };
2041
+ const runLoop = async (initial) => {
1585
2042
  running = true;
1586
2043
  try {
1587
2044
  for (;;) {
@@ -1627,7 +2084,8 @@ function registerWatch(program, ctx) {
1627
2084
  })]);
1628
2085
  }
1629
2086
  if (timer) clearTimeout(timer);
1630
- if (poller) clearInterval(poller);
2087
+ finished = true;
2088
+ if (poller) clearTimeout(poller);
1631
2089
  if (rootCheck) clearInterval(rootCheck);
1632
2090
  closeWatcher();
1633
2091
  if (signal?.aborted) throw new AbortError();
package/dist/index.d.ts CHANGED
@@ -236,6 +236,24 @@ export interface ComparisonResult {
236
236
  /** At most `top` directories with the largest size change, largest absolute change first. */
237
237
  directories: DirectoryDelta[];
238
238
  }
239
+ /** A feature a metric depends on; requesting the metric turns the feature on. */
240
+ type BudgetFeature = "largeFiles" | "duplicates" | "empty" | "stale";
241
+ interface MetricSpec {
242
+ kind: "size" | "count";
243
+ description: string;
244
+ requires?: BudgetFeature;
245
+ read: (result: AnalysisResult) => number;
246
+ }
247
+ export declare const BUDGET_METRICS: Readonly<Record<BudgetMetric, MetricSpec>>;
248
+ interface Budget {
249
+ rule: string;
250
+ metric: BudgetMetric;
251
+ operator: BudgetOperator;
252
+ limit: number;
253
+ }
254
+ /** Parses a rule such as `size<=500MB`, `duplicates=0`, or `files < 10000`. */
255
+ export declare function parseBudget(rule: string): Budget;
256
+ export declare function evaluateBudgets(budgets: readonly Budget[], result: AnalysisResult): BudgetResult[];
239
257
  interface DuplicateProgress {
240
258
  stage: "sample" | "full";
241
259
  done: number;
@@ -538,24 +556,6 @@ export declare function explainSkips(root: string, options?: ExplainSkipsOptions
538
556
  export declare function extensionOf(fileName: string): string;
539
557
  /** Classifies a file by its well-known name first, then by extension. */
540
558
  export declare function classify(fileName: string, extension?: string): Category;
541
- /** A feature a metric depends on; requesting the metric turns the feature on. */
542
- type BudgetFeature = "largeFiles" | "duplicates" | "empty" | "stale";
543
- interface MetricSpec {
544
- kind: "size" | "count";
545
- description: string;
546
- requires?: BudgetFeature;
547
- read: (result: AnalysisResult) => number;
548
- }
549
- export declare const BUDGET_METRICS: Readonly<Record<BudgetMetric, MetricSpec>>;
550
- interface Budget {
551
- rule: string;
552
- metric: BudgetMetric;
553
- operator: BudgetOperator;
554
- limit: number;
555
- }
556
- /** Parses a rule such as `size<=500MB`, `duplicates=0`, or `files < 10000`. */
557
- export declare function parseBudget(rule: string): Budget;
558
- export declare function evaluateBudgets(budgets: readonly Budget[], result: AnalysisResult): BudgetResult[];
559
559
  /** Settings accepted in a config file. CLI flags always take precedence. */
560
560
  interface DatConfig {
561
561
  exclude?: string[];
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { Z as AbortError, V as BUDGET_METRICS, q as CATEGORIES, g as CONFIG_FILE_NAMES, N as DEFAULT_CONCURRENCY, I as DEFAULT_EXCLUDES, x as DEFAULT_EXPLAIN_LIMIT, A as DEFAULT_LARGE_FILE_THRESHOLD, j as DEFAULT_STALE_AGE, Q as DatError, S as EXPLAIN_VERSION, C as MAX_EXPLAIN_LIMIT, J as VERSION, M as analyze, y as buildJsonSchema, z as classify, k as compactAnalysis, O as compare, m as createStyle, H as evaluateBudgets, w as explainPath, T as explainSkips, B as extensionOf, _ as findConfigFile, G as formatBytes, F as listDirectories, v as loadConfig, W as parseBudget, Y as parseDuration, X as parsePointInTime, K as parseSize, c as renderAnalysis, i as renderAnalysisCsv, r as renderAnalysisHtml, o as renderAnalysisMarkdown, l as renderComparison, a as renderComparisonCsv, s as renderComparisonMarkdown, t as renderPathExplanation, n as renderSkipsExplanation, b as validateConfig } from "./shared-bXznpAvJ.js";
1
+ export { ut as AbortError, et as BUDGET_METRICS, ot as CATEGORIES, g as CONFIG_FILE_NAMES, L as DEFAULT_CONCURRENCY, V as DEFAULT_EXCLUDES, x as DEFAULT_EXPLAIN_LIMIT, M as DEFAULT_LARGE_FILE_THRESHOLD, N as DEFAULT_STALE_AGE, dt as DatError, S as EXPLAIN_VERSION, C as MAX_EXPLAIN_LIMIT, st as VERSION, P as analyze, y as buildJsonSchema, Q as classify, k as compactAnalysis, O as compare, m as createStyle, tt as evaluateBudgets, w as explainPath, T as explainSkips, $ as extensionOf, _ as findConfigFile, it as formatBytes, z as listDirectories, v as loadConfig, rt as parseBudget, ct as parseDuration, lt as parsePointInTime, at as parseSize, c as renderAnalysis, i as renderAnalysisCsv, r as renderAnalysisHtml, o as renderAnalysisMarkdown, l as renderComparison, a as renderComparisonCsv, s as renderComparisonMarkdown, t as renderPathExplanation, n as renderSkipsExplanation, b as validateConfig } from "./shared-BCvVJ4Tm.js";
@@ -4,7 +4,7 @@ import { close, existsSync, open, read } from "node:fs";
4
4
  import { lstat, open as open$1, readFile, readdir, stat } from "node:fs/promises";
5
5
  import { availableParallelism } from "node:os";
6
6
  import { Worker } from "node:worker_threads";
7
- import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
8
8
  // src/errors.ts
9
9
  /**
10
10
  * An expected, user-facing failure (bad input, missing directory, invalid
@@ -1066,16 +1066,21 @@ var Scanner = class {
1066
1066
  this.#filtersActive = options.minSize > 0 || options.maxSize < Infinity || options.modifiedAfter > -Infinity || options.modifiedBefore < Infinity;
1067
1067
  }
1068
1068
  async run() {
1069
- const { root, signal, excluder } = this.#options;
1069
+ const { root, signal, excluder, start } = this.#options;
1070
1070
  if (signal?.aborted) throw new AbortError();
1071
- const rootStats = await stat(root);
1072
- if (this.#options.followSymlinks) this.#seenDirs.add(await inodeKey(rootStats, root));
1073
- const chain = await excluder.loadAncestorChain(root);
1074
- const index = this.#addDir("", -1, 0);
1071
+ let chain;
1072
+ if (start) chain = start.chain;
1073
+ else {
1074
+ const rootStats = await stat(root);
1075
+ if (this.#options.followSymlinks) this.#seenDirs.add(await inodeKey(rootStats, root));
1076
+ chain = await excluder.loadAncestorChain(root);
1077
+ }
1078
+ const index = this.#addDir(start ? basename(start.rel) : "", -1, start?.depth ?? 0, chain);
1079
+ const relRoot = start?.rel ?? "";
1075
1080
  const onAbort = () => this.#limiter.abort(new AbortError());
1076
1081
  signal?.addEventListener("abort", onAbort, { once: true });
1077
1082
  try {
1078
- this.#limiter.run(() => this.#scanDir(index, root, chain, ""));
1083
+ this.#limiter.run(() => this.#scanDir(index, root, chain, this.#options.excluder.needsPaths ? relRoot : ""));
1079
1084
  await this.#limiter.idle();
1080
1085
  } finally {
1081
1086
  signal?.removeEventListener("abort", onAbort);
@@ -1090,14 +1095,12 @@ var Scanner = class {
1090
1095
  }
1091
1096
  /** Root-relative path of a directory (or of `name` inside it), with `/` separators. */
1092
1097
  relativePath(dirIndex, name) {
1093
- const parts = name === void 0 ? [] : [name];
1094
- for (let i = dirIndex; i > 0; i = this.dirs[i].parent) parts.push(this.dirs[i].name);
1095
- return parts.toReversed().join("/");
1098
+ return relativePathOf(this.dirs, dirIndex, name);
1096
1099
  }
1097
1100
  absolutePath(dirIndex, name) {
1098
1101
  return joinRelative(this.#options.root, this.relativePath(dirIndex, name));
1099
1102
  }
1100
- #addDir(name, parent, depth) {
1103
+ #addDir(name, parent, depth, chain) {
1101
1104
  const node = {
1102
1105
  name,
1103
1106
  parent,
@@ -1113,7 +1116,7 @@ var Scanner = class {
1113
1116
  };
1114
1117
  const index = this.dirs.push(node) - 1;
1115
1118
  this.counters.directories++;
1116
- this.#visitor.directory?.(index, node);
1119
+ this.#visitor.directory?.(index, node, chain);
1117
1120
  return index;
1118
1121
  }
1119
1122
  /**
@@ -1128,7 +1131,7 @@ var Scanner = class {
1128
1131
  entries = await readdir(absPath, { withFileTypes: true });
1129
1132
  } catch (error) {
1130
1133
  this.dirs[index].entries = -1;
1131
- this.recordError(this.relativePath(index), error);
1134
+ this.recordError(this.relativePath(index), error, index);
1132
1135
  return;
1133
1136
  }
1134
1137
  const node = this.dirs[index];
@@ -1181,7 +1184,11 @@ var Scanner = class {
1181
1184
  });
1182
1185
  return;
1183
1186
  }
1184
- const child = this.#addDir(name, parent, depth);
1187
+ if (this.#options.start?.shallow) {
1188
+ this.#visitor.subfolder?.(parent, name, chain);
1189
+ return;
1190
+ }
1191
+ const child = this.#addDir(name, parent, depth, chain);
1185
1192
  this.#limiter.run(() => this.#scanDir(child, fullPath, chain, relPath));
1186
1193
  }
1187
1194
  async #statFile(dirIndex, name, fullPath) {
@@ -1189,7 +1196,7 @@ var Scanner = class {
1189
1196
  try {
1190
1197
  stats = await lstat(fullPath);
1191
1198
  } catch (error) {
1192
- this.recordError(this.relativePath(dirIndex, name), error);
1199
+ this.recordError(this.relativePath(dirIndex, name), error, dirIndex);
1193
1200
  return;
1194
1201
  }
1195
1202
  const pending = this.#acceptFile(dirIndex, name, fullPath, stats);
@@ -1228,7 +1235,7 @@ var Scanner = class {
1228
1235
  });
1229
1236
  return;
1230
1237
  }
1231
- this.recordError(this.relativePath(dirIndex, name), error);
1238
+ this.recordError(this.relativePath(dirIndex, name), error, dirIndex);
1232
1239
  return;
1233
1240
  }
1234
1241
  if (isSymlink) this.counters.symlinks++;
@@ -1261,6 +1268,13 @@ var Scanner = class {
1261
1268
  * identity needs an exact (bigint) stat; see `inodeKey`.
1262
1269
  */
1263
1270
  #acceptFile(dirIndex, name, fullPath, stats) {
1271
+ const onLinked = this.#options.onLinkedFile;
1272
+ if (onLinked && !this.#options.countHardlinks && stats.nlink > 1) {
1273
+ const key = inodeKey(stats, fullPath);
1274
+ if (typeof key !== "string") return key.then((exact) => onLinked(dirIndex, name, stats, exact));
1275
+ onLinked(dirIndex, name, stats, key);
1276
+ return;
1277
+ }
1264
1278
  if (!this.#options.countHardlinks && (stats.nlink > 1 || this.#options.followSymlinks)) {
1265
1279
  const key = inodeKey(stats, fullPath);
1266
1280
  if (typeof key !== "string") return key.then((exact) => this.#acceptKeyedFile(dirIndex, name, stats, exact));
@@ -1279,21 +1293,17 @@ var Scanner = class {
1279
1293
  }
1280
1294
  #countFile(dirIndex, name, stats) {
1281
1295
  const size = stats.size;
1282
- if (this.#filtersActive) {
1283
- const o = this.#options;
1284
- const mtime = stats.mtimeMs;
1285
- if (size < o.minSize || size > o.maxSize || mtime < o.modifiedAfter || mtime > o.modifiedBefore) {
1286
- this.counters.filtered++;
1287
- o.onSkip?.({
1288
- kind: "filtered",
1289
- dir: dirIndex,
1290
- name,
1291
- stats
1292
- });
1293
- return;
1294
- }
1296
+ if (this.#filtersActive && !passesFilters(this.#options, stats)) {
1297
+ this.counters.filtered++;
1298
+ this.#options.onSkip?.({
1299
+ kind: "filtered",
1300
+ dir: dirIndex,
1301
+ name,
1302
+ stats
1303
+ });
1304
+ return;
1295
1305
  }
1296
- const diskBytes = IS_WINDOWS || !(stats.blocks >= 0) ? size : stats.blocks * 512;
1306
+ const diskBytes = diskBytesOf(stats);
1297
1307
  const node = this.dirs[dirIndex];
1298
1308
  node.ownFiles++;
1299
1309
  node.ownBytes += size;
@@ -1304,15 +1314,11 @@ var Scanner = class {
1304
1314
  this.#visitor.file(dirIndex, name, stats, diskBytes);
1305
1315
  }
1306
1316
  /** Counts an error and keeps its details, up to {@link MAX_ERROR_DETAILS}. */
1307
- recordError(path, error) {
1317
+ recordError(path, error, dir = -1) {
1308
1318
  this.counters.errors++;
1309
- if (this.errors.length >= 100) return;
1310
- const code = errorCode(error);
1311
- this.errors.push({
1312
- path: path || ".",
1313
- code: code ?? "UNKNOWN",
1314
- message: (code && ERROR_DESCRIPTIONS[code]) ?? errorMessage(error)
1315
- });
1319
+ const detail = scanError(path, error);
1320
+ if (dir >= 0) this.#options.onError?.(dir, detail);
1321
+ if (this.errors.length < 100) this.errors.push(detail);
1316
1322
  }
1317
1323
  };
1318
1324
  /**
@@ -1334,6 +1340,31 @@ function rollUp(dirs) {
1334
1340
  }
1335
1341
  }
1336
1342
  }
1343
+ /** Root-relative path of a directory (or of `name` inside it) in `dirs`, with `/` separators. */
1344
+ function relativePathOf(dirs, dirIndex, name) {
1345
+ const parts = name === void 0 ? [] : [name];
1346
+ for (let i = dirIndex; i > 0; i = dirs[i].parent) parts.push(dirs[i].name);
1347
+ return parts.toReversed().join("/");
1348
+ }
1349
+ /** Whether a file passes the size and date filters. */
1350
+ function passesFilters(options, stats) {
1351
+ const size = stats.size;
1352
+ const mtime = stats.mtimeMs;
1353
+ return !(size < options.minSize || size > options.maxSize || mtime < options.modifiedAfter || mtime > options.modifiedBefore);
1354
+ }
1355
+ /** Space a file takes on disk, which `du` reports; its length where blocks aren't known. */
1356
+ function diskBytesOf(stats) {
1357
+ return IS_WINDOWS || !(stats.blocks >= 0) ? stats.size : stats.blocks * 512;
1358
+ }
1359
+ /** An error's details as reports show them. */
1360
+ function scanError(path, error) {
1361
+ const code = errorCode(error);
1362
+ return {
1363
+ path: path || ".",
1364
+ code: code ?? "UNKNOWN",
1365
+ message: (code && ERROR_DESCRIPTIONS[code]) ?? errorMessage(error)
1366
+ };
1367
+ }
1337
1368
  /** Code unit of the `/` that joins path segments. */
1338
1369
  const SLASH = 47;
1339
1370
  /**
@@ -1485,6 +1516,7 @@ async function hashStage(groups, stage, options, hashing) {
1485
1516
  /** Records one file's digest, or its error, the same way for both paths. */
1486
1517
  const record = (candidate, state, digest) => {
1487
1518
  if (typeof digest === "string") {
1519
+ options.cache?.set(candidate, stage, digest);
1488
1520
  const members = state.byHash.get(digest);
1489
1521
  if (members) members.push(candidate);
1490
1522
  else state.byHash.set(digest, [candidate]);
@@ -1497,17 +1529,24 @@ async function hashStage(groups, stage, options, hashing) {
1497
1529
  total
1498
1530
  });
1499
1531
  };
1500
- function* files() {
1501
- for (const group of groups) {
1502
- const state = {
1503
- bytes: group[0].bytes,
1504
- pending: group.length,
1505
- byHash: /* @__PURE__ */ new Map()
1506
- };
1507
- for (const candidate of group) yield [candidate, state];
1532
+ const cache = options.cache;
1533
+ const states = groups.map((group) => [group, {
1534
+ bytes: group[0].bytes,
1535
+ pending: group.length,
1536
+ byHash: /* @__PURE__ */ new Map()
1537
+ }]);
1538
+ let toHash = total;
1539
+ if (cache) for (const [group, state] of states) for (const candidate of group) {
1540
+ const digest = cache.get(candidate, stage);
1541
+ if (digest !== void 0) {
1542
+ record(candidate, state, digest);
1543
+ toHash--;
1508
1544
  }
1509
1545
  }
1510
- if (hashing.workers > 0 && total >= hashing.threshold) {
1546
+ function* files() {
1547
+ for (const [group, state] of states) for (const candidate of group) if (cache?.get(candidate, stage) === void 0) yield [candidate, state];
1548
+ }
1549
+ if (hashing.workers > 0 && toHash >= hashing.threshold) {
1511
1550
  hashing.pool ??= new HashPool(hashing.workers);
1512
1551
  await hashWithWorkers(files(), stage, options, hashing.pool, record);
1513
1552
  return results;
@@ -2525,6 +2564,13 @@ const DEFAULT_LARGE_FILE_THRESHOLD = 104857600;
2525
2564
  const DEFAULT_STALE_AGE = "1y";
2526
2565
  /** A directory is folded into its largest child when that child holds this share of its size. */
2527
2566
  const PASS_THROUGH_SHARE$1 = .95;
2567
+ /** Digests kept on the candidates themselves, for {@link Collector.findDuplicates}. */
2568
+ const CANDIDATE_DIGESTS = {
2569
+ get: (candidate, stage) => candidate.digests?.[stage],
2570
+ set: (candidate, stage, digest) => {
2571
+ (candidate.digests ??= {})[stage] = digest;
2572
+ }
2573
+ };
2528
2574
  /**
2529
2575
  * Analyzes a directory tree in a single pass.
2530
2576
  *
@@ -2566,7 +2612,7 @@ async function analyze(path, options = {}) {
2566
2612
  progress.stop();
2567
2613
  const interval = options.progressInterval ?? 100;
2568
2614
  let last = 0;
2569
- duplicates = await collector.findDuplicates(scanOptions.concurrency, scanOptions.signal, (p) => {
2615
+ duplicates = await collector.findDuplicates(scanner, scanOptions.concurrency, scanOptions.signal, (p) => {
2570
2616
  if (!report) return;
2571
2617
  const now = performance.now();
2572
2618
  if (p.done !== p.total && p.done !== 0 && now - last < interval) return;
@@ -2643,40 +2689,123 @@ function resolveFeatures(options, now) {
2643
2689
  budgets
2644
2690
  };
2645
2691
  }
2646
- /** Collects every statistic during the scan. One instance per analysis. */
2692
+ /**
2693
+ * Collects every statistic during the scan. One instance per analysis, or in
2694
+ * watch one per folder, merged into a fresh one with {@link absorb} for each report.
2695
+ */
2647
2696
  var Collector = class {
2648
2697
  #features;
2698
+ #stamps;
2649
2699
  #scanner = null;
2650
- #types = emptyTypeStats();
2651
- #extensions = /* @__PURE__ */ new Map();
2700
+ /** File types with at least one file; `build` lists every type in the usual order. */
2701
+ #types = null;
2702
+ #extensions = null;
2652
2703
  #largestFileBytes = 0;
2653
- #topFiles;
2654
- #large = {
2655
- refs: [],
2656
- bytes: 0
2657
- };
2658
- #empty = [];
2659
- #stale = {
2660
- refs: [],
2661
- bytes: 0
2662
- };
2704
+ #topFiles = null;
2705
+ #large = null;
2706
+ #empty = null;
2707
+ #stale = null;
2663
2708
  /** Size -> candidates; a single candidate is stored unwrapped to save memory. */
2664
- #bySize = /* @__PURE__ */ new Map();
2709
+ #bySize = null;
2665
2710
  /** Tree data: subdirectories and largest files of each directory shallower than the tree depth. */
2666
- #treeChildren = /* @__PURE__ */ new Map();
2667
- #treeFiles = /* @__PURE__ */ new Map();
2668
- constructor(features) {
2711
+ #treeChildren = null;
2712
+ #treeFiles = null;
2713
+ /** @param stamps Keep each duplicate candidate's timestamps (see {@link DigestCache}). */
2714
+ constructor(features, stamps = false) {
2669
2715
  this.#features = features;
2670
- this.#topFiles = new TopK(features.top, (a, b) => this.#compareRefs(a, b));
2716
+ this.#stamps = stamps;
2717
+ }
2718
+ #addType(category, files, bytes) {
2719
+ const types = this.#types ??= {};
2720
+ const stat = types[category];
2721
+ if (stat) {
2722
+ stat.files += files;
2723
+ stat.bytes += bytes;
2724
+ } else types[category] = {
2725
+ files,
2726
+ bytes
2727
+ };
2728
+ }
2729
+ #addExtension(extension, files, bytes) {
2730
+ const extensions = this.#extensions ??= /* @__PURE__ */ new Map();
2731
+ const stat = extensions.get(extension);
2732
+ if (stat) {
2733
+ stat.files += files;
2734
+ stat.bytes += bytes;
2735
+ } else extensions.set(extension, {
2736
+ files,
2737
+ bytes
2738
+ });
2739
+ }
2740
+ #pushTop(ref) {
2741
+ (this.#topFiles ??= new TopK(this.#features.top, (a, b) => this.#compareRefs(a, b))).push(ref.bytes, ref);
2742
+ }
2743
+ #acceptsTop(bytes) {
2744
+ if (this.#features.top === 0) return false;
2745
+ return this.#topFiles?.accepts(bytes) ?? true;
2671
2746
  }
2672
2747
  attach(scanner) {
2673
2748
  this.#scanner = scanner;
2674
2749
  }
2750
+ /**
2751
+ * Adds everything `other` collected for a single folder, which it knew as
2752
+ * directory 0, as directory `dir` of this collector's tree. Lists and top-N
2753
+ * heaps merge to what one collector would have kept seeing every file.
2754
+ */
2755
+ absorb(other, dir) {
2756
+ const move = (ref) => ({
2757
+ ...ref,
2758
+ dir
2759
+ });
2760
+ for (const category of CATEGORIES) {
2761
+ const stat = other.#types?.[category];
2762
+ if (stat) this.#addType(category, stat.files, stat.bytes);
2763
+ }
2764
+ for (const [extension, stat] of other.#extensions ?? []) this.#addExtension(extension, stat.files, stat.bytes);
2765
+ if (other.#largestFileBytes > this.#largestFileBytes) this.#largestFileBytes = other.#largestFileBytes;
2766
+ for (const ref of other.#topFiles?.sorted() ?? []) if (this.#acceptsTop(ref.bytes)) this.#pushTop(move(ref));
2767
+ if (other.#large) {
2768
+ const large = this.#large ??= {
2769
+ refs: [],
2770
+ bytes: 0
2771
+ };
2772
+ for (const ref of other.#large.refs) large.refs.push(move(ref));
2773
+ large.bytes += other.#large.bytes;
2774
+ }
2775
+ if (other.#empty) {
2776
+ const empty = this.#empty ??= [];
2777
+ for (const ref of other.#empty) empty.push(move(ref));
2778
+ }
2779
+ if (other.#stale) {
2780
+ const stale = this.#stale ??= {
2781
+ refs: [],
2782
+ bytes: 0
2783
+ };
2784
+ for (const ref of other.#stale.refs) stale.refs.push(move(ref));
2785
+ stale.bytes += other.#stale.bytes;
2786
+ }
2787
+ const files = other.#treeFiles?.get(0);
2788
+ if (files) {
2789
+ const heap = new TopK(this.#features.tree.limit, (a, b) => comparePaths(a.name, b.name));
2790
+ for (const ref of files.sorted()) heap.push(ref.bytes, move(ref));
2791
+ (this.#treeFiles ??= /* @__PURE__ */ new Map()).set(dir, heap);
2792
+ }
2793
+ for (const candidate of other.candidates()) {
2794
+ candidate.dir = dir;
2795
+ this.#addCandidate(candidate);
2796
+ }
2797
+ }
2798
+ /** Every duplicate candidate collected so far. */
2799
+ *candidates() {
2800
+ for (const value of this.#bySize?.values() ?? []) if (Array.isArray(value)) yield* value;
2801
+ else yield value;
2802
+ }
2675
2803
  directory(index, node) {
2676
2804
  const tree = this.#features.tree;
2677
2805
  if (tree && node.parent >= 0 && node.depth <= tree.depth) {
2678
- let siblings = this.#treeChildren.get(node.parent);
2679
- if (!siblings) this.#treeChildren.set(node.parent, siblings = []);
2806
+ const children = this.#treeChildren ??= /* @__PURE__ */ new Map();
2807
+ let siblings = children.get(node.parent);
2808
+ if (!siblings) children.set(node.parent, siblings = []);
2680
2809
  siblings.push(index);
2681
2810
  }
2682
2811
  }
@@ -2685,17 +2814,8 @@ var Collector = class {
2685
2814
  const mtimeMs = stats.mtimeMs;
2686
2815
  const features = this.#features;
2687
2816
  const extension = extensionOf(name);
2688
- const type = this.#types[classify(name, extension)];
2689
- type.files++;
2690
- type.bytes += bytes;
2691
- const ext = this.#extensions.get(extension);
2692
- if (ext) {
2693
- ext.files++;
2694
- ext.bytes += bytes;
2695
- } else this.#extensions.set(extension, {
2696
- files: 1,
2697
- bytes
2698
- });
2817
+ this.#addType(classify(name, extension), 1, bytes);
2818
+ this.#addExtension(extension, 1, bytes);
2699
2819
  if (bytes > this.#largestFileBytes) this.#largestFileBytes = bytes;
2700
2820
  let ref;
2701
2821
  const makeRef = () => ref ??= {
@@ -2704,22 +2824,31 @@ var Collector = class {
2704
2824
  bytes,
2705
2825
  mtimeMs
2706
2826
  };
2707
- if (this.#topFiles.accepts(bytes)) this.#topFiles.push(bytes, makeRef());
2827
+ if (this.#acceptsTop(bytes)) this.#pushTop(makeRef());
2708
2828
  if (features.largeThreshold !== null && bytes >= features.largeThreshold) {
2709
- this.#large.refs.push(makeRef());
2710
- this.#large.bytes += bytes;
2829
+ const large = this.#large ??= {
2830
+ refs: [],
2831
+ bytes: 0
2832
+ };
2833
+ large.refs.push(makeRef());
2834
+ large.bytes += bytes;
2711
2835
  }
2712
- if (features.empty && bytes === 0) this.#empty.push(makeRef());
2836
+ if (features.empty && bytes === 0) (this.#empty ??= []).push(makeRef());
2713
2837
  if (features.staleBefore !== null && mtimeMs < features.staleBefore) {
2714
- this.#stale.refs.push(makeRef());
2715
- this.#stale.bytes += bytes;
2838
+ const stale = this.#stale ??= {
2839
+ refs: [],
2840
+ bytes: 0
2841
+ };
2842
+ stale.refs.push(makeRef());
2843
+ stale.bytes += bytes;
2716
2844
  }
2717
2845
  if (features.tree) {
2718
2846
  if (this.#scanner.dirs[dir].depth < features.tree.depth) {
2719
- let heap = this.#treeFiles.get(dir);
2847
+ const heaps = this.#treeFiles ??= /* @__PURE__ */ new Map();
2848
+ let heap = heaps.get(dir);
2720
2849
  if (!heap) {
2721
2850
  heap = new TopK(features.tree.limit, (a, b) => comparePaths(a.name, b.name));
2722
- this.#treeFiles.set(dir, heap);
2851
+ heaps.set(dir, heap);
2723
2852
  }
2724
2853
  if (heap.accepts(bytes)) heap.push(bytes, makeRef());
2725
2854
  }
@@ -2733,17 +2862,24 @@ var Collector = class {
2733
2862
  ino: stats.ino,
2734
2863
  nlink: stats.nlink
2735
2864
  };
2736
- const existing = this.#bySize.get(bytes);
2737
- if (existing === void 0) this.#bySize.set(bytes, candidate);
2738
- else if (Array.isArray(existing)) existing.push(candidate);
2739
- else this.#bySize.set(bytes, [existing, candidate]);
2865
+ if (this.#stamps) {
2866
+ candidate.mtimeMs = mtimeMs;
2867
+ candidate.ctimeMs = stats.ctimeMs;
2868
+ }
2869
+ this.#addCandidate(candidate);
2740
2870
  }
2741
2871
  }
2742
- async findDuplicates(concurrency, signal, onProgress) {
2743
- const scanner = this.#scanner;
2872
+ #addCandidate(candidate) {
2873
+ const bySize = this.#bySize ??= /* @__PURE__ */ new Map();
2874
+ const existing = bySize.get(candidate.bytes);
2875
+ if (existing === void 0) bySize.set(candidate.bytes, candidate);
2876
+ else if (Array.isArray(existing)) existing.push(candidate);
2877
+ else bySize.set(candidate.bytes, [existing, candidate]);
2878
+ }
2879
+ async findDuplicates(scanner, concurrency, signal, onProgress, cache) {
2744
2880
  const groups = [];
2745
- for (const value of this.#bySize.values()) if (Array.isArray(value)) groups.push(value);
2746
- this.#bySize.clear();
2881
+ for (const value of this.#bySize?.values() ?? []) if (Array.isArray(value)) groups.push(value);
2882
+ this.#bySize = null;
2747
2883
  const dirPaths = /* @__PURE__ */ new Map();
2748
2884
  const items = (await findDuplicates(groups, {
2749
2885
  pathOf: (c) => {
@@ -2754,7 +2890,8 @@ var Collector = class {
2754
2890
  concurrency,
2755
2891
  signal,
2756
2892
  onProgress,
2757
- onError: (c, error) => scanner.recordError(scanner.relativePath(c.dir, c.name), error)
2893
+ onError: (c, error) => scanner.recordError(scanner.relativePath(c.dir, c.name), error),
2894
+ cache
2758
2895
  })).map((group) => {
2759
2896
  const files = group.members.map((m) => scanner.relativePath(m.dir, m.name)).sort(comparePaths);
2760
2897
  return {
@@ -2809,27 +2946,34 @@ var Collector = class {
2809
2946
  filtered: c.filtered,
2810
2947
  errors: c.errors
2811
2948
  },
2812
- types: this.#types,
2813
- extensions: [...this.#extensions].map(([extension, stat]) => ({
2949
+ types: this.#typeStats(),
2950
+ extensions: [...this.#extensions ?? []].map(([extension, stat]) => ({
2814
2951
  extension,
2815
2952
  ...stat
2816
2953
  })).sort((a, b) => b.bytes - a.bytes || b.files - a.files || comparePaths(a.extension, b.extension)),
2817
2954
  largestDirectories: this.#largestDirectories(scanner),
2818
- largestFiles: this.#topFiles.sorted().map(toEntry),
2955
+ largestFiles: (this.#topFiles?.sorted() ?? []).map(toEntry),
2819
2956
  errors: [...scanner.errors].sort((a, b) => comparePaths(a.path, b.path))
2820
2957
  };
2821
- if (features.largeThreshold !== null) result.largeFiles = {
2822
- threshold: features.largeThreshold,
2823
- count: this.#large.refs.length,
2824
- bytes: this.#large.bytes,
2825
- items: this.#large.refs.map(toEntry).sort(bySizeThenPath)
2826
- };
2958
+ if (features.largeThreshold !== null) {
2959
+ const large = this.#large ?? {
2960
+ refs: [],
2961
+ bytes: 0
2962
+ };
2963
+ result.largeFiles = {
2964
+ threshold: features.largeThreshold,
2965
+ count: large.refs.length,
2966
+ bytes: large.bytes,
2967
+ items: large.refs.map(toEntry).sort(bySizeThenPath)
2968
+ };
2969
+ }
2827
2970
  if (context.duplicates) result.duplicates = context.duplicates;
2828
2971
  if (features.empty) {
2972
+ const empty = this.#empty ?? [];
2829
2973
  result.emptyFiles = {
2830
- count: this.#empty.length,
2974
+ count: empty.length,
2831
2975
  bytes: 0,
2832
- items: this.#empty.map(toEntry).sort((a, b) => comparePaths(a.path, b.path))
2976
+ items: empty.map(toEntry).sort((a, b) => comparePaths(a.path, b.path))
2833
2977
  };
2834
2978
  const emptyDirs = [];
2835
2979
  for (let i = 1; i < scanner.dirs.length; i++) if (scanner.dirs[i].entries === 0) emptyDirs.push(scanner.relativePath(i));
@@ -2838,15 +2982,30 @@ var Collector = class {
2838
2982
  items: emptyDirs.sort(comparePaths)
2839
2983
  };
2840
2984
  }
2841
- if (features.staleBefore !== null) result.staleFiles = {
2842
- modifiedBefore: new Date(features.staleBefore).toISOString(),
2843
- count: this.#stale.refs.length,
2844
- bytes: this.#stale.bytes,
2845
- items: this.#stale.refs.map(toEntry).sort(bySizeThenPath)
2846
- };
2985
+ if (features.staleBefore !== null) {
2986
+ const stale = this.#stale ?? {
2987
+ refs: [],
2988
+ bytes: 0
2989
+ };
2990
+ result.staleFiles = {
2991
+ modifiedBefore: new Date(features.staleBefore).toISOString(),
2992
+ count: stale.refs.length,
2993
+ bytes: stale.bytes,
2994
+ items: stale.refs.map(toEntry).sort(bySizeThenPath)
2995
+ };
2996
+ }
2847
2997
  if (features.tree) result.tree = this.#buildTree(scanner, 0, features.tree.limit, toEntry);
2848
2998
  return result;
2849
2999
  }
3000
+ /** Every file type, in the usual order, including those without files. */
3001
+ #typeStats() {
3002
+ const types = emptyTypeStats();
3003
+ for (const category of CATEGORIES) {
3004
+ const stat = this.#types?.[category];
3005
+ if (stat) types[category] = { ...stat };
3006
+ }
3007
+ return types;
3008
+ }
2850
3009
  #largestDirectories(scanner) {
2851
3010
  const top = new TopK(this.#features.top, (a, b) => scanner.compareRelative(a, void 0, b, void 0));
2852
3011
  const dirs = scanner.dirs;
@@ -2871,8 +3030,8 @@ var Collector = class {
2871
3030
  bytes: node.bytes,
2872
3031
  files: node.files
2873
3032
  };
2874
- const subdirs = this.#treeChildren.get(index);
2875
- const files = this.#treeFiles.get(index);
3033
+ const subdirs = this.#treeChildren?.get(index);
3034
+ const files = this.#treeFiles?.get(index);
2876
3035
  if (!subdirs && !files) return result;
2877
3036
  const candidates = [];
2878
3037
  for (const child of subdirs ?? []) candidates.push({
@@ -5348,4 +5507,4 @@ function renderSkipsExplanation(result, options = {}) {
5348
5507
  }
5349
5508
  return `${lines.join("\n")}\n`;
5350
5509
  }
5351
- export { errorCode as $, DEFAULT_LARGE_FILE_THRESHOLD as A, extensionOf as B, MAX_EXPLAIN_LIMIT as C, outsideRootError as D, isOutside as E, listDirectories as F, formatBytes as G, evaluateBudgets as H, DEFAULT_EXCLUDES as I, VERSION as J, parseSize as K, Excluder as L, analyze as M, DEFAULT_CONCURRENCY as N, compare as O, assertDirectory as P, DatError as Q, joinRelative as R, EXPLAIN_VERSION as S, explainSkips as T, formatBudgetActual as U, BUDGET_METRICS as V, parseBudget as W, parsePointInTime as X, parseDuration as Y, AbortError as Z, findConfigFile as _, renderComparisonCsv as a, validateConfig as b, renderAnalysis as c, escapeControlInLines as d, errorMessage as et, formatCount as f, CONFIG_FILE_NAMES as g, supportsColor as h, renderAnalysisCsv as i, DEFAULT_STALE_AGE as j, compactAnalysis as k, renderComparison as l, createStyle as m, renderSkipsExplanation as n, renderAnalysisMarkdown as o, stringifyJson as p, CATEGORIES as q, renderAnalysisHtml as r, renderComparisonMarkdown as s, renderPathExplanation as t, escapeControl as u, loadConfig as v, explainPath as w, DEFAULT_EXPLAIN_LIMIT as x, buildJsonSchema as y, classify as z };
5510
+ export { extensionOf as $, CANDIDATE_DIGESTS as A, resolveScan as B, MAX_EXPLAIN_LIMIT as C, outsideRootError as D, isOutside as E, createProgressReporter as F, diskBytesOf as G, Excluder as H, resolveFeatures as I, rollUp as J, passesFilters as K, DEFAULT_CONCURRENCY as L, DEFAULT_LARGE_FILE_THRESHOLD as M, DEFAULT_STALE_AGE as N, compare as O, analyze as P, classify as Q, assertDirectory as R, EXPLAIN_VERSION as S, explainSkips as T, Scanner as U, DEFAULT_EXCLUDES as V, compareRelativePaths as W, comparePaths as X, scanError as Y, joinRelative as Z, findConfigFile as _, renderComparisonCsv as a, parseSize as at, validateConfig as b, renderAnalysis as c, parseDuration as ct, escapeControlInLines as d, DatError as dt, BUDGET_METRICS as et, formatCount as f, errorCode as ft, CONFIG_FILE_NAMES as g, supportsColor as h, renderAnalysisCsv as i, formatBytes as it, Collector as j, compactAnalysis as k, renderComparison as l, parsePointInTime as lt, createStyle as m, renderSkipsExplanation as n, formatBudgetActual as nt, renderAnalysisMarkdown as o, CATEGORIES as ot, stringifyJson as p, errorMessage as pt, relativePathOf as q, renderAnalysisHtml as r, parseBudget as rt, renderComparisonMarkdown as s, VERSION as st, renderPathExplanation as t, evaluateBudgets as tt, escapeControl as u, AbortError as ut, loadConfig as v, explainPath as w, DEFAULT_EXPLAIN_LIMIT as x, buildJsonSchema as y, listDirectories as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dir-analysis-tool",
3
- "version": "3.5.6",
3
+ "version": "3.5.8",
4
4
  "description": "Fast, zero-dependency directory analysis for your terminal and CI: largest folders and files, type and extension breakdowns, staged duplicate detection, size budgets, directory diffs, and self-contained HTML, Markdown, JSON, and CSV reports.",
5
5
  "type": "module",
6
6
  "exports": {