MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / countLooseRootContent

Function countLooseRootContent

apps/desktop/src/mcp/vault-ops.ts:68–84  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

66 * four system folders (inbox/quick/archive/trash), attachments,
67 * and dotfiles are excluded. */
68async 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. */

Callers 1

readPrimaryNotesLocationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected