(root: string)
| 120 | * that succeeded. |
| 121 | */ |
| 122 | export async function readPrimaryNotesLocation(root: string): Promise<PrimaryNotesLocation> { |
| 123 | const [rootContent, inboxNotes, explicit] = await Promise.all([ |
| 124 | countLooseRootContent(root), |
| 125 | countMdFilesRecursively(path.join(root, 'inbox')), |
| 126 | readExplicitPrimaryNotesLocation(root) |
| 127 | ]) |
| 128 | |
| 129 | // Strong layout signal — root has user-organized content (loose |
| 130 | // .md files, custom subfolders). The vault is laid out flat. |
| 131 | if (rootContent >= 1) return 'root' |
| 132 | |
| 133 | // Strong layout signal — only inbox/ has notes, root is empty or |
| 134 | // just system folders. Classic ZenNotes lifecycle layout. |
| 135 | if (inboxNotes >= 1) return 'inbox' |
| 136 | |
| 137 | // Ambiguous (empty vault). Trust the explicit setting if present, |
| 138 | // otherwise default to inbox (matches a fresh ZenNotes install). |
| 139 | return explicit ?? 'inbox' |
| 140 | } |
| 141 | |
| 142 | /** The absolute directory that holds notes for a given top-level |
| 143 | * folder, taking the vault's primaryNotesLocation into account. */ |
no test coverage detected