How many "non-system" things sit directly at the vault root. * Loose .md files and ordinary subfolders both count — both are * strong signals the user organizes their vault flat-style. The * four system folders (inbox/quick/archive/trash), attachments, * and dotfiles are excluded.
(root: string)
| 66 | * four system folders (inbox/quick/archive/trash), attachments, |
| 67 | * and dotfiles are excluded. */ |
| 68 | async function countLooseRootContent(root: string): Promise<number> { |
| 69 | let entries: import('node:fs').Dirent[] |
| 70 | try { |
| 71 | entries = await fs.readdir(root, { withFileTypes: true }) |
| 72 | } catch { |
| 73 | return 0 |
| 74 | } |
| 75 | let count = 0 |
| 76 | for (const entry of entries) { |
| 77 | if (entry.name.startsWith('.')) continue |
| 78 | if (HIDDEN_PRIMARY_ROOT_NAMES.has(entry.name)) continue |
| 79 | if (entry.name === 'inbox') continue |
| 80 | if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) count += 1 |
| 81 | else if (entry.isDirectory()) count += 1 |
| 82 | } |
| 83 | return count |
| 84 | } |
| 85 | |
| 86 | /** Recursively count .md files under a given directory. Used to see |
| 87 | * whether `<root>/inbox/` actually has content. */ |
no outgoing calls
no test coverage detected