Imported from mnaoumov/obsidian-root-folder-context-menu (
AGENTS.md). Install upstream withnpx skills add mnaoumov/obsidian-root-folder-context-menu. Copyright stays with the author.
AGENTS.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
Root Folder Context Menu enables the right-click context menu for the vault root folder in Obsidian's File Explorer, which Obsidian normally only offers for non-root folders. It is built on obsidian-dev-utils.
Commands
| Task | Command |
|---|---|
| TypeScript check | npm run build:compile |
| Build | npm run build |
| Dev (watch) | npm run dev |
| Lint | npm run lint |
| Lint (fix) | npm run lint:fix |
| Format | npm run format |
| Format (check) | npm run format:check |
| Spellcheck | npm run spellcheck |
| Markdown lint | npm run lint:md |
| Markdown lint fix | npm run lint:md:fix |
| Unit tests | npm test |
| Coverage | npm run test:coverage |
| Integration tests | npm run test:integration |
| Branch gate | npm run gate |
| Commit (wizard) | npm run commit |
Architecture
- Root config files are thin re-exports — actual logic lives in
scripts/(eslint.config.mts→scripts/eslint-config.ts, etc.). src/— plugin source:main.ts— Obsidian entry point (default export ofPlugin).plugin.ts—PluginextendsPluginBase; itsonloadImpladds theRootFolderContextMenuComponentchild.root-folder-context-menu-component.ts—LayoutReadyComponentholding the core logic: resolves the File Explorer plugin/view (disabling itself if File Explorer is off), wirescontextmenuhandlers on the root anchor and nav-files container, filters disallowed items (move/delete/copy/rename/search) out of the root folder'sfile-menu, and reloads the File Explorer.- The root anchor is per-platform —
ROOT_ANCHOR_SELECTORSis tried in order:.workspace-drawer-vault-switcher(the vault profile at the bottom of the desktop left sidebar, built insideif (isDesktopApp)) then.workspace-drawer-header-name(the vault-name row at the top of the mobile left drawer). The class name of the first reads mobile but the element is desktop-only, which is how the mobile half stayed broken unnoticed; the nav-files hook is nested inside the anchor'sif, so a null anchor kills both listeners at once. Both platforms are covered end-to-end byplugin.desktop.integration.test.ts/plugin.android.integration.test.ts.
- The root anchor is per-platform —
patches/file-explorer-view-open-file-context-menu-patch-component.ts—MonkeyAroundComponentthat monkey-patchesFileExplorerView.openFileContextMenuso the rootTFolderis temporarily treated as non-root, making Obsidian build the context menu for it.
mainfield points tosrc/main.ts(Obsidian plugin source entry; built artifact isdist/build/main.js, not published to npm).